Merge remote-tracking branch 'github/develop' into collected-small-fixes

This commit is contained in:
Axel Kohlmeyer
2023-07-21 17:27:06 -04:00
14 changed files with 104 additions and 74 deletions

View File

@ -980,7 +980,7 @@ void PairMEAMKokkos<DeviceType>::update_meam_views()
namespace LAMMPS_NS {
template class PairMEAMKokkos<LMPDeviceType>;
#ifdef KOKKOS_ENABLE_CUDA
#ifdef LMP_KOKKOS_GPU
template class PairMEAMKokkos<LMPHostType>;
#endif
}

View File

@ -26,7 +26,7 @@ PairMEAMMSKokkos<DeviceType>::PairMEAMMSKokkos(LAMMPS *lmp) : PairMEAMKokkos<Dev
namespace LAMMPS_NS {
template class PairMEAMMSKokkos<LMPDeviceType>;
#ifdef KOKKOS_ENABLE_CUDA
#ifdef LMP_KOKKOS_GPU
template class PairMEAMMSKokkos<LMPHostType>;
#endif
}

View File

@ -33,7 +33,7 @@ KSpaceStyle(pppm/kk/host,PPPMKokkos<LMPHostType>);
// clang-format off
// fix up FFT defines for KOKKOS with CUDA
// fix up FFT defines for KOKKOS with CUDA and HIP
#ifdef KOKKOS_ENABLE_CUDA
# if defined(FFT_FFTW)
@ -48,6 +48,19 @@ KSpaceStyle(pppm/kk/host,PPPMKokkos<LMPHostType>);
# if !defined(FFT_CUFFT) && !defined(FFT_KISSFFT)
# define FFT_KISSFFT
# endif
#elif defined(KOKKOS_ENABLE_HIP)
# if defined(FFT_FFTW)
# undef FFT_FFTW
# endif
# if defined(FFT_FFTW3)
# undef FFT_FFTW3
# endif
# if defined(FFT_MKL)
# undef FFT_MKL
# endif
# if !defined(FFT_HIPFFT) && !defined(FFT_KISSFFT)
# define FFT_KISSFFT
# endif
#endif
#include "pppm.h"

View File

