-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add device address sanitizer example (#311)
* Update BLT_CXX_STD default to c++17 * Update host config to rocm 6.3.0 * Add working device address sanitizer example
- Loading branch information
Showing
4 changed files
with
50 additions
and
3 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
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,31 @@ | ||
////////////////////////////////////////////////////////////////////////////// | ||
// Copyright (c) 2024, Lawrence Livermore National Security, LLC and CARE | ||
// project contributors. See the CARE LICENSE file for details. | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
////////////////////////////////////////////////////////////////////////////// | ||
|
||
// CARE library header | ||
#include "care/care.h" | ||
|
||
int main(int, char**) { | ||
const int size = 1000000; | ||
care::host_device_ptr<int> data(size); | ||
|
||
CARE_STREAM_LOOP(i, 0, size) { | ||
data[i] = i; | ||
} CARE_STREAM_LOOP_END | ||
|
||
// This will write past the end of the array. | ||
// ASAN should report something like the following: | ||
// | ||
// ==4084715==ERROR: AddressSanitizer: heap-buffer-overflow on amdgpu device 0 at pc 0x153d3cdd3db8 | ||
// READ of size 4 in workgroup id (3906,0,0) | ||
// #0 0x153d3cdd3db8 in main::'lambda0'(int)::operator()(int) const at /g/g17/dayton8/ale3d/github_care_4/examples/DeviceASAN.cpp:26:14 | ||
CARE_STREAM_LOOP(i, 0, size + 1) { | ||
data[i]++; | ||
} CARE_STREAM_LOOP_END | ||
|
||
data.free(); | ||
return 0; | ||
} |