diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 0a2684462d..315a4ea81b 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1210375dd8..0cdd736733 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/README.md b/README.md index 4917add660..c156d4f079 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 49e13eb869..a9fdf2ba37 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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() diff --git a/test/conformance/CMakeLists.txt b/test/conformance/CMakeLists.txt index 9a273470eb..f5f6c2a591 100644 --- a/test/conformance/CMakeLists.txt +++ b/test/conformance/CMakeLists.txt @@ -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 @@ -99,7 +99,9 @@ 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() @@ -107,4 +109,8 @@ if(DEFINED UR_DPCXX) 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() diff --git a/test/conformance/device_code/CMakeLists.txt b/test/conformance/device_code/CMakeLists.txt index 1d3f28df7f..10925b964f 100644 --- a/test/conformance/device_code/CMakeLists.txt +++ b/test/conformance/device_code/CMakeLists.txt @@ -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} )