# This is derived from the user-selected compiler class YaskCompiler(configuration['compiler'].__class__): def __init__(self, *args, **kwargs): kwargs['cpp'] = True kwargs['suffix'] = configuration['compiler'].suffix super(YaskCompiler, self).__init__(*args, **kwargs) self.cflags = [i for i in configuration['compiler'].cflags if not i.startswith('-std')] + ['-std=c++11'] # Tell the compiler where to get YASK header files and shared objects self.include_dirs.append(os.path.join(namespace['path'], 'include')) self.library_dirs.append(namespace['yask-lib']) self.ldflags.append('-Wl,-rpath,%s' % namespace['yask-lib']) yask_configuration = Parameters('yask') yask_configuration.add('compiler', YaskCompiler()) callback = lambda i: eval(i) if i else () yask_configuration.add('folding', (), callback=callback, impacts_jit=False) yask_configuration.add('blockshape', (), callback=callback, impacts_jit=False) yask_configuration.add('clustering', (), callback=callback, impacts_jit=False) yask_configuration.add('options', None, impacts_jit=False) yask_configuration.add('dump', None, impacts_jit=False) env_vars_mapper = { 'DEVITO_YASK_FOLDING': 'folding', 'DEVITO_YASK_BLOCKING': 'blockshape', 'DEVITO_YASK_CLUSTERING': 'clustering', 'DEVITO_YASK_OPTIONS': 'options', 'DEVITO_YASK_DUMP': 'dump' }
class YaskCompiler(configuration['compiler'].__class__): def __init__(self, *args, **kwargs): super(YaskCompiler, self).__init__(*args, **kwargs) # Switch to C++ self.cc = self.cpp_mapper[configuration['compiler'].cc] self.ld = self.cpp_mapper[configuration['compiler'].ld] self.cflags = configuration['compiler'].cflags + ['-std=c++11'] self.src_ext = 'cpp' # Tell the compiler where to get YASK header files and shared objects self.include_dirs.append(os.path.join(namespace['path'], 'include')) self.library_dirs.append(os.path.join(namespace['path'], 'lib')) self.ldflags.append('-Wl,-rpath,%s' % os.path.join(namespace['path'], 'lib')) yask_configuration = Parameters('yask') yask_configuration.add('compiler', YaskCompiler()) callback = lambda i: eval(i) if i else () yask_configuration.add('autotuning', 'runtime', ['off', 'runtime', 'preemptive']) yask_configuration.add('folding', (), callback=callback) yask_configuration.add('blockshape', (), callback=callback) yask_configuration.add('clustering', (), callback=callback) yask_configuration.add('options', None) yask_configuration.add('dump', None) # In develop-mode, no optimizations are applied to the generated code (e.g., SIMD). # When switching to non-develop-mode, optimizations are automatically switched on, # sniffing the highest Instruction Set Architecture level available on the architecture def switch_cpu(develop_mode):
class YaskCompiler(configuration['compiler'].__class__): def __init__(self, *args, **kwargs): super(YaskCompiler, self).__init__(*args, **kwargs) # Switch to C++ self.cc = self.cpp_mapper[configuration['compiler'].cc] self.ld = self.cpp_mapper[configuration['compiler'].ld] self.cflags = configuration['compiler'].cflags + ['-std=c++11'] self.src_ext = 'cpp' # Tell the compiler where to get YASK header files and shared objects self.include_dirs.append(os.path.join(namespace['path'], 'include')) self.library_dirs.append(os.path.join(namespace['path'], 'lib')) self.ldflags.append('-Wl,-rpath,%s' % os.path.join(namespace['path'], 'lib')) yask_configuration = Parameters('YASK-Configuration') yask_configuration.add('compiler', YaskCompiler()) yask_configuration.add('python-exec', False, [False, True]) # Set the Instruction Set Architecture used by the YASK code generator isa, ISAs = 'cpp', ['cpp', 'avx', 'avx2', 'avx512', 'knc'] yask_configuration.add('isa', isa, ISAs) # Currently YASK also require the CPU architecture (e.g., snb for sandy bridge, # hsw for haswell, etc.). At the moment, we simply infer it from the ISA arch_mapper = {'cpp': 'intel64', 'avx': 'snb', 'avx2': 'hsw', 'avx512': 'knl'} yask_configuration.add('arch', arch_mapper[isa], arch_mapper.values()) # In develop-mode, no optimizations are applied to the generated code (e.g., SIMD) # When switching to non-develop-mode, optimizations are automatically switched on, # sniffing the highest Instruction Set Architecture level available on the current # machine and providing it to YASK
""" The ``ops`` Devito backend uses the OPS library to generate, JIT-compile, and run kernels on multiple architectures. """ from devito.dle import (BasicRewriter, AdvancedRewriter, AdvancedRewriterSafeMath, SpeculativeRewriter, init_dle) from devito.parameters import Parameters, add_sub_configuration ops_configuration = Parameters('ops') env_vars_mapper = {} add_sub_configuration(ops_configuration, env_vars_mapper) # Initialize the DLE modes = {'basic': BasicRewriter, 'advanced': AdvancedRewriter, 'advanced-safemath': AdvancedRewriterSafeMath, 'speculative': SpeculativeRewriter} init_dle(modes) # The following used by backends.backendSelector from devito.ops.operator import OperatorOPS as Operator # noqa from devito.types.constant import * # noqa from devito.types.dense import * # noqa from devito.types.sparse import * # noqa from devito.types.basic import CacheManager # noqa from devito.types.grid import Grid # noqa
""" The ``core`` Devito backend is simply a "shadow" of the ``base`` backend, common to all other backends. The ``core`` backend (and therefore the ``base`` backend as well) are used to run Devito on standard CPU architectures. """ from devito.parameters import Parameters, add_sub_configuration core_configuration = Parameters('core') core_configuration.add('autotuning', 'basic', ['none', 'basic', 'aggressive']) env_vars_mapper = { 'DEVITO_AUTOTUNING': 'autotuning', } add_sub_configuration(core_configuration, env_vars_mapper) # The following used by backends.backendSelector from devito.function import ( Constant, Function, TimeFunction, SparseFunction, # noqa SparseTimeFunction) from devito.core.operator import Operator # noqa from devito.types import CacheManager # noqa
from devito.archinfo import Cpu64, Intel64, Arm, Power, Device from devito.core.cpu import (CPU64NoopOperator, CPU64Operator, Intel64Operator, Intel64FSGOperator, ArmOperator, PowerOperator, CustomOperator) from devito.core.gpu_openmp import (DeviceOpenMPNoopOperator, DeviceOpenMPOperator, DeviceOpenMPCustomOperator) from devito.operator.registry import operator_registry from devito.parameters import Parameters, add_sub_configuration core_configuration = Parameters('core') add_sub_configuration(core_configuration) # Add core-specific Operators operator_registry.add(CPU64NoopOperator, Cpu64, 'noop') operator_registry.add(CPU64Operator, Cpu64, 'advanced') operator_registry.add(CustomOperator, Cpu64, 'custom') operator_registry.add(CPU64NoopOperator, Intel64, 'noop') operator_registry.add(Intel64Operator, Intel64, 'advanced') operator_registry.add(Intel64FSGOperator, Intel64, 'advanced-fsg') operator_registry.add(CustomOperator, Intel64, 'custom') operator_registry.add(CPU64NoopOperator, Arm, 'noop') operator_registry.add(ArmOperator, Arm, 'advanced') operator_registry.add(CustomOperator, Arm, 'custom') operator_registry.add(CPU64NoopOperator, Power, 'noop') operator_registry.add(PowerOperator, Power, 'advanced') operator_registry.add(CustomOperator, Power, 'custom') operator_registry.add(DeviceOpenMPNoopOperator, Device, 'noop')
The ``ops`` Devito backend uses the OPS library to generate, JIT-compile, and run kernels on multiple architectures. """ from devito.archinfo import Cpu64 from devito.dle import PlatformRewriter, modes from devito.parameters import Parameters, add_sub_configuration # Add OPS-specific DLE modes modes.add( Cpu64, { 'noop': PlatformRewriter, 'advanced': PlatformRewriter, 'speculative': PlatformRewriter }) # The following used by backends.backendSelector from devito.ops.compiler import CompilerOPS as Compiler # noqa ops_configuration = Parameters('ops') ops_configuration.add('compiler', Compiler()) env_vars_mapper = {} add_sub_configuration(ops_configuration, env_vars_mapper) from devito.ops.operator import OperatorOPS as Operator # noqa from devito.types.constant import * # noqa from devito.types.dense import * # noqa from devito.types.sparse import * # noqa from devito.types.basic import CacheManager # noqa from devito.types.grid import Grid # noqa
def __init__(self, *args, **kwargs): kwargs['cpp'] = True kwargs['suffix'] = configuration['compiler'].suffix super(YaskCompiler, self).__init__(*args, **kwargs) self.cflags = [ i for i in configuration['compiler'].cflags if not i.startswith('-std') ] + ['-std=c++11'] # Tell the compiler where to get YASK header files and shared objects self.include_dirs.append(os.path.join(namespace['path'], 'include')) self.library_dirs.append(os.path.join(namespace['path'], 'lib')) self.ldflags.append('-Wl,-rpath,%s' % os.path.join(namespace['path'], 'lib')) yask_configuration = Parameters('yask') yask_configuration.add('compiler', YaskCompiler()) callback = lambda i: eval(i) if i else () yask_configuration.add('autotuning', 'runtime', ['off', 'runtime', 'preemptive']) yask_configuration.add('folding', (), callback=callback) yask_configuration.add('blockshape', (), callback=callback) yask_configuration.add('clustering', (), callback=callback) yask_configuration.add('options', None) yask_configuration.add('dump', None) env_vars_mapper = { 'DEVITO_YASK_AUTOTUNING': 'autotuning', 'DEVITO_YASK_FOLDING': 'folding', 'DEVITO_YASK_BLOCKING': 'blockshape', 'DEVITO_YASK_CLUSTERING': 'clustering',
""" The ``ops`` Devito backend uses the OPS library to generate, JIT-compile, and run kernels on multiple architectures. """ from devito.archinfo import Cpu64 from devito.dle import PlatformRewriter, modes from devito.parameters import Parameters, add_sub_configuration ops_configuration = Parameters('ops') ops_configuration.add('target', 'CUDA', accepted=('CUDA', 'OpenMP', 'MPI')) env_vars_mapper = { 'DEVITO_OPS_TARGET': 'target', } add_sub_configuration(ops_configuration, env_vars_mapper) # Add OPS-specific DLE modes modes.add(Cpu64, { 'advanced': PlatformRewriter, 'speculative': PlatformRewriter }) # The following used by backends.backendSelector from devito.ops.operator import OperatorOPS as Operator # noqa from devito.types.constant import * # noqa from devito.types.dense import * # noqa from devito.types.sparse import * # noqa from devito.types.basic import CacheManager # noqa from devito.types.grid import Grid # noqa
class YaskCompiler(configuration['compiler'].__class__): def __init__(self, *args, **kwargs): super(YaskCompiler, self).__init__(*args, **kwargs) # Switch to C++ self.cc = self.cpp_mapper[configuration['compiler'].cc] self.ld = self.cpp_mapper[configuration['compiler'].ld] self.cflags = configuration['compiler'].cflags + ['-std=c++11'] self.src_ext = 'cpp' # Tell the compiler where to get YASK header files and shared objects self.include_dirs.append(os.path.join(namespace['path'], 'include')) self.library_dirs.append(os.path.join(namespace['path'], 'lib')) self.ldflags.append('-Wl,-rpath,%s' % os.path.join(namespace['path'], 'lib')) yask_configuration = Parameters('yask') yask_configuration.add('compiler', YaskCompiler()) yask_configuration.add('python-exec', False, [False, True]) callback = lambda i: eval(i) if i else () yask_configuration.add('folding', (), callback=callback) yask_configuration.add('blockshape', (), callback=callback) yask_configuration.add('clustering', (), callback=callback) yask_configuration.add('options', None) yask_configuration.add('dump', None) # In develop-mode, no optimizations are applied to the generated code (e.g., SIMD). # When switching to non-develop-mode, optimizations are automatically switched on, # sniffing the highest Instruction Set Architecture level available on the architecture def switch_cpu(develop_mode): if bool(develop_mode) is False: