Skip to content

Commit a073325

Browse files
committed
Merge remote-tracking branch 'origin/main' into yc-PR/241107-misc-minor-fix
2 parents 062479a + 2d97965 commit a073325

File tree

248 files changed

+7173
-4454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

248 files changed

+7173
-4454
lines changed

.github/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ loader:
3131
opencl:
3232
- changed-files:
3333
- any-glob-to-any-file:
34-
- source/adapter/opencl/**
34+
- source/adapters/opencl/**
3535

3636
level-zero:
3737
- changed-files:

.github/scripts/0001-travis-fix-travisci_build_coverity_scan.sh.patch

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/benchmarks-reusable.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ jobs:
176176
let markdown = ""
177177
try {
178178
const fs = require('fs');
179-
markdown = fs.readFileSync('benchmark_results.md', 'utf8');
179+
markdown = fs.readFileSync('ur-repo/benchmark_results.md', 'utf8');
180180
} catch(err) {
181181
}
182182
@@ -199,5 +199,5 @@ jobs:
199199
if: ${{ always() && inputs.upload_report }}
200200
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
201201
with:
202-
path: ${{ github.workspace }}/ur-repo/benchmark_results.html
202+
path: ur-repo/benchmark_results.html
203203
key: benchmark-results-${{ matrix.adapter.str_name }}-${{ github.run_id }}

.github/workflows/build-fuzz-reusable.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ jobs:
4141
4242
- name: Build level zero with gcc
4343
run: |
44-
git clone -b v1.17.6 --depth=1 https://github.com/oneapi-src/level-zero.git ${{github.workspace}}/level-zero
44+
git clone -b v1.18.5 --depth=1 https://github.com/oneapi-src/level-zero.git ${{github.workspace}}/level-zero
4545
cd ${{github.workspace}}/level-zero
4646
cmake -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
4747
cmake --build build -j $(nproc)
4848
4949
- name: Configure CMake
50+
# CFI sanitization (or flto?) seems to cause linking to fail
51+
# https://github.com/oneapi-src/unified-runtime/issues/2323
5052
run: >
5153
cmake
5254
-B${{github.workspace}}/build
@@ -58,6 +60,7 @@ jobs:
5860
-DUR_USE_ASAN=ON
5961
-DUR_USE_UBSAN=ON
6062
-DUR_BUILD_ADAPTER_L0=ON
63+
-DUR_USE_CFI=OFF
6164
-DUR_LEVEL_ZERO_LOADER_LIBRARY=${{github.workspace}}/level-zero/build/lib/libze_loader.so
6265
-DUR_LEVEL_ZERO_INCLUDE_DIR=${{github.workspace}}/level-zero/include/
6366
-DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++

.github/workflows/cmake.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,12 @@ jobs:
256256
compiler: {c: clang-cl, cxx: clang-cl}
257257

258258
build_type: [Debug, Release]
259-
compiler: [{c: cl, cxx: cl}, {c: clang-cl, cxx: clang-cl}]
259+
# TODO: clang-cl seems to be fully broken (https://github.com/oneapi-src/unified-runtime/issues/2348)
260+
#compiler: [{c: cl, cxx: cl}, {c: clang-cl, cxx: clang-cl}]
261+
compiler: [{c: cl, cxx: cl}]
260262
include:
261-
- compiler: {c: clang-cl, cxx: clang-cl}
262-
toolset: "-T ClangCL"
263+
#- compiler: {c: clang-cl, cxx: clang-cl}
264+
# toolset: "-T ClangCL"
263265
- os: 'windows-2022'
264266
adapter: {name: L0, var: '-DUR_BUILD_ADAPTER_L0=ON -DUR_STATIC_ADAPTER_L0=ON'}
265267
build_type: 'Release'

.github/workflows/coverity.yml

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,81 @@
1-
#
2-
# Copyright (C) 2023-2024 Intel Corporation
3-
#
4-
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
5-
# See LICENSE.TXT
6-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7-
#
1+
# Coverity - static analysis build. It requires Coverity's token (set in CI's secret).
82
name: coverity-unified-runtime
9-
# It runs static analysis build - Coverity. It requires special token (set in CI's secret).
103

114
on:
125
workflow_dispatch:
136
schedule:
147
# Run every day at 22:00 UTC
158
- cron: '0 22 * * *'
169

17-
env:
18-
WORKDIR: ${{ github.workspace }}
19-
COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
20-
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
21-
COVERITY_SCAN_PROJECT_NAME: ${{ github.repository }}
22-
COVERITY_SCAN_BUILD_COMMAND: "cmake --build ${{github.workspace}}/build"
23-
COVERITY_SCAN_BRANCH_PATTERN: "main"
24-
TRAVIS_BRANCH: ${{ github.ref_name }}
25-
2610
permissions:
2711
contents: read
2812

2913
jobs:
30-
linux:
14+
coverity:
3115
name: Coverity
32-
runs-on: coverity
16+
# run only on upstream; forks don't have token for upstream's cov project
17+
if: github.repository == 'oneapi-src/unified-runtime'
18+
runs-on: ubuntu-latest
3319

3420
steps:
35-
- name: Clone the git repo
21+
- name: Checkout repository
3622
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Install dependencies
27+
run: |
28+
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
29+
sudo dpkg -i cuda-keyring_1.1-1_all.deb
30+
sudo apt-get update
31+
sudo apt-get install -y libhwloc-dev libtbb-dev cuda-toolkit-12-6
3732
3833
- name: Install pip packages
3934
run: pip install -r third_party/requirements.txt
4035

36+
- name: Download Coverity
37+
run: |
38+
wget -O coverity_tool.tgz -nv https://scan.coverity.com/download/linux64 \
39+
--post-data "token=${{ secrets.COVERITY_SCAN_TOKEN }}&project=oneapi-src%2Funified-runtime"
40+
41+
- name: Extract Coverity
42+
run: tar xzf coverity_tool.tgz
43+
44+
# TODO: enable HIP adapter as well (requires proper package(s) installation)
4145
- name: Configure CMake
4246
run: >
4347
cmake
44-
-B $WORKDIR/build
48+
-B ${{github.workspace}}/build
49+
-DCMAKE_BUILD_TYPE=Release
50+
-DUR_DEVELOPER_MODE=OFF
51+
-DUR_FORMAT_CPP_STYLE=ON
4552
-DUR_ENABLE_TRACING=ON
46-
-DUR_DEVELOPER_MODE=ON
4753
-DUR_BUILD_TESTS=ON
48-
-DUMF_ENABLE_POOL_TRACKING=ON
49-
-DUR_FORMAT_CPP_STYLE=ON
50-
-DCMAKE_BUILD_TYPE=Debug
5154
-DUR_BUILD_ADAPTER_L0=ON
5255
-DUR_BUILD_ADAPTER_CUDA=ON
53-
-DCUDA_CUDA_LIBRARY=/usr/local/cuda/lib64/stubs/libcuda.so
56+
-DCUDA_CUDA_LIBRARY=/usr/local/cuda-12.6/targets/x86_64-linux/lib/stubs/libcuda.so
5457
-DUR_BUILD_ADAPTER_NATIVE_CPU=ON
55-
-DUR_BUILD_ADAPTER_HIP=ON
58+
-DUR_BUILD_ADAPTER_HIP=OFF
5659
-DUR_BUILD_ADAPTER_OPENCL=ON
5760
58-
- name: Run Coverity
61+
- name: Build
62+
run: |
63+
export COVERITY_DIR=$(find . -maxdepth 1 -type d -name "cov-analysis-linux64-*" | head -n 1)
64+
if [ -n "$COVERITY_DIR" ]; then
65+
export PATH="$PATH:$COVERITY_DIR/bin"
66+
fi
67+
cov-build --dir ${{github.workspace}}/cov-int cmake --build ${{github.workspace}}/build --config Release -j$(nproc)
68+
69+
- name: Create tarball to analyze
70+
run: tar czvf cov-int_ur.tgz cov-int
71+
72+
- name: Push tarball to scan
5973
run: |
60-
cd $WORKDIR/build
61-
wget https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh
62-
patch < "../.github/scripts/0001-travis-fix-travisci_build_coverity_scan.sh.patch"
63-
bash ./travisci_build_coverity_scan.sh
74+
BRANCH_NAME=$(echo ${GITHUB_REF_NAME})
75+
COMMIT_ID=$(echo $GITHUB_SHA)
76+
curl --form token=${{ secrets.COVERITY_SCAN_TOKEN }} \
77+
78+
--form file=@cov-int_ur.tgz \
79+
--form version="$COMMIT_ID" \
80+
--form description="$BRANCH_NAME:$COMMIT_ID" \
81+
https://scan.coverity.com/builds\?project\=oneapi-src%2Funified-runtime

.github/workflows/docs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ jobs:
5454
id: download-bench-html
5555
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
5656
with:
57-
path: ${{ github.workspace }}/ur-repo/benchmark_results.html
57+
path: ur-repo/benchmark_results.html
5858
key: benchmark-results-
59-
restore-keys: benchmark-results-
6059

6160
- name: Move benchmark HTML
6261
# exact or partial cache hit

CMakeLists.txt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,6 @@ include(CheckCXXSourceCompiles)
1616
include(CMakePackageConfigHelpers)
1717
include(CTest)
1818

19-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
20-
include(helpers)
21-
22-
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
23-
set(Python3_FIND_FRAMEWORK NEVER)
24-
set(Python3_FIND_STRATEGY LOCATION)
25-
endif()
26-
27-
find_package(Python3 COMPONENTS Interpreter REQUIRED)
28-
29-
set(CMAKE_CXX_STANDARD 17)
30-
set(CMAKE_CXX_STANDARD_REQUIRED YES)
31-
3219
# Build Options
3320
option(UR_BUILD_EXAMPLES "Build example applications." ON)
3421
option(UR_BUILD_TESTS "Build unit tests." ON)
@@ -40,6 +27,7 @@ option(UR_USE_ASAN "enable AddressSanitizer" OFF)
4027
option(UR_USE_UBSAN "enable UndefinedBehaviorSanitizer" OFF)
4128
option(UR_USE_MSAN "enable MemorySanitizer" OFF)
4229
option(UR_USE_TSAN "enable ThreadSanitizer" OFF)
30+
option(UR_USE_CFI "enable Control Flow Integrity checks (requires clang and implies -flto)" ON)
4331
option(UR_ENABLE_TRACING "enable api tracing through xpti" OFF)
4432
option(UR_ENABLE_SANITIZER "enable device sanitizer" ON)
4533
option(UR_ENABLE_SYMBOLIZER "enable symoblizer for sanitizer" OFF)
@@ -80,6 +68,19 @@ set(UR_ADAPTER_HIP_SOURCE_DIR "" CACHE PATH
8068
set(UR_ADAPTER_NATIVE_CPU_SOURCE_DIR "" CACHE PATH
8169
"Path to external 'native_cpu' adapter source dir")
8270

71+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
72+
include(helpers)
73+
74+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
75+
set(Python3_FIND_FRAMEWORK NEVER)
76+
set(Python3_FIND_STRATEGY LOCATION)
77+
endif()
78+
79+
find_package(Python3 COMPONENTS Interpreter REQUIRED)
80+
81+
set(CMAKE_CXX_STANDARD 17)
82+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
83+
8384
# There's little reason not to generate the compile_commands.json
8485
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
8586

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
[![Build and test](https://github.com/oneapi-src/unified-runtime/actions/workflows/cmake.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/cmake.yml)
44
[![Bandit](https://github.com/oneapi-src/unified-runtime/actions/workflows/bandit.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/bandit.yml)
55
[![CodeQL](https://github.com/oneapi-src/unified-runtime/actions/workflows/codeql.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/codeql.yml)
6-
[![Coverity](https://scan.coverity.com/projects/28213/badge.svg)](https://scan.coverity.com/projects/oneapi-src-unified-runtime)
6+
[![Coverity build](https://github.com/oneapi-src/unified-runtime/actions/workflows/coverity.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-runtime/actions/workflows/coverity.yml)
7+
[![Coverity report](https://scan.coverity.com/projects/28213/badge.svg)](https://scan.coverity.com/projects/oneapi-src-unified-runtime)
78
[![Nightly](https://github.com/oneapi-src/unified-runtime/actions/workflows/nightly.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/nightly.yml)
89
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/oneapi-src/unified-runtime/badge)](https://securityscorecards.dev/viewer/?uri=github.com/oneapi-src/unified-runtime)
910
[![Trivy](https://github.com/oneapi-src/unified-runtime/actions/workflows/trivy.yml/badge.svg)](https://github.com/oneapi-src/unified-runtime/actions/workflows/trivy.yml)
@@ -129,6 +130,7 @@ List of options provided by CMake:
129130
| UR_USE_TSAN | Enable ThreadSanitizer | ON/OFF | OFF |
130131
| UR_USE_UBSAN | Enable UndefinedBehavior Sanitizer | ON/OFF | OFF |
131132
| UR_USE_MSAN | Enable MemorySanitizer (clang only) | ON/OFF | OFF |
133+
| UR_USE_CFI | Enable Control Flow Integrity checks (clang only, also enables lto) | ON/OFF | ON |
132134
| UR_ENABLE_TRACING | Enable XPTI-based tracing layer | ON/OFF | OFF |
133135
| UR_ENABLE_SANITIZER | Enable device sanitizer layer | ON/OFF | ON |
134136
| UR_CONFORMANCE_TARGET_TRIPLES | SYCL triples to build CTS device binaries for | Comma-separated list | spir64 |

cmake/FetchLevelZero.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if (NOT DEFINED LEVEL_ZERO_LIBRARY OR NOT DEFINED LEVEL_ZERO_INCLUDE_DIR)
4040
set(UR_LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git")
4141
endif()
4242
if (UR_LEVEL_ZERO_LOADER_TAG STREQUAL "")
43-
set(UR_LEVEL_ZERO_LOADER_TAG v1.17.39)
43+
set(UR_LEVEL_ZERO_LOADER_TAG v1.19.2)
4444
endif()
4545

4646
# Disable due to a bug https://github.com/oneapi-src/level-zero/issues/104

cmake/helpers.cmake

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
6363
check_cxx_compiler_flag("-fstack-clash-protection" CXX_HAS_FSTACK_CLASH_PROTECTION)
6464
endif()
6565

66+
if (UR_USE_CFI)
67+
set(SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
68+
set(CMAKE_REQUIRED_FLAGS "-flto -fvisibility=hidden")
69+
check_cxx_compiler_flag("-fsanitize=cfi" CXX_HAS_CFI_SANITIZE)
70+
set(CMAKE_REQUIRED_FLAGS ${SAVED_CMAKE_REQUIRED_FLAGS})
71+
else()
72+
# If CFI checking is disabled, pretend we don't support it
73+
set(CXX_HAS_CFI_SANITIZE OFF)
74+
endif()
75+
6676
function(add_ur_target_compile_options name)
6777
if(NOT MSVC)
6878
target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2)
@@ -78,11 +88,10 @@ function(add_ur_target_compile_options name)
7888
# Hardening options
7989
-fPIC
8090
-fstack-protector-strong
81-
-fvisibility=hidden # Required for -fsanitize=cfi
82-
# -fsanitize=cfi requires -flto, which breaks a lot of things
83-
# See: https://github.com/oneapi-src/unified-runtime/issues/2120
84-
# -flto
85-
# $<$<CXX_COMPILER_ID:Clang,AppleClang>:-fsanitize=cfi>
91+
-fvisibility=hidden
92+
# cfi-icall requires called functions in shared libraries to also be built with cfi-icall, which we can't
93+
# guarantee. -fsanitize=cfi depends on -flto
94+
$<$<BOOL:${CXX_HAS_CFI_SANITIZE}>:-flto -fsanitize=cfi -fno-sanitize=cfi-icall>
8695
$<$<BOOL:${CXX_HAS_FCF_PROTECTION_FULL}>:-fcf-protection=full>
8796
$<$<BOOL:${CXX_HAS_FSTACK_CLASH_PROTECTION}>:-fstack-clash-protection>
8897

@@ -119,7 +128,10 @@ endfunction()
119128
function(add_ur_target_link_options name)
120129
if(NOT MSVC)
121130
if (NOT APPLE)
122-
target_link_options(${name} PRIVATE "LINKER:-z,relro,-z,now,-z,noexecstack")
131+
target_link_options(${name} PRIVATE
132+
$<$<BOOL:${CXX_HAS_CFI_SANITIZE}>:-flto -fsanitize=cfi -fno-sanitize=cfi-icall>
133+
"LINKER:-z,relro,-z,now,-z,noexecstack"
134+
)
123135
if (UR_DEVELOPER_MODE)
124136
target_link_options(${name} PRIVATE -Werror -Wextra)
125137
endif()
@@ -131,17 +143,17 @@ function(add_ur_target_link_options name)
131143
endif()
132144
elseif(MSVC)
133145
target_link_options(${name} PRIVATE
134-
/DYNAMICBASE
135-
/HIGHENTROPYVA
136-
/NXCOMPAT
146+
LINKER:/DYNAMICBASE
147+
LINKER:/HIGHENTROPYVA
148+
LINKER:/NXCOMPAT
137149
)
138150
endif()
139151
endfunction()
140152

141153
function(add_ur_target_exec_options name)
142154
if(MSVC)
143155
target_link_options(${name} PRIVATE
144-
/ALLOWISOLATION
156+
LINKER:/ALLOWISOLATION
145157
)
146158
endif()
147159
endfunction()
@@ -159,7 +171,7 @@ function(add_ur_library name)
159171
add_ur_target_link_options(${name})
160172
if(MSVC)
161173
target_link_options(${name} PRIVATE
162-
$<$<STREQUAL:$<TARGET_LINKER_FILE_NAME:${name}>,link.exe>:/DEPENDENTLOADFLAG:0x2000>
174+
$<$<STREQUAL:$<TARGET_LINKER_FILE_NAME:${name}>,link.exe>:LINKER:/DEPENDENTLOADFLAG:0x2000>
163175
)
164176
endif()
165177
endfunction()

0 commit comments

Comments
 (0)