-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeviceSanitizer] Support nullpointer detection & enable GPU tests (#…
…14891) UR: oneapi-src/unified-runtime#1914 --------- Co-authored-by: omarahmed1111 <[email protected]>
- Loading branch information
1 parent
a9b870b
commit 0985116
Showing
5 changed files
with
105 additions
and
32 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
32 changes: 32 additions & 0 deletions
32
sycl/test-e2e/AddressSanitizer/nullpointer/global_nullptr.cpp
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,32 @@ | ||
// REQUIRES: linux | ||
// RUN: %{build} %device_asan_flags -O0 -g -o %t | ||
// RUN: %{run} not %t 2>&1 | FileCheck %s | ||
// RUN: %{build} %device_asan_flags -O1 -g -o %t | ||
// RUN: %{run} not %t 2>&1 | FileCheck %s | ||
// RUN: %{build} %device_asan_flags -O2 -g -o %t | ||
// RUN: %{run} not %t 2>&1 | FileCheck %s | ||
|
||
#include <sycl/detail/core.hpp> | ||
|
||
int main() { | ||
sycl::queue Q; | ||
constexpr std::size_t N = 4; | ||
int *array = nullptr; | ||
|
||
Q.submit([&](sycl::handler &h) { | ||
h.parallel_for<class MyKernel>( | ||
sycl::nd_range<1>(N, 1), [=](sycl::nd_item<1> item) { | ||
auto private_array = | ||
sycl::ext::oneapi::experimental::static_address_cast< | ||
sycl::access::address_space::private_space, | ||
sycl::access::decorated::no>(array); | ||
private_array[0] = 0; | ||
}); | ||
Q.wait(); | ||
}); | ||
// CHECK: ERROR: DeviceSanitizer: null-pointer-access on Unknown Memory | ||
// CHECK: WRITE of size 4 at kernel {{<.*MyKernel>}} LID(0, 0, 0) GID({{.*}}, 0, 0) | ||
// CHECK: {{.*global_nullptr.cpp}}:[[@LINE-5]] | ||
|
||
return 0; | ||
} |
36 changes: 36 additions & 0 deletions
36
sycl/test-e2e/AddressSanitizer/nullpointer/private_nullptr.cpp
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,36 @@ | ||
// REQUIRES: linux | ||
// RUN: %{build} %device_asan_flags -O0 -g -o %t | ||
// RUN: %{run} not %t 2>&1 | FileCheck %s | ||
// RUN: %{build} %device_asan_flags -O1 -g -o %t | ||
// RUN: %{run} not %t 2>&1 | FileCheck %s | ||
// RUN: %{build} %device_asan_flags -O2 -g -o %t | ||
// RUN: %{run} not %t 2>&1 | FileCheck %s | ||
|
||
// FIXME: There's an issue in gfx driver, so this test pending here. | ||
// XFAIL: * | ||
|
||
#include <sycl/detail/core.hpp> | ||
#include <sycl/ext/oneapi/experimental/address_cast.hpp> | ||
|
||
int main() { | ||
sycl::queue Q; | ||
constexpr std::size_t N = 4; | ||
int *array = nullptr; | ||
|
||
Q.submit([&](sycl::handler &h) { | ||
h.parallel_for<class MyKernel>( | ||
sycl::nd_range<1>(N, 1), [=](sycl::nd_item<1> item) { | ||
auto private_array = | ||
sycl::ext::oneapi::experimental::static_address_cast< | ||
sycl::access::address_space::private_space, | ||
sycl::access::decorated::no>(array); | ||
private_array[0] = 0; | ||
}); | ||
Q.wait(); | ||
}); | ||
// CHECK: ERROR: DeviceSanitizer: null-pointer-access on Unknown Memory | ||
// CHECK: WRITE of size 4 at kernel {{<.*MyKernel>}} LID(0, 0, 0) GID({{.*}}, 0, 0) | ||
// CHECK: {{.*private_nullptr.cpp}}:[[@LINE-5]] | ||
|
||
return 0; | ||
} |