Merge pull request #2520 from akohlmey/add-pgi-preset
Add a CMake preset and some workarounds for using PGI (Nvidia) compilers with LAMMPS
This commit is contained in:
@ -220,6 +220,7 @@ if(BUILD_OMP)
|
||||
endif()
|
||||
|
||||
if (((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)) OR
|
||||
(CMAKE_CXX_COMPILER_ID STREQUAL "PGI") OR
|
||||
((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)) OR
|
||||
((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0)))
|
||||
# GCC 9.x and later plus Clang 10.x and later implement strict OpenMP 4.0 semantics for consts.
|
||||
|
||||
16
cmake/presets/pgi.cmake
Normal file
16
cmake/presets/pgi.cmake
Normal file
@ -0,0 +1,16 @@
|
||||
# preset that will enable clang/clang++ with support for MPI and OpenMP (on Linux boxes)
|
||||
|
||||
set(CMAKE_CXX_COMPILER "pgc++" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_COMPILER "pgcc" CACHE STRING "" FORCE)
|
||||
set(CMAKE_Fortran_COMPILER "pgfortran" CACHE STRING "" FORCE)
|
||||
set(MPI_CXX "pgc++" CACHE STRING "" FORCE)
|
||||
set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE)
|
||||
unset(HAVE_OMP_H_INCLUDE CACHE)
|
||||
|
||||
set(OpenMP_C "pgcc" CACHE STRING "" FORCE)
|
||||
set(OpenMP_C_FLAGS "-mp" CACHE STRING "" FORCE)
|
||||
set(OpenMP_C_LIB_NAMES "omp" CACHE STRING "" FORCE)
|
||||
set(OpenMP_CXX "pgc++" CACHE STRING "" FORCE)
|
||||
set(OpenMP_CXX_FLAGS "-mp" CACHE STRING "" FORCE)
|
||||
set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE)
|
||||
set(OpenMP_omp_LIBRARY "libomp.so" CACHE PATH "" FORCE)
|
||||
@ -236,12 +236,15 @@ LAMMPS.
|
||||
cmake ../cmake -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc -DCMAKE_Fortran_COMPILER=ifort
|
||||
# Building with LLVM/Clang Compilers:
|
||||
cmake ../cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_Fortran_COMPILER=flang
|
||||
# Building with PGI/Nvidia Compilers:
|
||||
cmake ../cmake -DCMAKE_C_COMPILER=pgcc -DCMAKE_CXX_COMPILER=pgc++ -DCMAKE_Fortran_COMPILER=pgfortran
|
||||
|
||||
For compiling with the Clang/LLVM compilers a CMake preset is
|
||||
provided that can be loaded with
|
||||
`-C ../cmake/presets/clang.cmake`. Similarly,
|
||||
`-C ../cmake/presets/intel.cmake` should switch the compiler
|
||||
toolchain to the Intel compilers.
|
||||
toolchain to the Intel compilers and `-C ../cmake/presets/pgi.cmake`
|
||||
should switch the compiler to the PGI compilers.
|
||||
|
||||
In addition you can set ``CMAKE_TUNE_FLAGS`` to specifically add
|
||||
compiler flags to tune for optimal performance on given hosts. By
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
Include packages in build
|
||||
|
||||
=========================
|
||||
|
||||
In LAMMPS, a package is a group of files that enable a specific set of
|
||||
@ -160,6 +161,7 @@ one of them as a starting point and customize it to your needs.
|
||||
cmake -C ../cmake/presets/clang.cmake [OPTIONS] ../cmake # change settings to use the Clang compilers by default
|
||||
cmake -C ../cmake/presets/gcc.cmake [OPTIONS] ../cmake # change settings to use the GNU compilers by default
|
||||
cmake -C ../cmake/presets/intel.cmake [OPTIONS] ../cmake # change settings to use the Intel compilers by default
|
||||
cmake -C ../cmake/presets/pgi.cmake [OPTIONS] ../cmake # change settings to use the PGI compilers by default
|
||||
cmake -C ../cmake/presets/all_on.cmake [OPTIONS] ../cmake # enable all packages
|
||||
cmake -C ../cmake/presets/all_off.cmake [OPTIONS] ../cmake # disable all packages
|
||||
mingw64-cmake -C ../cmake/presets/mingw-cross.cmake [OPTIONS] ../cmake # compile with MinGW cross compilers
|
||||
|
||||
@ -375,7 +375,11 @@ struct ostream_params {
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
#if defined(__PGI)
|
||||
static detail::buffer_size buffer_size;
|
||||
#else
|
||||
static constexpr detail::buffer_size buffer_size;
|
||||
#endif
|
||||
|
||||
// A fast output stream which is not thread-safe.
|
||||
class ostream final : private detail::buffer<char> {
|
||||
|
||||
@ -1179,6 +1179,8 @@ std::string Info::get_compiler_info()
|
||||
std::string buf;
|
||||
#if __clang__
|
||||
buf = fmt::format("Clang C++ {}", __VERSION__);
|
||||
#elif __PGI
|
||||
buf = fmt::format("PGI C++ {}.{}",__PGIC__,__PGIC_MINOR__);
|
||||
#elif __INTEL_COMPILER
|
||||
double version = static_cast<double>(__INTEL_COMPILER)*0.01;
|
||||
buf = fmt::format("Intel C++ {:.2f}.{} / {}", version,
|
||||
|
||||
@ -268,6 +268,8 @@ The typecasts prevent compiler warnings about possible truncation issues.
|
||||
# define _noopt __attribute__((optnone))
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
# define _noopt
|
||||
#elif defined(__PGI)
|
||||
# define _noopt
|
||||
#elif defined(__GNUC__)
|
||||
# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9))
|
||||
# if defined(_FORTIFY_SOURCE) && (_FORTIFY_SOURCE > 0)
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
#include <vector>
|
||||
|
||||
#if !defined(_FORTIFY_SOURCE) || (_FORTIFY_SOURCE == 0)
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#if defined(__INTEL_COMPILER) || (__PGI)
|
||||
#define _do_nothing
|
||||
#elif defined(__clang__)
|
||||
#pragma clang optimize off
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
MODULE keepcmds
|
||||
USE liblammps
|
||||
TYPE(LAMMPS) :: lmp
|
||||
CHARACTER(len=*), DIMENSION(*), PARAMETER :: demo_input = &
|
||||
CHARACTER(len=40), DIMENSION(3), PARAMETER :: demo_input = &
|
||||
[ CHARACTER(len=40) :: &
|
||||
'region box block 0 $x 0 2 0 2', &
|
||||
'create_box 1 box', &
|
||||
'create_atoms 1 single 1.0 1.0 ${zpos}' ]
|
||||
CHARACTER(len=*), DIMENSION(*), PARAMETER :: cont_input = &
|
||||
CHARACTER(len=40), DIMENSION(2), PARAMETER :: cont_input = &
|
||||
[ CHARACTER(len=40) :: &
|
||||
'create_atoms 1 single &', &
|
||||
' 0.2 0.1 0.1' ]
|
||||
@ -19,7 +19,7 @@ FUNCTION f_lammps_with_args() BIND(C, name="f_lammps_with_args")
|
||||
IMPLICIT NONE
|
||||
TYPE(c_ptr) :: f_lammps_with_args
|
||||
|
||||
CHARACTER(len=*), DIMENSION(*), PARAMETER :: args = &
|
||||
CHARACTER(len=12), DIMENSION(12), PARAMETER :: args = &
|
||||
[ CHARACTER(len=12) :: 'liblammps', '-log', 'none', &
|
||||
'-echo','screen','-nocite','-var','zpos','1.5','-var','x','2']
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ FUNCTION f_lammps_no_mpi_with_args() BIND(C, name="f_lammps_no_mpi_with_args")
|
||||
IMPLICIT NONE
|
||||
TYPE(c_ptr) :: f_lammps_no_mpi_with_args
|
||||
|
||||
CHARACTER(len=*), DIMENSION(*), PARAMETER :: args = &
|
||||
CHARACTER(len=12), DIMENSION(4), PARAMETER :: args = &
|
||||
[ CHARACTER(len=12) :: 'liblammps', '-log', 'none', '-nocite' ]
|
||||
|
||||
lmp = lammps(args)
|
||||
@ -54,7 +54,7 @@ FUNCTION f_lammps_open_with_args() BIND(C, name="f_lammps_open_with_args")
|
||||
TYPE(c_ptr) :: f_lammps_open_with_args
|
||||
INTEGER :: color, key, ierr
|
||||
|
||||
CHARACTER(len=*), DIMENSION(*), PARAMETER :: args = &
|
||||
CHARACTER(len=12), DIMENSION(4), PARAMETER :: args = &
|
||||
[ CHARACTER(len=12) :: 'liblammps', '-log', 'none', '-nocite' ]
|
||||
|
||||
color = 2
|
||||
@ -73,7 +73,7 @@ SUBROUTINE f_lammps_close() BIND(C, name="f_lammps_close")
|
||||
CALL lmp%close()
|
||||
lmp%handle = c_null_ptr
|
||||
END SUBROUTINE f_lammps_close
|
||||
|
||||
|
||||
FUNCTION f_lammps_get_comm() BIND(C, name="f_lammps_get_comm")
|
||||
USE liblammps
|
||||
USE keepcreate, ONLY: mycomm
|
||||
@ -82,5 +82,3 @@ FUNCTION f_lammps_get_comm() BIND(C, name="f_lammps_get_comm")
|
||||
|
||||
f_lammps_get_comm = mycomm
|
||||
END FUNCTION f_lammps_get_comm
|
||||
|
||||
|
||||
|
||||
@ -57,10 +57,13 @@ if (Python_EXECUTABLE)
|
||||
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
|
||||
set_tests_properties(PythonOpen PROPERTIES ENVIRONMENT "${PYTHON_TEST_ENVIRONMENT}")
|
||||
|
||||
add_test(NAME PythonCommands
|
||||
COMMAND ${PYTHON_TEST_RUNNER} ${CMAKE_CURRENT_SOURCE_DIR}/python-commands.py -v
|
||||
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
|
||||
set_tests_properties(PythonCommands PROPERTIES ENVIRONMENT "${PYTHON_TEST_ENVIRONMENT}")
|
||||
# some of the tests in this file will fail without exceptions enabled
|
||||
if(LAMMPS_EXCEPTIONS)
|
||||
add_test(NAME PythonCommands
|
||||
COMMAND ${PYTHON_TEST_RUNNER} ${CMAKE_CURRENT_SOURCE_DIR}/python-commands.py -v
|
||||
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
|
||||
set_tests_properties(PythonCommands PROPERTIES ENVIRONMENT "${PYTHON_TEST_ENVIRONMENT}")
|
||||
endif()
|
||||
|
||||
add_test(NAME PythonNumpy
|
||||
COMMAND ${PYTHON_TEST_RUNNER} ${CMAKE_CURRENT_SOURCE_DIR}/python-numpy.py -v
|
||||
|
||||
Reference in New Issue
Block a user