From 9a66e02daed019463266ff04bd68b6341fb4cfa6 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Wed, 11 Sep 2024 14:25:32 -0500 Subject: [PATCH] Fix CUDA gcc 13 conflict. Similarily to https://github.com/QMCPACK/qmcpack/pull/4814 --- src/Platforms/CUDA/CMakeLists.txt | 2 +- src/Platforms/CUDA/CUDAerror.h | 28 ++++++++++------------------ src/Platforms/CUDA/CUDAruntime.hpp | 8 -------- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/Platforms/CUDA/CMakeLists.txt b/src/Platforms/CUDA/CMakeLists.txt index a37b0ecc9e0..489d8f3ec5b 100644 --- a/src/Platforms/CUDA/CMakeLists.txt +++ b/src/Platforms/CUDA/CMakeLists.txt @@ -9,7 +9,7 @@ #// File created by: Ye Luo, yeluo@anl.gov, 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}) diff --git a/src/Platforms/CUDA/CUDAerror.h b/src/Platforms/CUDA/CUDAerror.h index 2085ee8e72b..ede798d2ca8 100644 --- a/src/Platforms/CUDA/CUDAerror.h +++ b/src/Platforms/CUDA/CUDAerror.h @@ -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, yeluo@anl.gov, Argonne National Laboratory //// @@ -13,10 +13,14 @@ #ifndef QMCPLUSPLUS_CUDA_ERROR_H #define QMCPLUSPLUS_CUDA_ERROR_H -#include -#include -#include -#include +#include // 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 +#else +#include +#include "Platforms/ROCm/cuda2hip.h" +#endif #define cudaErrorCheck(ans, cause) \ { \ @@ -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 diff --git a/src/Platforms/CUDA/CUDAruntime.hpp b/src/Platforms/CUDA/CUDAruntime.hpp index b2a15025c8d..77c07b19a9b 100644 --- a/src/Platforms/CUDA/CUDAruntime.hpp +++ b/src/Platforms/CUDA/CUDAruntime.hpp @@ -17,14 +17,6 @@ #define QMCPLUSPLUS_CUDA_RUNTIME_H #include -#include "config.h" -#ifndef QMC_CUDA2HIP -#include -#else -#include -#include "Platforms/ROCm/cuda2hip.h" -#endif - #include "CUDAerror.h" size_t getCUDAdeviceFreeMem();