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 def reset_yask_isa(develop_mode):
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' }
""" 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
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): if bool(develop_mode) is False:
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
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', 'DEVITO_YASK_OPTIONS': 'options',
""" 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
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: isa, platform = infer_cpu()
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]) yask_configuration.add('develop-mode', True, [False, True]) # Sniff the highest Instruction Set Architecture level that we can YASK to use isa, ISAs = 'cpp', ['cpp', 'avx', 'avx2', 'avx512', 'knc'] if yask_configuration['develop-mode'] is False: cpu_flags = cpuinfo.get_cpu_info()['flags'] for i in reversed(ISAs): if i in cpu_flags: isa = i break 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())