diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9edbd459d7..258c0ca440 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -163,14 +163,15 @@ jobs: strategy: matrix: adapter: [ - {name: CUDA, triplet: nvptx64-nvidia-cuda}, - {name: HIP, triplet: spir64}, # should be amdgcn-amdhsa, but build scripts for device binaries are currently broken for this target. - {name: L0, triplet: spir64} + {name: CUDA, runner: CUDA, triplet: nvptx64-nvidia-cuda}, + {name: HIP, runner: HIP, triplet: spir64}, # should be amdgcn-amdhsa, but build scripts for device binaries are currently broken for this target. + {name: L0, runner: L0, triplet: spir64}, + {name: OPENCL, runner: ubuntu-latest, triplet: spir64} ] build_type: [Debug, Release] compiler: [{c: gcc, cxx: g++}, {c: clang, cxx: clang++}] - runs-on: ${{matrix.adapter.name}} + runs-on: ${{matrix.adapter.runner}} steps: - uses: actions/checkout@v3 @@ -178,6 +179,22 @@ jobs: - name: Install pip packages run: pip install -r third_party/requirements.txt + - name: Install OpenCL + if: matrix.adapter.name == 'OpenCL' + run: | + sudo apt-get update + sudo apt-get install ocl-icd-libopencl1 + mkdir intel-ocl-packages + cd intel-ocl-packages + wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.14828.8/intel-igc-core_1.0.14828.8_amd64.deb + wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.14828.8/intel-igc-opencl_1.0.14828.8_amd64.deb + wget https://github.com/intel/compute-runtime/releases/download/23.30.26918.9/intel-level-zero-gpu-dbgsym_1.3.26918.9_amd64.ddeb + wget https://github.com/intel/compute-runtime/releases/download/23.30.26918.9/intel-level-zero-gpu_1.3.26918.9_amd64.deb + wget https://github.com/intel/compute-runtime/releases/download/23.30.26918.9/intel-opencl-icd-dbgsym_23.30.26918.9_amd64.ddeb + wget https://github.com/intel/compute-runtime/releases/download/23.30.26918.9/intel-opencl-icd_23.30.26918.9_amd64.deb + wget https://github.com/intel/compute-runtime/releases/download/23.30.26918.9/libigdgmm12_22.3.0_amd64.deb + sudo dpkg -i *.deb + - name: Download DPC++ run: | wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/nightly-2023-09-21/sycl_linux.tar.gz diff --git a/source/adapters/opencl/CMakeLists.txt b/source/adapters/opencl/CMakeLists.txt index dc43a68ffa..af8e0559a6 100644 --- a/source/adapters/opencl/CMakeLists.txt +++ b/source/adapters/opencl/CMakeLists.txt @@ -43,6 +43,34 @@ set_target_properties(${TARGET_NAME} PROPERTIES find_package(Threads REQUIRED) +if(NOT OpenCL_INCLUDE_DIR) + set(OPENCL_HEADERS_REPO "https://github.com/KhronosGroup/OpenCL-Headers.git") + set(OPENCL_HEADERS_HASH 9ddb236e6eb3cf844f9e2f81677e1045f9bf838e) + + FetchContent_Declare(ocl-headers + GIT_REPOSITORY ${OPENCL_HEADERS_REPO} + GIT_TAG ${OPENCL_HEADERS_HASH} + ) + FetchContent_MakeAvailable(ocl-headers) + FetchContent_GetProperties(ocl-headers) + + set(OpenCL_INCLUDE_DIR ${ocl-headers_SOURCE_DIR} CACHE PATH "Path to OpenCL Headers") +endif() + +if(NOT OpenCL_LIBRARY) + set(OPENCL_ICD_LOADER_REPO "https://github.com/KhronosGroup/OpenCL-ICD-Loader.git") + set(OPENCL_ICD_LOADER_HASH 9a3e962f16f5097d2054233ad8b6dad51b6f41b7) + + FetchContent_Declare(ocl-icd-loader + GIT_REPOSITORY ${OPENCL_ICD_LOADER_REPO} + GIT_TAG ${OPENCL_ICD_LOADER_HASH} + ) + FetchContent_MakeAvailable(ocl-icd-loader) + FetchContent_GetProperties(ocl-icd-loader) + + set(OpenCL_LIBRARY ${PROJECT_BINARY_DIR}/lib/libOpenCL.so CACHE PATH "Path to OpenCL ICD Loader") +endif() + # The OpenCL target can be set manually on upstream cmake to avoid using find_package(). if (NOT UR_OPENCL_ICD_LOADER_LIBRARY) find_package(OpenCL REQUIRED)