Skip to content

Commit

Permalink
Setup optimization blaze defines globally
Browse files Browse the repository at this point in the history
  • Loading branch information
ankith26 committed Jul 10, 2024
1 parent 7d45e74 commit f1eaef8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
37 changes: 37 additions & 0 deletions backend/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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')

Expand Down
6 changes: 3 additions & 3 deletions backend/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit f1eaef8

Please sign in to comment.