Skip to content

Commit ab76c28

Browse files
authored
Merge branch 'main' into cuda-cubemap-driver-fix
2 parents eaf85e4 + fa06e95 commit ab76c28

File tree

11 files changed

+174
-133
lines changed

11 files changed

+174
-133
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
name: Build - Fuzztests on L0 HW - Reusable
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
test_label:
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
fuzztest-build-hw:
16+
name: Build and run fuzz tests on L0 HW
17+
if: github.repository == 'oneapi-src/unified-runtime' # run only on upstream; forks won't have the HW
18+
strategy:
19+
matrix:
20+
build_type: [Debug, Release]
21+
compiler: [{c: clang, cxx: clang++}]
22+
23+
runs-on: 'FUZZTESTS'
24+
# In order to use sanitizers, vm.mmap_rnd_bits=28 must be set in the system,
25+
# otherwise random SEGV at the start of the test occurs.
26+
# Alternatively, clang 18.1.0 onwards with fixed sanitizers behavior can be used,
27+
# if available.
28+
# TODO: Remove this advice once clang 18.1.0 is available in the system (like ie. as an apt package).
29+
30+
steps:
31+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
32+
33+
- name: Install pip packages
34+
run: pip install -r third_party/requirements.txt
35+
36+
- name: Download DPC++
37+
run: |
38+
wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/nightly-2024-01-29/sycl_linux.tar.gz
39+
mkdir dpcpp_compiler
40+
tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz -C dpcpp_compiler
41+
42+
- name: Build level zero with gcc
43+
run: |
44+
git clone -b v1.17.6 --depth=1 https://github.com/oneapi-src/level-zero.git ${{github.workspace}}/level-zero
45+
cd ${{github.workspace}}/level-zero
46+
cmake -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
47+
cmake --build build -j $(nproc)
48+
49+
- name: Configure CMake
50+
run: >
51+
cmake
52+
-B${{github.workspace}}/build
53+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
54+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
55+
-DUR_ENABLE_TRACING=ON
56+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
57+
-DUR_BUILD_TESTS=ON
58+
-DUR_USE_ASAN=ON
59+
-DUR_USE_UBSAN=ON
60+
-DUR_BUILD_ADAPTER_L0=ON
61+
-DUR_LEVEL_ZERO_LOADER_LIBRARY=${{github.workspace}}/level-zero/build/lib/libze_loader.so
62+
-DUR_LEVEL_ZERO_INCLUDE_DIR=${{github.workspace}}/level-zero/include/
63+
-DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++
64+
-DUR_SYCL_LIBRARY_DIR=${{github.workspace}}/dpcpp_compiler/lib
65+
66+
- name: Build
67+
run: cmake --build ${{github.workspace}}/build -j $(nproc)
68+
69+
- name: Fuzz test
70+
working-directory: ${{github.workspace}}/build
71+
run: ctest -C ${{matrix.build_type}} --output-on-failure -L "${{inputs.test_label}}" --verbose
72+
73+
- name: Get information about platform
74+
if: ${{ always() }}
75+
run: .github/scripts/get_system_info.sh

.github/workflows/cmake.yml

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -116,51 +116,12 @@ jobs:
116116
working-directory: ${{github.workspace}}/build
117117
run: ctest -C ${{matrix.build_type}} --output-on-failure -L "umf|loader|validation|tracing|unit|urtrace"
118118

