Skip to content

Commit

Permalink
Merge branch 'sycl-upstream' into ur-cmdbuf-cmdlist-bump
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrancepillois committed Feb 6, 2024
2 parents acc56bb + 2c85e99 commit 9649eda
Show file tree
Hide file tree
Showing 96 changed files with 3,299 additions and 3,612 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sycl-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: OCL CPU (Intel/GEN12)
runner: '["Linux", "gen12"]'
image: ghcr.io/intel/llvm/ubuntu2204_intel_drivers:latest
image_options: -u 1001
image_options: -u 1001 --privileged --cap-add SYS_ADMIN
target_devices: opencl:cpu

- name: OCL CPU (Intel/Arc)
Expand Down
57 changes: 57 additions & 0 deletions clang/lib/Driver/Compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,61 @@ Compilation::~Compilation() {
delete Arg.second;
}

static void HandleXarchArgs(DerivedArgList *OffloadArgList, const Driver &D,
bool IsDevice) {
if (!OffloadArgList)
return;

if (IsDevice && !OffloadArgList->hasArg(options::OPT_Xarch_device))
return;

if (!IsDevice && !OffloadArgList->hasArg(options::OPT_Xarch_host))
return;

bool NeedHandle = false;
std::vector<std::string> XarchValues;
XarchValues = IsDevice
? OffloadArgList->getAllArgValues(options::OPT_Xarch_device)
: OffloadArgList->getAllArgValues(options::OPT_Xarch_host);
SmallVector<StringRef, 8> XarchValueRefs;
for (auto XarchV : XarchValues) {
if (XarchV.find(' ') != std::string::npos) {
NeedHandle = true;
StringRef XarchVRef(XarchV);
SmallVector<StringRef, 8> XarchVecs;
XarchVRef.trim().split(XarchVecs, ' ', -1, false);
size_t Index;
const size_t XSize = XarchVecs.size();
for (Index = 0; Index < XSize; ++Index) {
if (XarchVecs[Index].compare("-mllvm") == 0) {
if (Index < (XSize - 1)) {
XarchValueRefs.push_back(OffloadArgList->MakeArgStringRef(
(StringRef("-mllvm=") + XarchVecs[Index + 1]).str()));
Index++;
continue;
} else
D.Diag(clang::diag::err_drv_missing_argument) << "-mllvm" << 1;
} else
XarchValueRefs.push_back(
OffloadArgList->MakeArgStringRef(XarchVecs[Index]));
}
} else
XarchValueRefs.push_back(StringRef(XarchV));
}

if (NeedHandle) {
auto Xarch_OPT =
IsDevice ? options::OPT_Xarch_device : options::OPT_Xarch_host;
OffloadArgList->eraseArg(Xarch_OPT);
for (auto XarchV : XarchValueRefs) {
Arg *A = OffloadArgList->MakeSeparateArg(
nullptr, D.getOpts().getOption(Xarch_OPT), XarchV);
A->claim();
OffloadArgList->append(A);
}
}
}

