Skip to content

Commit 8c528be

Browse files
authored
[SYCL] Change kernel/program cache data structures and get rid of boost (#18599)
I'm working to ease Linux distros in packaging this repo, and our use of boost was hindering that. The only place we use boost today is the data structures for the kernel and program cache. Change it to be an equally fast data structure that was already use for `xptifw` (albeit with a manually implemented wrapper for `unordered_multimap` that the upstream repo doesn't provide) and delete boost. I've done various benchmarks to make sure there is no performance impact using the cache benchmark test sent to me by Slawomir. Here the the performance results. Each entry is an average of 10 runs, each run using 3000 kernels with 10000 iterations. Let me know if you'd like the full data. All times are in milliseconds and lower is better. Linux: Fast kernel cache: | Boost | This PR | Percent Diff | ------------- | ------------- | ------------ | | 44.95478 | 45.04912 | 0.21% | Regular kernel cache/program cache: | Boost | This PR | Percent Diff | ------------- | ------------- | ------------ | | 21541.69 | 21150.15 | -1.83% Windows: Fast kernel cache: | Boost | This PR | Percent Diff | ------------- | ------------- | ------------ | | 71.19915 | 69.38018 | -2.59% | Regular kernel cache/program cache: | Boost | This PR | Percent Diff | ------------- | ------------- | ------------ | | 7295.955 | 7298.057 | 0.03% My interpretation of the results is that there is basically no performance impact, either positive or negative. Different test kinds may have been run on different hardware, though of course tests of the same os/test kind were done on the same machine. And just for fun: `configure.py` time: | Boost | This PR | Percent Diff | ------------- | ------------- | ------------ | | 29.812 | 21.1625 | -33.94% | Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 630ccc8 commit 8c528be

16 files changed

+248
-348
lines changed

sycl/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ if(MSVC)
8282
endif()
8383
endif()
8484

85+
include(FetchEmhash)
8586
include(FetchUnifiedRuntime)
8687

8788
# The change in SYCL_MAJOR_VERSION must be accompanied with the same update in
@@ -213,9 +214,6 @@ install(FILES
213214
DESTINATION "${SYCL_INCLUDE_DIR}/sycl"
214215
COMPONENT sycl-headers)
215216

216-
include(AddBoostMp11Headers)
217-
include(FetchBoostUnorderedHeaders)
218-
219217
# This is workaround to detect changes (add or modify) in subtree which
220218
# are not detected by copy_directory command.
221219
# TODO: detect and process remove header/directory case
@@ -250,7 +248,7 @@ add_custom_target(sycl-headers
250248
${OUT_HEADERS_IN_SYCLCOMPAT_DIR}
251249
${OUT_UR_HEADERS}
252250
sycl-device-aspect-macros-header
253-
boost_mp11-headers)
251+
)
254252

