Skip to content

Commit 4c88f0d

Browse files
authored
Move OMP flag to optionally, manually defined (#171)
In previous versions of SVS, the `SVS_ENABLE_OMP `flag was predefined as `OFF` in the SVS package. This PR allows users to manually configure the `SVS_ENABLE_OMP` flag in their CMake setup.
1 parent e525ed2 commit 4c88f0d

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ include("cmake/fmt.cmake")
7777
include("cmake/spdlog.cmake")
7878
include("cmake/toml.cmake")
7979

80-
if(SVS_ENABLE_OMP)
81-
include("cmake/openmp.cmake")
82-
endif()
83-
8480
add_library(svs_x86_options_base INTERFACE)
8581
add_library(svs::x86_options_base ALIAS svs_x86_options_base)
8682
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")

cmake/options.cmake

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ option(SVS_INITIALIZE_LOGGER
7373
ON # enabled by default
7474
)
7575

76-
option(SVS_ENABLE_OMP
77-
"Support OpenMP threadpool."
78-
OFF # disable by default
79-
)
80-
8176
#####
8277
##### Experimental
8378
#####
@@ -145,12 +140,6 @@ else()
145140
target_compile_options(${SVS_LIB} INTERFACE -DSVS_INITIALIZE_LOGGER=0)
146141
endif()
147142

148-
if (SVS_ENABLE_OMP)
149-
target_compile_options(${SVS_LIB} INTERFACE -DSVS_ENABLE_OMP=1)
150-
else()
151-
target_compile_options(${SVS_LIB} INTERFACE -DSVS_ENABLE_OMP=0)
152-
endif()
153-
154143
#####
155144
##### Helper target to apply relevant compiler optimizations.
156145
#####

include/svs/lib/preprocessor.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ consteval bool is_one_or_zero(const char* ptr) {
105105
return std::move(*this); \
106106
}
107107

108+
/////
109+
///// Optional flags
110+
/////
111+
#if defined(SVS_ENABLE_OMP)
112+
#define SVS_OMP 1
113+
#else
114+
#define SVS_OMP 0
115+
#endif
116+
117+
108118
/////
109119
///// Intel(R) AVX extensions
110120
/////

include/svs/lib/threads/threadpool.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#include <sstream>
2727
#include <vector>
2828

29-
SVS_VALIDATE_BOOL_ENV(SVS_ENABLE_OMP);
30-
#if SVS_ENABLE_OMP
29+
SVS_VALIDATE_BOOL_ENV(SVS_OMP);
30+
#if SVS_OMP
3131
#include <omp.h>
3232
#endif
3333

@@ -288,8 +288,8 @@ class SwitchNativeThreadPool {
288288
NativeThreadPool threadpool_;
289289
};
290290

291-
SVS_VALIDATE_BOOL_ENV(SVS_ENABLE_OMP);
292-
#if SVS_ENABLE_OMP
291+
SVS_VALIDATE_BOOL_ENV(SVS_OMP);
292+
#if SVS_OMP
293293
/////
294294
///// A thread pool that utilizes OpenMP for multithreading
295295
/////

0 commit comments

Comments
 (0)