Skip to content

Commit c85e8c0

Browse files
authored
Merge branch 'main' into fix-get-native-mem
2 parents caa7e30 + d3b81bf commit c85e8c0

File tree

159 files changed

+7487
-1679
lines changed

Some content is hidden

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

159 files changed

+7487
-1679
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ jobs:
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
5250
run: >
5351
cmake
5452
-B${{github.workspace}}/build
@@ -60,7 +58,6 @@ jobs:
6058
-DUR_USE_ASAN=ON
6159
-DUR_USE_UBSAN=ON
6260
-DUR_BUILD_ADAPTER_L0=ON
63-
-DUR_USE_CFI=OFF
6461
-DUR_LEVEL_ZERO_LOADER_LIBRARY=${{github.workspace}}/level-zero/build/lib/libze_loader.so
6562
-DUR_LEVEL_ZERO_INCLUDE_DIR=${{github.workspace}}/level-zero/include/
6663
-DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ jobs:
8282
tar -xvf ${{github.workspace}}/dpcpp_compiler.tar.gz -C dpcpp_compiler
8383
8484
- name: Configure CMake
85-
# CFI sanitization seems to fail on our CUDA nodes
86-
# https://github.com/oneapi-src/unified-runtime/issues/2309
8785
run: >
8886
cmake
8987
-B${{github.workspace}}/build
@@ -96,7 +94,6 @@ jobs:
9694
-DUR_BUILD_ADAPTER_${{matrix.adapter.name}}=ON
9795
-DUR_CONFORMANCE_TEST_LOADER=${{ matrix.adapter.other_name != '' && 'ON' || 'OFF' }}
9896
${{ matrix.adapter.other_name != '' && format('-DUR_BUILD_ADAPTER_{0}=ON', matrix.adapter.other_name) || '' }}
99-
-DUR_USE_CFI=${{ matrix.adapter.name == 'CUDA' && 'OFF' || 'ON' }}
10097
-DUR_STATIC_LOADER=${{matrix.adapter.static_Loader}}
10198
-DUR_STATIC_ADAPTER_${{matrix.adapter.name}}=${{matrix.adapter.static_adapter}}
10299
-DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++

.github/workflows/cmake.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,14 @@ jobs:
221221
needs: [ubuntu-build, opencl]
222222
uses: ./.github/workflows/e2e_opencl.yml
223223

224-
e2e-cuda:
225-
name: E2E CUDA
226-
permissions:
227-
contents: read
228-
pull-requests: write
229-
needs: [ubuntu-build, cuda]
230-
uses: ./.github/workflows/e2e_cuda.yml
224+
# Causes hangs: https://github.com/oneapi-src/unified-runtime/issues/2398
225+
#e2e-cuda:
226+
# name: E2E CUDA
227+
# permissions:
228+
# contents: read
229+
# pull-requests: write
230+
# needs: [ubuntu-build, cuda]
231+
# uses: ./.github/workflows/e2e_cuda.yml
231232

232233
windows-build:
233234
name: Build - Windows

.github/workflows/e2e_core.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ jobs:
190190
191191
- name: Run e2e tests
192192
id: tests
193-
run: ninja -C build-e2e check-sycl-e2e
193+
run: ninja -C build-e2e check-sycl-e2e || echo "e2e tests have failed. Ignoring failure."
194194

195195
# FIXME: Requires pull-request: write permissions but this is only granted
196196
# on pull requests from forks if using pull_request_target workflow

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ option(UR_USE_ASAN "enable AddressSanitizer" OFF)
2727
option(UR_USE_UBSAN "enable UndefinedBehaviorSanitizer" OFF)
2828
option(UR_USE_MSAN "enable MemorySanitizer" OFF)
2929
option(UR_USE_TSAN "enable ThreadSanitizer" OFF)
30-
option(UR_USE_CFI "enable Control Flow Integrity checks (requires clang and implies -flto)" ON)
30+
option(UR_USE_CFI "enable Control Flow Integrity checks (requires clang and implies -flto)" OFF)
3131
option(UR_ENABLE_TRACING "enable api tracing through xpti" OFF)
3232
option(UR_ENABLE_SANITIZER "enable device sanitizer" ON)
3333
option(UR_ENABLE_SYMBOLIZER "enable symoblizer for sanitizer" OFF)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ List of options provided by CMake:
130130
| UR_USE_TSAN | Enable ThreadSanitizer | ON/OFF | OFF |
131131
| UR_USE_UBSAN | Enable UndefinedBehavior Sanitizer | ON/OFF | OFF |
132132
| 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 |
133+
| UR_USE_CFI | Enable Control Flow Integrity checks (clang only, also enables lto) | ON/OFF | OFF |
134134
| UR_ENABLE_TRACING | Enable XPTI-based tracing layer | ON/OFF | OFF |
135135
| UR_ENABLE_SANITIZER | Enable device sanitizer layer | ON/OFF | ON |
136136
| UR_CONFORMANCE_TARGET_TRIPLES | SYCL triples to build CTS device binaries for | Comma-separated list | spir64 |

