Skip to content

Commit

Permalink
Update files to incorporate build-issue patches
Browse files Browse the repository at this point in the history
  • Loading branch information
LSchwiebert committed Dec 4, 2024
2 parents c05956a + 713622a commit 94f35fe
Show file tree
Hide file tree
Showing 108 changed files with 615 additions and 605 deletions.
1 change: 0 additions & 1 deletion CMake/FileLists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ set(libHeaders
lib/AlphaNum.h
lib/BasicTypes.h
lib/BitLib.h
lib/Endian.h
lib/GeomLib.h
lib/Lambda.h
lib/NumLib.h
Expand Down
41 changes: 30 additions & 11 deletions CMake/GOMCCPUSetup.cmake
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
#EnsemblePreprocessor defines NVT = 1, GEMC = 2, GCMC = 3, NPT = 4
#NPT (Isothermal-Isobaric) Ensemble

set(NPT_flags "-DENSEMBLE=4")
set(NPT_name "GOMC_CPU_NPT")

#Grand Canonical Monte Carlo
set(GC_flags "-DENSEMBLE=3")
set(GC_name "GOMC_CPU_GCMC")
#NVT (Canonical) Ensemble
set(NVT_flags "-DENSEMBLE=1")
set(NVT_name "GOMC_CPU_NVT")

#Gibbs Ensemble Monte Carlo
set(GE_flags "-DENSEMBLE=2")
set(GE_name "GOMC_CPU_GEMC")

#NVT (Canonical) Ensemble
set(NVT_flags "-DENSEMBLE=1")
set(NVT_name "GOMC_CPU_NVT")
#Grand Canonical Monte Carlo
set(GC_flags "-DENSEMBLE=3")
set(GC_name "GOMC_CPU_GCMC")

#NPT (Isothermal-Isobaric) Ensemble
set(NPT_flags "-DENSEMBLE=4")
set(NPT_name "GOMC_CPU_NPT")

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED true)

if(ENSEMBLE_NVT)
add_executable(NVT ${sources} ${headers} ${libHeaders} ${libSources})
# Set compiler and linker flags for each compiler
target_compile_options(NVT
PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_COMP_FLAGS}>)
target_link_options(NVT
PUBLIC $<$<LINK_LANGUAGE:CXX>:${CMAKE_LINK_FLAGS}>)
set_target_properties(NVT PROPERTIES
OUTPUT_NAME ${NVT_name}
COMPILE_FLAGS "${NVT_flags}")
Expand All @@ -35,6 +40,11 @@ endif()

if(ENSEMBLE_GEMC)
add_executable(GEMC ${sources} ${headers} ${libHeaders} ${libSources})
# Set compiler and linker flags for each compiler
target_compile_options(GEMC
PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_COMP_FLAGS}>)
target_link_options(GEMC
PUBLIC $<$<LINK_LANGUAGE:CXX>:${CMAKE_LINK_FLAGS}>)
set_target_properties(GEMC PROPERTIES
OUTPUT_NAME ${GE_name}
COMPILE_FLAGS "${GE_flags}")
Expand All @@ -49,6 +59,11 @@ endif()

if(ENSEMBLE_GCMC)
add_executable(GCMC ${sources} ${headers} ${libHeaders} ${libSources})
# Set compiler and linker flags for each compiler
target_compile_options(GCMC
PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_COMP_FLAGS}>)
target_link_options(GCMC
PUBLIC $<$<LINK_LANGUAGE:CXX>:${CMAKE_LINK_FLAGS}>)
set_target_properties(GCMC PROPERTIES
OUTPUT_NAME ${GC_name}
COMPILE_FLAGS "${GC_flags}")
Expand All @@ -63,6 +78,11 @@ endif()

if(ENSEMBLE_NPT)
add_executable(NPT ${sources} ${headers} ${libHeaders} ${libSources})
# Set compiler and linker flags for each compiler
target_compile_options(NPT
PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_COMP_FLAGS}>)
target_link_options(NPT
PUBLIC $<$<LINK_LANGUAGE:CXX>:${CMAKE_LINK_FLAGS}>)
set_target_properties(NPT PROPERTIES
OUTPUT_NAME ${NPT_name}
COMPILE_FLAGS "${NPT_flags}")
Expand All @@ -74,4 +94,3 @@ if(ENSEMBLE_NPT)
target_link_libraries(NPT ${MPI_LIBRARIES})
endif()
endif()

