@@ -128,6 +128,21 @@ if use_intel_sort and not fs.exists('src/npysort/x86-simd-sort/README.md')
128128 error (' Missing the `x86-simd-sort` git submodule! Run `git submodule update --init` to fix this.' )
129129endif
130130
131+ # openMP related settings:
132+ if get_option (' disable-threading' ) and get_option (' enable-openmp' )
133+ error (' Build options `disable-threading` and `enable-openmp` are conflicting. Please set at most one to true.' )
134+ endif
135+
136+ use_openmp = get_option (' enable-openmp' ) and not get_option (' disable-threading' )
137+
138+ # Setup openmp flags for x86-simd-sort:
139+ omp = []
140+ omp_dep = []
141+ if use_intel_sort and use_openmp
142+ omp = dependency (' openmp' , required : true )
143+ omp_dep = declare_dependency (dependencies : omp, compile_args : [' -DXSS_USE_OPENMP' ])
144+ endif
145+
131146if not fs.exists(' src/common/pythoncapi-compat' )
132147 error (' Missing the `pythoncapi-compat` git submodule! ' +
133148 ' Run `git submodule update --init` to fix this.' )
@@ -867,12 +882,15 @@ foreach gen_mtargets : [
867882 ] : []
868883 ],
869884]
885+
886+
887+
870888 mtargets = mod_features.multi_targets(
871889 gen_mtargets[0 ], multiarray_gen_headers + gen_mtargets[1 ],
872890 dispatch : gen_mtargets[2 ],
873891 # baseline: CPU_BASELINE, it doesn't provide baseline fallback
874892 prefix : ' NPY_' ,
875- dependencies : [py_dep, np_core_dep],
893+ dependencies : [py_dep, np_core_dep, omp_dep ],
876894 c_args : c_args_common + max_opt,
877895 cpp_args : cpp_args_common + max_opt,
878896 include_directories : [
@@ -1286,7 +1304,7 @@ py.extension_module('_multiarray_umath',
12861304 ' src/umath' ,
12871305 ' src/highway'
12881306 ],
1289- dependencies : [blas_dep],
1307+ dependencies : [blas_dep, omp ],
12901308 link_with : [
12911309 npymath_lib,
12921310 unique_hash_so,
0 commit comments