MAINT: Cleanup makefile to meson for parallel opt

Needs some work
This commit is contained in:
Rohit Goswami 2024-04-08 03:57:26 +00:00 committed by Mateusz Sokół
parent ec9f6504d6
commit 97861ab436
4 changed files with 48 additions and 14 deletions

View File

@ -83,10 +83,6 @@ _static_libs += static_library(
'rot.c',
include_directories: _inc,
c_args: [_cargs,
'-DSMP_SERVER',
'-DNO_WARMUP',
'-DMAX_CPU_NUMBER=12',
'-DMAX_PARALLEL_NUMBER=1',
'-DBUILD_SINGLE=1',
'-DBUILD_DOUBLE=1',
'-DBUILD_COMPLEX=1',
@ -97,10 +93,8 @@ _static_libs += static_library(
'-DCNAME=cblas_drot',
'-DCHAR_NAME="cblas_drot_"',
'-DCHAR_CNAME="cblas_drot"',
'-DNO_AFFINITY',
'-DDOUBLE',
'-UCOMPLEX',
'-DCBLAS',],
'-UCOMPLEX',],
)
_interface = static_library('_interface',

View File

@ -786,10 +786,6 @@ _configs = [
'undef': ['COMPLEX', 'COMPLEX'],
'def': ['DOUBLE'],
'addl': [fma3_flag,
'-DSMP_SERVER',
'-DNO_WARMUP',
'-DMAX_CPU_NUMBER=12',
'-DMAX_PARALLEL_NUMBER=1',
'-DBUILD_SINGLE=1',
'-DBUILD_DOUBLE=1',
'-DBUILD_COMPLEX=1',
@ -800,10 +796,8 @@ _configs = [
'-DCNAME=drot_k',
'-DCHAR_NAME="drot_k_"',
'-DCHAR_CNAME="drot_k"',
'-DNO_AFFINITY',
'-DDOUBLE',
'-UCOMPLEX',
'-DCBLAS',
]},
# {'name': 'qrot_k',
# 'undef': ['COMPLEX', 'COMPLEX'],

View File

@ -201,9 +201,47 @@ add_project_arguments(simd_cargs, language: 'c')
symnames = ['ASMNAME', 'ASMFNAME', 'NAME', 'CNAME', 'CHAR_NAME', 'CHAR_CNAME']
# Other common options, move later
# Undefine to help prevent clashes
foreach symb : symnames
_cargs += f'-U@symb@'
endforeach
# Based on options
if not build_without_cblas
_cargs += '-DCBLAS'
endif
if no_affinity
_cargs += '-DNO_AFFINITY'
endif
if no_warmup
_cargs += '-DNO_WARMUP'
endif
# Parallel builds
# TODO: This can be cleaned up significantly
# Also use multiprocessing.cpu_count()
# TODO: Handle SMP_SERVER
num_parallel = get_option('num_parallel')
if num_parallel > 1
_cargs += f'-DMAX_PARALLEL_NUMBER=@num_parallel@'
endif
num_cores = get_option('num_cores')
if num_cores > 0
num_threads = num_cores
else
num_threads = 0
endif
use_thread = false
if num_threads > 2
use_thread = true
endif
if use_thread
message('Multi-threading enabled with ' + num_threads.to_string() + ' threads.')
_cargs += f'-DMAX_CPU_NUMBER=@num_threads@'
_cargs += f'-DSMP_SERVER'
else
if get_option('use_locking')
_cargs += '-DUSE_LOCKING'
endif
endif
# Ignoring other hostarch checks and conflicts for arch in BSD for now

View File

@ -4,13 +4,21 @@ option('build_lapack_deprecated', type: 'boolean', value: true, description: 'Wh
option('build_testing', type: 'boolean', value: true, description: 'Build LAPACK testsuite when building LAPACK')
option('use_c_lapack', type: 'boolean', value: false, description: 'Build LAPACK from C sources instead of the original Fortran')
option('build_without_cblas', type: 'boolean', value: false, description: 'Do not build the C interface (CBLAS) to the BLAS functions')
option('use_locking', type: 'boolean', value: false, description: 'Use locks even in single-threaded builds to make them callable from multiple threads')
option('use_perl', type: 'boolean', value: false, description: 'Use the older PERL scripts for build preparation instead of universal shell scripts')
option('no_warmup', type: 'boolean', value: true, description: 'Do not run a benchmark on each startup just to find the best location for the memory buffer')
option('no_affinity', type: 'boolean', value: true, description: 'Disable support for CPU affinity masks to avoid binding processes from e.g. R or numpy/scipy to a single core')
option('build_cpp_thread_safety_test', type: 'boolean', value: false, description: 'Run a massively parallel DGEMM test to confirm thread safety of the library (requires OpenMP and about 1.3GB of RAM)')
option('build_cpp_thread_safety_gemv', type: 'boolean', value: false, description: 'Run a massively parallel DGEMV test to confirm thread safety of the library (requires OpenMP)')
option('build_static_libs', type: 'boolean', value: false, description: 'Build static library')
# Parallel options
option('num_cores', type: 'integer',
min: 1, value: 1, description: 'Number of CPUs')
option('num_parallel', type: 'integer',
min: 1, value: 1, description: 'Max CPU')
option('num_threads', type: 'integer',
min: 1, value: 12, description: 'Max threads')
option('use_locking', type: 'boolean', value: false,
description: 'Use locks even in single-threaded builds to make them callable from multiple threads')
# From Makefile
option('dynamic_arch', type: 'boolean', value: false, description: 'Include support for multiple CPU targets, with automatic selection at runtime (x86/x86_64, aarch64 or ppc only)')