268 changes: 150 additions & 118 deletions CMake/GOMCCUDASetup.cmake
Original file line number Diff line number Diff line change
@@ -1,118 +1,150 @@
# Find CUDA is enabled, set it up

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("-- Debug build type detected, passing : '-g -G --keep' to nvcc")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -g -G --keep")
endif()


set(GEN_COMP_flag "-DGOMC_CUDA -DTHRUST_IGNORE_DEPRECATED_CPP_DIALECT ")

if (GOMC_NVTX_ENABLED)
message("-- Enabling profiling with NVTX for GPU")
set(GEN_COMP_flag "${GEN_COMP_flag} -DGOMC_NVTX_ENABLED")
endif()


include_directories(src/GPU)

set(GPU_NPT_flags "-DENSEMBLE=4 ${GEN_COMP_flag}")
set(GPU_NPT_name "GOMC_GPU_NPT")
set(GPU_GC_flags "-DENSEMBLE=3 ${GEN_COMP_flag}")
set(GPU_GC_name "GOMC_GPU_GCMC")
set(GPU_GE_flags "-DENSEMBLE=2 ${GEN_COMP_flag}")
set(GPU_GE_name "GOMC_GPU_GEMC")
set(GPU_NVT_flags "-DENSEMBLE=1 ${GEN_COMP_flag}")
set(GPU_NVT_name "GOMC_GPU_NVT")

set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED true)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED true)

# Set host compiler
set(CCBIN "-ccbin=${CMAKE_CXX_COMPILER}")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} ${CCBIN} -Wno-deprecated-gpu-targets" )

include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})

