From 915ac0c5fbed5e194835e22db8e27df812ac3efc Mon Sep 17 00:00:00 2001 From: Martin Larralde <martin.larralde@embl.de> Date: Tue, 9 Jul 2024 18:21:30 +0200 Subject: [PATCH] Implement detection of SSE flush modes in `setup.py` --- setup.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f31e8dfb..4f2f8050 100644 --- a/setup.py +++ b/setup.py @@ -459,7 +459,7 @@ class configure(_build_clib): except CompileError: _eprint("no") return False - except (subprocess.SubprocessError, OSError): + except Exception: _eprint("yes, but cannot run code") return True # assume we are cross-compiling, and still build else: @@ -519,6 +519,30 @@ class configure(_build_clib): """ ) + def _check_denormals_zero_mode(self): + return self._check_simd_generic( + "denormals-are-zero", + program=""" + #include <pmmintrin.h> + int main(int argc, const char** argv) { + _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); + return 0; + } + """ + ) + + def _check_flush_zero_mode(self): + return self._check_simd_generic( + "flush-to-zero", + program=""" + #include <xmmintrin.h> + int main(int argc, const char** argv) { + _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); + return 0; + } + """ + ) + # --- Required interface for `setuptools.Command` --- def build_libraries(self, libraries): @@ -598,6 +622,13 @@ class configure(_build_clib): if not supported_feature: raise RuntimeError("failed to compile platform-specific code, aborting.") + # check zeroing mode for SSE code + if self.hmmer_impl == "SSE": + if self._check_denormals_zero_mode(): + defines["HAVE_DENORMALS_ZERO_MODE"] = 1 + if self._check_flush_zero_mode(): + defines["HAVE_FLUSH_ZERO_MODE"] = 1 + # fill the defines if headers are found headers = headers or [] for header in headers: -- GitLab