Skip to content
Merged
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(camp_VERSION_PATCH ${PROJECT_VERSION_PATCH})

include(CheckCXXCompilerFlag)
if(NOT DEFINED BLT_CXX_STD)
set(CXX_VERSIONS 17 14)
set(CXX_VERSIONS 17)
foreach(cxxver ${CXX_VERSIONS})
if("cxx_std_${cxxver}" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
if (ENABLE_CUDA AND (NOT DEFINED CMAKE_CUDA_COMPILE_FEATURES OR (NOT "cuda_std_${cxxver}" IN_LIST CMAKE_CUDA_COMPILE_FEATURES)))
Expand All @@ -28,17 +28,17 @@ if(NOT DEFINED BLT_CXX_STD)
endif()
endforeach()
if(NOT DEFINED CAMP_CXX_STD)
set(CAMP_CXX_STD 14)
set(CAMP_CXX_STD 17)
endif()
set(BLT_CXX_STD c++${CAMP_CXX_STD} CACHE STRING "Version of C++
standard")
message("Using C++ standard: ${BLT_CXX_STD}")
else() #check BLT_CXX_STD is high enough by disallowing the only invalid option
set(_unsupported_cxx "c++98" "c++11")
set(_unsupported_cxx "c++98" "c++11" "c++14")
if (BLT_CXX_STD IN_LIST _unsupported_cxx)
message(FATAL_ERROR "CAMP and the RAJA framework no
longer support ${_unsupported_cxx}, select a c++
standard of 14 or higher")
standard of 17 or higher")
endif()
endif(NOT DEFINED BLT_CXX_STD)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down
9 changes: 6 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@ jobs:
# NVIDIA no longer supports "latest", must update manually
nvcc11:
base_img: nvcc
ver: 11.1.1
ver: 11.8.0
cmake_extra: -DENABLE_CUDA=On -DCMAKE_CUDA_ARCHITECTURES=70
nvcc11-debug:
base_img: nvcc
ver: 11.1.1
ver: 11.8.0
cmake_extra: -DENABLE_CUDA=On -DCMAKE_CUDA_ARCHITECTURES=70
build_type: Debug
nvcc12:
base_img: nvcc
ver: 12.2.0
ver: 12.2.2
cmake_extra: -DENABLE_CUDA=On -DCMAKE_CUDA_ARCHITECTURES=70
rocm:
base_img: rocm
cmake_extra: -DROCM_PATH=/opt/rocm -DENABLE_HIP=On -DENABLE_OPENMP=Off -DENABLE_CUDA=Off
Expand Down
4 changes: 4 additions & 0 deletions include/camp/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ CAMP_DLL_EXPORT void throw_re(const char *s);

#define campCudaErrchk(ans) ::camp::cudaAssert((ans), #ans, __FILE__, __LINE__)

#define campCudaErrchkDiscardReturn(ans) (void)::camp::cudaAssert((ans), #ans, __FILE__, __LINE__)

CAMP_DLL_EXPORT cudaError_t cudaAssert(cudaError_t code,
const char *call,
const char *file,
Expand All @@ -194,6 +196,8 @@ CAMP_DLL_EXPORT cudaError_t cudaAssert(cudaError_t code,

#define campHipErrchk(ans) ::camp::hipAssert((ans), #ans, __FILE__, __LINE__)

#define campHipErrchkDiscardReturn(ans) (void)::camp::hipAssert((ans), #ans, __FILE__, __LINE__)

CAMP_DLL_EXPORT hipError_t hipAssert(hipError_t code,
const char *call,
const char *file,
Expand Down
38 changes: 19 additions & 19 deletions include/camp/resource/cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ namespace resources
struct device_guard {
device_guard(int device)
{
campCudaErrchk(cudaGetDevice(&prev_device));
campCudaErrchkDiscardReturn(cudaGetDevice(&prev_device));
if (device != prev_device) {
campCudaErrchk(cudaSetDevice(device));
campCudaErrchkDiscardReturn(cudaSetDevice(device));
} else {
prev_device = -1;
}
Expand All @@ -43,7 +43,7 @@ namespace resources
~device_guard()
{
if (prev_device != -1) {
campCudaErrchk(cudaSetDevice(prev_device));
campCudaErrchkDiscardReturn(cudaSetDevice(prev_device));
}
}

Expand All @@ -63,17 +63,17 @@ namespace resources
{
return (campCudaErrchk(cudaEventQuery(m_event)) == cudaSuccess);
}
void wait() const { campCudaErrchk(cudaEventSynchronize(m_event)); }
void wait() const { campCudaErrchkDiscardReturn(cudaEventSynchronize(m_event)); }
cudaEvent_t getCudaEvent_t() const { return m_event; }

private:
cudaEvent_t m_event;

void init(cudaStream_t stream)
{
campCudaErrchk(
campCudaErrchkDiscardReturn(
cudaEventCreateWithFlags(&m_event, cudaEventDisableTiming));
campCudaErrchk(cudaEventRecord(m_event, stream));
campCudaErrchkDiscardReturn(cudaEventRecord(m_event, stream));
}
};

Expand All @@ -90,7 +90,7 @@ namespace resources
std::call_once(m_onceFlag, [] {
if (streams[0] == nullptr) {
for (auto &s : streams) {
campCudaErrchk(cudaStreamCreate(&s));
campCudaErrchkDiscardReturn(cudaStreamCreate(&s));
}
}
});
Expand Down Expand Up @@ -141,7 +141,7 @@ namespace resources
static Cuda CudaFromStream(cudaStream_t s, int dev = -1)
{
if (dev < 0) {
campCudaErrchk(cudaGetDevice(&dev));
campCudaErrchkDiscardReturn(cudaGetDevice(&dev));
}
return Cuda(s, dev);
}
Expand All @@ -155,7 +155,7 @@ namespace resources
#if CAMP_USE_PLATFORM_DEFAULT_STREAM
s = 0;
#else
campCudaErrchk(cudaStreamCreate(&s));
campCudaErrchkDiscardReturn(cudaStreamCreate(&s));
#endif
return s;
}());
Expand All @@ -169,15 +169,15 @@ namespace resources
void wait()
{
auto d{device_guard(device)};
campCudaErrchk(cudaStreamSynchronize(stream));
campCudaErrchkDiscardReturn(cudaStreamSynchronize(stream));
}

void wait_for(Event *e)
{
auto *cuda_event = e->try_get<CudaEvent>();
if (cuda_event) {
auto d{device_guard(device)};
campCudaErrchk(cudaStreamWaitEvent(get_stream(),
campCudaErrchkDiscardReturn(cudaStreamWaitEvent(get_stream(),
cuda_event->getCudaEvent_t(),
0));
} else {
Expand All @@ -195,15 +195,15 @@ namespace resources
switch (ma) {
case MemoryAccess::Unknown:
case MemoryAccess::Device:
campCudaErrchk(cudaMalloc(&ret, sizeof(T) * size));
campCudaErrchkDiscardReturn(cudaMalloc(&ret, sizeof(T) * size));
break;
case MemoryAccess::Pinned:
// TODO: do a test here for whether managed is *actually* shared
// so we can use the better performing memory
campCudaErrchk(cudaMallocHost(&ret, sizeof(T) * size));
campCudaErrchkDiscardReturn(cudaMallocHost(&ret, sizeof(T) * size));
break;
case MemoryAccess::Managed:
campCudaErrchk(cudaMallocManaged(&ret, sizeof(T) * size));
campCudaErrchkDiscardReturn(cudaMallocManaged(&ret, sizeof(T) * size));
break;
}
}
Expand All @@ -223,15 +223,15 @@ namespace resources
}
switch (ma) {
case MemoryAccess::Device:
campCudaErrchk(cudaFree(p));
campCudaErrchkDiscardReturn(cudaFree(p));
break;
case MemoryAccess::Pinned:
// TODO: do a test here for whether managed is *actually* shared
// so we can use the better performing memory
campCudaErrchk(cudaFreeHost(p));
campCudaErrchkDiscardReturn(cudaFreeHost(p));
break;
case MemoryAccess::Managed:
campCudaErrchk(cudaFree(p));
campCudaErrchkDiscardReturn(cudaFree(p));
break;
case MemoryAccess::Unknown:
::camp::throw_re("Unknown memory access type, cannot free");
Expand All @@ -241,15 +241,15 @@ namespace resources
{
if (size > 0) {
auto d{device_guard(device)};
campCudaErrchk(
campCudaErrchkDiscardReturn(
cudaMemcpyAsync(dst, src, size, cudaMemcpyDefault, stream));
}
}
void memset(void *p, int val, size_t size)
{
if (size > 0) {
auto d{device_guard(device)};
campCudaErrchk(cudaMemsetAsync(p, val, size, stream));
campCudaErrchkDiscardReturn(cudaMemsetAsync(p, val, size, stream));
}
}

Expand Down
38 changes: 19 additions & 19 deletions include/camp/resource/hip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ namespace resources
struct device_guard {
device_guard(int device)
{
campHipErrchk(hipGetDevice(&prev_device));
campHipErrchkDiscardReturn(hipGetDevice(&prev_device));
if (device != prev_device) {
campHipErrchk(hipSetDevice(device));
campHipErrchkDiscardReturn(hipSetDevice(device));
} else {
prev_device = -1;
}
Expand All @@ -42,7 +42,7 @@ namespace resources
~device_guard()
{
if (prev_device != -1) {
campHipErrchk(hipSetDevice(prev_device));
campHipErrchkDiscardReturn(hipSetDevice(prev_device));
}
}

Expand All @@ -61,16 +61,16 @@ namespace resources
{
return (campHipErrchk(hipEventQuery(m_event)) == hipSuccess);
}
void wait() const { campHipErrchk(hipEventSynchronize(m_event)); }
void wait() const { campHipErrchkDiscardReturn(hipEventSynchronize(m_event)); }
hipEvent_t getHipEvent_t() const { return m_event; }

private:
hipEvent_t m_event;

void init(hipStream_t stream)
{
campHipErrchk(hipEventCreateWithFlags(&m_event, hipEventDisableTiming));
campHipErrchk(hipEventRecord(m_event, stream));
campHipErrchkDiscardReturn(hipEventCreateWithFlags(&m_event, hipEventDisableTiming));
campHipErrchkDiscardReturn(hipEventRecord(m_event, stream));
}
};

Expand All @@ -87,7 +87,7 @@ namespace resources
std::call_once(m_onceFlag, [] {
if (streams[0] == nullptr) {
for (auto &s : streams) {
campHipErrchk(hipStreamCreate(&s));
campHipErrchkDiscardReturn(hipStreamCreate(&s));
}
}
});
Expand Down Expand Up @@ -142,7 +142,7 @@ namespace resources
static Hip HipFromStream(hipStream_t s, int dev = -1)
{
if (dev < 0) {
campHipErrchk(hipGetDevice(&dev));
campHipErrchkDiscardReturn(hipGetDevice(&dev));
}
return Hip(s, dev);
}
Expand All @@ -156,7 +156,7 @@ namespace resources
#if CAMP_USE_PLATFORM_DEFAULT_STREAM
s = 0;
#else
campHipErrchk(hipStreamCreate(&s));
campHipErrchkDiscardReturn(hipStreamCreate(&s));
#endif
return s;
}());
Expand All @@ -170,15 +170,15 @@ namespace resources
void wait()
{
auto d{device_guard(device)};
campHipErrchk(hipStreamSynchronize(stream));
campHipErrchkDiscardReturn(hipStreamSynchronize(stream));
}

void wait_for(Event *e)
{
auto *hip_event = e->try_get<HipEvent>();
if (hip_event) {
auto d{device_guard(device)};
campHipErrchk(
campHipErrchkDiscardReturn(
hipStreamWaitEvent(get_stream(), hip_event->getHipEvent_t(), 0));
} else {
e->wait();
Expand All @@ -195,15 +195,15 @@ namespace resources
switch (ma) {
case MemoryAccess::Unknown:
case MemoryAccess::Device:
campHipErrchk(hipMalloc((void**)&ret, sizeof(T) * size));
campHipErrchkDiscardReturn(hipMalloc((void**)&ret, sizeof(T) * size));
break;
case MemoryAccess::Pinned:
// TODO: do a test here for whether managed is *actually* shared
// so we can use the better performing memory
campHipErrchk(hipHostMalloc((void**)&ret, sizeof(T) * size));
campHipErrchkDiscardReturn(hipHostMalloc((void**)&ret, sizeof(T) * size));
break;
case MemoryAccess::Managed:
campHipErrchk(hipMallocManaged((void**)&ret, sizeof(T) * size));
campHipErrchkDiscardReturn(hipMallocManaged((void**)&ret, sizeof(T) * size));
break;
}
}
Expand All @@ -223,15 +223,15 @@ namespace resources
}
switch (ma) {
case MemoryAccess::Device:
campHipErrchk(hipFree(p));
campHipErrchkDiscardReturn(hipFree(p));
break;
case MemoryAccess::Pinned:
// TODO: do a test here for whether managed is *actually* shared
// so we can use the better performing memory
campHipErrchk(hipHostFree(p));
campHipErrchkDiscardReturn(hipHostFree(p));
break;
case MemoryAccess::Managed:
campHipErrchk(hipFree(p));
campHipErrchkDiscardReturn(hipFree(p));
break;
case MemoryAccess::Unknown:
::camp::throw_re("Unknown memory access type, cannot free");
Expand All @@ -242,15 +242,15 @@ namespace resources
{
if (size > 0) {
auto d{device_guard(device)};
campHipErrchk(
campHipErrchkDiscardReturn(
hipMemcpyAsync(dst, src, size, hipMemcpyDefault, stream));
}
}
void memset(void *p, int val, size_t size)
{
if (size > 0) {
auto d{device_guard(device)};
campHipErrchk(hipMemsetAsync(p, val, size, stream));
campHipErrchkDiscardReturn(hipMemsetAsync(p, val, size, stream));
}
}

Expand Down
2 changes: 2 additions & 0 deletions test/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ CAMP_TEST_BEGIN(array, structured_binding)
a[1] == 3;
} CAMP_TEST_END(array, structured_binding)

//If CUDA is enabled and building with c++17, must use up-to-date CUDA version
//Or this test will fail. Worked with cuda/11.8.0 and clang/18.1.8
CAMP_TEST_BEGIN(array, deduction_guide)
{
camp::array a{-1, 1};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try Tom's suggestion of camp::array a(-1, 1);?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, when I do that I get the error

/g/g0/belcher6/camp/test/array.cpp(407): error: too many initializer values
/g/g0/belcher6/camp/test/array.cpp(407): error: no suitable constructor exists to convert from "int" to "camp::array<int, 2UL>"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I guess we can disable this test if CUDA is enabled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adayton1, I did some digging around and there was a suggestion to update the cuda version. I updated to CUDA 11.8.0 and used clang/18.1.8 (loaded the clang/18.1.8-cuda-11.8.0-gcc-11.2.1 module) and it worked on rzansel. So - it looks like this is a bug which has been fixed on later cuda versions than I initially tried (I was running on 11.2.0 before).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could add a test for this in the azure pipelines... but I noticed that cuda isn't being turned on for the nvcc docker runs. is that done on purpose?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. I'm glad the update worked. The extra error you posted means it didn't generate the right aggregate initializer like it should have. Has the min CUDA version for RAJA advanced that far yet? If so, we might be able to get some compile time back on tuples for nvcc builds as well.

I noticed that cuda isn't being turned on for the nvcc docker runs. is that done on purpose?

No, unless I missed it, and that's horrifying. Creating an issue about that right now...

Expand Down
Loading