summaryrefslogtreecommitdiff
path: root/numpy/distutils/command/build_clib.py
diff options
context:
space:
mode:
authorSayed Adel <seiko@imavr.com>2021-04-22 21:35:53 +0200
committerSayed Adel <seiko@imavr.com>2021-04-22 23:11:45 +0200
commit2d9e75f3a1dbe21de6b53cd2996e45054d3b86c5 (patch)
treef64637902e4838f233776e25449c3b86f5de97e1 /numpy/distutils/command/build_clib.py
parentbc59c81e55c0ae184be9ab3859dc6df41dab937c (diff)
downloadnumpy-2d9e75f3a1dbe21de6b53cd2996e45054d3b86c5.tar.gz
ENH, SIMD: Add support for dispatching C++ sources
Same usage as the C dispatch-able sources except files extensions should be `.dispatcher.cpp` or `.dispatch.cxx` rather than `.dispatch.c`
Diffstat (limited to 'numpy/distutils/command/build_clib.py')
-rw-r--r--numpy/distutils/command/build_clib.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/numpy/distutils/command/build_clib.py b/numpy/distutils/command/build_clib.py
index 1b3004c2f..a4f49b00e 100644
--- a/numpy/distutils/command/build_clib.py
+++ b/numpy/distutils/command/build_clib.py
@@ -271,6 +271,7 @@ class build_clib(old_build_clib):
# filtering C dispatch-table sources when optimization is not disabled,
# otherwise treated as normal sources.
copt_c_sources = []
+ copt_cxx_sources = []
copt_baseline_flags = []
copt_macros = []
if not self.disable_optimization:
@@ -280,15 +281,34 @@ class build_clib(old_build_clib):
include_dirs.append(dispatch_hpath)
copt_build_src = None if self.inplace else bsrc_dir
- copt_c_sources = [
- c_sources.pop(c_sources.index(src))
- for src in c_sources[:] if src.endswith(".dispatch.c")
- ]
+ for _srcs, _dst, _ext in (
+ ((c_sources,), copt_c_sources, ('.dispatch.c',)),
+ ((c_sources, cxx_sources), copt_cxx_sources,
+ ('.dispatch.cpp', '.dispatch.cxx'))
+ ):
+ for _src in _srcs:
+ _dst += [
+ _src.pop(_src.index(s))
+ for s in _src[:] if s.endswith(_ext)
+ ]
copt_baseline_flags = self.compiler_opt.cpu_baseline_flags()
else:
copt_macros.append(("NPY_DISABLE_OPTIMIZATION", 1))
objects = []
+ if copt_cxx_sources:
+ log.info("compiling C++ dispatch-able sources")
+ objects += self.compiler_opt.try_dispatch(
+ copt_c_sources,
+ output_dir=self.build_temp,
+ src_dir=copt_build_src,
+ macros=macros + copt_macros,
+ include_dirs=include_dirs,
+ debug=self.debug,
+ extra_postargs=extra_postargs,
+ ccompiler=cxx_compiler
+ )
+
if copt_c_sources:
log.info("compiling C dispatch-able sources")
objects += self.compiler_opt.try_dispatch(copt_c_sources,