Skip to content

Commit

Permalink
Revert "Separate GPU library from CPU library"
Browse files Browse the repository at this point in the history
This reverts commit 58bdbc8.
  • Loading branch information
jngrad committed Apr 16, 2020
1 parent 9912ad5 commit 7025e65
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 31 deletions.
39 changes: 21 additions & 18 deletions cmake/FindCUDACompilerClang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,17 @@ if(CUDA_VERSION VERSION_LESS ${MINIMAL_CUDA_VERSION})
)
endif()

add_library(gpu_interface INTERFACE)
target_compile_options(gpu_interface INTERFACE
$<$<CONFIG:DEBUG>:-g>
$<$<CONFIG:RELEASE>:-O3;-DNDEBUG>
$<$<CONFIG:MINSIZEREL>:-O2;-DNDEBUG>
$<$<CONFIG:RELWITHDEBINFO>:-O2;-g;-DNDEBUG>
$<$<CONFIG:COVERAGE>:-O3;-g>
$<$<CONFIG:RELWITHASSERT>:-O3;-g>
"${CUDA_NVCC_FLAGS}"
--cuda-gpu-arch=sm_30
$<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,3.8.9>:--cuda-gpu-arch=sm_52>
)
set(CUDA_NVCC_FLAGS_DEBUG "${CUDA_NVCC_FLAGS_DEBUG} -g")
set(CUDA_NVCC_FLAGS_RELEASE "${CUDA_NVCC_FLAGS_RELEASE} -O3 -DNDEBUG")
set(CUDA_NVCC_FLAGS_MINSIZEREL "${CUDA_NVCC_FLAGS_MINSIZEREL} -O2 -DNDEBUG")
set(CUDA_NVCC_FLAGS_RELWITHDEBINFO "${CUDA_NVCC_FLAGS_RELWITHDEBINFO} -O2 -g -DNDEBUG")
set(CUDA_NVCC_FLAGS_COVERAGE "${CUDA_NVCC_FLAGS_COVERAGE} -O3 -g")
set(CUDA_NVCC_FLAGS_RELWITHASSERT "${CUDA_NVCC_FLAGS_RELWITHASSERT} -O3 -g")
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
set(gpu_interface_flags "${CUDA_NVCC_FLAGS} ${CUDA_NVCC_FLAGS_${CMAKE_BUILD_TYPE_UPPER}} --cuda-gpu-arch=sm_30")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.8.9)
set(gpu_interface_flags "${gpu_interface_flags} --cuda-gpu-arch=sm_52")
endif()

find_library(
CUDART_LIBRARY NAMES cudart PATHS ${CUDA_DIR}/lib64 ${CUDA_DIR}/lib
Expand All @@ -77,14 +76,18 @@ function(add_gpu_library)
set(oneValueArgs)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
list(GET ARG_UNPARSED_ARGUMENTS 0 GPU_TARGET_NAME)
list(GET ARG_UNPARSED_ARGUMENTS 0 TARGET_NAME)
list(REMOVE_AT ARG_UNPARSED_ARGUMENTS 0)
set(GPU_TARGET_SOURCES ${ARG_UNPARSED_ARGUMENTS})
set_source_files_properties(${GPU_TARGET_SOURCES} PROPERTIES LANGUAGE "CXX")
set(TARGET_SOURCES ${ARG_UNPARSED_ARGUMENTS})
set_source_files_properties(${TARGET_SOURCES} PROPERTIES LANGUAGE "CXX")
add_library(${ARGV})
set_target_properties(${GPU_TARGET_NAME} PROPERTIES LINKER_LANGUAGE "CXX")
target_link_libraries(${GPU_TARGET_NAME} PRIVATE ${CUDA_LIBRARY} ${CUDART_LIBRARY} ${CUFFT_LIBRARY})
target_link_libraries(${GPU_TARGET_NAME} PRIVATE gpu_interface)
set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE "CXX")
target_link_libraries(${TARGET_NAME} PRIVATE ${CUDA_LIBRARY} ${CUDART_LIBRARY} ${CUFFT_LIBRARY})
foreach(file ${TARGET_SOURCES})
if(${file} MATCHES "\\.cu$")
set_source_files_properties (${file} PROPERTY COMPILE_FLAGS ${gpu_interface_flags})
endif()
endforeach()
endfunction()

include(FindPackageHandleStandardArgs)
Expand Down
20 changes: 7 additions & 13 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,30 @@ set(EspressoCore_SRC
PartCfg.cpp)

if(CUDA)
list(APPEND EspressoCore_SRC cuda_init.cpp cuda_interface.cpp
grid_based_algorithms/electrokinetics.cpp
grid_based_algorithms/lbgpu.cpp)
set(EspressoCuda_SRC
actor/DipolarBarnesHut_cuda.cu
actor/DipolarDirectSum_cuda.cu
actor/Mmm1dgpuForce_cuda.cu
cuda_common_cuda.cu
cuda_init.cpp
cuda_init_cuda.cu
cuda_interface.cpp
CudaHostAllocator.cu
electrostatics_magnetostatics/p3m_gpu_cuda.cu
electrostatics_magnetostatics/p3m_gpu_error_cuda.cu
EspressoSystemInterface_cuda.cu
grid_based_algorithms/electrokinetics_cuda.cu
grid_based_algorithms/lbgpu_cuda.cu
grid_based_algorithms/fd-electrostatics_cuda.cu
grid_based_algorithms/electrokinetics.cpp
grid_based_algorithms/lbgpu.cpp
virtual_sites/lb_inertialess_tracers_cuda.cu)

add_gpu_library(EspressoCuda SHARED ${EspressoCuda_SRC})
install(TARGETS EspressoCuda LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd)
add_gpu_library(EspressoCore SHARED ${EspressoCore_SRC} ${EspressoCuda_SRC})
else(CUDA)
add_library(EspressoCore SHARED ${EspressoCore_SRC})
endif(CUDA)

add_library(EspressoCore SHARED ${EspressoCore_SRC})

install(TARGETS EspressoCore LIBRARY DESTINATION ${PYTHON_INSTDIR}/espressomd)

target_link_libraries(
Expand All @@ -90,12 +90,6 @@ target_include_directories(

target_compile_definitions(EspressoCore PUBLIC $<$<BOOL:${H5MD}>:H5XX_USE_MPI>)

if(CUDA)
target_link_libraries(EspressoCuda PRIVATE EspressoConfig shapes utils)
target_include_directories(EspressoCuda PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(EspressoCore PRIVATE EspressoCuda)
endif(CUDA)

add_subdirectory(accumulators)
add_subdirectory(actor)
add_subdirectory(bonded_interactions)
Expand Down

0 comments on commit 7025e65

Please sign in to comment.