cmake/FetchLevelZero.cmake

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ set(UR_LEVEL_ZERO_LOADER_LIBRARY "" CACHE FILEPATH "Path of the Level Zero Loade
77
set(UR_LEVEL_ZERO_INCLUDE_DIR "" CACHE FILEPATH "Directory containing the Level Zero Headers")
88
set(UR_LEVEL_ZERO_LOADER_REPO "" CACHE STRING "Github repo to get the Level Zero loader sources from")
99
set(UR_LEVEL_ZERO_LOADER_TAG "" CACHE STRING " GIT tag of the Level Loader taken from github repo")
10+
set(UR_COMPUTE_RUNTIME_REPO "" CACHE STRING "Github repo to get the compute runtime sources from")
11+
set(UR_COMPUTE_RUNTIME_TAG "" CACHE STRING " GIT tag of the compute runtime taken from github repo")
1012

1113
# Copy Level Zero loader/headers locally to the build to avoid leaking their path.
1214
set(LEVEL_ZERO_COPY_DIR ${CMAKE_CURRENT_BINARY_DIR}/level_zero_loader)
@@ -87,8 +89,31 @@ target_link_libraries(LevelZeroLoader
8789
INTERFACE "${LEVEL_ZERO_LIB_NAME}"
8890
)
8991

92+
file(GLOB LEVEL_ZERO_LOADER_API_HEADERS "${LEVEL_ZERO_INCLUDE_DIR}/*.h")
93+
file(COPY ${LEVEL_ZERO_LOADER_API_HEADERS} DESTINATION ${LEVEL_ZERO_INCLUDE_DIR}/level_zero)
9094
add_library(LevelZeroLoader-Headers INTERFACE)
9195
target_include_directories(LevelZeroLoader-Headers
92-
INTERFACE "$<BUILD_INTERFACE:${LEVEL_ZERO_INCLUDE_DIR}>"
96+
INTERFACE "$<BUILD_INTERFACE:${LEVEL_ZERO_INCLUDE_DIR};${LEVEL_ZERO_INCLUDE_DIR}/level_zero>"
97+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
98+
)
99+
100+
if (UR_COMPUTE_RUNTIME_REPO STREQUAL "")
101+
set(UR_COMPUTE_RUNTIME_REPO "https://github.com/intel/compute-runtime.git")
102+
endif()
103+
if (UR_COMPUTE_RUNTIME_TAG STREQUAL "")
104+
set(UR_COMPUTE_RUNTIME_TAG 24.39.31294.12)
105+
endif()
106+
include(FetchContent)
107+
# Sparse fetch only the dir with level zero headers for experimental features to avoid pulling in the entire compute-runtime.
108+
FetchContentSparse_Declare(exp-headers ${UR_COMPUTE_RUNTIME_REPO} "${UR_COMPUTE_RUNTIME_TAG}" "level_zero/include")
109+
FetchContent_GetProperties(exp-headers)
110+
if(NOT exp-headers_POPULATED)
111+
FetchContent_Populate(exp-headers)
112+
endif()
113+
add_library(ComputeRuntimeLevelZero-Headers INTERFACE)
114+
set(COMPUTE_RUNTIME_LEVEL_ZERO_INCLUDE "${exp-headers_SOURCE_DIR}/../..")
115+
message(STATUS "Level Zero Adapter: Using Level Zero headers from ${COMPUTE_RUNTIME_LEVEL_ZERO_INCLUDE}")
116+
target_include_directories(ComputeRuntimeLevelZero-Headers
117+
INTERFACE "$<BUILD_INTERFACE:${COMPUTE_RUNTIME_LEVEL_ZERO_INCLUDE}>"
93118
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
94119
)

cmake/FindRocmAgentEnumerator.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# rocm_agent_enumerator is found.
1010
#
1111

12-
find_program(ROCM_AGENT_ENUMERATOR NAMES rocm_agent_enumerator)
12+
find_program(ROCM_AGENT_ENUMERATOR NAMES rocm_agent_enumerator PATHS /opt/rocm/bin)
1313

1414
if(ROCM_AGENT_ENUMERATOR)
1515
set(ROCM_AGENT_ENUMERATOR_FOUND TRUE)

cmake/helpers.cmake

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ 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 AND UR_USE_ASAN)
67+
message(WARNING "Both UR_USE_CFI and UR_USE_ASAN are ON. "
68+
"Due to build errors, this is unsupported; CFI checks will be disabled")
69+
set(UR_USE_CFI OFF)
70+
endif()
71+
6672
if (UR_USE_CFI)
6773
set(SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
6874
set(CMAKE_REQUIRED_FLAGS "-flto -fvisibility=hidden")
@@ -73,6 +79,13 @@ else()
7379
set(CXX_HAS_CFI_SANITIZE OFF)
7480
endif()
7581

82+
set(CFI_FLAGS "")
83+
if (CFI_HAS_CFI_SANITIZE)
84+
# cfi-icall requires called functions in shared libraries to also be built with cfi-icall, which we can't
85+
# guarantee. -fsanitize=cfi depends on -flto
86+
set(CFI_FLAGS "-flto -fsanitize=cfi -fno-sanitize=cfi-icall -fsanitize-ignorelist=${CMAKE_SOURCE_DIR}/sanitizer-ignorelist.txt")
87+
endif()
88+
7689
function(add_ur_target_compile_options name)
7790
if(NOT MSVC)
7891
target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2)
@@ -89,9 +102,8 @@ function(add_ur_target_compile_options name)
89102
-fPIC
90103
-fstack-protector-strong
91104
-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>
105+
106+
${CFI_FLAGS}
95107
$<$<BOOL:${CXX_HAS_FCF_PROTECTION_FULL}>:-fcf-protection=full>
96108
$<$<BOOL:${CXX_HAS_FSTACK_CLASH_PROTECTION}>:-fstack-clash-protection>
97109

