Skip to content

Commit

Permalink
Fix CUDA gcc 13 conflict. Similarily to QMCPACK#4814
Browse files Browse the repository at this point in the history
  • Loading branch information
ye-luo committed Sep 11, 2024
1 parent f5b0047 commit 9a66e02
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Platforms/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#// File created by: Ye Luo, [email protected], Argonne National Laboratory
#//////////////////////////////////////////////////////////////////////////////////////

set(CUDA_RT_SRCS CUDAfill.cpp CUDAallocator.cpp CUDAruntime.cpp CUDADeviceManager.cpp)
set(CUDA_RT_SRCS CUDAfill.cpp CUDAallocator.cpp CUDAerror.cpp CUDAruntime.cpp CUDADeviceManager.cpp)
set(CUDA_LA_SRCS cuBLAS_missing_functions.cu)

add_library(platform_cuda_runtime ${CUDA_RT_SRCS})
Expand Down
28 changes: 10 additions & 18 deletions src/Platforms/CUDA/CUDAerror.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//// This file is distributed under the University of Illinois/NCSA Open Source License.
//// See LICENSE file in top directory for details.
////
//// Copyright (c) 2019 QMCPACK developers.
//// Copyright (c) 2024 QMCPACK developers.
////
//// File developed by: Ye Luo, [email protected], Argonne National Laboratory
////
Expand All @@ -13,10 +13,14 @@
#ifndef QMCPLUSPLUS_CUDA_ERROR_H
#define QMCPLUSPLUS_CUDA_ERROR_H

#include <iostream>
#include <string>
#include <sstream>
#include <stdexcept>
#include <string> // Positioned here to avoid conflict between CUDA and GCC >= 12 header files. https://github.com/QMCPACK/qmcpack/pull/4814
#include "config.h"
#ifndef QMC_CUDA2HIP
#include <cuda_runtime.h>
#else
#include <hip/hip_runtime.h>
#include "Platforms/ROCm/cuda2hip.h"
#endif

#define cudaErrorCheck(ans, cause) \
{ \
Expand All @@ -30,18 +34,6 @@
}

/// prints CUDA error messages. Always use cudaErrorCheck macro.
inline void cudaAssert(cudaError_t code, const std::string& cause, const char* filename, int line, bool abort = true)
{
if (code != cudaSuccess)
{
std::ostringstream err;
err << "cudaAssert: " << cudaGetErrorName(code) << " " << cudaGetErrorString(code) << ", file " << filename
<< ", line " << line << std::endl
<< cause << std::endl;
std::cerr << err.str();
if (abort)
throw std::runtime_error(cause);
}
}
void cudaAssert(cudaError_t code, const std::string& cause, const char* filename, int line, bool abort = true);

#endif
8 changes: 0 additions & 8 deletions src/Platforms/CUDA/CUDAruntime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
#define QMCPLUSPLUS_CUDA_RUNTIME_H

#include <cstddef>
#include "config.h"
#ifndef QMC_CUDA2HIP
#include <cuda_runtime.h>
#else
#include <hip/hip_runtime.h>
#include "Platforms/ROCm/cuda2hip.h"
#endif

#include "CUDAerror.h"

size_t getCUDAdeviceFreeMem();
Expand Down

0 comments on commit 9a66e02

Please sign in to comment.