119-
fuzztest-build:
120-
name: Build and run quick fuzztest scenarios
121-
strategy:
122-
matrix:
123-
build_type: [Debug, Release]
124-
compiler: [{c: clang, cxx: clang++}]
125-
126-
runs-on: 'ubuntu-22.04'
127-
128-
steps:
129-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
130-
131-
- name: Install pip packages
132-
run: pip install -r third_party/requirements.txt
133-
134-
- name: Download DPC++
135-
run: |
136-
sudo apt install libncurses5
137-
wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/sycl-nightly%2F20230626/dpcpp-compiler.tar.gz
138-
tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz
139-
140-
- name: Setup DPC++
141-
run: |
142-
source ${{github.workspace}}/dpcpp_compiler/startup.sh
143-
144-
- name: Configure CMake
145-
run: >
146-
cmake
147-
-B${{github.workspace}}/build
148-
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
149-
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
150-
-DUR_ENABLE_TRACING=ON
151-
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
152-
-DUR_BUILD_TESTS=ON
153-
-DUR_USE_ASAN=ON
154-
-DUR_USE_UBSAN=ON
155-
-DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++
156-
157-
- name: Build
158-
run: cmake --build ${{github.workspace}}/build -j $(nproc)
159-
160-
- name: Fuzz test
161-
working-directory: ${{github.workspace}}/build
162-
run: ctest -C ${{matrix.build_type}} --output-on-failure -L "fuzz-short" --verbose
163-
119+
fuzztest:
120+
name: Fuzz tests short
121+
uses: ./.github/workflows/build-fuzz-reusable.yml
122+
with:
123+
test_label: "fuzz-short"
124+
164125
level-zero:
165126
name: Level Zero
166127
uses: ./.github/workflows/build-hw-reusable.yml

.github/workflows/nightly.yml

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,8 @@ permissions:
99
contents: read
1010

1111
jobs:
12-
long-fuzz-test:
13-
name: Run long fuzz tests
14-
strategy:
15-
matrix:
16-
build_type: [Debug, Release]
17-
compiler: [{c: clang, cxx: clang++}]
18-
19-
runs-on: 'ubuntu-22.04'
20-
21-
steps:
22-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
23-
24-
- name: Install pip packages
25-
run: pip install -r third_party/requirements.txt
26-
27-
- name: Download DPC++
28-
run: |
29-
wget -O ${{github.workspace}}/dpcpp_compiler.tar.gz https://github.com/intel/llvm/releases/download/nightly-2024-01-29/sycl_linux.tar.gz
30-
mkdir dpcpp_compiler
31-
tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz -C dpcpp_compiler
32-
33-
- name: Configure CMake
34-
run: >
35-
cmake
36-
-B${{github.workspace}}/build
37-
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
38-
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
39-
-DUR_ENABLE_TRACING=ON
40-
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
41-
-DUR_BUILD_TESTS=ON
42-
-DUR_USE_ASAN=ON
43-
-DUR_USE_UBSAN=ON
44-
-DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++
45-
46-
- name: Build
47-
run: >
48-
LD_LIBRARY_PATH=${{github.workspace}}/dpcpp_compiler/lib
49-
cmake --build ${{github.workspace}}/build -j $(nproc)
50-
51-
- name: Fuzz long test
52-
working-directory: ${{github.workspace}}/build
53-
run: ctest -C ${{matrix.build_type}} --output-on-failure -L "fuzz-long"
12+
fuzztest:
13+
name: Fuzz tests long
14+
uses: ./.github/workflows/build-fuzz-reusable.yml
15+
with:
16+
test_label: "fuzz-long"

source/adapters/level_zero/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ if (NOT UR_LEVEL_ZERO_LOADER_LIBRARY STREQUAL "")
1919
file(COPY ${UR_LEVEL_ZERO_LOADER_LIBRARY} DESTINATION ${LEVEL_ZERO_COPY_DIR} FOLLOW_SYMLINK_CHAIN)
2020
endif()
2121
if (NOT UR_LEVEL_ZERO_INCLUDE_DIR STREQUAL "")
22-
set(LEVEL_ZERO_INCLUDE_DIR ${LEVEL_ZERO_COPY_DIR}/level_zero)
22+
set(LEVEL_ZERO_INCLUDE_DIR ${LEVEL_ZERO_COPY_DIR})
2323
message(STATUS "Level Zero Adapter: Copying Level Zero headers to local build tree")
24-
file(COPY ${UR_LEVEL_ZERO_INCLUDE_DIR}/level_zero DESTINATION ${LEVEL_ZERO_COPY_DIR})
24+
file(COPY ${UR_LEVEL_ZERO_INCLUDE_DIR}/ DESTINATION ${LEVEL_ZERO_COPY_DIR})
2525
endif()
2626

2727
if (NOT DEFINED LEVEL_ZERO_LIBRARY OR NOT DEFINED LEVEL_ZERO_INCLUDE_DIR)

