Skip to content

Commit b01beb7

Browse files
committed
[CTS] Add UR_SYCL_LIBRARY_DIR CMake variable
The CTS is already dependant on the DPC++ compiler to generate programs inputs for the program, kernel, and enqueue test suites specified via the `UR_DPCXX` CMake variable. If the DPC++ compiler is not installed on the system the executables it outputs will likely fail to find the SYCL runtime library when executed, breaking the generation of CTS program inputs. The patch introduces the `UR_SYCL_LIBRARY_DIR` CMake variable enabling the user to specify the path to the SYCL runtime library for use when generating CTS program inputs.
1 parent 612a263 commit b01beb7

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
lines changed

.github/workflows/cmake.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ jobs:
196196
-DUR_BUILD_TESTS=ON
197197
-DUR_BUILD_ADAPTER_${{matrix.adapter.name}}=ON
198198
-DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++
199+
-DUR_SYCL_LIBRARY_DIR=${{github.workspace}}/dpcpp_compiler/lib
199200
-DUR_CONFORMANCE_TARGET_TRIPLES=${{matrix.adapter.triplet}}
200201
201202
- name: Build
202203
# This is so that device binaries can find the sycl runtime library
203-
run: LD_LIBRARY_PATH=${{github.workspace}}/dpcpp_compiler/lib
204-
cmake --build ${{github.workspace}}/build -j $(nproc)
204+
run: cmake --build ${{github.workspace}}/build -j $(nproc)
205205

206206
- name: Test adapter specific
207207
working-directory: ${{github.workspace}}/build

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ option(UR_BUILD_ADAPTER_CUDA "build cuda adapter from SYCL" OFF)
4141
option(UR_BUILD_ADAPTER_HIP "build hip adapter from SYCL" OFF)
4242
option(UR_BUILD_EXAMPLE_CODEGEN "Build the codegen example." OFF)
4343
option(VAL_USE_LIBBACKTRACE_BACKTRACE "enable libbacktrace validation backtrace for linux" OFF)
44+
set(UR_DPCXX "" CACHE FILEPATH "Path of the DPC++ compiler executable")
45+
set(UR_SYCL_LIBRARY_DIR "" CACHE PATH
46+
"Path of the SYCL runtime library directory")
4447

4548
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
4649
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ List of options provided by CMake:
133133
| UR_BUILD_ADAPTER_HIP | Fetch and use hip adapter from SYCL | ON/OFF | OFF |
134134
| UR_HIP_PLATFORM | Build hip adapter for AMD or NVIDIA platform | AMD/NVIDIA | AMD |
135135
| UR_ENABLE_COMGR | Enable comgr lib usage | AMD/NVIDIA | AMD |
136+
| UR_DPCXX | Path of the DPC++ compiler executable to build CTS device binaries | File path | `""` |
137+
| UR_SYCL_LIBRARY_DIR | Path of the SYCL runtime library directory to build CTS device binaries | Directory path | `""` |
136138

137139
### Additional make targets
138140

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ add_subdirectory(unit)
2525
if(UR_BUILD_TOOLS)
2626
add_subdirectory(tools)
2727
endif()
28-
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND DEFINED UR_DPCXX)
28+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND UR_DPCXX)
2929
add_subdirectory(fuzz)
3030
endif()

test/conformance/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ add_subdirectory(queue)
8989
add_subdirectory(sampler)
9090
add_subdirectory(virtual_memory)
9191

92-
if(DEFINED UR_DPCXX)
92+
if(UR_DPCXX)
9393
add_custom_target(generate_device_binaries)
9494

9595
set(UR_CONFORMANCE_DEVICE_BINARIES_DIR
@@ -99,12 +99,18 @@ if(DEFINED UR_DPCXX)
9999
if(NOT "${UR_CONFORMANCE_TARGET_TRIPLES}" STREQUAL "")
100100
string(REPLACE "," ";" TARGET_TRIPLES ${UR_CONFORMANCE_TARGET_TRIPLES})
101101
else()
102-
message(WARNING "UR_CONFORMANCE_TARGET_TRIPLES wasn't set, defaulting to only generate spir64 device binaries")
102+
message(WARNING
103+
"UR_CONFORMANCE_TARGET_TRIPLES wasn't set, defaulting to only \
104+
generate spir64 device binaries")
103105
list(APPEND TARGET_TRIPLES "spir64")
104106
endif()
105107

106108
add_subdirectory(device_code)
107109
add_subdirectory(kernel)
108110
add_subdirectory(program)
109111
add_subdirectory(enqueue)
112+
else()
113+
message(WARNING
114+
"UR_DPCXX is not defined, the following conformance test executables \
115+
are disabled: test-program, test-kernel, test-enqueue")
110116
endif()

test/conformance/device_code/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,22 @@ macro(add_device_binary SOURCE_FILE)
77
get_filename_component(KERNEL_NAME ${SOURCE_FILE} NAME_WE)
88
set(DEVICE_BINARY_DIR "${UR_CONFORMANCE_DEVICE_BINARIES_DIR}/${KERNEL_NAME}")
99
file(MAKE_DIRECTORY ${DEVICE_BINARY_DIR})
10+
if(UR_SYCL_LIBRARY_DIR)
11+
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
12+
set(EXTRA_ENV LD_LIBRARY_PATH=${UR_SYCL_LIBRARY_DIR})
13+
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows)
14+
set(EXTRA_ENV PATH=${UR_SYCL_LIBRARY_DIR};$ENV{PATH})
15+
else()
16+
set(EXTRA_ENV DYLD_FALLBACK_LIBRARY_PATH=${UR_SYCL_LIBRARY_DIR})
17+
endif()
18+
endif()
1019
foreach(TRIPLE ${TARGET_TRIPLES})
1120
set(EXE_PATH "${DEVICE_BINARY_DIR}/${KERNEL_NAME}_${TRIPLE}")
1221
add_custom_command(OUTPUT ${EXE_PATH}
1322
COMMAND ${UR_DPCXX} -fsycl -fsycl-targets=${TRIPLE} -fsycl-device-code-split=off
1423
${SOURCE_FILE} -o ${EXE_PATH}
15-
COMMAND ${CMAKE_COMMAND} -E env SYCL_DUMP_IMAGES=true
16-
${EXE_PATH} || (exit 0)
24+
COMMAND ${CMAKE_COMMAND} -E env ${EXTRA_ENV} SYCL_DUMP_IMAGES=true
25+
${EXE_PATH} || exit 0
1726
WORKING_DIRECTORY "${DEVICE_BINARY_DIR}"
1827
DEPENDS ${SOURCE_FILE}
1928
)

0 commit comments

Comments
 (0)