Skip to content

Commit a0555f7

Browse files
committed
Merge branch 'main' into sean/unique-addr-mode-per-dim-adapters
2 parents 7b0a45a + 92f44da commit a0555f7

Some content is hidden

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

44 files changed

+1739
-157
lines changed

.github/docker/ubuntu-22.04.Dockerfile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
@@ -51,20 +51,23 @@ RUN apt-get update \
5151
${BASE_DEPS} \
5252
${UR_DEPS} \
5353
${MISC_DEPS} \
54+
&& rm -rf /var/lib/apt/lists/* \
5455
&& apt-get clean all
5556

56-
RUN pip3 install ${UR_PYTHON_DEPS}
57+
# pip package is pinned to a version, but it's probably improperly parsed here
58+
# hadolint ignore=DL3013
59+
RUN pip3 install --no-cache-dir ${UR_PYTHON_DEPS}
5760

5861
# Install DPC++
59-
COPY install_dpcpp.sh install_dpcpp.sh
62+
COPY install_dpcpp.sh /opt/install_dpcpp.sh
6063
ENV DPCPP_PATH=/opt/dpcpp
61-
RUN ./install_dpcpp.sh
64+
RUN /opt/install_dpcpp.sh
6265

6366
# Install libbacktrace
64-
COPY install_libbacktrace.sh install_libbacktrace.sh
65-
RUN ./install_libbacktrace.sh
67+
COPY install_libbacktrace.sh /opt/install_libbacktrace.sh
68+
RUN /opt/install_libbacktrace.sh
6669

6770
# Add a new (non-root) 'user'
6871
ENV USER user
6972
ENV USERPASS pass
70-
RUN useradd -m $USER -g sudo -p `mkpasswd $USERPASS`
73+
RUN useradd -m "${USER}" -g sudo -p "$(mkpasswd ${USERPASS})"

.github/workflows/hadolint.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Runs linter for Docker files
2+
name: Hadolint
3+
4+
on:
5+
workflow_dispatch:
6+
push:
7+
pull_request:
8+
paths:
9+
- '.github/docker/*Dockerfile'
10+
- '.github/workflows/hadolint.yml'
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
linux:
21+
name: Hadolint
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Clone the git repo
26+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
27+
28+
- name: Run Hadolint
29+
uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0
30+
with:
31+
recursive: true
32+
dockerfile: ".github/docker/*Dockerfile"
33+
# ignore pinning apt packages to versions
34+
ignore: DL3008

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@ out/
8686

8787
# External content
8888
*/**/external
89+
90+
# VS clangd
91+
/.cache
92+
/compile_commands.json

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ option(UR_USE_UBSAN "enable UndefinedBehaviorSanitizer" OFF)
3434
option(UR_USE_MSAN "enable MemorySanitizer" OFF)
3535
option(UR_USE_TSAN "enable ThreadSanitizer" OFF)
3636
option(UR_ENABLE_TRACING "enable api tracing through xpti" OFF)
37+
option(UR_ENABLE_SANITIZER "enable device sanitizer" ON)
3738
option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF)
3839
option(UMF_ENABLE_POOL_TRACKING "Build UMF with pool tracking" ON)
3940
option(UR_BUILD_ADAPTER_L0 "Build the Level-Zero adapter" OFF)
@@ -116,14 +117,15 @@ if(UR_ENABLE_TRACING)
116117
)
117118
if (MSVC)
118119
set(TARGET_XPTI $<IF:$<CONFIG:Release>,xpti,xptid>)
119-
120-
# disable warning C4267: The compiler detected a conversion from size_t to a smaller type.
121-
target_compile_options(xptifw PRIVATE /wd4267)
122120
else()
123121
set(TARGET_XPTI xpti)
124122
endif()
125123
endif()
126124

125+
if(UR_ENABLE_SANITIZER)
126+
add_compile_definitions(UR_ENABLE_SANITIZER)
127+
endif()
128+
127129
if(UR_USE_ASAN)
128130
add_sanitizer_flag(address)
129131
endif()

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ List of options provided by CMake:
126126
| UR_USE_UBSAN | Enable UndefinedBehavior Sanitizer | ON/OFF | OFF |
127127
| UR_USE_MSAN | Enable MemorySanitizer (clang only) | ON/OFF | OFF |
128128
| UR_ENABLE_TRACING | Enable XPTI-based tracing layer | ON/OFF | OFF |
129+
| UR_ENABLE_SANITIZER | Enable device sanitizer layer | ON/OFF | ON |
129130
| UR_CONFORMANCE_TARGET_TRIPLES | SYCL triples to build CTS device binaries for | Comma-separated list | spir64 |
130131
| UR_BUILD_ADAPTER_L0 | Build the Level-Zero adapter | ON/OFF | OFF |
131132
| UR_BUILD_ADAPTER_OPENCL | Build the OpenCL adapter | ON/OFF | OFF |

cmake/helpers.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,16 @@ function(add_ur_target_compile_options name)
8484
/W3
8585
/MD$<$<CONFIG:Debug>:d>
8686
/GS
87+
/DWIN32_LEAN_AND_MEAN
88+
/DNOMINMAX
8789
)
8890

