Skip to content

Commit 094ebda

Browse files
committed
[SYCL][CMake] Simplify emhash fetch code
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 5b5fd84 commit 094ebda

File tree

8 files changed

+18
-26
lines changed

8 files changed

+18
-26
lines changed

sycl/cmake/modules/AddSYCLUnitTest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ function(add_sycl_unittest_internal test_dirname link_variant is_preview)
121121
mockOpenCL
122122
LLVMTestingSupport
123123
OpenCL-Headers
124+
emhash::emhash
124125
unified-runtime::mock
125126
${SYCL_LINK_LIBS}
126127
)

sycl/cmake/modules/FetchEmhash.cmake

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
# Finds or fetches emhash.
2-
if(DEFINED SYCL_EMHASH_DIR OR DEFINED EMHASH_SYS_LOC)
2+
if(TARGET emhash::emhash)
33
return()
44
endif()
5-
find_file(EMHASH_SYS_LOC "hash_table8.hpp" PATH_SUFFIXES "emhash")
6-
if(NOT EMHASH_SYS_LOC)
5+
find_package(emhash QUIET)
6+
if(NOT emhash_FOUND)
77
set(EMHASH_REPO https://github.com/ktprime/emhash)
88
message(STATUS "Will fetch emhash from ${EMHASH_REPO}")
99
include(FetchContent)
1010
FetchContent_Declare(emhash
1111
GIT_REPOSITORY ${EMHASH_REPO}
12-
GIT_TAG 3ba9abdfdc2e0430fcc2fd8993cad31945b6a02b
12+
GIT_TAG 09fb0439de0c65e387498232c89d561ee95fbd60
1313
SOURCE_SUBDIR emhash
1414
)
1515
FetchContent_MakeAvailable(emhash)
1616

17-
# FetchContent downloads the files into a directory with
18-
# '-src' as the suffix and emhash has the headers in the
19-
# top level directory in the repo, so copy the headers to a directory
20-
# named `emhash` so source files can include with <emhash/header.hpp>
21-
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include/emhash)
22-
file(GLOB HEADERS "${emhash_SOURCE_DIR}/*.h*")
23-
file(COPY ${HEADERS} DESTINATION ${CMAKE_BINARY_DIR}/include/emhash)
24-
set(SYCL_EMHASH_DIR ${CMAKE_BINARY_DIR}/include/ CACHE INTERNAL "")
17+
# The official cmake install target uses the 'emhash' namespace,
18+
# so emulate that here so client code can use a single target name for both cases.
19+
add_library(emhash INTERFACE)
20+
target_include_directories(emhash SYSTEM INTERFACE ${emhash_SOURCE_DIR})
21+
add_library(emhash::emhash ALIAS emhash)
2522
endif()

sycl/source/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,7 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME)
147147
target_include_directories(${LIB_OBJ_NAME} PRIVATE ${zstd_INCLUDE_DIR})
148148
endif()
149149

150-
if (EMHASH_SYS_LOC)
151-
# If we are using system emhash, include the system directory
152-
# containing the emhash folder and note this location so
153-
# other modules using emhash can find it.
154-
cmake_path(GET EMHASH_SYS_LOC PARENT_PATH EMHASH_SYS_LOC)
155-
set(SYCL_EMHASH_DIR ${EMHASH_SYS_LOC} CACHE INTERNAL "")
156-
target_include_directories(${LIB_OBJ_NAME} PRIVATE ${EMHASH_SYS_LOC})
157-
endif()
150+
target_link_libraries(${LIB_OBJ_NAME} PRIVATE emhash::emhash)
158151

159152
# ur_win_proxy_loader
160153
if (WIN32)

sycl/source/detail/kernel_name_based_cache_t.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include <detail/hashers.hpp>
1111
#include <detail/kernel_arg_mask.hpp>
12-
#include <emhash/hash_table8.hpp>
12+
#include <hash_table8.hpp>
1313
#include <sycl/detail/spinlock.hpp>
1414
#include <sycl/detail/ur.hpp>
1515

sycl/source/detail/unordered_multimap.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===--------------------------------------------------------------===//
88
#pragma once
99
#include <detail/hashers.hpp>
10-
#include <emhash/hash_table8.hpp>
10+
#include <hash_table8.hpp>
1111

1212
#include <utility>
1313
#include <vector>

xptifw/include/xpti_string_table.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include "parallel_hashmap/phmap.h"
99
#include "xpti/xpti_data_types.h"
10-
#include <emhash/hash_table7.hpp>
10+
#include <hash_table7.hpp>
1111

1212
#include <atomic>
1313
#include <shared_mutex>

xptifw/src/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include(FetchContent)
33

44
# The sycl target should download or find emhash but may not
55
# for standalone builds.
6-
if (NOT SYCL_EMHASH_DIR)
6+
if (NOT TARGET emhash::emhash)
77
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../sycl/cmake/modules")
88
include(FetchEmhash)
99
endif()
@@ -37,11 +37,12 @@ function(add_xpti_library LIB_NAME)
3737
target_compile_definitions(${LIB_NAME} PRIVATE -DXPTI_API_EXPORTS)
3838
target_include_directories(${LIB_NAME} PUBLIC
3939
$<BUILD_INTERFACE:${XPTIFW_DIR}/include>
40-
$<BUILD_INTERFACE:${SYCL_EMHASH_DIR}>
4140
$<BUILD_INTERFACE:${XPTIFW_PARALLEL_HASHMAP_HEADERS}>
4241
$<BUILD_INTERFACE:${XPTI_DIR}/include>
4342
)
4443

44+
target_link_libraries(${LIB_NAME} PUBLIC emhash::emhash)
45+
4546
find_package(Threads REQUIRED)
4647
target_link_libraries(${LIB_NAME} PUBLIC ${CMAKE_DL_LIBS} Threads::Threads)
4748

xptifw/src/xpti_trace_framework.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "xpti_int64_hash_table.hpp"
2020
#include "xpti_object_table.hpp"
2121
#include "xpti_string_table.hpp"
22-
#include <emhash/hash_table7.hpp>
22+
#include <hash_table7.hpp>
2323

2424
#include <algorithm>
2525
#include <array>

0 commit comments

Comments
 (0)