Merge pull request #2094 from akohlmey/collected-small-changes

Collected small changes and bug fixes for the next patch release
This commit is contained in:
Axel Kohlmeyer
2020-05-20 14:33:34 -04:00
committed by GitHub
36 changed files with 93 additions and 52 deletions

View File

@ -3,6 +3,11 @@
# This file is part of LAMMPS
# Created by Christoph Junghans and Richard Berger
cmake_minimum_required(VERSION 3.10)
# set policy to silence warnings about ignoring <PackageName>_ROOT but use it
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
########################################
project(lammps CXX)
set(SOVERSION 0)
@ -60,11 +65,11 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
endif()
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_TUNE_DEFAULT "-ffast-math -march=native")
set(CMAKE_TUNE_DEFAULT "-march=native")
endif()
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_TUNE_DEFAULT "-ffast-math -march=native")
set(CMAKE_TUNE_DEFAULT "-march=native")
endif()
# we require C++11 without extensions

View File

@ -6,7 +6,6 @@
# TBB_MALLOC_FOUND - True if tbb found.
#
########################################################
# TBB Malloc

View File

@ -1,8 +1,5 @@
enable_language(C)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
cmake_policy(SET CMP0074 NEW)
endif()
find_package(HDF5 REQUIRED)
target_link_libraries(h5md PRIVATE ${HDF5_LIBRARIES})
target_include_directories(h5md PUBLIC ${HDF5_INCLUDE_DIRS})

View File

@ -1,8 +1,7 @@
# 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"
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
cmake_policy(SET CMP0074 NEW)
endif()
# may use NetCDF or PNetCDF with MPI, but must have NetCDF without
if(NOT BUILD_MPI)
find_package(NetCDF REQUIRED)
else()

View File