8991
if(UR_DEVELOPER_MODE)
90-
target_compile_options(${name} PRIVATE /WX /GS)
92+
# _CRT_SECURE_NO_WARNINGS used mainly because of getenv
93+
# C4267: The compiler detected a conversion from size_t to a smaller type.
94+
target_compile_options(${name} PRIVATE
95+
/WX /GS /D_CRT_SECURE_NO_WARNINGS /wd4267
96+
)
9197
endif()
9298
endif()
9399
endfunction()

scripts/core/INTRO.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ Unified Runtime loader implements tracing support through the `XPTI framework <h
179179
| **user_data**: A pointer to `function_with_args_t` object, that includes function ID, name, arguments, and return value.
180180
- None
181181

182+
Sanitizers
183+
---------------------
184+
185+
Unified Runtime loader implements the runtime part of device-side sanitizers: AddressSanitizer (`UR_LAYER_ASAN`), MemorySanitizer (`UR_LAYER_MSAN`, planned), and ThreadSanitizer (`UR_LAYER_TSAN`, planned).
186+
187+
This layer shouldn't be enabled explicitly, for example, by the environment variable `UR_ENABLE_LAYERS`, but is enabled by program's runtime (e.g. SYCL/OpenMP Runtime) when the device code is compiled with flag `-fsanitize=address|memory|thread`.
188+
189+
Currently, AddressSanitizer only supports some of the devices on OpenCL and Level-Zero adapters, and this could be extended to support other devices and adapters if UR virtual memory APIs and shadow memory mapping in libdevice are supported.
190+
182191
Logging
183192
---------------------
184193

@@ -260,6 +269,8 @@ Layers currently included with the runtime are as follows:
260269
- Enables UR_LAYER_PARAMETER_VALIDATION and UR_LAYER_LEAK_CHECKING.
261270
* - UR_LAYER_TRACING
262271
- Enables the XPTI tracing layer, see Tracing_ for more detail.
272+
* - UR_LAYER_ASAN \| UR_LAYER_MSAN \| UR_LAYER_TSAN
273+
- Enables the device-side sanitizer layer, see Sanitizers_ for more detail.
263274

264275
Environment Variables
265276
---------------------
@@ -274,6 +285,10 @@ Specific environment variables can be set to control the behavior of unified run
274285

275286
Holds parameters for setting Unified Runtime null adapter logging. The syntax is described in the Logging_ section.
276287

288+
.. envvar:: UR_LOG_SANITIZER
289+
290+
Holds parameters for setting Unified Runtime sanitizer logging. The syntax is described in the Logging_ section.
291+
277292
.. envvar:: UR_LOG_VALIDATION
278293

279294
Holds parameters for setting Unified Runtime validation logging. The syntax is described in the Logging_ section.

source/adapters/cuda/device.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet(ur_platform_handle_t hPlatform,
11011101

11021102
UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetNativeHandle(
11031103
ur_device_handle_t hDevice, ur_native_handle_t *phNativeHandle) {
1104-
*phNativeHandle = reinterpret_cast<ur_native_handle_t>(hDevice->get());
1104+
*phNativeHandle = reinterpret_cast<ur_native_handle_t>(
1105+
static_cast<std::uintptr_t>(hDevice->get()));
11051106
return UR_RESULT_SUCCESS;
11061107
}
11071108

source/adapters/cuda/image.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ urToCudaImageChannelFormat(ur_image_channel_type_t image_channel_type,
146146
std::make_pair(image_channel_type, num_channels));
147147
cuda_format = cuda_format_and_size.first;
148148
pixel_size_bytes = cuda_format_and_size.second;
149-
} catch (std::out_of_range &e) {
149+
} catch (const std::out_of_range &) {
150150
return UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED;
151151
}
152152
}
@@ -285,7 +285,7 @@ ur_result_t urTextureCreate(ur_sampler_handle_t hSampler,
285285
ImageTexDesc.mipmapFilterMode = MipFilterMode;
286286
ImageTexDesc.maxMipmapLevelClamp = hSampler->MaxMipmapLevelClamp;
287287
ImageTexDesc.minMipmapLevelClamp = hSampler->MinMipmapLevelClamp;
288-
ImageTexDesc.maxAnisotropy = hSampler->MaxAnisotropy;
288+
ImageTexDesc.maxAnisotropy = static_cast<unsigned>(hSampler->MaxAnisotropy);
289289

290290
// The address modes can interfere with other dimensions
291291
// e.g. 1D texture sampling can be interfered with when setting other

source/adapters/cuda/program.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ ur_result_t ur_program_handle_t_::buildProgram(const char *BuildOptions) {
141141
getMaxRegistersJitOptionValue(this->BuildOptions, MaxRegs);
142142
if (Valid) {
143143
Options.push_back(CU_JIT_MAX_REGISTERS);
144-
OptionVals.push_back(reinterpret_cast<void *>(MaxRegs));
144+
OptionVals.push_back(
145+
reinterpret_cast<void *>(static_cast<std::uintptr_t>(MaxRegs)));
145146
}
146147
}
147148

0 commit comments

Comments
 (0)