|
| 1 | +From ec09862dac870c1b66dbb578bb892401a7455780 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ben Boeckel < [email protected]> |
| 3 | +Date: Mon, 11 Sep 2023 08:17:21 -0400 |
| 4 | +Subject: [PATCH] tasking_system_init: force SIMD off with `RKCOMMON_NO_SIMD` |
| 5 | + |
| 6 | +When the TBB backend is in use, the intrinsics headers are included |
| 7 | +through them. Instead of checking "do we already have the macros set", |
| 8 | +just force them to be no-op macro expansions via a local macro name |
| 9 | +instead when `RKCOMMON_NO_SIMD` is requested. |
| 10 | + |
| 11 | +Fixes: #9 |
| 12 | +--- |
| 13 | + rkcommon/tasking/detail/tasking_system_init.cpp | 16 ++++++++++------ |
| 14 | + 1 file changed, 10 insertions(+), 6 deletions(-) |
| 15 | + |
| 16 | +diff --git a/rkcommon/tasking/detail/tasking_system_init.cpp b/rkcommon/tasking/detail/tasking_system_init.cpp |
| 17 | +index f63e162..67aca08 100644 |
| 18 | +--- a/rkcommon/tasking/detail/tasking_system_init.cpp |
| 19 | ++++ b/rkcommon/tasking/detail/tasking_system_init.cpp |
| 20 | +@@ -33,16 +33,20 @@ |
| 21 | + #define _MM_SET_DENORMALS_ZERO_MODE(x) \ |
| 22 | + (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x))) |
| 23 | + #endif |
| 24 | ++ |
| 25 | ++#define RKCOMMON_MM_SET_DENORMALS_ZERO_MODE(x) \ |
| 26 | ++ _MM_SET_DENORMALS_ZERO_MODE(x) |
| 27 | ++#define RKCOMMON_MM_SET_FLUSH_ZERO_MODE(x) \ |
| 28 | ++ _MM_SET_FLUSH_ZERO_MODE(x) |
| 29 | ++ |
| 30 | + #else |
| 31 | +-#if !defined(_MM_SET_DENORMALS_ZERO_MODE) |
| 32 | +-#define _MM_SET_FLUSH_ZERO_MODE(x) \ |
| 33 | ++#define RKCOMMON_MM_SET_FLUSH_ZERO_MODE(x) \ |
| 34 | + do { \ |
| 35 | + } while (0) |
| 36 | +-#define _MM_SET_DENORMALS_ZERO_MODE(x) \ |
| 37 | ++#define RKCOMMON_MM_SET_DENORMALS_ZERO_MODE(x) \ |
| 38 | + do { \ |
| 39 | + } while (0) |
| 40 | + #endif |
| 41 | +-#endif |
| 42 | + |
| 43 | + // rkcommon |
| 44 | + #include "../../common.h" |
| 45 | +@@ -91,8 +95,8 @@ namespace rkcommon { |
| 46 | + void initTaskingSystem(int numThreads, bool flushDenormals) |
| 47 | + { |
| 48 | + if (flushDenormals) { |
| 49 | +- _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); |
| 50 | +- _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); |
| 51 | ++ RKCOMMON_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); |
| 52 | ++ RKCOMMON_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); |
| 53 | + } |
| 54 | + |
| 55 | + g_tasking_handle = make_unique<tasking_system_handle>(numThreads); |
0 commit comments