diff --git a/unified-runtime/source/adapters/offload/CMakeLists.txt b/unified-runtime/source/adapters/offload/CMakeLists.txt index 70336c6b24cd5..423330faf4952 100644 --- a/unified-runtime/source/adapters/offload/CMakeLists.txt +++ b/unified-runtime/source/adapters/offload/CMakeLists.txt @@ -10,11 +10,6 @@ if (UR_OFFLOAD_INSTALL_DIR STREQUAL "") message(FATAL_ERROR "UR_OFFLOAD_INSTALL_DIR must be defined for the Offload adapter") endif() -set(UR_OFFLOAD_INCLUDE_DIR "" CACHE PATH "Path to the directory containing LLVM headers") -if (UR_OFFLOAD_INCLUDE_DIR STREQUAL "") - message(FATAL_ERROR "UR_OFFLOAD_INCLUDE_DIR must be defined for the Offload adapter") -endif() - # When targetting CUDA devices, we need a workaround to avoid sending PTX to # liboffload as the CUDA plugin doesn't support it yet. The workaround is to # simply always link the incoming program so it ends up as CUBIN. Try to find @@ -68,6 +63,6 @@ target_link_libraries(${TARGET_NAME} PRIVATE ) target_include_directories(${TARGET_NAME} PRIVATE - "${UR_OFFLOAD_INCLUDE_DIR}/offload" + "${UR_OFFLOAD_INSTALL_DIR}/include/offload" "${CMAKE_CURRENT_SOURCE_DIR}/../../" ) diff --git a/unified-runtime/source/adapters/offload/README.md b/unified-runtime/source/adapters/offload/README.md new file mode 100644 index 0000000000000..b94e7465b954e --- /dev/null +++ b/unified-runtime/source/adapters/offload/README.md @@ -0,0 +1,50 @@ +# Offload Adapter + +The Offload adapter is an experimental adapter built on top of LLVM's liboffload +runtime. + +The main purpose of the adapter is to drive development of liboffload, and +identify gaps that need addressed for full SYCL support. + +The long-term goal of the project is to replace Unified Runtime with liboffload. + +The adapter should be used with an upstream build of LLVM with the `offload` +runtime enabled. The in-tree version is unlikely to be usable, as there are +frequent breaking API changes which happen out-of-sync with pulldowns. + +## Building upstream LLVM with Offload enabled +The `liboffload` library will be built if the `offload` runtime is enabled. An +example CMake configuration is: +```sh +cmake -S llvm -B build -GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=$PWD/build/install + -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;lldb;lld;' \ + -DLLVM_ENABLE_RUNTIMES='offload;openmp' +``` + +Because Offload's API header is generated with tablegen at build time, the +runtime must be installed rather than just built so it gets copied into the +correct location. From either the top-level build or runtime build directory: +```sh +$ ninja install +``` + +## Building the adapter +Build UR/DPC++ with the following additional flags: +``` + -DUR_BUILD_ADAPTER_OFFLOAD=ON + -DUR_OFFLOAD_INSTALL_DIR= +``` + +## Testing the adapter +The adapter can be tested with UR CTS via the +`check-unified-runtime-conformance-offload` target. + +It is also possible to run the SYCL E2E tests by configuring with +```sh + -DSYCL_TEST_E2E_TARGETS=offload:gpu + -DOFFLOAD_BUILD_TARGET= +``` +where `` is one of `target-nvidia` or `target-amdgpu`, depending +on the available device.