diff --git a/backend/meson.build b/backend/meson.build index 4c5cce8f..dc97db5f 100644 --- a/backend/meson.build +++ b/backend/meson.build @@ -12,6 +12,40 @@ cc = meson.get_compiler('cpp') py = import('python').find_installation(pure: false) py_dep = py.dependency() +# set up global defines to optimize blaze usages +add_global_arguments( + # - Enable external BLAS kernels + '-DBLAZE_BLAS_MODE=0', + # - Set default matrix storage order to column-major, since many of our + # functions are implemented for column-major layout. This default reduces + # conversions. + '-DBLAZE_DEFAULT_STORAGE_ORDER=blaze::rowMajor', + # - Disable SMP parallelization. This disables SMP parallelization for all + # possible backends (OpenMP, C++11 threads, Boost, HPX): + # https://bitbucket.org/blaze-lib/blaze/wiki/Serial%20Execution#!option-3-deactivation-of-parallel-execution + '-DBLAZE_USE_SHARED_MEMORY_PARALLELIZATION=0', + # - Disable MPI parallelization + '-DBLAZE_MPI_PARALLEL_MODE=0', + # - Using the default cache size, which may have been configured automatically + # by the Blaze CMake configuration for the machine we are running on. We + # could override it here explicitly to tune performance. + # BLAZE_CACHE_SIZE + '-DBLAZE_USE_PADDING=1', + # - Always enable non-temporal stores for cache optimization of large data + # structures: https://bitbucket.org/blaze-lib/blaze/wiki/Configuration%20Files#!streaming-non-temporal-stores + '-DBLAZE_USE_STREAMING=1', + # - Initializing default-constructed structures for fundamental types + '-DBLAZE_USE_DEFAULT_INITIALIZATON=1', + # Use Sleef for vectorization of more math functions + '-DBLAZE_USE_SLEEF=1', + # Set inlining settings + '-DBLAZE_USE_STRONG_INLINE=1', + '-DBLAZE_USE_ALWAYS_INLINE=1', + # Set vectorization (leave to 1, else there is no use for blaze) + '-DBLAZE_USE_VECTORIZATION=1', + language: 'cpp' +) + # find dependencies and create dep objects pybind11_dep = declare_dependency( include_directories: run_command( @@ -53,6 +87,9 @@ if not sleef_dep.found() ) endif +# blaze and deps commonly used together +blaze_deps = [blaze_dep, blaze_tensor_dep, sleef_dep] + brigand_dep = dependency('brigand', fallback : 'brigand') cxxopts_dep = dependency('cxxopts', fallback : 'cxxopts') diff --git a/backend/src/meson.build b/backend/src/meson.build index 42b030ee..fcbda76b 100644 --- a/backend/src/meson.build +++ b/backend/src/meson.build @@ -10,7 +10,7 @@ example_1 = py.extension_module( _linalg = py.extension_module( '_linalg', sources: ['_linalg.cpp'], - dependencies: [py_dep, pybind11_dep, blaze_dep, blaze_tensor_dep], + dependencies: [py_dep, pybind11_dep] + blaze_deps, link_language: 'cpp', install: true, subdir: package, @@ -19,7 +19,7 @@ _linalg = py.extension_module( _linalg_numpy = py.extension_module( '_linalg_numpy', sources: ['_linalg_numpy.cpp'], - dependencies: [py_dep, pybind11_dep, blaze_dep, blaze_tensor_dep], + dependencies: [py_dep, pybind11_dep] + blaze_deps, link_language: 'cpp', install: true, subdir: package, @@ -33,7 +33,7 @@ _PyArrays = py.extension_module( 'Utilities/Math/Python/BlazeMatrix.cpp', 'Utilities/Math/Python/BlazeTensor.cpp', ], - dependencies: [py_dep, pybind11_dep, blaze_dep, blaze_tensor_dep], + dependencies: [py_dep, pybind11_dep] + blaze_deps, link_language: 'cpp', install: true, subdir: package,