Skip to content

Commit 01f38d9

Browse files
committed
rkcommon, zstd
1 parent 5e67c46 commit 01f38d9

File tree

4 files changed

+130
-0
lines changed

4 files changed

+130
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff -u -Nr -U5 rkcommon-1.7.0/rkcommon/tasking/detail/tasking_system_init.cpp rkcommon-1.7.0.force-no-simd/rkcommon/tasking/detail/tasking_system_init.cpp
2+
--- rkcommon-1.7.0/rkcommon/tasking/detail/tasking_system_init.cpp 2021-08-11 14:43:39.000000000 -0400
3+
+++ rkcommon-1.7.0.force-no-simd/rkcommon/tasking/detail/tasking_system_init.cpp 2023-09-13 10:04:24.917412619 -0400
4+
@@ -76,11 +76,11 @@
5+
static std::unique_ptr<tasking_system_handle> g_tasking_handle;
6+
7+
void initTaskingSystem(int numThreads, bool flushDenormals)
8+
{
9+
if (flushDenormals) {
10+
- _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
11+
- _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
12+
+ /* _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); */
13+
+ /* _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); */
14+
}
15+
16+
g_tasking_handle = make_unique<tasking_system_handle>(numThreads);
17+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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);

projects/rkcommon.cmake

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
superbuild_add_project(rkcommon
2+
LICENSE_FILES
3+
LICENSE.txt
4+
SPDX_LICENSE_IDENTIFIER
5+
Apache-2.0
6+
SPDX_COPYRIGHT_TEXT
7+
"Copyright Intel Corporation"
8+
DEPENDS cxx11 tbb
9+
CMAKE_ARGS
10+
-DBUILD_TESTING:BOOL=OFF
11+
-DCMAKE_INSTALL_LIBDIR:STRING=lib
12+
-DCMAKE_INSTALL_NAME_DIR:PATH=<INSTALL_DIR>/lib
13+
-DINSTALL_DEPS:BOOL=OFF
14+
-DCMAKE_INSTALL_RPATH=<INSTALL_DIR>/lib
15+
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
16+
# Disable SIMD support here. This avoids setting floating point rounding
17+
# mode to "towards zero" which ends up making `numpy` unimportable on
18+
# macOS x86_64 (but almost certainly affects it on other Intel-based
19+
# platforms).
20+
# See: https://github.com/numpy/numpy/issues/20895
21+
# See: https://github.com/ospray/rkcommon/issues/9
22+
-DRKCOMMON_NO_SIMD:BOOL=ON
23+
)
24+
25+
if (ospray_SOURCE_SELECTION STREQUAL "2.12.0")
26+
# https://github.com/ospray/rkcommon/pull/10
27+
superbuild_apply_patch(rkcommon force-no-simd
28+
"Force SIMD off even with TBB")
29+
else ()
30+
superbuild_apply_patch(rkcommon 1.7.0-force-no-simd
31+
"Force SIMD off even with TBB")
32+
endif ()

projects/zstd.cmake

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
set(zstd_static_libs ON)
2+
if (BUILD_SHARED_LIBS)
3+
set(zstd_static_libs OFF)
4+
endif ()
5+
6+
superbuild_add_project(zstd
7+
CAN_USE_SYSTEM
8+
LICENSE_FILES
9+
LICENSE
10+
SPDX_LICENSE_IDENTIFIER
11+
"BSD-3-Clause"
12+
SPDX_COPYRIGHT_TEXT
13+
"Copyright (c) Meta Platforms, Inc. and affiliates"
14+
SOURCE_SUBDIR build/cmake
15+
CMAKE_ARGS
16+
-DBUILD_TESTING:BOOL=OFF
17+
-DZSTD_BUILD_SHARED:BOOL=${BUILD_SHARED_LIBS}
18+
-DZSTD_BUILD_STATIC:BOOL=${zstd_static_libs}
19+
-DZSTD_LEGACY_SUPPORT:BOOL=OFF
20+
-DZSTD_MULTITHREAD_SUPPORT:BOOL=ON
21+
-DZSTD_BUILD_PROGRAMS:BOOL=OFF
22+
-DZSTD_BUILD_CONTRIB:BOOL=OFF
23+
-DCMAKE_MACOSX_RPATH:BOOL=FALSE
24+
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
25+
-DCMAKE_INSTALL_LIBDIR:PATH=lib
26+
-DCMAKE_INSTALL_NAME_DIR:PATH=<INSTALL_DIR>/lib)

0 commit comments

Comments
 (0)