From 217079d1006b7d541f9e39cbf79ee66ea7f3ac7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Mestre?= Date: Tue, 24 Oct 2023 19:02:42 +0100 Subject: [PATCH] OpenCL CI trial and error --- .github/workflows/bandit.yml | 50 +- .github/workflows/cmake.yml | 580 +++++++++--------- .github/workflows/codeql.yml | 136 ++-- .github/workflows/coverity.yml | 84 +-- source/adapters/opencl/CMakeLists.txt | 28 + source/adapters/opencl/adapter.cpp | 4 +- test/conformance/CMakeLists.txt | 3 + .../context/context_adapter_opencl.match | 0 test/conformance/cts_exe.py | 1 + .../device/device_adapter_opencl.match | 0 .../enqueue/enqueue_adapter_opencl.match | 0 .../event/event_adapter_opencl.match | 0 .../kernel/kernel_adapter_opencl.match | 0 .../memory/memory_adapter_opencl.match | 0 .../platform/platform_adapter_opencl.match | 1 + .../program/program_adapter_opencl.match | 0 .../queue/queue_adapter_opencl.match | 0 .../runtime/runtime_adapter_opencl.match | 0 .../sampler/sampler_adapter_opencl.match | 0 test/conformance/usm/usm_adapter_opencl.match | 0 .../virtual_memory_adapter_opencl.match | 0 21 files changed, 469 insertions(+), 418 deletions(-) create mode 100644 test/conformance/context/context_adapter_opencl.match create mode 100644 test/conformance/device/device_adapter_opencl.match create mode 100644 test/conformance/enqueue/enqueue_adapter_opencl.match create mode 100644 test/conformance/event/event_adapter_opencl.match create mode 100644 test/conformance/kernel/kernel_adapter_opencl.match create mode 100644 test/conformance/memory/memory_adapter_opencl.match create mode 100644 test/conformance/platform/platform_adapter_opencl.match create mode 100644 test/conformance/program/program_adapter_opencl.match create mode 100644 test/conformance/queue/queue_adapter_opencl.match create mode 100644 test/conformance/runtime/runtime_adapter_opencl.match create mode 100644 test/conformance/sampler/sampler_adapter_opencl.match create mode 100644 test/conformance/usm/usm_adapter_opencl.match create mode 100644 test/conformance/virtual_memory/virtual_memory_adapter_opencl.match diff --git a/.github/workflows/bandit.yml b/.github/workflows/bandit.yml index e356e0bdb4..9cf5c655b8 100644 --- a/.github/workflows/bandit.yml +++ b/.github/workflows/bandit.yml @@ -1,25 +1,25 @@ -# Runs bandit security checker for code written in Python. -name: Bandit - -on: [push, pull_request, workflow_dispatch] - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - linux: - name: Bandit - runs-on: ubuntu-latest - - steps: - - name: Clone the git repo - uses: actions/checkout@v3 - - - name: Install pip packages - run: pip install -r third_party/requirements.txt - - # Scan is run only for the 'tools' folder. - - name: Run Bandit - run: | - bandit -r tools +## Runs bandit security checker for code written in Python. +#name: Bandit +# +#on: [push, pull_request, workflow_dispatch] +# +#concurrency: +# group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} +# cancel-in-progress: true +# +#jobs: +# linux: +# name: Bandit +# runs-on: ubuntu-latest +# +# steps: +# - name: Clone the git repo +# uses: actions/checkout@v3 +# +# - name: Install pip packages +# run: pip install -r third_party/requirements.txt +# +# # Scan is run only for the 'tools' folder. +# - name: Run Bandit +# run: | +# bandit -r tools diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9edbd459d7..45593251b3 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -7,155 +7,155 @@ concurrency: cancel-in-progress: true jobs: - ubuntu-build: - name: Build - Ubuntu - strategy: - matrix: - os: ['ubuntu-20.04', 'ubuntu-22.04'] - build_type: [Debug, Release] - compiler: [{c: gcc, cxx: g++}] - libbacktrace: ['-DVAL_USE_LIBBACKTRACE_BACKTRACE=OFF'] - pool_tracking: ['-DUMF_ENABLE_POOL_TRACKING=ON', '-DUMF_ENABLE_POOL_TRACKING=OFF'] - include: - - os: 'ubuntu-22.04' - build_type: Release - compiler: {c: clang, cxx: clang++} - libbacktrace: '-DVAL_USE_LIBBACKTRACE_BACKTRACE=OFF' - - os: 'ubuntu-22.04' - build_type: Release - compiler: {c: gcc, cxx: g++} - libbacktrace: '-DVAL_USE_LIBBACKTRACE_BACKTRACE=ON' - - os: 'ubuntu-22.04' - build_type: Release - compiler: {c: clang, cxx: clang++} - libbacktrace: '-DVAL_USE_LIBBACKTRACE_BACKTRACE=ON' - - os: 'ubuntu-20.04' - build_type: Release - compiler: {c: gcc-7, cxx: g++-7} - - runs-on: ${{matrix.os}} - - steps: - - uses: actions/checkout@v3 - - - name: Install apt packages - run: | - sudo apt-get update - sudo apt-get install -y doxygen ${{matrix.compiler.c}} - - - name: Install g++-7 - if: matrix.compiler.cxx == 'g++-7' - run: | - sudo apt-get install -y ${{matrix.compiler.cxx}} - - - name: Install pip packages - run: pip install -r third_party/requirements.txt - - - name: Install libbacktrace - if: matrix.libbacktrace == '-DVAL_USE_LIBBACKTRACE_BACKTRACE=ON' - run: | - git clone https://github.com/ianlancetaylor/libbacktrace.git - cd libbacktrace - ./configure - make - sudo make install - cd .. - - - name: Download DPC++ - if: matrix.os == 'ubuntu-22.04' - run: | - sudo apt install libncurses5 - wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/nightly-2023-09-21/sycl_linux.tar.gz - mkdir -p ${{github.workspace}}/dpcpp_compiler - tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz -C ${{github.workspace}}/dpcpp_compiler - - - name: Configure CMake - if: matrix.os == 'ubuntu-22.04' - run: > - cmake - -B${{github.workspace}}/build - -DCMAKE_C_COMPILER=${{matrix.compiler.c}} - -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} - -DUR_ENABLE_TRACING=ON - -DCMAKE_BUILD_TYPE=${{matrix.build_type}} - -DUR_BUILD_TESTS=ON - -DUR_FORMAT_CPP_STYLE=ON - -DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++ - ${{matrix.libbacktrace}} - ${{matrix.pool_tracking}} - - - name: Configure CMake - if: matrix.os == 'ubuntu-20.04' - run: > - cmake - -B${{github.workspace}}/build - -DCMAKE_C_COMPILER=${{matrix.compiler.c}} - -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} - -DUR_ENABLE_TRACING=ON - -DCMAKE_BUILD_TYPE=${{matrix.build_type}} - -DUR_BUILD_TESTS=ON - -DUR_FORMAT_CPP_STYLE=ON - ${{matrix.libbacktrace}} - ${{matrix.pool_tracking}} - - - name: Generate source from spec, check for uncommitted diff - if: matrix.os == 'ubuntu-22.04' - run: cmake --build ${{github.workspace}}/build --target check-generated - - - name: Verify that each source file contains a license - run: cmake --build ${{github.workspace}}/build --target verify-licenses - - - name: Build - run: cmake --build ${{github.workspace}}/build -j $(nproc) - - - name: Test - working-directory: ${{github.workspace}}/build - run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|umf|loader|validation|tracing|unit|urtrace" - - fuzztest-build: - name: Build and run quick fuzztest scenarios - strategy: - matrix: - build_type: [Debug, Release] - compiler: [{c: clang, cxx: clang++}] - - runs-on: 'ubuntu-22.04' - - steps: - - uses: actions/checkout@v3 - - - name: Install pip packages - run: pip install -r third_party/requirements.txt - - - name: Download DPC++ - run: | - sudo apt install libncurses5 - wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/sycl-nightly%2F20230626/dpcpp-compiler.tar.gz - tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz - - - name: Setup DPC++ - run: | - source ${{github.workspace}}/dpcpp_compiler/startup.sh - - - name: Configure CMake - run: > - cmake - -B${{github.workspace}}/build - -DCMAKE_C_COMPILER=${{matrix.compiler.c}} - -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} - -DUR_ENABLE_TRACING=ON - -DCMAKE_BUILD_TYPE=${{matrix.build_type}} - -DUR_BUILD_TESTS=ON - -DUR_USE_ASAN=ON - -DUR_USE_UBSAN=ON - -DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++ - - - name: Build - run: cmake --build ${{github.workspace}}/build -j $(nproc) - - - name: Fuzz test - working-directory: ${{github.workspace}}/build - run: ctest -C ${{matrix.build_type}} --output-on-failure -L "fuzz-short" +# ubuntu-build: +# name: Build - Ubuntu +# strategy: +# matrix: +# os: ['ubuntu-20.04', 'ubuntu-22.04'] +# build_type: [Debug, Release] +# compiler: [{c: gcc, cxx: g++}] +# libbacktrace: ['-DVAL_USE_LIBBACKTRACE_BACKTRACE=OFF'] +# pool_tracking: ['-DUMF_ENABLE_POOL_TRACKING=ON', '-DUMF_ENABLE_POOL_TRACKING=OFF'] +# include: +# - os: 'ubuntu-22.04' +# build_type: Release +# compiler: {c: clang, cxx: clang++} +# libbacktrace: '-DVAL_USE_LIBBACKTRACE_BACKTRACE=OFF' +# - os: 'ubuntu-22.04' +# build_type: Release +# compiler: {c: gcc, cxx: g++} +# libbacktrace: '-DVAL_USE_LIBBACKTRACE_BACKTRACE=ON' +# - os: 'ubuntu-22.04' +# build_type: Release +# compiler: {c: clang, cxx: clang++} +# libbacktrace: '-DVAL_USE_LIBBACKTRACE_BACKTRACE=ON' +# - os: 'ubuntu-20.04' +# build_type: Release +# compiler: {c: gcc-7, cxx: g++-7} +# +# runs-on: ${{matrix.os}} +# +# steps: +# - uses: actions/checkout@v3 +# +# - name: Install apt packages +# run: | +# sudo apt-get update +# sudo apt-get install -y doxygen ${{matrix.compiler.c}} +# +# - name: Install g++-7 +# if: matrix.compiler.cxx == 'g++-7' +# run: | +# sudo apt-get install -y ${{matrix.compiler.cxx}} +# +# - name: Install pip packages +# run: pip install -r third_party/requirements.txt +# +# - name: Install libbacktrace +# if: matrix.libbacktrace == '-DVAL_USE_LIBBACKTRACE_BACKTRACE=ON' +# run: | +# git clone https://github.com/ianlancetaylor/libbacktrace.git +# cd libbacktrace +# ./configure +# make +# sudo make install +# cd .. +# +# - name: Download DPC++ +# if: matrix.os == 'ubuntu-22.04' +# run: | +# sudo apt install libncurses5 +# wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/nightly-2023-09-21/sycl_linux.tar.gz +# mkdir -p ${{github.workspace}}/dpcpp_compiler +# tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz -C ${{github.workspace}}/dpcpp_compiler +# +# - name: Configure CMake +# if: matrix.os == 'ubuntu-22.04' +# run: > +# cmake +# -B${{github.workspace}}/build +# -DCMAKE_C_COMPILER=${{matrix.compiler.c}} +# -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} +# -DUR_ENABLE_TRACING=ON +# -DCMAKE_BUILD_TYPE=${{matrix.build_type}} +# -DUR_BUILD_TESTS=ON +# -DUR_FORMAT_CPP_STYLE=ON +# -DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++ +# ${{matrix.libbacktrace}} +# ${{matrix.pool_tracking}} +# +# - name: Configure CMake +# if: matrix.os == 'ubuntu-20.04' +# run: > +# cmake +# -B${{github.workspace}}/build +# -DCMAKE_C_COMPILER=${{matrix.compiler.c}} +# -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} +# -DUR_ENABLE_TRACING=ON +# -DCMAKE_BUILD_TYPE=${{matrix.build_type}} +# -DUR_BUILD_TESTS=ON +# -DUR_FORMAT_CPP_STYLE=ON +# ${{matrix.libbacktrace}} +# ${{matrix.pool_tracking}} +# +# - name: Generate source from spec, check for uncommitted diff +# if: matrix.os == 'ubuntu-22.04' +# run: cmake --build ${{github.workspace}}/build --target check-generated +# +# - name: Verify that each source file contains a license +# run: cmake --build ${{github.workspace}}/build --target verify-licenses +# +# - name: Build +# run: cmake --build ${{github.workspace}}/build -j $(nproc) +# +# - name: Test +# working-directory: ${{github.workspace}}/build +# run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|umf|loader|validation|tracing|unit|urtrace" +# +# fuzztest-build: +# name: Build and run quick fuzztest scenarios +# strategy: +# matrix: +# build_type: [Debug, Release] +# compiler: [{c: clang, cxx: clang++}] +# +# runs-on: 'ubuntu-22.04' +# +# steps: +# - uses: actions/checkout@v3 +# +# - name: Install pip packages +# run: pip install -r third_party/requirements.txt +# +# - name: Download DPC++ +# run: | +# sudo apt install libncurses5 +# wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/sycl-nightly%2F20230626/dpcpp-compiler.tar.gz +# tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz +# +# - name: Setup DPC++ +# run: | +# source ${{github.workspace}}/dpcpp_compiler/startup.sh +# +# - name: Configure CMake +# run: > +# cmake +# -B${{github.workspace}}/build +# -DCMAKE_C_COMPILER=${{matrix.compiler.c}} +# -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} +# -DUR_ENABLE_TRACING=ON +# -DCMAKE_BUILD_TYPE=${{matrix.build_type}} +# -DUR_BUILD_TESTS=ON +# -DUR_USE_ASAN=ON +# -DUR_USE_UBSAN=ON +# -DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++ +# +# - name: Build +# run: cmake --build ${{github.workspace}}/build -j $(nproc) +# +# - name: Fuzz test +# working-directory: ${{github.workspace}}/build +# run: ctest -C ${{matrix.build_type}} --output-on-failure -L "fuzz-short" adapter-build-hw: name: Build - Adapters on HW @@ -163,14 +163,12 @@ 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: OPENCL, runner: ubuntu-22.04, triplet: spir64} ] build_type: [Debug, Release] - compiler: [{c: gcc, cxx: g++}, {c: clang, cxx: clang++}] + compiler: [{c: clang, cxx: clang++}] - runs-on: ${{matrix.adapter.name}} + runs-on: ${{matrix.adapter.runner}} steps: - uses: actions/checkout@v3 @@ -178,6 +176,24 @@ jobs: - name: Install pip packages run: pip install -r third_party/requirements.txt + - name: Install OpenCL + if: matrix.adapter.name == 'OpenCL' + run: | + lscpu + sudo apt-get update + sudo apt-get install ocl-icd-libopencl1 ocl-icd-opencl-dev clinfo +# 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 + clinfo + - 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 @@ -215,131 +231,131 @@ jobs: working-directory: ${{github.workspace}}/build run: ctest -C ${{matrix.build_type}} --output-on-failure -L "conformance" --timeout 180 - examples-build-hw: - name: Build - examples on HW - if: github.repository == 'oneapi-src/unified-runtime' # run only on upstream; forks won't have the HW - strategy: - matrix: - adapter: [ - {name: L0} - ] - build_type: [Debug, Release] - compiler: [{c: gcc, cxx: g++}, {c: clang, cxx: clang++}] - - runs-on: ${{matrix.adapter.name}} - - steps: - - uses: actions/checkout@v3 - - - name: Install pip packages - run: pip install -r third_party/requirements.txt - - - name: Init conda env - uses: conda-incubator/setup-miniconda@v2 - with: - miniconda-version: "latest" - activate-environment: examples - environment-file: third_party/deps.yml - auto-activate-base: false - - - name: Configure CMake - shell: bash -el {0} - run: > - cmake - -B${{github.workspace}}/build - -DCMAKE_C_COMPILER=${{matrix.compiler.c}} - -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} - -DCMAKE_BUILD_TYPE=${{matrix.build_type}} - -DUR_BUILD_ADAPTER_${{matrix.adapter.name}}=ON - -DUR_BUILD_EXAMPLE_CODEGEN=ON - -DUR_DEVELOPER_MODE=ON - - - name: Build - run: cmake --build ${{github.workspace}}/build -j $(nproc) - - - name: Test codegen example - working-directory: ${{github.workspace}}/build - run: bin/codegen - - windows-build: - name: Build - Windows - strategy: - matrix: - os: ['windows-2019', 'windows-2022'] - adapter: [ - {name: None, var: ''}, {name: L0, var: '-DUR_BUILD_ADAPTER_L0=ON'} - ] - - # TODO: building level zero loader on windows-2019 is currently broken - exclude: - - os: 'windows-2019' - adapter: {name: L0, var: '-DUR_BUILD_ADAPTER_L0=ON'} - build_type: [Debug, Release] - compiler: [{c: cl.exe, cxx: cl.exe}, {c: clang-cl.exe, cxx: clang-cl.exe}] - runs-on: ${{matrix.os}} - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - - name: Install prerequisites - run: python3 -m pip install -r third_party/requirements.txt - - - name: Configure CMake - run: > - cmake - -B${{github.workspace}}/build - -DCMAKE_C_COMPILER=${{matrix.compiler.c}} - -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} - -DCMAKE_POLICY_DEFAULT_CMP0094=NEW - -DUR_ENABLE_TRACING=ON - -DUR_DEVELOPER_MODE=ON - -DUR_BUILD_TESTS=ON - -DUR_FORMAT_CPP_STYLE=ON - ${{matrix.adapter.var}} - - # TODO: re-enable when check-generated is fixed for windows runners see #888 - # - name: Generate source from spec, check for uncommitted diff - # if: matrix.os == 'windows-2022' - # run: cmake --build ${{github.workspace}}/build --target check-generated --config ${{matrix.build_type}} - - - name: Build all - run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -j 2 - - - name: Test - working-directory: ${{github.workspace}}/build - run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|umf|loader|validation|tracing|unit|urtrace" - - - macos-build: - name: Build - MacOS - strategy: - matrix: - os: ['macos-12', 'macos-13'] - runs-on: ${{matrix.os}} - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - - name: Install prerequisites - run: python3 -m pip install -r third_party/requirements.txt - - - name: Configure CMake - run: > - cmake - -B${{github.workspace}}/build - -DUR_ENABLE_TRACING=ON - -DUR_DEVELOPER_MODE=ON - -DCMAKE_BUILD_TYPE=Release - -DUR_BUILD_TESTS=ON - -DUR_FORMAT_CPP_STYLE=ON - -DUMF_ENABLE_POOL_TRACKING=ON - - name: Build - run: cmake --build ${{github.workspace}}/build -j $(nproc) +# examples-build-hw: +# name: Build - examples on HW +# if: github.repository == 'oneapi-src/unified-runtime' # run only on upstream; forks won't have the HW +# strategy: +# matrix: +# adapter: [ +# {name: L0} +# ] +# build_type: [Debug, Release] +# compiler: [{c: gcc, cxx: g++}, {c: clang, cxx: clang++}] +# +# runs-on: ${{matrix.adapter.name}} +# +# steps: +# - uses: actions/checkout@v3 +# +# - name: Install pip packages +# run: pip install -r third_party/requirements.txt +# +# - name: Init conda env +# uses: conda-incubator/setup-miniconda@v2 +# with: +# miniconda-version: "latest" +# activate-environment: examples +# environment-file: third_party/deps.yml +# auto-activate-base: false +# +# - name: Configure CMake +# shell: bash -el {0} +# run: > +# cmake +# -B${{github.workspace}}/build +# -DCMAKE_C_COMPILER=${{matrix.compiler.c}} +# -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} +# -DCMAKE_BUILD_TYPE=${{matrix.build_type}} +# -DUR_BUILD_ADAPTER_${{matrix.adapter.name}}=ON +# -DUR_BUILD_EXAMPLE_CODEGEN=ON +# -DUR_DEVELOPER_MODE=ON +# +# - name: Build +# run: cmake --build ${{github.workspace}}/build -j $(nproc) +# +# - name: Test codegen example +# working-directory: ${{github.workspace}}/build +# run: bin/codegen +# +# windows-build: +# name: Build - Windows +# strategy: +# matrix: +# os: ['windows-2019', 'windows-2022'] +# adapter: [ +# {name: None, var: ''}, {name: L0, var: '-DUR_BUILD_ADAPTER_L0=ON'} +# ] +# +# # TODO: building level zero loader on windows-2019 is currently broken +# exclude: +# - os: 'windows-2019' +# adapter: {name: L0, var: '-DUR_BUILD_ADAPTER_L0=ON'} +# build_type: [Debug, Release] +# compiler: [{c: cl.exe, cxx: cl.exe}, {c: clang-cl.exe, cxx: clang-cl.exe}] +# runs-on: ${{matrix.os}} +# +# steps: +# - uses: actions/checkout@v3 +# +# - uses: actions/setup-python@v4 +# with: +# python-version: 3.9 +# +# - name: Install prerequisites +# run: python3 -m pip install -r third_party/requirements.txt +# +# - name: Configure CMake +# run: > +# cmake +# -B${{github.workspace}}/build +# -DCMAKE_C_COMPILER=${{matrix.compiler.c}} +# -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} +# -DCMAKE_POLICY_DEFAULT_CMP0094=NEW +# -DUR_ENABLE_TRACING=ON +# -DUR_DEVELOPER_MODE=ON +# -DUR_BUILD_TESTS=ON +# -DUR_FORMAT_CPP_STYLE=ON +# ${{matrix.adapter.var}} +# +# # TODO: re-enable when check-generated is fixed for windows runners see #888 +# # - name: Generate source from spec, check for uncommitted diff +# # if: matrix.os == 'windows-2022' +# # run: cmake --build ${{github.workspace}}/build --target check-generated --config ${{matrix.build_type}} +# +# - name: Build all +# run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -j 2 +# +# - name: Test +# working-directory: ${{github.workspace}}/build +# run: ctest -C ${{matrix.build_type}} --output-on-failure -L "python|umf|loader|validation|tracing|unit|urtrace" +# +# +# macos-build: +# name: Build - MacOS +# strategy: +# matrix: +# os: ['macos-12', 'macos-13'] +# runs-on: ${{matrix.os}} +# +# steps: +# - uses: actions/checkout@v3 +# +# - uses: actions/setup-python@v4 +# with: +# python-version: 3.9 +# +# - name: Install prerequisites +# run: python3 -m pip install -r third_party/requirements.txt +# +# - name: Configure CMake +# run: > +# cmake +# -B${{github.workspace}}/build +# -DUR_ENABLE_TRACING=ON +# -DUR_DEVELOPER_MODE=ON +# -DCMAKE_BUILD_TYPE=Release +# -DUR_BUILD_TESTS=ON +# -DUR_FORMAT_CPP_STYLE=ON +# -DUMF_ENABLE_POOL_TRACKING=ON +# - name: Build +# run: cmake --build ${{github.workspace}}/build -j $(nproc) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index bf312be396..eacd520520 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,68 +1,68 @@ -name: "CodeQL" - -on: [push, pull_request] - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - analyze-ubuntu: - name: Analyze on Ubuntu - runs-on: ubuntu-latest - permissions: - security-events: write - - strategy: - fail-fast: false - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: cpp, python - - - name: Install pip packages - run: pip install -r third_party/requirements.txt - - - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_ENABLE_TRACING=ON -DUR_BUILD_TOOLS=ON -DUMF_ENABLE_POOL_TRACKING=ON - - - name: Build - run: cmake --build ${{github.workspace}}/build -j $(nproc) - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - - analyze-windows: - name: Analyze on Windows - runs-on: windows-latest - permissions: - security-events: write - - strategy: - fail-fast: false - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: cpp, python - - - name: Install pip packages - run: python3 -m pip install -r third_party/requirements.txt - - - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_POLICY_DEFAULT_CMP0094=NEW -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_ENABLE_TRACING=ON -DUR_BUILD_TOOLS=ON -DUMF_ENABLE_POOL_TRACKING=ON - - - name: Build - run: cmake --build ${{github.workspace}}/build -j $(nproc) --config Release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 +#name: "CodeQL" +# +#on: [push, pull_request] +# +#concurrency: +# group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} +# cancel-in-progress: true +# +#jobs: +# analyze-ubuntu: +# name: Analyze on Ubuntu +# runs-on: ubuntu-latest +# permissions: +# security-events: write +# +# strategy: +# fail-fast: false +# +# steps: +# - name: Checkout repository +# uses: actions/checkout@v3 +# +# - name: Initialize CodeQL +# uses: github/codeql-action/init@v2 +# with: +# languages: cpp, python +# +# - name: Install pip packages +# run: pip install -r third_party/requirements.txt +# +# - name: Configure CMake +# run: cmake -B ${{github.workspace}}/build -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_ENABLE_TRACING=ON -DUR_BUILD_TOOLS=ON -DUMF_ENABLE_POOL_TRACKING=ON +# +# - name: Build +# run: cmake --build ${{github.workspace}}/build -j $(nproc) +# +# - name: Perform CodeQL Analysis +# uses: github/codeql-action/analyze@v2 +# +# analyze-windows: +# name: Analyze on Windows +# runs-on: windows-latest +# permissions: +# security-events: write +# +# strategy: +# fail-fast: false +# +# steps: +# - name: Checkout repository +# uses: actions/checkout@v3 +# +# - name: Initialize CodeQL +# uses: github/codeql-action/init@v2 +# with: +# languages: cpp, python +# +# - name: Install pip packages +# run: python3 -m pip install -r third_party/requirements.txt +# +# - name: Configure CMake +# run: cmake -B ${{github.workspace}}/build -DCMAKE_POLICY_DEFAULT_CMP0094=NEW -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUR_ENABLE_TRACING=ON -DUR_BUILD_TOOLS=ON -DUMF_ENABLE_POOL_TRACKING=ON +# +# - name: Build +# run: cmake --build ${{github.workspace}}/build -j $(nproc) --config Release +# +# - name: Perform CodeQL Analysis +# uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index de327f92c7..135e4a61b1 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -1,45 +1,45 @@ +## +## Copyright (C) 2023 Intel Corporation +## +## Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +## See LICENSE.TXT +## SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +## +#name: coverity-unified-runtime +## It runs static analysis build - Coverity. It requires special token (set in CI's secret). # -# Copyright (C) 2023 Intel Corporation +#on: +# push: +# branches: ["main"] +# workflow_dispatch: # -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#env: +# WORKDIR: ${{ github.workspace }} +# COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }} +# COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} +# COVERITY_SCAN_PROJECT_NAME: ${{ github.repository }} +# COVERITY_SCAN_BUILD_COMMAND: "cmake --build ${{github.workspace}}/build" +# COVERITY_SCAN_BRANCH_PATTERN: "main" +# TRAVIS_BRANCH: ${{ github.ref_name }} # -name: coverity-unified-runtime -# It runs static analysis build - Coverity. It requires special token (set in CI's secret). - -on: - push: - branches: ["main"] - workflow_dispatch: - -env: - WORKDIR: ${{ github.workspace }} - COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }} - COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} - COVERITY_SCAN_PROJECT_NAME: ${{ github.repository }} - COVERITY_SCAN_BUILD_COMMAND: "cmake --build ${{github.workspace}}/build" - COVERITY_SCAN_BRANCH_PATTERN: "main" - TRAVIS_BRANCH: ${{ github.ref_name }} - -jobs: - linux: - name: Coverity - runs-on: ubuntu-latest - - steps: - - name: Clone the git repo - uses: actions/checkout@v3 - - - name: Install pip packages - run: pip install -r third_party/requirements.txt - - - name: Configure CMake - run: cmake -B $WORKDIR/build -DUR_ENABLE_TRACING=ON -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUMF_ENABLE_POOL_TRACKING=ON - - - name: Run Coverity - run: | - cd $WORKDIR/build - wget https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh - patch < "../.github/scripts/0001-travis-fix-travisci_build_coverity_scan.sh.patch" - bash ./travisci_build_coverity_scan.sh +#jobs: +# linux: +# name: Coverity +# runs-on: ubuntu-latest +# +# steps: +# - name: Clone the git repo +# uses: actions/checkout@v3 +# +# - name: Install pip packages +# run: pip install -r third_party/requirements.txt +# +# - name: Configure CMake +# run: cmake -B $WORKDIR/build -DUR_ENABLE_TRACING=ON -DUR_DEVELOPER_MODE=ON -DUR_BUILD_TESTS=ON -DUMF_ENABLE_POOL_TRACKING=ON +# +# - name: Run Coverity +# run: | +# cd $WORKDIR/build +# wget https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh +# patch < "../.github/scripts/0001-travis-fix-travisci_build_coverity_scan.sh.patch" +# bash ./travisci_build_coverity_scan.sh diff --git a/source/adapters/opencl/CMakeLists.txt b/source/adapters/opencl/CMakeLists.txt index dc43a68ffa..c610d1de20 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) diff --git a/source/adapters/opencl/adapter.cpp b/source/adapters/opencl/adapter.cpp index 10713b9ff9..f1c5eaa7fb 100644 --- a/source/adapters/opencl/adapter.cpp +++ b/source/adapters/opencl/adapter.cpp @@ -18,7 +18,9 @@ ur_adapter_handle_t_ adapter{}; UR_APIEXPORT ur_result_t UR_APICALL urInit(ur_device_init_flags_t, ur_loader_config_handle_t) { - cl_ext::ExtFuncPtrCache = new cl_ext::ExtFuncPtrCacheT(); + if (!cl_ext::ExtFuncPtrCache) { + cl_ext::ExtFuncPtrCache = new cl_ext::ExtFuncPtrCacheT(); + } return UR_RESULT_SUCCESS; } diff --git a/test/conformance/CMakeLists.txt b/test/conformance/CMakeLists.txt index e90b74f4cd..85a53e9e55 100644 --- a/test/conformance/CMakeLists.txt +++ b/test/conformance/CMakeLists.txt @@ -9,6 +9,9 @@ function(add_test_adapter name adapter) set(TEST_TARGET_NAME test-${name}) set(TEST_NAME ${name}-${adapter}) +# add_test(NAME ${TEST_NAME} +# COMMAND ${TEST_TARGET_NAME} +# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) add_test(NAME ${TEST_NAME} COMMAND ${CMAKE_COMMAND} -D TEST_FILE=${Python3_EXECUTABLE} diff --git a/test/conformance/context/context_adapter_opencl.match b/test/conformance/context/context_adapter_opencl.match new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/conformance/cts_exe.py b/test/conformance/cts_exe.py index 2b2c009a8e..2ec8232dba 100644 --- a/test/conformance/cts_exe.py +++ b/test/conformance/cts_exe.py @@ -24,6 +24,7 @@ pat = re.compile(r'\[( )*FAILED( )*\]') for line in result.stdout.readlines(): + print(line) if pat.search(line): test_case = line.split(" ")[5] test_case = test_case.rstrip(',') diff --git a/test/conformance/device/device_adapter_opencl.match b/test/conformance/device/device_adapter_opencl.match new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/conformance/enqueue/enqueue_adapter_opencl.match b/test/conformance/enqueue/enqueue_adapter_opencl.match new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/conformance/event/event_adapter_opencl.match b/test/conformance/event/event_adapter_opencl.match new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/conformance/kernel/kernel_adapter_opencl.match b/test/conformance/kernel/kernel_adapter_opencl.match new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/conformance/memory/memory_adapter_opencl.match b/test/conformance/memory/memory_adapter_opencl.match new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/conformance/platform/platform_adapter_opencl.match b/test/conformance/platform/platform_adapter_opencl.match new file mode 100644 index 0000000000..df63fbef05 --- /dev/null +++ b/test/conformance/platform/platform_adapter_opencl.match @@ -0,0 +1 @@ +urPlatformGetTest.InvalidNumEntries diff --git a/test/conformance/program/program_adapter_opencl.match b/test/conformance/program/program_adapter_opencl.match new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/conformance/queue/queue_adapter_opencl.match b/test/conformance/queue/queue_adapter_opencl.match new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/conformance/runtime/runtime_adapter_opencl.match b/test/conformance/runtime/runtime_adapter_opencl.match new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/conformance/sampler/sampler_adapter_opencl.match b/test/conformance/sampler/sampler_adapter_opencl.match new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/conformance/usm/usm_adapter_opencl.match b/test/conformance/usm/usm_adapter_opencl.match new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/conformance/virtual_memory/virtual_memory_adapter_opencl.match b/test/conformance/virtual_memory/virtual_memory_adapter_opencl.match new file mode 100644 index 0000000000..e69de29bb2