Skip to content

Commit

Permalink
CMake: more changes to support CUDA.
Browse files Browse the repository at this point in the history
* Add architecture detection
* Split compiler flags over multiple files based on the compiler ID
* Start adding GPU tests.

WARNING: this commit still has a linking problem when CUDA is enabled.
  • Loading branch information
mic84 committed Jan 29, 2019
1 parent 17ff5f9 commit d611427
Show file tree
Hide file tree
Showing 15 changed files with 915 additions and 267 deletions.
20 changes: 7 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,18 @@ include( AMReX_Machines )
# For the time being we force the CUDA host compiler
# to be the C++ compiler.
#
if ( (CMAKE_CUDA_HOST_COMPILER) OR
NOT ("$ENV{CUDAHOSTCXX}" STREQUAL "") )
message(WARNING
"User-defined CUDA host compiler does not match C++ compiler: overwriting user setting.")
endif ()
unset(ENV{CUDAHOSTCXX})
set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
if (ENABLE_CUDA)
setup_cuda_host_compiler()

enable_language(CUDA)
setup_cuda_environment()
print(NVCC_ARCH_FLAGS)
print(CUDA_ARCH)
print(CUDA_HOME)
print(CMAKE_CUDA_COMPILER_VERSION)
print(CMAKE_CUDA_COMPILER_ID)
print(CMAKE_CUDA_HOST_COMPILER)

# For now we require C++ to be the same as
#find is deprecated for CUDA but currently
#it still provides some features not yet implemented
# natively. Remove this part when native support is complete
#find_package(CUDA 8.0 REQUIRED QUIET)
print(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES)
endif ()

#
Expand Down
16 changes: 4 additions & 12 deletions Src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
#
add_library( amrex "" )

#
# List of directories with CUDA kernels
#
set(CUDA_DIRS Base AmrCore Particles)

#
# Next, we implement a wrapper to add sources and headers
# to target object "amrex".
Expand Down Expand Up @@ -40,12 +35,11 @@ macro( add_sources )
target_include_directories( amrex PUBLIC $<BUILD_INTERFACE:${dir}> )
endif()

# If it's a cpp file located in CUDA_DIRS and ENABLE_CUDA is on
# then force cpp file to be compiled with CUDA compiler
if ( ENABLE_CUDA AND ( ${ext} STREQUAL ".cpp") AND ("${dirname}" IN_LIST CUDA_DIRS ) )
# If it's a cpp file and ENABLE_CUDA is on, then force cpp file
# to be compiled with CUDA compiler
if ( ENABLE_CUDA AND ( ${ext} STREQUAL ".cpp") )
set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/${item}
PROPERTIES LANGUAGE CUDA)
# set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/${item} PROPERTIES CUDA_SOURCE_PROPERTY_FORMAT OBJ) #LANGUAGE CUDA)
PROPERTIES LANGUAGE CUDA INCLUDE_DIRECTORIES "/sw/summit/cuda/9.2.148/" )
endif ()
endforeach ()
unset(ext)
Expand Down Expand Up @@ -166,8 +160,6 @@ write_basic_package_version_file ( ${CMAKE_BINARY_DIR}/AMReXConfigVersion.cmake
VERSION ${AMREX_VERSION}
COMPATIBILITY AnyNewerVersion )



install ( FILES
${CMAKE_BINARY_DIR}/export/AMReXConfig.cmake
${CMAKE_BINARY_DIR}/AMReXConfigVersion.cmake
Expand Down
172 changes: 0 additions & 172 deletions Tools/CMake/AMReX_Compilers.cmake

This file was deleted.

Loading

0 comments on commit d611427

Please sign in to comment.