@ -297,9 +297,10 @@ int DumpVTK::count()
// cannot invoke before first run, otherwise invoke if necessary
if (ncompute) {
if (update->first_update == 0)
error->all(FLERR,"Dump compute cannot be invoked before first run");
for (i = 0; i < ncompute; i++) {
if (!compute[i]->is_initialized())
error->all(FLERR,"Dump compute ID {} cannot be invoked before initialization by a run",
compute[i]->id);
if (!(compute[i]->invoked_flag & Compute::INVOKED_PERATOM)) {
compute[i]->compute_peratom();
compute[i]->invoked_flag |= Compute::INVOKED_PERATOM;

View File

@ -74,6 +74,7 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) :
dynamic = 0;
dynamic_group_allow = 1;
initialized_flag = 0;
invoked_scalar = invoked_vector = invoked_array = -1;
invoked_peratom = invoked_local = -1;
invoked_flag = INVOKED_NONE;
@ -111,6 +112,15 @@ Compute::~Compute()
/* ---------------------------------------------------------------------- */
void Compute::init_flags()
{
initialized_flag = 1;
invoked_scalar = invoked_vector = invoked_array = -1;
invoked_peratom = invoked_local = -1;
}
/* ---------------------------------------------------------------------- */
void Compute::modify_params(int narg, char **arg)
{
if (narg == 0) error->all(FLERR,"Illegal compute_modify command");

View File

@ -62,7 +62,7 @@ class Compute : protected Pointers {
int size_local_rows; // rows in local vector or array
int size_local_cols; // 0 = vector, N = columns in local array
int pergrid_flag; // 0/1 if compute_pergrid() function exists
int pergrid_flag; // 0/1 if compute_pergrid() function exists
int extscalar; // 0/1 if global scalar is intensive/extensive
int extvector; // 0/1/-1 if global vector is all int/ext/extlist
@ -88,6 +88,7 @@ class Compute : protected Pointers {
int maxtime; // max # of entries time list can hold
bigint *tlist; // list of timesteps the Compute is called on
int initialized_flag; // 1 if compute is initialized, 0 if not
int invoked_flag; // non-zero if invoked or accessed this step, 0 if not
bigint invoked_scalar; // last timestep on which compute_scalar() was invoked
bigint invoked_vector; // ditto for compute_vector()
@ -114,6 +115,7 @@ class Compute : protected Pointers {
void modify_params(int, char **);
virtual void reset_extra_dof();
void init_flags();
virtual void init() = 0;
virtual void init_list(int, class NeighList *) {}
virtual void setup() {}
@ -161,6 +163,8 @@ class Compute : protected Pointers {
int matchstep(bigint);
void clearstep();
bool is_initialized() const { return initialized_flag == 1; }
virtual double memory_usage() { return 0.0; }
virtual void pair_setup_callback(int, int) {}

View File

@ -562,9 +562,10 @@ int DumpCustom::count()
// cannot invoke before first run, otherwise invoke if necessary
if (ncompute) {
if (update->first_update == 0)
error->all(FLERR,"Dump compute cannot be invoked before first run");
for (i = 0; i < ncompute; i++) {
if (!compute[i]->is_initialized())
error->all(FLERR,"Dump compute ID {} cannot be invoked before initialization by a run",
compute[i]->id);
if (!(compute[i]->invoked_flag & Compute::INVOKED_PERATOM)) {
compute[i]->compute_peratom();
compute[i]->invoked_flag |= Compute::INVOKED_PERATOM;

View File

@ -527,9 +527,10 @@ int DumpGrid::count()
// cannot invoke before first run, otherwise invoke if necessary
if (ncompute) {
if (update->first_update == 0)
error->all(FLERR,"Dump compute cannot be invoked before first run");
for (i = 0; i < ncompute; i++) {
if (!compute[i]->is_initialized())
error->all(FLERR,"Dump compute ID {} cannot be invoked before initialization by a run",
compute[i]->id);
if (!(compute[i]->invoked_flag & Compute::INVOKED_PERGRID)) {
compute[i]->compute_pergrid();
compute[i]->invoked_flag |= Compute::INVOKED_PERGRID;

View File

@ -667,8 +667,9 @@ void DumpImage::write()
// cannot invoke before first run, otherwise invoke if necessary
if (grid_compute) {
if (update->first_update == 0)
error->all(FLERR,"Grid compute used in dump image cannot be invoked before first run");
if (!grid_compute->is_initialized())
error->all(FLERR,"Grid compute ID {} used in dump image cannot be invoked "
"before initialization by a run", grid_compute->id);
if (!(grid_compute->invoked_flag & Compute::INVOKED_PERGRID)) {
grid_compute->compute_pergrid();
grid_compute->invoked_flag |= Compute::INVOKED_PERGRID;

View File

@ -328,9 +328,10 @@ int DumpLocal::count()
// cannot invoke before first run, otherwise invoke if necessary
if (ncompute) {
if (update->first_update == 0)
error->all(FLERR,"Dump compute cannot be invoked before first run");
for (i = 0; i < ncompute; i++) {
if (!compute[i]->is_initialized())
error->all(FLERR,"Dump compute ID {} cannot be invoked before initialization by a run",
compute[i]->id);
if (!(compute[i]->invoked_flag & Compute::INVOKED_LOCAL)) {
compute[i]->compute_local();
compute[i]->invoked_flag |= Compute::INVOKED_LOCAL;

View File

@ -191,11 +191,7 @@ void Modify::init()
for (i = 0; i < ncompute; i++) {
compute[i]->init();
compute[i]->invoked_scalar = -1;
compute[i]->invoked_vector = -1;
compute[i]->invoked_array = -1;
compute[i]->invoked_peratom = -1;
compute[i]->invoked_local = -1;
compute[i]->init_flags();
}
addstep_compute_all(update->ntimestep);

View File

@ -61,6 +61,22 @@ void ResetAtomsImage::command(int narg, char **arg)
MPI_Barrier(world);
double time1 = platform::walltime();
// create computes and variables
// must come before lmp->init so the computes are properly initialized
auto frags = modify->add_compute("frags_r_i_f all fragment/atom single yes");
auto chunk = modify->add_compute("chunk_r_i_f all chunk/atom c_frags_r_i_f compress yes");
auto flags = modify->add_compute("flags_r_i_f all property/atom ix iy iz");
input->variable->set("ix_r_i_f atom c_flags_r_i_f[1]");
input->variable->set("iy_r_i_f atom c_flags_r_i_f[2]");
input->variable->set("iz_r_i_f atom c_flags_r_i_f[3]");
auto ifmin = modify->add_compute("ifmin_r_i_f all reduce/chunk chunk_r_i_f min "
"v_ix_r_i_f v_iy_r_i_f v_iz_r_i_f");
auto ifmax = modify->add_compute("ifmax_r_i_f all reduce/chunk chunk_r_i_f max "
"v_ix_r_i_f v_iy_r_i_f v_iz_r_i_f");
auto cdist = modify->add_compute("cdist_r_i_f all chunk/spread/atom chunk_r_i_f "
"c_ifmax_r_i_f[*] c_ifmin_r_i_f[*]");
// initialize system since comm->borders() will be invoked
lmp->init();
@ -77,30 +93,7 @@ void ResetAtomsImage::command(int narg, char **arg)
comm->borders();
if (domain->triclinic) domain->lamda2x(atom->nlocal + atom->nghost);
// create computes and variables
auto frags = modify->add_compute("frags_r_i_f all fragment/atom single yes");
auto chunk = modify->add_compute("chunk_r_i_f all chunk/atom c_frags_r_i_f compress yes");
auto flags = modify->add_compute("flags_r_i_f all property/atom ix iy iz");
input->variable->set("ix_r_i_f atom c_flags_r_i_f[1]");
input->variable->set("iy_r_i_f atom c_flags_r_i_f[2]");
input->variable->set("iz_r_i_f atom c_flags_r_i_f[3]");
auto ifmin = modify->add_compute("ifmin_r_i_f all reduce/chunk chunk_r_i_f min "
"v_ix_r_i_f v_iy_r_i_f v_iz_r_i_f");
auto ifmax = modify->add_compute("ifmax_r_i_f all reduce/chunk chunk_r_i_f max "
"v_ix_r_i_f v_iy_r_i_f v_iz_r_i_f");
auto cdist = modify->add_compute("cdist_r_i_f all chunk/spread/atom chunk_r_i_f "
"c_ifmax_r_i_f[*] c_ifmin_r_i_f[*]");
// trigger computes
// need to ensure update->first_update = 1
// to allow this input script command prior to first run/minimize
// this is b/c internal variables are evaulated which invoke computes
// that will trigger an error unless first_update = 1
// reset update->first_update when done
int first_update_saved = update->first_update;
update->first_update = 1;
frags->compute_peratom();
chunk->compute_peratom();
@ -109,8 +102,6 @@ void ResetAtomsImage::command(int narg, char **arg)
ifmax->compute_array();
cdist->compute_peratom();
update->first_update = first_update_saved;
// reset image flags for atoms in group
const int *const mask = atom->mask;

View File

@ -1134,8 +1134,8 @@ void Thermo::check_temp(const std::string &keyword)
if (!temperature)
error->all(FLERR, "Thermo keyword {} in variable requires thermo to use/init temperature",
keyword);
if (update->first_update == 0)
error->all(FLERR,"Thermo keyword {} cannot be invoked before first run",keyword);
if (!temperature->is_initialized())
error->all(FLERR,"Thermo keyword {} cannot be invoked before initialization by a run",keyword);
if (!(temperature->invoked_flag & Compute::INVOKED_SCALAR)) {
temperature->compute_scalar();
temperature->invoked_flag |= Compute::INVOKED_SCALAR;
@ -1153,8 +1153,8 @@ void Thermo::check_pe(const std::string &keyword)
if (!pe)
error->all(FLERR, "Thermo keyword {} in variable requires thermo to use/init potential energy",
keyword);
if (update->first_update == 0)
error->all(FLERR,"Thermo keyword {} cannot be invoked before first run",keyword);
if (!pe->is_initialized())
error->all(FLERR,"Thermo keyword {} cannot be invoked before initialization by a run",keyword);
if (!(pe->invoked_flag & Compute::INVOKED_SCALAR)) {
pe->compute_scalar();
pe->invoked_flag |= Compute::INVOKED_SCALAR;
@ -1169,8 +1169,8 @@ void Thermo::check_press_scalar(const std::string &keyword)
{
if (!pressure)
error->all(FLERR, "Thermo keyword {} in variable requires thermo to use/init press", keyword);
if (update->first_update == 0)
error->all(FLERR,"Thermo keyword {} cannot be invoked before first run",keyword);
if (!pressure->is_initialized())
error->all(FLERR,"Thermo keyword {} cannot be invoked before initialization by a run",keyword);
if (!(pressure->invoked_flag & Compute::INVOKED_SCALAR)) {
pressure->compute_scalar();
pressure->invoked_flag |= Compute::INVOKED_SCALAR;
@ -1185,8 +1185,8 @@ void Thermo::check_press_vector(const std::string &keyword)
{
if (!pressure)
error->all(FLERR, "Thermo keyword {} in variable requires thermo to use/init press", keyword);
if (update->first_update == 0)
error->all(FLERR,"Thermo keyword {} cannot be invoked before first run",keyword);
if (!pressure->is_initialized())
error->all(FLERR,"Thermo keyword {} cannot be invoked before initialization by a run",keyword);
if (!(pressure->invoked_flag & Compute::INVOKED_VECTOR)) {
pressure->compute_vector();
pressure->invoked_flag |= Compute::INVOKED_VECTOR;

View File

@ -1505,8 +1505,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
if (nbracket == 0 && compute->scalar_flag && lowercase) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!compute->is_initialized())
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
"initialization by a run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) {
compute->compute_scalar();
compute->invoked_flag |= Compute::INVOKED_SCALAR;
@ -1527,8 +1528,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
if (index1 > compute->size_vector &&
compute->size_vector_variable == 0)
print_var_error(FLERR,"Variable formula compute vector is accessed out-of-range",ivar,0);
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!compute->is_initialized())
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
"initialization by a run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) {
compute->compute_vector();
compute->invoked_flag |= Compute::INVOKED_VECTOR;
@ -1553,8 +1555,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0);
if (index2 > compute->size_array_cols)
print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0);
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!compute->is_initialized())
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
"initialization by a run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) {
compute->compute_array();
compute->invoked_flag |= Compute::INVOKED_ARRAY;
@ -1580,8 +1583,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
print_var_error(FLERR,"Compute global vector in atom-style variable formula",ivar);
if (compute->size_vector == 0)
print_var_error(FLERR,"Variable formula compute vector is zero length",ivar);
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!compute->is_initialized())
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
"initialization by a run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) {
compute->compute_vector();
compute->invoked_flag |= Compute::INVOKED_VECTOR;
@ -1604,8 +1608,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
print_var_error(FLERR,"Compute global vector in atom-style variable formula",ivar);
if (compute->size_array_rows == 0)
print_var_error(FLERR,"Variable formula compute array is zero length",ivar);
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!compute->is_initialized())
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
"initialization by a run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) {
compute->compute_array();
compute->invoked_flag |= Compute::INVOKED_ARRAY;
@ -1623,8 +1628,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
} else if (nbracket == 1 && compute->peratom_flag &&
compute->size_peratom_cols == 0) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!compute->is_initialized())
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
"initialization by a run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= Compute::INVOKED_PERATOM;
@ -1640,8 +1646,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
if (index2 > compute->size_peratom_cols)
print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0);
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!compute->is_initialized())
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
"initialization by a run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= Compute::INVOKED_PERATOM;
@ -1663,8 +1670,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
print_var_error(FLERR,"Per-atom compute in equal-style variable formula",ivar);
if (treetype == VECTOR)
print_var_error(FLERR,"Per-atom compute in vector-style variable formula",ivar);
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!compute->is_initialized())
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
"initialization by a run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= Compute::INVOKED_PERATOM;
@ -1687,8 +1695,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
print_var_error(FLERR,"Per-atom compute in vector-style variable formula",ivar);
if (index1 > compute->size_peratom_cols)
print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0);
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!compute->is_initialized())
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
"initialization by a run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= Compute::INVOKED_PERATOM;
@ -4163,8 +4172,9 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree **t
print_var_error(FLERR,mesg,ivar);
}
if (index == 0 && compute->vector_flag) {
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!compute->is_initialized())
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
"initialization by a run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) {
compute->compute_vector();
compute->invoked_flag |= Compute::INVOKED_VECTOR;
@ -4174,8 +4184,9 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree **t
} else if (index && compute->array_flag) {
if (index > compute->size_array_cols)
print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0);
if (update->first_update == 0)
print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar);
if (!compute->is_initialized())
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
"initialization by a run",ivar);
if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) {
compute->compute_array();
compute->invoked_flag |= Compute::INVOKED_ARRAY;