@ -224,7 +224,7 @@ double BondClass2::single(int type, double rsq, int /*i*/, int /*j*/, double &ff
/* ---------------------------------------------------------------------- */
void *BondClass2::extract( char *str, int &dim )
void *BondClass2::extract(const char *str, int &dim)
{
dim = 1;
if (strcmp(str,"r0")==0) return (void*) r0;

View File

@ -35,7 +35,7 @@ class BondClass2 : public Bond {
virtual void read_restart(FILE *);
void write_data(FILE *);
double single(int, double, int, int, double &);
virtual void *extract(char *, int &);
virtual void *extract(const char *, int &);
protected:
double *r0,*k2,*k3,*k4;

View File

@ -276,7 +276,7 @@ double BondFENE::single(int type, double rsq, int /*i*/, int /*j*/,
/* ---------------------------------------------------------------------- */
void *BondFENE::extract( char *str, int &dim )
void *BondFENE::extract(const char *str, int &dim)
{
dim = 1;
if (strcmp(str,"kappa")==0) return (void*) k;

View File

@ -36,7 +36,7 @@ class BondFENE : public Bond {
void read_restart(FILE *);
void write_data(FILE *);
double single(int, double, int, int, double &);
virtual void *extract(char *, int &);
virtual void *extract(const char *, int &);
protected:
double TWO_1_3;

View File

@ -189,7 +189,7 @@ void BondGromos::write_data(FILE *fp)
/* ---------------------------------------------------------------------- */
double BondGromos::single(int type, double rsq, int /*i*/, int /*j*/,
double &fforce)
double &fforce)
{
double dr = rsq - r0[type]*r0[type];
fforce = -4.0*k[type] * dr;
@ -199,7 +199,7 @@ double BondGromos::single(int type, double rsq, int /*i*/, int /*j*/,
/* ----------------------------------------------------------------------
Return ptr to internal members upon request.
------------------------------------------------------------------------ */
void *BondGromos::extract( char *str, int &dim )
void *BondGromos::extract(const char *str, int &dim)
{
dim = 1;
if (strcmp(str,"kappa")==0) return (void*) k;

View File

@ -35,7 +35,7 @@ class BondGromos : public Bond {
void read_restart(FILE *);
void write_data(FILE *);
double single(int, double, int, int, double &);
virtual void *extract(char *, int &);
virtual void *extract(const char *, int &);
protected:
double *k,*r0;

View File

@ -190,7 +190,7 @@ void BondHarmonic::write_data(FILE *fp)
/* ---------------------------------------------------------------------- */
double BondHarmonic::single(int type, double rsq, int /*i*/, int /*j*/,
double &fforce)
double &fforce)
{
double r = sqrt(rsq);
double dr = r - r0[type];
@ -203,7 +203,7 @@ double BondHarmonic::single(int type, double rsq, int /*i*/, int /*j*/,
/* ----------------------------------------------------------------------
Return ptr to internal members upon request.
------------------------------------------------------------------------ */
void *BondHarmonic::extract( char *str, int &dim )
void *BondHarmonic::extract(const char *str, int &dim)
{
dim = 1;
if (strcmp(str,"kappa")==0) return (void*) k;

View File

@ -35,7 +35,7 @@ class BondHarmonic : public Bond {
virtual void read_restart(FILE *);
void write_data(FILE *);
double single(int, double, int, int, double &);
virtual void *extract(char *, int &);
virtual void *extract(const char *, int &);
protected:
double *k,*r0;

View File

@ -209,7 +209,7 @@ double BondMorse::single(int type, double rsq, int /*i*/, int /*j*/,
/* ---------------------------------------------------------------------- */
void *BondMorse::extract(char *str, int &dim )
void *BondMorse::extract(const char *str, int &dim)
{
dim = 1;
if (strcmp(str,"r0")==0) return (void*) r0;

View File

@ -35,7 +35,7 @@ class BondMorse : public Bond {
void read_restart(FILE *);
void write_data(FILE *);
double single(int, double, int, int, double &);
virtual void *extract(char *, int &);
virtual void *extract(const char *, int &);
protected:
double *d0,*alpha,*r0;

View File

@ -206,7 +206,7 @@ double BondNonlinear::single(int type, double rsq, int /*i*/, int /*j*/,
/* ---------------------------------------------------------------------- */
void *BondNonlinear::extract( char *str, int &dim )
void *BondNonlinear::extract(const char *str, int &dim)
{
dim = 1;
if (strcmp(str,"epsilon")==0) return (void*) epsilon;

View File

@ -35,7 +35,7 @@ class BondNonlinear : public Bond {
void read_restart(FILE *);
void write_data(FILE *);
double single(int, double, int, int, double &);
virtual void *extract(char *, int &);
virtual void *extract(const char *, int &);
protected:
double *epsilon,*r0,*lamda;

View File

@ -711,6 +711,8 @@ void PairEAMIntel::pack_force_const(ForceConst<flt_t> &fc,
if (type2rhor[i][j] >= 0) {
const int joff = ioff + j * fc.rhor_jstride();
for (int k = 0; k < nr + 1; k++) {
if ((type2rhor[j][i] < 0) || (type2rhor[i][j] < 0))
continue;
if (type2rhor[j][i] != type2rhor[i][j])
_onetype = 0;
else if (_onetype < 0)

View File

@ -63,7 +63,8 @@ static int get_tid()
FixOMP::FixOMP(LAMMPS *lmp, int narg, char **arg)
: Fix(lmp, narg, arg),
thr(NULL), last_omp_style(NULL), last_pair_hybrid(NULL),
_nthr(-1), _neighbor(true), _mixed(false), _reduced(true)
_nthr(-1), _neighbor(true), _mixed(false), _reduced(true),
_pair_compute_flag(false), _kspace_compute_flag(false)
{
if (narg < 4) error->all(FLERR,"Illegal package omp command");
@ -207,6 +208,11 @@ void FixOMP::init()
&& (strstr(update->integrate_style,"respa/omp") == NULL))
error->all(FLERR,"Need to use respa/omp for r-RESPA with /omp styles");
if (force->pair && force->pair->compute_flag) _pair_compute_flag = true;
else _pair_compute_flag = false;
if (force->kspace && force->kspace->compute_flag) _kspace_compute_flag = true;
else _kspace_compute_flag = false;
int check_hybrid, kspace_split;
last_pair_hybrid = NULL;
last_omp_style = NULL;
@ -254,7 +260,7 @@ void FixOMP::init()
} \
}
if (kspace_split <= 0) {
if (_pair_compute_flag && (kspace_split <= 0)) {
CheckStyleForOMP(pair);
CheckHybridForOMP(pair,Pair);
if (check_hybrid) {
@ -275,7 +281,7 @@ void FixOMP::init()
CheckHybridForOMP(improper,Improper);
}
if (kspace_split >= 0) {
if (_kspace_compute_flag && (kspace_split >= 0)) {
CheckStyleForOMP(kspace);
}

View File

@ -70,6 +70,8 @@ class FixOMP : public Fix {
bool _neighbor; // en/disable threads for neighbor list construction
bool _mixed; // whether to prefer mixed precision compute kernels
bool _reduced; // whether forces have been reduced for this step
bool _pair_compute_flag; // whether pair_compute is called
bool _kspace_compute_flag; // whether kspace_compute is called
void set_neighbor_omp();
};

View File

@ -39,6 +39,7 @@ PairLJClass2CoulLongOMP::PairLJClass2CoulLongOMP(LAMMPS *lmp) :
{
suffix_flag |= Suffix::OMP;
respa_enable = 0;
cut_respa = NULL;
}
/* ---------------------------------------------------------------------- */
@ -85,8 +86,9 @@ void PairLJClass2CoulLongOMP::compute(int eflag, int vflag)
template <int EVFLAG, int EFLAG, int NEWTON_PAIR>
void PairLJClass2CoulLongOMP::eval(int iifrom, int iito, ThrData * const thr)
{
int i,j,ii,jj,jnum,itype,jtype;
int i,j,ii,jj,jnum,itype,jtype,itable;
double qtmp,xtmp,ytmp,ztmp,delx,dely,delz,evdwl,ecoul,fpair;
double fraction,table;
double r,rsq,rinv,r2inv,r3inv,r6inv,forcecoul,forcelj,factor_coul,factor_lj;
double grij,expm2,prefactor,t,erfc;
int *ilist,*jlist,*numneigh,**firstneigh;
@ -137,14 +139,29 @@ void PairLJClass2CoulLongOMP::eval(int iifrom, int iito, ThrData * const thr)
r2inv = 1.0/rsq;
if (rsq < cut_coulsq) {
r = sqrt(rsq);
grij = g_ewald * r;
expm2 = exp(-grij*grij);
t = 1.0 / (1.0 + EWALD_P*grij);
erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2;
prefactor = qqrd2e * qtmp*q[j]/r;
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2);
if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor;
if (!ncoultablebits || rsq <= tabinnersq) {
r = sqrt(rsq);
grij = g_ewald * r;
expm2 = exp(-grij*grij);
t = 1.0 / (1.0 + EWALD_P*grij);
erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2;
prefactor = qqrd2e * qtmp*q[j]/r;
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2);
if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor;
} else {
union_int_float_t rsq_lookup;
rsq_lookup.f = rsq;
itable = rsq_lookup.i & ncoulmask;
itable >>= ncoulshiftbits;
fraction = (rsq_lookup.f - rtable[itable]) * drtable[itable];
table = ftable[itable] + fraction*dftable[itable];
forcecoul = qtmp*q[j] * table;
if (factor_coul < 1.0) {
table = ctable[itable] + fraction*dctable[itable];
prefactor = qtmp*q[j] * table;
forcecoul -= (1.0-factor_coul)*prefactor;
}
}
} else forcecoul = 0.0;
if (rsq < cut_ljsq[itype][jtype]) {
@ -168,7 +185,12 @@ void PairLJClass2CoulLongOMP::eval(int iifrom, int iito, ThrData * const thr)
if (EFLAG) {
if (rsq < cut_coulsq) {
ecoul = prefactor*erfc;
if (!ncoultablebits || rsq <= tabinnersq)
ecoul = prefactor*erfc;
else {
table = etable[itable] + fraction*detable[itable];
ecoul = qtmp*q[j] * table;
}
if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor;
} else ecoul = 0.0;

View File

@ -2279,7 +2279,7 @@ void AtomVec::write_improper(FILE *fp, int n, tagint **buf, int index)
bigint AtomVec::memory_usage()
{
int datatype,cols,index,maxcols;
int datatype,cols,maxcols;
void *pdata;
bigint bytes = 0;
@ -2296,7 +2296,6 @@ bigint AtomVec::memory_usage()
pdata = mgrow.pdata[i];
datatype = mgrow.datatype[i];
cols = mgrow.cols[i];
index = mgrow.index[i];
const int nthreads = threads[i] ? comm->nthreads : 1;
if (datatype == DOUBLE) {
if (cols == 0) {

View File

@ -52,7 +52,7 @@ class Bond : protected Pointers {
virtual void write_data(FILE *) {}
virtual double single(int, double, int, int, double &) = 0;
virtual double memory_usage();
virtual void *extract(char *, int &) {return NULL;}
virtual void *extract(const char *, int &) {return NULL;}
virtual void reinit();
void write_file(int, char**);

View File

@ -144,8 +144,6 @@ void BondZero::write_data(FILE *fp)
fprintf(fp,"%d %g\n",i,r0[i]);
}
/* ---------------------------------------------------------------------- */
double BondZero::single(int /*type*/, double /*rsq*/, int /*i*/, int /*j*/,
@ -153,3 +151,12 @@ double BondZero::single(int /*type*/, double /*rsq*/, int /*i*/, int /*j*/,
{
return 0.0;
}
/* ---------------------------------------------------------------------- */
void *BondZero::extract(const char *str, int &dim)
{
dim = 1;
if (strcmp(str,"r0")==0) return (void*) r0;
return NULL;
}

View File

@ -38,6 +38,7 @@ class BondZero : public Bond {
void write_data(FILE *);
double single(int, double, int, int, double &);
virtual void *extract(const char *, int &);
protected:
double *r0;

View File

@ -18,6 +18,7 @@
#include "atom_masks.h"
#include "memory.h"
#include "error.h"
#include "suffix.h"
using namespace LAMMPS_NS;
@ -32,6 +33,7 @@ Dihedral::Dihedral(LAMMPS *lmp) : Pointers(lmp)
writedata = 0;
allocated = 0;
suffix_flag = Suffix::NONE;
maxeatom = maxvatom = maxcvatom = 0;
eatom = NULL;

View File

@ -151,7 +151,7 @@ double RanMars::besselexp(double theta, double alpha, double cp)
{
double first,v1,v2;
if (theta < 0.0 || alpha < 0.0 || alpha < 1.0)
if (theta < 0.0 || alpha < 0.0 || alpha > 1.0)
error->all(FLERR,"Invalid Bessel exponential distribution parameters");
v1 = uniform();

View File

@ -46,7 +46,7 @@ EOF
. /etc/profile
module load mpi
# restrict OpenMPI to shared memory comm by default
OMPI_MCA_btl="sm,self"
OMPI_MCA_btl="tcp,self"
# do not warn about unused components as this messes up testing
OMPI_MCA_btl_base_warn_component_unused="0"
export OMPI_MCA_btl OMPI_MCA_btl_base_warn_component_unused

View File

@ -51,7 +51,7 @@ EOF
. /etc/profile
module load mpi
# restrict OpenMPI to shared memory comm by default
OMPI_MCA_btl="sm,self"
OMPI_MCA_btl="tcp,self"
# do not warn about unused components as this messes up testing
OMPI_MCA_btl_base_warn_component_unused="0"
export OMPI_MCA_btl OMPI_MCA_btl_base_warn_component_unused

View File

@ -66,7 +66,7 @@ EOF
. /etc/profile
module load mpi
# restrict OpenMPI to shared memory comm by default
OMPI_MCA_btl="sm,self"
OMPI_MCA_btl="tcp,self"
# do not warn about unused components as this messes up testing
OMPI_MCA_btl_base_warn_component_unused="0"
export OMPI_MCA_btl OMPI_MCA_btl_base_warn_component_unused

View File

@ -29,7 +29,7 @@ EOF
LC_ALL=C
export LC_ALL
# restrict OpenMPI to shared memory comm by default
OMPI_MCA_btl="sm,self"
OMPI_MCA_btl="tcp,self"
# do not warn about unused components as this messes up testing
OMPI_MCA_btl_base_warn_component_unused="0"
export OMPI_MCA_btl OMPI_MCA_btl_base_warn_component_unused

View File

@ -84,7 +84,7 @@ EOF
export LC_ALL
export PATH=/usr/lib/ccache:$PATH
# restrict OpenMPI to shared memory comm by default
OMPI_MCA_btl="sm,self"
OMPI_MCA_btl="tcp,self"
# do not warn about unused components as this messes up testing
OMPI_MCA_btl_base_warn_component_unused="0"
export OMPI_MCA_btl OMPI_MCA_btl_base_warn_component_unused

View File

@ -90,7 +90,7 @@ EOF
LC_ALL=C
export LC_ALL
# restrict OpenMPI to shared memory comm by default
OMPI_MCA_btl="sm,self"
OMPI_MCA_btl="tcp,self"
# do not warn about unused components as this messes up testing
OMPI_MCA_btl_base_warn_component_unused="0"
export OMPI_MCA_btl OMPI_MCA_btl_base_warn_component_unused

View File

@ -117,7 +117,7 @@ EOF
LC_ALL=C
export LC_ALL
# restrict OpenMPI to shared memory comm by default
OMPI_MCA_btl="sm,self"
OMPI_MCA_btl="tcp,self"
# do not warn about unused components as this messes up testing
OMPI_MCA_btl_base_warn_component_unused="0"
export OMPI_MCA_btl OMPI_MCA_btl_base_warn_component_unused

View File

@ -83,7 +83,7 @@ EOF
LC_ALL=C
export LC_ALL
# restrict OpenMPI to shared memory comm by default
OMPI_MCA_btl="sm,self"
OMPI_MCA_btl="tcp,self"
# do not warn about unused components as this messes up testing
OMPI_MCA_btl_base_warn_component_unused="0"
export OMPI_MCA_btl OMPI_MCA_btl_base_warn_component_unused

View File

@ -82,7 +82,7 @@ EOF
LC_ALL=C
export LC_ALL
# restrict OpenMPI to shared memory comm by default
OMPI_MCA_btl="sm,self"
OMPI_MCA_btl="tcp,self"
# do not warn about unused components as this messes up testing
OMPI_MCA_btl_base_warn_component_unused="0"
export OMPI_MCA_btl OMPI_MCA_btl_base_warn_component_unused

View File

@ -80,7 +80,7 @@ EOF
LC_ALL=C
export LC_ALL
# restrict OpenMPI to shared memory comm by default
OMPI_MCA_btl="sm,self"
OMPI_MCA_btl="tcp,self"
# do not warn about unused components as this messes up testing
OMPI_MCA_btl_base_warn_component_unused="0"
export OMPI_MCA_btl OMPI_MCA_btl_base_warn_component_unused