Skip to content

Commit 78e85c9

Browse files
Use readelf on pi_level_zero library to find exact name of ze_loader
Store that in include/Config/dpctl_config.h and use the define in dpctl_sycl_program_interface.cpp CMake is running the equivalent of the following ``` readelf -d $DPCPP_ROOT/lib/libpi_level_zero.so | grep libze_loader | grep -Po "libze_loader[^\]]*" libze_loader.so.1 ```
1 parent 10db385 commit 78e85c9

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

dpctl-capi/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ if(DPCTL_ENABLE_LO_PROGRAM_CREATION)
5050
set(DPCTL_ENABLE_LO_PROGRAM_CREATION 1)
5151
include(GetLevelZeroHeaders)
5252
get_level_zero_headers()
53+
if (UNIX)
54+
find_library(PI_LEVEL_ZERO_LIB
55+
NAMES pi_level_zero
56+
HINTS ${IntelSycl_LIBRARY_DIR}
57+
)
58+
find_program(READELF_PROG readelf)
59+
find_program(GREP_PROG grep)
60+
execute_process(
61+
COMMAND ${READELF_PROG} -d ${PI_LEVEL_ZERO_LIB}
62+
COMMAND ${GREP_PROG} libze_loader
63+
COMMAND ${GREP_PROG} -Po "libze_loader[^\]]*"
64+
OUTPUT_VARIABLE LIBZE_LOADER_FILENAME
65+
OUTPUT_STRIP_TRAILING_WHITESPACE
66+
ERROR_STRIP_TRAILING_WHITESPACE
67+
)
68+
endif()
5369
endif()
5470

5571
configure_file(

dpctl-capi/include/Config/dpctl_config.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@
3030

3131
/* The DPCPP version used to build dpctl */
3232
#define DPCTL_DPCPP_VERSION "@IntelSycl_VERSION@"
33+
34+
#define DPCTL_LIBZE_LOADER_FILENAME "@LIBZE_LOADER_FILENAME@"

dpctl-capi/source/dpctl_sycl_program_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace
4545
#ifdef DPCTL_ENABLE_LO_PROGRAM_CREATION
4646

4747
#ifdef __linux__
48-
static const char *zeLoaderName = "libze_loader.so";
48+
static const char *zeLoaderName = DPCTL_LIBZE_LOADER_FILENAME;
4949
static const int libLoadFlags = RTLD_NOLOAD | RTLD_NOW | RTLD_LOCAL;
5050
#elif defined(_WIN64)
5151
static const char *zeLoaderName = "ze_loader.dll";

0 commit comments

Comments
 (0)