Skip to content

Use readelf on pi_level_zero library to find exact name of ze_loader #617

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

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions dpctl-capi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ if(DPCTL_ENABLE_LO_PROGRAM_CREATION)
set(DPCTL_ENABLE_LO_PROGRAM_CREATION 1)
include(GetLevelZeroHeaders)
get_level_zero_headers()
if (UNIX)
find_library(PI_LEVEL_ZERO_LIB
NAMES pi_level_zero
HINTS ${IntelSycl_LIBRARY_DIR}
)
find_program(READELF_PROG readelf)
find_program(GREP_PROG grep)
execute_process(
COMMAND ${READELF_PROG} -d ${PI_LEVEL_ZERO_LIB}
COMMAND ${GREP_PROG} libze_loader
COMMAND ${GREP_PROG} -Po "libze_loader[^\]]*"
OUTPUT_VARIABLE LIBZE_LOADER_FILENAME
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
endif()
endif()

configure_file(
Expand Down
2 changes: 2 additions & 0 deletions dpctl-capi/include/Config/dpctl_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@

/* The DPCPP version used to build dpctl */
#define DPCTL_DPCPP_VERSION "@IntelSycl_VERSION@"

#define DPCTL_LIBZE_LOADER_FILENAME "@LIBZE_LOADER_FILENAME@"
2 changes: 1 addition & 1 deletion dpctl-capi/source/dpctl_sycl_program_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace
#ifdef DPCTL_ENABLE_LO_PROGRAM_CREATION

#ifdef __linux__
static const char *zeLoaderName = "libze_loader.so";
static const char *zeLoaderName = DPCTL_LIBZE_LOADER_FILENAME;
static const int libLoadFlags = RTLD_NOLOAD | RTLD_NOW | RTLD_LOCAL;
#elif defined(_WIN64)
static const char *zeLoaderName = "ze_loader.dll";
Expand Down