@@ -108,18 +120,28 @@ function(add_ur_target_compile_options name)
108120
elseif(MSVC)
109121
target_compile_options(${name} PRIVATE
110122
$<$<CXX_COMPILER_ID:MSVC>:/MP> # clang-cl.exe does not support /MP
111-
/W3
112123
/MD$<$<CONFIG:Debug>:d>
113-
/GS
114-
/DWIN32_LEAN_AND_MEAN
115-
/DNOMINMAX
124+
125+
/W3
126+
/GS # Enable: Buffer security check
127+
/Gy # Enable: Function-level linking
128+
129+
$<$<CONFIG:Release>:/sdl> # Enable: Additional SDL checks
130+
$<$<CXX_COMPILER_ID:MSVC>:/Qspectre> # Enable: Mitigate Spectre variant 1 vulnerabilities
131+
132+
/wd4267 # Disable: 'var' : conversion from 'size_t' to 'type', possible loss of data
133+
/wd6244 # Disable: local declaration of 'variable' hides previous declaration
134+
/wd6246 # Disable: local declaration of 'variable' hides declaration of same name in outer scope
135+
)
136+
137+
target_compile_definitions(${name} PRIVATE
138+
WIN32_LEAN_AND_MEAN NOMINMAX # Cajole Windows.h to define fewer symbols
139+
_CRT_SECURE_NO_WARNINGS # Slience warnings about getenv
116140
)
117141

118142
if(UR_DEVELOPER_MODE)
119-
# _CRT_SECURE_NO_WARNINGS used mainly because of getenv
120-
# C4267: The compiler detected a conversion from size_t to a smaller type.
121143
target_compile_options(${name} PRIVATE
122-
/WX /GS /D_CRT_SECURE_NO_WARNINGS /wd4267
144+
/WX # Enable: Treat all warnings as errors
123145
)
124146
endif()
125147
endif()
@@ -129,7 +151,7 @@ function(add_ur_target_link_options name)
129151
if(NOT MSVC)
130152
if (NOT APPLE)
131153
target_link_options(${name} PRIVATE
132-
$<$<BOOL:${CXX_HAS_CFI_SANITIZE}>:-flto -fsanitize=cfi -fno-sanitize=cfi-icall>
154+
${CFI_FLAGS}
133155
"LINKER:-z,relro,-z,now,-z,noexecstack"
134156
)
135157
if (UR_DEVELOPER_MODE)
@@ -143,9 +165,12 @@ function(add_ur_target_link_options name)
143165
endif()
144166
elseif(MSVC)
145167
target_link_options(${name} PRIVATE
146-
LINKER:/DYNAMICBASE
147-
LINKER:/HIGHENTROPYVA
148-
LINKER:/NXCOMPAT
168+
LINKER:/DYNAMICBASE # Enable: Modify header to indicate ASLR should be use
169+
LINKER:/HIGHENTROPYVA # Enable: High-entropy address space layout randomization (ASLR)
170+
$<$<CONFIG:Release>:
171+
LINKER:/NXCOMPAT # Enable: Data Execution Prevention
172+
LINKER:/LTCG # Enable: Link-time code generation
173+
>
149174
)
150175
endif()
151176
endfunction()

0 commit comments

Comments
 (0)