source/adapters/level_zero/context.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,10 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList(
733733
!(ZeCommandListIt->second.InOrderList)) {
734734
continue;
735735
}
736+
// Only allow to reuse Regular Command Lists
737+
if (ZeCommandListIt->second.IsImmediate) {
738+
continue;
739+
}
736740
auto &ZeCommandList = ZeCommandListIt->first;
737741
auto it = Queue->CommandListMap.find(ZeCommandList);
738742
if (it != Queue->CommandListMap.end()) {

source/adapters/level_zero/context.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
struct l0_command_list_cache_info {
3131
ZeStruct<ze_command_queue_desc_t> ZeQueueDesc;
3232
bool InOrderList = false;
33+
bool IsImmediate = false;
3334
};
3435

3536
struct ur_context_handle_t_ : _ur_object {

source/adapters/level_zero/queue.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ ur_result_t ur_queue_handle_legacy_t_::queueRelease() {
665665
struct l0_command_list_cache_info ListInfo;
666666
ListInfo.ZeQueueDesc = it->second.ZeQueueDesc;
667667
ListInfo.InOrderList = it->second.IsInOrderList;
668+
ListInfo.IsImmediate = it->second.IsImmediate;
668669
ZeCommandListCache.push_back({it->first, ListInfo});
669670
} else {
670671
// A non-reusable comamnd list that came from a make_queue call is
@@ -745,7 +746,8 @@ void ur_queue_handle_legacy_t_::ur_queue_group_t::setImmCmdList(
745746
.insert(std::pair<ze_command_list_handle_t, ur_command_list_info_t>{
746747
ZeCommandList,
747748
ur_command_list_info_t(nullptr, true, false, nullptr, ZeQueueDesc,
748-
queue->useCompletionBatching(), false)})
749+
queue->useCompletionBatching(), false,
750+
false, true)})
749751
.first);
750752
}
751753

@@ -2080,6 +2082,7 @@ ur_result_t ur_queue_handle_legacy_t_::resetCommandList(
20802082
struct l0_command_list_cache_info ListInfo;
20812083
ListInfo.ZeQueueDesc = CommandList->second.ZeQueueDesc;
20822084
ListInfo.InOrderList = CommandList->second.IsInOrderList;
2085+
ListInfo.IsImmediate = CommandList->second.IsImmediate;
20832086
ZeCommandListCache.push_back({CommandList->first, ListInfo});
20842087
}
20852088

@@ -2430,9 +2433,9 @@ ur_queue_handle_legacy_t_::ur_queue_group_t::getImmCmdList() {
24302433
Queue->CommandListMap
24312434
.insert(std::pair<ze_command_list_handle_t, ur_command_list_info_t>{
24322435
ZeCommandList,
2433-
ur_command_list_info_t(nullptr, true, false, nullptr,
2434-
ZeCommandQueueDesc,
2435-
Queue->useCompletionBatching())})
2436+
ur_command_list_info_t(
2437+
nullptr, true, false, nullptr, ZeCommandQueueDesc,
2438+
Queue->useCompletionBatching(), true, false, true)})
24362439
.first;
24372440

24382441
return ImmCmdLists[Index];

