diff --git a/cmake/SetupBLTWrapper.cmake b/cmake/SetupBLTWrapper.cmake index f55c52b7..a39803e4 100644 --- a/cmake/SetupBLTWrapper.cmake +++ b/cmake/SetupBLTWrapper.cmake @@ -50,7 +50,7 @@ if(NOT BLT_LOADED) option(ENABLE_FORTRAN "Enables Fortran compiler support" OFF) - set(BLT_CXX_STD "c++14" CACHE STRING "Set the c++ standard to use") + set(BLT_CXX_STD "c++17" CACHE STRING "Set the c++ standard to use") include(${BLT_SOURCE_DIR}/SetupBLT.cmake) endif() diff --git a/configs/lc/toss_4_x86_64_ib_cray/amdclang.cmake b/configs/lc/toss_4_x86_64_ib_cray/amdclang.cmake index 560e9fd1..9fb9af10 100644 --- a/configs/lc/toss_4_x86_64_ib_cray/amdclang.cmake +++ b/configs/lc/toss_4_x86_64_ib_cray/amdclang.cmake @@ -5,11 +5,15 @@ # SPDX-License-Identifier: BSD-3-Clause ############################################################################## -set(COMPILER_BASE "/usr/tce/packages/rocmcc/rocmcc-6.1.0-magic" CACHE PATH "") +set(ROCM_VER "6.3.0" CACHE STRING "") +set(COMPILER_BASE "/usr/tce/packages/rocmcc/rocmcc-${ROCM_VER}-magic" CACHE PATH "") set(CMAKE_C_COMPILER "${COMPILER_BASE}/bin/amdclang" CACHE PATH "") set(CMAKE_CXX_COMPILER "${COMPILER_BASE}/bin/amdclang++" CACHE PATH "") set(ENABLE_HIP ON CACHE BOOL "Enable Hip") -set(ROCM_PATH "/usr/tce/packages/rocmcc/rocmcc-6.1.0-magic" CACHE PATH "") +set(ROCM_PATH "/usr/tce/packages/rocmcc/rocmcc-${ROCM_VER}-magic" CACHE PATH "") set(CMAKE_HIP_ARCHITECTURES "gfx942:xnack+" CACHE STRING "") set(AMDGPU_TARGETS "gfx942:xnack+" CACHE STRING "") + +# Used by the DeviceASAN example +set(CARE_ASAN_RPATH_FLAG "-Wl,-rpath,/opt/rocm-${ROCM_VER}/lib/asan/:/opt/rocm-${ROCM_VER}/llvm/lib/asan:/opt/rocm-${ROCM_VER}/lib/llvm/lib/clang/18/lib/linux" CACHE STRING "") diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4a9fc53d..e7337c67 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -43,3 +43,15 @@ target_include_directories(RaceConditionsExample PRIVATE ${PROJECT_BINARY_DIR}/i target_compile_options(RaceConditionsExample PRIVATE -fsanitize=thread -g) target_link_options(RaceConditionsExample PRIVATE -fsanitize=thread) + +if (ENABLE_HIP) + blt_add_executable(NAME DeviceASANExample + SOURCES DeviceASAN.cpp + DEPENDS_ON ${care_depends}) + + target_include_directories(DeviceASANExample PRIVATE ${PROJECT_SOURCE_DIR}/src) + target_include_directories(DeviceASANExample PRIVATE ${PROJECT_BINARY_DIR}/include) + + target_compile_options(DeviceASANExample PRIVATE -fsanitize=address -shared-libsan -g) + target_link_options(DeviceASANExample PRIVATE -fsanitize=address -shared-libsan -g ${CARE_ASAN_RPATH_FLAG}) +endif () diff --git a/examples/DeviceASAN.cpp b/examples/DeviceASAN.cpp new file mode 100644 index 00000000..e36127e5 --- /dev/null +++ b/examples/DeviceASAN.cpp @@ -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 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; +}