Skip to content

Commit

Permalink
Squash amdclang warnings. (#299)
Browse files Browse the repository at this point in the history
* Separate host-configs for amdclang w/o +xnack.
* Squashing wanrings for amdclang HIP builds.
* Add CHAI_UNUSED_VAR.
  • Loading branch information
mdavis36 authored Feb 5, 2025
1 parent 799ce36 commit 6588a53
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 15 deletions.
26 changes: 26 additions & 0 deletions host-configs/lc/toss_4_x86_64_ib_cray/amdclang-xnack.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
##############################################################################
# Copyright (c) 2025, Lawrence Livermore National Security, LLC and CHAI
# project contributors. See the CHAI LICENSE file for details.
#
# SPDX-License-Identifier: BSD-3-Clause
##############################################################################

# Set up software versions
set(ROCM_VERSION "6.2.0" CACHE PATH "")
set(GCC_VERSION "12.2.1" CACHE PATH "")

# Set up compilers
set(COMPILER_BASE "/usr/tce/packages/rocmcc/rocmcc-${ROCM_VERSION}-magic" CACHE PATH "")
set(CMAKE_C_COMPILER "${COMPILER_BASE}/bin/amdclang" CACHE PATH "")
set(CMAKE_CXX_COMPILER "${COMPILER_BASE}/bin/amdclang++" CACHE PATH "")

# Set up compiler flags
set(GCC_HOME "/usr/tce/packages/gcc/gcc-${GCC_VERSION}" CACHE PATH "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --gcc-toolchain=${GCC_HOME}" CACHE STRING "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --gcc-toolchain=${GCC_HOME}" CACHE STRING "")

# Set up HIP
set(ENABLE_HIP ON CACHE BOOL "")
set(ROCM_PATH "/usr/tce/packages/rocmcc/rocmcc-${ROCM_VERSION}-magic" CACHE PATH "")
set(CMAKE_HIP_ARCHITECTURES "gfx942:xnack+" CACHE STRING "")
set(AMDGPU_TARGETS "${CMAKE_HIP_ARCHITECTURES}" CACHE STRING "")
4 changes: 2 additions & 2 deletions host-configs/lc/toss_4_x86_64_ib_cray/amdclang.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##############################################################################
# Copyright (c) 2024, Lawrence Livermore National Security, LLC and CHAI
# Copyright (c) 2025, Lawrence Livermore National Security, LLC and CHAI
# project contributors. See the CHAI LICENSE file for details.
#
# SPDX-License-Identifier: BSD-3-Clause
Expand All @@ -22,5 +22,5 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --gcc-toolchain=${GCC_HOME}" CACHE STRIN
# Set up HIP
set(ENABLE_HIP ON CACHE BOOL "")
set(ROCM_PATH "/usr/tce/packages/rocmcc/rocmcc-${ROCM_VERSION}-magic" CACHE PATH "")
set(CMAKE_HIP_ARCHITECTURES "gfx942:xnack+" CACHE STRING "")
set(CMAKE_HIP_ARCHITECTURES "gfx942" CACHE STRING "")
set(AMDGPU_TARGETS "${CMAKE_HIP_ARCHITECTURES}" CACHE STRING "")
10 changes: 10 additions & 0 deletions src/chai/ChaiMacros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

#include "umpire/util/Macros.hpp"

#if defined(CHAI_ENABLE_CUDA) || defined(CHAI_ENABLE_HIP)
#define CHAI_ENABLE_DEVICE
#endif

#if defined(CHAI_ENABLE_CUDA)

#include <cuda_runtime_api.h>
Expand Down Expand Up @@ -92,4 +96,10 @@
#endif
#endif

namespace chai
{
template <typename... T>
CHAI_HOST_DEVICE CHAI_INLINE void CHAI_UNUSED_VAR(T &&...) noexcept {}
} // namespace chai

#endif // CHAI_ChaiMacros_HPP
1 change: 1 addition & 0 deletions src/chai/ManagedArray.inl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ CHAI_HOST_DEVICE ManagedArray<T>::ManagedArray(
ExecutionSpace space) :
ManagedArray()
{
CHAI_UNUSED_VAR(elems, space);
#if !defined(CHAI_DEVICE_COMPILE)
this->allocate(elems, space);
#endif
Expand Down
20 changes: 13 additions & 7 deletions tests/integration/managed_array_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
static void gpu_test_##X##Y()

#ifdef NDEBUG
#define device_assert(EXP) if( !EXP ) asm ("trap;")

#ifdef CHAI_ENABLE_CUDA
#define device_assert(EXP) if( !(EXP) ) asm ("trap;")
#else
#define device_assert(EXP) if( !(EXP) ) asm ("s_trap 1;")
#endif

#else
#define device_assert(EXP) assert(EXP)
#endif
Expand Down Expand Up @@ -799,7 +805,7 @@ GPU_TEST(ManagedArray, dataGPU)
chai::ManagedArray<int> array;
array.allocate(length,
chai::GPU,
[&] (const chai::PointerRecord* record, chai::Action act, chai::ExecutionSpace s) {
[&] (const chai::PointerRecord*, chai::Action act, chai::ExecutionSpace s) {
if (act == chai::ACTION_MOVE) {
if (s == chai::CPU) {
++transfersD2H;
Expand Down Expand Up @@ -827,7 +833,7 @@ GPU_TEST(ManagedArray, dataGPU)

// Move data to device with touch
forall(gpu(), 0, length, [=] __device__ (int i) {
int* d_data = array.data();
array.data();
array[i] += 1;
});

Expand All @@ -845,7 +851,7 @@ GPU_TEST(ManagedArray, dataGPU)

// Access on device with touch (should not be moved)
forall(gpu(), 0, length, [=] __device__ (int i) {
int* d_data = array.data();
array.data();
array[i] += i;
});

Expand Down Expand Up @@ -896,7 +902,7 @@ GPU_TEST(ManagedArray, cdataGPU)
chai::ManagedArray<int> array;
array.allocate(length,
chai::GPU,
[&] (const chai::PointerRecord* record, chai::Action act, chai::ExecutionSpace s) {
[&] (const chai::PointerRecord*, chai::Action act, chai::ExecutionSpace s) {
if (act == chai::ACTION_MOVE) {
if (s == chai::CPU) {
++transfersD2H;
Expand Down Expand Up @@ -1791,11 +1797,11 @@ GPU_TEST(ManagedArray, CopyZero)
array.allocate(0);
ASSERT_EQ(array.size(), 0u);

forall(gpu(), 0, 1, [=] __device__ (int i) {
forall(gpu(), 0, 1, [=] __device__ (int) {
(void) array;
});

forall(sequential(), 0, 1, [=] (int i) {
forall(sequential(), 0, 1, [=] (int) {
(void) array;
});

Expand Down
12 changes: 6 additions & 6 deletions tests/integration/managed_ptr_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ GPU_TEST(managed_ptr, gpu_class_with_managed_array)

chai::ManagedArray<int> array(1, chai::CPU);

forall(sequential(), 0, 1, [=] (int i) {
forall(sequential(), 0, 1, [=] (int) {
array[0] = expectedValue;
});

Expand All @@ -549,7 +549,7 @@ GPU_TEST(managed_ptr, gpu_class_with_raw_ptr)

chai::ManagedArray<int> array(1, chai::CPU);

forall(sequential(), 0, 1, [=] (int i) {
forall(sequential(), 0, 1, [=] (int) {
array[0] = expectedValue;
});

Expand Down Expand Up @@ -642,7 +642,7 @@ GPU_TEST(managed_ptr, static_pointer_cast)

chai::ManagedArray<int> array(1, chai::CPU);

forall(sequential(), 0, 1, [=] (int i) {
forall(sequential(), 0, 1, [=] (int) {
array[0] = expectedValue;
});

Expand Down Expand Up @@ -675,7 +675,7 @@ GPU_TEST(managed_ptr, dynamic_pointer_cast)

chai::ManagedArray<int> array(1, chai::CPU);

forall(sequential(), 0, 1, [=] (int i) {
forall(sequential(), 0, 1, [=] (int) {
array[0] = expectedValue;
});

Expand Down Expand Up @@ -708,7 +708,7 @@ GPU_TEST(managed_ptr, const_pointer_cast)

chai::ManagedArray<int> array(1, chai::CPU);

forall(sequential(), 0, 1, [=] (int i) {
forall(sequential(), 0, 1, [=] (int) {
array[0] = expectedValue;
});

Expand Down Expand Up @@ -741,7 +741,7 @@ GPU_TEST(managed_ptr, reinterpret_pointer_cast)

chai::ManagedArray<int> array(1, chai::CPU);

forall(sequential(), 0, 1, [=] (int i) {
forall(sequential(), 0, 1, [=] (int) {
array[0] = expectedValue;
});

Expand Down

0 comments on commit 6588a53

Please sign in to comment.