-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeviceSanitizer] Support CPU Device & Static Local Memory (#12248)
UR: oneapi-src/unified-runtime#1210 --------- Co-authored-by: Maosu Zhao <maosu.zhao@intel.com>
- Loading branch information
Showing
19 changed files
with
1,304 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//==-- sanitizer_device_utils.hpp - Declaration for sanitizer global var ---==// | ||
// | ||
// 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 | ||
|
||
#include "spir_global_var.hpp" | ||
#include <cstdint> | ||
|
||
// Treat this header as system one to workaround frontend's restriction | ||
#pragma clang system_header | ||
|
||
template <typename T> | ||
class | ||
#ifdef __SYCL_DEVICE_ONLY__ | ||
[[__sycl_detail__::global_variable_allowed, __sycl_detail__::device_global, | ||
__sycl_detail__::add_ir_attributes_global_variable( | ||
"sycl-device-global-size", "sycl-device-image-scope", sizeof(T), | ||
nullptr)]] | ||
#endif | ||
DeviceGlobal { | ||
public: | ||
DeviceGlobal() = default; | ||
DeviceGlobal(const DeviceGlobal &) = delete; | ||
DeviceGlobal(const DeviceGlobal &&) = delete; | ||
DeviceGlobal &operator=(const DeviceGlobal &) = delete; | ||
DeviceGlobal &operator=(const DeviceGlobal &&) = delete; | ||
|
||
DeviceGlobal &operator=(const T newValue) noexcept { | ||
val = newValue; | ||
return *this; | ||
} | ||
|
||
operator T &() noexcept { return val; } | ||
|
||
operator const T &() const noexcept { return val; } | ||
|
||
T &get() noexcept { return val; } | ||
|
||
const T &get() const noexcept { return val; } | ||
|
||
private: | ||
T val; | ||
}; | ||
|
||
enum DeviceType : uintptr_t { UNKNOWN, CPU, GPU_PVC, GPU_DG2 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//==- spir_global_var.hpp - Declaration for device global variable 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 | ||
|
||
#ifndef SPIR_GLOBAL_VAR | ||
#ifdef __SYCL_DEVICE_ONLY__ | ||
#define SPIR_GLOBAL_VAR __attribute__((sycl_global_var)) | ||
#else | ||
#warning "SPIR_GLOBAL_VAR not defined in host mode. Defining as empty macro." | ||
#define SPIR_GLOBAL_VAR | ||
#endif | ||
#endif | ||
|
||
#define __SYCL_GLOBAL__ __attribute__((opencl_global)) | ||
#define __SYCL_LOCAL__ __attribute__((opencl_local)) | ||
#define __SYCL_PRIVATE__ __attribute__((opencl_private)) | ||
#define __SYCL_CONSTANT__ __attribute__((opencl_constant)) |
Oops, something went wrong.