#####################################
if(ENSEMBLE_GPU_NVT)
add_executable(GPU_NVT ${cudaSources} ${cudaHeaders}
${sources} ${headers} ${libHeaders} ${libSources})
set_target_properties(GPU_NVT PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
OUTPUT_NAME ${GPU_NVT_name}
CUDA_ARCHITECTURES "35;60;70;80"
COMPILE_FLAGS "${GPU_NVT_flags}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("-- Debug build type detected, GPU_NVT setting CUDA_RESOLVE_DEVICE_SYMBOLS ON")
set_property(TARGET GPU_NVT PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON)
endif()
if(WIN32)
target_link_libraries(GPU_NVT ws2_32)
endif()
if(MPI_FOUND)
target_link_libraries(GPU_NVT ${MPI_LIBRARIES})
endif()
endif()

if(ENSEMBLE_GPU_GEMC)
add_executable(GPU_GEMC ${cudaSources} ${cudaHeaders} ${sources}
${headers} ${libHeaders} ${libSources})
set_target_properties(GPU_GEMC PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
OUTPUT_NAME ${GPU_GE_name}
CUDA_ARCHITECTURES "35;60;70;80"
COMPILE_FLAGS "${GPU_GE_flags}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("-- Debug build type detected, GPU_GEMC setting CUDA_RESOLVE_DEVICE_SYMBOLS ON")
set_property(TARGET GPU_GEMC PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON)
endif()
if(WIN32)
target_link_libraries(GPU_GEMC ws2_32)
endif()
if(MPI_FOUND)
target_link_libraries(GPU_GEMC ${MPI_LIBRARIES})
endif()
endif()

if(ENSEMBLE_GPU_GCMC)
add_executable(GPU_GCMC ${cudaSources} ${cudaHeaders} ${sources}
${headers} ${libHeaders} ${libSources})
set_target_properties(GPU_GCMC PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
OUTPUT_NAME ${GPU_GC_name}
CUDA_ARCHITECTURES "35;60;70;80"
COMPILE_FLAGS "${GPU_GC_flags}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("-- Debug build type detected, GPU_GCMC setting CUDA_RESOLVE_DEVICE_SYMBOLS ON")
set_property(TARGET GPU_GCMC PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON)
endif()
if(WIN32)
target_link_libraries(GPU_GCMC ws2_32)
endif()
if(MPI_FOUND)
target_link_libraries(GPU_GCMC ${MPI_LIBRARIES})
endif()
endif()

if(ENSEMBLE_GPU_NPT)
add_executable(GPU_NPT ${cudaSources} ${cudaHeaders} ${sources}
${headers} ${libHeaders} ${libSources})
set_target_properties(GPU_NPT PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
OUTPUT_NAME ${GPU_NPT_name}
CUDA_ARCHITECTURES "35;60;70;80"
COMPILE_FLAGS "${GPU_NPT_flags}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("-- Debug build type detected, GPU_NPT setting CUDA_RESOLVE_DEVICE_SYMBOLS ON")
set_property(TARGET GPU_NPT PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON)
endif()
if(WIN32)
target_link_libraries(GPU_NPT ws2_32)
endif()
if(MPI_FOUND)
target_link_libraries(GPU_NPT ${MPI_LIBRARIES})
endif()
endif()
# Find CUDA is enabled, set it up
set(CMAKE_CUDA_COMP_FLAGS -DGOMC_CUDA -DTHRUST_IGNORE_DEPRECATED_CPP_DIALECT)
set(CMAKE_HOST_COMP_FLAGS ${CMAKE_COMP_FLAGS} -DGOMC_CUDA)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("-- Debug build type detected, passing '-g -G --keep' to nvcc")
set(CMAKE_CUDA_COMP_FLAGS ${CMAKE_CUDA_COMP_FLAGS} -g -G --keep)
set(CMAKE_CUDA_LINK_FLAGS -g -G --keep)
endif()

if(GOMC_NVTX_ENABLED)
message("-- Enabling profiling with NVTX for GPU")
set(CMAKE_CUDA_COMP_FLAGS ${CMAKE_CUDA_COMP_FLAGS} -DGOMC_NVTX_ENABLED)
endif()

# Set architecture flags based on the CMake version
# Once CMake 3.23 has been available for a while, we should just use
# set(CMAKE_CUDA_ARCHITECTURES all) and remove the if block
if (CMAKE_MAJOR_VERSION VERSION_GREATER 3 OR CMAKE_MINOR_VERSION VERSION_GREATER_EQUAL 23)
set(CMAKE_CUDA_ARCHITECTURES all)
else()
set(CMAKE_CUDA_ARCHITECTURES 60;70;75;80)
endif()

include_directories(src/GPU)

set(GPU_NVT_flags "-DENSEMBLE=1")
set(GPU_NVT_name "GOMC_GPU_NVT")
set(GPU_GE_flags "-DENSEMBLE=2")
set(GPU_GE_name "GOMC_GPU_GEMC")
set(GPU_GC_flags "-DENSEMBLE=3")
set(GPU_GC_name "GOMC_GPU_GCMC")
set(GPU_NPT_flags "-DENSEMBLE=4")
set(GPU_NPT_name "GOMC_GPU_NPT")

set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED true)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED true)

# Disable the warning on deprecated GPU targets
set(CMAKE_CUDA_COMP_FLAGS ${CMAKE_CUDA_COMP_FLAGS} -Wno-deprecated-gpu-targets)
set(CMAKE_CUDA_LINK_FLAGS ${CMAKE_CUDA_LINK_FLAGS} -Wno-deprecated-gpu-targets)

include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})

#####################################
if(ENSEMBLE_GPU_NVT)
add_executable(GPU_NVT ${cudaSources} ${cudaHeaders} ${sources}
${headers} ${libHeaders} ${libSources})
# Set compiler and linker flags for NVCC and the host compiler
target_compile_options(GPU_NVT
PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_HOST_COMP_FLAGS}>
$<$<COMPILE_LANGUAGE:CUDA>:${CMAKE_CUDA_COMP_FLAGS} ${CMAKE_GPU_COMP_FLAGS}>)
target_link_options(GPU_NVT
PUBLIC $<HOST_LINK:${CMAKE_LINK_FLAGS}>
$<DEVICE_LINK:${CMAKE_CUDA_LINK_FLAGS} ${CMAKE_GPU_COMP_FLAGS}>)
set_target_properties(GPU_NVT PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
OUTPUT_NAME ${GPU_NVT_name}
COMPILE_FLAGS "${GPU_NVT_flags}")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("-- Debug build type detected, GPU_NVT setting CUDA_RESOLVE_DEVICE_SYMBOLS ON")
set_property(TARGET GPU_NVT PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON)
endif()
if(WIN32)
target_link_libraries(GPU_NVT ws2_32)
endif()
if(MPI_FOUND)
target_link_libraries(GPU_NVT ${MPI_LIBRARIES})
endif()
endif()