const DerivedArgList &
Compilation::getArgsForToolChain(const ToolChain *TC, StringRef BoundArch,
Action::OffloadKind DeviceOffloadKind) {
Expand All @@ -82,9 +137,11 @@ Compilation::getArgsForToolChain(const ToolChain *TC, StringRef BoundArch,

DerivedArgList *NewDAL = nullptr;
if (!OffloadArgs) {
HandleXarchArgs(TranslatedArgs, getDriver(), false);
NewDAL = TC->TranslateXarchArgs(*TranslatedArgs, BoundArch,
DeviceOffloadKind, &AllocatedArgs);
} else {
HandleXarchArgs(OffloadArgs, getDriver(), true);
NewDAL = TC->TranslateXarchArgs(*OffloadArgs, BoundArch, DeviceOffloadKind,
&AllocatedArgs);
if (!NewDAL)
Expand Down
162 changes: 162 additions & 0 deletions clang/test/Driver/sycl-xarch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
///
/// Perform several driver tests for SYCL -Xarch_device/host on Linux
///

// UNSUPPORTED: system-windows

/// ###########################################################################

/// test behavior of -Xarch_device with 1 option for SYCL compiler, the flag
/// should be passed to device compilation only.
// RUN: %clangxx -fsycl %s -Xarch_device -fsanitize=address -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_DEVICE_OPTION
// RUN: %clangxx -fsycl %s -Xarch_device -fsanitize=address -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_DEVICE_ONLY
// SYCL_XARCH_DEVICE_OPTION: clang{{.*}} "-fsycl-is-device"
// SYCL_XARCH_DEVICE_OPTION-SAME: -fsanitize=address
// SYCL_XARCH_DEVICE_OPTION-SAME: -fsanitize-address-use-after-return=never
// SYCL_XARCH_DEVICE_OPTION-SAME: -fno-sanitize-address-use-after-scope
// SYCL_XARCH_DEVICE_OPTION-SAME: "-mllvm" "-asan-instrumentation-with-call-threshold=0"
// SYCL_XARCH_DEVICE_OPTION-SAME: "-mllvm" "-asan-stack=0"
// SYCL_XARCH_DEVICE_OPTION-SAME: "-mllvm" "-asan-globals=0"
// SYCL_XARCH_DEVICE_ONLY: llc{{.*}} "-filetype=obj"
// SYCL_XARCH_DEVICE_ONLY-NOT: fsanitize=address

/// test behavior of -Xarch_device with multiple options for SYCL compiler, the
/// flags should be passed to device compilation only.
// RUN: %clangxx -fsycl %s -Xarch_device "-fsanitize=address -DXARCH_DEVICE_TEST -mllvm -enable-merge-functions" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_DEVICE_OPTIONS1
// RUN: %clangxx -fsycl %s -Xarch_device "-fsanitize=address -DXARCH_DEVICE_TEST -mllvm -enable-merge-functions" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_DEVICE_OPTIONS1
// RUN: %clangxx -fsycl %s -Xarch_device "-fsanitize=address -DXARCH_DEVICE_TEST -mllvm -enable-merge-functions" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_DEVICE_OPTIONS2
// RUN: %clangxx -fsycl %s -Xarch_device "-fsanitize=address -DXARCH_DEVICE_TEST -mllvm -enable-merge-functions" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_DEVICE_OPTIONS3
// SYCL_XARCH_DEVICE_OPTIONS1: clang{{.*}} "-fsycl-is-device"
// SYCL_XARCH_DEVICE_OPTIONS1-SAME: -fsanitize=address
// SYCL_XARCH_DEVICE_OPTIONS1-SAME: -fsanitize-address-use-after-return=never
// SYCL_XARCH_DEVICE_OPTIONS1-SAME: -fno-sanitize-address-use-after-scope
// SYCL_XARCH_DEVICE_OPTIONS1-SAME: "-mllvm" "-asan-instrumentation-with-call-threshold=0"
// SYCL_XARCH_DEVICE_OPTIONS1-SAME: "-mllvm" "-asan-stack=0"
// SYCL_XARCH_DEVICE_OPTIONS1-SAME: "-mllvm" "-asan-globals=0"
// SYCL_XARCH_DEVICE_OPTIONS2: clang{{.*}} "-fsycl-is-device"
// SYCL_XARCH_DEVICE_OPTIONS2-SAME: XARCH_DEVICE_TEST
// SYCL_XARCH_DEVICE_OPTIONS3: clang{{.*}} "-fsycl-is-device"
// SYCL_XARCH_DEVICE_OPTIONS3-SAME: "-mllvm" "-enable-merge-functions"


/// test behavior of -Xarch_host with 1 option for SYCL compiler, the flag
/// should be passed to host compilation only.
// RUN: %clangxx -fsycl %s -Xarch_host -fsanitize=address -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_HOST_OPTION
// RUN: %clangxx -fsycl %s -Xarch_host -fsanitize=address -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_HOST_ONLY
// SYCL_XARCH_HOST_OPTION: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_HOST_OPTION-SAME: -fsanitize=address
// SYCL_XARCH_HOST_OPTION-SAME: -fsanitize-address-use-after-scope
// SYCL_XARCH_HOST_OPTION-NEXT: libclang_rt.asan
// SYCL_XARCH_HOST_ONLY: clang{{.*}} "-fsycl-is-device"
// SYCL_XARCH_HOST_ONLY-NOT: -fsanitize=address
// SYCL_XARCH_HOST_ONLY: clang{{.*}} "-fsycl-is-host"

/// test behavior of -Xarch_host with multiple options for SYCL compiler, the
/// flags should be passed to host compilation only.
// RUN: %clangxx -fsycl %s -Xarch_host "-fsanitize=address -DXARCH_HOST_TEST -mllvm -enable-merge-functions" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_HOST_OPTIONS1
// RUN: %clangxx -fsycl %s -Xarch_host "-fsanitize=address -DXARCH_HOST_TEST -mllvm -enable-merge-functions" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_HOST_OPTIONS2
// RUN: %clangxx -fsycl %s -Xarch_host "-fsanitize=address -DXARCH_HOST_TEST -mllvm -enable-merge-functions" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_HOST_OPTIONS3
// SYCL_XARCH_HOST_OPTIONS1: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_HOST_OPTIONS1-SAME: -fsanitize=address
// SYCL_XARCH_HOST_OPTIONS1-SAME: -fsanitize-address-use-after-scope
// SYCL_XARCH_HOST_OPTIONS2: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_HOST_OPTIONS2-SAME: XARCH_HOST_TEST
// SYCL_XARCH_HOST_OPTIONS3: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_HOST_OPTIONS3-SAME: "-mllvm" "-enable-merge-functions"

// test behavior of combination of -Xarch_device and -Xarch_device.
// RUN: %clangxx -fsycl %s -Xarch_device "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host "-fsanitize=memory -DUSE_XARCH_HOST -fno-builtin" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_COM_DEVICE_OPTIONS1
// RUN: %clangxx -fsycl %s -Xarch_device "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host "-fsanitize=memory -DUSE_XARCH_HOST -fno-builtin" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_COM_DEVICE_OPTIONS2
// RUN: %clangxx -fsycl %s -Xarch_device "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host "-fsanitize=memory -DUSE_XARCH_HOST -fno-builtin" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_COM_NO_DEVICE
// RUN: %clangxx -fsycl %s -Xarch_device "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host "-fsanitize=memory -DUSE_XARCH_HOST -fno-builtin" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_COM_HOST_OPTIONS1
// RUN: %clangxx -fsycl %s -Xarch_device "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host "-fsanitize=memory -DUSE_XARCH_HOST -fno-builtin" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_COM_HOST_OPTIONS2
// RUN: %clangxx -fsycl %s -Xarch_device "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host "-fsanitize=memory -DUSE_XARCH_HOST -fno-builtin" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_COM_HOST_OPTIONS3
// RUN: %clangxx -fsycl %s -Xarch_device "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host "-fsanitize=memory -DUSE_XARCH_HOST -fno-builtin" -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_COM_NO_HOST
// SYCL_XARCH_COM_DEVICE_OPTIONS1: clang{{.*}} "-fsycl-is-device"
// SYCL_XARCH_COM_DEVICE_OPTIONS1-SAME: -fsanitize=address
// SYCL_XARCH_COM_DEVICE_OPTIONS1-SAME: -fsanitize-address-use-after-return=never
// SYCL_XARCH_COM_DEVICE_OPTIONS1-SAME: -fno-sanitize-address-use-after-scope
// SYCL_XARCH_COM_DEVICE_OPTIONS1-SAME: "-mllvm" "-asan-instrumentation-with-call-threshold=0"
// SYCL_XARCH_COM_DEVICE_OPTIONS1-SAME: "-mllvm" "-asan-stack=0"
// SYCL_XARCH_COM_DEVICE_OPTIONS1-SAME: "-mllvm" "-asan-globals=0"
// SYCL_XARCH_COM_DEVICE_OPTIONS2: clang{{.*}} "-fsycl-is-device"
// SYCL_XARCH_COM_DEVICE_OPTIONS2-SAME: "-mllvm" "-enable-merge-functions"
// SYCL_XARCH_COM_NO_DEVICE: clang{{.*}} "-fsycl-is-device"
// SYCL_XARCH_COM_NO_DEVICE-NOT: USE_XARCH_HOST
// SYCL_XARCH_COM_NO_DEVICE: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_COM_HOST_OPTIONS1: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_COM_HOST_OPTIONS1-SAME: -fsanitize=memory
// SYCL_XARCH_COM_HOST_OPTIONS1-NEXT: libclang_rt.msan
// SYCL_XARCH_COM_HOST_OPTIONS2: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_COM_HOST_OPTIONS2-SAME: USE_XARCH_HOST
// SYCL_XARCH_COM_HOST_OPTIONS3: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_COM_HOST_OPTIONS3-SAME: -fno-builtin
// SYCL_XARCH_COM_NO_HOST: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_COM_NO_HOST-NOT: "-mllvm" "-enable-merge-functions"


// test behavior of multiple usage of -Xarch_host in single command line
// RUN: %clangxx -fsycl %s -Xarch_host "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host -DFOO -Xarch_host -DFOO1 -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_HOST_MULTIPLE1
// RUN: %clangxx -fsycl %s -Xarch_host "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host -DFOO -Xarch_host -DFOO1 -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_HOST_MULTIPLE2
// RUN: %clangxx -fsycl %s -Xarch_host "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host -DFOO -Xarch_host -DFOO1 -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_HOST_MULTIPLE3
// RUN: %clangxx -fsycl %s -Xarch_host "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host -DFOO -Xarch_host -DFOO1 -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_HOST_MULTIPLE4
// RUN: %clangxx -fsycl %s -Xarch_host "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host -DFOO -Xarch_host -DFOO1 -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_NO_DEVICE_MULTIPLE1
// RUN: %clangxx -fsycl %s -Xarch_host "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host -DFOO -Xarch_host -DFOO1 -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_NO_DEVICE_MULTIPLE2
// RUN: %clangxx -fsycl %s -Xarch_host "-fsanitize=address -mllvm -enable-merge-functions" \
// RUN: -Xarch_host -DFOO -Xarch_host -DFOO1 -### 2>&1 \
// RUN: | FileCheck %s -check-prefix=SYCL_XARCH_NO_DEVICE_MULTIPLE3
// SYCL_XARCH_HOST_MULTIPLE1: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_HOST_MULTIPLE1-SAME: -fsanitize=address
// SYCL_XARCH_HOST_MULTIPLE1-NEXT: libclang_rt.asan
// SYCL_XARCH_HOST_MULTIPLE2: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_HOST_MULTIPLE2-SAME: "-mllvm" "-enable-merge-functions"
// SYCL_XARCH_HOST_MULTIPLE3: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_HOST_MULTIPLE3-SAME: "FOO"
// SYCL_XARCH_HOST_MULTIPLE4: clang{{.*}} "-fsycl-is-host"
// SYCL_XARCH_HOST_MULTIPLE4-SAME: "FOO1"
// SYCL_XARCH_NO_DEVICE_MULTIPLE1: clang{{.*}} "-fsycl-is-device"
// SYCL_XARCH_NO_DEVICE_MULTIPLE1-NOT: -fsanitize=address
// SYCL_XARCH_NO_DEVICE_MULTIPLE1: llc{{.*}} "-filetype=obj"
// SYCL_XARCH_NO_DEVICE_MULTIPLE2: clang{{.*}} "-fsycl-is-device"
// SYCL_XARCH_NO_DEVICE_MULTIPLE2-NOT: "-mllvm" "-enable-merge-functions"
// SYCL_XARCH_NO_DEVICE_MULTIPLE2: llc{{.*}} "-filetype=obj"
// SYCL_XARCH_NO_DEVICE_MULTIPLE3: clang{{.*}} "-fsycl-is-device"
// SYCL_XARCH_NO_DEVICE_MULTIPLE3-NOT: "FOO"
// SYCL_XARCH_NO_DEVICE_MULTIPLE3: llc{{.*}} "-filetype=obj"
21 changes: 21 additions & 0 deletions libdevice/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ __spirv_AtomicCompareExchange(int SPIR_GLOBAL *, __spv::Scope::Flag,
__spv::MemorySemanticsMask::Flag,
__spv::MemorySemanticsMask::Flag, int, int);

extern DEVICE_EXTERNAL int
__spirv_AtomicCompareExchange(int *, __spv::Scope::Flag,
__spv::MemorySemanticsMask::Flag,
__spv::MemorySemanticsMask::Flag, int, int);

extern DEVICE_EXTERNAL int __spirv_AtomicLoad(const int SPIR_GLOBAL *,
__spv::Scope::Flag,
__spv::MemorySemanticsMask::Flag);
Expand All @@ -70,6 +75,10 @@ extern DEVICE_EXTERNAL void
__spirv_AtomicStore(int SPIR_GLOBAL *, __spv::Scope::Flag,
__spv::MemorySemanticsMask::Flag, int);

extern DEVICE_EXTERNAL void
__spirv_AtomicStore(int *, __spv::Scope::Flag, __spv::MemorySemanticsMask::Flag,
int);

/// Atomically set the value in *Ptr with Desired if and only if it is Expected
/// Return the value which already was in *Ptr
static inline int atomicCompareAndSet(SPIR_GLOBAL int *Ptr, int Desired,
Expand All @@ -80,6 +89,13 @@ static inline int atomicCompareAndSet(SPIR_GLOBAL int *Ptr, int Desired,
__spv::MemorySemanticsMask::SequentiallyConsistent, Desired, Expected);
}

static inline int atomicCompareAndSet(int *Ptr, int Desired, int Expected) {
return __spirv_AtomicCompareExchange(
Ptr, __spv::Scope::Device,
__spv::MemorySemanticsMask::SequentiallyConsistent,
__spv::MemorySemanticsMask::SequentiallyConsistent, Desired, Expected);
}

static inline int atomicLoad(SPIR_GLOBAL int *Ptr) {
return __spirv_AtomicLoad(Ptr, __spv::Scope::Device,
__spv::MemorySemanticsMask::SequentiallyConsistent);
Expand All @@ -90,4 +106,9 @@ static inline void atomicStore(SPIR_GLOBAL int *Ptr, int V) {
__spv::MemorySemanticsMask::SequentiallyConsistent, V);
}

static inline void atomicStore(int *Ptr, int V) {
__spirv_AtomicStore(Ptr, __spv::Scope::Device,
__spv::MemorySemanticsMask::SequentiallyConsistent, V);
}

#endif // __SPIR__
6 changes: 3 additions & 3 deletions libdevice/cmake/modules/SYCLLibdevice.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ set(imf_obj_deps device_imf.hpp imf_half.hpp imf_bf16.hpp imf_rounding_op.hpp im
set(itt_obj_deps device_itt.h spirv_vars.h device.h sycl-compiler)
set(bfloat16_obj_deps sycl-headers sycl-compiler)
if (NOT MSVC)
set(sanitizer_obj_deps device.h sycl-compiler)
set(sanitizer_obj_deps device.h atomic.hpp spirv_vars.h include/sanitizer_device_utils.hpp include/spir_global_var.hpp sycl-compiler)
endif()

add_devicelib_obj(libsycl-itt-stubs SRC itt_stubs.cpp DEP ${itt_obj_deps})
Expand All @@ -126,9 +126,9 @@ add_devicelib_obj(libsycl-imf-fp64 SRC imf_wrapper_fp64.cpp DEP ${imf_obj_deps})
add_devicelib_obj(libsycl-imf-bf16 SRC imf_wrapper_bf16.cpp DEP ${imf_obj_deps})
add_devicelib_obj(libsycl-bfloat16 SRC bfloat16_wrapper.cpp DEP ${cmath_obj_deps} )
if(MSVC)
add_devicelib_obj(libsycl-msvc-math SRC msvc_math.cpp DEP ${cmath_obj_deps})
add_devicelib_obj(libsycl-msvc-math SRC msvc_math.cpp DEP ${cmath_obj_deps})
else()
add_devicelib_obj(libsycl-sanitizer SRC sanitizer_utils.cpp DEP ${sanitizer_obj_deps})
add_devicelib_obj(libsycl-sanitizer SRC sanitizer_utils.cpp DEP ${sanitizer_obj_deps} EXTRA_ARGS -fno-sycl-instrument-device-code)
endif()

add_fallback_devicelib(libsycl-fallback-cassert SRC fallback-cassert.cpp DEP ${crt_obj_deps} EXTRA_ARGS -fno-sycl-instrument-device-code)
Expand Down
58 changes: 58 additions & 0 deletions libdevice/include/device-sanitizer-report.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//==-- device-sanitizer-report.hpp - Structure and declaration for assert
// support --==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#pragma once

// Treat this header as system one to workaround frontend's restriction
#pragma clang system_header

#include <cinttypes>

enum class DeviceSanitizerErrorType : int32_t {
UNKNOWN,
OUT_OF_BOUND,
MISALIGNED,
USE_AFTER_FREE,
OUT_OF_SHADOW_BOUND,
};

enum class DeviceSanitizerMemoryType : int32_t {
UNKNOWN,
USM_DEVICE,
USM_HOST,
USM_SHARED,
LOCAL,
PRIVATE,
MEM_BUFFER,
};

// NOTE Layout of this structure should be aligned with the one in
// sycl/include/sycl/detail/device_sanitizer_report.hpp
struct DeviceSanitizerReport {
int Flag = 0;

char File[256 + 1] = "";
char Func[256 + 1] = "";

int32_t Line = 0;

uint64_t GID0 = 0;
uint64_t GID1 = 0;
uint64_t GID2 = 0;

uint64_t LID0 = 0;
uint64_t LID1 = 0;
uint64_t LID2 = 0;

bool IsWrite = false;
uint32_t AccessSize = 0;
DeviceSanitizerMemoryType MemoryType = DeviceSanitizerMemoryType::UNKNOWN;
DeviceSanitizerErrorType ErrorType = DeviceSanitizerErrorType::UNKNOWN;

bool IsRecover = false;
};
Loading

0 comments on commit 9649eda

Please sign in to comment.