255253
add_custom_command(
256254
OUTPUT ${OUT_HEADERS_IN_SYCL_DIR}
@@ -275,7 +273,6 @@ add_custom_command(
275273
install(DIRECTORY "${sycl_inc_dir}/sycl" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers)
276274
install(DIRECTORY "${sycl_inc_dir}/CL" DESTINATION ${SYCL_INCLUDE_DIR}/ COMPONENT sycl-headers)
277275
install(DIRECTORY "${sycl_inc_dir}/std" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers)
278-
install(DIRECTORY ${BOOST_MP11_DESTINATION_DIR} DESTINATION ${SYCL_INCLUDE_DIR}/sycl/detail COMPONENT boost_mp11-headers)
279276
install(DIRECTORY "${sycl_inc_dir}/syclcompat" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers)
280277
install(FILES "${sycl_inc_dir}/syclcompat.hpp" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers)
281278
install(FILES "${UNIFIED_RUNTIME_INCLUDE_DIR}/ur_api.h" DESTINATION ${SYCL_INCLUDE_DIR}
@@ -458,7 +455,6 @@ get_property(SYCL_TOOLCHAIN_DEPS GLOBAL PROPERTY SYCL_TOOLCHAIN_INSTALL_COMPONEN
458455
# Listed here are component names contributing the package
459456
set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS
460457
append-file
461-
boost_mp11-headers
462458
clang
463459
clang-offload-wrapper
464460
clang-offload-bundler

sycl/cmake/modules/AddBoostMp11Headers.cmake

Lines changed: 0 additions & 54 deletions
This file was deleted.

sycl/cmake/modules/FetchBoostUnorderedHeaders.cmake

Lines changed: 0 additions & 101 deletions
This file was deleted.

sycl/cmake/modules/FetchEmhash.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Finds or fetches emhash.
2+
find_file(EMHASH_SYS_LOC "hash_table8.hpp" PATH_SUFFIXES "emhash")
3+
if(NOT EMHASH_SYS_LOC)
4+
set(EMHASH_REPO https://github.com/ktprime/emhash)
5+
message(STATUS "Will fetch emhash from ${EMHASH_REPO}")
6+
FetchContent_Declare(emhash
7+
GIT_REPOSITORY ${EMHASH_REPO}
8+
GIT_TAG 3ba9abdfdc2e0430fcc2fd8993cad31945b6a02b
9+
SOURCE_SUBDIR emhash
10+
)
11+
FetchContent_MakeAvailable(emhash)
12+
13+
# FetchContent downloads the files into a directory with
14+
# '-src' as the suffix and emhash has the headers in the
15+
# top level directory in the repo, so copy the headers to a directory
16+
# named `emhash` so source files can include with <emhash/header.hpp>
17+
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include/emhash)
18+
file(GLOB HEADERS "${emhash_SOURCE_DIR}/*.h*")
19+
file(COPY ${HEADERS} DESTINATION ${CMAKE_BINARY_DIR}/include/emhash)
20+
set(SYCL_EMHASH_DIR ${CMAKE_BINARY_DIR}/include/ CACHE INTERNAL "")
21+
endif()

sycl/cmake/modules/FetchUnifiedRuntime.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
358358
-DUMF_BUILD_SHARED_LIBRARY:BOOL=${UMF_BUILD_SHARED_LIBRARY}
359359
-DUMF_LINK_HWLOC_STATICALLY:BOOL=${UMF_LINK_HWLOC_STATICALLY}
360360
-DUMF_DISABLE_HWLOC:BOOL=${UMF_DISABLE_HWLOC}
361+
-DSYCL_EMHASH_DIR:STRING=${SYCL_EMHASH_DIR}
361362
# Enable d suffix in UMF
362363
-DUMF_USE_DEBUG_POSTFIX:BOOL=ON
363364
)

sycl/cmake/modules/PreprocessBoostMp11Headers.cmake

Lines changed: 0 additions & 105 deletions
This file was deleted.

sycl/source/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME)
149149
target_include_directories(${LIB_OBJ_NAME} PRIVATE ${zstd_INCLUDE_DIR})
150150
endif()
151151

152+
if (EMHASH_SYS_LOC)
153+
# If we are using system emhash, include the system directory
154+
# containing the emhash folder and note this location so
155+
# other modules using emhash can find it.
156+
cmake_path(GET EMHASH_SYS_LOC PARENT_PATH EMHASH_SYS_LOC)
157+
set(SYCL_EMHASH_DIR ${EMHASH_SYS_LOC} CACHE INTERNAL "")
158+
target_include_directories(${LIB_OBJ_NAME} PRIVATE ${EMHASH_SYS_LOC})
159+
endif()
160+
152161
# ur_win_proxy_loader
153162
if (WIN32)
154163
include_directories(${LLVM_EXTERNAL_SYCL_SOURCE_DIR}/ur_win_proxy_loader)

sycl/source/detail/context_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ std::optional<ur_program_handle_t> context_impl::getProgramForDevImgs(
520520

521521
auto KeyMappingsIt = KeyMap.find(OuterKey);
522522
assert(KeyMappingsIt != KeyMap.end());
523-
auto CachedProgIt = Cache.find(KeyMappingsIt->second);
523+
auto CachedProgIt = Cache.find((*KeyMappingsIt).second);
524524
assert(CachedProgIt != Cache.end());
525525
BuildRes = CachedProgIt->second;
526526
}

0 commit comments

Comments
 (0)