if(ENSEMBLE_GPU_GEMC)
add_executable(GPU_GEMC ${cudaSources} ${cudaHeaders} ${sources}
${headers} ${libHeaders} ${libSources})
# Set compiler and linker flags for NVCC and the host compiler
target_compile_options(GPU_GEMC
PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_HOST_COMP_FLAGS}>
$<$<COMPILE_LANGUAGE:CUDA>:${CMAKE_CUDA_COMP_FLAGS} ${CMAKE_GPU_COMP_FLAGS}>)
target_link_options(GPU_GEMC
PUBLIC $<HOST_LINK:${CMAKE_LINK_FLAGS}>
$<DEVICE_LINK:${CMAKE_CUDA_LINK_FLAGS} ${CMAKE_GPU_COMP_FLAGS}>)
set_target_properties(GPU_GEMC PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
OUTPUT_NAME ${GPU_GE_name}
COMPILE_FLAGS "${GPU_GE_flags}")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("-- Debug build type detected, GPU_GEMC setting CUDA_RESOLVE_DEVICE_SYMBOLS ON")
set_property(TARGET GPU_GEMC PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON)
endif()
if(WIN32)
target_link_libraries(GPU_GEMC ws2_32)
endif()
if(MPI_FOUND)
target_link_libraries(GPU_GEMC ${MPI_LIBRARIES})
endif()
endif()

if(ENSEMBLE_GPU_GCMC)
add_executable(GPU_GCMC ${cudaSources} ${cudaHeaders} ${sources}
${headers} ${libHeaders} ${libSources})
# Set compiler and linker flags for NVCC and the host compiler
target_compile_options(GPU_GCMC
PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_HOST_COMP_FLAGS}>
$<$<COMPILE_LANGUAGE:CUDA>:${CMAKE_CUDA_COMP_FLAGS} ${CMAKE_GPU_COMP_FLAGS}>)
target_link_options(GPU_GCMC
PUBLIC $<HOST_LINK:${CMAKE_LINK_FLAGS}>
$<DEVICE_LINK:${CMAKE_CUDA_LINK_FLAGS} ${CMAKE_GPU_COMP_FLAGS}>)
set_target_properties(GPU_GCMC PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
OUTPUT_NAME ${GPU_GC_name}
COMPILE_FLAGS "${GPU_GC_flags}")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("-- Debug build type detected, GPU_GCMC setting CUDA_RESOLVE_DEVICE_SYMBOLS ON")
set_property(TARGET GPU_GCMC PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON)
endif()
if(WIN32)
target_link_libraries(GPU_GCMC ws2_32)
endif()
if(MPI_FOUND)
target_link_libraries(GPU_GCMC ${MPI_LIBRARIES})
endif()
endif()

if(ENSEMBLE_GPU_NPT)
add_executable(GPU_NPT ${cudaSources} ${cudaHeaders} ${sources}
${headers} ${libHeaders} ${libSources})
# Set compiler and linker flags for NVCC and the host compiler
target_compile_options(GPU_NPT
PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_HOST_COMP_FLAGS}>
$<$<COMPILE_LANGUAGE:CUDA>:${CMAKE_CUDA_COMP_FLAGS} ${CMAKE_GPU_COMP_FLAGS}>)
target_link_options(GPU_NPT
PUBLIC $<HOST_LINK:${CMAKE_LINK_FLAGS}>
$<DEVICE_LINK:${CMAKE_CUDA_LINK_FLAGS} ${CMAKE_GPU_COMP_FLAGS}>)
set_target_properties(GPU_NPT PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
OUTPUT_NAME ${GPU_NPT_name}
COMPILE_FLAGS "${GPU_NPT_flags}")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("-- Debug build type detected, GPU_NPT setting CUDA_RESOLVE_DEVICE_SYMBOLS ON")
set_property(TARGET GPU_NPT PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON)
endif()
if(WIN32)
target_link_libraries(GPU_NPT ws2_32)
endif()
if(MPI_FOUND)
target_link_libraries(GPU_NPT ${MPI_LIBRARIES})
endif()
endif()
Loading

0 comments on commit 94f35fe

Please sign in to comment.