Merge pull request #3116 from akohlmey/build-kokkos-staticlib
Build KOKKOS package updates for Python module and Windows compatibility
This commit is contained in:
1
.github/workflows/compile-msvc.yml
vendored
1
.github/workflows/compile-msvc.yml
vendored
@ -21,6 +21,7 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
cmake -C cmake/presets/windows.cmake \
|
||||
-D PKG_PYTHON=on \
|
||||
-S cmake -B build \
|
||||
-D BUILD_SHARED_LIBS=on \
|
||||
-D LAMMPS_EXCEPTIONS=on \
|
||||
|
||||
@ -359,11 +359,13 @@ if(BUILD_OMP)
|
||||
((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0)))
|
||||
# GCC 9.x and later plus Clang 10.x and later implement strict OpenMP 4.0 semantics for consts.
|
||||
# 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)
|
||||
set(LAMMPS_OMP_COMPAT_LEVEL 4)
|
||||
else()
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_OMP_COMPAT=3)
|
||||
set(LAMMPS_OMP_COMPAT_LEVEL 3)
|
||||
endif()
|
||||
target_compile_definitions(lammps PRIVATE -DLAMMPS_OMP_COMPAT=${LAMMPS_OMP_COMPAT_LEVEL})
|
||||
target_link_libraries(lammps PRIVATE OpenMP::OpenMP_CXX)
|
||||
target_link_libraries(lmp PRIVATE OpenMP::OpenMP_CXX)
|
||||
endif()
|
||||
|
||||
if(PKG_MSCG OR PKG_ATC OR PKG_AWPMD OR PKG_ML-QUIP OR PKG_LATTE)
|
||||
|
||||
@ -11,8 +11,14 @@ if(Kokkos_ENABLE_CUDA)
|
||||
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")
|
||||
if(Kokkos_ENABLE_OPENMP)
|
||||
if(NOT BUILD_OMP)
|
||||
message(FATAL_ERROR "Must enable BUILD_OMP with Kokkos_ENABLE_OPENMP")
|
||||
else()
|
||||
if(LAMMPS_OMP_COMPAT_LEVEL LESS 4)
|
||||
message(FATAL_ERROR "Compiler must support OpenMP 4.0 or later with Kokkos_ENABLE_OPENMP")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
########################################################################
|
||||
|
||||
@ -27,6 +33,8 @@ if(DOWNLOAD_KOKKOS)
|
||||
endforeach()
|
||||
message(STATUS "KOKKOS download requested - we will build our own")
|
||||
list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>")
|
||||
# build KOKKOS downloaded libraries as static libraries but with PIC, if needed
|
||||
list(APPEND KOKKOS_LIB_BUILD_ARGS "-DBUILD_SHARED_LIBS=OFF")
|
||||
if(CMAKE_REQUEST_PIC)
|
||||
list(APPEND KOKKOS_LIB_BUILD_ARGS ${CMAKE_REQUEST_PIC})
|
||||
endif()
|
||||
@ -47,18 +55,22 @@ if(DOWNLOAD_KOKKOS)
|
||||
URL ${KOKKOS_URL}
|
||||
URL_MD5 ${KOKKOS_MD5}
|
||||
CMAKE_ARGS ${KOKKOS_LIB_BUILD_ARGS}
|
||||
BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libkokkoscore.a
|
||||
BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libkokkoscore.a <INSTALL_DIR>/lib/libkokkoscontainers.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
|
||||
add_library(LAMMPS::KOKKOSCORE UNKNOWN IMPORTED)
|
||||
add_library(LAMMPS::KOKKOSCONTAINERS UNKNOWN IMPORTED)
|
||||
set_target_properties(LAMMPS::KOKKOSCORE 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)
|
||||
target_link_libraries(lmp PRIVATE LAMMPS::KOKKOS)
|
||||
add_dependencies(LAMMPS::KOKKOS kokkos_build)
|
||||
set_target_properties(LAMMPS::KOKKOSCONTAINERS PROPERTIES
|
||||
IMPORTED_LOCATION "${INSTALL_DIR}/lib/libkokkoscontainers.a")
|
||||
target_link_libraries(lammps PRIVATE LAMMPS::KOKKOSCORE LAMMPS::KOKKOSCONTAINERS)
|
||||
target_link_libraries(lmp PRIVATE LAMMPS::KOKKOSCORE LAMMPS::KOKKOSCONTAINERS)
|
||||
add_dependencies(LAMMPS::KOKKOSCORE kokkos_build)
|
||||
add_dependencies(LAMMPS::KOKKOSCONTAINERS kokkos_build)
|
||||
elseif(EXTERNAL_KOKKOS)
|
||||
find_package(Kokkos 3.5.00 REQUIRED CONFIG)
|
||||
target_link_libraries(lammps PRIVATE Kokkos::kokkos)
|
||||
@ -66,8 +78,14 @@ elseif(EXTERNAL_KOKKOS)
|
||||
else()
|
||||
set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos)
|
||||
set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos)
|
||||
# build KOKKOS internal libraries as static libraries but with PIC, if needed
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
if(CMAKE_REQUEST_PIC)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR})
|
||||
|
||||
|
||||
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
|
||||
|
||||
@ -46,12 +46,10 @@ if(DOWNLOAD_N2P2)
|
||||
if((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING)
|
||||
get_target_property(N2P2_MPI_INCLUDE MPI::MPI_CXX INTERFACE_INCLUDE_DIRECTORIES)
|
||||
set(N2P2_PROJECT_OPTIONS "-I${N2P2_MPI_INCLUDE}")
|
||||
set(MPI_CXX_COMPILER ${CMAKE_CXX_COMPILER})
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
get_target_property(N2P2_MPI_INCLUDE MPI::MPI_CXX INTERFACE_INCLUDE_DIRECTORIES)
|
||||
set(N2P2_PROJECT_OPTIONS "-I${N2P2_MPI_INCLUDE}")
|
||||
set(MPI_CXX_COMPILER ${CMAKE_CXX_COMPILER})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -64,8 +62,8 @@ if(DOWNLOAD_N2P2)
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" BTYPE)
|
||||
set(N2P2_BUILD_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}} ${N2P2_CXX_STD}")
|
||||
set(N2P2_BUILD_OPTIONS INTERFACES=LAMMPS COMP=${N2P2_COMP} "PROJECT_OPTIONS=${N2P2_PROJECT_OPTIONS}" "PROJECT_DEBUG="
|
||||
"PROJECT_CC=${CMAKE_CXX_COMPILER}" "PROJECT_MPICC=${MPI_CXX_COMPILER}" "PROJECT_CFLAGS=${N2P2_BUILD_FLAGS}"
|
||||
"PROJECT_AR=${N2P2_AR}")
|
||||
"PROJECT_CC=${CMAKE_CXX_COMPILER}" "PROJECT_MPICC=${CMAKE_CXX_COMPILER}" "PROJECT_CFLAGS=${N2P2_BUILD_FLAGS}"
|
||||
"PROJECT_AR=${N2P2_AR}" "APP_CORE=nnp-convert" "APP_TRAIN=nnp-train" "APP=nnp-convert")
|
||||
# echo final flag for debugging
|
||||
message(STATUS "N2P2 BUILD OPTIONS: ${N2P2_BUILD_OPTIONS}")
|
||||
|
||||
|
||||
@ -10,8 +10,10 @@ SPDX-License-Identifier: (BSD-3-Clause)
|
||||
#define DESUL_ATOMICS_GENERIC_HPP_
|
||||
|
||||
#include <type_traits>
|
||||
#if defined(__GNUC__) && (!defined(__clang__))
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
#include "desul/atomics/Common.hpp"
|
||||
#include "desul/atomics/Compare_Exchange.hpp"
|
||||
#include "desul/atomics/Lock_Array.hpp"
|
||||
@ -686,5 +688,7 @@ DESUL_INLINE_FUNCTION bool atomic_compare_exchange_weak(T* const dest,
|
||||
#include <desul/atomics/GCC.hpp>
|
||||
#include <desul/atomics/HIP.hpp>
|
||||
#include <desul/atomics/OpenMP.hpp>
|
||||
#if defined(__GNUC__) && (!defined(__clang__))
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -58,7 +58,7 @@
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@ -600,7 +600,8 @@ void KokkosLMP::my_signal_handler(int sig)
|
||||
{
|
||||
if (sig == SIGSEGV) {
|
||||
#if defined(_WIN32)
|
||||
kill(_getpid(),SIGABRT);
|
||||
// there is no kill() function on Windows
|
||||
exit(1);
|
||||
#else
|
||||
kill(getpid(),SIGABRT);
|
||||
#endif
|
||||
|
||||
@ -17,9 +17,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "pair_exp6_rx_kokkos.h"
|
||||
#include <cmath>
|
||||
|
||||
#include <cstring>
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "force.h"
|
||||
@ -28,12 +26,14 @@
|
||||
#include "memory_kokkos.h"
|
||||
#include "error.h"
|
||||
#include "fix.h"
|
||||
#include <cfloat>
|
||||
#include "atom_masks.h"
|
||||
#include "neigh_request.h"
|
||||
#include "atom_kokkos.h"
|
||||
#include "kokkos.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cfloat>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef _OPENMP
|
||||
#include <omp.h>
|
||||
@ -57,22 +57,6 @@ using namespace MathSpecialKokkos;
|
||||
#define exp6PotentialType (1)
|
||||
#define isExp6PotentialType(_type) ( (_type) == exp6PotentialType )
|
||||
|
||||
namespace /* anonymous */
|
||||
{
|
||||
|
||||
//typedef double TimerType;
|
||||
//TimerType getTimeStamp(void) { return platform::walltime(); }
|
||||
//double getElapsedTime( const TimerType &t0, const TimerType &t1) { return t1-t0; }
|
||||
|
||||
typedef struct timespec TimerType;
|
||||
TimerType getTimeStamp(void) { TimerType tick; clock_gettime( CLOCK_MONOTONIC, &tick); return tick; }
|
||||
double getElapsedTime( const TimerType &t0, const TimerType &t1)
|
||||
{
|
||||
return (t1.tv_sec - t0.tv_sec) + 1e-9*(t1.tv_nsec - t0.tv_nsec);
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
template<class DeviceType>
|
||||
@ -142,8 +126,6 @@ void PairExp6rxKokkos<DeviceType>::init_style()
|
||||
template<class DeviceType>
|
||||
void PairExp6rxKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
|
||||
{
|
||||
//TimerType t_start = getTimeStamp();
|
||||
|
||||
copymode = 1;
|
||||
|
||||
eflag = eflag_in;
|
||||
@ -187,7 +169,6 @@ void PairExp6rxKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
|
||||
// and ghost atoms. Make the parameter data persistent
|
||||
// and exchange like any other atom property later.
|
||||
|
||||
//TimerType t_mix_start = getTimeStamp();
|
||||
{
|
||||
const int np_total = nlocal + atom->nghost;
|
||||
|
||||
@ -260,7 +241,6 @@ void PairExp6rxKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
|
||||
error->all(FLERR,"Computed fraction less than -10*DBL_EPSILON");
|
||||
#endif
|
||||
}
|
||||
//TimerType t_mix_stop = getTimeStamp();
|
||||
|
||||
k_error_flag.template modify<DeviceType>();
|
||||
k_error_flag.template sync<LMPHostType>();
|
||||
@ -377,9 +357,6 @@ void PairExp6rxKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
|
||||
}
|
||||
|
||||
copymode = 0;
|
||||
|
||||
//TimerType t_stop = getTimeStamp();
|
||||
//printf("PairExp6rxKokkos::compute %f %f\n", getElapsedTime(t_start, t_stop), getElapsedTime(t_mix_start, t_mix_stop));
|
||||
}
|
||||
|
||||
template<class DeviceType>
|
||||
|
||||
@ -2711,10 +2711,9 @@ void PPPMKokkos<DeviceType>::compute_rho_coeff()
|
||||
{
|
||||
int j,k,l,m;
|
||||
FFT_SCALAR s;
|
||||
|
||||
//FFT_SCALAR **a;
|
||||
//memory->create2d_offset(a,order,-order,order,"pppm:a");
|
||||
FFT_SCALAR a[order][2*order+1];
|
||||
FFT_SCALAR **a = new FFT_SCALAR *[order];
|
||||
for (int i = 0; i < order; ++i)
|
||||
a[i] = new FFT_SCALAR[2*order+1];
|
||||
|
||||
for (k = 0; k <= 2*order; k++)
|
||||
for (l = 0; l < order; l++)
|
||||
@ -2744,7 +2743,9 @@ void PPPMKokkos<DeviceType>::compute_rho_coeff()
|
||||
h_rho_coeff(l,m-(1-order)/2) = a[l][k+order];
|
||||
m++;
|
||||
}
|
||||
//memory->destroy2d_offset(a,-order);
|
||||
for (int i = 0; i < order; ++i)
|
||||
delete[] a[i];
|
||||
delete[] a;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -261,13 +261,13 @@ protected:
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
// only run this test fixture with kk suffix if KOKKOS package is installed
|
||||
// also need to figure out a way to find which parallelizations are enabled
|
||||
|
||||
if (LAMMPS::is_installed_pkg("KOKKOS")) {
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, StartsWith("Kokkos::OpenMP::"));
|
||||
if (Info::has_accelerator_feature("KOKKOS", "api", "openmp"))
|
||||
EXPECT_THAT(output, StartsWith("Kokkos::OpenMP::"));
|
||||
} else
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
lammps_version: 30 Jul 2021
|
||||
tags: slow, unstable
|
||||
tags: slow, unstable, noWindows
|
||||
date_generated: Mon Aug 23 20:32:05 2021
|
||||
epsilon: 1e-12
|
||||
skip_tests:
|
||||
|
||||
Reference in New Issue
Block a user