-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NATIVECPU] NativeCPU with optional oneTBB backend #2627
base: main
Are you sure you want to change the base?
Changes from all commits
da5500c
0b8b0f7
88db20a
f64fc08
0b89dee
d111337
a1166d8
47b12a4
4b04ce6
5406b39
2e8ae3f
3c64917
eb1b1cc
d5cf2c9
ba9b2c5
5cf59d2
7077d1a
a8e599c
4c64575
4905c44
e426b3f
4200f30
53f4494
2ca6a3f
835ce2f
42b1e6e
ceee902
9c6fb07
de98e9b
8dbe123
51e915a
dd8b027
4a5238f
3f697ae
5f687cc
b651d29
4f64538
6330a29
f566f80
e06b72b
2584cd4
c1cd18a
b78eb83
f121eb6
7357652
a3e52e6
56afb9a
488b641
fefafcb
75288ce
fc992e3
ea8a19c
469f27f
a67282b
7dc9416
7ed8432
cea6883
979072f
f035142
dac6f01
2abe90a
bddd831
e7d9ff7
4e9bd67
20668ff
6226347
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ add_ur_adapter(${TARGET_NAME} | |
${CMAKE_CURRENT_SOURCE_DIR}/queue.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/queue.hpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/sampler.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/threadpool.hpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/ur_interface_loader.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/usm_p2p.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/virtual_mem.cpp | ||
|
@@ -49,6 +50,34 @@ set_target_properties(${TARGET_NAME} PROPERTIES | |
SOVERSION "${PROJECT_VERSION_MAJOR}" | ||
) | ||
|
||
# oneTBB is used as an optional NativeCPU backend and disabled by default. | ||
option(NATIVECPU_WITH_ONETBB "Use oneTBB as backend for Native CPU" OFF) | ||
if(NATIVECPU_WITH_ONETBB) | ||
message(STATUS "Configuring Native CPU adapter with oneTBB backend.") | ||
|
||
include(FetchContent) | ||
FetchContent_Declare( | ||
tbb | ||
GIT_REPOSITORY https://github.com/uxlfoundation/oneTBB.git | ||
#commit 9d4578723827f31defd79389819a5fbf659577f7 (HEAD -> master, origin/master, origin/HEAD) | ||
#Author: Konstantin Boyarinov <konstantin.boyarinov@intel.com> | ||
#Date: Fri Jan 24 23:23:59 2025 +0200 | ||
# Add explicit deduction guides for blocked_nd_range (#1525) | ||
GIT_TAG 9d4578723827f31defd79389819a5fbf659577f7 | ||
CMAKE_ARGS "-DTBB_TEST:BOOL=OFF -DTBB_EXAMPLES:BOOL=OFF -DTBB_BENCH:BOOL=OFF" | ||
OVERRIDE_FIND_PACKAGE | ||
) | ||
set(TBB_TEST OFF CACHE INTERNAL "" FORCE) | ||
set(TBB_EXAMPLES OFF CACHE INTERNAL "" FORCE) | ||
set(TBB_BENCH OFF CACHE INTERNAL "" FORCE) | ||
set(TBB_BUILD ON CACHE INTERNAL "" FORCE) | ||
set(TBB_FIND_PACKAGE OFF CACHE INTERNAL "" FORCE) | ||
set(TBB_FUZZ_TESTING OFF CACHE INTERNAL "" FORCE) | ||
set(TBB_INSTALL ON CACHE INTERNAL "" FORCE) | ||
set (CMAKE_INCLUDE_CURRENT_DIR OFF) | ||
FetchContent_MakeAvailable(tbb) | ||
endif() | ||
|
||
find_package(Threads REQUIRED) | ||
|
||
target_link_libraries(${TARGET_NAME} PRIVATE | ||
|
@@ -61,3 +90,23 @@ target_link_libraries(${TARGET_NAME} PRIVATE | |
target_include_directories(${TARGET_NAME} PRIVATE | ||
"${CMAKE_CURRENT_SOURCE_DIR}/../../" | ||
) | ||
|
||
if(NATIVECPU_WITH_ONETBB) | ||
target_link_libraries(${TARGET_NAME} PRIVATE | ||
TBB::tbb | ||
) | ||
if (NOT MSVC) | ||
# oneTBB currently casts away some const qualifiers | ||
# todo: check if compiler actually supports these options | ||
target_compile_options(tbb PRIVATE -Wno-cast-qual) | ||
target_compile_options(tbbmalloc PRIVATE -Wno-cast-qual) | ||
endif() | ||
|
||
# Undefine _DEBUG option in release builds to find | ||
# release tbbbind | ||
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") | ||
target_compile_options(tbb PRIVATE -U_DEBUG) | ||
endif() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The root cause for the complication here and before is including oneTBB with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably, but this may require some more rework and retesting, and the current There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, but the "Using Dependencies Guide" only gives instructions on how to either use pre-built packages, or how to include an external project's sources as this project's sources. Neither works for us and the result is that we need workarounds to include oneTBB's sources as this project's sources, except make it mostly, but not entirely, as if they are a different project's sources, because our project's configuration is not what we want for oneTBB. But if we do not have an easy way of using an alternative, if it would be too much work to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment looks like it does not match what the code does, this does not build oneTBB in release mode, this only builds oneTBB without assertions. In debug builds with no (or minimal?) optimizations, this would build oneTBB with no/minimal optimizations as well, whereas release mode would enable aggressive optimizations. Is that intended? If it is, that is fine but can you update the comment to match? If it is not intended, some more work would be needed to really build in release mode. From what I can find, setting |
||
|
||
target_compile_definitions(${TARGET_NAME} PRIVATE NATIVECPU_WITH_ONETBB) | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we keep
FetchContent
: this line has no effect as far as I can see, CMake does not get called for oneTBB, so there is nothing that parses CMake args. This is why you needed to setTBB_TEST
etc. again below despite including them here.This is harmless though so I'm okay with leaving this as is unless other changes are needed as well.