-
Notifications
You must be signed in to change notification settings - Fork 23
Assert on out-of-range accesses #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 10 commits
e1f32c4
a7bde92
827c11a
6a7b929
a989c60
5bbb458
e81eb80
908df3f
a0a6664
f38337d
a7af717
6c55bf9
dfa4b55
deba461
183358a
4eb6636
495e9b4
56044d4
a2526d8
6f9e038
87375a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -393,20 +393,44 @@ CUDA_TEST(ManagedArray, UserCallback) | |
| #endif | ||
| #endif | ||
|
|
||
| #if defined(CHAI_ENABLE_BOUNDS_CHECK) | ||
| TEST(ManagedArray, UpperOutOfRangeAccess) | ||
| { | ||
| chai::ManagedArray<float> array(20); | ||
|
|
||
| #if defined(CHAI_ENABLE_CUDA) | ||
| CUDA_TEST(ManagedArray, Move) | ||
| array[19] = 0.0; | ||
| EXPECT_DEATH_IF_SUPPORTED( array[20] = 0.0, ".*" ); | ||
| } | ||
|
|
||
| TEST(ManagedArray, LowerOutOfRangeAccess) | ||
| { | ||
| chai::ManagedArray<float> array(10, chai::GPU); | ||
| chai::ManagedArray<float> array(20); | ||
|
|
||
| forall(cuda(), 0, 10, [=] __device__ (int i) { | ||
| array[i] = i; | ||
| }); | ||
| array[0] = 0.0; | ||
| EXPECT_DEATH_IF_SUPPORTED( array[-1] = 0.0, ".*" ); | ||
| } | ||
|
|
||
| array.move(chai::CPU); | ||
| #if defined(CHAI_ENABLE_CUDA) | ||
| CUDA_TEST(ManagedArray, UpperOutOfRangeAccessGPU) | ||
| { | ||
| chai::ManagedArray<float> array(20); | ||
|
|
||
| ASSERT_EQ(array[5], 5); | ||
| EXPECT_DEATH( | ||
| forall(cuda(), 19, 20, [=] __device__ (int i) { | ||
| array[i] = 0.0f; | ||
| });, | ||
| "i > m_elems"); | ||
| } | ||
|
|
||
|
||
| array.free(); | ||
| CUDA_TEST(ManagedArray, LowerOutOfRangeAccessGPU) | ||
| { | ||
| chai::ManagedArray<float> array(20); | ||
|
|
||
| EXPECT_DEATH( | ||
| forall(cuda(), -1, 0, [=] __device__ (int i) { | ||
| array[i] = 0.0f; | ||
| });, | ||
| "i < 0"); | ||
| } | ||
| #endif // defined(CHAI_ENABLE_CUDA) | ||
| #endif // !defined(NDEBUG) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be an
optionat the top of the CMakeLists file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.