Skip to content

Commit

Permalink
Merge pull request #1026 from kbenzie/benie/test-conformance-sycl-lib…
Browse files Browse the repository at this point in the history
…rary-dir

[CTS] Add UR_SYCL_LIBRARY_DIR CMake variable
  • Loading branch information
kbenzie authored Nov 7, 2023
2 parents 612a263 + b01beb7 commit d70bae4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ jobs:
-DUR_BUILD_TESTS=ON
-DUR_BUILD_ADAPTER_${{matrix.adapter.name}}=ON
-DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++
-DUR_SYCL_LIBRARY_DIR=${{github.workspace}}/dpcpp_compiler/lib
-DUR_CONFORMANCE_TARGET_TRIPLES=${{matrix.adapter.triplet}}
- name: Build
# This is so that device binaries can find the sycl runtime library
run: LD_LIBRARY_PATH=${{github.workspace}}/dpcpp_compiler/lib
cmake --build ${{github.workspace}}/build -j $(nproc)
run: cmake --build ${{github.workspace}}/build -j $(nproc)

- name: Test adapter specific
working-directory: ${{github.workspace}}/build
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ option(UR_BUILD_ADAPTER_CUDA "build cuda adapter from SYCL" OFF)
option(UR_BUILD_ADAPTER_HIP "build hip adapter from SYCL" OFF)
option(UR_BUILD_EXAMPLE_CODEGEN "Build the codegen example." OFF)
option(VAL_USE_LIBBACKTRACE_BACKTRACE "enable libbacktrace validation backtrace for linux" OFF)
set(UR_DPCXX "" CACHE FILEPATH "Path of the DPC++ compiler executable")
set(UR_SYCL_LIBRARY_DIR "" CACHE PATH
"Path of the SYCL runtime library directory")

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ List of options provided by CMake:
| UR_BUILD_ADAPTER_HIP | Fetch and use hip adapter from SYCL | ON/OFF | OFF |
| UR_HIP_PLATFORM | Build hip adapter for AMD or NVIDIA platform | AMD/NVIDIA | AMD |
| UR_ENABLE_COMGR | Enable comgr lib usage | AMD/NVIDIA | AMD |
| UR_DPCXX | Path of the DPC++ compiler executable to build CTS device binaries | File path | `""` |
| UR_SYCL_LIBRARY_DIR | Path of the SYCL runtime library directory to build CTS device binaries | Directory path | `""` |

### Additional make targets

Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ add_subdirectory(unit)
if(UR_BUILD_TOOLS)
add_subdirectory(tools)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND DEFINED UR_DPCXX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND UR_DPCXX)
add_subdirectory(fuzz)
endif()
10 changes: 8 additions & 2 deletions test/conformance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ add_subdirectory(queue)
add_subdirectory(sampler)
add_subdirectory(virtual_memory)

if(DEFINED UR_DPCXX)
if(UR_DPCXX)
add_custom_target(generate_device_binaries)

set(UR_CONFORMANCE_DEVICE_BINARIES_DIR
Expand All @@ -99,12 +99,18 @@ if(DEFINED UR_DPCXX)
if(NOT "${UR_CONFORMANCE_TARGET_TRIPLES}" STREQUAL "")
string(REPLACE "," ";" TARGET_TRIPLES ${UR_CONFORMANCE_TARGET_TRIPLES})
else()
message(WARNING "UR_CONFORMANCE_TARGET_TRIPLES wasn't set, defaulting to only generate spir64 device binaries")
message(WARNING
"UR_CONFORMANCE_TARGET_TRIPLES wasn't set, defaulting to only \
generate spir64 device binaries")
list(APPEND TARGET_TRIPLES "spir64")
endif()

add_subdirectory(device_code)
add_subdirectory(kernel)
add_subdirectory(program)
add_subdirectory(enqueue)
else()
message(WARNING
"UR_DPCXX is not defined, the following conformance test executables \
are disabled: test-program, test-kernel, test-enqueue")
endif()
13 changes: 11 additions & 2 deletions test/conformance/device_code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ macro(add_device_binary SOURCE_FILE)
get_filename_component(KERNEL_NAME ${SOURCE_FILE} NAME_WE)
set(DEVICE_BINARY_DIR "${UR_CONFORMANCE_DEVICE_BINARIES_DIR}/${KERNEL_NAME}")
file(MAKE_DIRECTORY ${DEVICE_BINARY_DIR})
if(UR_SYCL_LIBRARY_DIR)
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
set(EXTRA_ENV LD_LIBRARY_PATH=${UR_SYCL_LIBRARY_DIR})
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows)
set(EXTRA_ENV PATH=${UR_SYCL_LIBRARY_DIR};$ENV{PATH})
else()
set(EXTRA_ENV DYLD_FALLBACK_LIBRARY_PATH=${UR_SYCL_LIBRARY_DIR})
endif()
endif()
foreach(TRIPLE ${TARGET_TRIPLES})
set(EXE_PATH "${DEVICE_BINARY_DIR}/${KERNEL_NAME}_${TRIPLE}")
add_custom_command(OUTPUT ${EXE_PATH}
COMMAND ${UR_DPCXX} -fsycl -fsycl-targets=${TRIPLE} -fsycl-device-code-split=off
${SOURCE_FILE} -o ${EXE_PATH}
COMMAND ${CMAKE_COMMAND} -E env SYCL_DUMP_IMAGES=true
${EXE_PATH} || (exit 0)
COMMAND ${CMAKE_COMMAND} -E env ${EXTRA_ENV} SYCL_DUMP_IMAGES=true
${EXE_PATH} || exit 0
WORKING_DIRECTORY "${DEVICE_BINARY_DIR}"
DEPENDS ${SOURCE_FILE}
)
Expand Down

0 comments on commit d70bae4

Please sign in to comment.