source/adapters/level_zero/queue.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,11 @@ struct ur_command_list_info_t {
168168
bool IsClosed, ze_command_queue_handle_t ZeQueue,
169169
ZeStruct<ze_command_queue_desc_t> ZeQueueDesc,
170170
bool UseCompletionBatching, bool CanReuse = true,
171-
bool IsInOrderList = false)
171+
bool IsInOrderList = false, bool IsImmediate = false)
172172
: ZeFence(ZeFence), ZeFenceInUse(ZeFenceInUse), IsClosed(IsClosed),
173173
ZeQueue(ZeQueue), ZeQueueDesc(ZeQueueDesc),
174-
IsInOrderList(IsInOrderList), CanReuse(CanReuse) {
174+
IsInOrderList(IsInOrderList), CanReuse(CanReuse),
175+
IsImmediate(IsImmediate) {
175176
if (UseCompletionBatching) {
176177
completions = ur_completion_batches();
177178
}
@@ -204,6 +205,7 @@ struct ur_command_list_info_t {
204205
// Indicates if this is an inorder list
205206
bool IsInOrderList;
206207
bool CanReuse;
208+
bool IsImmediate;
207209

208210
// Helper functions to tell if this is a copy command-list.
209211
bool isCopy(ur_queue_handle_legacy_t Queue) const;

test/fuzz/CMakeLists.txt

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
1-
# Copyright (C) 2023 Intel Corporation
1+
# Copyright (C) 2023-2024 Intel Corporation
22
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
33
# See LICENSE.TXT
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

66
function(add_fuzz_test name label)
77
set(TEST_TARGET_NAME fuzztest-${name})
8-
add_ur_executable(${TEST_TARGET_NAME}
9-
urFuzz.cpp)
10-
target_link_libraries(${TEST_TARGET_NAME}
11-
PRIVATE
12-
${PROJECT_NAME}::loader
13-
${PROJECT_NAME}::headers
14-
${PROJECT_NAME}::common
15-
-fsanitize=fuzzer)
16-
add_test(NAME ${TEST_TARGET_NAME}
17-
COMMAND ${TEST_TARGET_NAME} ${ARGN} -verbosity=1
18-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
198

20-
set(ENV_VARS UR_ENABLE_LAYERS=UR_LAYER_FULL_VALIDATION)
21-
if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_ALL)
9+
set(ENV_VARS "")
10+
if(UR_USE_UBSAN)
2211
list(APPEND ENV_VARS
23-
UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_level_zero>\"
24-
NEOReadDebugKeys=1
25-
DisableDeepBind=1)
26-
else()
27-
list(APPEND ENV_VARS UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_null>\")
12+
UBSAN_OPTIONS=print_stacktrace=1)
2813
endif()
2914
if(UR_ENABLE_TRACING)
3015
list(APPEND ENV_VARS
@@ -33,17 +18,42 @@ function(add_fuzz_test name label)
3318
XPTI_SUBSCRIBERS=$<TARGET_FILE:collector>
3419
UR_ENABLE_LAYERS=UR_LAYER_TRACING)
3520
endif()
21+
22+
if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_ALL)
23+
list(APPEND ENV_VARS
24+
UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_level_zero>\")
25+
if(UR_USE_ASAN)
26+
list(APPEND ENV_VARS
27+
NEOReadDebugKeys=1
28+
DisableDeepBind=1)
29+
endif()
30+
else()
31+
list(APPEND ENV_VARS UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_adapter_null>\")
32+
endif()
33+
34+
add_test(NAME ${TEST_TARGET_NAME}
35+
COMMAND fuzztest-base ${ARGN} -verbosity=1 -detect_leaks=0
36+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
37+
3638
set_tests_properties(${TEST_TARGET_NAME} PROPERTIES
3739
LABELS ${label}
3840
ENVIRONMENT "${ENV_VARS}")
39-
# TODO: Should we check if this sanitizer flag is available?
40-
target_compile_options(${TEST_TARGET_NAME} PRIVATE -g -fsanitize=fuzzer)
41-
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE -DKERNEL_IL_PATH="${UR_CONFORMANCE_DEVICE_BINARIES_DIR}/bar/sycl_spir641.spv")
42-
target_include_directories(${TEST_TARGET_NAME} PRIVATE ${UR_CONFORMANCE_DEVICE_BINARIES_DIR})
43-
44-
add_dependencies(${TEST_TARGET_NAME} generate_device_binaries)
4541
endfunction()
4642

43+
# Create a single binary
44+
add_ur_executable(fuzztest-base
45+
urFuzz.cpp)
46+
target_link_libraries(fuzztest-base
47+
PRIVATE
48+
${PROJECT_NAME}::loader
49+
${PROJECT_NAME}::headers
50+
${PROJECT_NAME}::common
51+
-fsanitize=fuzzer)
52+
target_compile_options(fuzztest-base PRIVATE -g -fsanitize=fuzzer)
53+
target_compile_definitions(fuzztest-base PRIVATE -DKERNEL_IL_PATH="${UR_CONFORMANCE_DEVICE_BINARIES_DIR}/fill/spir64.bin.0")
54+
target_include_directories(fuzztest-base PRIVATE ${UR_CONFORMANCE_DEVICE_BINARIES_DIR})
55+
add_dependencies(fuzztest-base generate_device_binaries)
56+
4757
# Add long test
4858
add_fuzz_test(base fuzz-long -max_total_time=600 -seed=1)
4959

0 commit comments

Comments
 (0)