From 18e94342df15ad3929bce36fefdac0af4816b4e4 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Wed, 2 May 2018 17:21:54 -0500 Subject: [PATCH 01/11] Clean up all the C related stuff. --- CMake/ClangCompilers.cmake | 21 +++--------------- CMake/GNUCompilers.cmake | 21 +++--------------- CMake/IBMCompilers.cmake | 8 ------- CMake/IntelCompilers.cmake | 37 ++++++------------------------- CMakeLists.txt | 45 ++++++++++---------------------------- src/CMakeLists.txt | 2 +- src/Drivers/CMakeLists.txt | 2 -- 7 files changed, 26 insertions(+), 110 deletions(-) diff --git a/CMake/ClangCompilers.cmake b/CMake/ClangCompilers.cmake index e23ad3ba3..97a299094 100644 --- a/CMake/ClangCompilers.cmake +++ b/CMake/ClangCompilers.cmake @@ -4,34 +4,26 @@ IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3 ) MESSAGE(FATAL_ERROR "Requires clang 3.3 or higher ") ENDIF() -# Set the std -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") - # Enable OpenMP IF(QMC_OMP) SET(ENABLE_OPENMP 1) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") ENDIF(QMC_OMP) # Set clang specfic flags (which we always want) ADD_DEFINITIONS( -Drestrict=__restrict__ ) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -fstrict-aliasing") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -fstrict-aliasing -D__forceinline=inline") SET( HAVE_POSIX_MEMALIGN 0 ) # Clang doesn't support -malign-double # Suppress compile warnings -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated -Wno-unused-value") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-unused-value") IF ( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.8 ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-var-template") ENDIF() # Set extra optimization specific flags -SET( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math" ) SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math" ) -SET( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ffast-math" ) SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-math" ) #-------------------------------------- @@ -40,17 +32,11 @@ SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-ma IF((NOT $ENV{CRAYPE_VERSION} MATCHES ".") AND (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")) #check if the user has already specified -march=XXXX option for cross-compiling. -if(CMAKE_CXX_FLAGS MATCHES "-march=" OR CMAKE_C_FLAGS MATCHES "-march=") - # make sure that the user specifies -march= for both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS. - if(CMAKE_CXX_FLAGS MATCHES "-march=" AND CMAKE_C_FLAGS MATCHES "-march=") - else() #(CMAKE_CXX_FLAGS MATCHES "-march=" AND CMAKE_C_FLAGS MATCHES "-march=") - MESSAGE(FATAL_ERROR "if -march=ARCH is specified by the user, it should be added in both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS!") - endif() #(CMAKE_CXX_FLAGS MATCHES "-march=" AND CMAKE_C_FLAGS MATCHES "-march=") -else() #(CMAKE_CXX_FLAGS MATCHES "-march=" OR CMAKE_C_FLAGS MATCHES "-march=") +if(CMAKE_CXX_FLAGS MATCHES "-march=") +else() #(CMAKE_CXX_FLAGS MATCHES "-march=") # use -march=native - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") -endif() #(CMAKE_CXX_FLAGS MATCHES "-march=" OR CMAKE_C_FLAGS MATCHES "-march=") +endif() #(CMAKE_CXX_FLAGS MATCHES "-march=") ENDIF((NOT $ENV{CRAYPE_VERSION} MATCHES ".") AND (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")) @@ -63,7 +49,6 @@ ENDIF(QMC_BUILD_STATIC) IF (ENABLE_GCOV) SET(GCOV_COVERAGE TRUE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") ENDIF(ENABLE_GCOV) diff --git a/CMake/GNUCompilers.cmake b/CMake/GNUCompilers.cmake index 8666bf366..e0fb172eb 100755 --- a/CMake/GNUCompilers.cmake +++ b/CMake/GNUCompilers.cmake @@ -3,30 +3,22 @@ IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8 ) MESSAGE(FATAL_ERROR "Requires gcc 4.8 or higher ") ENDIF() -# Set the std -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") - # Enable OpenMP IF(QMC_OMP) SET(ENABLE_OPENMP 1) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") ENDIF(QMC_OMP) # Set gnu specfic flags (which we always want) ADD_DEFINITIONS( -Drestrict=__restrict__ ) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -finline-limit=1000 -fstrict-aliasing -funroll-all-loops") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -finline-limit=1000 -fstrict-aliasing -funroll-all-loops -D__forceinline=inline") # Suppress compile warnings -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") # Set extra optimization specific flags -SET( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math" ) SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math" ) -SET( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ffast-math" ) SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-math" ) #-------------------------------------- @@ -35,17 +27,11 @@ SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-ma IF((NOT $ENV{CRAYPE_VERSION} MATCHES ".") AND (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")) #check if the user has already specified -march=XXXX option for cross-compiling. -if(CMAKE_CXX_FLAGS MATCHES "-march=" OR CMAKE_C_FLAGS MATCHES "-march=") - # make sure that the user specifies -march= for both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS. - if(CMAKE_CXX_FLAGS MATCHES "-march=" AND CMAKE_C_FLAGS MATCHES "-march=") - else() #(CMAKE_CXX_FLAGS MATCHES "-march=" AND CMAKE_C_FLAGS MATCHES "-march=") - MESSAGE(FATAL_ERROR "if -march=ARCH is specified by the user, it should be added in both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS!") - endif() #(CMAKE_CXX_FLAGS MATCHES "-march=" AND CMAKE_C_FLAGS MATCHES "-march=") -else() #(CMAKE_CXX_FLAGS MATCHES "-march=" OR CMAKE_C_FLAGS MATCHES "-march=") +if(CMAKE_CXX_FLAGS MATCHES "-march=") +else() #(CMAKE_CXX_FLAGS MATCHES "-march=") # use -march=native - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") -endif() #(CMAKE_CXX_FLAGS MATCHES "-march=" OR CMAKE_C_FLAGS MATCHES "-march=") +endif() #(CMAKE_CXX_FLAGS MATCHES "-march=") ENDIF((NOT $ENV{CRAYPE_VERSION} MATCHES ".") AND (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")) @@ -58,7 +44,6 @@ ENDIF(QMC_BUILD_STATIC) IF (ENABLE_GCOV) SET(GCOV_SUPPORTED TRUE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") ENDIF(ENABLE_GCOV) diff --git a/CMake/IBMCompilers.cmake b/CMake/IBMCompilers.cmake index 420c9ca04..ea966265d 100755 --- a/CMake/IBMCompilers.cmake +++ b/CMake/IBMCompilers.cmake @@ -4,10 +4,6 @@ MESSAGE(STATUS "Power8+ system using xlC/xlc/xlf") ADD_DEFINITIONS( -Drestrict=__restrict__ ) # Clean up flags - -IF(CMAKE_C_FLAGS MATCHES "-qhalt=e") - SET(CMAKE_C_FLAGS "") -ENDIF() IF(CMAKE_CXX_FLAGS MATCHES "-qhalt=e") SET(CMAKE_CXX_FLAGS "") ENDIF() @@ -15,17 +11,13 @@ ENDIF() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__forceinline=inline") # Suppress compile warnings -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated -Wno-unused-value") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-unused-value") # Set extra optimization specific flags -SET( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" ) SET( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" ) -SET( CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O3" ) SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3" ) # Set language standardards -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -qnoxlcompatmacros") IF(QMC_OMP) diff --git a/CMake/IntelCompilers.cmake b/CMake/IntelCompilers.cmake index 8f0e23d17..ef977dece 100755 --- a/CMake/IntelCompilers.cmake +++ b/CMake/IntelCompilers.cmake @@ -4,50 +4,37 @@ IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0 ) MESSAGE(FATAL_ERROR "Requires Intel 15.0 or higher ") ENDIF() -# Set the std -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") - # Enable OpenMP IF(QMC_OMP) SET(ENABLE_OPENMP 1) IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16 ) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -openmp") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -openmp") ELSE() - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qopenmp") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qopenmp") ENDIF() ENDIF(QMC_OMP) # Suppress compile warnings -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") # Set extra optimization specific flags -SET( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -restrict -unroll -ip" ) SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -restrict -unroll -ip" ) -SET( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -restrict -unroll -ip" ) SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -restrict -unroll -ip" ) -SET( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -restrict -unroll -ip" ) SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -restrict -unroll -ip" ) # Use deprecated options prior to 11.1 SET(ICC_DEPRECATED_OPTS FALSE) IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.1 ) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -prefetch ") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -prefetch" ) ELSEIF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16 ) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -opt-prefetch" ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -opt-prefetch" ) ELSE() -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qopt-prefetch" ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qopt-prefetch" ) ENDIF() #check if -ftz is accepted -CHECK_C_COMPILER_FLAG( "${CMAKE_CXX_FLAGS} -ftz" INTEL_FTZ ) +CHECK_CXX_COMPILER_FLAG( "${CMAKE_CXX_FLAGS} -ftz" INTEL_FTZ ) IF( INTEL_FTZ) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftz" ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftz" ) ENDIF( INTEL_FTZ) @@ -57,23 +44,13 @@ ENDIF( INTEL_FTZ) IF(NOT $ENV{CRAYPE_VERSION} MATCHES ".") #check if the user has already specified -x option for cross-compiling. -if(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_C_FLAGS MATCHES "-x" OR - CMAKE_CXX_FLAGS MATCHES "-ax" OR CMAKE_C_FLAGS MATCHES "-ax") - # make sure that the user specifies -x for both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS. - if(CMAKE_CXX_FLAGS MATCHES "-x" AND CMAKE_C_FLAGS MATCHES "-x") - else() #(CMAKE_CXX_FLAGS MATCHES "-x" AND CMAKE_C_FLAGS MATCHES "-x") - if(CMAKE_CXX_FLAGS MATCHES "-ax" AND CMAKE_C_FLAGS MATCHES "-ax") - else() - MESSAGE(FATAL_ERROR "if -xcode or -axcode is specified by the user, it should be added in both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS!") - endif() - endif() #(CMAKE_CXX_FLAGS MATCHES "-x" AND CMAKE_C_FLAGS MATCHES "-x") -else() #(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_C_FLAGS MATCHES "-x") +if(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_CXX_FLAGS MATCHES "-ax") +else() #(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_CXX_FLAGS MATCHES "-ax") #check if -xHost is accepted - CHECK_C_COMPILER_FLAG( "-xHost" INTEL_CC_FLAGS ) - IF(INTEL_CC_FLAGS) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xHost") + CHECK_CXX_COMPILER_FLAG( "-xHost" INTEL_CXX_FLAGS ) + IF(INTEL_CXX_FLAGS) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost") - ENDIF(INTEL_CC_FLAGS) -endif() #(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_C_FLAGS MATCHES "-x") + ENDIF(INTEL_CXX_FLAGS) +endif() #(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_CXX_FLAGS MATCHES "-ax") ENDIF(NOT $ENV{CRAYPE_VERSION} MATCHES ".") diff --git a/CMakeLists.txt b/CMakeLists.txt index 343c84bda..c38085b5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -PROJECT(qmcpack) +PROJECT(qmcpack CXX) ##################################################### @@ -108,20 +108,10 @@ SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH}) # add macros to compile einspline if necessary ###################################################################### INCLUDE(${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) -INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) -INCLUDE(${CMAKE_ROOT}/Modules/CheckTypeSize.cmake) CHECK_FUNCTION_EXISTS(sincos HAVE_SINCOS) CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN) -CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H) -CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H) -CHECK_INCLUDE_FILE(memory.h HAVE_MEMORY_H) -CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) -CHECK_INCLUDE_FILE(sys/time.h HAVE_SYS_TIME_H) -CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H) -CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) - ###################################################################### # Build options # QMC_BUILD_STATIC build static/dynamic libraries @@ -140,12 +130,6 @@ iF(MIXED_PRECISION AND BUILD_LMYENGINE_INTERFACE) ENDIF() SET(BUILD_AFQMC 0 CACHE BOOL "Build with AFQMC") SET(BUILD_FCIQMC 0 CACHE BOOL "Build with FCIQMC") -#SET(BUILD_QMCTOOLS 1 CACHE BOOL "Build tools for QMCPACK") -#SET(BUILD_SANDBOX 0 CACHE BOOL "Build snadbox for testing") -#SET(MPIP_PROFILE 0 CACHE BOOL "Build with mpip for mpi profile") -#SET(BUILD_QMCTOOLS 1) -#SET(BUILD_SANDBOX 0) -#SET(MPIP_PROFILE 0) SET(QMC_BUILD_STATIC 0 CACHE BOOL "Link to static libraries") SET(ENABLE_TIMERS 1 CACHE BOOL "Enable internal timers") @@ -221,7 +205,6 @@ ENDIF() #If the automatic detection does not work, comment out everything #upto COMPILER MANUAL SELECTION and use one of the customized cmake file. ###################################################### -INCLUDE(${CMAKE_ROOT}/Modules/CheckCCompilerFlag.cmake) INCLUDE(${CMAKE_ROOT}/Modules/CheckCXXCompilerFlag.cmake) @@ -273,8 +256,6 @@ ELSE(CMAKE_TOOLCHAIN_FILE) SET(BUILD_SHARED_LIBS off) SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) FOREACH(type SHARED_LIBRARY SHARED_MODULE EXE) - SET(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic") - SET(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-static") SET(CMAKE_${type}_LINK_STATIC_CXX_FLAGS "-Wl,-Bstatic") SET(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-static") ENDFOREACH(type) @@ -286,23 +267,23 @@ ELSE(CMAKE_TOOLCHAIN_FILE) #------------------------------------ # Identify the compiler #------------------------------------ - IF ( CMAKE_C_COMPILER_WORKS OR CMAKE_C_COMPILER_WORKS ) - IF( (CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR ( CMAKE_C_COMPILER_ID MATCHES "GNU") ) + IF ( CMAKE_CXX_COMPILER_WORKS ) + IF( CMAKE_CXX_COMPILER_ID MATCHES "GNU" ) SET( COMPILER GNU ) - ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "XL") OR ( CMAKE_C_COMPILER_ID MATCHES "XL") ) + ELSEIF( CMAKE_CXX_COMPILER_ID MATCHES "XL" ) SET( COMPILER IBM ) - ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "Intel") OR (CMAKE_C_COMPILER_ID MATCHES "Intel") ) + ELSEIF( CMAKE_CXX_COMPILER_ID MATCHES "Intel" ) SET( COMPILER Intel ) - ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "PGI") OR (CMAKE_C_COMPILER_ID MATCHES "PGI") ) + ELSEIF( CMAKE_CXX_COMPILER_ID MATCHES "PGI" ) SET( COMPILER PGI ) - ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "Cray") OR (CMAKE_C_COMPILER_ID MATCHES "Cray") ) + ELSEIF( CMAKE_CXX_COMPILER_ID MATCHES "Cray" ) SET( COMPILER Cray ) - ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_C_COMPILER_ID MATCHES "Clang") ) + ELSEIF( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) SET( COMPILER Clang ) ELSE() - SET(USING_DEFAULT TRUE) - MESSAGE("${CMAKE_C_COMPILER_ID}") - MESSAGE(WARNING "Unknown C/C++ compiler, default flags will be used") + SET(USING_DEFAULT TRUE) + MESSAGE("${CMAKE_CXX_COMPILER_ID}") + MESSAGE(WARNING "Unknown C++ compiler, default flags will be used") ENDIF() ELSE() MESSAGE(WARNING "No compiler identified") @@ -353,7 +334,7 @@ ELSE(CMAKE_TOOLCHAIN_FILE) SET(MPI_WARNING_LIST "Building MPI version without using MPI compiler wrappers.\n" "This may not build qmcpack correctly. To ensure the correct version, specify the compiler wrappers to cmake.\n" - "For example: cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpic++\n" + "For example: cmake -DCMAKE_CXX_COMPILER=mpic++\n" "To build without MPI, pass '-DQMC_MPI=0' to cmake") MESSAGE(WARNING ${MPI_WARNING_LIST}) @@ -384,7 +365,6 @@ ELSE(CMAKE_TOOLCHAIN_FILE) ENDIF(INTEL_COMPILER) IF ( HAVE_MKL ) # We found MKL, add the link library - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MKL_FLAGS}") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MKL_FLAGS}") SET(LAPACK_FOUND 1) SET(LAPACK_LIBRARIES "${MKL_LIBRARIES}") @@ -486,7 +466,6 @@ IF ( HAVE_MPI ) ENDIF(HAVE_MPI) MESSAGE(STATUS "CXX compiler flags: ${CMAKE_CXX_FLAGS}") -MESSAGE(STATUS "CC compiler flags: ${CMAKE_C_FLAGS}") SET(HAVE_OOMPI ${HAVE_MPI}) INCLUDE(${CMAKE_ROOT}/Modules/FindThreads.cmake) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0e4c1d96f..3743b6a5d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -184,7 +184,7 @@ ENDIF() if(QMC_BUILD_LEVEL GREATER 4) - MESSAGE(STATUS "Minimal build: only minapp drivers") + MESSAGE(STATUS "Minimal build: only miniapp drivers") SUBDIRS(Drivers) else() #{{{ diff --git a/src/Drivers/CMakeLists.txt b/src/Drivers/CMakeLists.txt index 8d82da9c1..b67d0c779 100644 --- a/src/Drivers/CMakeLists.txt +++ b/src/Drivers/CMakeLists.txt @@ -1,5 +1,3 @@ -PROJECT(drivers) - if(QMC_BUILD_LEVEL GREATER 4) # add apps XYZ.cpp, e.g., qmc_particles.cpp #SET(ESTEST einspline_smp einspline_spo qmc_particles moveonsphere twobody ptclset) From 4d02aec13830493f2355fb0a1a73c7dcef88894d Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Wed, 2 May 2018 17:49:28 -0500 Subject: [PATCH 02/11] Clean up CMakeLists.txt --- CMakeLists.txt | 228 ++++++------------------------------------------- 1 file changed, 28 insertions(+), 200 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c38085b5e..cf9b8dfa8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,6 @@ SET (EXECUTABLE_OUTPUT_PATH ${qmcpack_BINARY_DIR}/bin CACHE PATH "Single output # QMC_COMPLEX = true if using complex wavefunctions # QMC_MPI = enable MPI # QMC_OMP = enable OMP -# QMC_BITS = 32/64 bit ###################################################################### SET(OHMMS_DIM 3 CACHE INTEGER "Select physical dimension") SET(OHMMS_INDEXTYPE int) @@ -117,12 +116,8 @@ CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN) # QMC_BUILD_STATIC build static/dynamic libraries # BUILD_QMCTOOLS build utility programs # BUILD_SANDBOX build test programs -# BUILD_MINIAPPS build miniapps (Incomplete) -# MPIP_PROFILE profile mpi performance ###################################################################### -SET(QMC_ADIOS 0 CACHE BOOL "Build with ADIOS") SET(BUILD_UNIT_TESTS 1 CACHE BOOL "Build unit tests") -SET(BUILD_MINIAPPS 1 CACHE BOOL "Build miniapps") SET(BUILD_LMYENGINE_INTERFACE 1 CACHE BOOL "Build LMY engine") iF(MIXED_PRECISION AND BUILD_LMYENGINE_INTERFACE) MESSAGE(STATUS "LMY engine is not compatiable with CPU mixed precision build! Disabling LMY engine") @@ -147,9 +142,6 @@ SET(OHMMS_ORTHO 0) #FindXYZ.cmake will set the values if successful ###################################################################### #SET(ENABLE_PHDF5 0 CACHE BOOL "Enable phdf5 for output") -SET(HAVE_LIBXML2 1) -SET(HAVE_LIBFFTW 0) -SET(HAVE_LIBXMLPP 0) #SET(HAVE_LIBHDF5 0) SET(HAVE_LIBSPRNG 0) SET(HAVE_LIBBLITZ 0) @@ -164,27 +156,6 @@ set(TAU_HOME $ENV{TAU_HOME}) ###################################################### SET (PROJECT_CMAKE ${qmcpack_SOURCE_DIR}/CMake) -###################################################### -# set ADIOS flags -###################################################### -IF(QMC_ADIOS) - IF(NOT HAVE_ADIOS) - SET (ADIOS_FOUND 0) - INCLUDE(${PROJECT_CMAKE}/FindADIOS.cmake) - IF (${ADIOS_FOUND} EQUAL 1) - INCLUDE_DIRECTORIES(${ADIOS_INCLUDES}) - MESSAGE(STATUS "Found ADIOS") - LINK_LIBRARIES(${ADIOS_LIBRARIES}) - ADD_DEFINITIONS(-DHAVE_ADIOS) - ELSE() - MESSAGE(STATUS "Couldn't find required library ADIOS") - MESSAGE(FATAL_ERROR "ADIOS_HOME: export ADIOS_HOME=/path/to/adios") - ENDIF() - ELSE() - ADD_DEFINITIONS(-DHAVE_ADIOS) - ENDIF() -ENDIF(QMC_ADIOS) - SET(QMCPACK_UNIT_TEST_DIR ${qmcpack_BINARY_DIR}/tests/bin) ###################################################### @@ -305,6 +276,34 @@ ELSE(CMAKE_TOOLCHAIN_FILE) MESSAGE(WARNING "No default file for compiler (${COMPILER})") ENDIF() + # Check for the compiler C++11 flag, if we go to requiring >= cmake 3.1.3 we could drop this + # and just write + # set(CMAKE_CXX_STANDARD_REQUIRED 11 CACHE INTEGER "C++ stangard must be at least 11") + SET(CXX11_FLAG "-std=c++11") + #check if the CXX compiler supports -std=c++11 option + include(CheckCXXCompilerFlag) # works with clean load paths and non system compilers with CMP0056 + CHECK_CXX_COMPILER_FLAG(${CXX11_FLAG} CXX_COMPILER_SUPPORT_CXX11) + + # Force the flag on Cray with Intel compiler, because the Cray wrapper + # prints an warning that interferes with the flag detection code + # with older versions of CMake. + IF($ENV{CRAYPE_VERSION} MATCHES ".") + IF( ${COMPILER} MATCHES "Intel" AND NOT CXX_COMPILER_SUPPORT_CXX11) + SET(CXX_COMPILER_SUPPORT_CXX11 TRUE) + MESSAGE(STATUS "Forcing C++11 support on Cray with Intel") + ENDIF() + ENDIF() + + IF (CXX_COMPILER_SUPPORT_CXX11) + # avoid repeated -std=c++11 flag + STRING(REPLACE "++" "\\+\\+" CXX11_FLAG_MATCH ${CXX11_FLAG}) + IF(NOT CMAKE_CXX_FLAGS MATCHES ${CXX11_FLAG_MATCH}) + SET (CMAKE_CXX_FLAGS "${CXX11_FLAG} ${CMAKE_CXX_FLAGS}") + ENDIF() + ELSE() + MESSAGE(FATAL_ERROR "A compiler supporting C++11 is required. Use a newer C++ compiler.") + ENDIF() + #------------------------------------------------------------------- # check MPI installation #------------------------------------------------------------------- @@ -403,36 +402,6 @@ IF (ENABLE_GCOV) ENDIF() ENDIF(ENABLE_GCOV) -# Require C++11 while leaving possibility to fall back by modifying this file -SET(CXX11_NEEDED TRUE) -IF(CXX11_NEEDED) - SET(CXX11_FLAG "-std=c++11") - #check if the CXX compiler supports -std=c++11 option - include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG(${CXX11_FLAG} CXX_COMPILER_SUPPORT_CXX11) - # Turn on C++11 for this code - - # Force the flag on Cray with Intel compiler, because the Cray wrapper - # prints an warning that interferes with the flag detection code - # with older versions of CMake. - IF($ENV{CRAYPE_VERSION} MATCHES ".") - IF( ${COMPILER} MATCHES "Intel" AND NOT CXX_COMPILER_SUPPORT_CXX11) - SET(CXX_COMPILER_SUPPORT_CXX11 TRUE) - MESSAGE(STATUS "Forcing C++11 support on Cray with Intel") - ENDIF() - ENDIF() - - IF (CXX_COMPILER_SUPPORT_CXX11) - # avoid repeated -std=c++11 flag - STRING(REPLACE "++" "\\+\\+" CXX11_FLAG_MATCH ${CXX11_FLAG}) - IF(NOT CMAKE_CXX_FLAGS MATCHES ${CXX11_FLAG_MATCH}) - SET (CMAKE_CXX_FLAGS "${CXX11_FLAG} ${CMAKE_CXX_FLAGS}") - ENDIF() - ELSE() - MESSAGE(FATAL_ERROR "A compiler supporting C++11 is required. Use a newer C++ compiler.") - ENDIF() -ENDIF(CXX11_NEEDED) - # AFQMC requires MKL sparse for good performance (roughly a factor of 2x) IF (BUILD_AFQMC AND NOT MKL_FOUND) MESSAGE(WARNING "AFQMC - MKL not found, using simple sparse matrix routines. Link with MKL sparse libraries for better performance.") @@ -477,40 +446,10 @@ INCLUDE(${CMAKE_ROOT}/Modules/FindThreads.cmake) # list of libraries to be linked with the main applications using I/O SET(QMC_UTIL_LIBS ${LAPACK_LIBRARY} ${BLAS_LIBRARY}) - -#SET( FFTW_FOUND 0 ) -#IF ( HAVE_MKL ) -# IF ( HAVE_MKL_FFTW3 ) -# SET( FFTW_FOUND 1 ) -# ENDIF() -#ENDIF() -#IF ( NOT FFTW_FOUND ) -# find_package(FFTW) -#ENDIF() -#IF(FFTW_FOUND) -# SET(HAVE_LIBFFTW 1) -# INCLUDE_DIRECTORIES(${FFTW_INCLUDE_DIR}) -# SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${FFTW_LIBRARIES}) -# MESSAGE(STATUS "Found FFTW") -#ELSE(FFTW_FOUND) -## MESSAGE(STATUS "Disabling FFTW") -# MESSAGE(FATAL_ERROR "Could not find required library FFTW. Verify FFTW_HOME") -#ENDIF(FFTW_FOUND) - SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${FORTRAN_LIBRARIES}) #find_package(ZLIB) -#find_package(LibXml2) -#INCLUDE(CMake/FindLibxml2QMC.cmake) -#IF(LIBXML2_FOUND) -# INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) -# SET(HAVE_LIBXML2 1) -# SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${LIBXML2_LIBRARIES}) -#ELSE() -# MESSAGE(FATAL_ERROR "Could not find required library Libxml2") -#ENDIF(LIBXML2_FOUND) - #set(HDF5_USE_STATIC_LIBRARIES off) #if(QMC_BUILD_STATIC) # set(HDF5_USE_STATIC_LIBRARIES on) @@ -541,48 +480,6 @@ SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${FORTRAN_LIBRARIES}) #ENDIF(HDF5_FOUND) # -#INCLUDE(${PROJECT_CMAKE}/FindPkgConfig.cmake) -################################################################## -# TODO:use profile tools -################################################################## -#IF(MPIP_PROFILE) -# LINK_LIBRARIES("/usr/apps/tools/mpip/lib/cmpi/libmpiP.a") -# LINK_LIBRARIES("/usr/lib/libbfd.a") -# LINK_LIBRARIES("/usr/lib/libiberty.a") -#ENDIF(MPIP_PROFILE) -#if(ENABLE_TAU_PROFILE) -# INCLUDE(${PROJECT_CMAKE}/FindTau.cmake) -#endif(ENABLE_TAU_PROFILE) -# #add tau stuff -# IF(FOUND_TAU) -# ADD_DEFINITIONS( -# -DTAU_MPI -# -DTAU_MPI_THREADED -# -DTAU_MPIGREQUEST -# -DTAU_MPIDATAREP -# -DTAU_MPIERRHANDLER -# -DTAU_MPIATTRFUNCTION -# -DTAU_MPITYPEEX -# -DTAU_MPIADDERROR -# ) -# #build libtau -# subdirs(src/tau) -# LINK_LIBRARIES(tau) -# ENDIF(FOUND_TAU) -#IF(FOUND_TAU) -# INCLUDE_DIRECTORIES(${TAU_INCLUDE_DIR}) -# ADD_DEFINITIONS (-DPROFILING_ON -# -DTAU_STDCXXLIB -# -DTAU_DOT_H_LESS_HEADERS -# -DTAU_CALLPATH -# -DTAU_LARGEFILE64_SOURCE -# -DTAU_BFD -# ) -# if(ENABLE_OPENMP) -# ADD_DEFINITIONS(-DTAU_OPENMP) -# endif(ENABLE_OPENMP) -#ENDIF(FOUND_TAU) - ###################################################### # Add optional macros ###################################################### @@ -590,50 +487,6 @@ SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${FORTRAN_LIBRARIES}) #include qmcpack/src build/src INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src) -#IF(BUILD_LMYENGINE_INTERFACE) -# ADD_DEFINITIONS(-DHAVE_LMY_ENGINE) -# SET(FORMIC_BINARY_DIR ${qmcpack_BINARY_DIR}) -# SUBDIRS(src/formic/utils) -# SET(QMC_UTIL_LIBS formic_utils ${QMC_UTIL_LIBS}) -#ENDIF(BUILD_LMYENGINE_INTERFACE) - -#include(ExternalProject) -# set(einspline_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/einspline") -# set(einspline_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/einspline") -# set(einspline_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${einspline_INSTALL_DIR}) -#ExternalProject_Add( -# einspline -# SVN_REPOSITORY http://qmctools.googlecode.com/svn/ext-packages/einspline -# ) -# INSTALL_DIR ${einspline_INSTALL_DIR} -# CMAKE_ARGS ${einspline_CMAKE_ARGS} -# ) -# find_package(einspline REQUIRED) -# set(HAVE_EINSPLINE 1) -####################################################################### -## Manage GTK+ and GTKMM packages for GUI -## search headers and libraries -## 1) -lXYZ-${XYZ_VERSION} -## 2) -lXYZ -## example: -lgtk-${GTK_VERSION} | -lgtk -####################################################################### -#SET(GTK_VERSION 2.0) -#SET(PANGO_VERSION 1.0) -# -#SET(GTKMM_VERSION 2.4) -#SET(PANGOMM_VERSION 1.4) -#SET(SIGCPP_VERSION 2.0) -#IF(ENABLE_GTK_GUI) -# INCLUDE(${PROJECT_CMAKE}/FindGTK.cmake) -# #THIS SHOULD GO TO the directory where GUI is built -# IF(GTKMM_FOUND) -# INCLUDE_DIRECTORIES(${GTKMM_INCLUDE_DIR}) -# LINK_LIBRARIES(${GTKMM_LIBRARIES}) -# ENDIF(GTKMM_FOUND) -#ENDIF(ENABLE_GTK_GUI) - - - # To connect the timer regions with VTune sampling, some Task API calls # are present in the code. To enable them, set USE_VTUNE_TASKS and add the # include and lib paths to VTune. @@ -706,34 +559,9 @@ ENDIF() if(HAVE_MPI) ADD_DEFINITIONS(-DMPICH_SKIP_MPICXX) endif() -#ADD_DEFINITIONS(-DDISABLE_WS_CELL) EXECUTE_PROCESS(COMMAND hostname OUTPUT_VARIABLE QMC_HOSTNAME OUTPUT_STRIP_TRAILING_WHITESPACE) CONFIGURE_FILE(${qmcpack_SOURCE_DIR}/qmcpack.settings ${qmcpack_BINARY_DIR}/bin/qmcpack.settings) -######################### -# add definitions for adios profile -# add definitions for adios verification -######################## -IF(QMC_ADIOS) - #ADD_DEFINITIONS(-DIO_PROFILE) - #ADD_DEFINITIONS(-DADIOS_VERIFY) - ADD_DEFINITIONS(-DWRITE_GLOBAL) -ENDIF(QMC_ADIOS) - SUBDIRS(src) -IF(NOT(QMC_BUILD_LEVEL GREATER 4)) - SUBDIRS(tests) - SUBDIRS(examples) -ENDIF() - -#ADD_CUSTOM_TARGET(print_settings ALL -# ${CMAKE_COMMAND} -E echo "Print build settings" -# VERBATIM) -# -#add_custom_command(TARGET print_settings -# POST_BUILD -# COMMAND svn info ${qmcpack_SOURCE_DIR}) -# -#file(APPEND ${qmcpack_BINARY_DIR}/bin/qmcpack.settings ${print_settings}) From a7beda65879bae8bdde9b9d9a7109509ff362774 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Wed, 2 May 2018 17:57:45 -0500 Subject: [PATCH 03/11] Bring in the improved MKL detection from QMCPACK. --- CMake/FindFFTW.cmake | 29 ----------- CMake/FindLibxml2QMC.cmake | 57 -------------------- CMake/FindMKL.cmake | 103 ++++++++++++++++++++++++++----------- CMakeLists.txt | 17 +++--- 4 files changed, 83 insertions(+), 123 deletions(-) delete mode 100644 CMake/FindFFTW.cmake delete mode 100644 CMake/FindLibxml2QMC.cmake diff --git a/CMake/FindFFTW.cmake b/CMake/FindFFTW.cmake deleted file mode 100644 index ad972dd0b..000000000 --- a/CMake/FindFFTW.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# FFTW_INCLUDE_DIR = fftw3.h -# FFTW_LIBRARIES = libfftw3.a -# FFTW_FOUND = true if FFTW3 is found - -SET(Libfftw fftw3) -IF(QMC_BUILD_STATIC) - SET(Libfftw libfftw3.a) -ENDIF(QMC_BUILD_STATIC) - -IF(FFTW_INCLUDE_DIRS) - FIND_PATH(FFTW_INCLUDE_DIR fftw3.h ${FFTW_INCLUDE_DIRS}) - FIND_LIBRARY(FFTW_LIBRARIES ${Libfftw} ${FFTW_LIBRARY_DIRS}) -ELSE(FFTW_INCLUDE_DIRS) - FIND_PATH(FFTW_INCLUDE_DIR fftw3.h ${FFTW_HOME}/include $ENV{FFTW_HOME}/include) - FIND_LIBRARY(FFTW_LIBRARIES ${Libfftw} ${FFTW_HOME}/lib $ENV{FFTW_HOME}/lib) -ENDIF(FFTW_INCLUDE_DIRS) - -SET(FFTW_FOUND FALSE) -IF(FFTW_INCLUDE_DIR AND FFTW_LIBRARIES) - MESSAGE(STATUS "FFTW_INCLUDE_DIR=${FFTW_INCLUDE_DIR}") - MESSAGE(STATUS "FFTW_LIBRARIES=${FFTW_LIBRARIES}") - SET(FFTW_FOUND TRUE) -ENDIF() - -MARK_AS_ADVANCED( - FFTW_INCLUDE_DIR - FFTW_LIBRARIES - FFTW_FOUND -) diff --git a/CMake/FindLibxml2QMC.cmake b/CMake/FindLibxml2QMC.cmake deleted file mode 100644 index c28d878a5..000000000 --- a/CMake/FindLibxml2QMC.cmake +++ /dev/null @@ -1,57 +0,0 @@ -# -# Find libxml2 (http://www.xmlsoft.org) -# -# Prioritizes LIBXML2_HOME and QMC_BUILD_STATIC -# before calling standard cmake find_package(LibXml2) -# -# Define the following values: -# -# LibXml2_INCLUDE_DIR = where libxml/xpath.h can be found -# LibXml2_LIBRARIES = the library to link against libxml2 -# LibXml2_FOUND = set to 1 if libxml2 is found -# -# Environment variables: -# -# LIBXML2_HOME = directory containing lib/ and include/libxml2 -# - -SET(Libxml2 xml2) -IF(QMC_BUILD_STATIC) - SET(Libxml2 libxml2.a) -ENDIF(QMC_BUILD_STATIC) - -IF(Libxml2_INCLUDE_DIRS) - MESSAGE(STATUS "Trying libxml2 via Libxml2_INCLUDE_DIRS") - FIND_PATH(LIBXML2_INCLUDE_DIR libxml/xpath.h ${Libxml2_INCLUDE_DIRS} NO_DEFAULT_PATH) - FIND_LIBRARY(LIBXML2_LIBRARIES xml2 ${Libxml2_LIBRARY_DIRS} NO_DEFAULT_PATH) -ELSE(Libxml2_INCLUDE_DIRS) - MESSAGE(STATUS "Trying libxml2 via LIBXML2_HOME") - FIND_LIBRARY(LIBXML2_LIBRARIES ${Libxml2} PATHS $ENV{LIBXML2_HOME}/lib NO_DEFAULT_PATH) - FIND_PATH(LIBXML_INCLUDE_DIR libxml2/libxml/xpath.h PATHS ${LIBXML2_HOME}/include $ENV{LIBXML2_HOME}/include NO_DEFAULT_PATH) - if(LIBXML_INCLUDE_DIR) - set(LIBXML2_INCLUDE_DIR ${LIBXML_INCLUDE_DIR}/libxml2) - else(LIBXML_INCLUDE_DIR) - FIND_PATH(LIBXML2_INCLUDE_DIR libxml/xpath.h $ENV{LIBXML2_HOME}/include) - endif(LIBXML_INCLUDE_DIR) -ENDIF(Libxml2_INCLUDE_DIRS) - -SET(LIBXML2_FOUND FALSE) -IF(LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES) - MESSAGE(STATUS "LIBXML2_INCLUDE_DIR=${LIBXML2_INCLUDE_DIR}") - MESSAGE(STATUS "LIBXML2_LIBRARIES=${LIBXML2_LIBRARIES}") - SET(LIBXML2_FOUND TRUE) -ENDIF() - -IF(LIBXML2_FOUND) - MESSAGE(STATUS "Libxml2 found by FindLibxml2QMC") -ELSE(LIBXML2_FOUND) - MESSAGE(STATUS "Locating Libxml2 via FIND_PACKAGE") - FIND_PACKAGE(LibXml2) -ENDIF(LIBXML2_FOUND) - -MARK_AS_ADVANCED( - LIBXML2_INCLUDE_DIR - LIBXML2_LIBRARIES - LIBXML2_FOUND - ) - diff --git a/CMake/FindMKL.cmake b/CMake/FindMKL.cmake index 29b6674ea..dd08d2c05 100644 --- a/CMake/FindMKL.cmake +++ b/CMake/FindMKL.cmake @@ -2,42 +2,85 @@ # This needs a lot of work to make it robust INCLUDE( CheckCXXSourceCompiles ) +if ( NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel" ) + # Extremely Basic Support of common mkl module environment variables + # or -DMKLROOT/-DMKL_HOME instead of prefered -DMKL_ROOT + if (NOT MKL_ROOT) + find_path(MKL_ROOT "mkl.h" + HINTS ${MKLROOT} ${MKL_HOME} $ENV{MKLROOT} $ENV{MKL_ROOT} $ENV{MKL_HOME} + PATH_SUFFIXES include) + string(REPLACE "/include" "" MKL_ROOT ${MKL_ROOT}) + endif (NOT MKL_ROOT) + if (NOT MKL_ROOT) + message (FATAL_ERROR "ENABLE_MKL is TRUE and mkl not found. Set MKL_ROOT." ) + endif (NOT MKL_ROOT) + + # Finding and setting the MKL_LINK_DIRECTORIES + # the directory organization varies with platform and targets + # these suffixes are not exhaustive + set(MKL_FIND_LIB "libmkl_intel_lp64${CMAKE_SHARED_LIBRARY_SUFFIX}") + set(SUFFIXES lib lib/intel64) + find_path(MKL_LINK_DIRECTORIES name "${MKL_FIND_LIB}" HINTS ${MKL_ROOT} + PATH_SUFFIXES ${SUFFIXES}) + if (MKL_LINK_DIRECTORIES-NOTFOUND) + message(FATAL_ERROR "MKL_LINK_DIRECTORIES not set. ${MKL_FIND_LIB} " + "not found in MKL_ROOT/(${SUFFIXES})") + endif (MKL_LINK_DIRECTORIES-NOTFOUND) + message("MKL_LINK_DIRECTORIES: ${MKL_LINK_DIRECTORIES}") + + # Finding and setting the MKL_INCLUDE_DIRECTORIES + set(SUFFIXES include) + find_path(MKL_INCLUDE_DIRECTORIES name "mkl.h" HINTS ${MKL_ROOT} + PATH_SUFFIXES ${SUFFIXES}) + if (MKL_INCLUDE_DIRECTORIES-NOTFOUND) + message(FATAL_ERROR "MKL_INCLUDE_DIRECTORIES not set. \"mkl.h\" not found in MKL_ROOT/(${SUFFIXES})") + endif (MKL_INCLUDE_DIRECTORIES-NOTFOUND) + message("MKL_INCLUDE_DIRECTORIES: ${MKL_INCLUDE_DIRECTORIES}") + + set(MKL_LINKER_FLAGS "-L${MKL_LINK_DIRECTORIES} -Wl,-rpath,${MKL_LINK_DIRECTORIES}") + set(MKL_FLAGS "-I${MKL_INCLUDE_DIRECTORIES}") + set(MKL_LIBRARIES "-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl") +else ( NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel" ) + # this takes away build control for intel but is convenient + set(MKL_FLAGS "-mkl") + set(MKL_COMPILE_DEFINITIONS "-mkl") +endif (NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel" ) + # Check for mkl.h FILE( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl.cxx" - "#include \n #include \n int main() { return 0; }\n" ) + "#include \n #include \n int main() { return 0; }\n" ) try_compile(HAVE_MKL ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl.cxx - COMPILE_DEFINITIONS "-mkl" ) + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl.cxx + CMAKE_FLAGS ${MKL_FLAGS} + "-DINCLUDE_DIRECTORIES=${MKL_INCLUDE_DIRECTORIES} " + "-DLINK_DIRECTORIES=${MKL_LINK_DIRECTORIES}" + LINK_LIBRARIES "${MKL_LIBRARIES}" + COMPILE_DEFINITIONS "${MKL_COMPILE_DEFINITIONS}" + OUTPUT_VARIABLE MKL_OUT) + +if ( NOT HAVE_MKL ) + MESSAGE( "${MKL_OUT}" ) +endif ( NOT HAVE_MKL ) # Check for mkl_vml_functions.h FILE( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl_vml.cxx" - "#include \n #include \n int main() { return 0; }\n" ) + "#include \n #include \n int main() { return 0; }\n" ) try_compile(HAVE_MKL_VML ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl_vml.cxx - COMPILE_DEFINITIONS "-mkl" ) - -# Check for fftw3 -FILE( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl_fftw3.cxx" - "#include \n #include \n int main() { return 0; }\n" ) -try_compile(HAVE_MKL_FFTW3 ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl_fftw3.cxx - COMPILE_DEFINITIONS "-mkl" ) + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl_vml.cxx + CMAKE_FLAGS ${MKL_FLAGS} + "-DINCLUDE_DIRECTORIES=${MKL_INCLUDE_DIRECTORIES} " + "-DLINK_DIRECTORIES=${MKL_LINK_DIRECTORIES}" + COMPILE_DEFINITIONS "${MKL_COMPILE_DEFINITIONS}" + OUTPUT_VARIABLE MKL_OUT) IF ( HAVE_MKL ) - SET( MKL_FOUND 1 ) - SET( MKL_FLAGS -mkl ) - SET( MKL_LIBRARIES ) - SET( MKL_LINKER_FLAGS -mkl ) - IF ( HAVE_MKL_FFTW3 ) - FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/include/fftw3.h" "#include \n" ) - INCLUDE_DIRECTORIES( "${CMAKE_CURRENT_BINARY_DIR}/include" ) - ENDIF() - MESSAGE(STATUS "MKL found: HAVE_MKL=${HAVE_MKL}, HAVE_MKL_VML=${HAVE_MKL_VML}, HAVE_MKL_FFTW3=${HAVE_MKL_FFTW3}") -ELSE() - SET( MKL_FOUND 0 ) - SET( MKL_FLAGS ) - SET( MKL_LIBRARIES ) - SET( MKL_LINKER_FLAGS ) - MESSAGE(STATUS "MKL not found") -ENDIF() - + SET( MKL_FOUND 1 ) + SET( MKL_FLAGS ${MKL_FLAGS} ) + MESSAGE(STATUS "MKL found: HAVE_MKL=${HAVE_MKL}, HAVE_MKL_VML=${HAVE_MKL_VML}") +ELSE( HAVE_MKL ) + SET( MKL_FOUND 0 ) + SET( MKL_FLAGS ) + SET( MKL_LIBRARIES ) + SET( MKL_LINKER_FLAGS ) + MESSAGE("MKL not found") +ENDIF( HAVE_MKL ) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf9b8dfa8..a931642fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -358,10 +358,17 @@ ELSE(CMAKE_TOOLCHAIN_FILE) #------------------------------------------------------------------- # check lapack/blas #------------------------------------------------------------------- - # Quick search for MKL (this will need to be improved). Currently only for Intel compilers + # Quick search for MKL (this will need to be improved). + # This reproduces the old intel -mkl behavior or + # if ENABLE_MKL is set to 1 supports other compilers IF (INTEL_COMPILER) + SET(ENABLE_MKL TRUE CACHE BOOL "ENABLE MKL for Intel compilers") + ELSE (INTEL_COMPILER) + SET(ENABLE_MKL FALSE CACHE BOOL "ENABLE MKL for non-intel compilers (Experimental)") + ENDIF (INTEL_COMPILER) + IF (ENABLE_MKL) INCLUDE(CMake/FindMKL.cmake) - ENDIF(INTEL_COMPILER) + ENDIF(ENABLE_MKL) IF ( HAVE_MKL ) # We found MKL, add the link library SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MKL_FLAGS}") @@ -550,11 +557,7 @@ MESSAGE(STATUS "Ready to build qmcpack") # -DMPICH_SKIP_MPICXX : disable C++ binding of MPICH #################################################################### -ADD_DEFINITIONS(-DHAVE_CONFIG_H -DH5_USE_16_API -DUSE_REAL_STRUCT_FACTOR -DINLINE_ALL=inline) - -IF(CMAKE_COMPILER_IS_GNUCXX OR (${COMPILER} STREQUAL "Clang")) - ADD_DEFINITIONS(-DADD_) -ENDIF() +ADD_DEFINITIONS(-DHAVE_CONFIG_H -DH5_USE_16_API -DUSE_REAL_STRUCT_FACTOR -DINLINE_ALL=inline -DADD_) if(HAVE_MPI) ADD_DEFINITIONS(-DMPICH_SKIP_MPICXX) From 1a825df8bb6e13a14902f994cd9dda3d0fe4ae7e Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Wed, 2 May 2018 23:28:51 -0500 Subject: [PATCH 04/11] Update git info handling --- CMakeLists.txt | 6 ++--- src/CMakeLists.txt | 55 +++++++++++++++++++++++----------------------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a931642fb..bc41a9e6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,12 +164,10 @@ SET(QMCPACK_UNIT_TEST_DIR ${qmcpack_BINARY_DIR}/tests/bin) ###################################################### FIND_PACKAGE(Git) -SET(IS_GIT_PROJECT false) -IF (EXISTS "${PROJECT_SOURCE_DIR}/.git") - SET(IS_GIT_PROJECT true) +IF (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") + SET(IS_GIT_PROJECT 1) ENDIF() - ###################################################### #COMPILER choose one of the cmake files to customize the compiler options #If nothing is chosen, default settings by cmake will be used. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3743b6a5d..ecbbcbd22 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,7 +25,12 @@ SET(GITREV_BARE_TMP git-rev-tmp.h) SET(GITREV_FILE ${CMAKE_BINARY_DIR}/src/${GITREV_BARE_FILE}) SET(GITREV_TMP ${CMAKE_BINARY_DIR}/src/${GITREV_BARE_TMP}) -IF (GIT_FOUND AND IS_GIT_PROJECT) +# Always clean up git-rev-tmp.h file when cmake is run +EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E remove ${GITREV_TMP} +) + +IF (IS_GIT_PROJECT) # The following custom command picks up changes to the git revision information # every time the project is rebuilt. Even if the repositiory is updated (git pull) # without re-running cmake. It also appends '-dirty' to the commit hash if there are @@ -40,6 +45,25 @@ IF (GIT_FOUND AND IS_GIT_PROJECT) # Apparently custom commands need to be defined where the output is used. # If this in the main CMakeLists.txt it does not work. + # Sed flags were once an issue and some HPC have old sed's + set(SED_FLAG "-E") + EXECUTE_PROCESS(COMMAND "sed" ${SED_FLAG} "s/\"/\\\\\"/g" "<${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" + OUTPUT_QUIET + ERROR_VARIABLE SED_ERROR) + if ( SED_ERROR MATCHES ".*invalid.*" ) + set(SED_FLAG "-r") + EXECUTE_PROCESS(COMMAND "sed" ${SED_FLAG} "s/\"/\\\\\"/g" "<${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" + OUTPUT_QUIET ERROR_QUIET + ERROR_VARIABLE SED_ERROR) + if ( SED_ERROR MATCHES ".*invalid.*" ) + MESSAGE(WARNING "Your system supports neither the sed -E or -r flag, git revision information will not be included in output") + else ( SED_ERROR MATCHES ".*invalid.*" ) + MESSAGE("sed supports -r") + endif ( SED_ERROR MATCHES ".*invalid.*" ) + else ( SED_ERROR MATCHES ".*invalid.*" ) + MESSAGE("sed supports -E") + endif ( SED_ERROR MATCHES ".*invalid.*" ) + ADD_CUSTOM_COMMAND( OUTPUT ${GITREV_TMP} COMMAND ${CMAKE_COMMAND} -E echo_append "#define GIT_BRANCH_RAW " > ${GITREV_TMP} @@ -52,8 +76,9 @@ IF (GIT_FOUND AND IS_GIT_PROJECT) COMMAND ${GIT_EXECUTABLE} log -1 --format=%ad >> ${GITREV_TMP} COMMAND ${CMAKE_COMMAND} -E echo >> ${GITREV_TMP} COMMAND ${CMAKE_COMMAND} -E echo_append "#define GIT_COMMIT_SUBJECT_RAW \"" >> ${GITREV_TMP} - COMMAND ${GIT_EXECUTABLE} log -1 --format=%s | sed -E "s/\"/\\\\\"/g" | tr -d '\\n' >> ${GITREV_TMP} + COMMAND ${GIT_EXECUTABLE} log -1 --format=%s | sed ${SED_FLAG} "s/\"/\\\\\"/g" | tr -d '\\n' >> ${GITREV_TMP} COMMAND ${CMAKE_COMMAND} -E echo_append "\"" >> ${GITREV_TMP} + COMMAND ${CMAKE_COMMAND} -E echo >> ${GITREV_TMP} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GITREV_TMP} ${GITREV_FILE} COMMAND ${CMAKE_COMMAND} -E remove ${GITREV_TMP} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} @@ -100,21 +125,6 @@ ELSE() ENDIF() -#################################### -# create liboompi -#################################### -#IF(HAVE_OOMPI) -# CONFIGURE_FILE(${qmcpack_SOURCE_DIR}/src/oompi-config.h.cmake.in -# ${qmcpack_BINARY_DIR}/src/oompi-config.h) -# INCLUDE_DIRECTORIES(${qmcpack_SOURCE_DIR}/src/OOMPI) -# SUBDIRS(OOMPI) -# IF ( MPI_LIBRARY ) -# SET(MPI_LIBRARY oompi ${MPI_LIBRARY}) -# ELSE() -# SET(MPI_LIBRARY oompi ) -# ENDIF() -#ENDIF(HAVE_OOMPI) - #################################### # create libqmcutil #################################### @@ -162,17 +172,6 @@ ENDIF() Particle/DistanceTable.cpp ) - - # IF(QMC_BUILD_LEVEL GREATER 2) - # IF(NOT QMC_COMPLEX) - # SET(PARTICLE ${PARTICLE} Particle/Bead_ParticleSet.cpp ) - # ENDIF(NOT QMC_COMPLEX) - # ENDIF(QMC_BUILD_LEVEL GREATER 2) - - #SET(PARTICLEIO - # ParticleIO/ParticleIOUtility.cpp - # ) - ADD_LIBRARY(qmcbase ${PARTICLE} ${PARTICLEIO}) #IF(QMC_BUILD_STATIC) From 3314b58999cd349ec56b6dd802d4876d5ebc0139 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Thu, 3 May 2018 13:36:46 -0500 Subject: [PATCH 05/11] Raise minimal CMake version to 3.4.0 --- CMakeLists.txt | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc41a9e6d..84ef87767 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(qmcpack CXX) ##################################################### -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10) +CMAKE_MINIMUM_REQUIRED(VERSION 3.4.0) IF(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) ENDIF(COMMAND cmake_policy) @@ -274,32 +274,13 @@ ELSE(CMAKE_TOOLCHAIN_FILE) MESSAGE(WARNING "No default file for compiler (${COMPILER})") ENDIF() - # Check for the compiler C++11 flag, if we go to requiring >= cmake 3.1.3 we could drop this - # and just write - # set(CMAKE_CXX_STANDARD_REQUIRED 11 CACHE INTEGER "C++ stangard must be at least 11") + # requires C++11 standard + set(CMAKE_CXX_STANDARD_REQUIRED 11 CACHE INTEGER "C++ stangard must be at least 11") SET(CXX11_FLAG "-std=c++11") - #check if the CXX compiler supports -std=c++11 option - include(CheckCXXCompilerFlag) # works with clean load paths and non system compilers with CMP0056 - CHECK_CXX_COMPILER_FLAG(${CXX11_FLAG} CXX_COMPILER_SUPPORT_CXX11) - - # Force the flag on Cray with Intel compiler, because the Cray wrapper - # prints an warning that interferes with the flag detection code - # with older versions of CMake. - IF($ENV{CRAYPE_VERSION} MATCHES ".") - IF( ${COMPILER} MATCHES "Intel" AND NOT CXX_COMPILER_SUPPORT_CXX11) - SET(CXX_COMPILER_SUPPORT_CXX11 TRUE) - MESSAGE(STATUS "Forcing C++11 support on Cray with Intel") - ENDIF() - ENDIF() - - IF (CXX_COMPILER_SUPPORT_CXX11) - # avoid repeated -std=c++11 flag - STRING(REPLACE "++" "\\+\\+" CXX11_FLAG_MATCH ${CXX11_FLAG}) - IF(NOT CMAKE_CXX_FLAGS MATCHES ${CXX11_FLAG_MATCH}) - SET (CMAKE_CXX_FLAGS "${CXX11_FLAG} ${CMAKE_CXX_FLAGS}") - ENDIF() - ELSE() - MESSAGE(FATAL_ERROR "A compiler supporting C++11 is required. Use a newer C++ compiler.") + # avoid repeated -std=c++11 flag + STRING(REPLACE "++" "\\+\\+" CXX11_FLAG_MATCH ${CXX11_FLAG}) + IF(NOT CMAKE_CXX_FLAGS MATCHES ${CXX11_FLAG_MATCH}) + SET (CMAKE_CXX_FLAGS "${CXX11_FLAG} ${CMAKE_CXX_FLAGS}") ENDIF() #------------------------------------------------------------------- From a94c19c547642f5b4435db82fd9fc9b4930f6faa Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Thu, 3 May 2018 13:37:13 -0500 Subject: [PATCH 06/11] No need to use -std=gnu++11. --- CMake/IBMCompilers.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/IBMCompilers.cmake b/CMake/IBMCompilers.cmake index ea966265d..d5534a781 100755 --- a/CMake/IBMCompilers.cmake +++ b/CMake/IBMCompilers.cmake @@ -18,7 +18,7 @@ SET( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" ) SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3" ) # Set language standardards -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -qnoxlcompatmacros") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qnoxlcompatmacros") IF(QMC_OMP) SET(ENABLE_OPENMP 1) From 0112366704cb4010e4cf0b54413137bd2f7d51f2 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Thu, 3 May 2018 13:45:28 -0500 Subject: [PATCH 07/11] Update CI script. --- testing/miniqmc_openshift_rhea.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/testing/miniqmc_openshift_rhea.sh b/testing/miniqmc_openshift_rhea.sh index 2d3008378..f66d5c7b0 100755 --- a/testing/miniqmc_openshift_rhea.sh +++ b/testing/miniqmc_openshift_rhea.sh @@ -18,6 +18,7 @@ source /sw/rhea/environment-modules/3.2.10/rhel6.7_gnu4.4.7/init/bash module unload PE-intel module load PE-gnu/5.3.0-1.10.2 module load git +module load cmake/3.6.1 env @@ -31,7 +32,7 @@ echo "" cd build -cmake -DCMAKE_C_COMPILER="mpicc" -DCMAKE_CXX_COMPILER="mpicxx" -DCMAKE_CXX_FLAGS="-std=c++11" -DBLAS_blas_LIBRARY="/usr/lib64/libblas.so.3" -DLAPACK_lapack_LIBRARY="/usr/lib64/atlas/liblapack.so.3" .. +cmake -DCMAKE_CXX_COMPILER="mpicxx" -DBLAS_blas_LIBRARY="/usr/lib64/libblas.so.3" -DLAPACK_lapack_LIBRARY="/usr/lib64/atlas/liblapack.so.3" .. make @@ -81,7 +82,7 @@ rm -rf ./build mkdir -p build cd build -cmake -D QMC_MIXED_PRECISION=1 -DCMAKE_C_COMPILER="mpicc" -DCMAKE_CXX_COMPILER="mpicxx" -DCMAKE_CXX_FLAGS="-std=c++11" -DBLAS_blas_LIBRARY="/usr/lib64/libblas.so.3" -DLAPACK_lapack_LIBRARY="/usr/lib64/atlas/liblapack.so.3" .. +cmake -DQMC_MIXED_PRECISION=1 -DCMAKE_CXX_COMPILER="mpicxx" -DBLAS_blas_LIBRARY="/usr/lib64/libblas.so.3" -DLAPACK_lapack_LIBRARY="/usr/lib64/atlas/liblapack.so.3" .. make From bcdc01ccf2263e9e3b2502de77ac00c736506282 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Thu, 3 May 2018 14:07:55 -0500 Subject: [PATCH 08/11] Minor change. --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84ef87767..2eebb9689 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,7 +275,8 @@ ELSE(CMAKE_TOOLCHAIN_FILE) ENDIF() # requires C++11 standard - set(CMAKE_CXX_STANDARD_REQUIRED 11 CACHE INTEGER "C++ stangard must be at least 11") + SET(CMAKE_CXX_STANDARD 11) + SET(CMAKE_CXX_STANDARD_REQUIRED ON) SET(CXX11_FLAG "-std=c++11") # avoid repeated -std=c++11 flag STRING(REPLACE "++" "\\+\\+" CXX11_FLAG_MATCH ${CXX11_FLAG}) From 4347f4c7b03cbbed1c815a749bc1c7f4c4724422 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Thu, 3 May 2018 15:15:39 -0500 Subject: [PATCH 09/11] Format source. --- src/Numerics/OhmmsPETE/OhmmsMatrix.h | 17 ++++++++++------- src/Numerics/OhmmsPETE/OhmmsVector.h | 10 ++++++---- src/QMCWaveFunctions/Jastrow/BsplineFunctor.h | 19 ++++++++++--------- src/QMCWaveFunctions/Jastrow/OneBodyJastrow.h | 4 ++-- .../Jastrow/OneBodyJastrowRef.h | 4 ++-- .../Jastrow/PolynomialFunctor3D.h | 18 +++++++++--------- .../Jastrow/ThreeBodyJastrow.h | 6 +++--- .../Jastrow/ThreeBodyJastrowRef.h | 6 +++--- src/QMCWaveFunctions/Jastrow/TwoBodyJastrow.h | 8 ++++---- .../Jastrow/TwoBodyJastrowRef.h | 2 +- 10 files changed, 50 insertions(+), 44 deletions(-) diff --git a/src/Numerics/OhmmsPETE/OhmmsMatrix.h b/src/Numerics/OhmmsPETE/OhmmsMatrix.h index 0990c02f3..a104c4383 100644 --- a/src/Numerics/OhmmsPETE/OhmmsMatrix.h +++ b/src/Numerics/OhmmsPETE/OhmmsMatrix.h @@ -178,7 +178,7 @@ template > class Matrix { for (int col = 0; col < D2; col++) { - Type_t tmp = (*this)(r1, col); + Type_t tmp = (*this)(r1, col); (*this)(r1, col) = (*this)(r2, col); (*this)(r2, col) = tmp; } @@ -188,7 +188,7 @@ template > class Matrix { for (int row = 0; row < D1; row++) { - Type_t tmp = (*this)(row, c1); + Type_t tmp = (*this)(row, c1); (*this)(row, c1) = (*this)(row, c2); (*this)(row, c2) = tmp; } @@ -202,13 +202,15 @@ template > class Matrix template inline void replaceColumn(IT first, size_type j) { typename Container_t::iterator ii(X.begin() + j); - for (int i = 0; i < D1; i++, ii += D2) *ii = *first++; + for (int i = 0; i < D1; i++, ii += D2) + *ii = *first++; } template inline void add2Column(IT first, size_type j) { typename Container_t::iterator ii(X.begin() + j); - for (int i = 0; i < D1; i++, ii += D2) *ii += *first++; + for (int i = 0; i < D1; i++, ii += D2) + *ii += *first++; } /** @@ -299,7 +301,8 @@ std::ostream &operator<<(std::ostream &out, const Matrix &rhs) size_type ii = 0; for (size_type i = 0; i < rhs.rows(); i++) { - for (size_type j = 0; j < rhs.cols(); j++) out << rhs(ii++) << " "; + for (size_type j = 0; j < rhs.cols(); j++) + out << rhs(ii++) << " "; out << std::endl; } return out; @@ -423,7 +426,7 @@ inline void evaluate(Matrix &lhs, const Op &op, abort(); } } -} +} // namespace qmcplusplus -#include "Numerics/OhmmsPETE/OhmmsMatrixOperators.h" +#include "Numerics/OhmmsPETE/OhmmsMatrixOperators.h" #endif // OHMMS_PETE_MATRIX_H diff --git a/src/Numerics/OhmmsPETE/OhmmsVector.h b/src/Numerics/OhmmsPETE/OhmmsVector.h index 344c3476b..1b397eb9f 100644 --- a/src/Numerics/OhmmsPETE/OhmmsVector.h +++ b/src/Numerics/OhmmsPETE/OhmmsVector.h @@ -158,7 +158,7 @@ template > class Vector } }; -} // end-of qmcplusplus +} // namespace qmcplusplus #include "Numerics/OhmmsPETE/OhmmsVectorOperators.h" @@ -257,7 +257,8 @@ inline void evaluate(Vector &lhs, const Op &op, template std::ostream &operator<<(std::ostream &out, const Vector &rhs) { - for (int i = 0; i < rhs.size(); i++) out << rhs[i] << std::endl; + for (int i = 0; i < rhs.size(); i++) + out << rhs[i] << std::endl; return out; } @@ -265,9 +266,10 @@ template std::istream &operator>>(std::istream &is, Vector &rhs) { // printTinyVector >::print(out,rhs); - for (int i = 0; i < rhs.size(); i++) is >> rhs[i]; + for (int i = 0; i < rhs.size(); i++) + is >> rhs[i]; return is; } -} +} // namespace qmcplusplus #endif // OHMMS_PARTICLEATTRIB_PEPE_H diff --git a/src/QMCWaveFunctions/Jastrow/BsplineFunctor.h b/src/QMCWaveFunctions/Jastrow/BsplineFunctor.h index 799b64f61..64227b007 100644 --- a/src/QMCWaveFunctions/Jastrow/BsplineFunctor.h +++ b/src/QMCWaveFunctions/Jastrow/BsplineFunctor.h @@ -122,10 +122,11 @@ template struct BsplineFunctor : public OptimizableFunctorBase void setupParameters(int n, real_type rcut, real_type cusp, std::vector ¶ms) { - CuspValue = cusp; + CuspValue = cusp; cutoff_radius = rcut; resize(n); - for (int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) + { Parameters[i] = params[i]; } reset(); @@ -251,7 +252,7 @@ template struct BsplineFunctor : public OptimizableFunctorBase int imin = std::max(i, 1); int imax = std::min(i + 4, NumParams + 1); - for (int n = imin; n < imax; ++n) + for (int n = imin; n < imax; ++n) derivs[n - 1] = SplineDerivs[n]; derivs[1] += SplineDerivs[0]; @@ -270,15 +271,15 @@ inline T BsplineFunctor::evaluateV(const int iStart, const int iEnd, int iCount = 0; const int iLimit = iEnd - iStart; - #pragma vector always +#pragma vector always for (int jat = 0; jat < iLimit; jat++) { - real_type r = distArray[jat]; + real_type r = distArray[jat]; if (r < cutoff_radius) distArrayCompressed[iCount++] = distArray[jat]; } real_type d = 0.0; - #pragma omp simd reduction(+:d) +#pragma omp simd reduction(+ : d) for (int jat = 0; jat < iCount; jat++) { real_type r = distArrayCompressed[jat]; @@ -323,7 +324,7 @@ inline void BsplineFunctor::evaluateVGL( real_type *gradArray = _gradArray + iStart; real_type *laplArray = _laplArray + iStart; - #pragma vector always +#pragma vector always for (int jat = 0; jat < iLimit; jat++) { real_type r = distArray[jat]; @@ -335,7 +336,7 @@ inline void BsplineFunctor::evaluateVGL( } } - #pragma omp simd +#pragma omp simd for (int j = 0; j < iCount; j++) { @@ -374,5 +375,5 @@ inline void BsplineFunctor::evaluateVGL( // clang-format on } } -} +} // namespace qmcplusplus #endif diff --git a/src/QMCWaveFunctions/Jastrow/OneBodyJastrow.h b/src/QMCWaveFunctions/Jastrow/OneBodyJastrow.h index 3fad77007..f84effecb 100644 --- a/src/QMCWaveFunctions/Jastrow/OneBodyJastrow.h +++ b/src/QMCWaveFunctions/Jastrow/OneBodyJastrow.h @@ -256,7 +256,7 @@ template struct OneBodyJastrow : public WaveFunctionComponentBase computeU3(P, iat, P.DistTables[myTableID]->Temp_r.data()); curLap = accumulateGL(dU.data(), d2U.data(), P.DistTables[myTableID]->Temp_dr, curGrad); - curAt = simd::accumulate_n(U.data(), Nions, valT()); + curAt = simd::accumulate_n(U.data(), Nions, valT()); grad_iat += curGrad; return std::exp(Vat[iat] - curAt); } @@ -278,5 +278,5 @@ template struct OneBodyJastrow : public WaveFunctionComponentBase Lap[iat] = curLap; } }; -} +} // namespace qmcplusplus #endif diff --git a/src/QMCWaveFunctions/Jastrow/OneBodyJastrowRef.h b/src/QMCWaveFunctions/Jastrow/OneBodyJastrowRef.h index 09f21eb59..f0177d5a1 100644 --- a/src/QMCWaveFunctions/Jastrow/OneBodyJastrowRef.h +++ b/src/QMCWaveFunctions/Jastrow/OneBodyJastrowRef.h @@ -253,7 +253,7 @@ template struct OneBodyJastrowRef : public WaveFunctionComponentBase computeU3(P, iat, P.DistTables[myTableID]->Temp_r.data()); curLap = accumulateGL(dU.data(), d2U.data(), P.DistTables[myTableID]->Temp_dr, curGrad); - curAt = std::accumulate(U.begin(), U.begin() + Nions, valT()); + curAt = std::accumulate(U.begin(), U.begin() + Nions, valT()); grad_iat += curGrad; return std::exp(Vat[iat] - curAt); } @@ -275,5 +275,5 @@ template struct OneBodyJastrowRef : public WaveFunctionComponentBase Lap[iat] = curLap; } }; // class OneBodyJastrowRef -} // miniqmcreferencce +} // namespace miniqmcreference #endif diff --git a/src/QMCWaveFunctions/Jastrow/PolynomialFunctor3D.h b/src/QMCWaveFunctions/Jastrow/PolynomialFunctor3D.h index 2427182a2..933e4d597 100644 --- a/src/QMCWaveFunctions/Jastrow/PolynomialFunctor3D.h +++ b/src/QMCWaveFunctions/Jastrow/PolynomialFunctor3D.h @@ -145,9 +145,9 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase GammaPerm.resize(NumGamma); IndepVar.resize(NumGamma, false); // Set identity permutation - for (int i = 0; i < NumGamma; i++) + for (int i = 0; i < NumGamma; i++) GammaPerm[i] = i; - int col = -1; + int col = -1; for (int row = 0; row < NumConstraints; row++) { int max_loc; @@ -173,7 +173,7 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase // manually swap the rows for (int ind_col = 0; ind_col < ConstraintMatrix.size2(); ind_col++) { - real_type temp = ConstraintMatrix(row, ind_col); + real_type temp = ConstraintMatrix(row, ind_col); ConstraintMatrix(row, ind_col) = ConstraintMatrix(max_loc, ind_col); ConstraintMatrix(max_loc, ind_col) = temp; } @@ -194,7 +194,7 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase } } } - for (int c = col + 1; c < NumGamma; c++) + for (int c = col + 1; c < NumGamma; c++) IndepVar[c] = true; } @@ -210,7 +210,7 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase std::fill(GammaVec.begin(), GammaVec.end(), 0.0); // First, set all independent variables int var = 0; - for (int i = 0; i < NumGamma; i++) + for (int i = 0; i < NumGamma; i++) if (IndepVar[i]) GammaVec[i] = scale * Parameters[var++]; assert(var == Parameters.size()); // Now, set dependent variables @@ -437,9 +437,9 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase hess(1, 2) = both_minus_L * hess(1, 2) + r_1I_minus_L * grad[1] + r_2I_minus_L * grad[2] + val; hess(2, 2) = both_minus_L * hess(2, 2) + ctwo * r_1I_minus_L * grad[2]; - grad[0] = both_minus_L * grad[0]; - grad[1] = both_minus_L * grad[1] + r_2I_minus_L * val; - grad[2] = both_minus_L * grad[2] + r_1I_minus_L * val; + grad[0] = both_minus_L * grad[0]; + grad[1] = both_minus_L * grad[1] + r_2I_minus_L * val; + grad[2] = both_minus_L * grad[2] + r_1I_minus_L * val; val *= both_minus_L; } hess(1, 0) = hess(0, 1); @@ -549,5 +549,5 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase } } }; -} +} // namespace qmcplusplus #endif diff --git a/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrow.h b/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrow.h index b0c93c7cb..145a1d837 100644 --- a/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrow.h +++ b/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrow.h @@ -158,7 +158,7 @@ template class ThreeBodyJastrow : public WaveFunctionComponentBase if (j) { RealType rcut = 0.5 * j->cutoff_radius; - for (int i = 0; i < Nion; i++) + for (int i = 0; i < Nion; i++) if (Ions.GroupID[i] == iSpecies) Ion_cutoff[i] = rcut; } else @@ -197,7 +197,7 @@ template class ThreeBodyJastrow : public WaveFunctionComponentBase // first set radii for (int i = 0; i < Nion; ++i) { - FT *f = F(Ions.GroupID[i], 0, 0); + FT *f = F(Ions.GroupID[i], 0, 0); if (f != 0) Ion_cutoff[i] = .5 * f->cutoff_radius; } // then check radii @@ -480,5 +480,5 @@ template class ThreeBodyJastrow : public WaveFunctionComponentBase LogValue = mhalf * LogValue; } }; -} +} // namespace qmcplusplus #endif diff --git a/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrowRef.h b/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrowRef.h index 5252dc23d..82b3f7647 100644 --- a/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrowRef.h +++ b/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrowRef.h @@ -160,7 +160,7 @@ template class ThreeBodyJastrowRef : public WaveFunctionComponentBase if (j) { RealType rcut = 0.5 * j->cutoff_radius; - for (int i = 0; i < Nion; i++) + for (int i = 0; i < Nion; i++) if (Ions.GroupID[i] == iSpecies) Ion_cutoff[i] = rcut; } else @@ -200,7 +200,7 @@ template class ThreeBodyJastrowRef : public WaveFunctionComponentBase // first set radii for (int i = 0; i < Nion; ++i) { - FT *f = F(Ions.GroupID[i], 0, 0); + FT *f = F(Ions.GroupID[i], 0, 0); if (f != 0) Ion_cutoff[i] = .5 * f->cutoff_radius; } // then check radii @@ -483,5 +483,5 @@ template class ThreeBodyJastrowRef : public WaveFunctionComponentBase LogValue = mhalf * LogValue; } }; // class ThreeBodyJastrowRef -} // miniqmcreference +} // namespace miniqmcreference #endif diff --git a/src/QMCWaveFunctions/Jastrow/TwoBodyJastrow.h b/src/QMCWaveFunctions/Jastrow/TwoBodyJastrow.h index 907de41db..f9a845daf 100644 --- a/src/QMCWaveFunctions/Jastrow/TwoBodyJastrow.h +++ b/src/QMCWaveFunctions/Jastrow/TwoBodyJastrow.h @@ -197,7 +197,7 @@ template void TwoBodyJastrow::addFunc(int ia, int ib, FT *j) { int ij = 0; for (int ig = 0; ig < NumGroups; ++ig) - for (int jg = 0; jg < NumGroups; ++jg, ++ij) + for (int jg = 0; jg < NumGroups; ++jg, ++ij) if (F[ij] == nullptr) F[ij] = j; } } @@ -208,13 +208,13 @@ template void TwoBodyJastrow::addFunc(int ia, int ib, FT *j) // a very special case, 1 up + 1 down // uu/dd was prevented by the builder for (int ig = 0; ig < NumGroups; ++ig) - for (int jg = 0; jg < NumGroups; ++jg) + for (int jg = 0; jg < NumGroups; ++jg) F[ig * NumGroups + jg] = j; } else { // generic case - F[ia * NumGroups + ib] = j; + F[ia * NumGroups + ib] = j; if (ia < ib) F[ib * NumGroups + ia] = j; } } @@ -386,5 +386,5 @@ void TwoBodyJastrow::evaluateGL(ParticleSet &P, constexpr valT mhalf(-0.5); LogValue = mhalf * LogValue; } -} +} // namespace qmcplusplus #endif diff --git a/src/QMCWaveFunctions/Jastrow/TwoBodyJastrowRef.h b/src/QMCWaveFunctions/Jastrow/TwoBodyJastrowRef.h index cef2331c2..9eb27d621 100644 --- a/src/QMCWaveFunctions/Jastrow/TwoBodyJastrowRef.h +++ b/src/QMCWaveFunctions/Jastrow/TwoBodyJastrowRef.h @@ -384,5 +384,5 @@ void TwoBodyJastrowRef::evaluateGL(ParticleSet &P, constexpr valT mhalf(-0.5); LogValue = mhalf * LogValue; } -} // miniqmcreference +} // namespace miniqmcreference #endif From c5969b387efc2ce9039acaaaa320865388fa67ad Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Thu, 3 May 2018 15:17:13 -0500 Subject: [PATCH 10/11] Revert "Format source." This reverts commit 4347f4c7b03cbbed1c815a749bc1c7f4c4724422. --- src/Numerics/OhmmsPETE/OhmmsMatrix.h | 17 +++++++---------- src/Numerics/OhmmsPETE/OhmmsVector.h | 10 ++++------ src/QMCWaveFunctions/Jastrow/BsplineFunctor.h | 19 +++++++++---------- src/QMCWaveFunctions/Jastrow/OneBodyJastrow.h | 4 ++-- .../Jastrow/OneBodyJastrowRef.h | 4 ++-- .../Jastrow/PolynomialFunctor3D.h | 18 +++++++++--------- .../Jastrow/ThreeBodyJastrow.h | 6 +++--- .../Jastrow/ThreeBodyJastrowRef.h | 6 +++--- src/QMCWaveFunctions/Jastrow/TwoBodyJastrow.h | 8 ++++---- .../Jastrow/TwoBodyJastrowRef.h | 2 +- 10 files changed, 44 insertions(+), 50 deletions(-) diff --git a/src/Numerics/OhmmsPETE/OhmmsMatrix.h b/src/Numerics/OhmmsPETE/OhmmsMatrix.h index a104c4383..0990c02f3 100644 --- a/src/Numerics/OhmmsPETE/OhmmsMatrix.h +++ b/src/Numerics/OhmmsPETE/OhmmsMatrix.h @@ -178,7 +178,7 @@ template > class Matrix { for (int col = 0; col < D2; col++) { - Type_t tmp = (*this)(r1, col); + Type_t tmp = (*this)(r1, col); (*this)(r1, col) = (*this)(r2, col); (*this)(r2, col) = tmp; } @@ -188,7 +188,7 @@ template > class Matrix { for (int row = 0; row < D1; row++) { - Type_t tmp = (*this)(row, c1); + Type_t tmp = (*this)(row, c1); (*this)(row, c1) = (*this)(row, c2); (*this)(row, c2) = tmp; } @@ -202,15 +202,13 @@ template > class Matrix template inline void replaceColumn(IT first, size_type j) { typename Container_t::iterator ii(X.begin() + j); - for (int i = 0; i < D1; i++, ii += D2) - *ii = *first++; + for (int i = 0; i < D1; i++, ii += D2) *ii = *first++; } template inline void add2Column(IT first, size_type j) { typename Container_t::iterator ii(X.begin() + j); - for (int i = 0; i < D1; i++, ii += D2) - *ii += *first++; + for (int i = 0; i < D1; i++, ii += D2) *ii += *first++; } /** @@ -301,8 +299,7 @@ std::ostream &operator<<(std::ostream &out, const Matrix &rhs) size_type ii = 0; for (size_type i = 0; i < rhs.rows(); i++) { - for (size_type j = 0; j < rhs.cols(); j++) - out << rhs(ii++) << " "; + for (size_type j = 0; j < rhs.cols(); j++) out << rhs(ii++) << " "; out << std::endl; } return out; @@ -426,7 +423,7 @@ inline void evaluate(Matrix &lhs, const Op &op, abort(); } } -} // namespace qmcplusplus +} -#include "Numerics/OhmmsPETE/OhmmsMatrixOperators.h" +#include "Numerics/OhmmsPETE/OhmmsMatrixOperators.h" #endif // OHMMS_PETE_MATRIX_H diff --git a/src/Numerics/OhmmsPETE/OhmmsVector.h b/src/Numerics/OhmmsPETE/OhmmsVector.h index 1b397eb9f..344c3476b 100644 --- a/src/Numerics/OhmmsPETE/OhmmsVector.h +++ b/src/Numerics/OhmmsPETE/OhmmsVector.h @@ -158,7 +158,7 @@ template > class Vector } }; -} // namespace qmcplusplus +} // end-of qmcplusplus #include "Numerics/OhmmsPETE/OhmmsVectorOperators.h" @@ -257,8 +257,7 @@ inline void evaluate(Vector &lhs, const Op &op, template std::ostream &operator<<(std::ostream &out, const Vector &rhs) { - for (int i = 0; i < rhs.size(); i++) - out << rhs[i] << std::endl; + for (int i = 0; i < rhs.size(); i++) out << rhs[i] << std::endl; return out; } @@ -266,10 +265,9 @@ template std::istream &operator>>(std::istream &is, Vector &rhs) { // printTinyVector >::print(out,rhs); - for (int i = 0; i < rhs.size(); i++) - is >> rhs[i]; + for (int i = 0; i < rhs.size(); i++) is >> rhs[i]; return is; } -} // namespace qmcplusplus +} #endif // OHMMS_PARTICLEATTRIB_PEPE_H diff --git a/src/QMCWaveFunctions/Jastrow/BsplineFunctor.h b/src/QMCWaveFunctions/Jastrow/BsplineFunctor.h index 64227b007..799b64f61 100644 --- a/src/QMCWaveFunctions/Jastrow/BsplineFunctor.h +++ b/src/QMCWaveFunctions/Jastrow/BsplineFunctor.h @@ -122,11 +122,10 @@ template struct BsplineFunctor : public OptimizableFunctorBase void setupParameters(int n, real_type rcut, real_type cusp, std::vector ¶ms) { - CuspValue = cusp; + CuspValue = cusp; cutoff_radius = rcut; resize(n); - for (int i = 0; i < n; i++) - { + for (int i = 0; i < n; i++) { Parameters[i] = params[i]; } reset(); @@ -252,7 +251,7 @@ template struct BsplineFunctor : public OptimizableFunctorBase int imin = std::max(i, 1); int imax = std::min(i + 4, NumParams + 1); - for (int n = imin; n < imax; ++n) + for (int n = imin; n < imax; ++n) derivs[n - 1] = SplineDerivs[n]; derivs[1] += SplineDerivs[0]; @@ -271,15 +270,15 @@ inline T BsplineFunctor::evaluateV(const int iStart, const int iEnd, int iCount = 0; const int iLimit = iEnd - iStart; -#pragma vector always + #pragma vector always for (int jat = 0; jat < iLimit; jat++) { - real_type r = distArray[jat]; + real_type r = distArray[jat]; if (r < cutoff_radius) distArrayCompressed[iCount++] = distArray[jat]; } real_type d = 0.0; -#pragma omp simd reduction(+ : d) + #pragma omp simd reduction(+:d) for (int jat = 0; jat < iCount; jat++) { real_type r = distArrayCompressed[jat]; @@ -324,7 +323,7 @@ inline void BsplineFunctor::evaluateVGL( real_type *gradArray = _gradArray + iStart; real_type *laplArray = _laplArray + iStart; -#pragma vector always + #pragma vector always for (int jat = 0; jat < iLimit; jat++) { real_type r = distArray[jat]; @@ -336,7 +335,7 @@ inline void BsplineFunctor::evaluateVGL( } } -#pragma omp simd + #pragma omp simd for (int j = 0; j < iCount; j++) { @@ -375,5 +374,5 @@ inline void BsplineFunctor::evaluateVGL( // clang-format on } } -} // namespace qmcplusplus +} #endif diff --git a/src/QMCWaveFunctions/Jastrow/OneBodyJastrow.h b/src/QMCWaveFunctions/Jastrow/OneBodyJastrow.h index f84effecb..3fad77007 100644 --- a/src/QMCWaveFunctions/Jastrow/OneBodyJastrow.h +++ b/src/QMCWaveFunctions/Jastrow/OneBodyJastrow.h @@ -256,7 +256,7 @@ template struct OneBodyJastrow : public WaveFunctionComponentBase computeU3(P, iat, P.DistTables[myTableID]->Temp_r.data()); curLap = accumulateGL(dU.data(), d2U.data(), P.DistTables[myTableID]->Temp_dr, curGrad); - curAt = simd::accumulate_n(U.data(), Nions, valT()); + curAt = simd::accumulate_n(U.data(), Nions, valT()); grad_iat += curGrad; return std::exp(Vat[iat] - curAt); } @@ -278,5 +278,5 @@ template struct OneBodyJastrow : public WaveFunctionComponentBase Lap[iat] = curLap; } }; -} // namespace qmcplusplus +} #endif diff --git a/src/QMCWaveFunctions/Jastrow/OneBodyJastrowRef.h b/src/QMCWaveFunctions/Jastrow/OneBodyJastrowRef.h index f0177d5a1..09f21eb59 100644 --- a/src/QMCWaveFunctions/Jastrow/OneBodyJastrowRef.h +++ b/src/QMCWaveFunctions/Jastrow/OneBodyJastrowRef.h @@ -253,7 +253,7 @@ template struct OneBodyJastrowRef : public WaveFunctionComponentBase computeU3(P, iat, P.DistTables[myTableID]->Temp_r.data()); curLap = accumulateGL(dU.data(), d2U.data(), P.DistTables[myTableID]->Temp_dr, curGrad); - curAt = std::accumulate(U.begin(), U.begin() + Nions, valT()); + curAt = std::accumulate(U.begin(), U.begin() + Nions, valT()); grad_iat += curGrad; return std::exp(Vat[iat] - curAt); } @@ -275,5 +275,5 @@ template struct OneBodyJastrowRef : public WaveFunctionComponentBase Lap[iat] = curLap; } }; // class OneBodyJastrowRef -} // namespace miniqmcreference +} // miniqmcreferencce #endif diff --git a/src/QMCWaveFunctions/Jastrow/PolynomialFunctor3D.h b/src/QMCWaveFunctions/Jastrow/PolynomialFunctor3D.h index 933e4d597..2427182a2 100644 --- a/src/QMCWaveFunctions/Jastrow/PolynomialFunctor3D.h +++ b/src/QMCWaveFunctions/Jastrow/PolynomialFunctor3D.h @@ -145,9 +145,9 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase GammaPerm.resize(NumGamma); IndepVar.resize(NumGamma, false); // Set identity permutation - for (int i = 0; i < NumGamma; i++) + for (int i = 0; i < NumGamma; i++) GammaPerm[i] = i; - int col = -1; + int col = -1; for (int row = 0; row < NumConstraints; row++) { int max_loc; @@ -173,7 +173,7 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase // manually swap the rows for (int ind_col = 0; ind_col < ConstraintMatrix.size2(); ind_col++) { - real_type temp = ConstraintMatrix(row, ind_col); + real_type temp = ConstraintMatrix(row, ind_col); ConstraintMatrix(row, ind_col) = ConstraintMatrix(max_loc, ind_col); ConstraintMatrix(max_loc, ind_col) = temp; } @@ -194,7 +194,7 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase } } } - for (int c = col + 1; c < NumGamma; c++) + for (int c = col + 1; c < NumGamma; c++) IndepVar[c] = true; } @@ -210,7 +210,7 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase std::fill(GammaVec.begin(), GammaVec.end(), 0.0); // First, set all independent variables int var = 0; - for (int i = 0; i < NumGamma; i++) + for (int i = 0; i < NumGamma; i++) if (IndepVar[i]) GammaVec[i] = scale * Parameters[var++]; assert(var == Parameters.size()); // Now, set dependent variables @@ -437,9 +437,9 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase hess(1, 2) = both_minus_L * hess(1, 2) + r_1I_minus_L * grad[1] + r_2I_minus_L * grad[2] + val; hess(2, 2) = both_minus_L * hess(2, 2) + ctwo * r_1I_minus_L * grad[2]; - grad[0] = both_minus_L * grad[0]; - grad[1] = both_minus_L * grad[1] + r_2I_minus_L * val; - grad[2] = both_minus_L * grad[2] + r_1I_minus_L * val; + grad[0] = both_minus_L * grad[0]; + grad[1] = both_minus_L * grad[1] + r_2I_minus_L * val; + grad[2] = both_minus_L * grad[2] + r_1I_minus_L * val; val *= both_minus_L; } hess(1, 0) = hess(0, 1); @@ -549,5 +549,5 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase } } }; -} // namespace qmcplusplus +} #endif diff --git a/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrow.h b/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrow.h index 145a1d837..b0c93c7cb 100644 --- a/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrow.h +++ b/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrow.h @@ -158,7 +158,7 @@ template class ThreeBodyJastrow : public WaveFunctionComponentBase if (j) { RealType rcut = 0.5 * j->cutoff_radius; - for (int i = 0; i < Nion; i++) + for (int i = 0; i < Nion; i++) if (Ions.GroupID[i] == iSpecies) Ion_cutoff[i] = rcut; } else @@ -197,7 +197,7 @@ template class ThreeBodyJastrow : public WaveFunctionComponentBase // first set radii for (int i = 0; i < Nion; ++i) { - FT *f = F(Ions.GroupID[i], 0, 0); + FT *f = F(Ions.GroupID[i], 0, 0); if (f != 0) Ion_cutoff[i] = .5 * f->cutoff_radius; } // then check radii @@ -480,5 +480,5 @@ template class ThreeBodyJastrow : public WaveFunctionComponentBase LogValue = mhalf * LogValue; } }; -} // namespace qmcplusplus +} #endif diff --git a/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrowRef.h b/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrowRef.h index 82b3f7647..5252dc23d 100644 --- a/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrowRef.h +++ b/src/QMCWaveFunctions/Jastrow/ThreeBodyJastrowRef.h @@ -160,7 +160,7 @@ template class ThreeBodyJastrowRef : public WaveFunctionComponentBase if (j) { RealType rcut = 0.5 * j->cutoff_radius; - for (int i = 0; i < Nion; i++) + for (int i = 0; i < Nion; i++) if (Ions.GroupID[i] == iSpecies) Ion_cutoff[i] = rcut; } else @@ -200,7 +200,7 @@ template class ThreeBodyJastrowRef : public WaveFunctionComponentBase // first set radii for (int i = 0; i < Nion; ++i) { - FT *f = F(Ions.GroupID[i], 0, 0); + FT *f = F(Ions.GroupID[i], 0, 0); if (f != 0) Ion_cutoff[i] = .5 * f->cutoff_radius; } // then check radii @@ -483,5 +483,5 @@ template class ThreeBodyJastrowRef : public WaveFunctionComponentBase LogValue = mhalf * LogValue; } }; // class ThreeBodyJastrowRef -} // namespace miniqmcreference +} // miniqmcreference #endif diff --git a/src/QMCWaveFunctions/Jastrow/TwoBodyJastrow.h b/src/QMCWaveFunctions/Jastrow/TwoBodyJastrow.h index f9a845daf..907de41db 100644 --- a/src/QMCWaveFunctions/Jastrow/TwoBodyJastrow.h +++ b/src/QMCWaveFunctions/Jastrow/TwoBodyJastrow.h @@ -197,7 +197,7 @@ template void TwoBodyJastrow::addFunc(int ia, int ib, FT *j) { int ij = 0; for (int ig = 0; ig < NumGroups; ++ig) - for (int jg = 0; jg < NumGroups; ++jg, ++ij) + for (int jg = 0; jg < NumGroups; ++jg, ++ij) if (F[ij] == nullptr) F[ij] = j; } } @@ -208,13 +208,13 @@ template void TwoBodyJastrow::addFunc(int ia, int ib, FT *j) // a very special case, 1 up + 1 down // uu/dd was prevented by the builder for (int ig = 0; ig < NumGroups; ++ig) - for (int jg = 0; jg < NumGroups; ++jg) + for (int jg = 0; jg < NumGroups; ++jg) F[ig * NumGroups + jg] = j; } else { // generic case - F[ia * NumGroups + ib] = j; + F[ia * NumGroups + ib] = j; if (ia < ib) F[ib * NumGroups + ia] = j; } } @@ -386,5 +386,5 @@ void TwoBodyJastrow::evaluateGL(ParticleSet &P, constexpr valT mhalf(-0.5); LogValue = mhalf * LogValue; } -} // namespace qmcplusplus +} #endif diff --git a/src/QMCWaveFunctions/Jastrow/TwoBodyJastrowRef.h b/src/QMCWaveFunctions/Jastrow/TwoBodyJastrowRef.h index 9eb27d621..cef2331c2 100644 --- a/src/QMCWaveFunctions/Jastrow/TwoBodyJastrowRef.h +++ b/src/QMCWaveFunctions/Jastrow/TwoBodyJastrowRef.h @@ -384,5 +384,5 @@ void TwoBodyJastrowRef::evaluateGL(ParticleSet &P, constexpr valT mhalf(-0.5); LogValue = mhalf * LogValue; } -} // namespace miniqmcreference +} // miniqmcreference #endif From 41416ad2e30e4a0fb257dfac5188421b3e692c50 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Fri, 11 May 2018 17:37:40 -0500 Subject: [PATCH 11/11] Applied the Peter's patch and raise minimum to 3.6. --- CMakeLists.txt | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2eebb9689..0d856dfa3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,18 @@ -PROJECT(qmcpack CXX) - - -##################################################### -CMAKE_MINIMUM_REQUIRED(VERSION 3.4.0) -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) +###################################################################### +# GLOBAL +###################################################################### +CMAKE_MINIMUM_REQUIRED(VERSION 3.6.0) +cmake_policy(SET CMP0003 NEW) +#Actually set CXX11 flag for Clang on Apple, even llvm non apple clang +#This is contrary to what the --help-policy says +cmake_policy(SET CMP0025 NEW) +###################################################################### +PROJECT(qmcpack CXX) +###################################################################### ###################################################################### -# Version +# Version ###################################################################### SET(QMCPACK_VERSION_MAJOR 3) SET(QMCPACK_VERSION_MINOR 1) @@ -17,7 +20,7 @@ SET(QMCPACK_VERSION_PATCH 0) SET(QMCPACK_VERSION "${QMCPACK_VERSION_MAJOR}.${QMCPACK_VERSION_MINOR}.${QMCPACK_VERSION_PATCH}") ###################################################################### -# CTest +# CTest ###################################################################### SET( DROP_METHOD "http" ) SET( DROP_SITE "cdash.qmcpack.org" ) @@ -68,8 +71,8 @@ SET (EXECUTABLE_OUTPUT_PATH ${qmcpack_BINARY_DIR}/bin CACHE PATH "Single output # OHMMS_PRECISION = base precision, float, double etc # OHMMS_PRECISION_FULL = full precision, double etc # QMC_COMPLEX = true if using complex wavefunctions -# QMC_MPI = enable MPI -# QMC_OMP = enable OMP +# QMC_MPI = enable MPI +# QMC_OMP = enable OMP ###################################################################### SET(OHMMS_DIM 3 CACHE INTEGER "Select physical dimension") SET(OHMMS_INDEXTYPE int) @@ -277,12 +280,7 @@ ELSE(CMAKE_TOOLCHAIN_FILE) # requires C++11 standard SET(CMAKE_CXX_STANDARD 11) SET(CMAKE_CXX_STANDARD_REQUIRED ON) - SET(CXX11_FLAG "-std=c++11") - # avoid repeated -std=c++11 flag - STRING(REPLACE "++" "\\+\\+" CXX11_FLAG_MATCH ${CXX11_FLAG}) - IF(NOT CMAKE_CXX_FLAGS MATCHES ${CXX11_FLAG_MATCH}) - SET (CMAKE_CXX_FLAGS "${CXX11_FLAG} ${CMAKE_CXX_FLAGS}") - ENDIF() + SET(CMAKE_CXX_EXTENSIONS OFF) #------------------------------------------------------------------- # check MPI installation @@ -303,10 +301,10 @@ ELSE(CMAKE_TOOLCHAIN_FILE) IF(MPI_FOUND) MESSAGE(STATUS "Found mpi.h and libraries. Check for working mpi compiler ") INCLUDE_DIRECTORIES(${MPI_CXX_INCLUDE_PATH}) - FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testmpi.cxx + FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testmpi.cxx "#include " "int main(int argc, char** argv){MPI_Init(&argc,&argv); MPI_Finalize();return 0;}\n") - #TRY_COMPILE(MPI_WORKS ${CMAKE_BINARY_DIR} + #TRY_COMPILE(MPI_WORKS ${CMAKE_BINARY_DIR} #${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testmpi.cxx #OUTPUT_VARIABLE OUTPUT) set(MPI_WORKS 1)