From 6d75dcfad617c35cc735ee2a82b2f5c5c1ca9ebe Mon Sep 17 00:00:00 2001 From: Patryk Kaminski Date: Fri, 16 Feb 2024 13:13:02 +0100 Subject: [PATCH 1/5] Verbose long fuzz tests --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 3deade6603..4ee74c8081 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -50,4 +50,4 @@ jobs: - name: Fuzz long test working-directory: ${{github.workspace}}/build - run: ctest -C ${{matrix.build_type}} --output-on-failure -L "fuzz-long" + run: ctest -C ${{matrix.build_type}} --output-on-failure -L "fuzz-long" --verbose From fcd0fe514042d509790eb579814efa1a855a3995 Mon Sep 17 00:00:00 2001 From: Patryk Kaminski Date: Wed, 5 Jun 2024 13:30:33 +0200 Subject: [PATCH 2/5] Update in custom user paths of L0 Changes the handling of the UR_LEVEL_ZERO_INCLUDE_DIR environment variable. The user can provide any direct path to the include directory containing level zero headers. No 'level-zero' subdirectory appended to this path anymore. Note that the path to the include directory has to end with a slash, like ie. "level-zero/include/". --- source/adapters/level_zero/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/adapters/level_zero/CMakeLists.txt b/source/adapters/level_zero/CMakeLists.txt index 171aaa3924..1c74124fc4 100644 --- a/source/adapters/level_zero/CMakeLists.txt +++ b/source/adapters/level_zero/CMakeLists.txt @@ -19,9 +19,9 @@ if (NOT UR_LEVEL_ZERO_LOADER_LIBRARY STREQUAL "") file(COPY ${UR_LEVEL_ZERO_LOADER_LIBRARY} DESTINATION ${LEVEL_ZERO_COPY_DIR} FOLLOW_SYMLINK_CHAIN) endif() if (NOT UR_LEVEL_ZERO_INCLUDE_DIR STREQUAL "") - set(LEVEL_ZERO_INCLUDE_DIR ${LEVEL_ZERO_COPY_DIR}/level_zero) + set(LEVEL_ZERO_INCLUDE_DIR ${LEVEL_ZERO_COPY_DIR}) message(STATUS "Level Zero Adapter: Copying Level Zero headers to local build tree") - file(COPY ${UR_LEVEL_ZERO_INCLUDE_DIR}/level_zero DESTINATION ${LEVEL_ZERO_COPY_DIR}) + file(COPY ${UR_LEVEL_ZERO_INCLUDE_DIR}/ DESTINATION ${LEVEL_ZERO_COPY_DIR}) endif() if (NOT DEFINED LEVEL_ZERO_LIBRARY OR NOT DEFINED LEVEL_ZERO_INCLUDE_DIR) From 3bf4675b0752ffd5c4359ca50677a3e8fa54ea59 Mon Sep 17 00:00:00 2001 From: Patryk Kaminski Date: Mon, 11 Mar 2024 14:58:51 +0100 Subject: [PATCH 3/5] Run fuzztests on L0 HW in CI instead of running fuzztests in CI on the null adapter. --- .github/workflows/cmake.yml | 23 +++++++++++++++++++---- .github/workflows/nightly.yml | 23 +++++++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 49e68c6b86..c0503905b5 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -116,14 +116,15 @@ jobs: working-directory: ${{github.workspace}}/build run: ctest -C ${{matrix.build_type}} --output-on-failure -L "umf|loader|validation|tracing|unit|urtrace" - fuzztest-build: - name: Build and run quick fuzztest scenarios + fuzztest-build-hw: + name: Build and run quick fuzztest scenarios on L0 HW + if: github.repository == 'oneapi-src/unified-runtime' # run only on upstream; forks won't have the HW strategy: matrix: build_type: [Debug, Release] compiler: [{c: clang, cxx: clang++}] - runs-on: 'ubuntu-22.04' + runs-on: 'FUZZTESTS' steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -133,7 +134,6 @@ jobs: - 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 @@ -141,6 +141,13 @@ jobs: run: | source ${{github.workspace}}/dpcpp_compiler/startup.sh + - name: Build level zero + run: | + git clone -b v1.17.6 --depth=1 https://github.com/oneapi-src/level-zero.git ${{github.workspace}}/level-zero + cd ${{github.workspace}}/level-zero + cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ + cmake --build build -j $(nproc) + - name: Configure CMake run: > cmake @@ -152,7 +159,11 @@ jobs: -DUR_BUILD_TESTS=ON -DUR_USE_ASAN=ON -DUR_USE_UBSAN=ON + -DUR_BUILD_ADAPTER_L0=ON + -DUR_LEVEL_ZERO_LOADER_LIBRARY=${{github.workspace}}/level-zero/build/lib/libze_loader.so + -DUR_LEVEL_ZERO_INCLUDE_DIR=${{github.workspace}}/level-zero/include/ -DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++ + -DUR_SYCL_LIBRARY_DIR=${{github.workspace}}/dpcpp_compiler/lib - name: Build run: cmake --build ${{github.workspace}}/build -j $(nproc) @@ -160,6 +171,10 @@ jobs: - name: Fuzz test working-directory: ${{github.workspace}}/build run: ctest -C ${{matrix.build_type}} --output-on-failure -L "fuzz-short" --verbose + + - name: Get information about platform + if: ${{ always() }} + run: .github/scripts/get_system_info.sh level-zero: name: Level Zero diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4ee74c8081..15957785d1 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -9,14 +9,15 @@ permissions: contents: read jobs: - long-fuzz-test: + long-fuzz-test-hw: name: Run long fuzz tests + if: github.repository == 'oneapi-src/unified-runtime' # run only on upstream; forks won't have the HW strategy: matrix: build_type: [Debug, Release] compiler: [{c: clang, cxx: clang++}] - runs-on: 'ubuntu-22.04' + runs-on: 'FUZZTESTS' steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -30,6 +31,13 @@ jobs: mkdir dpcpp_compiler tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz -C dpcpp_compiler + - name: Build level zero + run: | + git clone -b v1.17.6 --depth=1 https://github.com/oneapi-src/level-zero.git ${{github.workspace}}/level-zero + cd ${{github.workspace}}/level-zero + cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ + cmake --build build -j $(nproc) + - name: Configure CMake run: > cmake @@ -41,13 +49,20 @@ jobs: -DUR_BUILD_TESTS=ON -DUR_USE_ASAN=ON -DUR_USE_UBSAN=ON + -DUR_BUILD_ADAPTER_L0=ON + -DUR_LEVEL_ZERO_LOADER_LIBRARY=${{github.workspace}}/level-zero/build/lib/libze_loader.so + -DUR_LEVEL_ZERO_INCLUDE_DIR=${{github.workspace}}/level-zero/include/ -DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++ + -DUR_SYCL_LIBRARY_DIR=${{github.workspace}}/dpcpp_compiler/lib - name: Build - run: > - LD_LIBRARY_PATH=${{github.workspace}}/dpcpp_compiler/lib + run: | cmake --build ${{github.workspace}}/build -j $(nproc) - name: Fuzz long test working-directory: ${{github.workspace}}/build run: ctest -C ${{matrix.build_type}} --output-on-failure -L "fuzz-long" --verbose + + - name: Get information about platform + if: ${{ always() }} + run: .github/scripts/get_system_info.sh From afefdaaaf7c11947164622a3235256dcaef81c29 Mon Sep 17 00:00:00 2001 From: Patryk Kaminski Date: Fri, 16 Feb 2024 13:04:19 +0100 Subject: [PATCH 4/5] Refactor kernel triggering in fuzz tests - Properly set up and trigger the test kernel within the fuzz test. - Change the test kernel used from "bar" to "fill". - Refactor env vars used in test. --- test/fuzz/CMakeLists.txt | 4 ++-- test/fuzz/urFuzz.cpp | 40 +++++++++++++++++++++++++++++----------- test/fuzz/utils.hpp | 8 ++++++-- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/test/fuzz/CMakeLists.txt b/test/fuzz/CMakeLists.txt index 897075c53d..bc8512e4b3 100644 --- a/test/fuzz/CMakeLists.txt +++ b/test/fuzz/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2023 Intel Corporation +# Copyright (C) 2023-2024 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 @@ -38,7 +38,7 @@ function(add_fuzz_test name label) ENVIRONMENT "${ENV_VARS}") # TODO: Should we check if this sanitizer flag is available? target_compile_options(${TEST_TARGET_NAME} PRIVATE -g -fsanitize=fuzzer) - target_compile_definitions(${TEST_TARGET_NAME} PRIVATE -DKERNEL_IL_PATH="${UR_CONFORMANCE_DEVICE_BINARIES_DIR}/bar/sycl_spir641.spv") + target_compile_definitions(${TEST_TARGET_NAME} PRIVATE -DKERNEL_IL_PATH="${UR_CONFORMANCE_DEVICE_BINARIES_DIR}/fill/spir64.bin.0") target_include_directories(${TEST_TARGET_NAME} PRIVATE ${UR_CONFORMANCE_DEVICE_BINARIES_DIR}) add_dependencies(${TEST_TARGET_NAME} generate_device_binaries) diff --git a/test/fuzz/urFuzz.cpp b/test/fuzz/urFuzz.cpp index f91ca23633..7662a668fd 100644 --- a/test/fuzz/urFuzz.cpp +++ b/test/fuzz/urFuzz.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Intel Corporation +// Copyright (C) 2023-2024 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 @@ -353,36 +353,54 @@ int ur_program_create_with_il(TestState &state) { } std::vector il_bin; - ur_program_handle_t program = nullptr; - ur_kernel_handle_t kernel = nullptr; - ur_queue_handle_t queue = nullptr; - ur_event_handle_t event = nullptr; + ur_program_handle_t program; + ur_kernel_handle_t kernel; + ur_queue_handle_t queue; + ur_event_handle_t event; auto &context = state.contexts[state.context_num]->handle; auto &device = state.devices[state.device_num]; + // TODO: Use some generic utility to retrieve/use kernels std::string kernel_name = - uur::device_binaries::program_kernel_map["bar"][0]; + uur::device_binaries::program_kernel_map["fill"][0]; il_bin = state.load_kernel_source(); if (il_bin.empty()) { return -1; } + constexpr int vec_size = 64; + std::vector vec(vec_size, 0); + urProgramCreateWithIL(context, il_bin.data(), il_bin.size(), nullptr, &program); urProgramBuild(context, program, nullptr); + + ur_mem_handle_t memory_buffer; + urMemBufferCreate(context, UR_MEM_FLAG_READ_WRITE, vec_size * sizeof(int), + nullptr, &memory_buffer); urKernelCreate(program, kernel_name.data(), &kernel); + urKernelSetArgMemObj(kernel, 0, nullptr, memory_buffer); + urQueueCreate(context, device, nullptr, &queue); - const uint32_t nDim = 3; - const size_t gWorkOffset[] = {0, 0, 0}; - const size_t gWorkSize[] = {128, 128, 128}; + urEnqueueMemBufferWrite(queue, memory_buffer, true, 0, + vec_size * sizeof(int), vec.data(), 0, nullptr, + &event); + urEventWait(1, &event); + urEventRelease(event); - urEnqueueKernelLaunch(queue, kernel, nDim, gWorkOffset, gWorkSize, nullptr, - 0, nullptr, &event); + constexpr uint32_t nDim = 3; + const size_t gWorkOffset[] = {0, 0, 0}; + const size_t gWorkSize[] = {vec_size * 4, 1, 1}; + const size_t lWorkSize[] = {1, 1, 1}; + urEnqueueKernelLaunch(queue, kernel, nDim, gWorkOffset, gWorkSize, + lWorkSize, 0, nullptr, &event); urEventWait(1, &event); urEventRelease(event); + urQueueFinish(queue); + urMemRelease(memory_buffer); urQueueRelease(queue); urKernelRelease(kernel); urProgramRelease(program); diff --git a/test/fuzz/utils.hpp b/test/fuzz/utils.hpp index a65fc2e381..fc7eee23ad 100644 --- a/test/fuzz/utils.hpp +++ b/test/fuzz/utils.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2023 Intel Corporation +// Copyright (C) 2023-2024 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 @@ -105,7 +105,11 @@ struct TestState { uint8_t context_num; TestState(std::unique_ptr data_provider) - : data_provider(std::move(data_provider)) {} + : data_provider(std::move(data_provider)) { + num_adapters = 0; + num_platforms = 0; + num_devices = 0; + } template int get_next_input_data(IntType *data) { if (data_provider->remaining_bytes() < sizeof(IntType)) { From d5a90ad51aa7dda85dedb0bf5904e6c7f20f17c8 Mon Sep 17 00:00:00 2001 From: Patryk Kaminski Date: Thu, 6 Jun 2024 13:42:27 +0200 Subject: [PATCH 5/5] Refactor fuzz tests --- .github/workflows/build-fuzz-reusable.yml | 75 +++++++++++++++++++++++ .github/workflows/cmake.yml | 66 ++------------------ .github/workflows/nightly.yml | 62 ++----------------- test/fuzz/CMakeLists.txt | 58 ++++++++++-------- 4 files changed, 120 insertions(+), 141 deletions(-) create mode 100644 .github/workflows/build-fuzz-reusable.yml diff --git a/.github/workflows/build-fuzz-reusable.yml b/.github/workflows/build-fuzz-reusable.yml new file mode 100644 index 0000000000..ae589540fb --- /dev/null +++ b/.github/workflows/build-fuzz-reusable.yml @@ -0,0 +1,75 @@ +--- +name: Build - Fuzztests on L0 HW - Reusable + +on: + workflow_call: + inputs: + test_label: + required: true + type: string + +permissions: + contents: read + +jobs: + fuzztest-build-hw: + name: Build and run fuzz tests on L0 HW + if: github.repository == 'oneapi-src/unified-runtime' # run only on upstream; forks won't have the HW + strategy: + matrix: + build_type: [Debug, Release] + compiler: [{c: clang, cxx: clang++}] + + runs-on: 'FUZZTESTS' + # In order to use sanitizers, vm.mmap_rnd_bits=28 must be set in the system, + # otherwise random SEGV at the start of the test occurs. + # Alternatively, clang 18.1.0 onwards with fixed sanitizers behavior can be used, + # if available. + # TODO: Remove this advice once clang 18.1.0 is available in the system (like ie. as an apt package). + + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Install pip packages + run: pip install -r third_party/requirements.txt + + - name: Download DPC++ + run: | + wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/nightly-2024-01-29/sycl_linux.tar.gz + mkdir dpcpp_compiler + tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz -C dpcpp_compiler + + - name: Build level zero with gcc + run: | + git clone -b v1.17.6 --depth=1 https://github.com/oneapi-src/level-zero.git ${{github.workspace}}/level-zero + cd ${{github.workspace}}/level-zero + cmake -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ + cmake --build build -j $(nproc) + + - 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_BUILD_ADAPTER_L0=ON + -DUR_LEVEL_ZERO_LOADER_LIBRARY=${{github.workspace}}/level-zero/build/lib/libze_loader.so + -DUR_LEVEL_ZERO_INCLUDE_DIR=${{github.workspace}}/level-zero/include/ + -DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++ + -DUR_SYCL_LIBRARY_DIR=${{github.workspace}}/dpcpp_compiler/lib + + - 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 "${{inputs.test_label}}" --verbose + + - name: Get information about platform + if: ${{ always() }} + run: .github/scripts/get_system_info.sh diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index c0503905b5..fbb7ecc664 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -116,66 +116,12 @@ jobs: working-directory: ${{github.workspace}}/build run: ctest -C ${{matrix.build_type}} --output-on-failure -L "umf|loader|validation|tracing|unit|urtrace" - fuzztest-build-hw: - name: Build and run quick fuzztest scenarios on L0 HW - if: github.repository == 'oneapi-src/unified-runtime' # run only on upstream; forks won't have the HW - strategy: - matrix: - build_type: [Debug, Release] - compiler: [{c: clang, cxx: clang++}] - - runs-on: 'FUZZTESTS' - - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Install pip packages - run: pip install -r third_party/requirements.txt - - - name: Download DPC++ - run: | - 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: Build level zero - run: | - git clone -b v1.17.6 --depth=1 https://github.com/oneapi-src/level-zero.git ${{github.workspace}}/level-zero - cd ${{github.workspace}}/level-zero - cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ - cmake --build build -j $(nproc) - - - 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_BUILD_ADAPTER_L0=ON - -DUR_LEVEL_ZERO_LOADER_LIBRARY=${{github.workspace}}/level-zero/build/lib/libze_loader.so - -DUR_LEVEL_ZERO_INCLUDE_DIR=${{github.workspace}}/level-zero/include/ - -DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++ - -DUR_SYCL_LIBRARY_DIR=${{github.workspace}}/dpcpp_compiler/lib - - - 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" --verbose - - - name: Get information about platform - if: ${{ always() }} - run: .github/scripts/get_system_info.sh - + fuzztest: + name: Fuzz tests short + uses: ./.github/workflows/build-fuzz-reusable.yml + with: + test_label: "fuzz-short" + level-zero: name: Level Zero uses: ./.github/workflows/build-hw-reusable.yml diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 15957785d1..6c14faf7df 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -9,60 +9,8 @@ permissions: contents: read jobs: - long-fuzz-test-hw: - name: Run long fuzz tests - if: github.repository == 'oneapi-src/unified-runtime' # run only on upstream; forks won't have the HW - strategy: - matrix: - build_type: [Debug, Release] - compiler: [{c: clang, cxx: clang++}] - - runs-on: 'FUZZTESTS' - - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Install pip packages - run: pip install -r third_party/requirements.txt - - - name: Download DPC++ - run: | - wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/nightly-2024-01-29/sycl_linux.tar.gz - mkdir dpcpp_compiler - tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz -C dpcpp_compiler - - - name: Build level zero - run: | - git clone -b v1.17.6 --depth=1 https://github.com/oneapi-src/level-zero.git ${{github.workspace}}/level-zero - cd ${{github.workspace}}/level-zero - cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ - cmake --build build -j $(nproc) - - - 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_BUILD_ADAPTER_L0=ON - -DUR_LEVEL_ZERO_LOADER_LIBRARY=${{github.workspace}}/level-zero/build/lib/libze_loader.so - -DUR_LEVEL_ZERO_INCLUDE_DIR=${{github.workspace}}/level-zero/include/ - -DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++ - -DUR_SYCL_LIBRARY_DIR=${{github.workspace}}/dpcpp_compiler/lib - - - name: Build - run: | - cmake --build ${{github.workspace}}/build -j $(nproc) - - - name: Fuzz long test - working-directory: ${{github.workspace}}/build - run: ctest -C ${{matrix.build_type}} --output-on-failure -L "fuzz-long" --verbose - - - name: Get information about platform - if: ${{ always() }} - run: .github/scripts/get_system_info.sh + fuzztest: + name: Fuzz tests long + uses: ./.github/workflows/build-fuzz-reusable.yml + with: + test_label: "fuzz-long" diff --git a/test/fuzz/CMakeLists.txt b/test/fuzz/CMakeLists.txt index bc8512e4b3..c3b867928e 100644 --- a/test/fuzz/CMakeLists.txt +++ b/test/fuzz/CMakeLists.txt @@ -5,26 +5,11 @@ function(add_fuzz_test name label) set(TEST_TARGET_NAME fuzztest-${name}) - add_ur_executable(${TEST_TARGET_NAME} - urFuzz.cpp) - target_link_libraries(${TEST_TARGET_NAME} - PRIVATE - ${PROJECT_NAME}::loader - ${PROJECT_NAME}::headers - ${PROJECT_NAME}::common - -fsanitize=fuzzer) - add_test(NAME ${TEST_TARGET_NAME} - COMMAND ${TEST_TARGET_NAME} ${ARGN} -verbosity=1 - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - set(ENV_VARS UR_ENABLE_LAYERS=UR_LAYER_FULL_VALIDATION) - if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_ALL) + set(ENV_VARS "") + if(UR_USE_UBSAN) list(APPEND ENV_VARS - UR_ADAPTERS_FORCE_LOAD=\"$\" - NEOReadDebugKeys=1 - DisableDeepBind=1) - else() - list(APPEND ENV_VARS UR_ADAPTERS_FORCE_LOAD=\"$\") + UBSAN_OPTIONS=print_stacktrace=1) endif() if(UR_ENABLE_TRACING) list(APPEND ENV_VARS @@ -33,17 +18,42 @@ function(add_fuzz_test name label) XPTI_SUBSCRIBERS=$ UR_ENABLE_LAYERS=UR_LAYER_TRACING) endif() + + if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_ALL) + list(APPEND ENV_VARS + UR_ADAPTERS_FORCE_LOAD=\"$\") + if(UR_USE_ASAN) + list(APPEND ENV_VARS + NEOReadDebugKeys=1 + DisableDeepBind=1) + endif() + else() + list(APPEND ENV_VARS UR_ADAPTERS_FORCE_LOAD=\"$\") + endif() + + add_test(NAME ${TEST_TARGET_NAME} + COMMAND fuzztest-base ${ARGN} -verbosity=1 -detect_leaks=0 + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set_tests_properties(${TEST_TARGET_NAME} PROPERTIES LABELS ${label} ENVIRONMENT "${ENV_VARS}") - # TODO: Should we check if this sanitizer flag is available? - target_compile_options(${TEST_TARGET_NAME} PRIVATE -g -fsanitize=fuzzer) - target_compile_definitions(${TEST_TARGET_NAME} PRIVATE -DKERNEL_IL_PATH="${UR_CONFORMANCE_DEVICE_BINARIES_DIR}/fill/spir64.bin.0") - target_include_directories(${TEST_TARGET_NAME} PRIVATE ${UR_CONFORMANCE_DEVICE_BINARIES_DIR}) - - add_dependencies(${TEST_TARGET_NAME} generate_device_binaries) endfunction() +# Create a single binary +add_ur_executable(fuzztest-base + urFuzz.cpp) +target_link_libraries(fuzztest-base + PRIVATE + ${PROJECT_NAME}::loader + ${PROJECT_NAME}::headers + ${PROJECT_NAME}::common + -fsanitize=fuzzer) +target_compile_options(fuzztest-base PRIVATE -g -fsanitize=fuzzer) +target_compile_definitions(fuzztest-base PRIVATE -DKERNEL_IL_PATH="${UR_CONFORMANCE_DEVICE_BINARIES_DIR}/fill/spir64.bin.0") +target_include_directories(fuzztest-base PRIVATE ${UR_CONFORMANCE_DEVICE_BINARIES_DIR}) +add_dependencies(fuzztest-base generate_device_binaries) + # Add long test add_fuzz_test(base fuzz-long -max_total_time=600 -seed=1)