From 28379e145f5c8f06ff1f15cc6651136b64e169d4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 10 Apr 2020 12:16:24 -0400 Subject: [PATCH] set using C++11 w/o extensions globally. move KOKKOS only checks to KOKKOS.cmake --- cmake/CMakeLists.txt | 11 ++--------- cmake/Modules/Packages/KOKKOS.cmake | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index a7c3c07841..16e09af077 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -64,9 +64,10 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") set(CMAKE_TUNE_DEFAULT "-ffast-math -march=native") endif() -# we require C++11 +# we require C++11 without extensions set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) # GNU compiler specific features for testing if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") @@ -123,10 +124,6 @@ else() endif() add_executable(lammps ${ALL_SOURCES}) set_target_properties(lammps PROPERTIES OUTPUT_NAME ${LAMMPS_BINARY}) - if(Kokkos_ENABLE_CUDA) - # The Kokkos nvcc wrapper does not like -std=gnu++11 and wants -std=c++11 - set_target_properties(lammps PROPERTIES CXX_EXTENSIONS OFF) - endif() install(TARGETS lammps DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() @@ -261,10 +258,6 @@ if(BUILD_OMP) message(FATAL_ERROR "Cannot find the 'omp.h' header file required for full OpenMP support") endif() target_link_libraries(lammps PRIVATE OpenMP::OpenMP_CXX) -else() - if(Kokkos_ENABLE_OPENMP) - message(FATAL_ERROR "Must enable BUILD_OMP with Kokkos_ENABLE_OPENMP") - endif() endif() if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE) diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake index f224a565e4..9d9ef9f6cb 100644 --- a/cmake/Modules/Packages/KOKKOS.cmake +++ b/cmake/Modules/Packages/KOKKOS.cmake @@ -1,3 +1,15 @@ +######################################################################## +# consistency checks and Kokkos options/settings required by LAMMPS +if(Kokkos_ENABLE_CUDA) + set(Kokkos_ENABLE_CUDA_LAMBDA ON) +endif() +# Adding OpenMP compiler flags without the checks done for +# BUILD_OMP can result in compile failures. Enforce consistency. +if(Kokkos_ENABLE_OPENMP AND NOT BUILD_OMP) + message(FATAL_ERROR "Must enable BUILD_OMP with Kokkos_ENABLE_OPENMP") +endif() +######################################################################## + option(EXTERNAL_KOKKOS "Build against external kokkos library" OFF) option(DOWNLOAD_KOKKOS "Download the KOKKOS library instead of using the bundled one" OFF) if(DOWNLOAD_KOKKOS) @@ -31,10 +43,6 @@ elseif(EXTERNAL_KOKKOS) else() set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos) set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos) - # enforce using nvcc_wrapper as compiler wrapper - if(Kokkos_ENABLE_CUDA) - set(CMAKE_CXX_COMPILER ${LAMMPS_LIB_KOKKOS_SRC_DIR}/bin/nvcc_wrapper CACHE FILEPATH "Path to nvcc wrapper for Kokkos with CUDA" FORCE) - endif() add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR}) set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src