Skip to content

Commit

Permalink
Merge pull request lammps#2023 from akohlmey/collected-small-changes
Browse files Browse the repository at this point in the history
Collected small changes and bugfixes
  • Loading branch information
akohlmey authored Apr 28, 2020
2 parents 7863dfa + ad47b64 commit 2e07345
Show file tree
Hide file tree
Showing 20 changed files with 179 additions and 56 deletions.
19 changes: 9 additions & 10 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,20 @@ if(PKG_USER-ADIOS)
target_link_libraries(lammps PRIVATE adios2::adios2)
endif()

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
if(NOT CMAKE_CROSSCOMPILING)
set(MPI_CXX_SKIP_MPICXX TRUE)
find_package(MPI QUIET)
option(BUILD_MPI "Build MPI version" ${MPI_FOUND})
else()
option(BUILD_MPI "Build MPI version" OFF)
endif()

if(BUILD_MPI)
# We use a non-standard procedure to compile with MPI on windows
if (CMAKE_SYSTEM_NAME STREQUAL Windows)
# We use a non-standard procedure to cross-compile with MPI on Windows
if((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING)
include(MPI4WIN)
target_link_libraries(lammps PUBLIC MPI::MPI_CXX)
else()
set(MPI_CXX_SKIP_MPICXX ON)
find_package(MPI REQUIRED)
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)
Expand Down Expand Up @@ -332,8 +329,9 @@ set(CMAKE_TUNE_FLAGS "${CMAKE_TUNE_DEFAULT}" CACHE STRING "Compiler specific opt
separate_arguments(CMAKE_TUNE_FLAGS)
include(CheckCXXCompilerFlag)
foreach(_FLAG ${CMAKE_TUNE_FLAGS})
check_cxx_compiler_flag("${_FLAG}" COMPILER_SUPPORTS${_FLAG})
if(COMPILER_SUPPORTS${_FLAG})
string(REGEX REPLACE "[=\"]" "" _FLAGX ${_FLAG})
check_cxx_compiler_flag("${_FLAG}" COMPILER_SUPPORTS${_FLAGX})
if(COMPILER_SUPPORTS${_FLAGX})
target_compile_options(lammps PRIVATE ${_FLAG})
else()
message(WARNING "${_FLAG} found in CMAKE_TUNE_FLAGS, but not supported by the compiler, skipping")
Expand Down Expand Up @@ -705,6 +703,7 @@ else()
endif()
if(BUILD_MPI)
message(STATUS "<<< MPI flags >>>
-- MPI_defines: ${MPI_CXX_COMPILE_DEFINITIONS}
-- MPI includes: ${MPI_CXX_INCLUDE_PATH}
-- MPI libraries: ${MPI_CXX_LIBRARIES};${MPI_Fortran_LIBRARIES}")
endif()
Expand Down
5 changes: 5 additions & 0 deletions cmake/Modules/MPI4WIN.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ set_target_properties(MPI::MPI_CXX PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/include"
INTERFACE_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX")
add_dependencies(MPI::MPI_CXX mpi4win_build)

# set variables for status reporting at the end of CMake run
set(MPI_CXX_INCLUDE_PATH "${SOURCE_DIR}/include")
set(MPI_CXX_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX")
set(MPI_CXX_LIBRARIES "${SOURCE_DIR}/lib/libmpi.a")
15 changes: 13 additions & 2 deletions cmake/Modules/Packages/GPU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,20 @@ elseif(GPU_API STREQUAL "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 ${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})
elseif(HIP_PLATFORM STREQUAL "hcc")
target_compile_definitions(gpu PRIVATE -D__HIP_PLATFORM_HCC__)
target_include_directories(gpu PRIVATE ${HIP_ROOT_DIR}/../include)

target_compile_definitions(hip_get_devices PRIVATE -D__HIP_PLATFORM_HCC__)
target_include_directories(hip_get_devices PRIVATE ${HIP_ROOT_DIR}/../include)
endif()

target_link_libraries(lammps PRIVATE gpu)
Expand All @@ -353,7 +359,12 @@ RegisterStylesExt(${GPU_SOURCES_DIR} gpu GPU_SOURCES)

get_property(GPU_SOURCES GLOBAL PROPERTY GPU_SOURCES)

target_link_libraries(gpu PRIVATE MPI::MPI_CXX)
if(NOT BUILD_MPI)
# mpistubs is aliased to MPI::MPI_CXX, but older versions of cmake won't work forward the include path
target_link_libraries(gpu PRIVATE mpi_stubs)
else()
target_link_libraries(gpu PRIVATE MPI::MPI_CXX)
endif()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS gpu EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
Expand Down
10 changes: 9 additions & 1 deletion cmake/Modules/Packages/LATTE.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
enable_language(Fortran)

# using lammps in a super-build setting
if(TARGET LATTE::latte)
target_link_libraries(lammps PRIVATE LATTE::latte)
return()
endif()

find_package(LATTE)
if(LATTE_FOUND)
set(DOWNLOAD_LATTE_DEFAULT OFF)
Expand Down Expand Up @@ -35,5 +42,6 @@ else()
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)
# latte needs lapack
target_link_libraries(lammps PRIVATE LATTE::latte ${LAPACK_LIBRARIES})
endif()
2 changes: 1 addition & 1 deletion cmake/presets/clang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "" FORCE)
set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -g -O2 -DNDEBG" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
set(MPI_CXX "clang++" CACHE STRING "" FORCE)
set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE)
unset(HAVE_OMP_H_INCLUDE CACHE)
Expand Down
12 changes: 12 additions & 0 deletions cmake/presets/hip.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# preset that will enable hipcc plus gcc with support for MPI and OpenMP (on Linux boxes)

set(CMAKE_CXX_COMPILER "hipcc" CACHE STRING "" FORCE)
set(CMAKE_C_COMPILER "gcc" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -g -O2 -DNDEBUG" CACHE STRING "" FORCE)
unset(HAVE_OMP_H_INCLUDE CACHE)

set(OpenMP_CXX "hipcc" CACHE STRING "" FORCE)
set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "" FORCE)
set(OpenMP_CXX_LIB_NAMES "omp" CACHE STRING "" FORCE)
set(OpenMP_omp_LIBRARY "libomp.so" CACHE PATH "" FORCE)

2 changes: 2 additions & 0 deletions lib/message/cslib/src/STUBS_ZMQ/zmq.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef ZMQ_DUMMY_H
#define ZMQ_DUMMY_H

#include <cstddef>

namespace CSLIB_NS {

#define ZMQ_REQ 0
Expand Down
8 changes: 4 additions & 4 deletions src/KOKKOS/compute_orientorder_atom_kokkos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void ComputeOrientOrderAtomKokkos<DeviceType>::compute_peratom()
d_distsq = t_sna_2d_lr("orientorder/atom:distsq",chunk_size,maxneigh);
d_nearest = t_sna_2i_lr("orientorder/atom:nearest",chunk_size,maxneigh);
d_rlist = t_sna_3d_lr("orientorder/atom:rlist",chunk_size,maxneigh,3);

d_distsq_um = d_distsq;
d_rlist_um = d_rlist;
d_nearest_um = d_nearest;
Expand Down Expand Up @@ -194,11 +194,11 @@ void ComputeOrientOrderAtomKokkos<DeviceType>::compute_peratom()
typename Kokkos::TeamPolicy<DeviceType, TagComputeOrientOrderAtomNeigh> policy_neigh(chunk_size,team_size,vector_length);
Kokkos::parallel_for("ComputeOrientOrderAtomNeigh",policy_neigh,*this);
}

//Select3
typename Kokkos::RangePolicy<DeviceType, TagComputeOrientOrderAtomSelect3> policy_select3(0,chunk_size);
Kokkos::parallel_for("ComputeOrientOrderAtomSelect3",policy_select3,*this);

//BOOP1
{
int vector_length = vector_length_default;
Expand All @@ -207,7 +207,7 @@ void ComputeOrientOrderAtomKokkos<DeviceType>::compute_peratom()
typename Kokkos::TeamPolicy<DeviceType, TagComputeOrientOrderAtomBOOP1> policy_boop1(((chunk_size+team_size-1)/team_size)*maxneigh,team_size,vector_length);
Kokkos::parallel_for("ComputeOrientOrderAtomBOOP1",policy_boop1,*this);
}

//BOOP2
typename Kokkos::RangePolicy<DeviceType, TagComputeOrientOrderAtomBOOP2> policy_boop2(0,chunk_size);
Kokkos::parallel_for("ComputeOrientOrderAtomBOOP2",policy_boop2,*this);
Expand Down
Empty file removed src/MAKE/MINE/...
Empty file.
1 change: 1 addition & 0 deletions src/MAKE/MINE/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Makefile.*
28 changes: 16 additions & 12 deletions src/MAKE/OPTIONS/Makefile.hip
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ SHLIBFLAGS = -shared
# if you change any -D setting, do full re-compile after "make clean"

# LAMMPS ifdef settings
# see possible settings in Section 2.2 (step 4) of manual
# see possible settings in Section 3.5 of the manual

LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64

# MPI library
# see discussion in Section 2.2 (step 5) of manual
# see discussion in Section 3.4 of the manual
# MPI wrapper compiler/linker can provide this info
# can point to dummy MPI library in src/STUBS as in Makefile.serial
# use -D MPICH and OMPI settings in INC to avoid C++ lib conflicts
Expand All @@ -45,7 +45,7 @@ MPI_PATH =
MPI_LIB =

# FFT library
# see discussion in Section 2.2 (step 6) of manual
# see discussion in Section 3.5.2 of manual
# can be left blank to use provided KISS FFT library
# INC = -DFFT setting, e.g. -DFFT_FFTW, FFT compiler settings
# PATH = path for FFT library
Expand All @@ -56,7 +56,7 @@ FFT_PATH =
FFT_LIB =

# JPEG and/or PNG library
# see discussion in Section 2.2 (step 7) of manual
# see discussion in Section 3.5.4 of manual
# only needed if -DLAMMPS_JPEG or -DLAMMPS_PNG listed with LMP_INC
# INC = path(s) for jpeglib.h and/or png.h
# PATH = path(s) for JPEG library and/or PNG library
Expand Down Expand Up @@ -91,18 +91,22 @@ vpath %.h ..

# Link target

$(EXE): $(OBJ) $(EXTRA_LINK_DEPENDS)
$(LINK) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(EXTRA_LIB) $(LIB) -o $(EXE)
$(SIZE) $(EXE)
$(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS)
$(LINK) $(LINKFLAGS) main.o $(EXTRA_PATH) $(LMPLINK) $(EXTRA_LIB) $(LIB) -o $@
$(SIZE) $@

# Library targets

lib: $(OBJ) $(EXTRA_LINK_DEPENDS)
$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
$(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ)
@rm -f $(ARLIB)
@ln -s ../$(ARLIB) $(ARLIB)

shlib: $(OBJ) $(EXTRA_LINK_DEPENDS)
$(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o $(EXE) \
$(OBJ) $(EXTRA_LIB) $(LIB)
$(SHLIB): $(OBJ) $(EXTRA_LINK_DEPENDS)
$(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o ../$(SHLIB) \
$(OBJ) $(EXTRA_LIB) $(LIB)
@rm -f $(SHLIB)
@ln -s ../$(SHLIB) $(SHLIB)

# Compilation rules

Expand Down
5 changes: 3 additions & 2 deletions src/USER-MISC/pair_drip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "neigh_request.h"
#include "memory.h"
#include "error.h"
#include "utils.h"

using namespace LAMMPS_NS;

Expand Down Expand Up @@ -116,8 +117,8 @@ void PairDRIP::allocate()
void PairDRIP::settings(int narg, char ** /* arg */)
{
if (narg != 0) error->all(FLERR,"Illegal pair_style command");
if (strcmp(force->pair_style,"hybrid/overlay")!=0)
error->all(FLERR,"ERROR: requires hybrid/overlay pair_style");
if (!utils::strmatch(force->pair_style,"^hybrid/overlay"))
error->all(FLERR,"Pair style drip must be used as sub-style with hybrid/overlay");
}

/* ----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/pair_hybrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ void *PairHybrid::extract(const char *str, int &dim)
for (int m = 0; m < nstyles; m++) {
ptr = styles[m]->extract(str,dim);
if (ptr && strcmp(str,"cut_coul") == 0) {
if (cutptr && dim != couldim)
if (couldim != -1 && dim != couldim)
error->all(FLERR,
"Coulomb styles of pair hybrid sub-styles do not match");
double *p_newvalue = (double *) ptr;
Expand Down
2 changes: 1 addition & 1 deletion tools/singularity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ make
| ubuntu16.04.def | Ubuntu 16.04LTS with MPI == OpenMPI, no LaTeX |
| ubuntu18.04.def | Ubuntu 18.04LTS with MPI == OpenMPI |
| ubuntu18.04_amd_rocm.def | Ubuntu 18.04LTS with AMD ROCm toolkit |
| ubuntu18.04_amd_rocm_cuda.def | Ubuntu 18.04LTS with -"- plus Nvidia CUDA 10.2 |
| ubuntu18.04_gpu.def | Ubuntu 18.04LTS with -"- plus Nvidia CUDA 10.2 |
| ubuntu18.04_nvidia.def | Ubuntu 18.04LTS with Nvidia CUDA 10.2 toolkit |
| ubuntu18.04_intel_opencl.def | Ubuntu 18.04LTS with Intel OpenCL runtime |
| ubuntu20.04.def | Ubuntu 20.04LTS with MPI == OpenMPI |
10 changes: 6 additions & 4 deletions tools/singularity/fedora30_mingw.def
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ From: fedora:30

%post
dnf -y update
dnf -y install vim-enhanced git file make cmake patch which file \
dos2unix findutils rsync \
ccache gcc-c++ gdb valgrind eigen3-devel \
dnf -y install vim-enhanced git file make cmake patch which file Lmod \
ninja-build clang libomp-devel libubsan libasan libtsan \
dos2unix findutils rsync python-devel libjpeg-devel libpng-devel \
ccache gcc-c++ gcc-gfortran gdb valgrind eigen3-devel openblas-devel \
openmpi-devel mpich-devel fftw-devel voro++-devel gsl-devel \
mingw-filesystem-base mingw32-nsis mingw-binutils-generic \
mingw32-filesystem mingw32-pkg-config \
mingw64-filesystem mingw64-pkg-config \
Expand Down Expand Up @@ -39,7 +41,7 @@ From: fedora:30
# we need to reset any module variables
# inherited from the host.
unset LOADEDMODULES
source /etc/profile.d/modules.sh
. /etc/profile.d/modules.sh
module purge
module load mpi

Expand Down
2 changes: 2 additions & 0 deletions tools/singularity/fedora32_mingw.def
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ From: fedora:32
%environment
LC_ALL=C
export LC_ALL
# we need to reset any module variables
# inherited from the host.
unset LOADEDMODULES
. /etc/profile.d/modules.sh
module purge
Expand Down
6 changes: 0 additions & 6 deletions tools/singularity/ubuntu18.04_amd_rocm.def
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ From: rocm/dev-ubuntu-18.04
rocm-libs \
rsync \
ssh \
texlive \
texlive-latex-recommended \
texlive-pictures \
texlive-publishers \
texlive-science \
dvipng \
vim-nox \
virtualenv \
voro++-dev \
Expand Down
Loading

0 comments on commit 2e07345

Please sign in to comment.