Merge branch 'master' into neel-rework
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,6 +9,7 @@
|
||||
*.d
|
||||
*.x
|
||||
*.exe
|
||||
*.sif
|
||||
*.dll
|
||||
*.pyc
|
||||
__pycache__
|
||||
|
||||
@ -21,17 +21,12 @@ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "default install path" FORCE )
|
||||
endif()
|
||||
|
||||
# To avoid conflicts with the conventional Makefile build system, we build everything here
|
||||
file(GLOB LIB_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp)
|
||||
file(GLOB LMP_SOURCES ${LAMMPS_SOURCE_DIR}/main.cpp)
|
||||
list(REMOVE_ITEM LIB_SOURCES ${LMP_SOURCES})
|
||||
|
||||
# Cmake modules/macros are in a subdirectory to keep this file cleaner
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules)
|
||||
|
||||
include(LAMMPSUtils)
|
||||
|
||||
get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION)
|
||||
get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h PROJECT_VERSION)
|
||||
|
||||
include(PreventInSourceBuilds)
|
||||
|
||||
@ -69,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")
|
||||
@ -110,16 +106,28 @@ endif()
|
||||
|
||||
option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF)
|
||||
|
||||
if(NOT BUILD_EXE AND NOT BUILD_LIB)
|
||||
message(FATAL_ERROR "You need to at least enable one of two following options: BUILD_LIB or BUILD_EXE")
|
||||
include(GNUInstallDirs)
|
||||
file(GLOB ALL_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp)
|
||||
if(BUILD_LIB)
|
||||
file(GLOB MAIN_SOURCES ${LAMMPS_SOURCE_DIR}/main.cpp)
|
||||
list(REMOVE_ITEM ALL_SOURCES ${MAIN_SOURCES})
|
||||
add_library(lammps ${ALL_SOURCES})
|
||||
if(BUILD_EXE)
|
||||
add_executable(lmp ${MAIN_SOURCES})
|
||||
target_link_libraries(lmp PRIVATE lammps)
|
||||
set_target_properties(lmp PROPERTIES OUTPUT_NAME ${LAMMPS_BINARY})
|
||||
install(TARGETS lmp EXPORT LAMMPS_Targets DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
else()
|
||||
if(NOT BUILD_EXE)
|
||||
message(FATAL_ERROR "You need to at least enable one of two following options: BUILD_LIB or BUILD_EXE")
|
||||
endif()
|
||||
add_executable(lammps ${ALL_SOURCES})
|
||||
set_target_properties(lammps PROPERTIES OUTPUT_NAME ${LAMMPS_BINARY})
|
||||
install(TARGETS lammps DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
||||
option(CMAKE_VERBOSE_MAKEFILE "Generate verbose Makefiles" OFF)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(LAMMPS_LINK_LIBS)
|
||||
set(LAMMPS_DEPS)
|
||||
set(LAMMPS_API_DEFINES)
|
||||
|
||||
set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE
|
||||
GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MOLECULE PERI POEMS QEQ
|
||||
@ -135,28 +143,10 @@ foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES})
|
||||
option(PKG_${PKG} "Build ${PKG} Package" OFF)
|
||||
endforeach()
|
||||
|
||||
######################################################
|
||||
# download and unpack support binaries for compilation
|
||||
# of windows binaries.
|
||||
######################################################
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
set(LAMMPS_THIRDPARTY_URL "http://download.lammps.org/thirdparty")
|
||||
file(DOWNLOAD "${LAMMPS_THIRDPARTY_URL}/opencl-win-devel.tar.gz" "${CMAKE_CURRENT_BINARY_DIR}/opencl-win-devel.tar.gz"
|
||||
EXPECTED_MD5 2c00364888d5671195598b44c2e0d44d)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf opencl-win-devel.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
|
||||
set(OpenCL_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win32/libOpenCL.dll")
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
|
||||
set(OpenCL_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win64/libOpenCL.dll")
|
||||
endif()
|
||||
set(OpenCL_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/include")
|
||||
endif()
|
||||
|
||||
######################################################
|
||||
######################################################
|
||||
# packages with special compiler needs or external libs
|
||||
######################################################
|
||||
include_directories(${LAMMPS_SOURCE_DIR})
|
||||
target_include_directories(lammps PUBLIC $<BUILD_INTERFACE:${LAMMPS_SOURCE_DIR}>)
|
||||
|
||||
if(PKG_USER-ADIOS)
|
||||
# The search for ADIOS2 must come before MPI because
|
||||
@ -164,35 +154,50 @@ if(PKG_USER-ADIOS)
|
||||
# script that defines the MPI::MPI_C target
|
||||
enable_language(C)
|
||||
find_package(ADIOS2 REQUIRED)
|
||||
list(APPEND LAMMPS_LINK_LIBS adios2::adios2)
|
||||
target_link_libraries(lammps PRIVATE adios2::adios2)
|
||||
endif()
|
||||
|
||||
# do MPI detection after language activation,
|
||||
# in case MPI for these languages is required
|
||||
set(MPI_CXX_SKIP_MPICXX TRUE)
|
||||
find_package(MPI QUIET)
|
||||
option(BUILD_MPI "Build MPI version" ${MPI_FOUND})
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
option(BUILD_MPI "Build MPI version" OFF)
|
||||
else()
|
||||
# do MPI detection after language activation,
|
||||
# in case MPI for these languages is required
|
||||
set(MPI_CXX_SKIP_MPICXX TRUE)
|
||||
find_package(MPI QUIET)
|
||||
option(BUILD_MPI "Build MPI version" ${MPI_FOUND})
|
||||
endif()
|
||||
|
||||
if(BUILD_MPI)
|
||||
# We use a non-standard procedure to compile with MPI on windows
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
include(MPI4WIN)
|
||||
target_link_libraries(lammps PUBLIC MPI::MPI_CXX)
|
||||
else()
|
||||
set(MPI_CXX_SKIP_MPICXX ON)
|
||||
find_package(MPI REQUIRED)
|
||||
include_directories(${MPI_CXX_INCLUDE_PATH})
|
||||
add_definitions(-DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${MPI_CXX_LIBRARIES})
|
||||
target_link_libraries(lammps PUBLIC MPI::MPI_CXX)
|
||||
option(LAMMPS_LONGLONG_TO_LONG "Workaround if your system or MPI version does not recognize 'long long' data types" OFF)
|
||||
if(LAMMPS_LONGLONG_TO_LONG)
|
||||
add_definitions(-DLAMMPS_LONGLONG_TO_LONG)
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_LONGLONG_TO_LONG)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
enable_language(C)
|
||||
file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.c)
|
||||
add_library(mpi_stubs STATIC ${MPI_SOURCES})
|
||||
include_directories(${LAMMPS_SOURCE_DIR}/STUBS)
|
||||
list(APPEND LAMMPS_LINK_LIBS mpi_stubs)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS mpi_stubs EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
set_target_properties(mpi_stubs PROPERTIES OUTPUT_NAME lammps_mpi_stubs${LAMMPS_LIB_SUFFIX})
|
||||
target_include_directories(mpi_stubs PUBLIC $<BUILD_INTERFACE:${LAMMPS_SOURCE_DIR}/STUBS> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/lammps/mpi>)
|
||||
install(FILES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps/mpi)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_link_libraries(lammps PRIVATE mpi_stubs)
|
||||
target_include_directories(lammps INTERFACE $<BUILD_INTERFACE:${LAMMPS_SOURCE_DIR}/STUBS> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/lammps/mpi>)
|
||||
else()
|
||||
target_link_libraries(lammps PUBLIC mpi_stubs)
|
||||
endif()
|
||||
add_library(MPI::MPI_CXX ALIAS mpi_stubs)
|
||||
endif()
|
||||
|
||||
set(LAMMPS_SIZES "smallbig" CACHE STRING "LAMMPS integer sizes (smallsmall: all 32-bit, smallbig: 64-bit #atoms #timesteps, bigbig: also 64-bit imageint, 64-bit atom ids)")
|
||||
@ -200,8 +205,7 @@ set(LAMMPS_SIZES_VALUES smallbig bigbig smallsmall)
|
||||
set_property(CACHE LAMMPS_SIZES PROPERTY STRINGS ${LAMMPS_SIZES_VALUES})
|
||||
validate_option(LAMMPS_SIZES LAMMPS_SIZES_VALUES)
|
||||
string(TOUPPER ${LAMMPS_SIZES} LAMMPS_SIZES)
|
||||
add_definitions(-DLAMMPS_${LAMMPS_SIZES})
|
||||
set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -DLAMMPS_${LAMMPS_SIZES}")
|
||||
target_compile_definitions(lammps PUBLIC -DLAMMPS_${LAMMPS_SIZES})
|
||||
|
||||
# posix_memalign is not available on Windows
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
@ -210,13 +214,12 @@ else()
|
||||
set(LAMMPS_MEMALIGN "64" CACHE STRING "enables the use of the posix_memalign() call instead of malloc() when large chunks or memory are allocated by LAMMPS. Set to 0 to disable")
|
||||
endif()
|
||||
if(NOT ${LAMMPS_MEMALIGN} STREQUAL "0")
|
||||
add_definitions(-DLAMMPS_MEMALIGN=${LAMMPS_MEMALIGN})
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_MEMALIGN=${LAMMPS_MEMALIGN})
|
||||
endif()
|
||||
|
||||
option(LAMMPS_EXCEPTIONS "enable the use of C++ exceptions for error messages (useful for library interface)" OFF)
|
||||
if(LAMMPS_EXCEPTIONS)
|
||||
add_definitions(-DLAMMPS_EXCEPTIONS)
|
||||
set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -DLAMMPS_EXCEPTIONS")
|
||||
target_compile_definitions(lammps PUBLIC -DLAMMPS_EXCEPTIONS)
|
||||
endif()
|
||||
|
||||
# "hard" dependencies between packages resulting
|
||||
@ -237,16 +240,7 @@ if(OpenMP_FOUND)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# TODO: this is a temporary workaround until a better solution is found. AK 2019-05-30
|
||||
# GNU GCC 9.x uses settings incompatible with our use of 'default(none)' in OpenMP pragmas
|
||||
# where we assume older GCC semantics. For the time being, we disable OpenMP by default
|
||||
# for GCC 9.x and beyond. People may manually turn it on, but need to run the script
|
||||
# src/USER-OMP/hack_openmp_for_pgi_gcc9.sh on all sources to make it compatible with gcc 9.
|
||||
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.99.9))
|
||||
option(BUILD_OMP "Build with OpenMP support" OFF)
|
||||
else()
|
||||
option(BUILD_OMP "Build with OpenMP support" ${BUILD_OMP_DEFAULT})
|
||||
endif()
|
||||
option(BUILD_OMP "Build with OpenMP support" ${BUILD_OMP_DEFAULT})
|
||||
|
||||
if(BUILD_OMP)
|
||||
find_package(OpenMP REQUIRED)
|
||||
@ -254,8 +248,18 @@ if(BUILD_OMP)
|
||||
if(NOT HAVE_OMP_H_INCLUDE)
|
||||
message(FATAL_ERROR "Cannot find the 'omp.h' header file required for full OpenMP support")
|
||||
endif()
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
|
||||
if (((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.99.9)) OR
|
||||
((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.99.9)) OR
|
||||
((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 18.99.9))
|
||||
)
|
||||
# GCC 9.x and later plus Clang 10.x and later implement strict OpenMP 4.0 semantics for consts.
|
||||
# Intel 18.0 was tested to support both, so we switch to OpenMP 4+ from 19.x onward to be safe.
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_OMP_COMPAT=4)
|
||||
else()
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_OMP_COMPAT=3)
|
||||
endif()
|
||||
target_link_libraries(lammps PRIVATE OpenMP::OpenMP_CXX)
|
||||
endif()
|
||||
|
||||
if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE)
|
||||
@ -270,6 +274,10 @@ if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE)
|
||||
enable_language(Fortran)
|
||||
file(GLOB LAPACK_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.[fF])
|
||||
add_library(linalg STATIC ${LAPACK_SOURCES})
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS linalg EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
set_target_properties(linalg PROPERTIES OUTPUT_NAME lammps_linalg${LAMMPS_LIB_SUFFIX})
|
||||
set(BLAS_LIBRARIES "$<TARGET_FILE:linalg>")
|
||||
set(LAPACK_LIBRARIES "$<TARGET_FILE:linalg>")
|
||||
else()
|
||||
@ -282,9 +290,13 @@ find_package(JPEG QUIET)
|
||||
option(WITH_JPEG "Enable JPEG support" ${JPEG_FOUND})
|
||||
if(WITH_JPEG)
|
||||
find_package(JPEG REQUIRED)
|
||||
add_definitions(-DLAMMPS_JPEG)
|
||||
include_directories(${JPEG_INCLUDE_DIR})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${JPEG_LIBRARIES})
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_JPEG)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.12)
|
||||
target_include_directories(lammps PRIVATE ${JPEG_INCLUDE_DIR})
|
||||
target_link_libraries(lammps PRIVATE ${JPEG_LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(lammps PRIVATE JPEG::JPEG)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(PNG QUIET)
|
||||
@ -297,9 +309,8 @@ endif()
|
||||
if(WITH_PNG)
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
include_directories(${PNG_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${PNG_LIBRARIES} ${ZLIB_LIBRARIES})
|
||||
add_definitions(-DLAMMPS_PNG)
|
||||
target_link_libraries(lammps PRIVATE PNG::PNG ZLIB::ZLIB)
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_PNG)
|
||||
endif()
|
||||
|
||||
find_program(GZIP_EXECUTABLE gzip)
|
||||
@ -309,7 +320,7 @@ if(WITH_GZIP)
|
||||
if(NOT GZIP_FOUND)
|
||||
message(FATAL_ERROR "gzip executable not found")
|
||||
endif()
|
||||
add_definitions(-DLAMMPS_GZIP)
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_GZIP)
|
||||
endif()
|
||||
|
||||
find_program(FFMPEG_EXECUTABLE ffmpeg)
|
||||
@ -319,7 +330,7 @@ if(WITH_FFMPEG)
|
||||
if(NOT FFMPEG_FOUND)
|
||||
message(FATAL_ERROR "ffmpeg executable not found")
|
||||
endif()
|
||||
add_definitions(-DLAMMPS_FFMPEG)
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_FFMPEG)
|
||||
endif()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
@ -332,29 +343,24 @@ else()
|
||||
set(CUDA_REQUEST_PIC)
|
||||
endif()
|
||||
|
||||
include(Packages/KSPACE)
|
||||
include(Packages/PYTHON)
|
||||
include(Packages/VORONOI)
|
||||
include(Packages/USER-COLVARS)
|
||||
include(Packages/USER-MOLFILE)
|
||||
include(Packages/USER-NETCDF)
|
||||
include(Packages/USER-PLUMED)
|
||||
include(Packages/USER-QMMM)
|
||||
include(Packages/USER-QUIP)
|
||||
include(Packages/USER-SCAFACOS)
|
||||
include(Packages/USER-SMD)
|
||||
include(Packages/USER-VTK)
|
||||
include(Packages/KIM)
|
||||
include(Packages/LATTE)
|
||||
include(Packages/MESSAGE)
|
||||
include(Packages/MSCG)
|
||||
include(Packages/COMPRESS)
|
||||
foreach(PKG_WITH_INCL KSPACE PYTHON VORONOI USER-COLVARS USER-MOLFILE USER-NETCDF USER-PLUMED USER-QMMM
|
||||
USER-QUIP USER-SCAFACOS USER-SMD USER-VTK KIM LATTE MESSAGE MSCG COMPRESS)
|
||||
if(PKG_${PKG_WITH_INCL})
|
||||
include(Packages/${PKG_WITH_INCL})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(CMAKE_TUNE_FLAGS "${CMAKE_TUNE_DEFAULT}" CACHE STRING "Compiler specific optimization or instrumentation")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_TUNE_FLAGS}")
|
||||
if(CMAKE_Fortran_COMPILER)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${CMAKE_TUNE_FLAGS}")
|
||||
endif()
|
||||
separate_arguments(CMAKE_TUNE_FLAGS)
|
||||
include(CheckCXXCompilerFlag)
|
||||
foreach(_FLAG ${CMAKE_TUNE_FLAGS})
|
||||
check_cxx_compiler_flag("${_FLAG}" COMPILER_SUPPORTS${_FLAG})
|
||||
if(COMPILER_SUPPORTS${_FLAG})
|
||||
target_compile_options(lammps PRIVATE ${_FLAG})
|
||||
else()
|
||||
message(WARNING "${_FLAG} found in CMAKE_TUNE_FLAGS, but not supported by the compiler, skipping")
|
||||
endif()
|
||||
endforeach()
|
||||
########################################################################
|
||||
# Basic system tests (standard libraries, headers, functions, types) #
|
||||
########################################################################
|
||||
@ -367,15 +373,7 @@ endforeach(HEADER)
|
||||
|
||||
set(MATH_LIBRARIES "m" CACHE STRING "math library")
|
||||
mark_as_advanced( MATH_LIBRARIES )
|
||||
include(CheckLibraryExists)
|
||||
# RB: disabled this check because it breaks with KOKKOS CUDA enabled
|
||||
#foreach(FUNC sin cos)
|
||||
# check_library_exists(${MATH_LIBRARIES} ${FUNC} "" FOUND_${FUNC}_${MATH_LIBRARIES})
|
||||
# if(NOT FOUND_${FUNC}_${MATH_LIBRARIES})
|
||||
# message(FATAL_ERROR "Could not find needed math function - ${FUNC}")
|
||||
# endif(NOT FOUND_${FUNC}_${MATH_LIBRARIES})
|
||||
#endforeach(FUNC)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${MATH_LIBRARIES})
|
||||
target_link_libraries(lammps PRIVATE ${MATH_LIBRARIES})
|
||||
|
||||
######################################
|
||||
# Generate Basic Style files
|
||||
@ -399,8 +397,8 @@ foreach(PKG ${DEFAULT_PACKAGES})
|
||||
# detects styles in package and adds them to global list
|
||||
RegisterStyles(${${PKG}_SOURCES_DIR})
|
||||
|
||||
list(APPEND LIB_SOURCES ${${PKG}_SOURCES})
|
||||
include_directories(${${PKG}_SOURCES_DIR})
|
||||
target_sources(lammps PRIVATE ${${PKG}_SOURCES})
|
||||
target_include_directories(lammps PRIVATE ${${PKG}_SOURCES_DIR})
|
||||
endif()
|
||||
|
||||
RegisterPackages(${${PKG}_SOURCES_DIR})
|
||||
@ -409,7 +407,7 @@ endforeach()
|
||||
# packages that need defines set
|
||||
foreach(PKG MPIIO)
|
||||
if(PKG_${PKG})
|
||||
add_definitions(-DLMP_${PKG})
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_${PKG})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@ -434,14 +432,14 @@ foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD)
|
||||
string(REGEX REPLACE "^USER-" "" PKG_LIB "${SIMPLE_LIB}")
|
||||
string(TOLOWER "${PKG_LIB}" PKG_LIB)
|
||||
file(GLOB_RECURSE ${PKG_LIB}_SOURCES
|
||||
${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.F
|
||||
${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.c
|
||||
${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.cpp)
|
||||
add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES})
|
||||
if(LAMMPS_USE_MPI4WIN)
|
||||
add_dependencies(${PKG_LIB} mpi4win_build)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS ${PKG_LIB} EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
list(APPEND LAMMPS_LINK_LIBS ${PKG_LIB})
|
||||
set_target_properties(${PKG_LIB} PROPERTIES OUTPUT_NAME lammps_${PKG_LIB}${LAMMPS_LIB_SUFFIX})
|
||||
target_link_libraries(lammps PRIVATE ${PKG_LIB})
|
||||
if(PKG_LIB STREQUAL awpmd)
|
||||
target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include)
|
||||
elseif(PKG_LIB STREQUAL h5md)
|
||||
@ -453,30 +451,31 @@ foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD)
|
||||
endforeach()
|
||||
|
||||
if(PKG_USER-AWPMD)
|
||||
target_link_libraries(awpmd ${LAPACK_LIBRARIES})
|
||||
target_link_libraries(awpmd PRIVATE ${LAPACK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(PKG_USER-ATC)
|
||||
if(LAMMPS_SIZES STREQUAL BIGBIG)
|
||||
message(FATAL_ERROR "The USER-ATC Package is not compatible with -DLAMMPS_BIGBIG")
|
||||
endif()
|
||||
target_link_libraries(atc ${LAPACK_LIBRARIES})
|
||||
target_link_libraries(atc PRIVATE ${LAPACK_LIBRARIES} MPI::MPI_CXX)
|
||||
target_include_directories(atc PRIVATE ${LAMMPS_SOURCE_DIR})
|
||||
target_compile_definitions(atc PRIVATE -DLAMMPS_${LAMMPS_SIZES})
|
||||
endif()
|
||||
|
||||
include(Packages/USER-H5MD)
|
||||
if(PKG_USER-H5MD)
|
||||
include(Packages/USER-H5MD)
|
||||
endif()
|
||||
|
||||
######################################################################
|
||||
# packages which selectively include variants based on enabled styles
|
||||
# e.g. accelerator packages
|
||||
######################################################################
|
||||
include(Packages/CORESHELL)
|
||||
include(Packages/QEQ)
|
||||
include(Packages/USER-OMP)
|
||||
include(Packages/USER-SDPD)
|
||||
include(Packages/KOKKOS)
|
||||
include(Packages/OPT)
|
||||
include(Packages/USER-INTEL)
|
||||
include(Packages/GPU)
|
||||
foreach(PKG_WITH_INCL CORESHELL QEQ USER-OMP USER-SDPD KOKKOS OPT USER-INTEL GPU)
|
||||
if(PKG_${PKG_WITH_INCL})
|
||||
include(Packages/${PKG_WITH_INCL})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
######################################################################
|
||||
# the windows version of LAMMPS requires a couple extra libraries
|
||||
@ -484,10 +483,7 @@ include(Packages/GPU)
|
||||
# and after everything else that is compiled locally
|
||||
######################################################################
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
if(LAMMPS_USE_MPI4WIN)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${MPI4WIN_LIBRARIES})
|
||||
endif()
|
||||
list(APPEND LAMMPS_LINK_LIBS -lwsock32 -lpsapi)
|
||||
target_link_libraries(lammps PRIVATE -lwsock32 -lpsapi)
|
||||
endif()
|
||||
|
||||
######################################################
|
||||
@ -500,7 +496,7 @@ set(LAMMPS_STYLE_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/styles)
|
||||
GenerateStyleHeaders(${LAMMPS_STYLE_HEADERS_DIR})
|
||||
GeneratePackagesHeaders(${LAMMPS_STYLE_HEADERS_DIR})
|
||||
|
||||
include_directories(${LAMMPS_STYLE_HEADERS_DIR})
|
||||
target_include_directories(lammps PRIVATE ${LAMMPS_STYLE_HEADERS_DIR})
|
||||
|
||||
######################################
|
||||
# Generate lmpinstalledpkgs.h
|
||||
@ -529,7 +525,7 @@ add_custom_target(gitversion COMMAND ${CMAKE_COMMAND}
|
||||
-DLAMMPS_STYLE_HEADERS_DIR="${LAMMPS_STYLE_HEADERS_DIR}"
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/Modules/generate_lmpgitversion.cmake)
|
||||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${LAMMPS_STYLE_HEADERS_DIR}/gitversion.h)
|
||||
list(APPEND LAMMPS_DEPS gitversion)
|
||||
add_dependencies(lammps gitversion)
|
||||
|
||||
###########################################
|
||||
# Actually add executable and lib to build
|
||||
@ -537,85 +533,57 @@ list(APPEND LAMMPS_DEPS gitversion)
|
||||
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
list (FIND LANGUAGES "Fortran" _index)
|
||||
if (${_index} GREATER -1)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
|
||||
target_link_libraries(lammps PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
|
||||
endif()
|
||||
list(REMOVE_DUPLICATES LAMMPS_LINK_LIBS)
|
||||
if(BUILD_LIB)
|
||||
add_library(lammps ${LIB_SOURCES})
|
||||
target_link_libraries(lammps ${LAMMPS_LINK_LIBS})
|
||||
if(LAMMPS_DEPS)
|
||||
add_dependencies(lammps ${LAMMPS_DEPS})
|
||||
set(LAMMPS_CXX_HEADERS angle.h atom.h bond.h citeme.h comm.h compute.h dihedral.h domain.h error.h fix.h force.h group.h improper.h
|
||||
input.h info.h kspace.h lammps.h lattice.h library.h lmppython.h lmptype.h memory.h modify.h neighbor.h neigh_list.h output.h
|
||||
pair.h pointers.h region.h timer.h universe.h update.h variable.h)
|
||||
if(LAMMPS_EXCEPTIONS)
|
||||
list(APPEND LAMMPS_CXX_HEADERS exceptions.h)
|
||||
endif()
|
||||
set(LAMMPS_CXX_HEADERS
|
||||
${LAMMPS_SOURCE_DIR}/angle.h
|
||||
${LAMMPS_SOURCE_DIR}/atom.h
|
||||
${LAMMPS_SOURCE_DIR}/bond.h
|
||||
${LAMMPS_SOURCE_DIR}/citeme.h
|
||||
${LAMMPS_SOURCE_DIR}/comm.h
|
||||
${LAMMPS_SOURCE_DIR}/compute.h
|
||||
${LAMMPS_SOURCE_DIR}/dihedral.h
|
||||
${LAMMPS_SOURCE_DIR}/domain.h
|
||||
${LAMMPS_SOURCE_DIR}/error.h
|
||||
${LAMMPS_SOURCE_DIR}/fix.h
|
||||
${LAMMPS_SOURCE_DIR}/force.h
|
||||
${LAMMPS_SOURCE_DIR}/group.h
|
||||
${LAMMPS_SOURCE_DIR}/improper.h
|
||||
${LAMMPS_SOURCE_DIR}/input.h
|
||||
${LAMMPS_SOURCE_DIR}/kspace.h
|
||||
${LAMMPS_SOURCE_DIR}/lammps.h
|
||||
${LAMMPS_SOURCE_DIR}/lattice.h
|
||||
${LAMMPS_SOURCE_DIR}/lmppython.h
|
||||
${LAMMPS_SOURCE_DIR}/memory.h
|
||||
${LAMMPS_SOURCE_DIR}/modify.h
|
||||
${LAMMPS_SOURCE_DIR}/neighbor.h
|
||||
${LAMMPS_SOURCE_DIR}/neigh_list.h
|
||||
${LAMMPS_SOURCE_DIR}/output.h
|
||||
${LAMMPS_SOURCE_DIR}/pair.h
|
||||
${LAMMPS_SOURCE_DIR}/pointers.h
|
||||
${LAMMPS_SOURCE_DIR}/region.h
|
||||
${LAMMPS_SOURCE_DIR}/timer.h
|
||||
${LAMMPS_SOURCE_DIR}/universe.h
|
||||
${LAMMPS_SOURCE_DIR}/update.h
|
||||
${LAMMPS_SOURCE_DIR}/variable.h)
|
||||
|
||||
set_target_properties(lammps PROPERTIES OUTPUT_NAME lammps${LAMMPS_LIB_SUFFIX})
|
||||
set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION})
|
||||
install(TARGETS lammps LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
install(FILES ${LAMMPS_SOURCE_DIR}/library.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps)
|
||||
install(FILES ${LAMMPS_CXX_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps)
|
||||
install(TARGETS lammps EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
target_include_directories(lammps PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps)
|
||||
foreach(_HEADER ${LAMMPS_CXX_HEADERS})
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAMMPS_SOURCE_DIR}/${_HEADER} ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER} DEPENDS ${LAMMPS_SOURCE_DIR}/${_HEADER})
|
||||
add_custom_target(${_HEADER} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER})
|
||||
add_dependencies(lammps ${_HEADER})
|
||||
install(FILES ${LAMMPS_SOURCE_DIR}/${_HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps)
|
||||
endforeach()
|
||||
target_include_directories(lammps INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/includes>)
|
||||
add_library(LAMMPS::lammps ALIAS lammps)
|
||||
get_target_property(LAMMPS_DEFINES lammps INTERFACE_COMPILE_DEFINITIONS)
|
||||
set(LAMMPS_API_DEFINES)
|
||||
foreach(_DEF ${LAMMPS_DEFINES})
|
||||
set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -D${_DEF}")
|
||||
endforeach()
|
||||
configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_LIB_SUFFIX}.pc @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_LIB_SUFFIX}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
configure_file(FindLAMMPS.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindLAMMPS${LAMMPS_LIB_SUFFIX}.cmake @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FindLAMMPS${LAMMPS_LIB_SUFFIX}.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/Modules)
|
||||
else()
|
||||
list(APPEND LMP_SOURCES ${LIB_SOURCES})
|
||||
install(EXPORT LAMMPS_Targets FILE LAMMPS_Targets.cmake NAMESPACE LAMMPS:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS)
|
||||
include(CMakePackageConfigHelpers)
|
||||
configure_file(LAMMPSConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake @ONLY)
|
||||
write_basic_package_version_file("LAMMPSConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY ExactVersion)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS)
|
||||
endif()
|
||||
|
||||
if(BUILD_EXE)
|
||||
add_executable(lmp ${LMP_SOURCES})
|
||||
if(BUILD_LIB)
|
||||
target_link_libraries(lmp lammps)
|
||||
else()
|
||||
target_link_libraries(lmp ${LAMMPS_LINK_LIBS})
|
||||
if(LAMMPS_DEPS)
|
||||
add_dependencies(lmp ${LAMMPS_DEPS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_target_properties(lmp PROPERTIES OUTPUT_NAME ${LAMMPS_BINARY})
|
||||
install(TARGETS lmp DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(FILES ${LAMMPS_DOC_DIR}/lammps.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME ${LAMMPS_BINARY}.1)
|
||||
endif()
|
||||
|
||||
if(BUILD_TOOLS)
|
||||
add_executable(binary2txt ${LAMMPS_TOOLS_DIR}/binary2txt.cpp)
|
||||
target_compile_definitions(binary2txt PRIVATE -DLAMMPS_${LAMMPS_SIZES})
|
||||
install(TARGETS binary2txt DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
include(CheckGeneratorSupport)
|
||||
if(CMAKE_GENERATOR_SUPPORT_FORTRAN)
|
||||
enable_language(Fortran)
|
||||
add_executable(chain.x ${LAMMPS_TOOLS_DIR}/chain.f)
|
||||
target_link_libraries(chain.x ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
|
||||
target_link_libraries(chain.x PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
|
||||
install(TARGETS chain.x DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
else()
|
||||
message(WARNING "CMake build doesn't support fortran, skipping building 'chain.x'")
|
||||
@ -625,7 +593,7 @@ if(BUILD_TOOLS)
|
||||
get_filename_component(MSI2LMP_SOURCE_DIR ${LAMMPS_TOOLS_DIR}/msi2lmp/src ABSOLUTE)
|
||||
file(GLOB MSI2LMP_SOURCES ${MSI2LMP_SOURCE_DIR}/[^.]*.c)
|
||||
add_executable(msi2lmp ${MSI2LMP_SOURCES})
|
||||
target_link_libraries(msi2lmp m)
|
||||
target_link_libraries(msi2lmp PRIVATE ${MATH_LIBRARIES})
|
||||
install(TARGETS msi2lmp DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(FILES ${LAMMPS_DOC_DIR}/msi2lmp.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
||||
endif()
|
||||
@ -656,8 +624,12 @@ install(
|
||||
# This is primarily for people that only want to use the Python wrapper.
|
||||
###############################################################################
|
||||
if(BUILD_LIB AND BUILD_SHARED_LIBS)
|
||||
find_package(PythonInterp)
|
||||
if (PYTHONINTERP_FOUND)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.12)
|
||||
find_package(PythonInterp) # Deprecated since version 3.12
|
||||
else()
|
||||
find_package(Python COMPONENTS Interpreter)
|
||||
endif()
|
||||
if (PYTHON_EXECUTABLE)
|
||||
add_custom_target(
|
||||
install-python
|
||||
${PYTHON_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h
|
||||
@ -682,8 +654,12 @@ endif()
|
||||
# This requires either a shared library or that the PYTHON package is included.
|
||||
###############################################################################
|
||||
if((BUILD_LIB AND BUILD_SHARED_LIBS) OR (PKG_PYTHON))
|
||||
find_package(PythonInterp)
|
||||
if (PYTHONINTERP_FOUND)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.12)
|
||||
find_package(PythonInterp) # Deprecated since version 3.12
|
||||
else()
|
||||
find_package(Python COMPONENTS Interpreter)
|
||||
endif()
|
||||
if (PYTHON_EXECUTABLE)
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE}
|
||||
-c "import distutils.sysconfig as cg; print(cg.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}'))"
|
||||
OUTPUT_VARIABLE PYTHON_DEFAULT_INSTDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
@ -704,61 +680,79 @@ foreach(PKG ${DEFAULT_PACKAGES} ${ACCEL_PACKAGES})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
get_directory_property(CPPFLAGS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS)
|
||||
get_target_property(DEFINES lammps COMPILE_DEFINITIONS)
|
||||
include(FeatureSummary)
|
||||
feature_summary(DESCRIPTION "The following tools and libraries have been found and configured:" WHAT PACKAGES_FOUND)
|
||||
message(STATUS "<<< Build configuration >>>
|
||||
Build type ${CMAKE_BUILD_TYPE}
|
||||
Install path ${CMAKE_INSTALL_PREFIX}
|
||||
Generator ${CMAKE_GENERATOR} using ${CMAKE_MAKE_PROGRAM}
|
||||
Compilers and Flags:
|
||||
C++ Compiler ${CMAKE_CXX_COMPILER}
|
||||
Type ${CMAKE_CXX_COMPILER_ID}
|
||||
Version ${CMAKE_CXX_COMPILER_VERSION}
|
||||
C++ Flags ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}
|
||||
Defines ${CPPFLAGS}")
|
||||
Build type: ${CMAKE_BUILD_TYPE}
|
||||
Install path: ${CMAKE_INSTALL_PREFIX}
|
||||
Generator: ${CMAKE_GENERATOR} using ${CMAKE_MAKE_PROGRAM}
|
||||
-- <<< Compilers and Flags: >>>
|
||||
-- C++ Compiler: ${CMAKE_CXX_COMPILER}
|
||||
Type: ${CMAKE_CXX_COMPILER_ID}
|
||||
Version: ${CMAKE_CXX_COMPILER_VERSION}
|
||||
C++ Flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}
|
||||
Defines: ${DEFINES}")
|
||||
get_target_property(OPTIONS lammps COMPILE_OPTIONS)
|
||||
if(OPTIONS)
|
||||
message(" Options: ${OPTIONS}")
|
||||
endif()
|
||||
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
list (FIND LANGUAGES "Fortran" _index)
|
||||
if (${_index} GREATER -1)
|
||||
message(STATUS "Fortran Compiler ${CMAKE_Fortran_COMPILER}
|
||||
Type ${CMAKE_Fortran_COMPILER_ID}
|
||||
Version ${CMAKE_Fortran_COMPILER_VERSION}
|
||||
Fortran Flags ${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}")
|
||||
message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER}
|
||||
Type: ${CMAKE_Fortran_COMPILER_ID}
|
||||
Version: ${CMAKE_Fortran_COMPILER_VERSION}
|
||||
Fortran Flags:${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}")
|
||||
endif()
|
||||
list (FIND LANGUAGES "C" _index)
|
||||
if (${_index} GREATER -1)
|
||||
message(STATUS "C compiler ${CMAKE_C_COMPILER}
|
||||
Type ${CMAKE_C_COMPILER_ID}
|
||||
Version ${CMAKE_C_COMPILER_VERSION}
|
||||
C Flags ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BTYPE}}")
|
||||
message(STATUS "C compiler: ${CMAKE_C_COMPILER}
|
||||
Type: ${CMAKE_C_COMPILER_ID}
|
||||
Version: ${CMAKE_C_COMPILER_VERSION}
|
||||
C Flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BTYPE}}")
|
||||
endif()
|
||||
message(STATUS "<<< Linker flags: >>>")
|
||||
if(BUILD_EXE)
|
||||
message(STATUS "Executable name: ${LAMMPS_BINARY}")
|
||||
endif()
|
||||
if(CMAKE_EXE_LINKER_FLAGS)
|
||||
message(STATUS "Linker flags:
|
||||
Executable ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
message(STATUS "Executable linker flags: ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
endif()
|
||||
if(BUILD_SHARED_LIBS)
|
||||
message(STATUS "Shared library flags: ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
message(STATUS "Shared library flags: ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
else()
|
||||
message(STATUS "Static library flags: ${CMAKE_STATIC_LINKER_FLAGS}")
|
||||
message(STATUS "Static library flags: ${CMAKE_STATIC_LINKER_FLAGS}")
|
||||
endif()
|
||||
message(STATUS "Link libraries: ${LAMMPS_LINK_LIBS}")
|
||||
if(BUILD_MPI)
|
||||
message(STATUS "Using MPI with headers in ${MPI_CXX_INCLUDE_PATH} and these libraries: ${MPI_CXX_LIBRARIES};${MPI_Fortran_LIBRARIES}")
|
||||
message(STATUS "<<< MPI flags >>>
|
||||
-- MPI includes: ${MPI_CXX_INCLUDE_PATH}
|
||||
-- MPI libraries: ${MPI_CXX_LIBRARIES};${MPI_Fortran_LIBRARIES}")
|
||||
endif()
|
||||
if(PKG_GPU)
|
||||
message(STATUS "GPU API: ${GPU_API}")
|
||||
message(STATUS "<<< GPU package settings >>>
|
||||
-- GPU API: ${GPU_API}")
|
||||
if(GPU_API STREQUAL "CUDA")
|
||||
message(STATUS "GPU architecture: ${GPU_ARCH}")
|
||||
elseif(GPU_API STREQUAL "OPENCL")
|
||||
message(STATUS "OpenCL parameter tuning: ${OCL_TUNE}")
|
||||
message(STATUS "OpenCL tuning: ${OCL_TUNE}")
|
||||
elseif(GPU_API STREQUAL "HIP")
|
||||
message(STATUS "HIP platform: ${HIP_PLATFORM}")
|
||||
message(STATUS "HIP architecture: ${HIP_ARCH}")
|
||||
if(HIP_USE_DEVICE_SORT)
|
||||
message(STATUS "HIP GPU sorting: on")
|
||||
else()
|
||||
message(STATUS "HIP GPU sorting: off")
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "GPU precision: ${GPU_PREC}")
|
||||
message(STATUS "GPU precision: ${GPU_PREC}")
|
||||
endif()
|
||||
if(PKG_KOKKOS)
|
||||
message(STATUS "Kokkos Arch: ${KOKKOS_ARCH}")
|
||||
endif()
|
||||
if(PKG_KSPACE)
|
||||
message(STATUS "Using ${FFT} as primary FFT library")
|
||||
message(STATUS "<<< FFT settings >>>
|
||||
-- Primary FFT lib: ${FFT}")
|
||||
if(FFT_SINGLE)
|
||||
message(STATUS "Using single precision FFTs")
|
||||
else()
|
||||
@ -770,7 +764,7 @@ if(PKG_KSPACE)
|
||||
message(STATUS "Using non-threaded FFTs")
|
||||
endif()
|
||||
if(PKG_KOKKOS)
|
||||
if(KOKKOS_ENABLE_CUDA)
|
||||
if(Kokkos_ENABLE_CUDA)
|
||||
if (${FFT} STREQUAL "KISS")
|
||||
message(STATUS "Kokkos FFT: KISS")
|
||||
else()
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
# - Find liblammps
|
||||
# Find the native liblammps headers and libraries.
|
||||
#
|
||||
# The following variables will set:
|
||||
# LAMMPS_INCLUDE_DIRS - where to find lammps/library.h, etc.
|
||||
# LAMMPS_LIBRARIES - List of libraries when using lammps.
|
||||
# LAMMPS_API_DEFINES - lammps library api defines
|
||||
# LAMMPS_VERSION - lammps library version
|
||||
# LAMMPS_FOUND - True if liblammps found.
|
||||
#
|
||||
# In addition a LAMMPS::LAMMPS imported target is getting created.
|
||||
#
|
||||
# LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
# http://lammps.sandia.gov, Sandia National Laboratories
|
||||
# Steve Plimpton, sjplimp@sandia.gov
|
||||
#
|
||||
# Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
# certain rights in this software. This software is distributed under
|
||||
# the GNU General Public License.
|
||||
#
|
||||
# See the README file in the top-level LAMMPS directory.
|
||||
#
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
pkg_check_modules(PC_LAMMPS liblammps@LAMMPS_LIB_SUFFIX@)
|
||||
find_path(LAMMPS_INCLUDE_DIR lammps/library.h HINTS ${PC_LAMMPS_INCLUDE_DIRS} @CMAKE_INSTALL_FULL_INCLUDEDIR@)
|
||||
|
||||
set(LAMMPS_VERSION @LAMMPS_VERSION@)
|
||||
set(LAMMPS_API_DEFINES @LAMMPS_API_DEFINES@)
|
||||
|
||||
find_library(LAMMPS_LIBRARY NAMES lammps@LAMMPS_LIB_SUFFIX@ HINTS ${PC_LAMMPS_LIBRARY_DIRS} @CMAKE_INSTALL_FULL_LIBDIR@)
|
||||
|
||||
set(LAMMPS_INCLUDE_DIRS "${LAMMPS_INCLUDE_DIR}")
|
||||
set(LAMMPS_LIBRARIES "${LAMMPS_LIBRARY}")
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set LAMMPS_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(LAMMPS REQUIRED_VARS LAMMPS_LIBRARY LAMMPS_INCLUDE_DIR VERSION_VAR LAMMPS_VERSION)
|
||||
|
||||
mark_as_advanced(LAMMPS_INCLUDE_DIR LAMMPS_LIBRARY)
|
||||
|
||||
if(LAMMPS_FOUND AND NOT TARGET LAMMPS::LAMMPS)
|
||||
add_library(LAMMPS::LAMMPS UNKNOWN IMPORTED)
|
||||
set_target_properties(LAMMPS::LAMMPS PROPERTIES IMPORTED_LOCATION "${LAMMPS_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${LAMMPS_INCLUDE_DIR}" INTERFACE_COMPILE_DEFINITIONS "${LAMMPS_API_DEFINES}")
|
||||
endif()
|
||||
96
cmake/LAMMPSConfig.cmake.in
Normal file
96
cmake/LAMMPSConfig.cmake.in
Normal file
@ -0,0 +1,96 @@
|
||||
include(CMakeFindDependencyMacro)
|
||||
if(@BUILD_MPI@)
|
||||
find_dependency(MPI REQUIRED CXX)
|
||||
endif()
|
||||
if(@PKG_KSPACE@)
|
||||
if(@FFT@ STREQUAL "FFTW3")
|
||||
if(@FFTW@ STREQUAL "FFTW3" AND NOT TARGET FFTW3::FFTW3)
|
||||
add_library(FFTW3::FFTW3 UNKNOWN IMPORTED)
|
||||
set_target_properties(FFTW3::FFTW3 PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "@FFTW3_LIBRARY@"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "@FFTW3_INCLUDE_DIRS@")
|
||||
endif()
|
||||
if(@FFTW@ STREQUAL "FFTW3F" AND NOT TARGET FFTW3F::FFTW3F)
|
||||
add_library(FFTW3F::FFTW3F UNKNOWN IMPORTED)
|
||||
set_target_properties(FFTW3F::FFTW3F PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "@FFTW3F_LIBRARY@"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "@FFTW3F_INCLUDE_DIRS@")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(NOT @BUILD_SHARED_LIBS@)
|
||||
if(@WITH_JPEG@)
|
||||
find_dependency(JPEG REQUIRED)
|
||||
endif()
|
||||
if(@WITH_PNG@)
|
||||
find_dependency(PNG REQUIRED)
|
||||
find_dependency(ZLIB REQUIRED)
|
||||
endif()
|
||||
if(@PKG_KIM@ AND NOT @DOWNLOAD_KIM@)
|
||||
find_dependency(PkgConfig REQUIRED)
|
||||
pkg_check_modules(KIM-API REQUIRED IMPORTED_TARGET libkim-api>=@KIM-API_MIN_VERSION@)
|
||||
if(@CURL_FOUND@)
|
||||
find_dependency(CURL REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
if(@PKG_USER-SMD@ AND NOT @DOWNLOAD_EIGEN3@)
|
||||
find_dependency(Eigen3 NO_MODULE REQUIRED)
|
||||
endif()
|
||||
if(@PKG_KSPACE@)
|
||||
if(@FFT@ STREQUAL "FFTW3" AND @FFT_FFTW_THREADS@)
|
||||
if(@FFTW@ STREQUAL "FFTW3" AND NOT TARGET FFTW3::FFTW3_OMP)
|
||||
add_library(FFTW3::FFTW3_OMP UNKNOWN IMPORTED)
|
||||
set_target_properties(FFTW3::FFTW3_OMP PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "@FFTW3_OMP_LIBRARY@"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "@FFTW3_OMP_INCLUDE_DIRS@")
|
||||
endif()
|
||||
if(@FFTW@ STREQUAL "FFTW3F" AND NOT TARGET FFTW3F::FFTW3F_OMP)
|
||||
add_library(FFTW3F::FFTW3F_OMP UNKNOWN IMPORTED)
|
||||
set_target_properties(FFTW3F::FFTW3F_OMP PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "@FFTW3F_OMP_LIBRARY@"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "@FFTW3F_OMP_INCLUDE_DIRS@")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(@PKG_USER-SCAFACOS@ AND NOT @DOWNLOAD_SCAFACOS@)
|
||||
find_dependency(PkgConfig REQUIRED)
|
||||
pkg_check_modules(SCAFACOS REQUIRED IMPORTED_TARGET scafacos)
|
||||
endif()
|
||||
if(@PKG_PYTHON@ AND NOT CMAKE_VERSION VERSION_LESS 3.12)
|
||||
find_package(Python REQUIRED COMPONENTS Development)
|
||||
endif()
|
||||
if(@PKG_COMPRESS@)
|
||||
find_dependency(ZLIB REQUIRED)
|
||||
endif()
|
||||
if(@PKG_KOKKOS@)
|
||||
if(@EXTERNAL_KOKKOS@)
|
||||
find_dependency(Kokkos 3 REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
if(@PKG_VORONOI@ AND NOT @DOWNLOAD_VORO@)
|
||||
if(NOT TARGET VORO::VORO)
|
||||
add_library(VORO::VORO UNKNOWN IMPORTED)
|
||||
set_target_properties(VORO::VORO PROPERTIES
|
||||
IMPORTED_LOCATION "@VORO_LIBRARY@"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "@VORO_INCLUDE_DIR@")
|
||||
endif()
|
||||
endif()
|
||||
if(@PKG_USER-INTEL@)
|
||||
if(@INTEL_LRT_MODE@ STREQUAL "THREADS")
|
||||
find_dependency(Threads REQUIRED)
|
||||
endif()
|
||||
if(@TBB_MALLOC_FOUND@)
|
||||
if(NOT TARGET TBB::TBB_MALLOC)
|
||||
add_library(TBB::TBB_MALLOC UNKNOWN IMPORTED)
|
||||
set_target_properties(TBB::TBB_MALLOC PROPERTIES
|
||||
IMPORTED_LOCATION "@TBB_MALLOC_LIBRARY@"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "@TBB_MALLOC_INCLUDE_DIR@")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/LAMMPS_Targets.cmake")
|
||||
16
cmake/Modules/FindCUB.cmake
Normal file
16
cmake/Modules/FindCUB.cmake
Normal file
@ -0,0 +1,16 @@
|
||||
# - Find CUB
|
||||
# Find the CUB header library
|
||||
#
|
||||
# CUB_INCLUDE_DIRS - where to find cub/cub.cuh
|
||||
# CUB_FOUND - True if CUB found.
|
||||
#
|
||||
|
||||
find_path(CUB_INCLUDE_DIR cub.cuh PATH_SUFFIXES cub)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set CUB_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
|
||||
find_package_handle_standard_args(CUB DEFAULT_MSG CUB_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(CUB_INCLUDE_DIR)
|
||||
@ -14,14 +14,34 @@ find_path(FFTW3_INCLUDE_DIR fftw3.h HINTS ${PC_FFTW3_INCLUDE_DIRS})
|
||||
find_library(FFTW3_LIBRARY NAMES fftw3 HINTS ${PC_FFTW3_LIBRARY_DIRS})
|
||||
find_library(FFTW3_OMP_LIBRARY NAMES fftw3_omp HINTS ${PC_FFTW3_LIBRARY_DIRS})
|
||||
|
||||
set(FFTW3_INCLUDE_DIRS ${FFTW3_INCLUDE_DIR})
|
||||
set(FFTW3_LIBRARIES ${FFTW3_LIBRARY})
|
||||
set(FFTW3_OMP_LIBRARIES ${FFTW3_OMP_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
|
||||
find_package_handle_standard_args(FFTW3 DEFAULT_MSG FFTW3_LIBRARY FFTW3_INCLUDE_DIR)
|
||||
|
||||
# Copy the results to the output variables and target.
|
||||
if(FFTW3_FOUND)
|
||||
set(FFTW3_LIBRARIES ${FFTW3_LIBRARY} )
|
||||
set(FFTW3_INCLUDE_DIRS ${FFTW3_INCLUDE_DIR} )
|
||||
|
||||
if(NOT TARGET FFTW3::FFTW3)
|
||||
add_library(FFTW3::FFTW3 UNKNOWN IMPORTED)
|
||||
set_target_properties(FFTW3::FFTW3 PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${FFTW3_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIRS}")
|
||||
endif()
|
||||
if(FFTW3_OMP_LIBRARY)
|
||||
set(FFTW3_OMP_LIBRARIES ${FFTW3_OMP_LIBRARY})
|
||||
if(NOT TARGET FFTW3::FFTW3_OMP)
|
||||
add_library(FFTW3::FFTW3_OMP UNKNOWN IMPORTED)
|
||||
set_target_properties(FFTW3::FFTW3_OMP PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${FFTW3_OMP_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${FFTW3_INCLUDE_DIRS}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(FFTW3_INCLUDE_DIR FFTW3_LIBRARY FFTW3_OMP_LIBRARY)
|
||||
|
||||
@ -13,14 +13,34 @@ find_path(FFTW3F_INCLUDE_DIR fftw3.h HINTS ${PC_FFTW3F_INCLUDE_DIRS})
|
||||
find_library(FFTW3F_LIBRARY NAMES fftw3f HINTS ${PC_FFTW3F_LIBRARY_DIRS})
|
||||
find_library(FFTW3F_OMP_LIBRARY NAMES fftw3f_omp HINTS ${PC_FFTW3F_LIBRARY_DIRS})
|
||||
|
||||
set(FFTW3F_INCLUDE_DIRS ${FFTW3F_INCLUDE_DIR})
|
||||
set(FFTW3F_LIBRARIES ${FFTW3F_LIBRARY})
|
||||
set(FFTW3F_OMP_LIBRARIES ${FFTW3F_OMP_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set FFTW3F_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
|
||||
find_package_handle_standard_args(FFTW3F DEFAULT_MSG FFTW3F_LIBRARY FFTW3F_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY)
|
||||
# Copy the results to the output variables and target.
|
||||
if(FFTW3F_FOUND)
|
||||
set(FFTW3F_LIBRARIES ${FFTW3F_LIBRARY} )
|
||||
set(FFTW3F_INCLUDE_DIRS ${FFTW3F_INCLUDE_DIR} )
|
||||
|
||||
if(NOT TARGET FFTW3F::FFTW3F)
|
||||
add_library(FFTW3F::FFTW3F UNKNOWN IMPORTED)
|
||||
set_target_properties(FFTW3F::FFTW3F PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${FFTW3F_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${FFTW3F_INCLUDE_DIRS}")
|
||||
endif()
|
||||
if(FFTW3F_OMP_LIBRARY)
|
||||
set(FFTW3F_OMP_LIBRARIES ${FFTW3F_OMP_LIBRARY})
|
||||
if(NOT TARGET FFTW3F::FFTW3F_OMP)
|
||||
add_library(FFTW3F::FFTW3F_OMP UNKNOWN IMPORTED)
|
||||
set_target_properties(FFTW3F::FFTW3F_OMP PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${FFTW3F_OMP_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${FFTW3F_INCLUDE_DIRS}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(FFTW3F_INCLUDE_DIR FFTW3F_LIBRARY FFTW3F_OMP_LIBRARY)
|
||||
|
||||
@ -1,85 +0,0 @@
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the Common Development
|
||||
# and Distribution License Version 1.0 (the "License").
|
||||
#
|
||||
# You can obtain a copy of the license at
|
||||
# http://www.opensource.org/licenses/CDDL-1.0. See the License for the
|
||||
# specific language governing permissions and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each file and
|
||||
# include the License file in a prominent location with the name LICENSE.CDDL.
|
||||
# If applicable, add the following below this CDDL HEADER, with the fields
|
||||
# enclosed by brackets "[]" replaced with your own identifying information:
|
||||
#
|
||||
# Portions Copyright (c) [yyyy] [name of copyright owner]. All rights reserved.
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013--2019, Regents of the University of Minnesota.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Contributors:
|
||||
# Richard Berger
|
||||
# Christoph Junghans
|
||||
# Ryan S. Elliott
|
||||
#
|
||||
|
||||
# - Find KIM-API
|
||||
#
|
||||
# sets standard pkg_check_modules variables plus:
|
||||
#
|
||||
# KIM-API-CMAKE_C_COMPILER
|
||||
# KIM-API-CMAKE_CXX_COMPILER
|
||||
# KIM-API-CMAKE_Fortran_COMPILER
|
||||
#
|
||||
|
||||
function(_KIMAPI_GET_VERSION _OUT_ver _version_hdr)
|
||||
if(NOT EXISTS ${_version_hdr})
|
||||
message(FATAL_ERROR "Header file ${_version_hdr} not found (check value of KIM-API_INCLUDE_DIR)")
|
||||
endif()
|
||||
foreach(_var KIM_VERSION_MAJOR KIM_VERSION_MINOR KIM_VERSION_PATCH)
|
||||
file(STRINGS ${_version_hdr} _contents REGEX "#define ${_var}[ \t]+")
|
||||
if(_contents)
|
||||
string(REGEX REPLACE ".*#define ${_var}[ \t]+([0-9]+).*" "\\1" _${_var} "${_contents}")
|
||||
if(${_${_var}} STREQUAL "")
|
||||
message(FATAL_ERROR "Version parsing failed for ${_var} in ${_version_hdr}, got empty return!")
|
||||
elseif(NOT ${_${_var}} MATCHES "^[0-9]+$")
|
||||
message(FATAL_ERROR "Version parsing failed for ${_var} in ${_version_hdr}, excepted a number but got ${_${_var}}!")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "No ${_var} line found in include file ${_version_hdr}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(${_OUT_ver} ${_KIM_VERSION_MAJOR}.${_KIM_VERSION_MINOR}.${_KIM_VERSION_PATCH} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if(KIM-API_FIND_QUIETLY)
|
||||
set(REQ_OR_QUI "QUIET")
|
||||
else()
|
||||
set(REQ_OR_QUI "REQUIRED")
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig ${REQ_OR_QUI})
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
pkg_check_modules(KIM-API ${REQ_OR_QUI} libkim-api>=2.0)
|
||||
|
||||
if(KIM-API_FOUND)
|
||||
pkg_get_variable(KIM-API-CMAKE_C_COMPILER libkim-api CMAKE_C_COMPILER)
|
||||
pkg_get_variable(KIM-API-CMAKE_CXX_COMPILER libkim-api CMAKE_CXX_COMPILER)
|
||||
pkg_get_variable(KIM-API_CMAKE_Fortran_COMPILER libkim-api CMAKE_Fortran_COMPILER)
|
||||
endif()
|
||||
|
||||
if(KIM-API_INCLUDEDIR)
|
||||
_KIMAPI_GET_VERSION(KIM-API_VERSION ${KIM-API_INCLUDEDIR}/KIM_Version.h)
|
||||
else()
|
||||
set(KIM-API_VERSION 0)
|
||||
endif()
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set KIM-API_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(KIM-API REQUIRED_VARS KIM-API_LIBRARIES VERSION_VAR KIM-API_VERSION)
|
||||
@ -7,12 +7,21 @@
|
||||
|
||||
find_library(LATTE_LIBRARY NAMES latte)
|
||||
|
||||
set(LATTE_LIBRARIES ${LATTE_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set LATTE_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
|
||||
find_package_handle_standard_args(LATTE DEFAULT_MSG LATTE_LIBRARY)
|
||||
|
||||
# Copy the results to the output variables and target.
|
||||
if(LATTE_FOUND)
|
||||
set(LATTE_LIBRARIES ${LATTE_LIBRARY})
|
||||
|
||||
if(NOT TARGET LATTE::latte)
|
||||
add_library(LATTE::latte UNKNOWN IMPORTED)
|
||||
set_target_properties(LATTE::latte PROPERTIES
|
||||
IMPORTED_LOCATION "${LATTE_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(LATTE_LIBRARY)
|
||||
|
||||
@ -10,13 +10,22 @@ find_path(MKL_INCLUDE_DIR mkl_dfti.h HINTS $ENV{MKLROOT}/include)
|
||||
|
||||
find_library(MKL_LIBRARY NAMES mkl_rt HINTS $ENV{MKLROOT}/lib $ENV{MKLROOT}/lib/intel64)
|
||||
|
||||
set(MKL_LIBRARIES ${MKL_LIBRARY})
|
||||
set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set MKL_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
|
||||
find_package_handle_standard_args(MKL DEFAULT_MSG MKL_LIBRARY MKL_INCLUDE_DIR)
|
||||
|
||||
if(MKL_FOUND)
|
||||
set(MKL_LIBRARIES ${MKL_LIBRARY})
|
||||
set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR})
|
||||
|
||||
if(NOT TARGET MKL::MKL)
|
||||
add_library(MKL::MKL UNKNOWN IMPORTED)
|
||||
set_target_properties(MKL::MKL PROPERTIES
|
||||
IMPORTED_LOCATION "${MKL_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${MKL_INCLUDE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(MKL_INCLUDE_DIR MKL_LIBRARY )
|
||||
|
||||
@ -10,13 +10,23 @@ find_path(MSCG_INCLUDE_DIR mscg.h PATH_SUFFIXES mscg)
|
||||
|
||||
find_library(MSCG_LIBRARY NAMES mscg)
|
||||
|
||||
set(MSCG_LIBRARIES ${MSCG_LIBRARY})
|
||||
set(MSCG_INCLUDE_DIRS ${MSCG_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set MSCG_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
|
||||
find_package_handle_standard_args(MSCG DEFAULT_MSG MSCG_LIBRARY MSCG_INCLUDE_DIR)
|
||||
|
||||
# Copy the results to the output variables and target.
|
||||
if(MSCG_FOUND)
|
||||
set(MSCG_LIBRARIES ${MSCG_LIBRARY})
|
||||
set(MSCG_INCLUDE_DIRS ${MSCG_INCLUDE_DIR})
|
||||
|
||||
if(NOT TARGET MSCG::MSCG)
|
||||
add_library(MSCG::MSCG UNKNOWN IMPORTED)
|
||||
set_target_properties(MSCG::MSCG PROPERTIES
|
||||
IMPORTED_LOCATION "${MSCG_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${MSCG_INCLUDE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(MSCG_INCLUDE_DIR MSCG_LIBRARY )
|
||||
|
||||
@ -120,3 +120,14 @@ set (NETCDF_INCLUDE_DIRS ${NetCDF_includes})
|
||||
include (FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (NetCDF
|
||||
DEFAULT_MSG NETCDF_LIBRARIES NETCDF_INCLUDE_DIRS NETCDF_HAS_INTERFACES)
|
||||
|
||||
# Copy the results to the output variables and target.
|
||||
if(NetCDF_FOUND)
|
||||
if(NOT TARGET NetCDF::NetCDF)
|
||||
add_library(NetCDF::NetCDF UNKNOWN IMPORTED)
|
||||
set_target_properties(NetCDF::NetCDF PROPERTIES
|
||||
IMPORTED_LOCATION "${NETCDF_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${NETCDF_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${NETCDF_LIBRARIES}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -53,3 +53,12 @@ include (FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (PNetCDF DEFAULT_MSG PNETCDF_LIBRARIES PNETCDF_INCLUDES)
|
||||
|
||||
mark_as_advanced (PNETCDF_LIBRARIES PNETCDF_INCLUDES)
|
||||
|
||||
if(PNetCDF_FOUND)
|
||||
if(NOT TARGET PNetCDF::PNetCDF)
|
||||
add_library(PNetCDF::PNetCDF UNKNOWN IMPORTED)
|
||||
set_target_properties(PNetCDF::PNetCDF PROPERTIES
|
||||
IMPORTED_LOCATION "${PNETCDF_LIBRARIES}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${PNETCDF_INCLUDES}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -7,12 +7,21 @@
|
||||
|
||||
find_library(QUIP_LIBRARY NAMES quip)
|
||||
|
||||
set(QUIP_LIBRARIES ${QUIP_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set QUIP_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
|
||||
find_package_handle_standard_args(QUIP DEFAULT_MSG QUIP_LIBRARY)
|
||||
|
||||
# Copy the results to the output variables and target.
|
||||
if(QUIP_FOUND)
|
||||
set(QUIP_LIBRARIES ${QUIP_LIBRARY})
|
||||
|
||||
if(NOT TARGET QUIP::QUIP)
|
||||
add_library(QUIP::QUIP UNKNOWN IMPORTED)
|
||||
set_target_properties(QUIP::QUIP PROPERTIES
|
||||
IMPORTED_LOCATION "${QUIP_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(QUIP_LIBRARY)
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
# - Find parts of TBB
|
||||
# Find the native TBB headers and libraries.
|
||||
#
|
||||
# TBB_INCLUDE_DIRS - where to find tbb.h, etc.
|
||||
# TBB_LIBRARIES - List of libraries when using tbb.
|
||||
# TBB_FOUND - True if tbb found.
|
||||
#
|
||||
|
||||
########################################################
|
||||
# TBB
|
||||
|
||||
# TODO use more generic FindTBB
|
||||
|
||||
find_path(TBB_INCLUDE_DIR NAMES tbb/tbb.h PATHS $ENV{TBBROOT}/include)
|
||||
find_library(TBB_LIBRARY NAMES tbb PATHS $ENV{TBBROOT}/lib/intel64/gcc4.7
|
||||
$ENV{TBBROOT}/lib/intel64/gcc4.4
|
||||
$ENV{TBBROOT}/lib/intel64/gcc4.1)
|
||||
set(TBB_LIBRARIES ${TBB_LIBRARY})
|
||||
set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set TBB_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
|
||||
find_package_handle_standard_args(TBB DEFAULT_MSG TBB_LIBRARY TBB_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(TBB_INCLUDE_DIR TBB_LIBRARY )
|
||||
|
||||
########################################################
|
||||
# TBB Malloc
|
||||
|
||||
find_path(TBB_MALLOC_INCLUDE_DIR NAMES tbb/tbb.h PATHS $ENV{TBBROOT}/include)
|
||||
find_library(TBB_MALLOC_LIBRARY NAMES tbbmalloc PATHS $ENV{TBBROOT}/lib/intel64/gcc4.7
|
||||
$ENV{TBBROOT}/lib/intel64/gcc4.4
|
||||
$ENV{TBBROOT}/lib/intel64/gcc4.1)
|
||||
|
||||
set(TBB_MALLOC_LIBRARIES ${TBB_MALLOC_LIBRARY})
|
||||
set(TBB_MALLOC_INCLUDE_DIRS ${TBB_MALLOC_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set TBB_MALLOC_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
|
||||
find_package_handle_standard_args(TBB_MALLOC DEFAULT_MSG TBB_MALLOC_LIBRARY TBB_MALLOC_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(TBB_MALLOC_INCLUDE_DIR TBB_MALLOC_LIBRARY )
|
||||
36
cmake/Modules/FindTBB_MALLOC.cmake
Normal file
36
cmake/Modules/FindTBB_MALLOC.cmake
Normal file
@ -0,0 +1,36 @@
|
||||
# - Find parts of TBB_MALLOC
|
||||
# Find the native TBB_MALLOC headers and libraries.
|
||||
#
|
||||
# TBB_MALLOC_INCLUDE_DIRS - where to find tbb.h, etc.
|
||||
# TBB_MALLOC_LIBRARIES - List of libraries when using tbb.
|
||||
# TBB_MALLOC_FOUND - True if tbb found.
|
||||
#
|
||||
|
||||
|
||||
########################################################
|
||||
# TBB Malloc
|
||||
|
||||
find_path(TBB_MALLOC_INCLUDE_DIR NAMES tbb/tbb.h PATHS $ENV{TBBROOT}/include)
|
||||
find_library(TBB_MALLOC_LIBRARY NAMES tbbmalloc PATHS $ENV{TBBROOT}/lib/intel64/gcc4.7
|
||||
$ENV{TBBROOT}/lib/intel64/gcc4.4
|
||||
$ENV{TBBROOT}/lib/intel64/gcc4.1)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set TBB_MALLOC_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
|
||||
find_package_handle_standard_args(TBB_MALLOC DEFAULT_MSG TBB_MALLOC_LIBRARY TBB_MALLOC_INCLUDE_DIR)
|
||||
|
||||
if(TBB_MALLOC_FOUND)
|
||||
set(TBB_MALLOC_LIBRARIES ${TBB_MALLOC_LIBRARY})
|
||||
set(TBB_MALLOC_INCLUDE_DIRS ${TBB_MALLOC_INCLUDE_DIR})
|
||||
|
||||
if(NOT TARGET TBB::TBB_MALLOC)
|
||||
add_library(TBB::TBB_MALLOC UNKNOWN IMPORTED)
|
||||
set_target_properties(TBB::TBB_MALLOC PROPERTIES
|
||||
IMPORTED_LOCATION "${TBB_MALLOC_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${TBB_MALLOC_INCLUDE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(TBB_MALLOC_INCLUDE_DIR TBB_MALLOC_LIBRARY )
|
||||
@ -10,13 +10,23 @@ find_path(VORO_INCLUDE_DIR voro++.hh PATH_SUFFIXES voro++)
|
||||
|
||||
find_library(VORO_LIBRARY NAMES voro++)
|
||||
|
||||
set(VORO_LIBRARIES ${VORO_LIBRARY})
|
||||
set(VORO_INCLUDE_DIRS ${VORO_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set VORO_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
|
||||
find_package_handle_standard_args(VORO DEFAULT_MSG VORO_LIBRARY VORO_INCLUDE_DIR)
|
||||
|
||||
# Copy the results to the output variables and target.
|
||||
if(VORO_FOUND)
|
||||
set(VORO_LIBRARIES ${VORO_LIBRARY})
|
||||
set(VORO_INCLUDE_DIRS ${VORO_INCLUDE_DIR})
|
||||
|
||||
if(NOT TARGET VORO::VORO)
|
||||
add_library(VORO::VORO UNKNOWN IMPORTED)
|
||||
set_target_properties(VORO::VORO PROPERTIES
|
||||
IMPORTED_LOCATION "${VORO_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${VORO_INCLUDE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(VORO_INCLUDE_DIR VORO_LIBRARY )
|
||||
|
||||
@ -1,8 +1,19 @@
|
||||
find_path(ZMQ_INCLUDE_DIR zmq.h)
|
||||
find_library(ZMQ_LIBRARY NAMES zmq)
|
||||
|
||||
set(ZMQ_LIBRARIES ${ZMQ_LIBRARY})
|
||||
set(ZMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ZMQ DEFAULT_MSG ZMQ_LIBRARY ZMQ_INCLUDE_DIR)
|
||||
|
||||
# Copy the results to the output variables and target.
|
||||
if(ZMQ_FOUND)
|
||||
set(ZMQ_LIBRARIES ${ZMQ_LIBRARY})
|
||||
set(ZMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIR})
|
||||
|
||||
if(NOT TARGET ZMQ::ZMQ)
|
||||
add_library(ZMQ::ZMQ UNKNOWN IMPORTED)
|
||||
set_target_properties(ZMQ::ZMQ PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${ZMQ_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${ZMQ_INCLUDE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
3
cmake/Modules/GenerateBinaryHeader.cmake
Normal file
3
cmake/Modules/GenerateBinaryHeader.cmake
Normal file
@ -0,0 +1,3 @@
|
||||
# utility script to call GenerateBinaryHeader function
|
||||
include(${SOURCE_DIR}/Modules/LAMMPSUtils.cmake)
|
||||
GenerateBinaryHeader(${VARNAME} ${HEADER_FILE} ${SOURCE_FILES})
|
||||
@ -69,3 +69,19 @@ macro(pkg_depends PKG1 PKG2)
|
||||
message(FATAL_ERROR "${PKG1} package needs LAMMPS to be build with ${PKG2}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# CMake-only replacement for bin2c and xxd
|
||||
function(GenerateBinaryHeader varname outfile files)
|
||||
message("Creating ${outfile}...")
|
||||
file(WRITE ${outfile} "// CMake generated file\n")
|
||||
math(EXPR ARG_END "${ARGC}-1")
|
||||
|
||||
foreach(IDX RANGE 2 ${ARG_END})
|
||||
list(GET ARGV ${IDX} filename)
|
||||
file(READ ${filename} content HEX)
|
||||
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," content "${content}")
|
||||
string(REGEX REPLACE ",$" "" content "${content}")
|
||||
file(APPEND ${outfile} "const unsigned char ${varname}[] = { ${content} };\n")
|
||||
file(APPEND ${outfile} "const unsigned int ${varname}_size = sizeof(${varname});\n")
|
||||
endforeach()
|
||||
endfunction(GenerateBinaryHeader)
|
||||
|
||||
@ -16,8 +16,10 @@ else()
|
||||
endif()
|
||||
|
||||
ExternalProject_get_property(mpi4win_build SOURCE_DIR)
|
||||
add_definitions(-DMPICH_SKIP_MPICXX)
|
||||
include_directories("${SOURCE_DIR}/include")
|
||||
set(MPI4WIN_LIBRARIES "${SOURCE_DIR}/lib/libmpi.a")
|
||||
list(APPEND LAMMPS_DEPS mpi4win_build)
|
||||
set(LAMMPS_USE_MPI4WIN ON)
|
||||
file(MAKE_DIRECTORY "${SOURCE_DIR}/include")
|
||||
add_library(MPI::MPI_CXX UNKNOWN IMPORTED)
|
||||
set_target_properties(MPI::MPI_CXX PROPERTIES
|
||||
IMPORTED_LOCATION "${SOURCE_DIR}/lib/libmpi.a"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/include"
|
||||
INTERFACE_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX")
|
||||
add_dependencies(MPI::MPI_CXX mpi4win_build)
|
||||
|
||||
@ -1,5 +1,2 @@
|
||||
if(PKG_COMPRESS)
|
||||
find_package(ZLIB REQUIRED)
|
||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${ZLIB_LIBRARIES})
|
||||
endif()
|
||||
find_package(ZLIB REQUIRED)
|
||||
target_link_libraries(lammps PRIVATE ZLIB::ZLIB)
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
if(PKG_CORESHELL)
|
||||
set(CORESHELL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/CORESHELL)
|
||||
set(CORESHELL_SOURCES)
|
||||
set_property(GLOBAL PROPERTY "CORESHELL_SOURCES" "${CORESHELL_SOURCES}")
|
||||
set(CORESHELL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/CORESHELL)
|
||||
set(CORESHELL_SOURCES)
|
||||
set_property(GLOBAL PROPERTY "CORESHELL_SOURCES" "${CORESHELL_SOURCES}")
|
||||
|
||||
# detects styles which have a CORESHELL version
|
||||
RegisterStylesExt(${CORESHELL_SOURCES_DIR} cs CORESHELL_SOURCES)
|
||||
# detects styles which have a CORESHELL version
|
||||
RegisterStylesExt(${CORESHELL_SOURCES_DIR} cs CORESHELL_SOURCES)
|
||||
|
||||
get_property(CORESHELL_SOURCES GLOBAL PROPERTY CORESHELL_SOURCES)
|
||||
get_property(CORESHELL_SOURCES GLOBAL PROPERTY CORESHELL_SOURCES)
|
||||
|
||||
list(APPEND LIB_SOURCES ${CORESHELL_SOURCES})
|
||||
include_directories(${CORESHELL_SOURCES_DIR})
|
||||
endif()
|
||||
target_sources(lammps PRIVATE ${CORESHELL_SOURCES})
|
||||
target_include_directories(lammps PRIVATE ${CORESHELL_SOURCES_DIR})
|
||||
|
||||
@ -1,197 +1,365 @@
|
||||
if(PKG_GPU)
|
||||
set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU)
|
||||
set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h
|
||||
${GPU_SOURCES_DIR}/fix_gpu.h
|
||||
${GPU_SOURCES_DIR}/fix_gpu.cpp)
|
||||
set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU)
|
||||
set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h
|
||||
${GPU_SOURCES_DIR}/fix_gpu.h
|
||||
${GPU_SOURCES_DIR}/fix_gpu.cpp)
|
||||
|
||||
set(GPU_API "opencl" CACHE STRING "API used by GPU package")
|
||||
set(GPU_API_VALUES opencl cuda)
|
||||
set_property(CACHE GPU_API PROPERTY STRINGS ${GPU_API_VALUES})
|
||||
validate_option(GPU_API GPU_API_VALUES)
|
||||
string(TOUPPER ${GPU_API} GPU_API)
|
||||
set(GPU_API "opencl" CACHE STRING "API used by GPU package")
|
||||
set(GPU_API_VALUES opencl cuda hip)
|
||||
set_property(CACHE GPU_API PROPERTY STRINGS ${GPU_API_VALUES})
|
||||
validate_option(GPU_API GPU_API_VALUES)
|
||||
string(TOUPPER ${GPU_API} GPU_API)
|
||||
|
||||
set(GPU_PREC "mixed" CACHE STRING "LAMMPS GPU precision")
|
||||
set(GPU_PREC_VALUES double mixed single)
|
||||
set_property(CACHE GPU_PREC PROPERTY STRINGS ${GPU_PREC_VALUES})
|
||||
validate_option(GPU_PREC GPU_PREC_VALUES)
|
||||
string(TOUPPER ${GPU_PREC} GPU_PREC)
|
||||
set(GPU_PREC "mixed" CACHE STRING "LAMMPS GPU precision")
|
||||
set(GPU_PREC_VALUES double mixed single)
|
||||
set_property(CACHE GPU_PREC PROPERTY STRINGS ${GPU_PREC_VALUES})
|
||||
validate_option(GPU_PREC GPU_PREC_VALUES)
|
||||
string(TOUPPER ${GPU_PREC} GPU_PREC)
|
||||
|
||||
if(GPU_PREC STREQUAL "DOUBLE")
|
||||
set(GPU_PREC_SETTING "DOUBLE_DOUBLE")
|
||||
elseif(GPU_PREC STREQUAL "MIXED")
|
||||
set(GPU_PREC_SETTING "SINGLE_DOUBLE")
|
||||
elseif(GPU_PREC STREQUAL "SINGLE")
|
||||
set(GPU_PREC_SETTING "SINGLE_SINGLE")
|
||||
endif()
|
||||
|
||||
file(GLOB GPU_LIB_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp)
|
||||
file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu)
|
||||
|
||||
if(GPU_API STREQUAL "CUDA")
|
||||
find_package(CUDA REQUIRED)
|
||||
find_program(BIN2C bin2c)
|
||||
if(NOT BIN2C)
|
||||
message(FATAL_ERROR "Could not find bin2c, use -DBIN2C=/path/to/bin2c to help cmake finding it.")
|
||||
endif()
|
||||
option(CUDPP_OPT "Enable CUDPP_OPT" ON)
|
||||
option(CUDA_MPS_SUPPORT "Enable tweaks to support CUDA Multi-process service (MPS)" OFF)
|
||||
if(CUDA_MPS_SUPPORT)
|
||||
set(GPU_CUDA_MPS_FLAGS "-DCUDA_PROXY")
|
||||
endif()
|
||||
|
||||
set(GPU_ARCH "sm_30" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)")
|
||||
|
||||
file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu)
|
||||
list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu)
|
||||
|
||||
cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu)
|
||||
|
||||
if(CUDPP_OPT)
|
||||
cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini)
|
||||
file(GLOB GPU_LIB_CUDPP_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp)
|
||||
file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu)
|
||||
endif()
|
||||
|
||||
# build arch/gencode commands for nvcc based on CUDA toolkit version and use choice
|
||||
# --arch translates directly instead of JIT, so this should be for the preferred or most common architecture
|
||||
set(GPU_CUDA_GENCODE "-arch=${GPU_ARCH} ")
|
||||
# Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0
|
||||
if((CUDA_VERSION VERSION_GREATER "3.1") AND (CUDA_VERSION VERSION_LESS "9.0"))
|
||||
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_20,code=[sm_20,compute_20] ")
|
||||
endif()
|
||||
# Kepler (GPU Arch 3.x) is supported by CUDA 5 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "4.9")
|
||||
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_35,code=[sm_35,compute_35] ")
|
||||
endif()
|
||||
# Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "5.9")
|
||||
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] ")
|
||||
endif()
|
||||
# Pascal (GPU Arch 6.x) is supported by CUDA 8 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "7.9")
|
||||
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] ")
|
||||
endif()
|
||||
# Volta (GPU Arch 7.0) is supported by CUDA 9 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "8.9")
|
||||
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_70,code=[sm_70,compute_70] ")
|
||||
endif()
|
||||
# Turing (GPU Arch 7.5) is supported by CUDA 10 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "9.9")
|
||||
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_75,code=[sm_75,compute_75] ")
|
||||
endif()
|
||||
|
||||
cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS
|
||||
-DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING})
|
||||
|
||||
cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS ${CUDA_REQUEST_PIC}
|
||||
-DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING})
|
||||
|
||||
foreach(CU_OBJ ${GPU_GEN_OBJS})
|
||||
get_filename_component(CU_NAME ${CU_OBJ} NAME_WE)
|
||||
string(REGEX REPLACE "^.*_lal_" "" CU_NAME "${CU_NAME}")
|
||||
add_custom_command(OUTPUT ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h
|
||||
COMMAND ${BIN2C} -c -n ${CU_NAME} ${CU_OBJ} > ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h
|
||||
DEPENDS ${CU_OBJ}
|
||||
COMMENT "Generating ${CU_NAME}_cubin.h")
|
||||
list(APPEND GPU_LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h)
|
||||
endforeach()
|
||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h")
|
||||
|
||||
|
||||
add_library(gpu STATIC ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS})
|
||||
target_link_libraries(gpu ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
|
||||
target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu ${CUDA_INCLUDE_DIRS})
|
||||
target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT ${GPU_CUDA_MPS_FLAGS})
|
||||
if(CUDPP_OPT)
|
||||
target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini)
|
||||
target_compile_definitions(gpu PRIVATE -DUSE_CUDPP)
|
||||
endif()
|
||||
|
||||
list(APPEND LAMMPS_LINK_LIBS gpu)
|
||||
if(LAMMPS_USE_MPI4WIN)
|
||||
add_dependencies(gpu mpi4win_build)
|
||||
endif()
|
||||
|
||||
add_executable(nvc_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
|
||||
target_compile_definitions(nvc_get_devices PRIVATE -DUCL_CUDADR)
|
||||
target_link_libraries(nvc_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
|
||||
target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS})
|
||||
|
||||
|
||||
elseif(GPU_API STREQUAL "OPENCL")
|
||||
find_package(OpenCL REQUIRED)
|
||||
set(OCL_TUNE "generic" CACHE STRING "OpenCL Device Tuning")
|
||||
set(OCL_TUNE_VALUES intel fermi kepler cypress generic)
|
||||
set_property(CACHE OCL_TUNE PROPERTY STRINGS ${OCL_TUNE_VALUES})
|
||||
validate_option(OCL_TUNE OCL_TUNE_VALUES)
|
||||
string(TOUPPER ${OCL_TUNE} OCL_TUNE)
|
||||
|
||||
include(OpenCLUtils)
|
||||
set(OCL_COMMON_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_preprocessor.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_aux_fun1.h)
|
||||
|
||||
file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu)
|
||||
list(REMOVE_ITEM GPU_LIB_CU
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu
|
||||
)
|
||||
|
||||
foreach(GPU_KERNEL ${GPU_LIB_CU})
|
||||
get_filename_component(basename ${GPU_KERNEL} NAME_WE)
|
||||
string(SUBSTRING ${basename} 4 -1 KERNEL_NAME)
|
||||
GenerateOpenCLHeader(${KERNEL_NAME} ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h ${OCL_COMMON_HEADERS} ${GPU_KERNEL})
|
||||
list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h)
|
||||
endforeach()
|
||||
|
||||
GenerateOpenCLHeader(gayberne ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu)
|
||||
GenerateOpenCLHeader(gayberne_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu)
|
||||
GenerateOpenCLHeader(re_squared ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu)
|
||||
GenerateOpenCLHeader(re_squared_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu)
|
||||
GenerateOpenCLHeader(tersoff ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu)
|
||||
GenerateOpenCLHeader(tersoff_zbl ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu)
|
||||
GenerateOpenCLHeader(tersoff_mod ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu)
|
||||
|
||||
list(APPEND GPU_LIB_SOURCES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h
|
||||
)
|
||||
|
||||
add_library(gpu STATIC ${GPU_LIB_SOURCES})
|
||||
target_link_libraries(gpu ${OpenCL_LIBRARIES})
|
||||
target_include_directories(gpu PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gpu ${OpenCL_INCLUDE_DIRS})
|
||||
target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -D${OCL_TUNE}_OCL -DMPI_GERYON -DUCL_NO_EXIT)
|
||||
target_compile_definitions(gpu PRIVATE -DUSE_OPENCL)
|
||||
|
||||
list(APPEND LAMMPS_LINK_LIBS gpu)
|
||||
if(LAMMPS_USE_MPI4WIN)
|
||||
add_dependencies(gpu mpi4win_build)
|
||||
endif()
|
||||
|
||||
add_executable(ocl_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
|
||||
target_compile_definitions(ocl_get_devices PRIVATE -DUCL_OPENCL)
|
||||
target_link_libraries(ocl_get_devices PRIVATE ${OpenCL_LIBRARIES})
|
||||
target_include_directories(ocl_get_devices PRIVATE ${OpenCL_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
# GPU package
|
||||
FindStyleHeaders(${GPU_SOURCES_DIR} FIX_CLASS fix_ FIX)
|
||||
|
||||
set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}")
|
||||
|
||||
# detects styles which have GPU version
|
||||
RegisterStylesExt(${GPU_SOURCES_DIR} gpu GPU_SOURCES)
|
||||
|
||||
get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES)
|
||||
|
||||
list(APPEND LIB_SOURCES ${GPU_SOURCES})
|
||||
include_directories(${GPU_SOURCES_DIR})
|
||||
if(GPU_PREC STREQUAL "DOUBLE")
|
||||
set(GPU_PREC_SETTING "DOUBLE_DOUBLE")
|
||||
elseif(GPU_PREC STREQUAL "MIXED")
|
||||
set(GPU_PREC_SETTING "SINGLE_DOUBLE")
|
||||
elseif(GPU_PREC STREQUAL "SINGLE")
|
||||
set(GPU_PREC_SETTING "SINGLE_SINGLE")
|
||||
endif()
|
||||
|
||||
file(GLOB GPU_LIB_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp)
|
||||
file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu)
|
||||
|
||||
if(GPU_API STREQUAL "CUDA")
|
||||
find_package(CUDA REQUIRED)
|
||||
find_program(BIN2C bin2c)
|
||||
if(NOT BIN2C)
|
||||
message(FATAL_ERROR "Could not find bin2c, use -DBIN2C=/path/to/bin2c to help cmake finding it.")
|
||||
endif()
|
||||
option(CUDPP_OPT "Enable CUDPP_OPT" ON)
|
||||
option(CUDA_MPS_SUPPORT "Enable tweaks to support CUDA Multi-process service (MPS)" OFF)
|
||||
if(CUDA_MPS_SUPPORT)
|
||||
set(GPU_CUDA_MPS_FLAGS "-DCUDA_PROXY")
|
||||
endif()
|
||||
|
||||
set(GPU_ARCH "sm_30" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)")
|
||||
|
||||
file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu)
|
||||
list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu)
|
||||
|
||||
cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu ${LAMMPS_LIB_BINARY_DIR}/gpu)
|
||||
|
||||
if(CUDPP_OPT)
|
||||
cuda_include_directories(${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini)
|
||||
file(GLOB GPU_LIB_CUDPP_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp)
|
||||
file(GLOB GPU_LIB_CUDPP_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu)
|
||||
endif()
|
||||
|
||||
# build arch/gencode commands for nvcc based on CUDA toolkit version and use choice
|
||||
# --arch translates directly instead of JIT, so this should be for the preferred or most common architecture
|
||||
set(GPU_CUDA_GENCODE "-arch=${GPU_ARCH} ")
|
||||
# Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0
|
||||
if((CUDA_VERSION VERSION_GREATER "3.1") AND (CUDA_VERSION VERSION_LESS "9.0"))
|
||||
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_20,code=[sm_20,compute_20] ")
|
||||
endif()
|
||||
# Kepler (GPU Arch 3.x) is supported by CUDA 5 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "4.9")
|
||||
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_35,code=[sm_35,compute_35] ")
|
||||
endif()
|
||||
# Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "5.9")
|
||||
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] ")
|
||||
endif()
|
||||
# Pascal (GPU Arch 6.x) is supported by CUDA 8 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "7.9")
|
||||
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] ")
|
||||
endif()
|
||||
# Volta (GPU Arch 7.0) is supported by CUDA 9 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "8.9")
|
||||
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_70,code=[sm_70,compute_70] ")
|
||||
endif()
|
||||
# Turing (GPU Arch 7.5) is supported by CUDA 10 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "9.9")
|
||||
string(APPEND GPU_CUDA_GENCODE "-gencode arch=compute_75,code=[sm_75,compute_75] ")
|
||||
endif()
|
||||
|
||||
cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS
|
||||
-DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DNV_KERNEL -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING})
|
||||
|
||||
cuda_compile(GPU_OBJS ${GPU_LIB_CUDPP_CU} OPTIONS ${CUDA_REQUEST_PIC}
|
||||
-DUNIX -O3 --use_fast_math -Wno-deprecated-gpu-targets -DUCL_CUDADR ${GPU_CUDA_GENCODE} -D_${GPU_PREC_SETTING})
|
||||
|
||||
foreach(CU_OBJ ${GPU_GEN_OBJS})
|
||||
get_filename_component(CU_NAME ${CU_OBJ} NAME_WE)
|
||||
string(REGEX REPLACE "^.*_lal_" "" CU_NAME "${CU_NAME}")
|
||||
add_custom_command(OUTPUT ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h
|
||||
COMMAND ${BIN2C} -c -n ${CU_NAME} ${CU_OBJ} > ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h
|
||||
DEPENDS ${CU_OBJ}
|
||||
COMMENT "Generating ${CU_NAME}_cubin.h")
|
||||
list(APPEND GPU_LIB_SOURCES ${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h)
|
||||
endforeach()
|
||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h")
|
||||
|
||||
|
||||
add_library(gpu STATIC ${GPU_LIB_SOURCES} ${GPU_LIB_CUDPP_SOURCES} ${GPU_OBJS})
|
||||
target_link_libraries(gpu PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
|
||||
target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu ${CUDA_INCLUDE_DIRS})
|
||||
target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT ${GPU_CUDA_MPS_FLAGS})
|
||||
if(CUDPP_OPT)
|
||||
target_include_directories(gpu PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini)
|
||||
target_compile_definitions(gpu PRIVATE -DUSE_CUDPP)
|
||||
endif()
|
||||
|
||||
target_link_libraries(lammps PRIVATE gpu)
|
||||
|
||||
add_executable(nvc_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
|
||||
target_compile_definitions(nvc_get_devices PRIVATE -DUCL_CUDADR)
|
||||
target_link_libraries(nvc_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
|
||||
target_include_directories(nvc_get_devices PRIVATE ${CUDA_INCLUDE_DIRS})
|
||||
|
||||
|
||||
elseif(GPU_API STREQUAL "OPENCL")
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
# download and unpack support binaries for compilation of windows binaries.
|
||||
set(LAMMPS_THIRDPARTY_URL "http://download.lammps.org/thirdparty")
|
||||
file(DOWNLOAD "${LAMMPS_THIRDPARTY_URL}/opencl-win-devel.tar.gz" "${CMAKE_CURRENT_BINARY_DIR}/opencl-win-devel.tar.gz"
|
||||
EXPECTED_MD5 2c00364888d5671195598b44c2e0d44d)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf opencl-win-devel.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_library(OpenCL::OpenCL UNKNOWN IMPORTED)
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
|
||||
set_target_properties(OpenCL::OpenCL PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win32/libOpenCL.dll")
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
|
||||
set_target_properties(OpenCL::OpenCL PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/lib_win64/libOpenCL.dll")
|
||||
endif()
|
||||
set_target_properties(OpenCL::OpenCL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/include")
|
||||
else()
|
||||
find_package(OpenCL REQUIRED)
|
||||
endif()
|
||||
set(OCL_TUNE "generic" CACHE STRING "OpenCL Device Tuning")
|
||||
set(OCL_TUNE_VALUES intel fermi kepler cypress generic)
|
||||
set_property(CACHE OCL_TUNE PROPERTY STRINGS ${OCL_TUNE_VALUES})
|
||||
validate_option(OCL_TUNE OCL_TUNE_VALUES)
|
||||
string(TOUPPER ${OCL_TUNE} OCL_TUNE)
|
||||
|
||||
include(OpenCLUtils)
|
||||
set(OCL_COMMON_HEADERS ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_preprocessor.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_aux_fun1.h)
|
||||
|
||||
file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu)
|
||||
list(REMOVE_ITEM GPU_LIB_CU
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu
|
||||
${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu
|
||||
)
|
||||
|
||||
foreach(GPU_KERNEL ${GPU_LIB_CU})
|
||||
get_filename_component(basename ${GPU_KERNEL} NAME_WE)
|
||||
string(SUBSTRING ${basename} 4 -1 KERNEL_NAME)
|
||||
GenerateOpenCLHeader(${KERNEL_NAME} ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h ${OCL_COMMON_HEADERS} ${GPU_KERNEL})
|
||||
list(APPEND GPU_LIB_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/gpu/${KERNEL_NAME}_cl.h)
|
||||
endforeach()
|
||||
|
||||
GenerateOpenCLHeader(gayberne ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne.cu)
|
||||
GenerateOpenCLHeader(gayberne_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_gayberne_lj.cu)
|
||||
GenerateOpenCLHeader(re_squared ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared.cu)
|
||||
GenerateOpenCLHeader(re_squared_lj ${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_ellipsoid_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_re_squared_lj.cu)
|
||||
GenerateOpenCLHeader(tersoff ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff.cu)
|
||||
GenerateOpenCLHeader(tersoff_zbl ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_zbl.cu)
|
||||
GenerateOpenCLHeader(tersoff_mod ${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h ${OCL_COMMON_HEADERS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod_extra.h ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_tersoff_mod.cu)
|
||||
|
||||
list(APPEND GPU_LIB_SOURCES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_cl.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/gayberne_lj_cl.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_cl.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/re_squared_lj_cl.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_cl.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_zbl_cl.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gpu/tersoff_mod_cl.h
|
||||
)
|
||||
|
||||
add_library(gpu STATIC ${GPU_LIB_SOURCES})
|
||||
target_link_libraries(gpu PRIVATE OpenCL::OpenCL)
|
||||
target_include_directories(gpu PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gpu)
|
||||
target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -D${OCL_TUNE}_OCL -DMPI_GERYON -DUCL_NO_EXIT)
|
||||
target_compile_definitions(gpu PRIVATE -DUSE_OPENCL)
|
||||
|
||||
target_link_libraries(lammps PRIVATE gpu)
|
||||
|
||||
add_executable(ocl_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
|
||||
target_compile_definitions(ocl_get_devices PRIVATE -DUCL_OPENCL)
|
||||
target_link_libraries(ocl_get_devices PRIVATE OpenCL::OpenCL)
|
||||
elseif(GPU_API STREQUAL "HIP")
|
||||
if(NOT DEFINED HIP_PATH)
|
||||
if(NOT DEFINED ENV{HIP_PATH})
|
||||
set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed")
|
||||
else()
|
||||
set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed")
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
|
||||
find_package(HIP REQUIRED)
|
||||
option(HIP_USE_DEVICE_SORT "Use GPU sorting" ON)
|
||||
|
||||
if(NOT DEFINED HIP_PLATFORM)
|
||||
if(NOT DEFINED ENV{HIP_PLATFORM})
|
||||
set(HIP_PLATFORM "hcc" CACHE PATH "HIP Platform to be used during compilation")
|
||||
else()
|
||||
set(HIP_PLATFORM $ENV{HIP_PLATFORM} CACHE PATH "HIP Platform used during compilation")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(ENV{HIP_PLATFORM} ${HIP_PLATFORM})
|
||||
|
||||
if(HIP_PLATFORM STREQUAL "hcc")
|
||||
set(HIP_ARCH "gfx906" CACHE STRING "HIP target architecture")
|
||||
elseif(HIP_PLATFORM STREQUAL "nvcc")
|
||||
find_package(CUDA REQUIRED)
|
||||
set(HIP_ARCH "sm_30" CACHE STRING "HIP primary CUDA architecture (e.g. sm_60)")
|
||||
|
||||
# build arch/gencode commands for nvcc based on CUDA toolkit version and use choice
|
||||
# --arch translates directly instead of JIT, so this should be for the preferred or most common architecture
|
||||
set(HIP_CUDA_GENCODE "-arch=${HIP_ARCH} ")
|
||||
# Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0
|
||||
if((CUDA_VERSION VERSION_GREATER "3.1") AND (CUDA_VERSION VERSION_LESS "9.0"))
|
||||
string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_20,code=[sm_20,compute_20] ")
|
||||
endif()
|
||||
# Kepler (GPU Arch 3.x) is supported by CUDA 5 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "4.9")
|
||||
string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_35,code=[sm_35,compute_35] ")
|
||||
endif()
|
||||
# Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "5.9")
|
||||
string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] ")
|
||||
endif()
|
||||
# Pascal (GPU Arch 6.x) is supported by CUDA 8 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "7.9")
|
||||
string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] ")
|
||||
endif()
|
||||
# Volta (GPU Arch 7.0) is supported by CUDA 9 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "8.9")
|
||||
string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_70,code=[sm_70,compute_70] ")
|
||||
endif()
|
||||
# Turing (GPU Arch 7.5) is supported by CUDA 10 and later
|
||||
if(CUDA_VERSION VERSION_GREATER "9.9")
|
||||
string(APPEND HIP_CUDA_GENCODE "-gencode arch=compute_75,code=[sm_75,compute_75] ")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(GLOB GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu)
|
||||
list(REMOVE_ITEM GPU_LIB_CU ${LAMMPS_LIB_SOURCE_DIR}/gpu/lal_pppm.cu)
|
||||
|
||||
set(GPU_LIB_CU_HIP "")
|
||||
foreach(CU_FILE ${GPU_LIB_CU})
|
||||
get_filename_component(CU_NAME ${CU_FILE} NAME_WE)
|
||||
string(REGEX REPLACE "^.*lal_" "" CU_NAME "${CU_NAME}")
|
||||
|
||||
set(CU_CPP_FILE "${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}.cu.cpp")
|
||||
set(CUBIN_FILE "${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}.cubin")
|
||||
set(CUBIN_H_FILE "${LAMMPS_LIB_BINARY_DIR}/gpu/${CU_NAME}_cubin.h")
|
||||
|
||||
if(HIP_PLATFORM STREQUAL "hcc")
|
||||
configure_file(${CU_FILE} ${CU_CPP_FILE} COPYONLY)
|
||||
|
||||
add_custom_command(OUTPUT ${CUBIN_FILE}
|
||||
VERBATIM COMMAND ${HIP_HIPCC_EXECUTABLE} --genco -t="${HIP_ARCH}" -f=\"-O3 -ffast-math -DUSE_HIP -D_${GPU_PREC_SETTING} -I${LAMMPS_LIB_SOURCE_DIR}/gpu\" -o ${CUBIN_FILE} ${CU_CPP_FILE}
|
||||
DEPENDS ${CU_CPP_FILE}
|
||||
COMMENT "Generating ${CU_NAME}.cubin")
|
||||
elseif(HIP_PLATFORM STREQUAL "nvcc")
|
||||
add_custom_command(OUTPUT ${CUBIN_FILE}
|
||||
VERBATIM COMMAND ${HIP_HIPCC_EXECUTABLE} --fatbin --use_fast_math -DUSE_HIP -D_${GPU_PREC_SETTING} ${HIP_CUDA_GENCODE} -I${LAMMPS_LIB_SOURCE_DIR}/gpu -o ${CUBIN_FILE} ${CU_FILE}
|
||||
DEPENDS ${CU_FILE}
|
||||
COMMENT "Generating ${CU_NAME}.cubin")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${CUBIN_H_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -D SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -D VARNAME=${CU_NAME} -D HEADER_FILE=${CUBIN_H_FILE} -D SOURCE_FILES=${CUBIN_FILE} -P ${CMAKE_CURRENT_SOURCE_DIR}/Modules/GenerateBinaryHeader.cmake
|
||||
DEPENDS ${CUBIN_FILE}
|
||||
COMMENT "Generating ${CU_NAME}_cubin.h")
|
||||
|
||||
list(APPEND GPU_LIB_SOURCES ${CUBIN_H_FILE})
|
||||
endforeach()
|
||||
|
||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${LAMMPS_LIB_BINARY_DIR}/gpu/*_cubin.h ${LAMMPS_LIB_BINARY_DIR}/gpu/*.cu.cpp")
|
||||
|
||||
hip_add_library(gpu STATIC ${GPU_LIB_SOURCES})
|
||||
target_include_directories(gpu PRIVATE ${LAMMPS_LIB_BINARY_DIR}/gpu)
|
||||
target_compile_definitions(gpu PRIVATE -D_${GPU_PREC_SETTING} -DMPI_GERYON -DUCL_NO_EXIT)
|
||||
target_compile_definitions(gpu PRIVATE -DUSE_HIP)
|
||||
|
||||
if(HIP_USE_DEVICE_SORT)
|
||||
# add hipCUB
|
||||
target_include_directories(gpu PRIVATE ${HIP_ROOT_DIR}/../include)
|
||||
target_compile_definitions(gpu PRIVATE -DUSE_HIP_DEVICE_SORT)
|
||||
|
||||
if(HIP_PLATFORM STREQUAL "nvcc")
|
||||
find_package(CUB)
|
||||
|
||||
if(CUB_FOUND)
|
||||
set(DOWNLOAD_CUB_DEFAULT OFF)
|
||||
else()
|
||||
set(DOWNLOAD_CUB_DEFAULT ON)
|
||||
endif()
|
||||
|
||||
option(DOWNLOAD_CUB "Download and compile the CUB library instead of using an already installed one" ${DOWNLOAD_CUB_DEFAULT})
|
||||
|
||||
if(DOWNLOAD_CUB)
|
||||
message(STATUS "CUB download requested")
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(CUB
|
||||
GIT_REPOSITORY https://github.com/NVlabs/cub
|
||||
TIMEOUT 5
|
||||
PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
UPDATE_COMMAND ""
|
||||
)
|
||||
ExternalProject_get_property(CUB SOURCE_DIR)
|
||||
set(CUB_INCLUDE_DIR ${SOURCE_DIR})
|
||||
else()
|
||||
find_package(CUB)
|
||||
if(NOT CUB_FOUND)
|
||||
message(FATAL_ERROR "CUB library not found. Help CMake to find it by setting CUB_INCLUDE_DIR, or set DOWNLOAD_VORO=ON to download it")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_include_directories(gpu PRIVATE ${CUB_INCLUDE_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
hip_add_executable(hip_get_devices ${LAMMPS_LIB_SOURCE_DIR}/gpu/geryon/ucl_get_devices.cpp)
|
||||
target_compile_definitions(hip_get_devices PRIVATE -DUCL_HIP)
|
||||
|
||||
if(HIP_PLATFORM STREQUAL "nvcc")
|
||||
target_compile_definitions(gpu PRIVATE -D__HIP_PLATFORM_NVCC__)
|
||||
target_include_directories(gpu PRIVATE ${HIP_ROOT_DIR}/include)
|
||||
target_include_directories(gpu PRIVATE ${CUDA_INCLUDE_DIRS})
|
||||
target_link_libraries(gpu PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
|
||||
|
||||
target_compile_definitions(hip_get_devices PRIVATE -D__HIP_PLATFORM_NVCC__)
|
||||
target_include_directories(hip_get_devices PRIVATE ${HIP_ROOT_DIR}/include)
|
||||
target_include_directories(hip_get_devices PRIVATE ${CUDA_INCLUDE_DIRS})
|
||||
target_link_libraries(hip_get_devices PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY})
|
||||
endif()
|
||||
|
||||
target_link_libraries(lammps PRIVATE gpu)
|
||||
endif()
|
||||
|
||||
# GPU package
|
||||
FindStyleHeaders(${GPU_SOURCES_DIR} FIX_CLASS fix_ FIX)
|
||||
|
||||
set_property(GLOBAL PROPERTY "GPU_SOURCES" "${GPU_SOURCES}")
|
||||
|
||||
# detects styles which have GPU version
|
||||
RegisterStylesExt(${GPU_SOURCES_DIR} gpu GPU_SOURCES)
|
||||
|
||||
get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES)
|
||||
|
||||
target_link_libraries(gpu PRIVATE MPI::MPI_CXX)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS gpu EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
target_compile_definitions(gpu PRIVATE -DLAMMPS_${LAMMPS_SIZES})
|
||||
set_target_properties(gpu PROPERTIES OUTPUT_NAME lammps_gpu${LAMMPS_LIB_SUFFIX})
|
||||
target_sources(lammps PRIVATE ${GPU_SOURCES})
|
||||
target_include_directories(lammps PRIVATE ${GPU_SOURCES_DIR})
|
||||
|
||||
@ -1,67 +1,61 @@
|
||||
if(PKG_KIM)
|
||||
set(KIM-API_MIN_VERSION 2.1)
|
||||
find_package(CURL)
|
||||
if(CURL_FOUND)
|
||||
include_directories(${CURL_INCLUDE_DIRS})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${CURL_LIBRARIES})
|
||||
add_definitions(-DLMP_KIM_CURL)
|
||||
set(LMP_DEBUG_CURL OFF CACHE STRING "Set libcurl verbose mode on/off. If on, it displays a lot of verbose information about its operations.")
|
||||
mark_as_advanced(LMP_DEBUG_CURL)
|
||||
if(LMP_DEBUG_CURL)
|
||||
add_definitions(-DLMP_DEBUG_CURL)
|
||||
endif()
|
||||
set(LMP_NO_SSL_CHECK OFF CACHE STRING "Tell libcurl to not verify the peer. If on, the connection succeeds regardless of the names in the certificate. Insecure - Use with caution!")
|
||||
mark_as_advanced(LMP_NO_SSL_CHECK)
|
||||
if(LMP_NO_SSL_CHECK)
|
||||
add_definitions(-DLMP_NO_SSL_CHECK)
|
||||
endif()
|
||||
set(KIM-API_MIN_VERSION 2.1.3)
|
||||
find_package(CURL)
|
||||
if(CURL_FOUND)
|
||||
target_link_libraries(lammps PRIVATE CURL::libcurl)
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_KIM_CURL)
|
||||
set(LMP_DEBUG_CURL OFF CACHE STRING "Set libcurl verbose mode on/off. If on, it displays a lot of verbose information about its operations.")
|
||||
mark_as_advanced(LMP_DEBUG_CURL)
|
||||
if(LMP_DEBUG_CURL)
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_DEBUG_CURL)
|
||||
endif()
|
||||
find_package(KIM-API QUIET)
|
||||
if(KIM-API_FOUND)
|
||||
if (KIM-API_VERSION VERSION_LESS ${KIM-API_MIN_VERSION})
|
||||
if ("${DOWNLOAD_KIM}" STREQUAL "")
|
||||
message(WARNING "Unsuitable KIM-API version \"${KIM-API_VERSION}\" found, but required is at least \"${KIM-API_MIN_VERSION}\". Default behavior set to download and build our own.")
|
||||
endif()
|
||||
set(DOWNLOAD_KIM_DEFAULT ON)
|
||||
else()
|
||||
set(DOWNLOAD_KIM_DEFAULT OFF)
|
||||
endif()
|
||||
else()
|
||||
if ("${DOWNLOAD_KIM}" STREQUAL "")
|
||||
message(WARNING "KIM-API package not found. Default behavior set to download and build our own")
|
||||
endif()
|
||||
set(DOWNLOAD_KIM_DEFAULT ON)
|
||||
set(LMP_NO_SSL_CHECK OFF CACHE STRING "Tell libcurl to not verify the peer. If on, the connection succeeds regardless of the names in the certificate. Insecure - Use with caution!")
|
||||
mark_as_advanced(LMP_NO_SSL_CHECK)
|
||||
if(LMP_NO_SSL_CHECK)
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_NO_SSL_CHECK)
|
||||
endif()
|
||||
option(DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" ${DOWNLOAD_KIM_DEFAULT})
|
||||
if(DOWNLOAD_KIM)
|
||||
message(STATUS "KIM-API download requested - we will build our own")
|
||||
# Workaround for cross compilation with MinGW where ${CMAKE_INSTALL_LIBDIR}
|
||||
# is a full path, so we need to remove the prefix
|
||||
string(REPLACE ${CMAKE_INSTALL_PREFIX} "" _KIM_LIBDIR ${CMAKE_INSTALL_LIBDIR})
|
||||
include(ExternalProject)
|
||||
enable_language(C)
|
||||
enable_language(Fortran)
|
||||
ExternalProject_Add(kim_build
|
||||
URL https://s3.openkim.org/kim-api/kim-api-2.1.3.txz
|
||||
URL_MD5 6ee829a1bbba5f8b9874c88c4c4ebff8
|
||||
BINARY_DIR build
|
||||
CMAKE_ARGS ${CMAKE_REQUEST_PIC}
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
|
||||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
BUILD_BYPRODUCTS <INSTALL_DIR>/${_KIM_LIBDIR}/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
)
|
||||
ExternalProject_get_property(kim_build INSTALL_DIR)
|
||||
set(KIM-API_INCLUDE_DIRS ${INSTALL_DIR}/include/kim-api)
|
||||
set(KIM-API_LDFLAGS ${INSTALL_DIR}/${_KIM_LIBDIR}/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
list(APPEND LAMMPS_DEPS kim_build)
|
||||
else()
|
||||
find_package(KIM-API ${KIM-API_MIN_VERSION} REQUIRED)
|
||||
endif()
|
||||
list(APPEND LAMMPS_LINK_LIBS "${KIM-API_LDFLAGS}")
|
||||
include_directories(${KIM-API_INCLUDE_DIRS})
|
||||
endif()
|
||||
find_package(PkgConfig QUIET)
|
||||
set(DOWNLOAD_KIM_DEFAULT ON)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(KIM-API QUIET libkim-api>=${KIM-API_MIN_VERSION})
|
||||
if(KIM-API_FOUND)
|
||||
set(DOWNLOAD_KIM_DEFAULT OFF)
|
||||
endif()
|
||||
endif()
|
||||
option(DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" ${DOWNLOAD_KIM_DEFAULT})
|
||||
if(DOWNLOAD_KIM)
|
||||
message(STATUS "KIM-API download requested - we will build our own")
|
||||
include(ExternalProject)
|
||||
enable_language(C)
|
||||
enable_language(Fortran)
|
||||
ExternalProject_Add(kim_build
|
||||
URL https://s3.openkim.org/kim-api/kim-api-2.1.3.txz
|
||||
URL_MD5 6ee829a1bbba5f8b9874c88c4c4ebff8
|
||||
BINARY_DIR build
|
||||
CMAKE_ARGS ${CMAKE_REQUEST_PIC}
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
|
||||
-DCMAKE_INSTALL_LIBDIR=lib
|
||||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
)
|
||||
ExternalProject_get_property(kim_build INSTALL_DIR)
|
||||
file(MAKE_DIRECTORY ${INSTALL_DIR}/include/kim-api)
|
||||
add_library(LAMMPS::KIM UNKNOWN IMPORTED)
|
||||
set_target_properties(LAMMPS::KIM PROPERTIES
|
||||
IMPORTED_LOCATION "${INSTALL_DIR}/lib/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include/kim-api")
|
||||
target_link_libraries(lammps PRIVATE LAMMPS::KIM)
|
||||
add_dependencies(LAMMPS::KIM kim_build)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
|
||||
endif()
|
||||
else()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(KIM-API REQUIRED IMPORTED_TARGET libkim-api>=${KIM-API_MIN_VERSION})
|
||||
target_link_libraries(lammps PRIVATE PkgConfig::KIM-API)
|
||||
endif()
|
||||
|
||||
@ -1,74 +1,111 @@
|
||||
if(PKG_KOKKOS)
|
||||
# TODO: this option needs to be documented when this works with a
|
||||
# regular release version of KOKKOS, and a version compatibility check
|
||||
# of external KOKKOS lib versus what the KOKKOS package needs is required.
|
||||
option(EXTERNAL_KOKKOS "Build against external kokkos library")
|
||||
if(EXTERNAL_KOKKOS)
|
||||
find_package(Kokkos REQUIRED)
|
||||
list(APPEND LAMMPS_LINK_LIBS Kokkos::kokkos)
|
||||
else()
|
||||
set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos)
|
||||
set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos)
|
||||
add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR})
|
||||
########################################################################
|
||||
# consistency checks and Kokkos options/settings required by LAMMPS
|
||||
if(Kokkos_ENABLE_CUDA)
|
||||
message(STATUS "KOKKOS: Enabling CUDA LAMBDA function support")
|
||||
set(Kokkos_ENABLE_CUDA_LAMBDA ON CACHE BOOL "" FORCE)
|
||||
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()
|
||||
########################################################################
|
||||
|
||||
set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src
|
||||
${LAMMPS_LIB_KOKKOS_SRC_DIR}/containers/src
|
||||
${LAMMPS_LIB_KOKKOS_SRC_DIR}/algorithms/src
|
||||
${LAMMPS_LIB_KOKKOS_BIN_DIR})
|
||||
include_directories(${Kokkos_INCLUDE_DIRS})
|
||||
list(APPEND LAMMPS_LINK_LIBS kokkos)
|
||||
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)
|
||||
message(STATUS "KOKKOS download requested - we will build our own")
|
||||
file(DOWNLOAD https://github.com/kokkos/kokkos/compare/3.0.00...stanmoore1:lammps.diff ${CMAKE_CURRENT_BINARY_DIR}/kokkos-lammps.patch)
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(kokkos_build
|
||||
URL https://github.com/kokkos/kokkos/archive/3.0.00.tar.gz
|
||||
URL_MD5 281c7093aa3a603276e93abdf4be23b9
|
||||
PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_BINARY_DIR}/kokkos-lammps.patch
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> ${CMAKE_REQUEST_PIC}
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_LIBDIR=lib
|
||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libkokkoscore.a
|
||||
)
|
||||
ExternalProject_get_property(kokkos_build INSTALL_DIR)
|
||||
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
|
||||
add_library(LAMMPS::KOKKOS UNKNOWN IMPORTED)
|
||||
set_target_properties(LAMMPS::KOKKOS PROPERTIES
|
||||
IMPORTED_LOCATION "${INSTALL_DIR}/lib/libkokkoscore.a"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include"
|
||||
INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS})
|
||||
target_link_libraries(lammps PRIVATE LAMMPS::KOKKOS)
|
||||
add_dependencies(LAMMPS::KOKKOS kokkos_build)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
|
||||
endif()
|
||||
add_definitions(-DLMP_KOKKOS)
|
||||
elseif(EXTERNAL_KOKKOS)
|
||||
find_package(Kokkos 3)
|
||||
if(NOT Kokkos_FOUND)
|
||||
message(FATAL_ERROR "KOKKOS library not found, help CMake to find it by setting KOKKOS_LIBRARY, or set DOWNLOAD_KOKKOS=ON to download it")
|
||||
endif()
|
||||
target_link_libraries(lammps PRIVATE Kokkos::kokkos)
|
||||
else()
|
||||
set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos)
|
||||
set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos)
|
||||
add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR})
|
||||
|
||||
set(KOKKOS_PKG_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/KOKKOS)
|
||||
set(KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/atom_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/atom_vec_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/comm_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/comm_tiled_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/min_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/min_linesearch_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/neighbor_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/neigh_list_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/neigh_bond_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/fix_nh_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/npair_halffull_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/domain_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/modify_kokkos.cpp)
|
||||
set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src
|
||||
${LAMMPS_LIB_KOKKOS_SRC_DIR}/containers/src
|
||||
${LAMMPS_LIB_KOKKOS_SRC_DIR}/algorithms/src
|
||||
${LAMMPS_LIB_KOKKOS_BIN_DIR})
|
||||
target_include_directories(lammps PRIVATE ${Kokkos_INCLUDE_DIRS})
|
||||
target_link_libraries(lammps PRIVATE kokkos)
|
||||
endif()
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_KOKKOS)
|
||||
|
||||
if(PKG_KSPACE)
|
||||
list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/fft3d_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/gridcomm_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/remap_kokkos.cpp)
|
||||
if(KOKKOS_ENABLE_CUDA)
|
||||
if(NOT ${FFT} STREQUAL "KISS")
|
||||
add_definitions(-DFFT_CUFFT)
|
||||
list(APPEND LAMMPS_LINK_LIBS cufft)
|
||||
endif()
|
||||
set(KOKKOS_PKG_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/KOKKOS)
|
||||
set(KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/atom_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/atom_vec_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/comm_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/comm_tiled_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/min_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/min_linesearch_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/neighbor_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/neigh_list_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/neigh_bond_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/fix_nh_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/npair_halffull_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/domain_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/modify_kokkos.cpp)
|
||||
|
||||
if(PKG_KSPACE)
|
||||
list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/fft3d_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/gridcomm_kokkos.cpp
|
||||
${KOKKOS_PKG_SOURCES_DIR}/remap_kokkos.cpp)
|
||||
if(Kokkos_ENABLE_CUDA)
|
||||
if(NOT ${FFT} STREQUAL "KISS")
|
||||
target_compile_definitions(lammps PRIVATE -DFFT_CUFFT)
|
||||
target_link_libraries(lammps PRIVATE cufft)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
|
||||
|
||||
# detects styles which have KOKKOS version
|
||||
RegisterStylesExt(${KOKKOS_PKG_SOURCES_DIR} kokkos KOKKOS_PKG_SOURCES)
|
||||
|
||||
# register kokkos-only styles
|
||||
RegisterNBinStyle(${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.h)
|
||||
RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.h)
|
||||
RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_halffull_kokkos.h)
|
||||
|
||||
if(PKG_USER-DPD)
|
||||
get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES)
|
||||
list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.cpp)
|
||||
RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.h)
|
||||
set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
|
||||
endif()
|
||||
|
||||
get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES)
|
||||
|
||||
list(APPEND LIB_SOURCES ${KOKKOS_PKG_SOURCES})
|
||||
include_directories(${KOKKOS_PKG_SOURCES_DIR})
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
|
||||
|
||||
# detects styles which have KOKKOS version
|
||||
RegisterStylesExt(${KOKKOS_PKG_SOURCES_DIR} kokkos KOKKOS_PKG_SOURCES)
|
||||
|
||||
# register kokkos-only styles
|
||||
RegisterNBinStyle(${KOKKOS_PKG_SOURCES_DIR}/nbin_kokkos.h)
|
||||
RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_kokkos.h)
|
||||
RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_halffull_kokkos.h)
|
||||
|
||||
if(PKG_USER-DPD)
|
||||
get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES)
|
||||
list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.cpp)
|
||||
RegisterNPairStyle(${KOKKOS_PKG_SOURCES_DIR}/npair_ssa_kokkos.h)
|
||||
set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
|
||||
endif()
|
||||
|
||||
get_property(KOKKOS_PKG_SOURCES GLOBAL PROPERTY KOKKOS_PKG_SOURCES)
|
||||
|
||||
target_sources(lammps PRIVATE ${KOKKOS_PKG_SOURCES})
|
||||
target_include_directories(lammps PRIVATE ${KOKKOS_PKG_SOURCES_DIR})
|
||||
|
||||
@ -1,60 +1,56 @@
|
||||
if(PKG_KSPACE)
|
||||
option(FFT_SINGLE "Use single precision FFTs instead of double precision FFTs" OFF)
|
||||
set(FFTW "FFTW3")
|
||||
if(FFT_SINGLE)
|
||||
set(FFTW "FFTW3F")
|
||||
add_definitions(-DFFT_SINGLE)
|
||||
endif()
|
||||
find_package(${FFTW} QUIET)
|
||||
if(${FFTW}_FOUND)
|
||||
set(FFT "FFTW3" CACHE STRING "FFT library for KSPACE package")
|
||||
else()
|
||||
set(FFT "KISS" CACHE STRING "FFT library for KSPACE package")
|
||||
endif()
|
||||
set(FFT_VALUES KISS FFTW3 MKL)
|
||||
set_property(CACHE FFT PROPERTY STRINGS ${FFT_VALUES})
|
||||
validate_option(FFT FFT_VALUES)
|
||||
string(TOUPPER ${FFT} FFT)
|
||||
|
||||
if(FFT STREQUAL "FFTW3")
|
||||
find_package(${FFTW} REQUIRED)
|
||||
add_definitions(-DFFT_FFTW3)
|
||||
include_directories(${${FFTW}_INCLUDE_DIRS})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${${FFTW}_LIBRARIES})
|
||||
if(FFTW3_OMP_LIBRARY OR FFTW3F_OMP_LIBRARY)
|
||||
option(FFT_FFTW_THREADS "Use threaded FFTW library" ON)
|
||||
else()
|
||||
option(FFT_FFTW_THREADS "Use threaded FFT library" OFF)
|
||||
endif()
|
||||
|
||||
if(FFT_FFTW_THREADS)
|
||||
if(FFTW3_OMP_LIBRARY OR FFTW3F_OMP_LIBRARY)
|
||||
add_definitions(-DFFT_FFTW_THREADS)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${${FFTW}_OMP_LIBRARIES})
|
||||
else()
|
||||
message(FATAL_ERROR "Need OpenMP enabled FFTW3 library for FFT_THREADS")
|
||||
endif()
|
||||
endif()
|
||||
elseif(FFT STREQUAL "MKL")
|
||||
find_package(MKL REQUIRED)
|
||||
add_definitions(-DFFT_MKL)
|
||||
option(FFT_MKL_THREADS "Use threaded MKL FFT" ON)
|
||||
if(FFT_MKL_THREADS)
|
||||
add_definitions(-DFFT_MKL_THREADS)
|
||||
endif()
|
||||
include_directories(${MKL_INCLUDE_DIRS})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${MKL_LIBRARIES})
|
||||
else()
|
||||
# last option is KISSFFT
|
||||
add_definitions(-DFFT_KISS)
|
||||
endif()
|
||||
|
||||
set(FFT_PACK "array" CACHE STRING "Optimization for FFT")
|
||||
set(FFT_PACK_VALUES array pointer memcpy)
|
||||
set_property(CACHE FFT_PACK PROPERTY STRINGS ${FFT_PACK_VALUES})
|
||||
validate_option(FFT_PACK FFT_PACK_VALUES)
|
||||
if(NOT FFT_PACK STREQUAL "array")
|
||||
string(TOUPPER ${FFT_PACK} FFT_PACK)
|
||||
add_definitions(-DFFT_PACK_${FFT_PACK})
|
||||
endif()
|
||||
option(FFT_SINGLE "Use single precision FFTs instead of double precision FFTs" OFF)
|
||||
set(FFTW "FFTW3")
|
||||
if(FFT_SINGLE)
|
||||
set(FFTW "FFTW3F")
|
||||
target_compile_definitions(lammps PUBLIC -DFFT_SINGLE)
|
||||
endif()
|
||||
find_package(${FFTW} QUIET)
|
||||
if(${FFTW}_FOUND)
|
||||
set(FFT "FFTW3" CACHE STRING "FFT library for KSPACE package")
|
||||
else()
|
||||
set(FFT "KISS" CACHE STRING "FFT library for KSPACE package")
|
||||
endif()
|
||||
set(FFT_VALUES KISS FFTW3 MKL)
|
||||
set_property(CACHE FFT PROPERTY STRINGS ${FFT_VALUES})
|
||||
validate_option(FFT FFT_VALUES)
|
||||
string(TOUPPER ${FFT} FFT)
|
||||
|
||||
if(FFT STREQUAL "FFTW3")
|
||||
find_package(${FFTW} REQUIRED)
|
||||
target_compile_definitions(lammps PUBLIC -DFFT_FFTW3)
|
||||
target_link_libraries(lammps PUBLIC ${FFTW}::${FFTW})
|
||||
if(FFTW3_OMP_LIBRARY OR FFTW3F_OMP_LIBRARY)
|
||||
option(FFT_FFTW_THREADS "Use threaded FFTW library" ON)
|
||||
else()
|
||||
option(FFT_FFTW_THREADS "Use threaded FFT library" OFF)
|
||||
endif()
|
||||
|
||||
if(FFT_FFTW_THREADS)
|
||||
if(FFTW3_OMP_LIBRARY OR FFTW3F_OMP_LIBRARY)
|
||||
target_compile_definitions(lammps PRIVATE -DFFT_FFTW_THREADS)
|
||||
target_link_libraries(lammps PRIVATE ${FFTW}::${FFTW}_OMP)
|
||||
else()
|
||||
message(FATAL_ERROR "Need OpenMP enabled FFTW3 library for FFT_THREADS")
|
||||
endif()
|
||||
endif()
|
||||
elseif(FFT STREQUAL "MKL")
|
||||
find_package(MKL REQUIRED)
|
||||
target_compile_definitions(lammps PRIVATE -DFFT_MKL)
|
||||
option(FFT_MKL_THREADS "Use threaded MKL FFT" ON)
|
||||
if(FFT_MKL_THREADS)
|
||||
target_compile_definitions(lammps PRIVATE -DFFT_MKL_THREADS)
|
||||
endif()
|
||||
target_link_libraries(lammps PRIVATE MKL::MKL)
|
||||
else()
|
||||
# last option is KISSFFT
|
||||
target_compile_definitions(lammps PRIVATE -DFFT_KISS)
|
||||
endif()
|
||||
|
||||
set(FFT_PACK "array" CACHE STRING "Optimization for FFT")
|
||||
set(FFT_PACK_VALUES array pointer memcpy)
|
||||
set_property(CACHE FFT_PACK PROPERTY STRINGS ${FFT_PACK_VALUES})
|
||||
validate_option(FFT_PACK FFT_PACK_VALUES)
|
||||
if(NOT FFT_PACK STREQUAL "array")
|
||||
string(TOUPPER ${FFT_PACK} FFT_PACK)
|
||||
target_compile_definitions(lammps PRIVATE -DFFT_PACK_${FFT_PACK})
|
||||
endif()
|
||||
|
||||
@ -1,40 +1,39 @@
|
||||
if(PKG_LATTE)
|
||||
enable_language(Fortran)
|
||||
find_package(LATTE)
|
||||
if(LATTE_FOUND)
|
||||
set(DOWNLOAD_LATTE_DEFAULT OFF)
|
||||
else()
|
||||
set(DOWNLOAD_LATTE_DEFAULT ON)
|
||||
endif()
|
||||
option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT})
|
||||
if(DOWNLOAD_LATTE)
|
||||
message(STATUS "LATTE download requested - we will build our own")
|
||||
# Workaround for cross compilation with MinGW where ${CMAKE_INSTALL_LIBDIR}
|
||||
# is a full path, so we need to remove the prefix
|
||||
string(REPLACE ${CMAKE_INSTALL_PREFIX} "" _LATTE_LIBDIR ${CMAKE_INSTALL_LIBDIR})
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(latte_build
|
||||
URL https://github.com/lanl/LATTE/archive/v1.2.1.tar.gz
|
||||
URL_MD5 85ac414fdada2d04619c8f936344df14
|
||||
SOURCE_SUBDIR cmake
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> ${CMAKE_REQUEST_PIC}
|
||||
-DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES}
|
||||
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} -DCMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS}
|
||||
-DCMAKE_Fortran_FLAGS_${BTYPE}=${CMAKE_Fortran_FLAGS_${BTYPE}} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
BUILD_BYPRODUCTS <INSTALL_DIR>/${_LATTE_LIBDIR}/liblatte.a
|
||||
)
|
||||
list(APPEND LAMMPS_DEPS latte_build)
|
||||
ExternalProject_get_property(latte_build INSTALL_DIR)
|
||||
set(LATTE_LIBRARIES ${INSTALL_DIR}/${_LATTE_LIBDIR}/liblatte.a)
|
||||
else()
|
||||
find_package(LATTE)
|
||||
if(NOT LATTE_FOUND)
|
||||
message(FATAL_ERROR "LATTE library not found, help CMake to find it by setting LATTE_LIBRARY, or set DOWNLOAD_LATTE=ON to download it")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT LAPACK_FOUND)
|
||||
add_dependencies(latte_build linalg)
|
||||
endif()
|
||||
list(APPEND LAMMPS_LINK_LIBS ${LATTE_LIBRARIES} ${LAPACK_LIBRARIES})
|
||||
enable_language(Fortran)
|
||||
find_package(LATTE)
|
||||
if(LATTE_FOUND)
|
||||
set(DOWNLOAD_LATTE_DEFAULT OFF)
|
||||
else()
|
||||
set(DOWNLOAD_LATTE_DEFAULT ON)
|
||||
endif()
|
||||
option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT})
|
||||
if(DOWNLOAD_LATTE)
|
||||
message(STATUS "LATTE download requested - we will build our own")
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(latte_build
|
||||
URL https://github.com/lanl/LATTE/archive/v1.2.1.tar.gz
|
||||
URL_MD5 85ac414fdada2d04619c8f936344df14
|
||||
SOURCE_SUBDIR cmake
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> ${CMAKE_REQUEST_PIC} -DCMAKE_INSTALL_LIBDIR=lib
|
||||
-DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES}
|
||||
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} -DCMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS}
|
||||
-DCMAKE_Fortran_FLAGS_${BTYPE}=${CMAKE_Fortran_FLAGS_${BTYPE}} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
BUILD_BYPRODUCTS <INSTALL_DIR>/lib/liblatte.a
|
||||
)
|
||||
ExternalProject_get_property(latte_build INSTALL_DIR)
|
||||
add_library(LAMMPS::LATTE UNKNOWN IMPORTED)
|
||||
set_target_properties(LAMMPS::LATTE PROPERTIES
|
||||
IMPORTED_LOCATION "${INSTALL_DIR}/lib/liblatte.a"
|
||||
INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES}")
|
||||
target_link_libraries(lammps PRIVATE LAMMPS::LATTE)
|
||||
add_dependencies(LAMMPS::LATTE latte_build)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
|
||||
endif()
|
||||
else()
|
||||
find_package(LATTE)
|
||||
if(NOT LATTE_FOUND)
|
||||
message(FATAL_ERROR "LATTE library not found, help CMake to find it by setting LATTE_LIBRARY, or set DOWNLOAD_LATTE=ON to download it")
|
||||
endif()
|
||||
target_link_libraries(lammps PRIVATE LATTE::latte)
|
||||
endif()
|
||||
|
||||
@ -1,32 +1,35 @@
|
||||
if(PKG_MESSAGE)
|
||||
if(LAMMPS_SIZES STREQUAL BIGBIG)
|
||||
message(FATAL_ERROR "The MESSAGE Package is not compatible with -DLAMMPS_BIGBIG")
|
||||
endif()
|
||||
option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF)
|
||||
file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.F
|
||||
${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.c
|
||||
${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp)
|
||||
|
||||
add_library(cslib STATIC ${cslib_SOURCES})
|
||||
if(BUILD_MPI)
|
||||
target_compile_definitions(cslib PRIVATE -DMPI_YES)
|
||||
set_target_properties(cslib PROPERTIES OUTPUT_NAME "csmpi")
|
||||
else()
|
||||
target_compile_definitions(cslib PRIVATE -DMPI_NO)
|
||||
target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_MPI)
|
||||
set_target_properties(cslib PROPERTIES OUTPUT_NAME "csnompi")
|
||||
endif()
|
||||
|
||||
if(MESSAGE_ZMQ)
|
||||
target_compile_definitions(cslib PRIVATE -DZMQ_YES)
|
||||
find_package(ZMQ REQUIRED)
|
||||
target_include_directories(cslib PRIVATE ${ZMQ_INCLUDE_DIRS})
|
||||
target_link_libraries(cslib PUBLIC ${ZMQ_LIBRARIES})
|
||||
else()
|
||||
target_compile_definitions(cslib PRIVATE -DZMQ_NO)
|
||||
target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_ZMQ)
|
||||
endif()
|
||||
|
||||
list(APPEND LAMMPS_LINK_LIBS cslib)
|
||||
include_directories(${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src)
|
||||
if(LAMMPS_SIZES STREQUAL BIGBIG)
|
||||
message(FATAL_ERROR "The MESSAGE Package is not compatible with -DLAMMPS_BIGBIG")
|
||||
endif()
|
||||
option(MESSAGE_ZMQ "Use ZeroMQ in MESSAGE package" OFF)
|
||||
file(GLOB_RECURSE cslib_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.F
|
||||
${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.c
|
||||
${LAMMPS_LIB_SOURCE_DIR}/message/cslib/[^.]*.cpp)
|
||||
|
||||
add_library(cslib STATIC ${cslib_SOURCES})
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS cslib EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
target_compile_definitions(cslib PRIVATE -DLAMMPS_${LAMMPS_SIZES})
|
||||
set_target_properties(cslib PROPERTIES OUTPUT_NAME lammps_cslib${LAMMPS_LIB_SUFFIX})
|
||||
if(BUILD_MPI)
|
||||
target_compile_definitions(cslib PRIVATE -DMPI_YES)
|
||||
set_target_properties(cslib PROPERTIES OUTPUT_NAME "csmpi")
|
||||
target_link_libraries(cslib PRIVATE MPI::MPI_CXX)
|
||||
else()
|
||||
target_compile_definitions(cslib PRIVATE -DMPI_NO)
|
||||
target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_MPI)
|
||||
set_target_properties(cslib PROPERTIES OUTPUT_NAME "csnompi")
|
||||
endif()
|
||||
|
||||
if(MESSAGE_ZMQ)
|
||||
target_compile_definitions(cslib PRIVATE -DZMQ_YES)
|
||||
find_package(ZMQ REQUIRED)
|
||||
target_link_libraries(cslib PUBLIC ZMQ::ZMQ)
|
||||
else()
|
||||
target_compile_definitions(cslib PRIVATE -DZMQ_NO)
|
||||
target_include_directories(cslib PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src/STUBS_ZMQ)
|
||||
endif()
|
||||
|
||||
target_link_libraries(lammps PRIVATE cslib)
|
||||
target_include_directories(lammps PRIVATE ${LAMMPS_LIB_SOURCE_DIR}/message/cslib/src)
|
||||
|
||||
@ -1,48 +1,48 @@
|
||||
if(PKG_MSCG)
|
||||
find_package(GSL REQUIRED)
|
||||
find_package(MSCG QUIET)
|
||||
if(MSGC_FOUND)
|
||||
set(DOWNLOAD_MSCG_DEFAULT OFF)
|
||||
else()
|
||||
set(DOWNLOAD_MSCG_DEFAULT ON)
|
||||
endif()
|
||||
option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" ${DOWNLOAD_MSCG_DEFAULT})
|
||||
if(DOWNLOAD_MSCG)
|
||||
include(ExternalProject)
|
||||
if(NOT LAPACK_FOUND)
|
||||
set(EXTRA_MSCG_OPTS "-DLAPACK_LIBRARIES=${CMAKE_CURRENT_BINARY_DIR}/liblinalg.a")
|
||||
endif()
|
||||
ExternalProject_Add(mscg_build
|
||||
URL https://github.com/uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz
|
||||
URL_MD5 8c45e269ee13f60b303edd7823866a91
|
||||
SOURCE_SUBDIR src/CMake
|
||||
CMAKE_ARGS ${CMAKE_REQUEST_PIC} ${EXTRA_MSCG_OPTS}
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
|
||||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} --build . --target mscg
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_BYPRODUCTS <BINARY_DIR>/libmscg.a
|
||||
)
|
||||
ExternalProject_get_property(mscg_build BINARY_DIR)
|
||||
set(MSCG_LIBRARIES ${BINARY_DIR}/libmscg.a)
|
||||
ExternalProject_get_property(mscg_build SOURCE_DIR)
|
||||
set(MSCG_INCLUDE_DIRS ${SOURCE_DIR}/src)
|
||||
list(APPEND LAMMPS_DEPS mscg_build)
|
||||
if(NOT LAPACK_FOUND)
|
||||
file(MAKE_DIRECTORY ${MSCG_INCLUDE_DIRS})
|
||||
add_dependencies(mscg_build linalg)
|
||||
endif()
|
||||
else()
|
||||
find_package(MSCG)
|
||||
if(NOT MSCG_FOUND)
|
||||
message(FATAL_ERROR "MSCG not found, help CMake to find it by setting MSCG_LIBRARY and MSCG_INCLUDE_DIRS, or set DOWNLOAD_MSCG=ON to download it")
|
||||
endif()
|
||||
endif()
|
||||
list(APPEND LAMMPS_LINK_LIBS ${MSCG_LIBRARIES} ${GSL_LIBRARIES} ${LAPACK_LIBRARIES})
|
||||
include_directories(${MSCG_INCLUDE_DIRS})
|
||||
find_package(GSL REQUIRED)
|
||||
find_package(MSCG QUIET)
|
||||
if(MSGC_FOUND)
|
||||
set(DOWNLOAD_MSCG_DEFAULT OFF)
|
||||
else()
|
||||
set(DOWNLOAD_MSCG_DEFAULT ON)
|
||||
endif()
|
||||
option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" ${DOWNLOAD_MSCG_DEFAULT})
|
||||
if(DOWNLOAD_MSCG)
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(mscg_build
|
||||
URL https://github.com/uchicago-voth/MSCG-release/archive/1.7.3.1.tar.gz
|
||||
URL_MD5 8c45e269ee13f60b303edd7823866a91
|
||||
SOURCE_SUBDIR src/CMake
|
||||
CMAKE_ARGS ${CMAKE_REQUEST_PIC} ${EXTRA_MSCG_OPTS}
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
|
||||
-DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES}
|
||||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} --build . --target mscg
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_BYPRODUCTS <BINARY_DIR>/libmscg.a
|
||||
)
|
||||
ExternalProject_get_property(mscg_build BINARY_DIR)
|
||||
ExternalProject_get_property(mscg_build SOURCE_DIR)
|
||||
file(MAKE_DIRECTORY ${SOURCE_DIR}/src)
|
||||
add_library(LAMMPS::MSCG UNKNOWN IMPORTED)
|
||||
set_target_properties(LAMMPS::MSCG PROPERTIES
|
||||
IMPORTED_LOCATION "${BINARY_DIR}/libmscg.a"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/src"
|
||||
INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES}")
|
||||
target_link_libraries(lammps PRIVATE LAMMPS::MSCG)
|
||||
add_dependencies(LAMMPS::MSCG mscg_build)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
|
||||
endif()
|
||||
else()
|
||||
find_package(MSCG)
|
||||
if(NOT MSCG_FOUND)
|
||||
message(FATAL_ERROR "MSCG not found, help CMake to find it by setting MSCG_LIBRARY and MSCG_INCLUDE_DIRS, or set DOWNLOAD_MSCG=ON to download it")
|
||||
endif()
|
||||
target_link_libraries(lammps PRIVATE MSCG::MSCG)
|
||||
endif()
|
||||
target_link_libraries(lammps PRIVATE GSL::gsl ${LAPACK_LIBRARIES})
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
if(PKG_OPT)
|
||||
set(OPT_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/OPT)
|
||||
set(OPT_SOURCES)
|
||||
set_property(GLOBAL PROPERTY "OPT_SOURCES" "${OPT_SOURCES}")
|
||||
set(OPT_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/OPT)
|
||||
set(OPT_SOURCES)
|
||||
set_property(GLOBAL PROPERTY "OPT_SOURCES" "${OPT_SOURCES}")
|
||||
|
||||
# detects styles which have OPT version
|
||||
RegisterStylesExt(${OPT_SOURCES_DIR} opt OPT_SOURCES)
|
||||
# detects styles which have OPT version
|
||||
RegisterStylesExt(${OPT_SOURCES_DIR} opt OPT_SOURCES)
|
||||
|
||||
get_property(OPT_SOURCES GLOBAL PROPERTY OPT_SOURCES)
|
||||
get_property(OPT_SOURCES GLOBAL PROPERTY OPT_SOURCES)
|
||||
|
||||
list(APPEND LIB_SOURCES ${OPT_SOURCES})
|
||||
include_directories(${OPT_SOURCES_DIR})
|
||||
endif()
|
||||
target_sources(lammps PRIVATE ${OPT_SOURCES})
|
||||
target_include_directories(lammps PRIVATE ${OPT_SOURCES_DIR})
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
if(PKG_PYTHON)
|
||||
find_package(PythonLibs REQUIRED)
|
||||
add_definitions(-DLMP_PYTHON)
|
||||
include_directories(${PYTHON_INCLUDE_DIR})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${PYTHON_LIBRARY})
|
||||
if(CMAKE_VERSION VERSION_LESS 3.12)
|
||||
find_package(PythonLibs REQUIRED) # Deprecated since version 3.12
|
||||
target_include_directories(lammps PRIVATE ${PYTHON_INCLUDE_DIR})
|
||||
target_link_libraries(lammps PRIVATE ${PYTHON_LIBRARY})
|
||||
else()
|
||||
find_package(Python REQUIRED COMPONENTS Development)
|
||||
target_link_libraries(lammps PRIVATE Python::Python)
|
||||
endif()
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_PYTHON)
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
# Fix qeq/fire requires MANYBODY (i.e. COMB and COMB3) to be installed
|
||||
if(PKG_QEQ)
|
||||
set(QEQ_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/QEQ)
|
||||
file(GLOB QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix*.h)
|
||||
file(GLOB QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix*.cpp)
|
||||
set(QEQ_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/QEQ)
|
||||
file(GLOB QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix*.h)
|
||||
file(GLOB QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix*.cpp)
|
||||
|
||||
if(NOT PKG_MANYBODY)
|
||||
list(REMOVE_ITEM QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix_qeq_fire.h)
|
||||
list(REMOVE_ITEM QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix_qeq_fire.cpp)
|
||||
endif()
|
||||
set_property(GLOBAL PROPERTY "QEQ_SOURCES" "${QEQ_SOURCES}")
|
||||
|
||||
foreach(MY_HEADER ${QEQ_HEADERS})
|
||||
AddStyleHeader(${MY_HEADER} FIX)
|
||||
endforeach()
|
||||
|
||||
get_property(QEQ_SOURCES GLOBAL PROPERTY QEQ_SOURCES)
|
||||
list(APPEND LIB_SOURCES ${QEQ_SOURCES})
|
||||
include_directories(${QEQ_SOURCES_DIR})
|
||||
if(NOT PKG_MANYBODY)
|
||||
list(REMOVE_ITEM QEQ_HEADERS ${QEQ_SOURCES_DIR}/fix_qeq_fire.h)
|
||||
list(REMOVE_ITEM QEQ_SOURCES ${QEQ_SOURCES_DIR}/fix_qeq_fire.cpp)
|
||||
endif()
|
||||
set_property(GLOBAL PROPERTY "QEQ_SOURCES" "${QEQ_SOURCES}")
|
||||
|
||||
foreach(MY_HEADER ${QEQ_HEADERS})
|
||||
AddStyleHeader(${MY_HEADER} FIX)
|
||||
endforeach()
|
||||
|
||||
get_property(QEQ_SOURCES GLOBAL PROPERTY QEQ_SOURCES)
|
||||
target_sources(lammps PRIVATE ${QEQ_SOURCES})
|
||||
target_include_directories(lammps PRIVATE ${QEQ_SOURCES_DIR})
|
||||
|
||||
@ -1,27 +1,32 @@
|
||||
if(PKG_USER-COLVARS)
|
||||
set(COLVARS_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars)
|
||||
|
||||
set(COLVARS_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars)
|
||||
file(GLOB COLVARS_SOURCES ${COLVARS_SOURCE_DIR}/[^.]*.cpp)
|
||||
|
||||
file(GLOB COLVARS_SOURCES ${COLVARS_SOURCE_DIR}/[^.]*.cpp)
|
||||
# Build Lepton by default
|
||||
option(COLVARS_LEPTON "Build and link the Lepton library" ON)
|
||||
|
||||
# Build Lepton by default
|
||||
option(COLVARS_LEPTON "Build and link the Lepton library" ON)
|
||||
|
||||
if(COLVARS_LEPTON)
|
||||
set(LEPTON_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars/lepton)
|
||||
file(GLOB LEPTON_SOURCES ${LEPTON_DIR}/src/[^.]*.cpp)
|
||||
add_library(lepton STATIC ${LEPTON_SOURCES})
|
||||
target_include_directories(lepton PRIVATE ${LEPTON_DIR}/include)
|
||||
if(COLVARS_LEPTON)
|
||||
set(LEPTON_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars/lepton)
|
||||
file(GLOB LEPTON_SOURCES ${LEPTON_DIR}/src/[^.]*.cpp)
|
||||
add_library(lepton STATIC ${LEPTON_SOURCES})
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS lepton EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
add_library(colvars STATIC ${COLVARS_SOURCES})
|
||||
target_include_directories(colvars PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/colvars)
|
||||
list(APPEND LAMMPS_LINK_LIBS colvars)
|
||||
|
||||
if(COLVARS_LEPTON)
|
||||
list(APPEND LAMMPS_LINK_LIBS lepton)
|
||||
target_compile_options(colvars PRIVATE -DLEPTON)
|
||||
target_include_directories(colvars PUBLIC ${LEPTON_DIR}/include)
|
||||
endif()
|
||||
|
||||
set_target_properties(lepton PROPERTIES OUTPUT_NAME lammps_lepton${LAMMPS_LIB_SUFFIX})
|
||||
target_include_directories(lepton PRIVATE ${LEPTON_DIR}/include)
|
||||
endif()
|
||||
|
||||
add_library(colvars STATIC ${COLVARS_SOURCES})
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS colvars EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
target_compile_definitions(colvars PRIVATE -DLAMMPS_${LAMMPS_SIZES})
|
||||
set_target_properties(colvars PROPERTIES OUTPUT_NAME lammps_colvars${LAMMPS_LIB_SUFFIX})
|
||||
target_include_directories(colvars PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/colvars)
|
||||
target_link_libraries(lammps PRIVATE colvars)
|
||||
|
||||
if(COLVARS_LEPTON)
|
||||
target_link_libraries(lammps PRIVATE lepton)
|
||||
target_compile_options(colvars PRIVATE -DLEPTON)
|
||||
target_include_directories(colvars PUBLIC ${LEPTON_DIR}/include)
|
||||
endif()
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
if(PKG_USER-H5MD)
|
||||
enable_language(C)
|
||||
enable_language(C)
|
||||
|
||||
find_package(HDF5 REQUIRED)
|
||||
target_link_libraries(h5md ${HDF5_LIBRARIES})
|
||||
target_include_directories(h5md PRIVATE ${HDF5_INCLUDE_DIRS})
|
||||
include_directories(${HDF5_INCLUDE_DIRS})
|
||||
endif()
|
||||
find_package(HDF5 REQUIRED)
|
||||
target_link_libraries(h5md PRIVATE ${HDF5_LIBRARIES})
|
||||
target_include_directories(h5md PUBLIC ${HDF5_INCLUDE_DIRS})
|
||||
|
||||
@ -1,113 +1,109 @@
|
||||
if(PKG_USER-INTEL)
|
||||
check_include_file_cxx(immintrin.h FOUND_IMMINTRIN)
|
||||
if(NOT FOUND_IMMINTRIN)
|
||||
message(FATAL_ERROR "immintrin.h header not found, Intel package won't work without it")
|
||||
endif()
|
||||
|
||||
add_definitions(-DLMP_USER_INTEL)
|
||||
|
||||
set(INTEL_ARCH "cpu" CACHE STRING "Architectures used by USER-INTEL (cpu or knl)")
|
||||
set(INTEL_ARCH_VALUES cpu knl)
|
||||
set_property(CACHE INTEL_ARCH PROPERTY STRINGS ${INTEL_ARCH_VALUES})
|
||||
validate_option(INTEL_ARCH INTEL_ARCH_VALUES)
|
||||
string(TOUPPER ${INTEL_ARCH} INTEL_ARCH)
|
||||
|
||||
find_package(Threads QUIET)
|
||||
if(Threads_FOUND)
|
||||
set(INTEL_LRT_MODE "threads" CACHE STRING "Long-range threads mode (none, threads, or c++11)")
|
||||
else()
|
||||
set(INTEL_LRT_MODE "none" CACHE STRING "Long-range threads mode (none, threads, or c++11)")
|
||||
endif()
|
||||
set(INTEL_LRT_VALUES none threads c++11)
|
||||
set_property(CACHE INTEL_LRT_MODE PROPERTY STRINGS ${INTEL_LRT_VALUES})
|
||||
validate_option(INTEL_LRT_MODE INTEL_LRT_VALUES)
|
||||
string(TOUPPER ${INTEL_LRT_MODE} INTEL_LRT_MODE)
|
||||
if(INTEL_LRT_MODE STREQUAL "THREADS")
|
||||
if(Threads_FOUND)
|
||||
add_definitions(-DLMP_INTEL_USELRT)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${CMAKE_THREAD_LIBS_INIT})
|
||||
else()
|
||||
message(FATAL_ERROR "Must have working threads library for Long-range thread support")
|
||||
endif()
|
||||
endif()
|
||||
if(INTEL_LRT_MODE STREQUAL "C++11")
|
||||
add_definitions(-DLMP_INTEL_USELRT -DLMP_INTEL_LRT11)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
|
||||
message(FATAL_ERROR "USER-INTEL needs at least a 2016 Intel compiler, found ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "USER-INTEL gives best performance with Intel compilers")
|
||||
endif()
|
||||
|
||||
find_package(TBB QUIET)
|
||||
if(TBB_FOUND)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${TBB_MALLOC_LIBRARIES})
|
||||
else()
|
||||
add_definitions(-DLMP_INTEL_NO_TBB)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
message(WARNING "USER-INTEL with Intel compilers should use TBB malloc libraries")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(MKL QUIET)
|
||||
if(MKL_FOUND)
|
||||
add_definitions(-DLMP_USE_MKL_RNG)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${MKL_LIBRARIES})
|
||||
else()
|
||||
message(STATUS "Pair style dpd/intel will be faster with MKL libraries")
|
||||
endif()
|
||||
|
||||
if((NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "64") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "128") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "256"))
|
||||
message(FATAL_ERROR "USER-INTEL only supports memory alignment of 64, 128 or 256 on this platform")
|
||||
endif()
|
||||
|
||||
if(INTEL_ARCH STREQUAL "KNL")
|
||||
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
message(FATAL_ERROR "Must use Intel compiler with USER-INTEL for KNL architecture")
|
||||
endif()
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -xHost -qopenmp -qoffload")
|
||||
set(MIC_OPTIONS "-qoffload-option,mic,compiler,\"-fp-model fast=2 -mGLOB_default_function_attrs=\\\"gather_scatter_loop_unroll=4\\\"\"")
|
||||
add_compile_options(-xMIC-AVX512 -qoffload -fno-alias -ansi-alias -restrict -qoverride-limits ${MIC_OPTIONS})
|
||||
add_definitions(-DLMP_INTEL_OFFLOAD)
|
||||
else()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
include(CheckCXXCompilerFlag)
|
||||
foreach(_FLAG -O2 -fp-model fast=2 -no-prec-div -qoverride-limits -qopt-zmm-usage=high -qno-offload -fno-alias -ansi-alias -restrict)
|
||||
check_cxx_compiler_flag("${__FLAG}" COMPILER_SUPPORTS${_FLAG})
|
||||
if(COMPILER_SUPPORTS${_FLAG})
|
||||
add_compile_options(${_FLAG})
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
add_compile_options(-O3 -ffast-math)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# collect sources
|
||||
set(USER-INTEL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-INTEL)
|
||||
set(USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/fix_intel.cpp
|
||||
${USER-INTEL_SOURCES_DIR}/fix_nh_intel.cpp
|
||||
${USER-INTEL_SOURCES_DIR}/intel_buffers.cpp
|
||||
${USER-INTEL_SOURCES_DIR}/nbin_intel.cpp
|
||||
${USER-INTEL_SOURCES_DIR}/npair_intel.cpp)
|
||||
|
||||
set_property(GLOBAL PROPERTY "USER-INTEL_SOURCES" "${USER-INTEL_SOURCES}")
|
||||
|
||||
# detect styles which have a USER-INTEL version
|
||||
RegisterStylesExt(${USER-INTEL_SOURCES_DIR} intel USER-INTEL_SOURCES)
|
||||
RegisterNBinStyle(${USER-INTEL_SOURCES_DIR}/nbin_intel.h)
|
||||
RegisterNPairStyle(${USER-INTEL_SOURCES_DIR}/npair_intel.h)
|
||||
RegisterFixStyle(${USER-INTEL_SOURCES_DIR}/fix_intel.h)
|
||||
|
||||
get_property(USER-INTEL_SOURCES GLOBAL PROPERTY USER-INTEL_SOURCES)
|
||||
if(PKG_KSPACE)
|
||||
list(APPEND USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.cpp)
|
||||
RegisterIntegrateStyle(${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.h)
|
||||
endif()
|
||||
|
||||
list(APPEND LIB_SOURCES ${USER-INTEL_SOURCES})
|
||||
include_directories(${USER-INTEL_SOURCES_DIR})
|
||||
check_include_file_cxx(immintrin.h FOUND_IMMINTRIN)
|
||||
if(NOT FOUND_IMMINTRIN)
|
||||
message(FATAL_ERROR "immintrin.h header not found, Intel package won't work without it")
|
||||
endif()
|
||||
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_USER_INTEL)
|
||||
|
||||
set(INTEL_ARCH "cpu" CACHE STRING "Architectures used by USER-INTEL (cpu or knl)")
|
||||
set(INTEL_ARCH_VALUES cpu knl)
|
||||
set_property(CACHE INTEL_ARCH PROPERTY STRINGS ${INTEL_ARCH_VALUES})
|
||||
validate_option(INTEL_ARCH INTEL_ARCH_VALUES)
|
||||
string(TOUPPER ${INTEL_ARCH} INTEL_ARCH)
|
||||
|
||||
find_package(Threads QUIET)
|
||||
if(Threads_FOUND)
|
||||
set(INTEL_LRT_MODE "threads" CACHE STRING "Long-range threads mode (none, threads, or c++11)")
|
||||
else()
|
||||
set(INTEL_LRT_MODE "none" CACHE STRING "Long-range threads mode (none, threads, or c++11)")
|
||||
endif()
|
||||
set(INTEL_LRT_VALUES none threads c++11)
|
||||
set_property(CACHE INTEL_LRT_MODE PROPERTY STRINGS ${INTEL_LRT_VALUES})
|
||||
validate_option(INTEL_LRT_MODE INTEL_LRT_VALUES)
|
||||
string(TOUPPER ${INTEL_LRT_MODE} INTEL_LRT_MODE)
|
||||
if(INTEL_LRT_MODE STREQUAL "THREADS")
|
||||
if(Threads_FOUND)
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_INTEL_USELRT)
|
||||
target_link_libraries(lammps PRIVATE Threads::Threads)
|
||||
else()
|
||||
message(FATAL_ERROR "Must have working threads library for Long-range thread support")
|
||||
endif()
|
||||
endif()
|
||||
if(INTEL_LRT_MODE STREQUAL "C++11")
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_INTEL_USELRT -DLMP_INTEL_LRT11)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
|
||||
message(FATAL_ERROR "USER-INTEL needs at least a 2016 Intel compiler, found ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "USER-INTEL gives best performance with Intel compilers")
|
||||
endif()
|
||||
|
||||
find_package(TBB_MALLOC QUIET)
|
||||
if(TBB_MALLOC_FOUND)
|
||||
target_link_libraries(lammps PRIVATE TBB::TBB_MALLOC)
|
||||
else()
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_INTEL_NO_TBB)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
message(WARNING "USER-INTEL with Intel compilers should use TBB malloc libraries")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(MKL QUIET)
|
||||
if(MKL_FOUND)
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_USE_MKL_RNG)
|
||||
target_link_libraries(lammps PRIVATE MKL::MKL)
|
||||
else()
|
||||
message(STATUS "Pair style dpd/intel will be faster with MKL libraries")
|
||||
endif()
|
||||
|
||||
if((NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "64") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "128") AND (NOT ${LAMMPS_MEMALIGN} STREQUAL "256"))
|
||||
message(FATAL_ERROR "USER-INTEL only supports memory alignment of 64, 128 or 256 on this platform")
|
||||
endif()
|
||||
|
||||
if(INTEL_ARCH STREQUAL "KNL")
|
||||
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
message(FATAL_ERROR "Must use Intel compiler with USER-INTEL for KNL architecture")
|
||||
endif()
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -xHost -qopenmp -qoffload")
|
||||
set(MIC_OPTIONS "-qoffload-option,mic,compiler,\"-fp-model fast=2 -mGLOB_default_function_attrs=\\\"gather_scatter_loop_unroll=4\\\"\"")
|
||||
target_compile_options(lammps PRIVATE -xMIC-AVX512 -qoffload -fno-alias -ansi-alias -restrict -qoverride-limits ${MIC_OPTIONS})
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_INTEL_OFFLOAD)
|
||||
else()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
include(CheckCXXCompilerFlag)
|
||||
foreach(_FLAG -O2 -fp-model fast=2 -no-prec-div -qoverride-limits -qopt-zmm-usage=high -qno-offload -fno-alias -ansi-alias -restrict)
|
||||
check_cxx_compiler_flag("${_FLAG}" COMPILER_SUPPORTS${_FLAG})
|
||||
if(COMPILER_SUPPORTS${_FLAG})
|
||||
target_compile_options(lammps PRIVATE ${_FLAG})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# collect sources
|
||||
set(USER-INTEL_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-INTEL)
|
||||
set(USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/fix_intel.cpp
|
||||
${USER-INTEL_SOURCES_DIR}/fix_nh_intel.cpp
|
||||
${USER-INTEL_SOURCES_DIR}/intel_buffers.cpp
|
||||
${USER-INTEL_SOURCES_DIR}/nbin_intel.cpp
|
||||
${USER-INTEL_SOURCES_DIR}/npair_intel.cpp)
|
||||
|
||||
set_property(GLOBAL PROPERTY "USER-INTEL_SOURCES" "${USER-INTEL_SOURCES}")
|
||||
|
||||
# detect styles which have a USER-INTEL version
|
||||
RegisterStylesExt(${USER-INTEL_SOURCES_DIR} intel USER-INTEL_SOURCES)
|
||||
RegisterNBinStyle(${USER-INTEL_SOURCES_DIR}/nbin_intel.h)
|
||||
RegisterNPairStyle(${USER-INTEL_SOURCES_DIR}/npair_intel.h)
|
||||
RegisterFixStyle(${USER-INTEL_SOURCES_DIR}/fix_intel.h)
|
||||
|
||||
get_property(USER-INTEL_SOURCES GLOBAL PROPERTY USER-INTEL_SOURCES)
|
||||
if(PKG_KSPACE)
|
||||
list(APPEND USER-INTEL_SOURCES ${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.cpp)
|
||||
RegisterIntegrateStyle(${USER-INTEL_SOURCES_DIR}/verlet_lrt_intel.h)
|
||||
endif()
|
||||
|
||||
target_sources(lammps PRIVATE ${USER-INTEL_SOURCES})
|
||||
target_include_directories(lammps PRIVATE ${USER-INTEL_SOURCES_DIR})
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
if(PKG_USER-MOLFILE)
|
||||
set(MOLFILE_INCLUDE_DIRS "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers")
|
||||
add_library(molfile INTERFACE)
|
||||
target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS})
|
||||
# no need to link with -ldl on windows
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(molfile INTERFACE ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
list(APPEND LAMMPS_LINK_LIBS molfile)
|
||||
set(MOLFILE_INCLUDE_DIRS "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers")
|
||||
add_library(molfile INTERFACE)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS molfile EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS})
|
||||
# no need to link with -ldl on windows
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(molfile INTERFACE ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
target_link_libraries(lammps PRIVATE molfile)
|
||||
|
||||
@ -1,24 +1,20 @@
|
||||
if(PKG_USER-NETCDF)
|
||||
# USER-NETCDF can use NetCDF, Parallel NetCDF (PNetCDF), or both. At least one necessary.
|
||||
# NetCDF library enables dump style "netcdf", while PNetCDF enables dump style "netcdf/mpiio"
|
||||
find_package(NetCDF)
|
||||
if(NETCDF_FOUND)
|
||||
find_package(PNetCDF)
|
||||
else(NETCDF_FOUND)
|
||||
find_package(PNetCDF REQUIRED)
|
||||
endif(NETCDF_FOUND)
|
||||
# USER-NETCDF can use NetCDF, Parallel NetCDF (PNetCDF), or both. At least one necessary.
|
||||
# NetCDF library enables dump style "netcdf", while PNetCDF enables dump style "netcdf/mpiio"
|
||||
find_package(NetCDF)
|
||||
if(NETCDF_FOUND)
|
||||
find_package(PNetCDF)
|
||||
else(NETCDF_FOUND)
|
||||
find_package(PNetCDF REQUIRED)
|
||||
endif(NETCDF_FOUND)
|
||||
|
||||
if(NETCDF_FOUND)
|
||||
include_directories(${NETCDF_INCLUDE_DIRS})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${NETCDF_LIBRARIES})
|
||||
add_definitions(-DLMP_HAS_NETCDF)
|
||||
endif(NETCDF_FOUND)
|
||||
if(NETCDF_FOUND)
|
||||
target_link_libraries(lammps PRIVATE NetCDF::NetCDF)
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_HAS_NETCDF)
|
||||
endif(NETCDF_FOUND)
|
||||
|
||||
if(PNETCDF_FOUND)
|
||||
include_directories(${PNETCDF_INCLUDES})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${PNETCDF_LIBRARIES})
|
||||
add_definitions(-DLMP_HAS_PNETCDF)
|
||||
endif(PNETCDF_FOUND)
|
||||
if(PNETCDF_FOUND)
|
||||
target_link_libraries(lammps PRIVATE PNetCDF::PNetCDF)
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_HAS_PNETCDF)
|
||||
endif(PNETCDF_FOUND)
|
||||
|
||||
add_definitions(-DNC_64BIT_DATA=0x0020)
|
||||
endif()
|
||||
target_compile_definitions(lammps PRIVATE -DNC_64BIT_DATA=0x0020)
|
||||
|
||||
@ -1,42 +1,40 @@
|
||||
if(PKG_USER-OMP)
|
||||
set(USER-OMP_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-OMP)
|
||||
set(USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/thr_data.cpp
|
||||
${USER-OMP_SOURCES_DIR}/thr_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/fix_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/fix_nh_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/fix_nh_sphere_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/domain_omp.cpp)
|
||||
add_definitions(-DLMP_USER_OMP)
|
||||
set_property(GLOBAL PROPERTY "OMP_SOURCES" "${USER-OMP_SOURCES}")
|
||||
set(USER-OMP_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-OMP)
|
||||
set(USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/thr_data.cpp
|
||||
${USER-OMP_SOURCES_DIR}/thr_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/fix_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/fix_nh_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/fix_nh_sphere_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/domain_omp.cpp)
|
||||
target_compile_definitions(lammps PRIVATE -DLMP_USER_OMP)
|
||||
set_property(GLOBAL PROPERTY "OMP_SOURCES" "${USER-OMP_SOURCES}")
|
||||
|
||||
# detects styles which have USER-OMP version
|
||||
RegisterStylesExt(${USER-OMP_SOURCES_DIR} omp OMP_SOURCES)
|
||||
RegisterFixStyle(${USER-OMP_SOURCES_DIR}/fix_omp.h)
|
||||
# detects styles which have USER-OMP version
|
||||
RegisterStylesExt(${USER-OMP_SOURCES_DIR} omp OMP_SOURCES)
|
||||
RegisterFixStyle(${USER-OMP_SOURCES_DIR}/fix_omp.h)
|
||||
|
||||
get_property(USER-OMP_SOURCES GLOBAL PROPERTY OMP_SOURCES)
|
||||
get_property(USER-OMP_SOURCES GLOBAL PROPERTY OMP_SOURCES)
|
||||
|
||||
# manually add package dependent source files from USER-OMP that do not provide styles
|
||||
# manually add package dependent source files from USER-OMP that do not provide styles
|
||||
|
||||
if(PKG_ASPHERE)
|
||||
list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_nh_asphere_omp.cpp)
|
||||
endif()
|
||||
if(PKG_ASPHERE)
|
||||
list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_nh_asphere_omp.cpp)
|
||||
endif()
|
||||
|
||||
if(PKG_RIGID)
|
||||
list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_rigid_nh_omp.cpp)
|
||||
endif()
|
||||
if(PKG_RIGID)
|
||||
list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/fix_rigid_nh_omp.cpp)
|
||||
endif()
|
||||
|
||||
if(PKG_USER-REAXC)
|
||||
list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/reaxc_bond_orders_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_hydrogen_bonds_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_nonbonded_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_bonds_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_init_md_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_torsion_angles_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_forces_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_multi_body_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_valence_angles_omp.cpp)
|
||||
endif()
|
||||
if(PKG_USER-REAXC)
|
||||
list(APPEND USER-OMP_SOURCES ${USER-OMP_SOURCES_DIR}/reaxc_bond_orders_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_hydrogen_bonds_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_nonbonded_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_bonds_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_init_md_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_torsion_angles_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_forces_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_multi_body_omp.cpp
|
||||
${USER-OMP_SOURCES_DIR}/reaxc_valence_angles_omp.cpp)
|
||||
endif()
|
||||
|
||||
list(APPEND LIB_SOURCES ${USER-OMP_SOURCES})
|
||||
include_directories(${USER-OMP_SOURCES_DIR})
|
||||
endif()
|
||||
target_sources(lammps PRIVATE ${USER-OMP_SOURCES})
|
||||
target_include_directories(lammps PRIVATE ${USER-OMP_SOURCES_DIR})
|
||||
|
||||
@ -1,96 +1,103 @@
|
||||
if(PKG_USER-PLUMED)
|
||||
set(PLUMED_MODE "static" CACHE STRING "Linkage mode for Plumed2 library")
|
||||
set(PLUMED_MODE_VALUES static shared runtime)
|
||||
set_property(CACHE PLUMED_MODE PROPERTY STRINGS ${PLUMED_MODE_VALUES})
|
||||
validate_option(PLUMED_MODE PLUMED_MODE_VALUES)
|
||||
string(TOUPPER ${PLUMED_MODE} PLUMED_MODE)
|
||||
set(PLUMED_MODE "static" CACHE STRING "Linkage mode for Plumed2 library")
|
||||
set(PLUMED_MODE_VALUES static shared runtime)
|
||||
set_property(CACHE PLUMED_MODE PROPERTY STRINGS ${PLUMED_MODE_VALUES})
|
||||
validate_option(PLUMED_MODE PLUMED_MODE_VALUES)
|
||||
string(TOUPPER ${PLUMED_MODE} PLUMED_MODE)
|
||||
|
||||
set(PLUMED_LINK_LIBS "")
|
||||
if(PLUMED_MODE STREQUAL "STATIC")
|
||||
find_package(LAPACK REQUIRED)
|
||||
find_package(BLAS REQUIRED)
|
||||
find_package(GSL REQUIRED)
|
||||
list(APPEND LAPACK_LIBRARIES ${BLAS_LIBRARIES})
|
||||
list(APPEND PLUMED_LINK_LIBS ${LAPACK_LIBRARIES} ${GSL_LIBRARIES})
|
||||
find_package(ZLIB QUIET)
|
||||
if(ZLIB_FOUND)
|
||||
list(APPEND PLUMED_LINK_LIBS ${ZLIB_LIBRARIES})
|
||||
endif()
|
||||
set(PLUMED_LINK_LIBS)
|
||||
if(PLUMED_MODE STREQUAL "STATIC")
|
||||
find_package(LAPACK REQUIRED)
|
||||
find_package(BLAS REQUIRED)
|
||||
find_package(GSL REQUIRED)
|
||||
list(APPEND PLUMED_LINK_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} GSL::gsl)
|
||||
find_package(ZLIB QUIET)
|
||||
if(ZLIB_FOUND)
|
||||
list(APPEND PLUMED_LINK_LIBS ZLIB::ZLIB)
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
set(DOWNLOAD_PLUMED_DEFAULT ON)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PLUMED QUIET plumed)
|
||||
if(PLUMED_FOUND)
|
||||
set(DOWNLOAD_PLUMED_DEFAULT OFF)
|
||||
endif()
|
||||
find_package(FFTW3 QUIET)
|
||||
if(FFTW3_FOUND)
|
||||
list(APPEND PLUMED_LINK_LIBS FFTW3::FFTW3)
|
||||
endif()
|
||||
|
||||
option(DOWNLOAD_PLUMED "Download Plumed package instead of using an already installed one" ${DOWNLOAD_PLUMED_DEFAULT})
|
||||
if(DOWNLOAD_PLUMED)
|
||||
if(BUILD_MPI)
|
||||
set(PLUMED_CONFIG_MPI "--enable-mpi")
|
||||
set(PLUMED_CONFIG_CC ${CMAKE_MPI_C_COMPILER})
|
||||
set(PLUMED_CONFIG_CXX ${CMAKE_MPI_CXX_COMPILER})
|
||||
else()
|
||||
set(PLUMED_CONFIG_MPI "--disable-mpi")
|
||||
set(PLUMED_CONFIG_CC ${CMAKE_C_COMPILER})
|
||||
set(PLUMED_CONFIG_CXX ${CMAKE_CXX_COMPILER})
|
||||
endif()
|
||||
if(BUILD_OMP)
|
||||
set(PLUMED_CONFIG_OMP "--enable-openmp")
|
||||
else()
|
||||
set(PLUMED_CONFIG_OMP "--disable-openmp")
|
||||
endif()
|
||||
message(STATUS "PLUMED download requested - we will build our own")
|
||||
if(PLUMED_MODE STREQUAL "STATIC")
|
||||
set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/libplumed.a")
|
||||
elseif(PLUMED_MODE STREQUAL "SHARED")
|
||||
set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/libplumed${CMAKE_SHARED_LIBRARY_SUFFIX};<INSTALL_DIR>/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
elseif(PLUMED_MODE STREQUAL "RUNTIME")
|
||||
set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/libplumedWrapper.a")
|
||||
endif()
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(plumed_build
|
||||
URL https://github.com/plumed/plumed2/releases/download/v2.6.0/plumed-src-2.6.0.tgz
|
||||
URL_MD5 204d2edae58d9b10ba3ad460cad64191
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
|
||||
${CONFIGURE_REQUEST_PIC}
|
||||
--enable-modules=all
|
||||
${PLUMED_CONFIG_MPI}
|
||||
${PLUMED_CONFIG_OMP}
|
||||
CXX=${PLUMED_CONFIG_CXX}
|
||||
CC=${PLUMED_CONFIG_CC}
|
||||
BUILD_BYPRODUCTS ${PLUMED_BUILD_BYPRODUCTS}
|
||||
)
|
||||
ExternalProject_get_property(plumed_build INSTALL_DIR)
|
||||
set(PLUMED_INSTALL_DIR ${INSTALL_DIR})
|
||||
list(APPEND LAMMPS_DEPS plumed_build)
|
||||
if(PLUMED_MODE STREQUAL "STATIC")
|
||||
add_definitions(-D__PLUMED_WRAPPER_CXX=1)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumed.a ${PLUMED_LINK_LIBS} ${CMAKE_DL_LIBS})
|
||||
elseif(PLUMED_MODE STREQUAL "SHARED")
|
||||
list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumed${CMAKE_SHARED_LIBRARY_SUFFIX} ${PLUMED_INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_DL_LIBS})
|
||||
elseif(PLUMED_MODE STREQUAL "RUNTIME")
|
||||
add_definitions(-D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumedWrapper.a -rdynamic ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
set(PLUMED_INCLUDE_DIRS "${PLUMED_INSTALL_DIR}/include")
|
||||
else()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(PLUMED REQUIRED plumed)
|
||||
if(PLUMED_MODE STREQUAL "STATIC")
|
||||
add_definitions(-D__PLUMED_WRAPPER_CXX=1)
|
||||
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.static)
|
||||
elseif(PLUMED_MODE STREQUAL "SHARED")
|
||||
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.shared)
|
||||
elseif(PLUMED_MODE STREQUAL "RUNTIME")
|
||||
add_definitions(-D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_LIBDIR}/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.runtime)
|
||||
endif()
|
||||
list(APPEND LAMMPS_LINK_LIBS ${PLUMED_LOAD})
|
||||
endif()
|
||||
include_directories(${PLUMED_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
set(DOWNLOAD_PLUMED_DEFAULT ON)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PLUMED QUIET plumed)
|
||||
if(PLUMED_FOUND)
|
||||
set(DOWNLOAD_PLUMED_DEFAULT OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(DOWNLOAD_PLUMED "Download Plumed package instead of using an already installed one" ${DOWNLOAD_PLUMED_DEFAULT})
|
||||
if(DOWNLOAD_PLUMED)
|
||||
if(BUILD_MPI)
|
||||
set(PLUMED_CONFIG_MPI "--enable-mpi")
|
||||
set(PLUMED_CONFIG_CC ${CMAKE_MPI_C_COMPILER})
|
||||
set(PLUMED_CONFIG_CXX ${CMAKE_MPI_CXX_COMPILER})
|
||||
else()
|
||||
set(PLUMED_CONFIG_MPI "--disable-mpi")
|
||||
set(PLUMED_CONFIG_CC ${CMAKE_C_COMPILER})
|
||||
set(PLUMED_CONFIG_CXX ${CMAKE_CXX_COMPILER})
|
||||
endif()
|
||||
if(BUILD_OMP)
|
||||
set(PLUMED_CONFIG_OMP "--enable-openmp")
|
||||
else()
|
||||
set(PLUMED_CONFIG_OMP "--disable-openmp")
|
||||
endif()
|
||||
message(STATUS "PLUMED download requested - we will build our own")
|
||||
if(PLUMED_MODE STREQUAL "STATIC")
|
||||
set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/libplumed.a")
|
||||
elseif(PLUMED_MODE STREQUAL "SHARED")
|
||||
set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/libplumed${CMAKE_SHARED_LIBRARY_SUFFIX};<INSTALL_DIR>/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
elseif(PLUMED_MODE STREQUAL "RUNTIME")
|
||||
set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/libplumedWrapper.a")
|
||||
endif()
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(plumed_build
|
||||
URL https://github.com/plumed/plumed2/releases/download/v2.6.0/plumed-src-2.6.0.tgz
|
||||
URL_MD5 204d2edae58d9b10ba3ad460cad64191
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
|
||||
${CONFIGURE_REQUEST_PIC}
|
||||
--enable-modules=all
|
||||
${PLUMED_CONFIG_MPI}
|
||||
${PLUMED_CONFIG_OMP}
|
||||
CXX=${PLUMED_CONFIG_CXX}
|
||||
CC=${PLUMED_CONFIG_CC}
|
||||
BUILD_BYPRODUCTS ${PLUMED_BUILD_BYPRODUCTS}
|
||||
)
|
||||
ExternalProject_get_property(plumed_build INSTALL_DIR)
|
||||
add_library(LAMMPS::PLUMED UNKNOWN IMPORTED)
|
||||
add_dependencies(LAMMPS::PLUMED plumed_build)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
|
||||
endif()
|
||||
if(PLUMED_MODE STREQUAL "STATIC")
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__PLUMED_WRAPPER_CXX=1")
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumed.a INTERFACE_LINK_LIBRARIES "${PLUMED_LINK_LIBS};${CMAKE_DL_LIBS}")
|
||||
elseif(PLUMED_MODE STREQUAL "SHARED")
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumed${CMAKE_SHARED_LIBRARY_SUFFIX} INTERFACE_LINK_LIBRARIES "${INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX};${CMAKE_DL_LIBS}")
|
||||
elseif(PLUMED_MODE STREQUAL "RUNTIME")
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__PLUMED_HAS_DLOPEN=1;__PLUMED_DEFAULT_KERNEL=${INSTALL_DIR}/lib/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libplumedWrapper.a INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}")
|
||||
endif()
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
|
||||
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
|
||||
else()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(PLUMED REQUIRED plumed)
|
||||
add_library(LAMMPS::PLUMED INTERFACE IMPORTED)
|
||||
if(PLUMED_MODE STREQUAL "STATIC")
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__PLUMED_WRAPPER_CXX=1")
|
||||
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.static)
|
||||
elseif(PLUMED_MODE STREQUAL "SHARED")
|
||||
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.shared)
|
||||
elseif(PLUMED_MODE STREQUAL "RUNTIME")
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__PLUMED_HAS_DLOPEN=1;__PLUMED_DEFAULT_KERNEL=${PLUMED_LIBDIR}/libplumedKernel${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.runtime)
|
||||
endif()
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_LINK_LIBRARIES "${PLUMED_LOAD}")
|
||||
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PLUMED_INCLUDE_DIRS}")
|
||||
endif()
|
||||
target_link_libraries(lammps PRIVATE LAMMPS::PLUMED)
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
if(PKG_USER-QMMM)
|
||||
enable_language(C)
|
||||
enable_language(C)
|
||||
|
||||
if(NOT BUILD_LIB)
|
||||
message(FATAL_ERROR "Building a QM/MM executable with USER-QMMM requires BUILD_LIB=yes")
|
||||
endif()
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
message(WARNING "It is recommended to use BUILD_SHARED_LIBS=yes with USER-QMMM")
|
||||
endif()
|
||||
add_library(qmmm STATIC ${LAMMPS_LIB_SOURCE_DIR}/qmmm/libqmmm.c)
|
||||
list(APPEND LAMMPS_LINK_LIBS qmmm)
|
||||
target_include_directories(qmmm PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/qmmm)
|
||||
if(NOT BUILD_LIB)
|
||||
message(FATAL_ERROR "Building a QM/MM executable with USER-QMMM requires BUILD_LIB=yes")
|
||||
endif()
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
message(WARNING "It is recommended to use BUILD_SHARED_LIBS=yes with USER-QMMM")
|
||||
endif()
|
||||
add_library(qmmm STATIC ${LAMMPS_LIB_SOURCE_DIR}/qmmm/libqmmm.c)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS qmmm EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
set_target_properties(qmmm PROPERTIES OUTPUT_NAME lammps_qmmm${LAMMPS_LIB_SUFFIX})
|
||||
target_link_libraries(lammps PRIVATE qmmm)
|
||||
target_include_directories(qmmm PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/qmmm)
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
if(PKG_USER-QUIP)
|
||||
enable_language(Fortran)
|
||||
find_package(QUIP REQUIRED)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${QUIP_LIBRARIES} ${LAPACK_LIBRARIES})
|
||||
endif()
|
||||
enable_language(Fortran)
|
||||
find_package(QUIP REQUIRED)
|
||||
target_link_libraries(lammps PRIVATE QUIP::QUIP ${LAPACK_LIBRARIES})
|
||||
|
||||
@ -1,76 +1,62 @@
|
||||
if(PKG_USER-SCAFACOS)
|
||||
enable_language(Fortran)
|
||||
enable_language(C)
|
||||
enable_language(Fortran)
|
||||
enable_language(C)
|
||||
|
||||
find_package(GSL REQUIRED)
|
||||
find_package(PkgConfig QUIET)
|
||||
find_package(MPI REQUIRED)
|
||||
set(DOWNLOAD_SCAFACOS_DEFAULT ON)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(SCAFACOS QUIET scafacos)
|
||||
if(SCAFACOS_FOUND)
|
||||
set(DOWNLOAD_SCAFACOS_DEFAULT OFF)
|
||||
endif()
|
||||
find_package(GSL REQUIRED)
|
||||
find_package(PkgConfig QUIET)
|
||||
find_package(MPI REQUIRED)
|
||||
set(DOWNLOAD_SCAFACOS_DEFAULT ON)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(SCAFACOS QUIET scafacos)
|
||||
if(SCAFACOS_FOUND)
|
||||
set(DOWNLOAD_SCAFACOS_DEFAULT OFF)
|
||||
endif()
|
||||
option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" ${DOWNLOAD_SCAFACOS_DEFAULT})
|
||||
if(DOWNLOAD_SCAFACOS)
|
||||
message(STATUS "ScaFaCoS download requested - we will build our own")
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(scafacos_build
|
||||
URL https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz
|
||||
URL_MD5 bd46d74e3296bd8a444d731bb10c1738
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --disable-doc
|
||||
--enable-fcs-solvers=fmm,p2nfft,direct,ewald,p3m
|
||||
--with-internal-fftw --with-internal-pfft
|
||||
--with-internal-pnfft ${CONFIGURE_REQUEST_PIC}
|
||||
FC=${CMAKE_MPI_Fortran_COMPILER}
|
||||
CXX=${CMAKE_MPI_CXX_COMPILER}
|
||||
CC=${CMAKE_MPI_C_COMPILER}
|
||||
F77=
|
||||
BUILD_BYPRODUCTS
|
||||
<INSTALL_DIR>/lib/libfcs.a
|
||||
<INSTALL_DIR>/lib/libfcs_direct.a
|
||||
<INSTALL_DIR>/lib/libfcs_ewald.a
|
||||
<INSTALL_DIR>/lib/libfcs_fmm.a
|
||||
<INSTALL_DIR>/lib/libfcs_p2nfft.a
|
||||
<INSTALL_DIR>/lib/libfcs_p3m.a
|
||||
<INSTALL_DIR>/lib/libfcs_near.a
|
||||
<INSTALL_DIR>/lib/libfcs_gridsort.a
|
||||
<INSTALL_DIR>/lib/libfcs_resort.a
|
||||
<INSTALL_DIR>/lib/libfcs_redist.a
|
||||
<INSTALL_DIR>/lib/libfcs_common.a
|
||||
<INSTALL_DIR>/lib/libfcs_pnfft.a
|
||||
<INSTALL_DIR>/lib/libfcs_pfft.a
|
||||
<INSTALL_DIR>/lib/libfcs_fftw3_mpi.a
|
||||
<INSTALL_DIR>/lib/libfcs_fftw3.a
|
||||
)
|
||||
ExternalProject_get_property(scafacos_build INSTALL_DIR)
|
||||
set(SCAFACOS_BUILD_DIR ${INSTALL_DIR})
|
||||
set(SCAFACOS_INCLUDE_DIRS ${SCAFACOS_BUILD_DIR}/include)
|
||||
list(APPEND LAMMPS_DEPS scafacos_build)
|
||||
# list and order from pkg_config file of ScaFaCoS build
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_direct.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_ewald.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fmm.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_p2nfft.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_p3m.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${GSL_LIBRARIES})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_near.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_gridsort.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_resort.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_redist.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_common.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_pnfft.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_pfft.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fftw3_mpi.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_BUILD_DIR}/lib/libfcs_fftw3.a)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${MPI_Fortran_LIBRARIES})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${MPI_C_LIBRARIES})
|
||||
else()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(SCAFACOS REQUIRED scafacos)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${SCAFACOS_LDFLAGS})
|
||||
endif()
|
||||
include_directories(${SCAFACOS_INCLUDE_DIRS})
|
||||
endif()
|
||||
option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" ${DOWNLOAD_SCAFACOS_DEFAULT})
|
||||
if(DOWNLOAD_SCAFACOS)
|
||||
message(STATUS "ScaFaCoS download requested - we will build our own")
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(scafacos_build
|
||||
URL https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz
|
||||
URL_MD5 bd46d74e3296bd8a444d731bb10c1738
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --disable-doc
|
||||
--enable-fcs-solvers=fmm,p2nfft,direct,ewald,p3m
|
||||
--with-internal-fftw --with-internal-pfft
|
||||
--with-internal-pnfft ${CONFIGURE_REQUEST_PIC}
|
||||
FC=${CMAKE_MPI_Fortran_COMPILER}
|
||||
CXX=${CMAKE_MPI_CXX_COMPILER}
|
||||
CC=${CMAKE_MPI_C_COMPILER}
|
||||
F77=
|
||||
BUILD_BYPRODUCTS
|
||||
<INSTALL_DIR>/lib/libfcs.a
|
||||
<INSTALL_DIR>/lib/libfcs_direct.a
|
||||
<INSTALL_DIR>/lib/libfcs_ewald.a
|
||||
<INSTALL_DIR>/lib/libfcs_fmm.a
|
||||
<INSTALL_DIR>/lib/libfcs_p2nfft.a
|
||||
<INSTALL_DIR>/lib/libfcs_p3m.a
|
||||
<INSTALL_DIR>/lib/libfcs_near.a
|
||||
<INSTALL_DIR>/lib/libfcs_gridsort.a
|
||||
<INSTALL_DIR>/lib/libfcs_resort.a
|
||||
<INSTALL_DIR>/lib/libfcs_redist.a
|
||||
<INSTALL_DIR>/lib/libfcs_common.a
|
||||
<INSTALL_DIR>/lib/libfcs_pnfft.a
|
||||
<INSTALL_DIR>/lib/libfcs_pfft.a
|
||||
<INSTALL_DIR>/lib/libfcs_fftw3_mpi.a
|
||||
<INSTALL_DIR>/lib/libfcs_fftw3.a
|
||||
)
|
||||
ExternalProject_get_property(scafacos_build INSTALL_DIR)
|
||||
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
|
||||
add_library(LAMMPS::SCAFACOS UNKNOWN IMPORTED)
|
||||
set_target_properties(LAMMPS::SCAFACOS PROPERTIES
|
||||
IMPORTED_LOCATION "${INSTALL_DIR}/lib/libfcs.a"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include"
|
||||
INTERFACE_LINK_LIBRARIES "${INSTALL_DIR}/lib/libfcs.a;${INSTALL_DIR}/lib/libfcs_direct.a;${INSTALL_DIR}/lib/libfcs_ewald.a;${INSTALL_DIR}/lib/libfcs_fmm.a;${INSTALL_DIR}/lib/libfcs_p2nfft.a;${INSTALL_DIR}/lib/libfcs_p3m.a;GSL::gsl;${INSTALL_DIR}/lib/libfcs_near.a;${INSTALL_DIR}/lib/libfcs_gridsort.a;${INSTALL_DIR}/lib/libfcs_resort.a;${INSTALL_DIR}/lib/libfcs_redist.a;${INSTALL_DIR}/lib/libfcs_common.a;${INSTALL_DIR}/lib/libfcs_pnfft.a;${INSTALL_DIR}/lib/libfcs_pfft.a;${INSTALL_DIR}/lib/libfcs_fftw3_mpi.a;${INSTALL_DIR}/lib/libfcs_fftw3.a;MPI::MPI_Fortran;MPI::MPI_C")
|
||||
target_link_libraries(lammps PRIVATE LAMMPS::SCAFACOS)
|
||||
add_dependencies(LAMMPS::SCAFACOS scafacos_build)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
|
||||
endif()
|
||||
else()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(SCAFACOS REQUIRED IMPORTED_TARGET scafacos)
|
||||
target_link_libraries(lammps PRIVATE PkgConfig::SCAFACOS)
|
||||
endif()
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
# Fix rigid/meso requires RIGID to be installed
|
||||
if(PKG_USER-SDPD)
|
||||
set(USER-SDPD_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-SDPD)
|
||||
set(USER-SDPD_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-SDPD)
|
||||
|
||||
get_property(hlist GLOBAL PROPERTY FIX)
|
||||
if(NOT PKG_RIGID)
|
||||
list(REMOVE_ITEM hlist ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.h)
|
||||
list(REMOVE_ITEM LIB_SOURCES ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.cpp)
|
||||
endif()
|
||||
set_property(GLOBAL PROPERTY FIX "${hlist}")
|
||||
|
||||
include_directories(${USER-SDPD_SOURCES_DIR})
|
||||
get_property(hlist GLOBAL PROPERTY FIX)
|
||||
if(NOT PKG_RIGID)
|
||||
list(REMOVE_ITEM hlist ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.h)
|
||||
get_target_property(LAMMPS_SOURCES lammps SOURCES)
|
||||
list(REMOVE_ITEM LAMMPS_SOURCES ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.cpp)
|
||||
set_property(TARGET lammps PROPERTY SOURCES ${LAMMPS_SOURCES})
|
||||
endif()
|
||||
set_property(GLOBAL PROPERTY FIX "${hlist}")
|
||||
|
||||
target_include_directories(lammps PRIVATE ${USER-SDPD_SOURCES_DIR})
|
||||
|
||||
@ -1,28 +1,31 @@
|
||||
if(PKG_USER-SMD)
|
||||
find_package(Eigen3 NO_MODULE)
|
||||
if(EIGEN3_FOUND)
|
||||
set(DOWNLOAD_EIGEN3_DEFAULT OFF)
|
||||
else()
|
||||
set(DOWNLOAD_EIGEN3_DEFAULT ON)
|
||||
endif()
|
||||
option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" ${DOWNLOAD_EIGEN3_DEFAULT})
|
||||
if(DOWNLOAD_EIGEN3)
|
||||
message(STATUS "Eigen3 download requested - we will build our own")
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(Eigen3_build
|
||||
URL http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz
|
||||
URL_MD5 f2a417d083fe8ca4b8ed2bc613d20f07
|
||||
CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND ""
|
||||
)
|
||||
ExternalProject_get_property(Eigen3_build SOURCE_DIR)
|
||||
set(EIGEN3_INCLUDE_DIR ${SOURCE_DIR})
|
||||
list(APPEND LAMMPS_DEPS Eigen3_build)
|
||||
else()
|
||||
find_package(Eigen3 NO_MODULE)
|
||||
mark_as_advanced(Eigen3_DIR)
|
||||
if(NOT EIGEN3_FOUND)
|
||||
message(FATAL_ERROR "Eigen3 not found, help CMake to find it by setting EIGEN3_INCLUDE_DIR, or set DOWNLOAD_EIGEN3=ON to download it")
|
||||
endif()
|
||||
endif()
|
||||
include_directories(${EIGEN3_INCLUDE_DIR})
|
||||
find_package(Eigen3 NO_MODULE)
|
||||
if(EIGEN3_FOUND)
|
||||
set(DOWNLOAD_EIGEN3_DEFAULT OFF)
|
||||
else()
|
||||
set(DOWNLOAD_EIGEN3_DEFAULT ON)
|
||||
endif()
|
||||
option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" ${DOWNLOAD_EIGEN3_DEFAULT})
|
||||
if(DOWNLOAD_EIGEN3)
|
||||
message(STATUS "Eigen3 download requested - we will build our own")
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(Eigen3_build
|
||||
URL http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz
|
||||
URL_MD5 f2a417d083fe8ca4b8ed2bc613d20f07
|
||||
CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND ""
|
||||
)
|
||||
ExternalProject_get_property(Eigen3_build SOURCE_DIR)
|
||||
add_library(LAMMPS::EIGEN3 INTERFACE IMPORTED)
|
||||
set_target_properties(LAMMPS::EIGEN3 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}")
|
||||
target_link_libraries(lammps PRIVATE LAMMPS::EIGEN3)
|
||||
add_dependencies(LAMMPS::EIGEN3 Eigen3_build)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
|
||||
endif()
|
||||
else()
|
||||
find_package(Eigen3 NO_MODULE)
|
||||
mark_as_advanced(Eigen3_DIR)
|
||||
if(NOT EIGEN3_FOUND)
|
||||
message(FATAL_ERROR "Eigen3 not found, help CMake to find it by setting EIGEN3_INCLUDE_DIR, or set DOWNLOAD_EIGEN3=ON to download it")
|
||||
endif()
|
||||
target_link_libraries(lammps PRIVATE Eigen3::Eigen)
|
||||
endif()
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
if(PKG_USER-VTK)
|
||||
find_package(VTK REQUIRED NO_MODULE)
|
||||
include(${VTK_USE_FILE})
|
||||
add_definitions(-DLAMMPS_VTK)
|
||||
list(APPEND LAMMPS_LINK_LIBS ${VTK_LIBRARIES})
|
||||
endif()
|
||||
find_package(VTK REQUIRED NO_MODULE)
|
||||
include(${VTK_USE_FILE})
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_VTK)
|
||||
target_link_libraries(lammps PRIVATE ${VTK_LIBRARIES})
|
||||
|
||||
@ -1,43 +1,47 @@
|
||||
if(PKG_VORONOI)
|
||||
find_package(VORO)
|
||||
if(VORO_FOUND)
|
||||
set(DOWNLOAD_VORO_DEFAULT OFF)
|
||||
else()
|
||||
set(DOWNLOAD_VORO_DEFAULT ON)
|
||||
endif()
|
||||
option(DOWNLOAD_VORO "Download and compile the Voro++ library instead of using an already installed one" ${DOWNLOAD_VORO_DEFAULT})
|
||||
if(DOWNLOAD_VORO)
|
||||
message(STATUS "Voro++ download requested - we will build our own")
|
||||
include(ExternalProject)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(VORO_BUILD_CFLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}")
|
||||
else()
|
||||
set(VORO_BUILD_CFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}")
|
||||
endif()
|
||||
if(APPLE)
|
||||
get_filename_component(VORO_CXX ${CMAKE_CXX_COMPILER} NAME_WE)
|
||||
set(VORO_BUILD_OPTIONS CXX=${VORO_CXX} CFLAGS=${VORO_BUILD_CFLAGS})
|
||||
else()
|
||||
set(VORO_BUILD_OPTIONS CXX=${CMAKE_CXX_COMPILER} CFLAGS=${VORO_BUILD_CFLAGS})
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(voro_build
|
||||
URL https://download.lammps.org/thirdparty/voro++-0.4.6.tar.gz
|
||||
URL_MD5 2338b824c3b7b25590e18e8df5d68af9
|
||||
CONFIGURE_COMMAND "" BUILD_COMMAND make ${VORO_BUILD_OPTIONS} BUILD_IN_SOURCE 1 INSTALL_COMMAND ""
|
||||
BUILD_BYPRODUCTS <SOURCE_DIR>/src/libvoro++.a
|
||||
)
|
||||
ExternalProject_get_property(voro_build SOURCE_DIR)
|
||||
set(VORO_LIBRARIES ${SOURCE_DIR}/src/libvoro++.a)
|
||||
set(VORO_INCLUDE_DIRS ${SOURCE_DIR}/src)
|
||||
list(APPEND LAMMPS_DEPS voro_build)
|
||||
else()
|
||||
find_package(VORO)
|
||||
if(NOT VORO_FOUND)
|
||||
message(FATAL_ERROR "Voro++ library not found. Help CMake to find it by setting VORO_LIBRARY and VORO_INCLUDE_DIR, or set DOWNLOAD_VORO=ON to download it")
|
||||
endif()
|
||||
endif()
|
||||
include_directories(${VORO_INCLUDE_DIRS})
|
||||
list(APPEND LAMMPS_LINK_LIBS ${VORO_LIBRARIES})
|
||||
find_package(VORO)
|
||||
if(VORO_FOUND)
|
||||
set(DOWNLOAD_VORO_DEFAULT OFF)
|
||||
else()
|
||||
set(DOWNLOAD_VORO_DEFAULT ON)
|
||||
endif()
|
||||
option(DOWNLOAD_VORO "Download and compile the Voro++ library instead of using an already installed one" ${DOWNLOAD_VORO_DEFAULT})
|
||||
if(DOWNLOAD_VORO)
|
||||
message(STATUS "Voro++ download requested - we will build our own")
|
||||
include(ExternalProject)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(VORO_BUILD_CFLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}")
|
||||
else()
|
||||
set(VORO_BUILD_CFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}}")
|
||||
endif()
|
||||
if(APPLE)
|
||||
get_filename_component(VORO_CXX ${CMAKE_CXX_COMPILER} NAME_WE)
|
||||
set(VORO_BUILD_OPTIONS CXX=${VORO_CXX} CFLAGS=${VORO_BUILD_CFLAGS})
|
||||
else()
|
||||
set(VORO_BUILD_OPTIONS CXX=${CMAKE_CXX_COMPILER} CFLAGS=${VORO_BUILD_CFLAGS})
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(voro_build
|
||||
URL https://download.lammps.org/thirdparty/voro++-0.4.6.tar.gz
|
||||
URL_MD5 2338b824c3b7b25590e18e8df5d68af9
|
||||
CONFIGURE_COMMAND "" BUILD_COMMAND make ${VORO_BUILD_OPTIONS} BUILD_IN_SOURCE 1 INSTALL_COMMAND ""
|
||||
BUILD_BYPRODUCTS <SOURCE_DIR>/src/libvoro++.a
|
||||
)
|
||||
ExternalProject_get_property(voro_build SOURCE_DIR)
|
||||
file(MAKE_DIRECTORY ${SOURCE_DIR}/src)
|
||||
add_library(LAMMPS::VORO UNKNOWN IMPORTED)
|
||||
set_target_properties(LAMMPS::VORO PROPERTIES
|
||||
IMPORTED_LOCATION "${SOURCE_DIR}/src/libvoro++.a"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/src")
|
||||
target_link_libraries(lammps PRIVATE LAMMPS::VORO)
|
||||
add_dependencies(LAMMPS::VORO voro_build)
|
||||
if(BUILD_LIB AND NOT BUILD_SHARED_LIBS)
|
||||
install(CODE "MESSAGE(FATAL_ERROR \"Installing liblammps with downloaded libraries is currently not supported.\")")
|
||||
endif()
|
||||
else()
|
||||
find_package(VORO)
|
||||
if(NOT VORO_FOUND)
|
||||
message(FATAL_ERROR "Voro++ library not found. Help CMake to find it by setting VORO_LIBRARY and VORO_INCLUDE_DIR, or set DOWNLOAD_VORO=ON to download it")
|
||||
endif()
|
||||
target_link_libraries(lammps PRIVATE VORO::VORO)
|
||||
endif()
|
||||
|
||||
@ -28,7 +28,7 @@ if(ENABLE_TESTING AND BUILD_EXE)
|
||||
"https://github.com/lammps/lammps-testing in LAMMPS_TESTING_SOURCE_DIR")
|
||||
endif()
|
||||
|
||||
add_test(ShowHelp ${CMAKE_BINARY_DIR}/${LAMMPS_BINARY} -help)
|
||||
add_test(NAME ShowHelp COMMAND $<TARGET_FILE:lmp> -help)
|
||||
|
||||
if(EXISTS ${LAMMPS_TESTING_SOURCE_DIR})
|
||||
message(STATUS "Running test discovery...")
|
||||
@ -42,8 +42,7 @@ if(ENABLE_TESTING AND BUILD_EXE)
|
||||
string(REPLACE "-" "_" TEST_NAME ${TEST_NAME})
|
||||
string(REPLACE "+" "_" TEST_NAME ${TEST_NAME})
|
||||
set(TEST_NAME "test_core_${TEST_NAME}_serial")
|
||||
add_test(${TEST_NAME} ${CMAKE_BINARY_DIR}/${LAMMPS_BINARY} -in ${SCRIPT_NAME})
|
||||
set_tests_properties(${TEST_NAME} PROPERTIES WORKING_DIRECTORY ${PARENT_DIR})
|
||||
add_test(NAME ${TEST_NAME} COMMAND $<TARGET_FILE:lmp> -in ${SCRIPT_NAME} WORKING_DIRECTORY ${PARENT_DIR})
|
||||
endforeach()
|
||||
list(LENGTH TEST_SCRIPTS NUM_TESTS)
|
||||
|
||||
|
||||
@ -264,6 +264,16 @@ cmake -C ../cmake/presets/all_on.cmake -C ../cmake/presets/nolib.cmake -D PKG_GP
|
||||
</dl>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>LAMMPS_OMP_COMPAT</code></td>
|
||||
<td>Workaround for backwards-incompatible changes regarding predetermined sharing modes in OpenMP 4.x. A value of 3 or 4 should be used, reflecting the version of the OpenMP spec that is implemented by the compiler.</td>
|
||||
<td>
|
||||
<dl>
|
||||
<dt><code>3</code> (default except for known OMP 4.0 compilers)</dt>
|
||||
<dt><code>4</code></dt>
|
||||
</dl>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>LAMMPS_MEMALIGN</code></td>
|
||||
<td>controls the alignment of blocks of memory allocated by LAMMPS</td>
|
||||
|
||||
@ -18,12 +18,6 @@
|
||||
# myapp_CFLAGS = $(LAMMPS_CFLAGS)
|
||||
# myapp_LDADD = $(LAMMPS_LIBS)
|
||||
|
||||
# Use this in CMake:
|
||||
# CMakeLists.txt:
|
||||
# find_package(PkgConfig)
|
||||
# pkg_check_modules(LAMMPS IMPORTED_TARGET lammps)
|
||||
# target_link_libraries(<lib> PkgConfig::LAMMPS)
|
||||
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
@ -31,7 +25,7 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
Name: liblammps@LAMMPS_MACHINE@
|
||||
Description: Large-scale Atomic/Molecular Massively Parallel Simulator Library
|
||||
URL: http://lammps.sandia.gov
|
||||
Version: @LAMMPS_VERSION@
|
||||
Version: @PROJECT_VERSION@
|
||||
Requires:
|
||||
Libs: -L${libdir} -llammps@LAMMPS_LIB_SUFFIX@
|
||||
Libs.private: -lm
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
set(CMAKE_CXX_COMPILER "icpc" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_COMPILER "icc" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS "-O3 -DNDEBG" CACHE STRING "" FORCE)
|
||||
set(MPI_CXX "icpc" CACHE STRING "" FORCE)
|
||||
set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE)
|
||||
unset(HAVE_OMP_H_INCLUDE CACHE)
|
||||
|
||||
11
cmake/presets/kokkos-cuda.cmake
Normal file
11
cmake/presets/kokkos-cuda.cmake
Normal file
@ -0,0 +1,11 @@
|
||||
# preset that enables KOKKOS and selects CUDA compilation with OpenMP
|
||||
# enabled as well. This preselects CC 5.0 as default GPU arch, since
|
||||
# that is compatible with all higher CC, but not the default CC 3.5
|
||||
set(PKG_KOKKOS ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ENABLE_OPENMP ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ENABLE_CUDA ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ARCH_MAXWELL50 on CACHE BOOL "" FORCE)
|
||||
set(BUILD_OMP ON CACHE BOOL "" FORCE)
|
||||
get_filename_component(NVCC_WRAPPER_CMD ${CMAKE_CURRENT_SOURCE_DIR}/../lib/kokkos/bin/nvcc_wrapper ABSOLUTE)
|
||||
set(CMAKE_CXX_COMPILER ${NVCC_WRAPPER_CMD} CACHE FILEPATH "" FORCE)
|
||||
6
cmake/presets/kokkos-openmp.cmake
Normal file
6
cmake/presets/kokkos-openmp.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
# preset that enables KOKKOS and selects OpenMP (only) compilation
|
||||
set(PKG_KOKKOS ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ENABLE_OPENMP ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ENABLE_CUDA OFF CACHE BOOL "" FORCE)
|
||||
set(BUILD_OMP ON CACHE BOOL "" FORCE)
|
||||
5
cmake/presets/kokkos-serial.cmake
Normal file
5
cmake/presets/kokkos-serial.cmake
Normal file
@ -0,0 +1,5 @@
|
||||
# preset that enables KOKKOS and selects serial compilation only
|
||||
set(PKG_KOKKOS ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ENABLE_OPENMP OFF CACHE BOOL "" FORCE)
|
||||
set(Kokkos_ENABLE_CUDA OFF CACHE BOOL "" FORCE)
|
||||
@ -23,6 +23,7 @@ set(DOWNLOAD_VORO ON CACHE BOOL "" FORCE)
|
||||
set(DOWNLOAD_EIGEN3 ON CACHE BOOL "" FORCE)
|
||||
set(LAMMPS_MEMALIGN "0" CACHE STRING "" FORCE)
|
||||
set(CMAKE_TUNE_FLAGS "-Wno-missing-include-dirs" CACHE STRING "" FORCE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "--enable-stdcall-fixup" CACHE STRING "" FORCE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-stdcall-fixup" CACHE STRING "" FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-stdcall-fixup" CACHE STRING "" FORCE)
|
||||
set(BUILD_TOOLS ON CACHE BOOL "" FORCE)
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/lammps-installer")
|
||||
|
||||
15
doc/Makefile
15
doc/Makefile
@ -12,6 +12,7 @@ PYTHON = $(shell which python3)
|
||||
VIRTUALENV = virtualenv
|
||||
HAS_PYTHON3 = NO
|
||||
HAS_VIRTUALENV = NO
|
||||
HAS_PDFLATEX = NO
|
||||
|
||||
ifeq ($(shell which python3 >/dev/null 2>&1; echo $$?), 0)
|
||||
HAS_PYTHON3 = YES
|
||||
@ -27,6 +28,11 @@ VIRTUALENV = virtualenv
|
||||
HAS_VIRTUALENV = YES
|
||||
endif
|
||||
|
||||
ifeq ($(shell which pdflatex >/dev/null 2>&1; echo $$?), 0)
|
||||
HAS_PDFLATEX = YES
|
||||
endif
|
||||
|
||||
|
||||
SPHINXEXTRA = -j $(shell $(PYTHON) -c 'import multiprocessing;print(multiprocessing.cpu_count())')
|
||||
|
||||
.PHONY: help clean-all clean clean-spelling epub mobi rst html pdf spelling anchor_check style_check
|
||||
@ -86,8 +92,7 @@ html: $(ANCHORCHECK) $(MATHJAX)
|
||||
spelling: $(VENV) utils/sphinx-config/false_positives.txt
|
||||
@(\
|
||||
. $(VENV)/bin/activate ;\
|
||||
pip install sphinxcontrib-spelling ;\
|
||||
cp utils/sphinx-config/false_positives.txt $(RSTDIR)/ ;\
|
||||
cp utils/sphinx-config/false_positives.txt $(RSTDIR)/ ; env PYTHONWARNINGS= \
|
||||
sphinx-build -b spelling -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) spelling ;\
|
||||
deactivate ;\
|
||||
)
|
||||
@ -113,6 +118,7 @@ mobi: epub
|
||||
@echo "Conversion finished. The MOBI manual file is created."
|
||||
|
||||
pdf: $(ANCHORCHECK)
|
||||
@if [ "$(HAS_PDFLATEX)" == "NO" ] ; then echo "PDFLaTeX was not found! Please check README.md for further instructions" 1>&2; exit 1; fi
|
||||
@(\
|
||||
cd src/Developer; \
|
||||
pdflatex developer; \
|
||||
@ -187,7 +193,10 @@ $(VENV):
|
||||
@( \
|
||||
$(VIRTUALENV) -p $(PYTHON) $(VENV); \
|
||||
. $(VENV)/bin/activate; \
|
||||
pip install Sphinx; \
|
||||
pip install --upgrade pip; \
|
||||
pip install Sphinx==2.4.4; \
|
||||
pip install sphinxcontrib-spelling ;\
|
||||
pip install breathe; \
|
||||
deactivate;\
|
||||
)
|
||||
|
||||
|
||||
@ -93,12 +93,18 @@ support for PDFLaTeX. Also the following LaTeX packages need
|
||||
to be installed (e.g. from texlive):
|
||||
- amsmath
|
||||
- babel
|
||||
- capt-of
|
||||
- cmap
|
||||
- fncychap
|
||||
- framed
|
||||
- geometry
|
||||
- hyperref
|
||||
- hypcap
|
||||
- needspace
|
||||
- times
|
||||
- tabulary
|
||||
- upquote
|
||||
- wrapfig
|
||||
----------------
|
||||
|
||||
Installing prerequisites for epub build
|
||||
|
||||
@ -142,14 +142,15 @@ please refer to its documentation.
|
||||
**OpenMP Compiler compatibility info**\ :
|
||||
|
||||
Some compilers do not fully support the ``default(none)`` directive
|
||||
and others (e.g. GCC version 9 and beyond) may implement OpenMP 4.0
|
||||
semantics, which are incompatible with the OpenMP 3.1 semantics used
|
||||
in LAMMPS (for maximal compatibility with compiler versions in use).
|
||||
In those case, all ``default(none)`` directives (which aid in detecting
|
||||
incorrect and unwanted sharing) can be replaced with ``default(shared)``
|
||||
while dropping all ``shared()`` directives. The script
|
||||
'src/USER-OMP/hack_openmp_for_pgi_gcc9.sh' can be used to automate
|
||||
this conversion.
|
||||
and others (e.g. GCC version 9 and beyond, Clang version 10 and later)
|
||||
may implement strict OpenMP 4.0 and later semantics, which are incompatible
|
||||
with the OpenMP 3.1 semantics used in LAMMPS for maximal compatibility
|
||||
with compiler versions in use. If compilation with OpenMP enabled fails
|
||||
because of your compiler requiring strict OpenMP 4.0 semantic, you can
|
||||
change the behavior by adding ``-D LAMMPS_OMP_COMPAT=4`` to the ``LMP_INC``
|
||||
variable in your makefile, or add it to the command line while configuring
|
||||
with CMake. CMake will detect the suitable setting for the GNU, Clang,
|
||||
and Intel compilers.
|
||||
|
||||
----------
|
||||
|
||||
|
||||
@ -87,27 +87,33 @@ GPU package
|
||||
---------------------
|
||||
|
||||
To build with this package, you must choose options for precision and
|
||||
which GPU hardware to build for.
|
||||
which GPU hardware to build for. The GPU package currently supports
|
||||
three different types of backends: OpenCL, CUDA and HIP.
|
||||
|
||||
**CMake build**\ :
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
-D GPU_API=value # value = opencl (default) or cuda
|
||||
-D GPU_PREC=value # precision setting
|
||||
# value = double or mixed (default) or single
|
||||
-D OCL_TUNE=value # hardware choice for GPU_API=opencl
|
||||
# generic (default) or intel (Intel CPU) or fermi, kepler, cypress (NVIDIA)
|
||||
-D GPU_ARCH=value # primary GPU hardware choice for GPU_API=cuda
|
||||
# value = sm_XX, see below
|
||||
# default is sm_30
|
||||
-D CUDPP_OPT=value # optimization setting for GPU_API=cuda
|
||||
# enables CUDA Performance Primitives Optimizations
|
||||
# value = yes (default) or no
|
||||
-D CUDA_MPS_SUPPORT=value # enables some tweaks required to run with active nvidia-cuda-mps daemon
|
||||
# value = yes or no (default)
|
||||
-D GPU_API=value # value = opencl (default) or cuda or hip
|
||||
-D GPU_PREC=value # precision setting
|
||||
# value = double or mixed (default) or single
|
||||
-D OCL_TUNE=value # hardware choice for GPU_API=opencl
|
||||
# generic (default) or intel (Intel CPU) or fermi, kepler, cypress (NVIDIA)
|
||||
-D GPU_ARCH=value # primary GPU hardware choice for GPU_API=cuda
|
||||
# value = sm_XX, see below
|
||||
# default is sm_30
|
||||
-D HIP_ARCH=value # primary GPU hardware choice for GPU_API=hip
|
||||
# value depends on selected HIP_PLATFORM
|
||||
# default is 'gfx906' for HIP_PLATFORM=hcc and 'sm_30' for HIP_PLATFORM=nvcc
|
||||
-D HIP_USE_DEVICE_SORT=value # enables GPU sorting
|
||||
# value = yes (default) or no
|
||||
-D CUDPP_OPT=value # optimization setting for GPU_API=cuda
|
||||
# enables CUDA Performance Primitives Optimizations
|
||||
# value = yes (default) or no
|
||||
-D CUDA_MPS_SUPPORT=value # enables some tweaks required to run with active nvidia-cuda-mps daemon
|
||||
# value = yes or no (default)
|
||||
|
||||
GPU_ARCH settings for different GPU hardware is as follows:
|
||||
:code:`GPU_ARCH` settings for different GPU hardware is as follows:
|
||||
|
||||
* sm_12 or sm_13 for GT200 (supported by CUDA 3.2 until CUDA 6.5)
|
||||
* sm_20 or sm_21 for Fermi (supported by CUDA 3.2 until CUDA 7.5)
|
||||
@ -126,6 +132,28 @@ Thus the GPU_ARCH setting is merely an optimization, to have code for
|
||||
the preferred GPU architecture directly included rather than having to wait
|
||||
for the JIT compiler of the CUDA driver to translate it.
|
||||
|
||||
If you are compiling with HIP, note that before running CMake you will have to
|
||||
set appropriate environment variables. Some variables such as
|
||||
:code:`HCC_AMDGPU_TARGET` or :code:`CUDA_PATH` are necessary for :code:`hipcc`
|
||||
and the linker to work correctly.
|
||||
|
||||
.. code:: bash
|
||||
|
||||
# AMDGPU target
|
||||
export HIP_PLATFORM=hcc
|
||||
export HCC_AMDGPU_TARGET=gfx906
|
||||
cmake -D PKG_GPU=on -D GPU_API=HIP -D HIP_ARCH=gfx906 -D CMAKE_CXX_COMPILER=hipcc ..
|
||||
make -j 4
|
||||
|
||||
.. code:: bash
|
||||
|
||||
# CUDA target
|
||||
# !!! DO NOT set CMAKE_CXX_COMPILER !!!
|
||||
export HIP_PLATFORM=nvcc
|
||||
export CUDA_PATH=/usr/local/cuda
|
||||
cmake -D PKG_GPU=on -D GPU_API=HIP -D HIP_ARCH=sm_70 ..
|
||||
make -j 4
|
||||
|
||||
**Traditional make**\ :
|
||||
|
||||
Before building LAMMPS, you must build the GPU library in ``lib/gpu``\ .
|
||||
@ -279,74 +307,131 @@ using. For example:
|
||||
.. _kokkos:
|
||||
|
||||
KOKKOS package
|
||||
---------------------------
|
||||
--------------
|
||||
|
||||
To build with this package, you must choose which hardware you want to
|
||||
build for, either CPUs (multi-threading via OpenMP) or KNLs (OpenMP)
|
||||
or GPUs (NVIDIA Cuda).
|
||||
Using the KOKKOS package requires choosing several settings. You have
|
||||
to select whether you want to compile with parallelization on the host
|
||||
and whether you want to include offloading of calculations to a device
|
||||
(e.g. a GPU). The default setting is to have no host parallelization
|
||||
and no device offloading. In addition, you can select the hardware
|
||||
architecture to select the instruction set. Since most hardware is
|
||||
backward compatible, you may choose settings for an older architecture
|
||||
to have an executable that will run on this and newer architectures.
|
||||
|
||||
For a CMake or make build, these are the possible choices for the
|
||||
``KOKKOS_ARCH`` settings described below. Note that for CMake, these are
|
||||
really Kokkos variables, not LAMMPS variables. Hence you must use
|
||||
case-sensitive values, e.g. BDW, not bdw.
|
||||
.. note::
|
||||
|
||||
* AMDAVX = AMD 64-bit x86 CPUs
|
||||
* EPYC = AMD EPYC Zen class CPUs
|
||||
* ARMv80 = ARMv8.0 Compatible CPU
|
||||
* ARMv81 = ARMv8.1 Compatible CPU
|
||||
* ARMv8-ThunderX = ARMv8 Cavium ThunderX CPU
|
||||
* ARMv8-TX2 = ARMv8 Cavium ThunderX2 CPU
|
||||
* WSM = Intel Westmere CPUs
|
||||
* SNB = Intel Sandy/Ivy Bridge CPUs
|
||||
* HSW = Intel Haswell CPUs
|
||||
* BDW = Intel Broadwell Xeon E-class CPUs
|
||||
* SKX = Intel Sky Lake Xeon E-class HPC CPUs (AVX512)
|
||||
* KNC = Intel Knights Corner Xeon Phi
|
||||
* KNL = Intel Knights Landing Xeon Phi
|
||||
* BGQ = IBM Blue Gene/Q CPUs
|
||||
* Power7 = IBM POWER8 CPUs
|
||||
* Power8 = IBM POWER8 CPUs
|
||||
* Power9 = IBM POWER9 CPUs
|
||||
* Kepler = NVIDIA Kepler default (generation CC 3.5)
|
||||
* Kepler30 = NVIDIA Kepler generation CC 3.0
|
||||
* Kepler32 = NVIDIA Kepler generation CC 3.2
|
||||
* Kepler35 = NVIDIA Kepler generation CC 3.5
|
||||
* Kepler37 = NVIDIA Kepler generation CC 3.7
|
||||
* Maxwell = NVIDIA Maxwell default (generation CC 5.0)
|
||||
* Maxwell50 = NVIDIA Maxwell generation CC 5.0
|
||||
* Maxwell52 = NVIDIA Maxwell generation CC 5.2
|
||||
* Maxwell53 = NVIDIA Maxwell generation CC 5.3
|
||||
* Pascal60 = NVIDIA Pascal generation CC 6.0
|
||||
* Pascal61 = NVIDIA Pascal generation CC 6.1
|
||||
* Volta70 = NVIDIA Volta generation CC 7.0
|
||||
* Volta72 = NVIDIA Volta generation CC 7.2
|
||||
* Turing75 = NVIDIA Turing generation CC 7.5
|
||||
NVIDIA GPUs with CC 5.0 (Maxwell) and newer are not compatible with
|
||||
CC 3.x (Kepler). If you run Kokkos on a newer architecture than what
|
||||
LAMMPS was compiled with, there will be a significant delay during
|
||||
device initialization since the just-in-time compiler has to
|
||||
recompile the GPU kernel code for the new hardware.
|
||||
|
||||
**CMake build**\ :
|
||||
The settings discussed below have been tested with LAMMPS and are
|
||||
confirmed to work. Kokkos is an active project with ongoing improvements
|
||||
and projects working on including support for additional architectures.
|
||||
More information on Kokkos can be found on the
|
||||
`Kokkos GitHub project <https://github.com/kokkos>`_.
|
||||
|
||||
Available Architecture settings
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
These are the possible choices for the Kokkos architecture ID. They must
|
||||
be specified in uppercase.
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 0
|
||||
:widths: auto
|
||||
|
||||
* - **Arch-ID**
|
||||
- **Description**
|
||||
* - AMDAVX
|
||||
- AMD 64-bit x86 CPU (AVX 1)
|
||||
* - EPYC
|
||||
- AMD EPYC Zen class CPU (AVX 2)
|
||||
* - ARMV80
|
||||
- ARMv8.0 Compatible CPU
|
||||
* - ARMV81
|
||||
- ARMv8.1 Compatible CPU
|
||||
* - ARMV8_THUNDERX
|
||||
- ARMv8 Cavium ThunderX CPU
|
||||
* - ARMV8_THUNDERX2
|
||||
- ARMv8 Cavium ThunderX2 CPU
|
||||
* - WSM
|
||||
- Intel Westmere CPU (SSE 4.2)
|
||||
* - SNB
|
||||
- Intel Sandy/Ivy Bridge CPU (AVX 1)
|
||||
* - HSW
|
||||
- Intel Haswell CPU (AVX 2)
|
||||
* - BDW
|
||||
- Intel Broadwell Xeon E-class CPU (AVX 2 + transactional mem)
|
||||
* - SKX
|
||||
- Intel Sky Lake Xeon E-class HPC CPU (AVX512 + transactional mem)
|
||||
* - KNC
|
||||
- Intel Knights Corner Xeon Phi
|
||||
* - KNL
|
||||
- Intel Knights Landing Xeon Phi
|
||||
* - BGQ
|
||||
- IBM Blue Gene/Q CPU
|
||||
* - POWER7
|
||||
- IBM POWER8 CPU
|
||||
* - POWER8
|
||||
- IBM POWER8 CPU
|
||||
* - POWER9
|
||||
- IBM POWER9 CPU
|
||||
* - KEPLER30
|
||||
- NVIDIA Kepler generation CC 3.0 GPU
|
||||
* - KEPLER32
|
||||
- NVIDIA Kepler generation CC 3.2 GPU
|
||||
* - KEPLER35
|
||||
- NVIDIA Kepler generation CC 3.5 GPU
|
||||
* - KEPLER37
|
||||
- NVIDIA Kepler generation CC 3.7 GPU
|
||||
* - MAXWELL50
|
||||
- NVIDIA Maxwell generation CC 5.0 GPU
|
||||
* - MAXWELL52
|
||||
- NVIDIA Maxwell generation CC 5.2 GPU
|
||||
* - MAXWELL53
|
||||
- NVIDIA Maxwell generation CC 5.3 GPU
|
||||
* - PASCAL60
|
||||
- NVIDIA Pascal generation CC 6.0 GPU
|
||||
* - PASCAL61
|
||||
- NVIDIA Pascal generation CC 6.1 GPU
|
||||
* - VOLTA70
|
||||
- NVIDIA Volta generation CC 7.0 GPU
|
||||
* - VOLTA72
|
||||
- NVIDIA Volta generation CC 7.2 GPU
|
||||
* - TURING75
|
||||
- NVIDIA Turing generation CC 7.5 GPU
|
||||
|
||||
CMake build settings:
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
For multicore CPUs using OpenMP, set these 2 variables.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
-D KOKKOS_ARCH=archCPU # archCPU = CPU from list above
|
||||
-D KOKKOS_ENABLE_OPENMP=yes
|
||||
-D Kokkos_ARCH_CPUARCH=yes # CPUARCH = CPU from list above
|
||||
-D Kokkos_ENABLE_OPENMP=yes
|
||||
-D BUILD_OMP=yes
|
||||
|
||||
For Intel KNLs using OpenMP, set these 2 variables:
|
||||
Please note that enabling OpenMP for KOKKOS requires that OpenMP is
|
||||
also :ref:`enabled for the rest of LAMMPS <serial>`.
|
||||
|
||||
For Intel KNLs using OpenMP, set these variables:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
-D KOKKOS_ARCH=KNL
|
||||
-D KOKKOS_ENABLE_OPENMP=yes
|
||||
-D Kokkos_ARCH_KNL=yes
|
||||
-D Kokkos_ENABLE_OPENMP=yes
|
||||
|
||||
For NVIDIA GPUs using CUDA, set these 4 variables:
|
||||
For NVIDIA GPUs using CUDA, set these variables:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
-D KOKKOS_ARCH="archCPU;archGPU" # archCPU = CPU from list above that is hosting the GPU
|
||||
# archGPU = GPU from list above
|
||||
-D KOKKOS_ENABLE_CUDA=yes
|
||||
-D KOKKOS_ENABLE_OPENMP=yes
|
||||
-D CMAKE_CXX_COMPILER=wrapper # wrapper = full path to Cuda nvcc wrapper
|
||||
-D Kokkos_ARCH_CPUARCH=yes # CPUARCH = CPU from list above
|
||||
-D Kokkos_ARCH_GPUARCH=yes # GPUARCH = GPU from list above
|
||||
-D Kokkos_ENABLE_CUDA=yes
|
||||
-D Kokkos_ENABLE_OPENMP=yes
|
||||
-D CMAKE_CXX_COMPILER=wrapper # wrapper = full path to Cuda nvcc wrapper
|
||||
|
||||
The wrapper value is the Cuda nvcc compiler wrapper provided in the
|
||||
Kokkos library: ``lib/kokkos/bin/nvcc_wrapper``\ . The setting should
|
||||
@ -354,20 +439,35 @@ include the full path name to the wrapper, e.g.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
-D CMAKE_CXX_COMPILER=/home/username/lammps/lib/kokkos/bin/nvcc_wrapper
|
||||
-D CMAKE_CXX_COMPILER=${HOME}/lammps/lib/kokkos/bin/nvcc_wrapper
|
||||
|
||||
**Traditional make**\ :
|
||||
To simplify the compilation, three preset files are included in the
|
||||
``cmake/presets`` folder, ``kokkos-serial.cmake``, ``kokkos-openmp.cmake``,
|
||||
and ``kokkos-cuda.cmake``. They will enable the KOKKOS package and
|
||||
enable some hardware choice. So to compile with OpenMP host parallelization,
|
||||
CUDA device parallelization (for GPUs with CC 5.0 and up) with some
|
||||
common packages enabled, you can do the following:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
mkdir build-kokkos-cuda
|
||||
cd build-kokkos-cuda
|
||||
cmake -C ../cmake/presets/minimal.cmake -C ../cmake/presets/kokkos-cuda.cmake ../cmake
|
||||
cmake --build .
|
||||
|
||||
Traditional make settings:
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Choose which hardware to support in ``Makefile.machine`` via
|
||||
``KOKKOS_DEVICES`` and ``KOKKOS_ARCH`` settings. See the
|
||||
``src/MAKE/OPTIONS/Makefile.kokkos\*`` files for examples.
|
||||
``src/MAKE/OPTIONS/Makefile.kokkos*`` files for examples.
|
||||
|
||||
For multicore CPUs using OpenMP:
|
||||
|
||||
.. code-block:: make
|
||||
|
||||
KOKKOS_DEVICES = OpenMP
|
||||
KOKKOS_ARCH = archCPU # archCPU = CPU from list above
|
||||
KOKKOS_ARCH = CPUARCH # CPUARCH = CPU from list above
|
||||
|
||||
For Intel KNLs using OpenMP:
|
||||
|
||||
@ -381,22 +481,28 @@ For NVIDIA GPUs using CUDA:
|
||||
.. code-block:: make
|
||||
|
||||
KOKKOS_DEVICES = Cuda
|
||||
KOKKOS_ARCH = archCPU,archGPU # archCPU = CPU from list above that is hosting the GPU
|
||||
# archGPU = GPU from list above
|
||||
FFT_INC = -DFFT_CUFFT # enable use of cuFFT (optional)
|
||||
FFT_LIB = -lcufft # link to cuFFT library
|
||||
KOKKOS_ARCH = CPUARCH,GPUARCH # CPUARCH = CPU from list above that is hosting the GPU
|
||||
# GPUARCH = GPU from list above
|
||||
FFT_INC = -DFFT_CUFFT # enable use of cuFFT (optional)
|
||||
FFT_LIB = -lcufft # link to cuFFT library
|
||||
|
||||
For GPUs, you also need the following 2 lines in your Makefile.machine
|
||||
before the CC line is defined, in this case for use with OpenMPI mpicxx.
|
||||
The 2 lines define a nvcc wrapper compiler, which will use nvcc for
|
||||
compiling CUDA files and use a C++ compiler for non-Kokkos, non-CUDA
|
||||
files.
|
||||
For GPUs, you also need the following lines in your ``Makefile.machine``
|
||||
before the CC line is defined. They tell ``mpicxx`` to use an ``nvcc``
|
||||
compiler wrapper, which will use ``nvcc`` for compiling CUDA files and a
|
||||
C++ compiler for non-Kokkos, non-CUDA files.
|
||||
|
||||
.. code-block:: make
|
||||
|
||||
# For OpenMPI
|
||||
KOKKOS_ABSOLUTE_PATH = $(shell cd $(KOKKOS_PATH); pwd)
|
||||
export OMPI_CXX = $(KOKKOS_ABSOLUTE_PATH)/config/nvcc_wrapper
|
||||
CC = mpicxx
|
||||
CC = mpicxx
|
||||
|
||||
.. code-block:: make
|
||||
|
||||
# For MPICH and derivatives
|
||||
KOKKOS_ABSOLUTE_PATH = $(shell cd $(KOKKOS_PATH); pwd)
|
||||
CC = mpicxx -cxx=$(KOKKOS_ABSOLUTE_PATH)/config/nvcc_wrapper
|
||||
|
||||
----------
|
||||
|
||||
@ -435,7 +541,7 @@ args:
|
||||
$ make lib-latte args="-b" # download and build in lib/latte/LATTE-master
|
||||
$ make lib-latte args="-p $HOME/latte" # use existing LATTE installation in $HOME/latte
|
||||
$ make lib-latte args="-b -m gfortran" # download and build in lib/latte and
|
||||
# copy Makefile.lammps.gfortran to Makefile.lammps
|
||||
# copy Makefile.lammps.gfortran to Makefile.lammps
|
||||
|
||||
Note that 3 symbolic (soft) links, "includelink" and "liblink" and
|
||||
"filelink.o", are created in lib/latte to point into the LATTE home
|
||||
|
||||
@ -48,7 +48,7 @@ The USER-CUDA package had been removed, since it had been unmaintained
|
||||
for a long time and had known bugs and problems. Significant parts of
|
||||
the design were transferred to the
|
||||
:ref:`KOKKOS package <PKG-KOKKOS>`, which has similar
|
||||
performance characteristics on Nvidia GPUs. Both, the KOKKOS
|
||||
performance characteristics on NVIDIA GPUs. Both, the KOKKOS
|
||||
and the :ref:`GPU package <PKG-GPU>` are maintained
|
||||
and allow running LAMMPS with GPU acceleration.
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ section below for examples where this has been done.
|
||||
* The GPU package requires neighbor lists to be built on the CPU when using
|
||||
exclusion lists, or a triclinic simulation box.
|
||||
* The GPU package can be compiled for CUDA or OpenCL and thus supports
|
||||
both, Nvidia and AMD GPUs well. On Nvidia hardware, using CUDA is typically
|
||||
both, NVIDIA and AMD GPUs well. On NVIDIA hardware, using CUDA is typically
|
||||
resulting in equal or better performance over OpenCL.
|
||||
* OpenCL in the GPU package does theoretically also support Intel CPUs or
|
||||
Intel Xeon Phi, but the native support for those in KOKKOS (or USER-INTEL)
|
||||
|
||||
@ -38,7 +38,7 @@ compatible with specific hardware.
|
||||
.. note::
|
||||
|
||||
To build with Kokkos support for NVIDIA GPUs, NVIDIA CUDA
|
||||
software version 7.5 or later must be installed on your system. See
|
||||
software version 9.0 or later must be installed on your system. See
|
||||
the discussion for the :doc:`GPU package <Speed_gpu>` for details of how
|
||||
to check and do this.
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ standard or user packages:
|
||||
+-----------------------------------------+-------------------------------------------------------+
|
||||
| :doc:`USER-INTEL Package <Speed_intel>` | for Intel CPUs and Intel Xeon Phi |
|
||||
+-----------------------------------------+-------------------------------------------------------+
|
||||
| :doc:`KOKKOS Package <Speed_kokkos>` | for Nvidia GPUs, Intel Xeon Phi, and OpenMP threading |
|
||||
| :doc:`KOKKOS Package <Speed_kokkos>` | for NVIDIA GPUs, Intel Xeon Phi, and OpenMP threading |
|
||||
+-----------------------------------------+-------------------------------------------------------+
|
||||
| :doc:`USER-OMP Package <Speed_omp>` | for OpenMP threading and generic CPU optimizations |
|
||||
+-----------------------------------------+-------------------------------------------------------+
|
||||
|
||||
@ -14,7 +14,7 @@ Syntax
|
||||
* adapt = style name of this fix command
|
||||
* N = adapt simulation settings every this many timesteps
|
||||
* one or more attribute/arg pairs may be appended
|
||||
* attribute = *pair* or *kspace* or *atom*
|
||||
* attribute = *pair* or *bond* or *kspace* or *atom*
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
@ -86,8 +86,8 @@ the end of a simulation. Even if *reset* is specified as *yes*\ , a
|
||||
restart file written during a simulation will contain the modified
|
||||
settings.
|
||||
|
||||
If the *scale* keyword is set to *no*\ , then the value the parameter is
|
||||
set to will be whatever the variable generates. If the *scale*
|
||||
If the *scale* keyword is set to *no*\ , then the value of the altered
|
||||
parameter will be whatever the variable generates. If the *scale*
|
||||
keyword is set to *yes*\ , then the value of the altered parameter will
|
||||
be the initial value of that parameter multiplied by whatever the
|
||||
variable generates. I.e. the variable is now a "scale factor" applied
|
||||
@ -288,11 +288,19 @@ Currently *bond* does not support bond_style hybrid nor bond_style
|
||||
hybrid/overlay as bond styles. The only bonds that currently are
|
||||
working with fix_adapt are
|
||||
|
||||
+---------------------------------+-------+------------+
|
||||
| :doc:`gromos <bond_gromos>` | k, r0 | type bonds |
|
||||
+---------------------------------+-------+------------+
|
||||
| :doc:`harmonic <bond_harmonic>` | k,r0 | type bonds |
|
||||
+---------------------------------+-------+------------+
|
||||
+------------------------------------+-------+------------+
|
||||
| :doc:`class2 <bond_class2>` | r0 | type bonds |
|
||||
+------------------------------------+-------+------------+
|
||||
| :doc:`fene <bond_fene>` | k, r0 | type bonds |
|
||||
+------------------------------------+-------+------------+
|
||||
| :doc:`gromos <bond_gromos>` | k, r0 | type bonds |
|
||||
+------------------------------------+-------+------------+
|
||||
| :doc:`harmonic <bond_harmonic>` | k,r0 | type bonds |
|
||||
+------------------------------------+-------+------------+
|
||||
| :doc:`morse <bond_morse>` | r0 | type bonds |
|
||||
+------------------------------------+-------+------------+
|
||||
| :doc:`nonlinear <bond_nonlinear>` | r0 | type bonds |
|
||||
+------------------------------------+-------+------------+
|
||||
|
||||
----------
|
||||
|
||||
@ -311,26 +319,23 @@ The *atom* keyword enables various atom properties to be changed. The
|
||||
current list of atom parameters that can be varied by this fix:
|
||||
|
||||
* charge = charge on particle
|
||||
* diameter = diameter of particle
|
||||
* diameter, or, diameter/disc = diameter of particle
|
||||
|
||||
The *v_name* argument of the *atom* keyword is the name of an
|
||||
:doc:`equal-style variable <variable>` which will be evaluated each time
|
||||
this fix is invoked to set the parameter to a new value. It should be
|
||||
specified as v_name, where name is the variable name. See the
|
||||
this fix is invoked to set, or scale the parameter to a new value.
|
||||
It should be specified as v_name, where name is the variable name. See the
|
||||
discussion above describing the formulas associated with equal-style
|
||||
variables. The new value is assigned to the corresponding attribute
|
||||
for all atoms in the fix group.
|
||||
|
||||
.. note::
|
||||
|
||||
The *atom* keyword works this way whether the *scale* keyword is
|
||||
set to *no* or *yes*\ . I.e. the use of scale yes is not yet supported
|
||||
by the *atom* keyword.
|
||||
|
||||
If the atom parameter is *diameter* and per-atom density and per-atom
|
||||
mass are defined for particles (e.g. :doc:`atom_style granular <atom_style>`), then the mass of each particle is also
|
||||
changed when the diameter changes (density is assumed to stay
|
||||
constant).
|
||||
changed when the diameter changes. The mass is set from the particle volume
|
||||
for 3d systems (density is assumed to stay constant). For 2d, the default is
|
||||
for LAMMPS to model particles with a radius attribute as spheres.
|
||||
However, if the atom parameter is *diameter/disc*, then the mass is
|
||||
set from the particle area (the density is assumed to be in mass/distance^2 units).
|
||||
|
||||
For example, these commands would shrink the diameter of all granular
|
||||
particles in the "center" group from 1.0 to 0.1 in a linear fashion
|
||||
|
||||
@ -64,7 +64,7 @@ performed using a line search algorithm. The line search typically
|
||||
evaluates forces and energies several times to set new coordinates.
|
||||
Currently, a backtracking algorithm is used which may not be optimal
|
||||
in terms of the number of force evaluations performed, but appears to
|
||||
be more robust than previous line searches we've tried. The
|
||||
be more robust than previous line searches we have tried. The
|
||||
backtracking method is described in Nocedal and Wright's Numerical
|
||||
Optimization (Procedure 3.1 on p 41).
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ Style *cosine/squared* computes a potential of the form
|
||||
E =
|
||||
\begin{cases}
|
||||
-\epsilon& \quad r < \sigma \\
|
||||
-\epsilon\cos\left(\frac{\pi\left(r - \sigma\right)}{2\left(r_c - \sigma\right)}\right)&\quad \sigma \leq r < r_c \\
|
||||
-\epsilon\cos\left(\frac{\pi\left(r - \sigma\right)}{2\left(r_c - \sigma\right)}\right)^2&\quad \sigma \leq r < r_c \\
|
||||
0& \quad r \geq r_c
|
||||
\end{cases}
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ usrpkg = []
|
||||
# folder, and is not called 'MAKE' is a package
|
||||
|
||||
for d in pkgdirs:
|
||||
pkg = dirs.match(d)[1]
|
||||
pkg = dirs.match(d).group(1)
|
||||
if not os.path.isdir(os.path.join(src,pkg)): continue
|
||||
if pkg in ['DEPEND','MAKE','STUBS']: continue
|
||||
if user.match(pkg):
|
||||
|
||||
@ -170,6 +170,7 @@ ba
|
||||
Babadi
|
||||
Babaei
|
||||
backcolor
|
||||
backends
|
||||
Baczewski
|
||||
Bagi
|
||||
Bagnold
|
||||
@ -262,6 +263,7 @@ Boltzman
|
||||
BondAngle
|
||||
BondBond
|
||||
bondchk
|
||||
BondingIDs
|
||||
bondmax
|
||||
bondtype
|
||||
Bonet
|
||||
@ -367,6 +369,8 @@ Chemnitz
|
||||
Cheng
|
||||
Chenoweth
|
||||
chiral
|
||||
ChiralIDs
|
||||
chiralIDs
|
||||
chirality
|
||||
Cho
|
||||
chris
|
||||
@ -433,6 +437,7 @@ cond
|
||||
conda
|
||||
Conda
|
||||
Condens
|
||||
Connor
|
||||
conf
|
||||
config
|
||||
configfile
|
||||
@ -564,6 +569,7 @@ defn
|
||||
deformable
|
||||
del
|
||||
delaystep
|
||||
DeleteIDs
|
||||
deleteIDs
|
||||
Dellago
|
||||
delocalization
|
||||
@ -713,6 +719,7 @@ Ec
|
||||
ecoul
|
||||
ecp
|
||||
Ecut
|
||||
EdgeIDs
|
||||
edgeIDs
|
||||
edihed
|
||||
edim
|
||||
@ -1050,6 +1057,7 @@ gpu
|
||||
gpuID
|
||||
gpus
|
||||
gradV
|
||||
GradVidottan
|
||||
graining
|
||||
Graining
|
||||
Grama
|
||||
@ -1157,6 +1165,7 @@ Houlle
|
||||
howto
|
||||
Howto
|
||||
Hoyt
|
||||
Hs
|
||||
hstyle
|
||||
html
|
||||
hTST
|
||||
@ -1388,6 +1397,7 @@ KDevelop
|
||||
ke
|
||||
KE
|
||||
Keblinski
|
||||
Keefe
|
||||
keflag
|
||||
Keir
|
||||
Kelchner
|
||||
@ -1410,6 +1420,7 @@ Klapp
|
||||
Kloss
|
||||
kmax
|
||||
Kmax
|
||||
KMP
|
||||
Knizhnik
|
||||
knl
|
||||
Kofke
|
||||
@ -1578,6 +1589,7 @@ lmpqst
|
||||
lmpsdata
|
||||
Lmpsdata
|
||||
lmptype
|
||||
LMT
|
||||
ln
|
||||
localTemp
|
||||
localvectors
|
||||
@ -1593,6 +1605,7 @@ Lookups
|
||||
LoopVar
|
||||
Lorant
|
||||
lorenz
|
||||
Los
|
||||
lossless
|
||||
lossy
|
||||
Lozovik
|
||||
@ -1722,6 +1735,7 @@ Melchor
|
||||
Meloni
|
||||
Melrose
|
||||
Mem
|
||||
mem
|
||||
memalign
|
||||
MEMALIGN
|
||||
membered
|
||||
@ -2092,7 +2106,6 @@ nvc
|
||||
nvcc
|
||||
nve
|
||||
nvidia
|
||||
Nvidia
|
||||
nvk
|
||||
nvt
|
||||
Nwait
|
||||
@ -2657,6 +2670,8 @@ Shi
|
||||
Shiga
|
||||
Shinoda
|
||||
shlib
|
||||
SHM
|
||||
shm
|
||||
shockvel
|
||||
si
|
||||
SiC
|
||||
@ -2945,6 +2960,7 @@ traceless
|
||||
tradeoff
|
||||
traj
|
||||
Tranchida
|
||||
transactional
|
||||
transferability
|
||||
translational
|
||||
Translational
|
||||
|
||||
17
examples/COUPLE/simple/CMakeLists.txt
Normal file
17
examples/COUPLE/simple/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(simple CXX)
|
||||
|
||||
set(LAMMPS_SRC_DIRECTORY "" CACHE PATH "Path for lammps source")
|
||||
if(NOT LAMMPS_SRC_DIRECTORY STREQUAL "" AND EXISTS ${LAMMPS_SRC_DIRECTORY}/cmake/CMakeLists.txt)
|
||||
option(BUILD_LIB "Build LAMMPS library" ON)
|
||||
add_subdirectory(${LAMMPS_SRC_DIRECTORY}/cmake lammps)
|
||||
else()
|
||||
find_package(LAMMPS REQUIRED)
|
||||
endif()
|
||||
|
||||
add_executable(simpleCC simple.cpp)
|
||||
target_link_libraries(simpleCC LAMMPS::lammps)
|
||||
|
||||
enable_language(C)
|
||||
add_executable(simpleC simple.c)
|
||||
target_link_libraries(simpleC LAMMPS::lammps)
|
||||
@ -23,7 +23,7 @@
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "mpi.h"
|
||||
#include "library.h" /* this is a LAMMPS include file */
|
||||
#include "lammps/library.h" /* this is a LAMMPS include file */
|
||||
|
||||
int main(int narg, char **arg)
|
||||
{
|
||||
|
||||
@ -8,9 +8,13 @@
|
||||
* (VC11 has _MSC_VER=1700).
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#if !defined(M_PI)
|
||||
#define M_PI 3.14159265358979323846264338327950288
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if _MSC_VER <= 1700 // 1700 is VC11, 1800 is VC12
|
||||
/***************************
|
||||
* erf.cpp
|
||||
|
||||
1
lib/gpu/.gitignore
vendored
1
lib/gpu/.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
/obj_ocl
|
||||
/ocl_get_devices
|
||||
/nvc_get_devices
|
||||
/hip_get_devices
|
||||
/*.cubin
|
||||
/*_cubin.h
|
||||
/*_cl.h
|
||||
|
||||
148
lib/gpu/Makefile.hip
Normal file
148
lib/gpu/Makefile.hip
Normal file
@ -0,0 +1,148 @@
|
||||
# /* ----------------------------------------------------------------------
|
||||
# Generic Linux Makefile for HIP
|
||||
# - export HIP_PLATFORM=hcc (or nvcc) before execution
|
||||
# - change HIP_ARCH for your GPU
|
||||
# ------------------------------------------------------------------------- */
|
||||
|
||||
# this setting should match LAMMPS Makefile
|
||||
# one of LAMMPS_SMALLBIG (default), LAMMPS_BIGBIG and LAMMPS_SMALLSMALL
|
||||
|
||||
LMP_INC = -DLAMMPS_SMALLBIG
|
||||
|
||||
# precision for GPU calculations
|
||||
# -D_SINGLE_SINGLE # Single precision for all calculations
|
||||
# -D_DOUBLE_DOUBLE # Double precision for all calculations
|
||||
# -D_SINGLE_DOUBLE # Accumulation of forces, etc. in double
|
||||
|
||||
HIP_PRECISION = -D_SINGLE_DOUBLE
|
||||
|
||||
HIP_OPTS = -O3
|
||||
HIP_HOST_OPTS = -Wno-deprecated-declarations
|
||||
HIP_HOST_INCLUDE =
|
||||
|
||||
# use device sort
|
||||
# requires linking with hipcc and hipCUB + (rocPRIM or CUB for AMD or Nvidia respectively)
|
||||
HIP_HOST_OPTS += -DUSE_HIP_DEVICE_SORT
|
||||
# path to cub
|
||||
HIP_HOST_INCLUDE += -I./
|
||||
# path to hipcub
|
||||
HIP_HOST_INCLUDE += -I$(HIP_PATH)/../include
|
||||
|
||||
# use mpi
|
||||
HIP_HOST_OPTS += -DMPI_GERYON -DUCL_NO_EXIT
|
||||
# this settings should match LAMMPS Makefile
|
||||
MPI_COMP_OPTS = $(shell mpicxx --showme:compile)
|
||||
MPI_LINK_OPTS = $(shell mpicxx --showme:link)
|
||||
#MPI_COMP_OPTS += -I/usr/include/mpi -DMPICH_IGNORE_CXX_SEEK -DOMPI_SKIP_MPICXX=1
|
||||
|
||||
HIP_PATH ?= $(wildcard /opt/rocm/hip)
|
||||
HIP_PLATFORM=$(shell $(HIP_PATH)/bin/hipconfig --compiler)
|
||||
|
||||
ifeq (hcc,$(HIP_PLATFORM))
|
||||
HIP_OPTS += -ffast-math
|
||||
# possible values: gfx803,gfx900,gfx906
|
||||
HIP_ARCH = gfx906
|
||||
else ifeq (nvcc,$(HIP_PLATFORM))
|
||||
HIP_OPTS += --use_fast_math
|
||||
HIP_ARCH = -gencode arch=compute_30,code=[sm_30,compute_30] -gencode arch=compute_32,code=[sm_32,compute_32] -gencode arch=compute_35,code=[sm_35,compute_35] \
|
||||
-gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52] -gencode arch=compute_53,code=[sm_53,compute_53]\
|
||||
-gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61] -gencode arch=compute_62,code=[sm_62,compute_62]\
|
||||
-gencode arch=compute_70,code=[sm_70,compute_70] -gencode arch=compute_72,code=[sm_72,compute_72] -gencode arch=compute_75,code=[sm_75,compute_75]
|
||||
else
|
||||
$(error Specify HIP platform using 'export HIP_PLATFORM=(hcc,nvcc)')
|
||||
endif
|
||||
|
||||
BIN_DIR = .
|
||||
OBJ_DIR = ./obj
|
||||
LIB_DIR = .
|
||||
AR = ar
|
||||
BSH = /bin/sh
|
||||
|
||||
|
||||
# /* ----------------------------------------------------------------------
|
||||
# don't change section below without need
|
||||
# ------------------------------------------------------------------------- */
|
||||
|
||||
HIP_OPTS += -DUSE_HIP $(HIP_PRECISION)
|
||||
HIP_GPU_OPTS += $(HIP_OPTS) -I./
|
||||
|
||||
ifeq (hcc,$(HIP_PLATFORM))
|
||||
HIP_HOST_OPTS += -fPIC
|
||||
HIP_GPU_CC = $(HIP_PATH)/bin/hipcc --genco
|
||||
HIP_GPU_OPTS_S = -t="$(HIP_ARCH)" -f=\"
|
||||
HIP_GPU_OPTS_E = \"
|
||||
HIP_KERNEL_SUFFIX = .cpp
|
||||
HIP_LIBS_TARGET = export HCC_AMDGPU_TARGET := $(HIP_ARCH)
|
||||
export HCC_AMDGPU_TARGET := $(HIP_ARCH)
|
||||
else ifeq (nvcc,$(HIP_PLATFORM))
|
||||
HIP_GPU_CC = $(HIP_PATH)/bin/hipcc --fatbin
|
||||
HIP_GPU_OPTS += $(HIP_ARCH)
|
||||
HIP_GPU_SORT_ARCH = $(HIP_ARCH)
|
||||
# fix nvcc can't handle -pthread flag
|
||||
MPI_COMP_OPTS := $(subst -pthread,-Xcompiler -pthread,$(MPI_COMP_OPTS))
|
||||
MPI_LINK_OPTS := $(subst -pthread,-Xcompiler -pthread,$(MPI_LINK_OPTS))
|
||||
endif
|
||||
|
||||
# hipcc is essential for device sort, because of hipcub is header only library and ROCm gpu code generation is deferred to the linking stage
|
||||
HIP_HOST_CC = $(HIP_PATH)/bin/hipcc
|
||||
HIP_HOST_OPTS += $(HIP_OPTS) $(MPI_COMP_OPTS) $(LMP_INC)
|
||||
HIP_HOST_CC_CMD = $(HIP_HOST_CC) $(HIP_HOST_OPTS) $(HIP_HOST_INCLUDE)
|
||||
|
||||
# sources
|
||||
|
||||
ALL_H = $(wildcard ./geryon/ucl*.h) $(wildcard ./geryon/hip*.h) $(wildcard ./lal_*.h)
|
||||
SRCS := $(wildcard ./lal_*.cpp)
|
||||
OBJS := $(subst ./,$(OBJ_DIR)/,$(SRCS:%.cpp=%.o))
|
||||
CUS := $(wildcard lal_*.cu)
|
||||
CUHS := $(filter-out pppm_cubin.h, $(CUS:lal_%.cu=%_cubin.h)) pppm_f_cubin.h pppm_d_cubin.h
|
||||
CUHS := $(addprefix $(OBJ_DIR)/, $(CUHS))
|
||||
|
||||
all: $(OBJ_DIR) $(CUHS) $(LIB_DIR)/libgpu.a $(BIN_DIR)/hip_get_devices
|
||||
|
||||
$(OBJ_DIR):
|
||||
mkdir -p $@
|
||||
|
||||
# GPU kernels compilation
|
||||
|
||||
$(OBJ_DIR)/pppm_f_cubin.h: lal_pppm.cu $(ALL_H)
|
||||
@cp $< $(OBJ_DIR)/temp_pppm_f.cu$(HIP_KERNEL_SUFFIX)
|
||||
$(HIP_GPU_CC) $(HIP_GPU_OPTS_S) $(HIP_GPU_OPTS) -Dgrdtyp=float -Dgrdtyp4=float4 $(HIP_GPU_OPTS_E) -o $(OBJ_DIR)/pppm_f.cubin $(OBJ_DIR)/temp_pppm_f.cu$(HIP_KERNEL_SUFFIX)
|
||||
@xxd -i $(OBJ_DIR)/pppm_f.cubin $@
|
||||
@sed -i "s/[a-zA-Z0-9_]*pppm_f_cubin/pppm_f/g" $@
|
||||
@rm $(OBJ_DIR)/temp_pppm_f.cu$(HIP_KERNEL_SUFFIX) $(OBJ_DIR)/pppm_f.cubin
|
||||
|
||||
$(OBJ_DIR)/pppm_d_cubin.h: lal_pppm.cu $(ALL_H)
|
||||
@cp $< $(OBJ_DIR)/temp_pppm_d.cu$(HIP_KERNEL_SUFFIX)
|
||||
$(HIP_GPU_CC) $(HIP_GPU_OPTS_S) $(HIP_GPU_OPTS) -Dgrdtyp=double -Dgrdtyp4=double4 $(HIP_GPU_OPTS_E) -o $(OBJ_DIR)/pppm_d.cubin $(OBJ_DIR)/temp_pppm_d.cu$(HIP_KERNEL_SUFFIX)
|
||||
@xxd -i $(OBJ_DIR)/pppm_d.cubin $@
|
||||
@sed -i "s/[a-zA-Z0-9_]*pppm_d_cubin/pppm_d/g" $@
|
||||
@rm $(OBJ_DIR)/temp_pppm_d.cu$(HIP_KERNEL_SUFFIX) $(OBJ_DIR)/pppm_d.cubin
|
||||
|
||||
$(OBJ_DIR)/%_cubin.h: lal_%.cu $(ALL_H)
|
||||
@cp $< $(OBJ_DIR)/temp_$*.cu$(HIP_KERNEL_SUFFIX)
|
||||
$(HIP_GPU_CC) $(HIP_GPU_OPTS_S) $(HIP_GPU_OPTS) $(HIP_GPU_OPTS_E) -o $(OBJ_DIR)/$*.cubin $(OBJ_DIR)/temp_$*.cu$(HIP_KERNEL_SUFFIX)
|
||||
@xxd -i $(OBJ_DIR)/$*.cubin $@
|
||||
@sed -i "s/[a-zA-Z0-9_]*$*_cubin/$*/g" $@
|
||||
@rm $(OBJ_DIR)/temp_$*.cu$(HIP_KERNEL_SUFFIX) $(OBJ_DIR)/$*.cubin
|
||||
|
||||
# host sources compilation
|
||||
|
||||
$(OBJ_DIR)/lal_atom.o: lal_atom.cpp $(CUHS) $(ALL_H)
|
||||
$(HIP_HOST_CC_CMD) -o $@ -c $< -I$(OBJ_DIR) $(HIP_GPU_SORT_ARCH)
|
||||
|
||||
$(OBJ_DIR)/lal_%.o: lal_%.cpp $(CUHS) $(ALL_H)
|
||||
$(HIP_HOST_CC_CMD) -o $@ -c $< -I$(OBJ_DIR)
|
||||
|
||||
# libgpu building
|
||||
|
||||
$(LIB_DIR)/libgpu.a: $(OBJS)
|
||||
$(AR) -crs $@ $(OBJS)
|
||||
printf "export HIP_PLATFORM := %s\n%s\n" "$(HIP_PLATFORM)" "$(HIP_LIBS_TARGET)" > Makefile.lammps
|
||||
|
||||
# test app building
|
||||
|
||||
$(BIN_DIR)/hip_get_devices: ./geryon/ucl_get_devices.cpp $(ALL_H)
|
||||
$(HIP_HOST_CC_CMD) -o $@ $< -DUCL_HIP $(MPI_LINK_OPTS)
|
||||
|
||||
clean:
|
||||
-rm -f $(BIN_DIR)/hip_get_devices $(LIB_DIR)/libgpu.a $(OBJS) $(OBJ_DIR)/temp_* $(CUHS)
|
||||
@ -67,8 +67,8 @@ library requires installing the CUDA GPU driver and CUDA toolkit for
|
||||
your operating system. Installation of the CUDA SDK is not necessary.
|
||||
In addition to the LAMMPS library, the binary nvc_get_devices will also
|
||||
be built. This can be used to query the names and properties of GPU
|
||||
devices on your system. A Makefile for OpenCL compilation is provided,
|
||||
but support for OpenCL use is not currently provided by the developers.
|
||||
devices on your system. A Makefile for OpenCL and ROCm HIP compilation
|
||||
is provided, but support for it is not currently provided by the developers.
|
||||
Details of the implementation are provided in:
|
||||
|
||||
----
|
||||
@ -169,6 +169,25 @@ NOTE: The system-specific setting LAMMPS_SMALLBIG (default), LAMMPS_BIGBIG,
|
||||
src/MAKE/Makefile.foo) should be consistent with that specified
|
||||
when building libgpu.a (i.e. by LMP_INC in the lib/gpu/Makefile.bar).
|
||||
|
||||
BUILDING FOR HIP FRAMEWORK
|
||||
--------------------------------
|
||||
1. Install the latest ROCm framework (https://github.com/RadeonOpenCompute/ROCm).
|
||||
2. GPU sorting requires installing hipcub
|
||||
(https://github.com/ROCmSoftwarePlatform/hipCUB). The HIP CUDA-backend
|
||||
additionally requires cub (https://nvlabs.github.io/cub). Download and
|
||||
extract the cub directory to lammps/lib/gpu/ or specify an appropriate
|
||||
path in lammps/lib/gpu/Makefile.hip.
|
||||
3. In Makefile.hip it is possible to specify the target platform via
|
||||
export HIP_PLATFORM=hcc or HIP_PLATFORM=nvcc as well as the target
|
||||
architecture (gfx803, gfx900, gfx906 etc.)
|
||||
4. If your MPI implementation does not support `mpicxx --showme` command,
|
||||
it is required to specify the corresponding MPI compiler and linker flags
|
||||
in lammps/lib/gpu/Makefile.hip and in lammps/src/MAKE/OPTIONS/Makefile.hip.
|
||||
5. Building the GPU library (libgpu.a):
|
||||
cd lammps/lib/gpu; make -f Makefile.hip -j
|
||||
6. Building the LAMMPS executable (lmp_hip):
|
||||
cd ../../src; make hip -j
|
||||
|
||||
EXAMPLE CONVENTIONAL BUILD PROCESS
|
||||
--------------------------------
|
||||
|
||||
|
||||
519
lib/gpu/geryon/hip_device.h
Normal file
519
lib/gpu/geryon/hip_device.h
Normal file
@ -0,0 +1,519 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
Copyright (2009) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the Simplified BSD License.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef HIP_DEVICE
|
||||
#define HIP_DEVICE
|
||||
|
||||
|
||||
#include <hip/hip_runtime.h>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include "hip_macros.h"
|
||||
#include "ucl_types.h"
|
||||
|
||||
namespace ucl_hip {
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// - COMMAND QUEUE STUFF
|
||||
// --------------------------------------------------------------------------
|
||||
typedef hipStream_t command_queue;
|
||||
|
||||
inline void ucl_sync(hipStream_t &stream) {
|
||||
CU_SAFE_CALL(hipStreamSynchronize(stream));
|
||||
}
|
||||
|
||||
struct NVDProperties {
|
||||
int device_id;
|
||||
std::string name;
|
||||
int major;
|
||||
int minor;
|
||||
CUDA_INT_TYPE totalGlobalMem;
|
||||
int multiProcessorCount;
|
||||
|
||||
int maxThreadsPerBlock;
|
||||
int maxThreadsDim[3];
|
||||
int maxGridSize[3];
|
||||
int sharedMemPerBlock;
|
||||
int totalConstantMemory;
|
||||
int SIMDWidth;
|
||||
int memPitch;
|
||||
int regsPerBlock;
|
||||
int clockRate;
|
||||
int textureAlign;
|
||||
|
||||
int kernelExecTimeoutEnabled;
|
||||
int integrated;
|
||||
int canMapHostMemory;
|
||||
int concurrentKernels;
|
||||
int ECCEnabled;
|
||||
int computeMode;
|
||||
};
|
||||
|
||||
/// Class for looking at device properties
|
||||
/** \note Calls to change the device outside of the class results in incorrect
|
||||
* behavior
|
||||
* \note There is no error checking for indexing past the number of devices **/
|
||||
class UCL_Device {
|
||||
public:
|
||||
/// Collect properties for every GPU on the node
|
||||
/** \note You must set the active GPU with set() before using the device **/
|
||||
inline UCL_Device();
|
||||
|
||||
inline ~UCL_Device();
|
||||
|
||||
/// Returns 1 (For compatibility with OpenCL)
|
||||
inline int num_platforms() { return 1; }
|
||||
|
||||
/// Return a string with name and info of the current platform
|
||||
inline std::string platform_name()
|
||||
{ return "HIP platform"; }
|
||||
|
||||
/// Delete any contexts/data and set the platform number to be used
|
||||
inline int set_platform(const int pid);
|
||||
|
||||
/// Return the number of devices that support CUDA
|
||||
inline int num_devices() { return _properties.size(); }
|
||||
|
||||
/// Set the CUDA device to the specified device number
|
||||
/** A context and default command queue will be created for the device
|
||||
* Returns UCL_SUCCESS if successful or UCL_ERROR if the device could not
|
||||
* be allocated for use. clear() is called to delete any contexts and
|
||||
* associated data from previous calls to set(). **/
|
||||
inline int set(int num);
|
||||
|
||||
/// Delete any context and associated data stored from a call to set()
|
||||
inline void clear();
|
||||
|
||||
/// Get the current device number
|
||||
inline int device_num() { return _device; }
|
||||
|
||||
/// Returns the default stream for the current device
|
||||
inline command_queue & cq() { return cq(0); }
|
||||
|
||||
/// Returns the stream indexed by i
|
||||
inline command_queue & cq(const int i) { return _cq[i]; }
|
||||
|
||||
/// Block until all commands in the default stream have completed
|
||||
inline void sync() { sync(0); }
|
||||
|
||||
/// Block until all commands in the specified stream have completed
|
||||
inline void sync(const int i) { ucl_sync(cq(i)); }
|
||||
|
||||
/// Get the number of command queues currently available on device
|
||||
inline int num_queues()
|
||||
{ return _cq.size(); }
|
||||
|
||||
/// Add a stream for device computations
|
||||
inline void push_command_queue() {
|
||||
_cq.push_back(hipStream_t());
|
||||
CU_SAFE_CALL(hipStreamCreateWithFlags(&_cq.back(),0));
|
||||
}
|
||||
|
||||
/// Remove a stream for device computations
|
||||
/** \note You cannot delete the default stream **/
|
||||
inline void pop_command_queue() {
|
||||
if (_cq.size()<2) return;
|
||||
CU_SAFE_CALL_NS(hipStreamDestroy(_cq.back()));
|
||||
_cq.pop_back();
|
||||
}
|
||||
|
||||
/// Set the default command queue (by default this is the null stream)
|
||||
/** \param i index of the command queue (as added by push_command_queue())
|
||||
If i is 0, the default command queue is set to the null stream **/
|
||||
inline void set_command_queue(const int i) {
|
||||
if (i==0) _cq[0]=0;
|
||||
else _cq[0]=_cq[i];
|
||||
}
|
||||
|
||||
/// Get the current CUDA device name
|
||||
inline std::string name() { return name(_device); }
|
||||
/// Get the CUDA device name
|
||||
inline std::string name(const int i)
|
||||
{ return std::string(_properties[i].name); }
|
||||
|
||||
/// Get a string telling the type of the current device
|
||||
inline std::string device_type_name() { return device_type_name(_device); }
|
||||
/// Get a string telling the type of the device
|
||||
inline std::string device_type_name(const int i) { return "GPU"; }
|
||||
|
||||
/// Get current device type (UCL_CPU, UCL_GPU, UCL_ACCELERATOR, UCL_DEFAULT)
|
||||
inline int device_type() { return device_type(_device); }
|
||||
/// Get device type (UCL_CPU, UCL_GPU, UCL_ACCELERATOR, UCL_DEFAULT)
|
||||
inline int device_type(const int i) { return UCL_GPU; }
|
||||
|
||||
/// Returns true if host memory is efficiently addressable from device
|
||||
inline bool shared_memory() { return shared_memory(_device); }
|
||||
/// Returns true if host memory is efficiently addressable from device
|
||||
inline bool shared_memory(const int i) { return device_type(i)==UCL_CPU; }
|
||||
|
||||
/// Returns true if double precision is support for the current device
|
||||
inline bool double_precision() { return double_precision(_device); }
|
||||
/// Returns true if double precision is support for the device
|
||||
inline bool double_precision(const int i) {return arch(i)>=1.3;}
|
||||
|
||||
/// Get the number of compute units on the current device
|
||||
inline unsigned cus() { return cus(_device); }
|
||||
/// Get the number of compute units
|
||||
inline unsigned cus(const int i)
|
||||
{ return _properties[i].multiProcessorCount; }
|
||||
|
||||
/// Get the number of cores in the current device
|
||||
inline unsigned cores() { return cores(_device); }
|
||||
/// Get the number of cores
|
||||
inline unsigned cores(const int i)
|
||||
{ if (arch(i)<2.0) return _properties[i].multiProcessorCount*8;
|
||||
else if (arch(i)<2.1) return _properties[i].multiProcessorCount*32;
|
||||
else if (arch(i)<3.0) return _properties[i].multiProcessorCount*48;
|
||||
else return _properties[i].multiProcessorCount*192; }
|
||||
|
||||
/// Get the gigabytes of global memory in the current device
|
||||
inline double gigabytes() { return gigabytes(_device); }
|
||||
/// Get the gigabytes of global memory
|
||||
inline double gigabytes(const int i)
|
||||
{ return static_cast<double>(_properties[i].totalGlobalMem)/1073741824; }
|
||||
|
||||
/// Get the bytes of global memory in the current device
|
||||
inline size_t bytes() { return bytes(_device); }
|
||||
/// Get the bytes of global memory
|
||||
inline size_t bytes(const int i) { return _properties[i].totalGlobalMem; }
|
||||
|
||||
// Get the gigabytes of free memory in the current device
|
||||
inline double free_gigabytes() { return free_gigabytes(_device); }
|
||||
// Get the gigabytes of free memory
|
||||
inline double free_gigabytes(const int i)
|
||||
{ return static_cast<double>(free_bytes(i))/1073741824; }
|
||||
|
||||
// Get the bytes of free memory in the current device
|
||||
inline size_t free_bytes() { return free_bytes(_device); }
|
||||
// Get the bytes of free memory
|
||||
inline size_t free_bytes(const int i) {
|
||||
CUDA_INT_TYPE dfree, dtotal;
|
||||
CU_SAFE_CALL_NS(hipMemGetInfo(&dfree, &dtotal));
|
||||
return static_cast<size_t>(dfree);
|
||||
}
|
||||
|
||||
/// Return the GPGPU compute capability for current device
|
||||
inline double arch() { return arch(_device); }
|
||||
/// Return the GPGPU compute capability
|
||||
inline double arch(const int i)
|
||||
{ return static_cast<double>(_properties[i].minor)/10+_properties[i].major;}
|
||||
|
||||
/// Clock rate in GHz for current device
|
||||
inline double clock_rate() { return clock_rate(_device); }
|
||||
/// Clock rate in GHz
|
||||
inline double clock_rate(const int i)
|
||||
{ return _properties[i].clockRate*1e-6;}
|
||||
|
||||
/// Get the maximum number of threads per block
|
||||
inline size_t group_size() { return group_size(_device); }
|
||||
/// Get the maximum number of threads per block
|
||||
inline size_t group_size(const int i)
|
||||
{ return _properties[i].maxThreadsPerBlock; }
|
||||
|
||||
/// Return the maximum memory pitch in bytes for current device
|
||||
inline size_t max_pitch() { return max_pitch(_device); }
|
||||
/// Return the maximum memory pitch in bytes
|
||||
inline size_t max_pitch(const int i) { return _properties[i].memPitch; }
|
||||
|
||||
/// Returns false if accelerator cannot be shared by multiple processes
|
||||
/** If it cannot be determined, true is returned **/
|
||||
inline bool sharing_supported() { return sharing_supported(_device); }
|
||||
/// Returns false if accelerator cannot be shared by multiple processes
|
||||
/** If it cannot be determined, true is returned **/
|
||||
inline bool sharing_supported(const int i)
|
||||
{ return (_properties[i].computeMode == hipComputeModeDefault); }
|
||||
|
||||
/// True if splitting device into equal subdevices supported
|
||||
inline bool fission_equal()
|
||||
{ return fission_equal(_device); }
|
||||
/// True if splitting device into equal subdevices supported
|
||||
inline bool fission_equal(const int i)
|
||||
{ return false; }
|
||||
/// True if splitting device into subdevices by specified counts supported
|
||||
inline bool fission_by_counts()
|
||||
{ return fission_by_counts(_device); }
|
||||
/// True if splitting device into subdevices by specified counts supported
|
||||
inline bool fission_by_counts(const int i)
|
||||
{ return false; }
|
||||
/// True if splitting device into subdevices by affinity domains supported
|
||||
inline bool fission_by_affinity()
|
||||
{ return fission_by_affinity(_device); }
|
||||
/// True if splitting device into subdevices by affinity domains supported
|
||||
inline bool fission_by_affinity(const int i)
|
||||
{ return false; }
|
||||
|
||||
/// Maximum number of subdevices allowed from device fission
|
||||
inline int max_sub_devices()
|
||||
{ return max_sub_devices(_device); }
|
||||
/// Maximum number of subdevices allowed from device fission
|
||||
inline int max_sub_devices(const int i)
|
||||
{ return 0; }
|
||||
|
||||
/// List all devices along with all properties
|
||||
inline void print_all(std::ostream &out);
|
||||
|
||||
/// Select the platform that has accelerators (for compatibility with OpenCL)
|
||||
inline int set_platform_accelerator(int pid=-1) { return UCL_SUCCESS; }
|
||||
|
||||
inline int load_module(const void* program, hipModule_t& module, std::string *log=NULL){
|
||||
auto it = _loaded_modules.emplace(program, hipModule_t());
|
||||
if(!it.second){
|
||||
module = it.first->second;
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
const unsigned int num_opts=2;
|
||||
hipJitOption options[num_opts];
|
||||
void *values[num_opts];
|
||||
|
||||
// set up size of compilation log buffer
|
||||
options[0] = hipJitOptionInfoLogBufferSizeBytes;
|
||||
values[0] = (void *)(int)10240;
|
||||
// set up pointer to the compilation log buffer
|
||||
options[1] = hipJitOptionInfoLogBuffer;
|
||||
char clog[10240] = { 0 };
|
||||
values[1] = clog;
|
||||
|
||||
hipError_t err=hipModuleLoadDataEx(&module,program,num_opts, options,(void **)values);
|
||||
|
||||
if (log!=NULL)
|
||||
*log=std::string(clog);
|
||||
|
||||
if (err != hipSuccess) {
|
||||
#ifndef UCL_NO_EXIT
|
||||
std::cerr << std::endl
|
||||
<< "----------------------------------------------------------\n"
|
||||
<< " UCL Error: Error compiling PTX Program...\n"
|
||||
<< "----------------------------------------------------------\n";
|
||||
std::cerr << log << std::endl;
|
||||
#endif
|
||||
_loaded_modules.erase(it.first);
|
||||
return UCL_COMPILE_ERROR;
|
||||
}
|
||||
it.first->second = module;
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
private:
|
||||
std::unordered_map<const void*, hipModule_t> _loaded_modules;
|
||||
int _device, _num_devices;
|
||||
std::vector<NVDProperties> _properties;
|
||||
std::vector<hipStream_t> _cq;
|
||||
hipDevice_t _cu_device;
|
||||
};
|
||||
|
||||
// Grabs the properties for all devices
|
||||
UCL_Device::UCL_Device() {
|
||||
CU_SAFE_CALL_NS(hipInit(0));
|
||||
CU_SAFE_CALL_NS(hipGetDeviceCount(&_num_devices));
|
||||
for (int i=0; i<_num_devices; ++i) {
|
||||
hipDevice_t dev;
|
||||
CU_SAFE_CALL_NS(hipDeviceGet(&dev,i));
|
||||
int major, minor;
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&major, hipDeviceAttributeComputeCapabilityMajor, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&minor, hipDeviceAttributeComputeCapabilityMinor, dev));
|
||||
if (major==9999)
|
||||
continue;
|
||||
|
||||
NVDProperties prop;
|
||||
prop.device_id = i;
|
||||
prop.major=major;
|
||||
prop.minor=minor;
|
||||
|
||||
char namecstr[1024];
|
||||
CU_SAFE_CALL_NS(hipDeviceGetName(namecstr,1024,dev));
|
||||
prop.name=namecstr;
|
||||
|
||||
CU_SAFE_CALL_NS(hipDeviceTotalMem(&prop.totalGlobalMem,dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.multiProcessorCount, hipDeviceAttributeMultiprocessorCount, dev));
|
||||
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.maxThreadsPerBlock, hipDeviceAttributeMaxThreadsPerBlock, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.maxThreadsDim[0], hipDeviceAttributeMaxBlockDimX, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.maxThreadsDim[1], hipDeviceAttributeMaxBlockDimY, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.maxThreadsDim[2], hipDeviceAttributeMaxBlockDimZ, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.maxGridSize[0], hipDeviceAttributeMaxGridDimX, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.maxGridSize[1], hipDeviceAttributeMaxGridDimY, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.maxGridSize[2], hipDeviceAttributeMaxGridDimZ, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.sharedMemPerBlock, hipDeviceAttributeMaxSharedMemoryPerBlock, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.totalConstantMemory, hipDeviceAttributeTotalConstantMemory, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.SIMDWidth, hipDeviceAttributeWarpSize, dev));
|
||||
//CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.memPitch, CU_DEVICE_ATTRIBUTE_MAX_PITCH, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.regsPerBlock, hipDeviceAttributeMaxRegistersPerBlock, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.clockRate, hipDeviceAttributeClockRate, dev));
|
||||
//CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.textureAlign, CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT, dev));
|
||||
|
||||
//#if CUDA_VERSION >= 2020
|
||||
//CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.kernelExecTimeoutEnabled, CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT,dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.integrated, hipDeviceAttributeIntegrated, dev));
|
||||
//CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.canMapHostMemory, CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY, dev));
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.computeMode, hipDeviceAttributeComputeMode,dev));
|
||||
//#endif
|
||||
//#if CUDA_VERSION >= 3010
|
||||
CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.concurrentKernels, hipDeviceAttributeConcurrentKernels, dev));
|
||||
//CU_SAFE_CALL_NS(hipDeviceGetAttribute(&prop.ECCEnabled, CU_DEVICE_ATTRIBUTE_ECC_ENABLED, dev));
|
||||
//#endif
|
||||
|
||||
_properties.push_back(prop);
|
||||
}
|
||||
_device=-1;
|
||||
_cq.push_back(hipStream_t());
|
||||
_cq.back()=0;
|
||||
}
|
||||
|
||||
UCL_Device::~UCL_Device() {
|
||||
clear();
|
||||
}
|
||||
|
||||
int UCL_Device::set_platform(const int pid) {
|
||||
clear();
|
||||
#ifdef UCL_DEBUG
|
||||
assert(pid<num_platforms());
|
||||
#endif
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
|
||||
// Set the CUDA device to the specified device number
|
||||
int UCL_Device::set(int num) {
|
||||
clear();
|
||||
_device=_properties[num].device_id;
|
||||
hipError_t err=hipDeviceGet(&_cu_device,_device);
|
||||
if (err!=hipSuccess) {
|
||||
#ifndef UCL_NO_EXIT
|
||||
std::cerr << "UCL Error: Could not access accelerator number " << num
|
||||
<< " for use.\n";
|
||||
UCL_GERYON_EXIT;
|
||||
#endif
|
||||
return UCL_ERROR;
|
||||
}
|
||||
//hipError_t err=hipCtxCreate(&_context,0,_cu_device); deprecated and unnecessary
|
||||
err=hipSetDevice(_device);
|
||||
if (err!=hipSuccess) {
|
||||
#ifndef UCL_NO_EXIT
|
||||
std::cerr << "UCL Error: Could not set accelerator number " << num
|
||||
<< " for use.\n";
|
||||
UCL_GERYON_EXIT;
|
||||
#endif
|
||||
return UCL_ERROR;
|
||||
}
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
|
||||
void UCL_Device::clear() {
|
||||
if (_device>-1) {
|
||||
for (int i=1; i<num_queues(); i++) pop_command_queue();
|
||||
CU_SAFE_CALL_NS(hipDeviceReset());
|
||||
}
|
||||
_device=-1;
|
||||
}
|
||||
|
||||
// List all devices along with all properties
|
||||
void UCL_Device::print_all(std::ostream &out) {
|
||||
//#if CUDA_VERSION >= 2020
|
||||
int driver_version;
|
||||
hipDriverGetVersion(&driver_version);
|
||||
out << "Driver Version: "
|
||||
<< driver_version/1000 << "." << driver_version%100
|
||||
<< std::endl;
|
||||
//#endif
|
||||
|
||||
if (num_devices() == 0)
|
||||
out << "There is no device supporting HIP\n";
|
||||
for (int i=0; i<num_devices(); ++i) {
|
||||
out << "\nDevice " << i << ": \"" << name(i) << "\"\n";
|
||||
out << " Type of device: "
|
||||
<< device_type_name(i).c_str() << std::endl;
|
||||
out << " Compute capability: "
|
||||
<< arch(i) << std::endl;
|
||||
out << " Double precision support: ";
|
||||
if (double_precision(i))
|
||||
out << "Yes\n";
|
||||
else
|
||||
out << "No\n";
|
||||
out << " Total amount of global memory: "
|
||||
<< gigabytes(i) << " GB\n";
|
||||
//#if CUDA_VERSION >= 2000
|
||||
out << " Number of compute units/multiprocessors: "
|
||||
<< _properties[i].multiProcessorCount << std::endl;
|
||||
out << " Number of cores: "
|
||||
<< cores(i) << std::endl;
|
||||
//#endif
|
||||
out << " Total amount of constant memory: "
|
||||
<< _properties[i].totalConstantMemory << " bytes\n";
|
||||
out << " Total amount of local/shared memory per block: "
|
||||
<< _properties[i].sharedMemPerBlock << " bytes\n";
|
||||
out << " Total number of registers available per block: "
|
||||
<< _properties[i].regsPerBlock << std::endl;
|
||||
out << " Warp size: "
|
||||
<< _properties[i].SIMDWidth << std::endl;
|
||||
out << " Maximum number of threads per block: "
|
||||
<< _properties[i].maxThreadsPerBlock << std::endl;
|
||||
out << " Maximum group size (# of threads per block) "
|
||||
<< _properties[i].maxThreadsDim[0] << " x "
|
||||
<< _properties[i].maxThreadsDim[1] << " x "
|
||||
<< _properties[i].maxThreadsDim[2] << std::endl;
|
||||
out << " Maximum item sizes (# threads for each dim) "
|
||||
<< _properties[i].maxGridSize[0] << " x "
|
||||
<< _properties[i].maxGridSize[1] << " x "
|
||||
<< _properties[i].maxGridSize[2] << std::endl;
|
||||
//out << " Maximum memory pitch: "
|
||||
// << max_pitch(i) << " bytes\n";
|
||||
//out << " Texture alignment: "
|
||||
// << _properties[i].textureAlign << " bytes\n";
|
||||
out << " Clock rate: "
|
||||
<< clock_rate(i) << " GHz\n";
|
||||
//#if CUDA_VERSION >= 2020
|
||||
//out << " Run time limit on kernels: ";
|
||||
//if (_properties[i].kernelExecTimeoutEnabled)
|
||||
// out << "Yes\n";
|
||||
//else
|
||||
// out << "No\n";
|
||||
out << " Integrated: ";
|
||||
if (_properties[i].integrated)
|
||||
out << "Yes\n";
|
||||
else
|
||||
out << "No\n";
|
||||
//out << " Support host page-locked memory mapping: ";
|
||||
//if (_properties[i].canMapHostMemory)
|
||||
// out << "Yes\n";
|
||||
//else
|
||||
// out << "No\n";
|
||||
out << " Compute mode: ";
|
||||
if (_properties[i].computeMode == hipComputeModeDefault)
|
||||
out << "Default\n"; // multiple threads can use device
|
||||
//#if CUDA_VERSION >= 8000
|
||||
// else if (_properties[i].computeMode == hipComputeModeExclusiveProcess)
|
||||
//#else
|
||||
else if (_properties[i].computeMode == hipComputeModeExclusive)
|
||||
//#endif
|
||||
out << "Exclusive\n"; // only thread can use device
|
||||
else if (_properties[i].computeMode == hipComputeModeProhibited)
|
||||
out << "Prohibited\n"; // no thread can use device
|
||||
//#if CUDART_VERSION >= 4000
|
||||
else if (_properties[i].computeMode == hipComputeModeExclusiveProcess)
|
||||
out << "Exclusive Process\n"; // multiple threads 1 process
|
||||
//#endif
|
||||
else
|
||||
out << "Unknown\n";
|
||||
//#endif
|
||||
//#if CUDA_VERSION >= 3010
|
||||
out << " Concurrent kernel execution: ";
|
||||
if (_properties[i].concurrentKernels)
|
||||
out << "Yes\n";
|
||||
else
|
||||
out << "No\n";
|
||||
//out << " Device has ECC support enabled: ";
|
||||
//if (_properties[i].ECCEnabled)
|
||||
// out << "Yes\n";
|
||||
//else
|
||||
// out << "No\n";
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
298
lib/gpu/geryon/hip_kernel.h
Normal file
298
lib/gpu/geryon/hip_kernel.h
Normal file
@ -0,0 +1,298 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
Copyright (2010) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the Simplified BSD License.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef HIP_KERNEL
|
||||
#define HIP_KERNEL
|
||||
|
||||
|
||||
#include <hip/hip_runtime.h>
|
||||
#include "hip_device.h"
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
namespace ucl_hip {
|
||||
|
||||
class UCL_Texture;
|
||||
template <class numtyp> class UCL_D_Vec;
|
||||
template <class numtyp> class UCL_D_Mat;
|
||||
template <class hosttype, class devtype> class UCL_Vector;
|
||||
template <class hosttype, class devtype> class UCL_Matrix;
|
||||
#define UCL_MAX_KERNEL_ARGS 256
|
||||
|
||||
/// Class storing 1 or more kernel functions from a single string or file
|
||||
class UCL_Program {
|
||||
UCL_Device* _device_ptr;
|
||||
public:
|
||||
inline UCL_Program(UCL_Device &device) { _device_ptr = &device; _cq=device.cq(); }
|
||||
inline UCL_Program(UCL_Device &device, const void *program,
|
||||
const char *flags="", std::string *log=NULL) {
|
||||
_device_ptr = &device; _cq=device.cq();
|
||||
init(device);
|
||||
load_string(program,flags,log);
|
||||
}
|
||||
|
||||
inline ~UCL_Program() {}
|
||||
|
||||
/// Initialize the program with a device
|
||||
inline void init(UCL_Device &device) { _device_ptr = &device; _cq=device.cq(); }
|
||||
|
||||
/// Clear any data associated with program
|
||||
/** \note Must call init() after each clear **/
|
||||
inline void clear() { }
|
||||
|
||||
/// Load a program from a file and compile with flags
|
||||
inline int load(const char *filename, const char *flags="", std::string *log=NULL) {
|
||||
std::ifstream in(filename);
|
||||
if (!in || in.is_open()==false) {
|
||||
#ifndef UCL_NO_EXIT
|
||||
std::cerr << "UCL Error: Could not open kernel file: "
|
||||
<< filename << std::endl;
|
||||
UCL_GERYON_EXIT;
|
||||
#endif
|
||||
return UCL_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
std::string program((std::istreambuf_iterator<char>(in)),
|
||||
std::istreambuf_iterator<char>());
|
||||
in.close();
|
||||
return load_string(program.c_str(),flags,log);
|
||||
}
|
||||
|
||||
/// Load a program from a string and compile with flags
|
||||
inline int load_string(const void *program, const char *flags="", std::string *log=NULL) {
|
||||
return _device_ptr->load_module(program, _module, log);
|
||||
}
|
||||
|
||||
friend class UCL_Kernel;
|
||||
private:
|
||||
hipModule_t _module;
|
||||
hipStream_t _cq;
|
||||
friend class UCL_Texture;
|
||||
};
|
||||
|
||||
/// Class for dealing with CUDA Driver kernels
|
||||
class UCL_Kernel {
|
||||
public:
|
||||
UCL_Kernel() : _dimensions(1), _num_args(0) {
|
||||
_num_blocks[0]=0;
|
||||
}
|
||||
|
||||
UCL_Kernel(UCL_Program &program, const char *function) :
|
||||
_dimensions(1), _num_args(0) {
|
||||
_num_blocks[0]=0;
|
||||
set_function(program,function);
|
||||
_cq=program._cq;
|
||||
}
|
||||
|
||||
~UCL_Kernel() {}
|
||||
|
||||
/// Clear any function associated with the kernel
|
||||
inline void clear() { }
|
||||
|
||||
/// Get the kernel function from a program
|
||||
/** \ret UCL_ERROR_FLAG (UCL_SUCCESS, UCL_FILE_NOT_FOUND, UCL_ERROR) **/
|
||||
inline int set_function(UCL_Program &program, const char *function) {
|
||||
hipError_t err=hipModuleGetFunction(&_kernel,program._module,function);
|
||||
if (err!=hipSuccess) {
|
||||
#ifndef UCL_NO_EXIT
|
||||
std::cerr << "UCL Error: Could not find function: " << function
|
||||
<< " in program.\n";
|
||||
UCL_GERYON_EXIT;
|
||||
#endif
|
||||
return UCL_FUNCTION_NOT_FOUND;
|
||||
}
|
||||
_cq=program._cq;
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
|
||||
/// Set the kernel argument.
|
||||
/** If not a device pointer, this must be repeated each time the argument
|
||||
* changes
|
||||
* \note To set kernel parameter i (i>0), parameter i-1 must be set **/
|
||||
template <class dtype>
|
||||
inline void set_arg(const unsigned index, const dtype * const arg) {
|
||||
if (index==_num_args)
|
||||
add_arg(arg);
|
||||
else if (index<_num_args){
|
||||
assert(0==1); // not implemented
|
||||
}
|
||||
else
|
||||
assert(0==1); // Must add kernel parameters in sequential order
|
||||
}
|
||||
|
||||
/// Set a geryon container as a kernel argument.
|
||||
template <class numtyp>
|
||||
inline void set_arg(const UCL_D_Vec<numtyp> * const arg)
|
||||
{ set_arg(&arg->begin()); }
|
||||
|
||||
/// Set a geryon container as a kernel argument.
|
||||
template <class numtyp>
|
||||
inline void set_arg(const UCL_D_Mat<numtyp> * const arg)
|
||||
{ set_arg(&arg->begin()); }
|
||||
|
||||
/// Set a geryon container as a kernel argument.
|
||||
template <class hosttype, class devtype>
|
||||
inline void set_arg(const UCL_Vector<hosttype, devtype> * const arg)
|
||||
{ set_arg(&arg->device.begin()); }
|
||||
|
||||
/// Set a geryon container as a kernel argument.
|
||||
template <class hosttype, class devtype>
|
||||
inline void set_arg(const UCL_Matrix<hosttype, devtype> * const arg)
|
||||
{ set_arg(&arg->device.begin()); }
|
||||
|
||||
/// Add a kernel argument.
|
||||
inline void add_arg(const hipDeviceptr_t* const arg) {
|
||||
add_arg<void*>((void**)arg);
|
||||
}
|
||||
|
||||
/// Add a kernel argument.
|
||||
template <class dtype>
|
||||
inline void add_arg(const dtype* const arg) {
|
||||
const auto old_size = _hip_kernel_args.size();
|
||||
const auto aligned_size = (old_size+alignof(dtype)-1) & ~(alignof(dtype)-1);
|
||||
const auto arg_size = sizeof(dtype);
|
||||
_hip_kernel_args.resize(aligned_size + arg_size);
|
||||
*((dtype*)(&_hip_kernel_args[aligned_size])) = *arg;
|
||||
_num_args++;
|
||||
if (_num_args>UCL_MAX_KERNEL_ARGS) assert(0==1);
|
||||
}
|
||||
|
||||
/// Add a geryon container as a kernel argument.
|
||||
template <class numtyp>
|
||||
inline void add_arg(const UCL_D_Vec<numtyp> * const arg)
|
||||
{ add_arg(&arg->begin()); }
|
||||
|
||||
/// Add a geryon container as a kernel argument.
|
||||
template <class numtyp>
|
||||
inline void add_arg(const UCL_D_Mat<numtyp> * const arg)
|
||||
{ add_arg(&arg->begin()); }
|
||||
|
||||
/// Add a geryon container as a kernel argument.
|
||||
template <class hosttype, class devtype>
|
||||
inline void add_arg(const UCL_Vector<hosttype, devtype> * const arg)
|
||||
{ add_arg(&arg->device.begin()); }
|
||||
|
||||
/// Add a geryon container as a kernel argument.
|
||||
template <class hosttype, class devtype>
|
||||
inline void add_arg(const UCL_Matrix<hosttype, devtype> * const arg)
|
||||
{ add_arg(&arg->device.begin()); }
|
||||
|
||||
/// Set the number of thread blocks and the number of threads in each block
|
||||
/** \note This should be called before any arguments have been added
|
||||
\note The default command queue is used for the kernel execution **/
|
||||
inline void set_size(const size_t num_blocks, const size_t block_size) {
|
||||
_dimensions=1;
|
||||
_num_blocks[0]=num_blocks;
|
||||
_num_blocks[1]=1;
|
||||
_num_blocks[2]=1;
|
||||
|
||||
_block_size[0]=block_size;
|
||||
_block_size[1]=1;
|
||||
_block_size[2]=1;
|
||||
}
|
||||
|
||||
/// Set the number of thread blocks and the number of threads in each block
|
||||
/** \note This should be called before any arguments have been added
|
||||
\note The default command queue for the kernel is changed to cq **/
|
||||
inline void set_size(const size_t num_blocks, const size_t block_size,
|
||||
command_queue &cq)
|
||||
{ _cq=cq; set_size(num_blocks,block_size); }
|
||||
|
||||
/// Set the number of thread blocks and the number of threads in each block
|
||||
/** \note This should be called before any arguments have been added
|
||||
\note The default command queue is used for the kernel execution **/
|
||||
inline void set_size(const size_t num_blocks_x, const size_t num_blocks_y,
|
||||
const size_t block_size_x, const size_t block_size_y) {
|
||||
_dimensions=2;
|
||||
_num_blocks[0]=num_blocks_x;
|
||||
_num_blocks[1]=num_blocks_y;
|
||||
_num_blocks[2]=1;
|
||||
|
||||
_block_size[0]=block_size_x;
|
||||
_block_size[1]=block_size_y;
|
||||
_block_size[2]=1;
|
||||
}
|
||||
|
||||
/// Set the number of thread blocks and the number of threads in each block
|
||||
/** \note This should be called before any arguments have been added
|
||||
\note The default command queue for the kernel is changed to cq **/
|
||||
inline void set_size(const size_t num_blocks_x, const size_t num_blocks_y,
|
||||
const size_t block_size_x, const size_t block_size_y,
|
||||
command_queue &cq)
|
||||
{_cq=cq; set_size(num_blocks_x, num_blocks_y, block_size_x, block_size_y);}
|
||||
|
||||
/// Set the number of thread blocks and the number of threads in each block
|
||||
/** \note This should be called before any arguments have been added
|
||||
\note The default command queue is used for the kernel execution **/
|
||||
inline void set_size(const size_t num_blocks_x, const size_t num_blocks_y,
|
||||
const size_t block_size_x,
|
||||
const size_t block_size_y, const size_t block_size_z) {
|
||||
_dimensions=2;
|
||||
_num_blocks[0]=num_blocks_x;
|
||||
_num_blocks[1]=num_blocks_y;
|
||||
_num_blocks[2]=1;
|
||||
|
||||
_block_size[0]=block_size_x;
|
||||
_block_size[1]=block_size_y;
|
||||
_block_size[2]=block_size_z;
|
||||
}
|
||||
|
||||
/// Set the number of thread blocks and the number of threads in each block
|
||||
/** \note This should be called before any arguments have been added
|
||||
\note The default command queue is used for the kernel execution **/
|
||||
inline void set_size(const size_t num_blocks_x, const size_t num_blocks_y,
|
||||
const size_t block_size_x, const size_t block_size_y,
|
||||
const size_t block_size_z, command_queue &cq) {
|
||||
_cq=cq;
|
||||
set_size(num_blocks_x, num_blocks_y, block_size_x, block_size_y,
|
||||
block_size_z);
|
||||
}
|
||||
|
||||
/// Run the kernel in the default command queue
|
||||
inline void run() {
|
||||
size_t args_size = _hip_kernel_args.size();
|
||||
void *config[] = {
|
||||
HIP_LAUNCH_PARAM_BUFFER_POINTER, (void*)_hip_kernel_args.data(),
|
||||
HIP_LAUNCH_PARAM_BUFFER_SIZE, &args_size,
|
||||
HIP_LAUNCH_PARAM_END
|
||||
};
|
||||
const auto res = hipModuleLaunchKernel(_kernel,_num_blocks[0],_num_blocks[1],
|
||||
_num_blocks[2],_block_size[0],_block_size[1],
|
||||
_block_size[2],0,_cq, NULL, config);
|
||||
CU_SAFE_CALL(res);
|
||||
//#endif
|
||||
}
|
||||
|
||||
/// Clear any arguments associated with the kernel
|
||||
inline void clear_args() {
|
||||
_num_args=0;
|
||||
_hip_kernel_args.clear();
|
||||
}
|
||||
|
||||
/// Return the default command queue/stream associated with this data
|
||||
inline command_queue & cq() { return _cq; }
|
||||
/// Change the default command queue associated with matrix
|
||||
inline void cq(command_queue &cq_in) { _cq=cq_in; }
|
||||
#include "ucl_arg_kludge.h"
|
||||
|
||||
private:
|
||||
hipFunction_t _kernel;
|
||||
hipStream_t _cq;
|
||||
unsigned _dimensions;
|
||||
unsigned _num_blocks[3];
|
||||
unsigned _num_args;
|
||||
friend class UCL_Texture;
|
||||
|
||||
unsigned _block_size[3];
|
||||
std::vector<char> _hip_kernel_args;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
83
lib/gpu/geryon/hip_macros.h
Normal file
83
lib/gpu/geryon/hip_macros.h
Normal file
@ -0,0 +1,83 @@
|
||||
#ifndef HIP_MACROS_H
|
||||
#define HIP_MACROS_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <hip/hip_runtime.h>
|
||||
|
||||
//#if CUDA_VERSION >= 3020
|
||||
#define CUDA_INT_TYPE size_t
|
||||
//#else
|
||||
//#define CUDA_INT_TYPE unsigned
|
||||
//#endif
|
||||
|
||||
#ifdef MPI_GERYON
|
||||
#include "mpi.h"
|
||||
#define NVD_GERYON_EXIT do { \
|
||||
int is_final; \
|
||||
MPI_Finalized(&is_final); \
|
||||
if (!is_final) \
|
||||
MPI_Abort(MPI_COMM_WORLD,-1); \
|
||||
} while(0)
|
||||
#else
|
||||
#define NVD_GERYON_EXIT assert(0==1)
|
||||
#endif
|
||||
|
||||
#ifndef UCL_GERYON_EXIT
|
||||
#define UCL_GERYON_EXIT NVD_GERYON_EXIT
|
||||
#endif
|
||||
|
||||
#ifdef UCL_DEBUG
|
||||
#define UCL_SYNC_DEBUG
|
||||
#define UCL_DESTRUCT_CHECK
|
||||
#endif
|
||||
|
||||
#ifndef UCL_NO_API_CHECK
|
||||
|
||||
#define CU_SAFE_CALL_NS( call ) do { \
|
||||
hipError_t err = call; \
|
||||
if( hipSuccess != err) { \
|
||||
fprintf(stderr, "HIP runtime error %d in call at file '%s' in line %i.\n", \
|
||||
err, __FILE__, __LINE__ ); \
|
||||
NVD_GERYON_EXIT; \
|
||||
} } while (0)
|
||||
|
||||
#ifdef UCL_SYNC_DEBUG
|
||||
|
||||
#define CU_SAFE_CALL( call ) do { \
|
||||
CU_SAFE_CALL_NS( call ); \
|
||||
hipError_t err=hipCtxSynchronize(); \
|
||||
if( hipSuccess != err) { \
|
||||
fprintf(stderr, "HIP runtime error %d in file '%s' in line %i.\n", \
|
||||
err, __FILE__, __LINE__ ); \
|
||||
NVD_GERYON_EXIT; \
|
||||
} } while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define CU_SAFE_CALL( call ) CU_SAFE_CALL_NS( call )
|
||||
|
||||
#endif
|
||||
|
||||
#else // not DEBUG
|
||||
|
||||
// void macros for performance reasons
|
||||
#define CU_SAFE_CALL_NS( call ) call
|
||||
#define CU_SAFE_CALL( call) call
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef UCL_DESTRUCT_CHECK
|
||||
|
||||
#define CU_DESTRUCT_CALL( call) CU_SAFE_CALL( call)
|
||||
#define CU_DESTRUCT_CALL_NS( call) CU_SAFE_CALL_NS( call)
|
||||
|
||||
#else
|
||||
|
||||
#define CU_DESTRUCT_CALL( call) call
|
||||
#define CU_DESTRUCT_CALL_NS( call) call
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
43
lib/gpu/geryon/hip_mat.h
Normal file
43
lib/gpu/geryon/hip_mat.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
Copyright (2010) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the Simplified BSD License.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
/*! \file */
|
||||
|
||||
#ifndef HIP_MAT_H
|
||||
#define HIP_MAT_H
|
||||
|
||||
|
||||
#include <hip/hip_runtime.h>
|
||||
#include "hip_memory.h"
|
||||
|
||||
/// Namespace for CUDA Driver routines
|
||||
namespace ucl_hip {
|
||||
|
||||
#define _UCL_MAT_ALLOW
|
||||
#define _UCL_DEVICE_PTR_MAT
|
||||
#include "ucl_basemat.h"
|
||||
#include "ucl_h_vec.h"
|
||||
#include "ucl_h_mat.h"
|
||||
#include "ucl_d_vec.h"
|
||||
#include "ucl_d_mat.h"
|
||||
#include "ucl_s_obj_help.h"
|
||||
#include "ucl_vector.h"
|
||||
#include "ucl_matrix.h"
|
||||
#undef _UCL_DEVICE_PTR_MAT
|
||||
#undef _UCL_MAT_ALLOW
|
||||
|
||||
#define UCL_COPY_ALLOW
|
||||
#include "ucl_copy.h"
|
||||
#undef UCL_COPY_ALLOW
|
||||
|
||||
#define UCL_PRINT_ALLOW
|
||||
#include "ucl_print.h"
|
||||
#undef UCL_PRINT_ALLOW
|
||||
|
||||
} // namespace ucl_cudadr
|
||||
|
||||
#endif
|
||||
279
lib/gpu/geryon/hip_memory.h
Normal file
279
lib/gpu/geryon/hip_memory.h
Normal file
@ -0,0 +1,279 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
Copyright (2010) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the Simplified BSD License.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef HIP_MEMORY_H
|
||||
#define HIP_MEMORY_H
|
||||
|
||||
|
||||
#include <hip/hip_runtime.h>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include "hip_macros.h"
|
||||
#include "hip_device.h"
|
||||
#include "ucl_types.h"
|
||||
|
||||
namespace ucl_hip {
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// - API Specific Types
|
||||
// --------------------------------------------------------------------------
|
||||
//typedef dim3 ucl_kernel_dim;
|
||||
|
||||
#ifdef __HIP_PLATFORM_NVCC__
|
||||
typedef enum hipArray_Format {
|
||||
HIP_AD_FORMAT_UNSIGNED_INT8 = 0x01,
|
||||
HIP_AD_FORMAT_UNSIGNED_INT16 = 0x02,
|
||||
HIP_AD_FORMAT_UNSIGNED_INT32 = 0x03,
|
||||
HIP_AD_FORMAT_SIGNED_INT8 = 0x08,
|
||||
HIP_AD_FORMAT_SIGNED_INT16 = 0x09,
|
||||
HIP_AD_FORMAT_SIGNED_INT32 = 0x0a,
|
||||
HIP_AD_FORMAT_HALF = 0x10,
|
||||
HIP_AD_FORMAT_FLOAT = 0x20
|
||||
}hipArray_Format;
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// - API SPECIFIC DEVICE POINTERS
|
||||
// --------------------------------------------------------------------------
|
||||
typedef hipDeviceptr_t device_ptr;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// - HOST MEMORY ALLOCATION ROUTINES
|
||||
// --------------------------------------------------------------------------
|
||||
template <class mat_type, class copy_type>
|
||||
inline int _host_alloc(mat_type &mat, copy_type &cm, const size_t n,
|
||||
const enum UCL_MEMOPT kind, const enum UCL_MEMOPT kind2){
|
||||
hipError_t err=hipSuccess;
|
||||
if (kind==UCL_NOT_PINNED)
|
||||
*(mat.host_ptr())=(typename mat_type::data_type*)malloc(n);
|
||||
else if (kind==UCL_WRITE_ONLY)
|
||||
err=hipHostMalloc((void **)mat.host_ptr(),n,hipHostMallocWriteCombined);
|
||||
else
|
||||
err=hipHostMalloc((void **)mat.host_ptr(),n,hipHostMallocDefault);
|
||||
if (err!=hipSuccess || *(mat.host_ptr())==NULL)
|
||||
return UCL_MEMORY_ERROR;
|
||||
mat.cq()=cm.cq();
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
|
||||
template <class mat_type>
|
||||
inline int _host_alloc(mat_type &mat, UCL_Device &dev, const size_t n,
|
||||
const enum UCL_MEMOPT kind, const enum UCL_MEMOPT kind2){
|
||||
hipError_t err=hipSuccess;
|
||||
if (kind==UCL_NOT_PINNED)
|
||||
*(mat.host_ptr())=(typename mat_type::data_type*)malloc(n);
|
||||
else if (kind==UCL_WRITE_ONLY)
|
||||
err=hipHostMalloc((void **)mat.host_ptr(),n,hipHostMallocWriteCombined);
|
||||
else
|
||||
err=hipHostMalloc((void **)mat.host_ptr(),n,hipHostMallocDefault);
|
||||
if (err!=hipSuccess || *(mat.host_ptr())==NULL)
|
||||
return UCL_MEMORY_ERROR;
|
||||
mat.cq()=dev.cq();
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
|
||||
template <class mat_type>
|
||||
inline void _host_free(mat_type &mat) {
|
||||
if (mat.kind()==UCL_VIEW)
|
||||
return;
|
||||
else if (mat.kind()!=UCL_NOT_PINNED)
|
||||
CU_DESTRUCT_CALL(hipHostFree(mat.begin()));
|
||||
else
|
||||
free(mat.begin());
|
||||
}
|
||||
|
||||
template <class mat_type>
|
||||
inline int _host_resize(mat_type &mat, const size_t n) {
|
||||
_host_free(mat);
|
||||
hipError_t err=hipSuccess;
|
||||
if (mat.kind()==UCL_NOT_PINNED)
|
||||
*(mat.host_ptr())=(typename mat_type::data_type*)malloc(n);
|
||||
else if (mat.kind()==UCL_WRITE_ONLY)
|
||||
err=hipHostMalloc((void **)mat.host_ptr(),n,hipHostMallocWriteCombined);
|
||||
else
|
||||
err=hipHostMalloc((void **)mat.host_ptr(),n,hipHostMallocDefault);
|
||||
if (err!=hipSuccess || *(mat.host_ptr())==NULL)
|
||||
return UCL_MEMORY_ERROR;
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// - DEVICE MEMORY ALLOCATION ROUTINES
|
||||
// --------------------------------------------------------------------------
|
||||
template <class mat_type, class copy_type>
|
||||
inline int _device_alloc(mat_type &mat, copy_type &cm, const size_t n,
|
||||
const enum UCL_MEMOPT kind) {
|
||||
hipError_t err=hipMalloc((void**)&mat.cbegin(),n);
|
||||
if (err!=hipSuccess)
|
||||
return UCL_MEMORY_ERROR;
|
||||
mat.cq()=cm.cq();
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
|
||||
template <class mat_type>
|
||||
inline int _device_alloc(mat_type &mat, UCL_Device &dev, const size_t n,
|
||||
const enum UCL_MEMOPT kind) {
|
||||
hipError_t err=hipMalloc((void**)&mat.cbegin(),n);
|
||||
if (err!=hipSuccess)
|
||||
return UCL_MEMORY_ERROR;
|
||||
mat.cq()=dev.cq();
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
|
||||
template <class mat_type, class copy_type>
|
||||
inline int _device_alloc(mat_type &mat, copy_type &cm, const size_t rows,
|
||||
const size_t cols, size_t &pitch,
|
||||
const enum UCL_MEMOPT kind) {
|
||||
hipError_t err;
|
||||
size_t upitch;
|
||||
err=hipMallocPitch((void**)&mat.cbegin(),&upitch,
|
||||
cols*sizeof(typename mat_type::data_type),rows);
|
||||
pitch=static_cast<size_t>(upitch);
|
||||
if (err!=hipSuccess)
|
||||
return UCL_MEMORY_ERROR;
|
||||
mat.cq()=cm.cq();
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
|
||||
template <class mat_type, class copy_type>
|
||||
inline int _device_alloc(mat_type &mat, UCL_Device &d, const size_t rows,
|
||||
const size_t cols, size_t &pitch,
|
||||
const enum UCL_MEMOPT kind) {
|
||||
hipError_t err;
|
||||
size_t upitch;
|
||||
err=hipMallocPitch((void**)&mat.cbegin(),&upitch,
|
||||
cols*sizeof(typename mat_type::data_type),rows);
|
||||
pitch=static_cast<size_t>(upitch);
|
||||
if (err!=hipSuccess)
|
||||
return UCL_MEMORY_ERROR;
|
||||
mat.cq()=d.cq();
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
|
||||
template <class mat_type>
|
||||
inline void _device_free(mat_type &mat) {
|
||||
if (mat.kind()!=UCL_VIEW){
|
||||
CU_DESTRUCT_CALL(hipFree((void*)mat.cbegin()));
|
||||
}
|
||||
}
|
||||
|
||||
template <class mat_type>
|
||||
inline int _device_resize(mat_type &mat, const size_t n) {
|
||||
_device_free(mat);
|
||||
hipError_t err=hipMalloc((void**)&mat.cbegin(),n);
|
||||
if (err!=hipSuccess)
|
||||
return UCL_MEMORY_ERROR;
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
|
||||
template <class mat_type>
|
||||
inline int _device_resize(mat_type &mat, const size_t rows,
|
||||
const size_t cols, size_t &pitch) {
|
||||
_device_free(mat);
|
||||
hipError_t err;
|
||||
size_t upitch;
|
||||
err=hipMallocPitch((void**)&mat.cbegin(),&upitch,
|
||||
cols*sizeof(typename mat_type::data_type),rows);
|
||||
pitch=static_cast<size_t>(upitch);
|
||||
if (err!=hipSuccess)
|
||||
return UCL_MEMORY_ERROR;
|
||||
return UCL_SUCCESS;
|
||||
}
|
||||
|
||||
inline void _device_view(hipDeviceptr_t *ptr, hipDeviceptr_t &in) {
|
||||
*ptr=in;
|
||||
}
|
||||
|
||||
template <class numtyp>
|
||||
inline void _device_view(hipDeviceptr_t *ptr, numtyp *in) {
|
||||
*ptr=0;
|
||||
}
|
||||
|
||||
inline void _device_view(hipDeviceptr_t *ptr, hipDeviceptr_t &in,
|
||||
const size_t offset, const size_t numsize) {
|
||||
*ptr=(hipDeviceptr_t)(((char*)in)+offset*numsize);
|
||||
}
|
||||
|
||||
template <class numtyp>
|
||||
inline void _device_view(hipDeviceptr_t *ptr, numtyp *in,
|
||||
const size_t offset, const size_t numsize) {
|
||||
*ptr=0;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// - DEVICE IMAGE ALLOCATION ROUTINES
|
||||
// --------------------------------------------------------------------------
|
||||
template <class mat_type, class copy_type>
|
||||
inline void _device_image_alloc(mat_type &mat, copy_type &cm, const size_t rows,
|
||||
const size_t cols) {
|
||||
assert(0==1);
|
||||
}
|
||||
|
||||
template <class mat_type, class copy_type>
|
||||
inline void _device_image_alloc(mat_type &mat, UCL_Device &d, const size_t rows,
|
||||
const size_t cols) {
|
||||
assert(0==1);
|
||||
}
|
||||
|
||||
template <class mat_type>
|
||||
inline void _device_image_free(mat_type &mat) {
|
||||
assert(0==1);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// - ZERO ROUTINES
|
||||
// --------------------------------------------------------------------------
|
||||
inline void _host_zero(void *ptr, const size_t n) {
|
||||
memset(ptr,0,n);
|
||||
}
|
||||
|
||||
template <class mat_type>
|
||||
inline void _device_zero(mat_type &mat, const size_t n, command_queue &cq) {
|
||||
CU_SAFE_CALL(hipMemsetAsync((void*)mat.cbegin(),0,n,cq));
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// - MEMCPY ROUTINES
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
||||
template<class mat1, class mat2>
|
||||
hipMemcpyKind _memcpy_kind(mat1 &dst, const mat2 &src){
|
||||
assert(mat1::MEM_TYPE < 2 && mat2::MEM_TYPE < 2);
|
||||
return (hipMemcpyKind)((1 - mat2::MEM_TYPE)*2 + (1 - mat1::MEM_TYPE));
|
||||
}
|
||||
|
||||
template<class mat1, class mat2>
|
||||
inline void ucl_mv_cpy(mat1 &dst, const mat2 &src, const size_t n) {
|
||||
CU_SAFE_CALL(hipMemcpy((void*)dst.begin(), (void*)src.begin(), n, _memcpy_kind(dst, src)));
|
||||
}
|
||||
|
||||
template<class mat1, class mat2>
|
||||
inline void ucl_mv_cpy(mat1 &dst, const mat2 &src, const size_t n, hipStream_t &cq) {
|
||||
CU_SAFE_CALL(hipMemcpyAsync((void*)dst.begin(), (void*)src.begin(), n, _memcpy_kind(dst, src), cq));
|
||||
}
|
||||
|
||||
template<class mat1, class mat2>
|
||||
inline void ucl_mv_cpy(mat1 &dst, const size_t dpitch, const mat2 &src,
|
||||
const size_t spitch, const size_t cols,
|
||||
const size_t rows) {
|
||||
CU_SAFE_CALL(hipMemcpy2D((void*)dst.begin(), dpitch, (void*)src.begin(), spitch, cols, rows, _memcpy_kind(dst, src)));
|
||||
}
|
||||
|
||||
template<class mat1, class mat2>
|
||||
inline void ucl_mv_cpy(mat1 &dst, const size_t dpitch, const mat2 &src,
|
||||
const size_t spitch, const size_t cols,
|
||||
const size_t rows,hipStream_t &cq) {
|
||||
CU_SAFE_CALL(hipMemcpy2DAsync((void*)dst.begin(), dpitch, (void*)src.begin(), spitch, cols, rows, _memcpy_kind(dst, src), cq));
|
||||
}
|
||||
|
||||
} // namespace ucl_cudart
|
||||
|
||||
#endif
|
||||
|
||||
113
lib/gpu/geryon/hip_texture.h
Normal file
113
lib/gpu/geryon/hip_texture.h
Normal file
@ -0,0 +1,113 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
Copyright (2010) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the Simplified BSD License.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef HIP_TEXTURE
|
||||
#define HIP_TEXTURE
|
||||
|
||||
|
||||
#include <hip/hip_runtime.h>
|
||||
#include "hip_kernel.h"
|
||||
#include "hip_mat.h"
|
||||
|
||||
namespace ucl_hip {
|
||||
|
||||
#ifdef __HIP_PLATFORM_NVCC__
|
||||
inline hipError_t hipModuleGetTexRef(CUtexref* texRef, hipModule_t hmod, const char* name){
|
||||
return hipCUResultTohipError(cuModuleGetTexRef(texRef, hmod, name));
|
||||
}
|
||||
inline hipError_t hipTexRefSetFormat(CUtexref tex, hipArray_Format fmt, int NumPackedComponents) {
|
||||
return hipCUResultTohipError(cuTexRefSetFormat(tex, (CUarray_format)fmt, NumPackedComponents ));
|
||||
}
|
||||
inline hipError_t hipTexRefSetAddress(size_t* offset, CUtexref tex, hipDeviceptr_t devPtr, size_t size) {
|
||||
return hipCUResultTohipError(cuTexRefSetAddress(offset, tex, devPtr, size));
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Class storing a texture reference
|
||||
class UCL_Texture {
|
||||
public:
|
||||
UCL_Texture() {}
|
||||
~UCL_Texture() {}
|
||||
/// Construct with a specified texture reference
|
||||
inline UCL_Texture(UCL_Program &prog, const char *texture_name)
|
||||
{ get_texture(prog,texture_name); }
|
||||
/// Set the texture reference for this object
|
||||
inline void get_texture(UCL_Program &prog, const char *texture_name)
|
||||
{
|
||||
#ifdef __HIP_PLATFORM_NVCC__
|
||||
CU_SAFE_CALL(hipModuleGetTexRef(&_tex, prog._module, texture_name));
|
||||
#else
|
||||
size_t _global_var_size;
|
||||
CU_SAFE_CALL(hipModuleGetGlobal(&_device_ptr_to_global_var, &_global_var_size, prog._module, texture_name));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Bind a float array where each fetch grabs a vector of length numel
|
||||
template<class numtyp>
|
||||
inline void bind_float(UCL_D_Vec<numtyp> &vec, const unsigned numel)
|
||||
{ _bind_float(vec,numel); }
|
||||
|
||||
/// Bind a float array where each fetch grabs a vector of length numel
|
||||
template<class numtyp>
|
||||
inline void bind_float(UCL_D_Mat<numtyp> &vec, const unsigned numel)
|
||||
{ _bind_float(vec,numel); }
|
||||
|
||||
/// Bind a float array where each fetch grabs a vector of length numel
|
||||
template<class numtyp, class devtyp>
|
||||
inline void bind_float(UCL_Vector<numtyp, devtyp> &vec, const unsigned numel)
|
||||
{ _bind_float(vec.device,numel); }
|
||||
|
||||
/// Bind a float array where each fetch grabs a vector of length numel
|
||||
template<class numtyp, class devtyp>
|
||||
inline void bind_float(UCL_Matrix<numtyp, devtyp> &vec, const unsigned numel)
|
||||
{ _bind_float(vec.device,numel); }
|
||||
|
||||
/// Unbind the texture reference from the memory allocation
|
||||
inline void unbind() { }
|
||||
|
||||
/// Make a texture reference available to kernel
|
||||
inline void allow(UCL_Kernel &kernel) {
|
||||
//#if CUDA_VERSION < 4000
|
||||
//CU_SAFE_CALL(cuParamSetTexRef(kernel._kernel, CU_PARAM_TR_DEFAULT, _tex));
|
||||
//#endif
|
||||
}
|
||||
|
||||
private:
|
||||
#ifdef __HIP_PLATFORM_NVCC__
|
||||
CUtexref _tex;
|
||||
#else
|
||||
void* _device_ptr_to_global_var;
|
||||
#endif
|
||||
friend class UCL_Kernel;
|
||||
|
||||
template<class mat_typ>
|
||||
inline void _bind_float(mat_typ &vec, const unsigned numel) {
|
||||
#ifdef UCL_DEBUG
|
||||
assert(numel!=0 && numel<5);
|
||||
#endif
|
||||
|
||||
#ifdef __HIP_PLATFORM_NVCC__
|
||||
if (vec.element_size()==sizeof(float))
|
||||
CU_SAFE_CALL(hipTexRefSetFormat(_tex, HIP_AD_FORMAT_FLOAT, numel));
|
||||
else {
|
||||
if (numel>2)
|
||||
CU_SAFE_CALL(hipTexRefSetFormat(_tex, HIP_AD_FORMAT_SIGNED_INT32, numel));
|
||||
else
|
||||
CU_SAFE_CALL(hipTexRefSetFormat(_tex,HIP_AD_FORMAT_SIGNED_INT32,numel*2));
|
||||
}
|
||||
CU_SAFE_CALL(hipTexRefSetAddress(NULL, _tex, vec.cbegin(), vec.numel()*vec.element_size()));
|
||||
#else
|
||||
void* data_ptr = (void*)vec.cbegin();
|
||||
CU_SAFE_CALL(hipMemcpyHtoD(hipDeviceptr_t(_device_ptr_to_global_var), &data_ptr, sizeof(void*)));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
107
lib/gpu/geryon/hip_timer.h
Normal file
107
lib/gpu/geryon/hip_timer.h
Normal file
@ -0,0 +1,107 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
Copyright (2010) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the Simplified BSD License.
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef HIP_TIMER_H
|
||||
#define HIP_TIMER_H
|
||||
|
||||
|
||||
#include <hip/hip_runtime.h>
|
||||
#include "hip_macros.h"
|
||||
#include "hip_device.h"
|
||||
|
||||
namespace ucl_hip {
|
||||
|
||||
/// Class for timing CUDA Driver events
|
||||
class UCL_Timer {
|
||||
public:
|
||||
inline UCL_Timer() : _total_time(0.0f), _initialized(false) { }
|
||||
inline UCL_Timer(UCL_Device &dev) : _total_time(0.0f), _initialized(false)
|
||||
{ init(dev); }
|
||||
|
||||
inline ~UCL_Timer() { clear(); }
|
||||
|
||||
/// Clear any data associated with timer
|
||||
/** \note init() must be called to reuse timer after a clear() **/
|
||||
inline void clear() {
|
||||
if (_initialized) {
|
||||
CU_DESTRUCT_CALL(hipEventDestroy(start_event));
|
||||
CU_DESTRUCT_CALL(hipEventDestroy(stop_event));
|
||||
_initialized=false;
|
||||
_total_time=0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialize default command queue for timing
|
||||
inline void init(UCL_Device &dev) { init(dev, dev.cq()); }
|
||||
|
||||
/// Initialize command queue for timing
|
||||
inline void init(UCL_Device &dev, command_queue &cq) {
|
||||
clear();
|
||||
_cq=cq;
|
||||
_initialized=true;
|
||||
CU_SAFE_CALL( hipEventCreateWithFlags(&start_event,0) );
|
||||
CU_SAFE_CALL( hipEventCreateWithFlags(&stop_event,0) );
|
||||
}
|
||||
|
||||
/// Start timing on command queue
|
||||
inline void start() { CU_SAFE_CALL(hipEventRecord(start_event,_cq)); }
|
||||
|
||||
/// Stop timing on command queue
|
||||
inline void stop() { CU_SAFE_CALL(hipEventRecord(stop_event,_cq)); }
|
||||
|
||||
/// Block until the start event has been reached on device
|
||||
inline void sync_start()
|
||||
{ CU_SAFE_CALL(hipEventSynchronize(start_event)); }
|
||||
|
||||
/// Block until the stop event has been reached on device
|
||||
inline void sync_stop()
|
||||
{ CU_SAFE_CALL(hipEventSynchronize(stop_event)); }
|
||||
|
||||
/// Set the time elapsed to zero (not the total_time)
|
||||
inline void zero() {
|
||||
CU_SAFE_CALL(hipEventRecord(start_event,_cq));
|
||||
CU_SAFE_CALL(hipEventRecord(stop_event,_cq));
|
||||
}
|
||||
|
||||
/// Set the total time to zero
|
||||
inline void zero_total() { _total_time=0.0; }
|
||||
|
||||
/// Add time from previous start and stop to total
|
||||
/** Forces synchronization **/
|
||||
inline double add_to_total()
|
||||
{ double t=time(); _total_time+=t; return t/1000.0; }
|
||||
|
||||
/// Add a user specified time to the total (ms)
|
||||
inline void add_time_to_total(const double t) { _total_time+=t; }
|
||||
|
||||
/// Return the time (ms) of last start to stop - Forces synchronization
|
||||
inline double time() {
|
||||
float timer;
|
||||
CU_SAFE_CALL(hipEventSynchronize(stop_event));
|
||||
CU_SAFE_CALL( hipEventElapsedTime(&timer,start_event,stop_event) );
|
||||
return timer;
|
||||
}
|
||||
|
||||
/// Return the time (s) of last start to stop - Forces synchronization
|
||||
inline double seconds() { return time()/1000.0; }
|
||||
|
||||
/// Return the total time in ms
|
||||
inline double total_time() { return _total_time; }
|
||||
|
||||
/// Return the total time in seconds
|
||||
inline double total_seconds() { return _total_time/1000.0; }
|
||||
|
||||
private:
|
||||
hipEvent_t start_event, stop_event;
|
||||
hipStream_t _cq;
|
||||
double _total_time;
|
||||
bool _initialized;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
@ -36,6 +36,11 @@ using namespace ucl_cudadr;
|
||||
using namespace ucl_cudart;
|
||||
#endif
|
||||
|
||||
#ifdef UCL_HIP
|
||||
#include "hip_device.h"
|
||||
using namespace ucl_hip;
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
UCL_Device cop;
|
||||
std::cout << "Found " << cop.num_platforms() << " platform(s).\n";
|
||||
|
||||
@ -179,13 +179,15 @@ double AnswerT::energy_virial(double *eatom, double **vatom,
|
||||
if (_eflag) {
|
||||
for (int i=0; i<_inum; i++)
|
||||
evdwl+=engv[i];
|
||||
if (_ef_atom)
|
||||
if (_ilist==NULL)
|
||||
if (_ef_atom) {
|
||||
if (_ilist==NULL) {
|
||||
for (int i=0; i<_inum; i++)
|
||||
eatom[i]+=engv[i];
|
||||
else
|
||||
} else {
|
||||
for (int i=0; i<_inum; i++)
|
||||
eatom[_ilist[i]]+=engv[i];
|
||||
}
|
||||
}
|
||||
vstart=_inum;
|
||||
}
|
||||
if (_vflag) {
|
||||
@ -193,7 +195,7 @@ double AnswerT::energy_virial(double *eatom, double **vatom,
|
||||
for (int j=0; j<6; j++) {
|
||||
for (int i=vstart; i<iend; i++)
|
||||
virial[j]+=engv[i];
|
||||
if (_vf_atom)
|
||||
if (_vf_atom){
|
||||
if (_ilist==NULL) {
|
||||
int ii=0;
|
||||
for (int i=vstart; i<iend; i++)
|
||||
@ -203,6 +205,7 @@ double AnswerT::energy_virial(double *eatom, double **vatom,
|
||||
for (int i=vstart; i<iend; i++)
|
||||
vatom[_ilist[ii++]][j]+=engv[i];
|
||||
}
|
||||
}
|
||||
vstart+=_inum;
|
||||
iend+=_inum;
|
||||
}
|
||||
@ -228,7 +231,7 @@ double AnswerT::energy_virial(double *eatom, double **vatom,
|
||||
evdwl+=engv[i];
|
||||
for (int i=_inum; i<iend; i++)
|
||||
ecoul+=engv[i];
|
||||
if (_ef_atom)
|
||||
if (_ef_atom) {
|
||||
if (_ilist==NULL) {
|
||||
for (int i=0; i<_inum; i++)
|
||||
eatom[i]+=engv[i];
|
||||
@ -240,6 +243,7 @@ double AnswerT::energy_virial(double *eatom, double **vatom,
|
||||
for (int i=_inum, ii=0; i<iend; i++)
|
||||
eatom[_ilist[ii++]]+=engv[i];
|
||||
}
|
||||
}
|
||||
vstart=iend;
|
||||
iend+=_inum;
|
||||
}
|
||||
@ -247,7 +251,7 @@ double AnswerT::energy_virial(double *eatom, double **vatom,
|
||||
for (int j=0; j<6; j++) {
|
||||
for (int i=vstart; i<iend; i++)
|
||||
virial[j]+=engv[i];
|
||||
if (_vf_atom)
|
||||
if (_vf_atom) {
|
||||
if (_ilist==NULL) {
|
||||
for (int i=vstart, ii=0; i<iend; i++)
|
||||
vatom[ii++][j]+=engv[i];
|
||||
@ -255,6 +259,7 @@ double AnswerT::energy_virial(double *eatom, double **vatom,
|
||||
for (int i=vstart, ii=0; i<iend; i++)
|
||||
vatom[_ilist[ii++]][j]+=engv[i];
|
||||
}
|
||||
}
|
||||
vstart+=_inum;
|
||||
iend+=_inum;
|
||||
}
|
||||
|
||||
@ -27,6 +27,10 @@ using namespace ucl_opencl;
|
||||
#include "geryon/nvc_timer.h"
|
||||
#include "geryon/nvc_mat.h"
|
||||
using namespace ucl_cudart;
|
||||
#elif defined(USE_HIP)
|
||||
#include "geryon/hip_timer.h"
|
||||
#include "geryon/hip_mat.h"
|
||||
using namespace ucl_hip;
|
||||
#else
|
||||
#include "geryon/nvd_timer.h"
|
||||
#include "geryon/nvd_mat.h"
|
||||
|
||||
@ -15,6 +15,11 @@
|
||||
|
||||
#include "lal_atom.h"
|
||||
|
||||
#ifdef USE_HIP_DEVICE_SORT
|
||||
#include <hip/hip_runtime.h>
|
||||
#include <hipcub/hipcub.hpp>
|
||||
#endif
|
||||
|
||||
namespace LAMMPS_AL {
|
||||
#define AtomT Atom<numtyp,acctyp>
|
||||
|
||||
@ -70,6 +75,26 @@ bool AtomT::alloc(const int nall) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_HIP_DEVICE_SORT
|
||||
if (_gpu_nbor==1) {
|
||||
size_t temp_storage_bytes = 0;
|
||||
if(hipSuccess != hipcub::DeviceRadixSort::SortPairs(nullptr, temp_storage_bytes, sort_out_keys, sort_out_keys, sort_out_values, sort_out_values, _max_atoms))
|
||||
return false;
|
||||
if(sort_out_size < _max_atoms){
|
||||
if (sort_out_keys ) hipFree(sort_out_keys);
|
||||
if (sort_out_values) hipFree(sort_out_values);
|
||||
hipMalloc(&sort_out_keys , _max_atoms * sizeof(unsigned));
|
||||
hipMalloc(&sort_out_values, _max_atoms * sizeof(int ));
|
||||
sort_out_size = _max_atoms;
|
||||
}
|
||||
if(temp_storage_bytes > sort_temp_storage_size){
|
||||
if(sort_temp_storage) hipFree(sort_temp_storage);
|
||||
hipMalloc(&sort_temp_storage, temp_storage_bytes);
|
||||
sort_temp_storage_size = temp_storage_bytes;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// --------------------------- Device allocations
|
||||
int gpu_bytes=0;
|
||||
success=success && (x.alloc(_max_atoms*4,*dev,UCL_WRITE_ONLY,
|
||||
@ -184,6 +209,27 @@ bool AtomT::add_fields(const bool charge, const bool rot,
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_HIP_DEVICE_SORT
|
||||
if (_gpu_nbor==1) {
|
||||
size_t temp_storage_bytes = 0;
|
||||
if(hipSuccess != hipcub::DeviceRadixSort::SortPairs(nullptr, temp_storage_bytes, sort_out_keys, sort_out_keys, sort_out_values, sort_out_values, _max_atoms))
|
||||
return false;
|
||||
if(sort_out_size < _max_atoms){
|
||||
if (sort_out_keys ) hipFree(sort_out_keys);
|
||||
if (sort_out_values) hipFree(sort_out_values);
|
||||
hipMalloc(&sort_out_keys , _max_atoms * sizeof(unsigned));
|
||||
hipMalloc(&sort_out_values, _max_atoms * sizeof(int ));
|
||||
sort_out_size = _max_atoms;
|
||||
}
|
||||
if(temp_storage_bytes > sort_temp_storage_size){
|
||||
if(sort_temp_storage) hipFree(sort_temp_storage);
|
||||
hipMalloc(&sort_temp_storage, temp_storage_bytes);
|
||||
sort_temp_storage_size = temp_storage_bytes;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
success=success && (dev_particle_id.alloc(_max_atoms,*dev,
|
||||
UCL_READ_ONLY)==UCL_SUCCESS);
|
||||
gpu_bytes+=dev_particle_id.row_bytes();
|
||||
@ -275,6 +321,19 @@ void AtomT::clear_resize() {
|
||||
if (_gpu_nbor==1) cudppDestroyPlan(sort_plan);
|
||||
#endif
|
||||
|
||||
#ifdef USE_HIP_DEVICE_SORT
|
||||
if (_gpu_nbor==1) {
|
||||
if(sort_out_keys) hipFree(sort_out_keys);
|
||||
if(sort_out_values) hipFree(sort_out_values);
|
||||
if(sort_temp_storage) hipFree(sort_temp_storage);
|
||||
sort_out_keys = nullptr;
|
||||
sort_out_values = nullptr;
|
||||
sort_temp_storage = nullptr;
|
||||
sort_temp_storage_size = 0;
|
||||
sort_out_size = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_gpu_nbor==2) {
|
||||
host_particle_id.clear();
|
||||
host_cell_id.clear();
|
||||
@ -326,6 +385,22 @@ void AtomT::sort_neighbor(const int num_atoms) {
|
||||
UCL_GERYON_EXIT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_HIP_DEVICE_SORT
|
||||
if(sort_out_size < num_atoms){
|
||||
printf("AtomT::sort_neighbor: invalid temp buffer size\n");
|
||||
UCL_GERYON_EXIT;
|
||||
}
|
||||
if(hipSuccess != hipcub::DeviceRadixSort::SortPairs(sort_temp_storage, sort_temp_storage_size, (unsigned *)dev_cell_id.begin(), sort_out_keys, (int *)dev_particle_id.begin(), sort_out_values, num_atoms)){
|
||||
printf("AtomT::sort_neighbor: DeviceRadixSort error\n");
|
||||
UCL_GERYON_EXIT;
|
||||
}
|
||||
if(hipSuccess != hipMemcpy((unsigned *)dev_cell_id.begin(), sort_out_keys , num_atoms*sizeof(unsigned), hipMemcpyDeviceToDevice) ||
|
||||
hipSuccess != hipMemcpy((int *) dev_particle_id.begin(), sort_out_values, num_atoms*sizeof(int ), hipMemcpyDeviceToDevice)){
|
||||
printf("AtomT::sort_neighbor: copy output error\n");
|
||||
UCL_GERYON_EXIT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef GPU_CAST
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
// email : brownw@ornl.gov
|
||||
// ***************************************************************************/
|
||||
|
||||
#ifdef NV_KERNEL
|
||||
#if defined(NV_KERNEL) || defined(USE_HIP)
|
||||
#include "lal_preprocessor.h"
|
||||
#endif
|
||||
|
||||
|
||||
@ -29,6 +29,11 @@ using namespace ucl_opencl;
|
||||
#include "geryon/nvc_mat.h"
|
||||
#include "geryon/nvc_kernel.h"
|
||||
using namespace ucl_cudart;
|
||||
#elif defined(USE_HIP)
|
||||
#include "geryon/hip_timer.h"
|
||||
#include "geryon/hip_mat.h"
|
||||
#include "geryon/hip_kernel.h"
|
||||
using namespace ucl_hip;
|
||||
#else
|
||||
#include "geryon/nvd_timer.h"
|
||||
#include "geryon/nvd_mat.h"
|
||||
@ -477,6 +482,14 @@ class Atom {
|
||||
CUDPPConfiguration sort_config;
|
||||
CUDPPHandle sort_plan;
|
||||
#endif
|
||||
|
||||
#ifdef USE_HIP_DEVICE_SORT
|
||||
unsigned* sort_out_keys = nullptr;
|
||||
int* sort_out_values = nullptr;
|
||||
void* sort_temp_storage = nullptr;
|
||||
size_t sort_temp_storage_size = 0;
|
||||
size_t sort_out_size = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
// email : brownw@ornl.gov
|
||||
// ***************************************************************************/
|
||||
|
||||
#ifdef NV_KERNEL
|
||||
#if defined(NV_KERNEL) || defined(USE_HIP)
|
||||
#include "lal_preprocessor.h"
|
||||
#endif
|
||||
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
#include "geryon/ocl_texture.h"
|
||||
#elif defined(USE_CUDART)
|
||||
#include "geryon/nvc_texture.h"
|
||||
#elif defined(USE_HIP)
|
||||
#include "geryon/hip_texture.h"
|
||||
#else
|
||||
#include "geryon/nvd_texture.h"
|
||||
#endif
|
||||
|
||||
@ -25,6 +25,8 @@
|
||||
#include "geryon/ocl_texture.h"
|
||||
#elif defined(USE_CUDART)
|
||||
#include "geryon/nvc_texture.h"
|
||||
#elif defined(USE_HIP)
|
||||
#include "geryon/hip_texture.h"
|
||||
#else
|
||||
#include "geryon/nvd_texture.h"
|
||||
#endif
|
||||
|
||||
@ -23,6 +23,8 @@
|
||||
|
||||
#ifdef USE_OPENCL
|
||||
#include "geryon/ocl_texture.h"
|
||||
#elif defined(USE_HIP)
|
||||
#include "geryon/hip_texture.h"
|
||||
#else
|
||||
#include "geryon/nvd_texture.h"
|
||||
#endif
|
||||
|
||||
@ -23,6 +23,8 @@
|
||||
|
||||
#ifdef USE_OPENCL
|
||||
#include "geryon/ocl_texture.h"
|
||||
#elif defined(USE_HIP)
|
||||
#include "geryon/hip_texture.h"
|
||||
#else
|
||||
#include "geryon/nvd_texture.h"
|
||||
#endif
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
#include "geryon/ocl_texture.h"
|
||||
#elif defined(USE_CUDART)
|
||||
#include "geryon/nvc_texture.h"
|
||||
#elif defined(USE_HIP)
|
||||
#include "geryon/hip_texture.h"
|
||||
#else
|
||||
#include "geryon/nvd_texture.h"
|
||||
#endif
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
#include "geryon/ocl_texture.h"
|
||||
#elif defined(USE_CUDART)
|
||||
#include "geryon/nvc_texture.h"
|
||||
#elif defined(USE_HIP)
|
||||
#include "geryon/hip_texture.h"
|
||||
#else
|
||||
#include "geryon/nvd_texture.h"
|
||||
#endif
|
||||
|
||||
@ -13,12 +13,12 @@
|
||||
// email : nguyentd@ornl.gov
|
||||
// ***************************************************************************/
|
||||
|
||||
#ifdef NV_KERNEL
|
||||
#if defined(NV_KERNEL) || defined(USE_HIP)
|
||||
#include "lal_aux_fun1.h"
|
||||
#ifndef _DOUBLE_DOUBLE
|
||||
texture<float4> pos_tex;
|
||||
_texture( pos_tex,float4);
|
||||
#else
|
||||
texture<int4,1> pos_tex;
|
||||
_texture_2d( pos_tex,int4);
|
||||
#endif
|
||||
#else
|
||||
#define pos_tex x_
|
||||
|
||||
@ -13,12 +13,12 @@
|
||||
// email : nguyentd@ornl.gov
|
||||
// ***************************************************************************/
|
||||
|
||||
#ifdef NV_KERNEL
|
||||
#if defined(NV_KERNEL) || defined(USE_HIP)
|
||||
#include "lal_aux_fun1.h"
|
||||
#ifndef _DOUBLE_DOUBLE
|
||||
texture<float4> pos_tex;
|
||||
_texture( pos_tex,float4);
|
||||
#else
|
||||
texture<int4,1> pos_tex;
|
||||
_texture_2d( pos_tex,int4);
|
||||
#endif
|
||||
#else
|
||||
#define pos_tex x_
|
||||
|
||||
@ -13,15 +13,15 @@
|
||||
// email : nguyentd@ornl.gov
|
||||
// ***************************************************************************/
|
||||
|
||||
#ifdef NV_KERNEL
|
||||
#if defined(NV_KERNEL) || defined(USE_HIP)
|
||||
|
||||
#include "lal_aux_fun1.h"
|
||||
#ifndef _DOUBLE_DOUBLE
|
||||
texture<float4> pos_tex;
|
||||
texture<float> q_tex;
|
||||
_texture( pos_tex,float4);
|
||||
_texture( q_tex,float);
|
||||
#else
|
||||
texture<int4,1> pos_tex;
|
||||
texture<int2> q_tex;
|
||||
_texture_2d( pos_tex,int4);
|
||||
_texture( q_tex,int2);
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
@ -13,15 +13,16 @@
|
||||
// email : ndactrung@gmail.com
|
||||
// ***************************************************************************/
|
||||
|
||||
#ifdef NV_KERNEL
|
||||
#if defined(NV_KERNEL) || defined(USE_HIP)
|
||||
|
||||
#include "lal_aux_fun1.h"
|
||||
|
||||
#ifndef _DOUBLE_DOUBLE
|
||||
texture<float4> pos_tex;
|
||||
texture<float> q_tex;
|
||||
_texture( pos_tex,float4);
|
||||
_texture( q_tex,float);
|
||||
#else
|
||||
texture<int4,1> pos_tex;
|
||||
texture<int2> q_tex;
|
||||
_texture_2d( pos_tex,int4);
|
||||
_texture( q_tex,int2);
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
@ -13,15 +13,15 @@
|
||||
// email : nguyentd@ornl.gov
|
||||
// ***************************************************************************/
|
||||
|
||||
#ifdef NV_KERNEL
|
||||
#if defined(NV_KERNEL) || defined(USE_HIP)
|
||||
|
||||
#include "lal_aux_fun1.h"
|
||||
#ifndef _DOUBLE_DOUBLE
|
||||
texture<float4> pos_tex;
|
||||
texture<float> q_tex;
|
||||
_texture( pos_tex,float4);
|
||||
_texture( q_tex,float);
|
||||
#else
|
||||
texture<int4,1> pos_tex;
|
||||
texture<int2> q_tex;
|
||||
_texture_2d( pos_tex,int4);
|
||||
_texture( q_tex,int2);
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
@ -13,15 +13,15 @@
|
||||
// email : ndactrung@gmail.com
|
||||
// ***************************************************************************/
|
||||
|
||||
#ifdef NV_KERNEL
|
||||
#if defined(NV_KERNEL) || defined(USE_HIP)
|
||||
|
||||
#include "lal_aux_fun1.h"
|
||||
#ifndef _DOUBLE_DOUBLE
|
||||
texture<float4> pos_tex;
|
||||
texture<float> q_tex;
|
||||
_texture( pos_tex,float4);
|
||||
_texture( q_tex,float);
|
||||
#else
|
||||
texture<int4,1> pos_tex;
|
||||
texture<int2> q_tex;
|
||||
_texture_2d( pos_tex,int4);
|
||||
_texture( q_tex,int2);
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user