-
Notifications
You must be signed in to change notification settings - Fork 594
Expand file tree
/
Copy paththreading.cmake
More file actions
50 lines (48 loc) · 1.83 KB
/
threading.cmake
File metadata and controls
50 lines (48 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
if(MULTITHREADING)
message(STATUS "Multithreading is enabled.")
add_compile_options(-pthread)
add_link_options(-pthread)
if(WASM)
# Emscripten + pthreads. SHARED_MEMORY is implied by -pthread, but
# passing it explicitly makes the target memory shape obvious to
# readers of CMakeCache.txt.
add_link_options("SHELL:-sSHARED_MEMORY=1")
# Prevent indirect call type mismatch errors in thread_local destructors
# (without this the benchmark flow fails at destruction point for WASM)
add_compile_options(-fno-c++-static-destructors)
endif()
#add_compile_options(-fsanitize=thread)
#add_link_options(-fsanitize=thread)
else()
message(STATUS "Multithreading is disabled.")
add_definitions(-DNO_MULTITHREADING)
set(OMP_MULTITHREADING OFF)
if(WASM)
# Single-threaded wasm: bake out the pthread pool entirely. The
# toolchain enables -pthread by default; we override here.
add_compile_options(-pthread)
add_link_options(-pthread)
add_link_options("SHELL:-sPTHREAD_POOL_SIZE=0")
endif()
endif()
if(OMP_MULTITHREADING)
find_package(OpenMP REQUIRED)
message(STATUS "OMP multithreading is enabled.")
link_libraries(OpenMP::OpenMP_CXX)
add_definitions(-DOMP_MULTITHREADING)
else()
message(STATUS "OMP multithreading is disabled.")
endif()
if(ENABLE_PAR_ALGOS)
find_package(TBB QUIET OPTIONAL_COMPONENTS tbb)
if(${TBB_FOUND})
message(STATUS "std::execution parallel algorithms are enabled.")
link_libraries(TBB::tbb)
else()
message(STATUS "Could not locate Intel TBB, disabling std::execution parallel algorithms.")
add_definitions(-DNO_PAR_ALGOS)
endif()
else()
message(STATUS "std::execution parallel algorithms are disabled.")
add_definitions(-DNO_PAR_ALGOS)
endif()