From ec60fcf1fecfcfb5db243cf90b543c73c7a1e829 Mon Sep 17 00:00:00 2001 From: YangZhuo Date: Thu, 10 Jul 2025 15:07:17 +0800 Subject: [PATCH] =?UTF-8?q?build(gpu):=20=E6=B7=BB=E5=8A=A0CUDA=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=94=AF=E6=8C=81=E5=B9=B6=E6=89=A9=E5=B1=95=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 在GPU.cmake中添加了${CUDA_NVCC_FLAGS_CUSTOM}变量到CUDA编译命令 * 引入gpu-granular-debug.cmake构建预设配置 * 添加调试模式支持(-g -G -O0)和详细的编译器检测 * 为所有构建模式设置-allow-unsupported-compiler标志 --- cmake/Modules/Packages/GPU.cmake | 4 ++-- cmake/presets/gpu-granular-debug.cmake | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 cmake/presets/gpu-granular-debug.cmake diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake index dd4ac31025..b18efa16c0 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -158,10 +158,10 @@ if(GPU_API STREQUAL "CUDA") endif() cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS ${CUDA_REQUEST_PIC} - -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -allow-unsupported-compiler -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING} -DLAMMPS_${LAMMPS_SIZES}) + -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -allow-unsupported-compiler -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING} -DLAMMPS_${LAMMPS_SIZES} ${CUDA_NVCC_FLAGS_CUSTOM}) cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS ${CUDA_REQUEST_PIC} - -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -allow-unsupported-compiler -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING} -DLAMMPS_${LAMMPS_SIZES}) + -DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -allow-unsupported-compiler -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING} -DLAMMPS_${LAMMPS_SIZES} ${CUDA_NVCC_FLAGS_CUSTOM}) foreach(CU_OBJ ${GPU_GEN_OBJS}) get_filename_component(CU_NAME ${CU_OBJ} NAME_WE) diff --git a/cmake/presets/gpu-granular-debug.cmake b/cmake/presets/gpu-granular-debug.cmake new file mode 100644 index 0000000000..59d4f09f09 --- /dev/null +++ b/cmake/presets/gpu-granular-debug.cmake @@ -0,0 +1,16 @@ +# preset that enables GPU and selects CUDA API + +set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "" FORCE) +set(PKG_GPU ON CACHE BOOL "Build GPU package" FORCE) +set(PKG_GRANULAR ON CACHE BOOL "Build GRANULAR package" FORCE) +set(GPU_API "cuda" CACHE STRING "API used by GPU package" FORCE) +set(GPU_ARCH "sm_86" CACHE STRING "ARCH used by GPU package" FORCE) +set(GPU_PREC "double" CACHE STRING "prec used by gpu" FORCE) +set(GPU_DEBUG ON CACHE BOOL "" FORCE) + +set(CUDA_NVCC_FLAGS_CUSTOM "-allow-unsupported-compiler -g -G -O0" CACHE STRING "" FORCE) +set(CUDA_NVCC_FLAGS "-allow-unsupported-compiler" CACHE STRING "" FORCE) +set(CUDA_NVCC_FLAGS_DEBUG "-allow-unsupported-compiler" CACHE STRING "" FORCE) +set(CUDA_NVCC_FLAGS_MINSIZEREL "-allow-unsupported-compiler" CACHE STRING "" FORCE) +set(CUDA_NVCC_FLAGS_RELWITHDEBINFO "-allow-unsupported-compiler" CACHE STRING "" FORCE) +set(CUDA_NVCC_FLAGS_RELEASE "-allow-unsupported-compiler" CACHE STRING "" FORCE)