From 74d89c4c9b417c7923af279e5bb09270ac993fbb Mon Sep 17 00:00:00 2001 From: "Megan J. McCarthy" Date: Wed, 24 May 2023 11:07:03 -0600 Subject: [PATCH 01/25] init --- doc/src/compute_local_composition_atom.rst | 116 +++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 doc/src/compute_local_composition_atom.rst diff --git a/doc/src/compute_local_composition_atom.rst b/doc/src/compute_local_composition_atom.rst new file mode 100644 index 0000000000..270783d749 --- /dev/null +++ b/doc/src/compute_local_composition_atom.rst @@ -0,0 +1,116 @@ +.. index:: compute ave/sphere/atom +.. index:: compute local_composition/atom/kk + +compute local_composition/atom command +================================ + +Accelerator Variants: *local_composition/atom/kk* + +Syntax +"""""" + +.. code-block:: LAMMPS + + compute ID group-ID local_composition/atom keyword values ... + +* ID, group-ID are documented in :doc:`compute ` command +* local_composition/atom = style name of this compute command +* one or more keyword/value pairs may be appended + + .. parsed-literal:: + + keyword = *cutoff* + *cutoff* value = distance cutoff + +Examples +"""""""" + +.. code-block:: LAMMPS + + compute 1 all local_composition/atom + + compute 1 all local_composition/atom cutoff 9.0 + comm_modify cutoff 9.0 + +.. + ****** UNDER CONSTRUCTION ****** + Description + """"""""""" + + .. versionadded:: 24May2023 + + Define a computation that calculates the local composition for each atom based on its neighbors inside a spherical + cutoff. If an atom has :math:`M` neighbors, then its local mass density is + calculated as the sum of its mass and its :math:`M` neighbor masses, divided + by the volume of the cutoff sphere (or circle in 2d). The local + temperature of the atom is calculated as the temperature of the + collection of :math:`M+1` atoms, after subtracting the center-of-mass velocity + of the :math:`M+1` atoms from each of the :math:`M+1` atom's velocities. This + is effectively the thermal velocity of the neighborhood of the central + atom, similar to :doc:`compute temp/com `. + + The optional keyword *cutoff* defines the distance cutoff used when + searching for neighbors. The default value is the cutoff specified by + the pair style. If no pair style is defined, then a cutoff must be + defined using this keyword. If the specified cutoff is larger than + that of the pair_style plus neighbor skin (or no pair style is + defined), the *comm_modify cutoff* option must also be set to match + that of the *cutoff* keyword. + + The neighbor list needed to compute this quantity is constructed each + time the calculation is performed (i.e. each time a snapshot of atoms + is dumped). Thus it can be inefficient to compute/dump this quantity + too frequently. + + .. note:: + + If you have a bonded system, then the settings of + :doc:`special_bonds ` command can remove pairwise + interactions between atoms in the same bond, angle, or dihedral. + This is the default setting for the :doc:`special_bonds + ` command, and means those pairwise interactions do + not appear in the neighbor list. Because this compute uses the + neighbor list, it also means those pairs will not be included in + the order parameter. This difficulty can be circumvented by + writing a dump file, and using the :doc:`rerun ` command to + compute the order parameter for snapshots in the dump file. The + rerun script can use a :doc:`special_bonds ` command + that includes all pairs in the neighbor list. + + ---------- + + + .. include:: accel_styles.rst + + + ---------- + + Output info + """"""""""" + + This compute calculates a per-atom array with two columns: mass + density in density :doc:`units ` and temperature in temperature + :doc:`units `. + + These values can be accessed by any command that uses per-atom values + from a compute as input. See the :doc:`Howto output ` + doc page for an overview of LAMMPS output options. + + Restrictions + """""""""""" + + This compute is part of the EXTRA-COMPUTE package. It is only enabled + if LAMMPS was built with that package. See the :doc:`Build package + ` page for more info. + + Related commands + """""""""""""""" + + :doc:`comm_modify ` + + Default + """"""" + + The option defaults are *cutoff* = pair style cutoff. + +.. \ No newline at end of file From d9937fc2c635f993acbb9c68cbd811c7fbab1577 Mon Sep 17 00:00:00 2001 From: "Megan J. McCarthy" Date: Wed, 24 May 2023 13:16:08 -0600 Subject: [PATCH 02/25] add base tested code --- .../compute_local_composition_atom.cpp | 255 ++++++++++++++++++ .../compute_local_composition_atom.h | 48 ++++ 2 files changed, 303 insertions(+) create mode 100644 src/EXTRA-COMPUTE/compute_local_composition_atom.cpp create mode 100644 src/EXTRA-COMPUTE/compute_local_composition_atom.h diff --git a/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp b/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp new file mode 100644 index 0000000000..157b31b33d --- /dev/null +++ b/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp @@ -0,0 +1,255 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Stan Moore (SNL) +------------------------------------------------------------------------- */ + +#include "compute_local_composition_atom.h" + +#include "atom.h" +#include "comm.h" +#include "domain.h" +#include "error.h" +#include "force.h" +#include "math_const.h" +#include "memory.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" +#include "update.h" + +#include + +using namespace LAMMPS_NS; +using namespace MathConst; + +/* ---------------------------------------------------------------------- */ + +ComputeLocalCompositionAtom::ComputeLocalCompositionAtom(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), result(nullptr) +{ + if (narg < 3 || narg > 5) error->all(FLERR, "Illegal compute local_composition/atom command"); + + // get nelements and ntypes + + int ntypes = atom->ntypes; + + // memory->create(map, ntypes + 1, "compute_sna_grid:map"); + // nelements = utils::inumeric(FLERR, 0, false, lmp); // !!!!!!!! what is 2nd arg in inumeric? + // for (int i = 0; i < ntypes; i++) { + // int jelem = utils::inumeric(FLERR, i, false, lmp); + // if (jelem < 0 || jelem >= nelements) error->all(FLERR, "Illegal compute {} command", style); + // map[i + 1] = jelem; + // printf("mapp[x] %d jelem %d \n", map[i + 1], jelem); + // } + + // printf("ntypes %d \n", ntypes); + // printf("elements %d \n", nelements); + + // process optional args + + cutoff = 0.0; + + int iarg = 3; + while (iarg < narg) { + if (strcmp(arg[iarg], "cutoff") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal compute local_composition/atom command"); + cutoff = utils::numeric(FLERR, arg[iarg + 1], false, lmp); + if (cutoff <= 0.0) error->all(FLERR, "Illegal compute local_composition/atom command"); + iarg += 2; + } else + error->all(FLERR, "Illegal compute local_composition/atom command"); + } + + peratom_flag = 1; + + size_peratom_cols = 1 + ntypes; + + nmax = 0; +} + +/* ---------------------------------------------------------------------- */ + +ComputeLocalCompositionAtom::~ComputeLocalCompositionAtom() +{ + if (copymode) return; + + memory->destroy(result); + // memory->destroy(map); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeLocalCompositionAtom::init() +{ + if (!force->pair && cutoff == 0.0) + error->all(FLERR, + "Compute local_composition/atom requires a cutoff be specified " + "or a pair style be defined"); + + double skin = neighbor->skin; + if (cutoff != 0.0) { + double cutghost; // as computed by Neighbor and Comm + if (force->pair) + cutghost = MAX(force->pair->cutforce + skin, comm->cutghostuser); + else + cutghost = comm->cutghostuser; + + if (cutoff > cutghost) + error->all(FLERR, + "Compute local_composition/atom cutoff exceeds ghost atom range - " + "use comm_modify cutoff command"); + } + + int cutflag = 1; + if (force->pair) { + if (cutoff == 0.0) { cutoff = force->pair->cutforce; } + if (cutoff <= force->pair->cutforce + skin) cutflag = 0; + } + + cutsq = cutoff * cutoff; + if (domain->dimension == 3) + volume = 4.0 / 3.0 * MY_PI * cutsq * cutoff; + else + volume = MY_PI * cutsq; + + // need an occasional full neighbor list + + auto req = neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); + if (cutflag) req->set_cutoff(cutoff); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeLocalCompositionAtom::init_list(int /*id*/, NeighList *ptr) +{ + list = ptr; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeLocalCompositionAtom::compute_peratom() +{ + int i, j, ii, jj, inum, jnum; + double xtmp, ytmp, ztmp, delx, dely, delz, rsq; + int *ilist, *jlist, *numneigh, **firstneigh; + int count; + + invoked_peratom = update->ntimestep; + + // grow result array if necessary + + if (atom->nmax > nmax) { + memory->destroy(result); + nmax = atom->nmax; + + // TODO what is the LAMMPSIAN, idiomatic way to get correct num cols assigned here for memory? + // TODO is there any reason not to use size_peratom_cols? + + // orig from compute_ave_sphere_atom: + // memory->create(result, nmax, 2, "local_composition/atom:result"); + memory->create(result, nmax, size_peratom_cols, "local_composition/atom:result"); + array_atom = result; + } + + // invoke full neighbor list (will copy or build if necessary) + + neighbor->build_one(list); + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // compute properties for each atom in group + // use full neighbor list to count atoms less than cutoff + + double **x = atom->x; + int *type = atom->type; + int *mask = atom->mask; + + int typeone_i, typeone_j; + + // TODO what is LAMMPSian way to get ntypes info here + // TODO continue to implement map (nelements instead of ntypes) + + int ntypes = atom->ntypes; + + // TODO what is LAMMPSian/c++ way to init and populate array + + double lcomp[ntypes]; + for (int i = 0; i < ntypes; i++) { + lcomp[i] = 0; + } + + // get per-atom local compositions + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + + if (mask[i] & groupbit) { + + typeone_i = type[i]; + + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + // i atom contribution + + count = 1; + + typeone_i = type[i]; + lcomp[typeone_i - 1]++; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + typeone_j = type[j]; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + if (rsq < cutsq) { + count++; + lcomp[typeone_j-1]++; + } + } + + // total count of atoms found in sampled radius range + + result[i][0] = count; + + // local composition fractions per element + for (int n = 0; n < ntypes; n++) { + result[i][n + 1] = lcomp[n] / count; + } + } + } +} + +/* ---------------------------------------------------------------------- + memory usage of local atom-based array +------------------------------------------------------------------------- */ + +double ComputeLocalCompositionAtom::memory_usage() +{ + double bytes = (double) 2 * nmax * sizeof(double); + return bytes; +} diff --git a/src/EXTRA-COMPUTE/compute_local_composition_atom.h b/src/EXTRA-COMPUTE/compute_local_composition_atom.h new file mode 100644 index 0000000000..fb8c8b6c49 --- /dev/null +++ b/src/EXTRA-COMPUTE/compute_local_composition_atom.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + 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. +------------------------------------------------------------------------- */ + +#ifdef COMPUTE_CLASS +// clang-format off +ComputeStyle(local_composition/atom,ComputeLocalCompositionAtom); +// clang-format on +#else + +#ifndef LMP_COMPUTE_LOCAL_COMPOSITION_ATOM_H +#define LMP_COMPUTE_LOCAL_COMPOSITION_ATOM_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeLocalCompositionAtom : public Compute { + public: + ComputeLocalCompositionAtom(class LAMMPS *, int, char **); + ~ComputeLocalCompositionAtom() override; + void init() override; + void init_list(int, class NeighList *) override; + void compute_peratom() override; + double memory_usage() override; + + protected: + int nmax; + double cutoff, cutsq, volume, nelements; + int *map; // map types to [0,nelements), taken from example in compute_snap + class NeighList *list; + + double **result; +}; + +} // namespace LAMMPS_NS + +#endif +#endif From 40056e29a47a617a3da1a1b3b4627ef0f4f7ffd2 Mon Sep 17 00:00:00 2001 From: "Megan J. McCarthy" Date: Thu, 25 May 2023 11:58:02 -0600 Subject: [PATCH 03/25] move reset of lcomp array to correct scope --- .../compute_local_composition_atom.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp b/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp index 157b31b33d..5aeb04c33e 100644 --- a/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp @@ -154,12 +154,6 @@ void ComputeLocalCompositionAtom::compute_peratom() if (atom->nmax > nmax) { memory->destroy(result); nmax = atom->nmax; - - // TODO what is the LAMMPSIAN, idiomatic way to get correct num cols assigned here for memory? - // TODO is there any reason not to use size_peratom_cols? - - // orig from compute_ave_sphere_atom: - // memory->create(result, nmax, 2, "local_composition/atom:result"); memory->create(result, nmax, size_peratom_cols, "local_composition/atom:result"); array_atom = result; } @@ -182,21 +176,20 @@ void ComputeLocalCompositionAtom::compute_peratom() int typeone_i, typeone_j; - // TODO what is LAMMPSian way to get ntypes info here // TODO continue to implement map (nelements instead of ntypes) int ntypes = atom->ntypes; - - // TODO what is LAMMPSian/c++ way to init and populate array double lcomp[ntypes]; - for (int i = 0; i < ntypes; i++) { - lcomp[i] = 0; - } // get per-atom local compositions for (ii = 0; ii < inum; ii++) { + + for (int i = 0; i < ntypes; i++) { + lcomp[i] = 0; + } + i = ilist[ii]; if (mask[i] & groupbit) { From 1124f7eb93ca7544aaaacb99cdb808e99956c5d7 Mon Sep 17 00:00:00 2001 From: "Megan J. McCarthy" Date: Wed, 31 May 2023 13:32:37 -0600 Subject: [PATCH 04/25] adjust to one-liner --- src/EXTRA-COMPUTE/compute_local_composition_atom.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp b/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp index 5aeb04c33e..ba3e40d8c8 100644 --- a/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp @@ -186,16 +186,12 @@ void ComputeLocalCompositionAtom::compute_peratom() for (ii = 0; ii < inum; ii++) { - for (int i = 0; i < ntypes; i++) { - lcomp[i] = 0; - } + for (int i = 0; i < ntypes; i++) lcomp[i] = 0; i = ilist[ii]; if (mask[i] & groupbit) { - typeone_i = type[i]; - xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; From 90e84a6ff8d5f0d3644a3b4d1c490f3cf043137b Mon Sep 17 00:00:00 2001 From: "Megan J. McCarthy" Date: Wed, 31 May 2023 13:32:52 -0600 Subject: [PATCH 05/25] set up basic KOKKOS file (untested) --- src/KOKKOS/compute_local_composition_atom.cpp | 188 ++++++++++++++++++ src/KOKKOS/compute_local_composition_atom.h | 69 +++++++ 2 files changed, 257 insertions(+) create mode 100644 src/KOKKOS/compute_local_composition_atom.cpp create mode 100644 src/KOKKOS/compute_local_composition_atom.h diff --git a/src/KOKKOS/compute_local_composition_atom.cpp b/src/KOKKOS/compute_local_composition_atom.cpp new file mode 100644 index 0000000000..1c52d6c948 --- /dev/null +++ b/src/KOKKOS/compute_local_composition_atom.cpp @@ -0,0 +1,188 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + 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 Gdirectoryeneral Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Stan Moore (SNL) +------------------------------------------------------------------------- */ + +#include "compute_local_composition_kokkos.h" + +#include "atom_kokkos.h" +#include "atom_masks.h" +#include "comm.h" +#include "domain.h" +#include "error.h" +#include "force.h" +#include "memory_kokkos.h" +#include "modify.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor_kokkos.h" +#include "pair.h" +#include "update.h" + +#include +#include + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +ComputeLocalCompositionKokkos::ComputeLocalCompositionKokkos(LAMMPS *lmp, int narg, char **arg) : + ComputeLocalComposition(lmp, narg, arg) +{ + kokkosable = 1; + atomKK = (AtomKokkos *) atom; + execution_space = ExecutionSpaceFromDevice::space; + datamask_read = EMPTY_MASK; + datamask_modify = EMPTY_MASK; +} + +/* ---------------------------------------------------------------------- */ + +template +ComputeLocalCompositionKokkos::~ComputeLocalCompositionKokkos() +{ + if (copymode) return; + + memoryKK->destroy_kokkos(k_result,result); +} + +/* ---------------------------------------------------------------------- */ + +template +void ComputeLocalCompositionKokkos::init() +{ + ComputeLocalComposition::init(); + + // adjust neighbor list request for KOKKOS + + auto request = neighbor->find_request(this); + request->set_kokkos_host(std::is_same::value && + !std::is_same::value); + request->set_kokkos_device(std::is_same::value); +} + +/* ---------------------------------------------------------------------- */ + +template +void ComputeLocalCompositionKokkos::compute_peratom() +{ + invoked_peratom = update->ntimestep; + + // grow result array if necessary + + if (atom->nmax > nmax) { + memoryKK->destroy_kokkos(k_result,result); + nmax = atom->nmax; + memoryKK->create_kokkos(k_result,result,nmax,2,"local_composition/atom:result"); + d_result = k_result.view(); + array_atom = result; + } + + // // need velocities of ghost atoms + + // atomKK->sync(Host,V_MASK); + // comm->forward_comm(this); + // atomKK->modified(Host,V_MASK); + + // invoke full neighbor list (will copy or build if necessary) + + neighbor->build_one(list); + int inum = list->inum; + + NeighListKokkos* k_list = static_cast*>(list); + d_numneigh = k_list->d_numneigh; + d_neighbors = k_list->d_neighbors; + d_ilist = k_list->d_ilist; + + // compute properties for each atom in group + // use full neighbor list to count atoms less than cutoff + + atomKK->sync(execution_space,X_MASK|V_MASK|RMASS_MASK|TYPE_MASK|MASK_MASK); + x = atomKK->k_x.view(); + type = atomKK->k_type.view(); + ntypes = atomKK->k_ntypes.view(); + mask = atomKK->k_mask.view(); + + Kokkos::deep_copy(d_result,0.0); + + copymode = 1; + typename Kokkos::RangePolicy policy(0,inum); + Kokkos::parallel_for("ComputeLocalComposition",policy,*this); + copymode = 0; + + k_result.modify(); + k_result.sync_host(); +} + +template +KOKKOS_INLINE_FUNCTION +void ComputeLocalCompositionKokkos::operator()(TagComputeLocalComposition, const int &ii) const +{ + double typeone_i, typeone_j; + + // TODO continue to implement map (nelements instead of ntypes) + + double lcomp[ntypes]; + + // get per-atom local compositions + + for (ii = 0; ii < inum; ii++) { + + for (int i = 0; i < ntypes; i++) lcomp[i] = 0; + + const int i = d_ilist[ii]; + + if (mask[i] & groupbit) { + + const X_FLOAT xtmp = x(i,0); + const X_FLOAT ytmp = x(i,1); + const X_FLOAT ztmp = x(i,2); + const int jnum = d_numneigh[i]; + + // i atom contribution + + int count = 1; + + typeone_i = type[i]; + + for (int jj = 0; jj < jnum; jj++) { + int j = d_neighbors(i,jj); + j &= NEIGHMASK; + + typeone_j = type[j]; + + const F_FLOAT delx = x(j,0) - xtmp; + const F_FLOAT dely = x(j,1) - ytmp; + const F_FLOAT delz = x(j,2) - ztmp; + const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; + if (rsq < cutsq) { + count++; + lcomp[typeone_j]++; + } + } + for (int n = 0 n < 4; n++) { + d_result(i,n+1) = lcomp[n] / density; + } + } + } +} + +namespace LAMMPS_NS { +template class ComputeLocalCompositionKokkos; +#ifdef LMP_KOKKOS_GPU +template class ComputeLocalCompositionKokkos; +#endif +} diff --git a/src/KOKKOS/compute_local_composition_atom.h b/src/KOKKOS/compute_local_composition_atom.h new file mode 100644 index 0000000000..fb0c914b36 --- /dev/null +++ b/src/KOKKOS/compute_local_composition_atom.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + 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. +------------------------------------------------------------------------- */ + +#ifdef COMPUTE_CLASS +// clang-format off +ComputeStyle(local_composition/atom/kk,ComputeLocalCompositionAtomKokkos); +ComputeStyle(local_composition/atom/kk/device,ComputeLocalCompositionAtomKokkos); +ComputeStyle(local_composition/atom/kk/host,ComputeLocalCompositionAtomKokkos); +// clang-format on + +#else + +#ifndef LMP_COMPUTE_LOCAL_COMPOSITION_ATOM_KOKKOS_H +#define LMP_COMPUTE_LOCAL_COMPOSITION_ATOM_KOKKOS_H + +#include "compute_local_composition_atom.h" +#include "kokkos_type.h" + +namespace LAMMPS_NS { + +// clang-format off +struct TagComputeLocalCompositionAtom {}; +// clang-format on + +template class ComputeLocalCompositionAtomKokkos : public ComputeLocalCompositionAtom { + public: + typedef DeviceType device_type; + typedef ArrayTypes AT; + + ComputeLocalCompositionAtomKokkos(class LAMMPS *, int, char **); + ~ComputeLocalCompositionAtomKokkos() override; + void init() override; + void compute_peratom() override; + + KOKKOS_INLINE_FUNCTION + void operator()(TagComputeLocalCompositionAtom, const int &) const; + + private: + double adof, mvv2e, mv2d, boltz; + + typename AT::t_x_array x; + typename AT::t_v_array v; + typename ArrayTypes::t_float_1d rmass; + typename ArrayTypes::t_float_1d mass; + typename ArrayTypes::t_int_1d type; + typename ArrayTypes::t_int_1d mask; + + typename AT::t_neighbors_2d d_neighbors; + typename AT::t_int_1d d_ilist; + typename AT::t_int_1d d_numneigh; + + DAT::tdual_float_2d k_result; + typename AT::t_float_2d d_result; +}; + +} // namespace LAMMPS_NS + +#endif +#endif From 4ebc8afd1ea44386be4608bd3357d7f3d974a88d Mon Sep 17 00:00:00 2001 From: "Megan J. McCarthy" Date: Thu, 1 Jun 2023 03:20:43 -0600 Subject: [PATCH 06/25] update documentation --- doc/src/compute_local_composition_atom.rst | 130 +++++++++++---------- 1 file changed, 68 insertions(+), 62 deletions(-) diff --git a/doc/src/compute_local_composition_atom.rst b/doc/src/compute_local_composition_atom.rst index 270783d749..2b8fb7f080 100644 --- a/doc/src/compute_local_composition_atom.rst +++ b/doc/src/compute_local_composition_atom.rst @@ -32,85 +32,91 @@ Examples compute 1 all local_composition/atom cutoff 9.0 comm_modify cutoff 9.0 -.. - ****** UNDER CONSTRUCTION ****** - Description - """"""""""" - .. versionadded:: 24May2023 +Description +""""""""""" - Define a computation that calculates the local composition for each atom based on its neighbors inside a spherical - cutoff. If an atom has :math:`M` neighbors, then its local mass density is - calculated as the sum of its mass and its :math:`M` neighbor masses, divided - by the volume of the cutoff sphere (or circle in 2d). The local - temperature of the atom is calculated as the temperature of the - collection of :math:`M+1` atoms, after subtracting the center-of-mass velocity - of the :math:`M+1` atoms from each of the :math:`M+1` atom's velocities. This - is effectively the thermal velocity of the neighborhood of the central - atom, similar to :doc:`compute temp/com `. +.. versionadded:: 24May2023 - The optional keyword *cutoff* defines the distance cutoff used when - searching for neighbors. The default value is the cutoff specified by - the pair style. If no pair style is defined, then a cutoff must be - defined using this keyword. If the specified cutoff is larger than - that of the pair_style plus neighbor skin (or no pair style is - defined), the *comm_modify cutoff* option must also be set to match - that of the *cutoff* keyword. +Define a computation that calculates the local composition of atom types for a +central atom based on its neighbors inside a spherical cutoff. For a simulation with +:math:`N` atom types and an atom with :math:`M` neighbors within the cutoff, the +fraction of each atom type is counted and divided by the total number of atoms in the +sphere, including the central atom (:math:`M+1`). The sum of all fractions will +always add to one. - The neighbor list needed to compute this quantity is constructed each - time the calculation is performed (i.e. each time a snapshot of atoms - is dumped). Thus it can be inefficient to compute/dump this quantity - too frequently. +.. note:: - .. note:: + This compute uses the number of atom types, not chemical species, assigned in + :doc:`pair_coeff ` command. If an interatomic potential has two + species (i.e., Cu and Ni) assigned to four different atom types in + :doc:`pair_coeff ` (i.e., 'Cu Cu Ni Ni'), the local composition will + output four fractional values. In those cases, the user may desire an extra + calculation step to consolidate per-type fractions into per-species fractions. + This calculation can be conducted within LAMMPS using another compute such as + :doc:`compute reduce `, an atom-style :doc:`variable`, or as a + post-processing step. - If you have a bonded system, then the settings of - :doc:`special_bonds ` command can remove pairwise - interactions between atoms in the same bond, angle, or dihedral. - This is the default setting for the :doc:`special_bonds - ` command, and means those pairwise interactions do - not appear in the neighbor list. Because this compute uses the - neighbor list, it also means those pairs will not be included in - the order parameter. This difficulty can be circumvented by - writing a dump file, and using the :doc:`rerun ` command to - compute the order parameter for snapshots in the dump file. The - rerun script can use a :doc:`special_bonds ` command - that includes all pairs in the neighbor list. +---------- - ---------- +The optional keyword *cutoff* defines the distance cutoff used when +searching for neighbors. The default value is the cutoff specified by +the pair style. If no pair style is defined, then a cutoff must be +defined using this keyword. If the specified cutoff is larger than +that of the pair_style plus neighbor skin (or no pair style is +defined), the *comm_modify cutoff* option must also be set to match +that of the *cutoff* keyword. + +The neighbor list needed to compute this quantity is constructed each +time the calculation is performed (i.e. each time a snapshot of atoms +is dumped). Thus it can be inefficient to compute/dump this quantity +too frequently. + +.. note:: + + If you have a bonded system, then the settings of + :doc:`special_bonds ` command can remove pairwise + interactions between atoms in the same bond, angle, or dihedral. + This is the default setting for the :doc:`special_bonds + ` command, and means those pairwise interactions do + not appear in the neighbor list. Because this compute uses the + neighbor list, it also means those pairs will not be included in + the order parameter. This difficulty can be circumvented by + writing a dump file, and using the :doc:`rerun ` command to + compute the order parameter for snapshots in the dump file. The + rerun script can use a :doc:`special_bonds ` command + that includes all pairs in the neighbor list. + +---------- - .. include:: accel_styles.rst +.. include:: accel_styles.rst - ---------- +---------- - Output info - """"""""""" +Output info +""""""""""" - This compute calculates a per-atom array with two columns: mass - density in density :doc:`units ` and temperature in temperature - :doc:`units `. +This compute calculates a per-atom array with :math:`1 + N` columns, where :math:`N` is the number of atom types. The first column is a count of the number of atoms used to calcuate composition (including the central atom), and each subsequent column indicates the fraction of that atom type detected within the cutoff range. - These values can be accessed by any command that uses per-atom values - from a compute as input. See the :doc:`Howto output ` - doc page for an overview of LAMMPS output options. +These values can be accessed by any command that uses per-atom values +from a compute as input. See the :doc:`Howto output ` +doc page for an overview of LAMMPS output options. - Restrictions - """""""""""" +Restrictions +"""""""""""" - This compute is part of the EXTRA-COMPUTE package. It is only enabled - if LAMMPS was built with that package. See the :doc:`Build package - ` page for more info. +This compute is part of the EXTRA-COMPUTE package. It is only enabled +if LAMMPS was built with that package. See the :doc:`Build package +` page for more info. - Related commands - """""""""""""""" +Related commands +"""""""""""""""" - :doc:`comm_modify ` +:doc:`comm_modify ` - Default - """"""" +Default +""""""" - The option defaults are *cutoff* = pair style cutoff. - -.. \ No newline at end of file +The option defaults are *cutoff* = pair style cutoff. From 9a389fbac6d0e3b0e1d08297da0090bdcbf9c3df Mon Sep 17 00:00:00 2001 From: "Megan J. McCarthy" Date: Thu, 1 Jun 2023 03:25:17 -0600 Subject: [PATCH 07/25] fix typo --- doc/src/compute_local_composition_atom.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/compute_local_composition_atom.rst b/doc/src/compute_local_composition_atom.rst index 2b8fb7f080..96e422122b 100644 --- a/doc/src/compute_local_composition_atom.rst +++ b/doc/src/compute_local_composition_atom.rst @@ -48,9 +48,9 @@ always add to one. .. note:: This compute uses the number of atom types, not chemical species, assigned in - :doc:`pair_coeff ` command. If an interatomic potential has two + :doc:`pair_coeff ` command. If an interatomic potential has two species (i.e., Cu and Ni) assigned to four different atom types in - :doc:`pair_coeff ` (i.e., 'Cu Cu Ni Ni'), the local composition will + :doc:`pair_coeff ` (i.e., 'Cu Cu Ni Ni'), the compute will output four fractional values. In those cases, the user may desire an extra calculation step to consolidate per-type fractions into per-species fractions. This calculation can be conducted within LAMMPS using another compute such as From 2c22bb49b4401dd38bbc13f6c8b9843520ef829b Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Thu, 1 Jun 2023 12:32:02 -0600 Subject: [PATCH 08/25] Added some comments to data members --- src/EXTRA-COMPUTE/compute_local_composition_atom.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_local_composition_atom.h b/src/EXTRA-COMPUTE/compute_local_composition_atom.h index fb8c8b6c49..64498b6640 100644 --- a/src/EXTRA-COMPUTE/compute_local_composition_atom.h +++ b/src/EXTRA-COMPUTE/compute_local_composition_atom.h @@ -35,11 +35,14 @@ class ComputeLocalCompositionAtom : public Compute { protected: int nmax; - double cutoff, cutsq, volume, nelements; - int *map; // map types to [0,nelements), taken from example in compute_snap - class NeighList *list; + double cutoff; // global cutoff distance + double cutsq; // cutoff**2 + double volume; // local volume + double nelements; // number of elements + int *map; // map types to [0,nelements) + class NeighList *list; // neighbor list - double **result; + double **result; // peratom array of local compositions }; } // namespace LAMMPS_NS From 710597a353b906d4e460c3558ddb2bd9a9cbfc60 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Thu, 1 Jun 2023 17:43:51 -0600 Subject: [PATCH 09/25] Made some coding style changes --- doc/src/Commands_compute.rst | 1 + doc/src/compute.rst | 1 + ...n_atom.rst => compute_local_comp_atom.rst} | 39 ++++------ doc/utils/sphinx-config/false_positives.txt | 2 + ...n_atom.cpp => compute_local_comp_atom.cpp} | 73 +++++++------------ ...ition_atom.h => compute_local_comp_atom.h} | 15 ++-- ...cpp => compute_local_comp_atom_kokkos.cpp} | 44 +++++------ ...tom.h => compute_local_comp_atom_kokkos.h} | 25 +++---- 8 files changed, 81 insertions(+), 119 deletions(-) rename doc/src/{compute_local_composition_atom.rst => compute_local_comp_atom.rst} (72%) rename src/EXTRA-COMPUTE/{compute_local_composition_atom.cpp => compute_local_comp_atom.cpp} (71%) rename src/EXTRA-COMPUTE/{compute_local_composition_atom.h => compute_local_comp_atom.h} (71%) rename src/KOKKOS/{compute_local_composition_atom.cpp => compute_local_comp_atom_kokkos.cpp} (77%) rename src/KOKKOS/{compute_local_composition_atom.h => compute_local_comp_atom_kokkos.h} (60%) diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index 755000c976..a2d0fd3823 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -91,6 +91,7 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`ke/atom/eff ` * :doc:`ke/eff ` * :doc:`ke/rigid ` + * :doc:`local/comp/atom ` * :doc:`mliap ` * :doc:`momentum ` * :doc:`msd ` diff --git a/doc/src/compute.rst b/doc/src/compute.rst index 950487cb72..2862e94b02 100644 --- a/doc/src/compute.rst +++ b/doc/src/compute.rst @@ -245,6 +245,7 @@ The individual style names on the :doc:`Commands compute ` pag * :doc:`ke/atom/eff ` - per-atom translational and radial kinetic energy in the electron force field model * :doc:`ke/eff ` - kinetic energy of a group of nuclei and electrons in the electron force field model * :doc:`ke/rigid ` - translational kinetic energy of rigid bodies +* :doc:`local/comp/atom ` - local composition for each atom * :doc:`mliap ` - gradients of energy and forces with respect to model parameters and related quantities for training machine learning interatomic potentials * :doc:`momentum ` - translational momentum * :doc:`msd ` - mean-squared displacement of group of atoms diff --git a/doc/src/compute_local_composition_atom.rst b/doc/src/compute_local_comp_atom.rst similarity index 72% rename from doc/src/compute_local_composition_atom.rst rename to doc/src/compute_local_comp_atom.rst index 96e422122b..ad9331895e 100644 --- a/doc/src/compute_local_composition_atom.rst +++ b/doc/src/compute_local_comp_atom.rst @@ -1,20 +1,17 @@ -.. index:: compute ave/sphere/atom -.. index:: compute local_composition/atom/kk +.. index:: compute local/comp/atom -compute local_composition/atom command -================================ - -Accelerator Variants: *local_composition/atom/kk* +compute local/comp/atom command +====================================== Syntax """""" .. code-block:: LAMMPS - compute ID group-ID local_composition/atom keyword values ... + compute ID group-ID local/comp/atom keyword values ... * ID, group-ID are documented in :doc:`compute ` command -* local_composition/atom = style name of this compute command +* local/comp/atom = style name of this compute command * one or more keyword/value pairs may be appended .. parsed-literal:: @@ -27,9 +24,9 @@ Examples .. code-block:: LAMMPS - compute 1 all local_composition/atom + compute 1 all local/comp/atom - compute 1 all local_composition/atom cutoff 9.0 + compute 1 all local/comp/atom cutoff 9.0 comm_modify cutoff 9.0 @@ -38,12 +35,11 @@ Description .. versionadded:: 24May2023 -Define a computation that calculates the local composition of atom types for a -central atom based on its neighbors inside a spherical cutoff. For a simulation with -:math:`N` atom types and an atom with :math:`M` neighbors within the cutoff, the -fraction of each atom type is counted and divided by the total number of atoms in the -sphere, including the central atom (:math:`M+1`). The sum of all fractions will -always add to one. +Define a computation that calculates a local composition vector for each +atom. For a central atom with :math:`M` neighbors within the neighbor cutoff sphere, +composition is defined as the number of atoms of a given type +(including the central atom) divided by (:math:`M+1`). For a given central atom, +the sum of all compositions equals one. .. note:: @@ -89,16 +85,13 @@ too frequently. ---------- - -.. include:: accel_styles.rst - - ----------- - Output info """"""""""" -This compute calculates a per-atom array with :math:`1 + N` columns, where :math:`N` is the number of atom types. The first column is a count of the number of atoms used to calcuate composition (including the central atom), and each subsequent column indicates the fraction of that atom type detected within the cutoff range. +This compute calculates a per-atom array with :math:`1 + N` columns, where :math:`N` +is the number of atom types. The first column is a count of the number of atoms +used to calculate composition (including the central atom), and each subsequent +column indicates the fraction of that atom type within the cutoff sphere. These values can be accessed by any command that uses per-atom values from a compute as input. See the :doc:`Howto output ` diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index d2d15633af..6c53226332 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -3611,6 +3611,7 @@ Tk Tkin tloop tlsph +tm tmax Tmax tmd @@ -3736,6 +3737,7 @@ Umin un unary uncomment +uncommented uncompress uncompute underprediction diff --git a/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp similarity index 71% rename from src/EXTRA-COMPUTE/compute_local_composition_atom.cpp rename to src/EXTRA-COMPUTE/compute_local_comp_atom.cpp index ba3e40d8c8..50ad3ce72c 100644 --- a/src/EXTRA-COMPUTE/compute_local_composition_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp @@ -15,7 +15,7 @@ Contributing author: Stan Moore (SNL) ------------------------------------------------------------------------- */ -#include "compute_local_composition_atom.h" +#include "compute_local_comp_atom.h" #include "atom.h" #include "comm.h" @@ -37,40 +37,24 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -ComputeLocalCompositionAtom::ComputeLocalCompositionAtom(LAMMPS *lmp, int narg, char **arg) : +ComputeLocalCompAtom::ComputeLocalCompAtom(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), result(nullptr) { - if (narg < 3 || narg > 5) error->all(FLERR, "Illegal compute local_composition/atom command"); - - // get nelements and ntypes + if (narg < 3 || narg > 5) error->all(FLERR, "Illegal compute local/comp/atom command"); int ntypes = atom->ntypes; - // memory->create(map, ntypes + 1, "compute_sna_grid:map"); - // nelements = utils::inumeric(FLERR, 0, false, lmp); // !!!!!!!! what is 2nd arg in inumeric? - // for (int i = 0; i < ntypes; i++) { - // int jelem = utils::inumeric(FLERR, i, false, lmp); - // if (jelem < 0 || jelem >= nelements) error->all(FLERR, "Illegal compute {} command", style); - // map[i + 1] = jelem; - // printf("mapp[x] %d jelem %d \n", map[i + 1], jelem); - // } - - // printf("ntypes %d \n", ntypes); - // printf("elements %d \n", nelements); - - // process optional args - cutoff = 0.0; int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg], "cutoff") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal compute local_composition/atom command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal compute local/comp/atom command"); cutoff = utils::numeric(FLERR, arg[iarg + 1], false, lmp); - if (cutoff <= 0.0) error->all(FLERR, "Illegal compute local_composition/atom command"); + if (cutoff <= 0.0) error->all(FLERR, "Illegal compute local/comp/atom command"); iarg += 2; } else - error->all(FLERR, "Illegal compute local_composition/atom command"); + error->all(FLERR, "Illegal compute local/comp/atom command"); } peratom_flag = 1; @@ -82,21 +66,20 @@ ComputeLocalCompositionAtom::ComputeLocalCompositionAtom(LAMMPS *lmp, int narg, /* ---------------------------------------------------------------------- */ -ComputeLocalCompositionAtom::~ComputeLocalCompositionAtom() +ComputeLocalCompAtom::~ComputeLocalCompAtom() { if (copymode) return; memory->destroy(result); - // memory->destroy(map); } /* ---------------------------------------------------------------------- */ -void ComputeLocalCompositionAtom::init() +void ComputeLocalCompAtom::init() { if (!force->pair && cutoff == 0.0) error->all(FLERR, - "Compute local_composition/atom requires a cutoff be specified " + "Compute local/comp/atom requires a cutoff be specified " "or a pair style be defined"); double skin = neighbor->skin; @@ -109,7 +92,7 @@ void ComputeLocalCompositionAtom::init() if (cutoff > cutghost) error->all(FLERR, - "Compute local_composition/atom cutoff exceeds ghost atom range - " + "Compute local/comp/atom cutoff exceeds ghost atom range - " "use comm_modify cutoff command"); } @@ -120,10 +103,6 @@ void ComputeLocalCompositionAtom::init() } cutsq = cutoff * cutoff; - if (domain->dimension == 3) - volume = 4.0 / 3.0 * MY_PI * cutsq * cutoff; - else - volume = MY_PI * cutsq; // need an occasional full neighbor list @@ -133,19 +112,19 @@ void ComputeLocalCompositionAtom::init() /* ---------------------------------------------------------------------- */ -void ComputeLocalCompositionAtom::init_list(int /*id*/, NeighList *ptr) +void ComputeLocalCompAtom::init_list(int /*id*/, NeighList *ptr) { list = ptr; } /* ---------------------------------------------------------------------- */ -void ComputeLocalCompositionAtom::compute_peratom() +void ComputeLocalCompAtom::compute_peratom() { int i, j, ii, jj, inum, jnum; double xtmp, ytmp, ztmp, delx, dely, delz, rsq; int *ilist, *jlist, *numneigh, **firstneigh; - int count; + int count, itype, jtype; invoked_peratom = update->ntimestep; @@ -154,7 +133,7 @@ void ComputeLocalCompositionAtom::compute_peratom() if (atom->nmax > nmax) { memory->destroy(result); nmax = atom->nmax; - memory->create(result, nmax, size_peratom_cols, "local_composition/atom:result"); + memory->create(result, nmax, size_peratom_cols, "local/comp/atom:result"); array_atom = result; } @@ -176,11 +155,9 @@ void ComputeLocalCompositionAtom::compute_peratom() int typeone_i, typeone_j; - // TODO continue to implement map (nelements instead of ntypes) - int ntypes = atom->ntypes; - double lcomp[ntypes]; + int lcomp[ntypes]; // get per-atom local compositions @@ -202,14 +179,14 @@ void ComputeLocalCompositionAtom::compute_peratom() count = 1; - typeone_i = type[i]; - lcomp[typeone_i - 1]++; + itype = type[i]; + lcomp[itype-1]++; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; j &= NEIGHMASK; - typeone_j = type[j]; + jtype = type[j]; delx = xtmp - x[j][0]; dely = ytmp - x[j][1]; @@ -217,7 +194,7 @@ void ComputeLocalCompositionAtom::compute_peratom() rsq = delx * delx + dely * dely + delz * delz; if (rsq < cutsq) { count++; - lcomp[typeone_j-1]++; + lcomp[jtype-1]++; } } @@ -225,10 +202,12 @@ void ComputeLocalCompositionAtom::compute_peratom() result[i][0] = count; - // local composition fractions per element - for (int n = 0; n < ntypes; n++) { - result[i][n + 1] = lcomp[n] / count; - } + // local comp fractions per element + + double lfac = 1.0 / count; + for (int n = 0; n < ntypes; n++) + result[i][n+1] = lcomp[n] * lfac; + } } } @@ -237,7 +216,7 @@ void ComputeLocalCompositionAtom::compute_peratom() memory usage of local atom-based array ------------------------------------------------------------------------- */ -double ComputeLocalCompositionAtom::memory_usage() +double ComputeLocalCompAtom::memory_usage() { double bytes = (double) 2 * nmax * sizeof(double); return bytes; diff --git a/src/EXTRA-COMPUTE/compute_local_composition_atom.h b/src/EXTRA-COMPUTE/compute_local_comp_atom.h similarity index 71% rename from src/EXTRA-COMPUTE/compute_local_composition_atom.h rename to src/EXTRA-COMPUTE/compute_local_comp_atom.h index 64498b6640..22e40edab9 100644 --- a/src/EXTRA-COMPUTE/compute_local_composition_atom.h +++ b/src/EXTRA-COMPUTE/compute_local_comp_atom.h @@ -13,21 +13,21 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(local_composition/atom,ComputeLocalCompositionAtom); +ComputeStyle(local/comp/atom,ComputeLocalCompAtom); // clang-format on #else -#ifndef LMP_COMPUTE_LOCAL_COMPOSITION_ATOM_H -#define LMP_COMPUTE_LOCAL_COMPOSITION_ATOM_H +#ifndef LMP_COMPUTE_LOCAL_COMP_ATOM_H +#define LMP_COMPUTE_LOCAL_COMP_ATOM_H #include "compute.h" namespace LAMMPS_NS { -class ComputeLocalCompositionAtom : public Compute { +class ComputeLocalCompAtom : public Compute { public: - ComputeLocalCompositionAtom(class LAMMPS *, int, char **); - ~ComputeLocalCompositionAtom() override; + ComputeLocalCompAtom(class LAMMPS *, int, char **); + ~ComputeLocalCompAtom() override; void init() override; void init_list(int, class NeighList *) override; void compute_peratom() override; @@ -37,9 +37,6 @@ class ComputeLocalCompositionAtom : public Compute { int nmax; double cutoff; // global cutoff distance double cutsq; // cutoff**2 - double volume; // local volume - double nelements; // number of elements - int *map; // map types to [0,nelements) class NeighList *list; // neighbor list double **result; // peratom array of local compositions diff --git a/src/KOKKOS/compute_local_composition_atom.cpp b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp similarity index 77% rename from src/KOKKOS/compute_local_composition_atom.cpp rename to src/KOKKOS/compute_local_comp_atom_kokkos.cpp index 1c52d6c948..7ee63eafea 100644 --- a/src/KOKKOS/compute_local_composition_atom.cpp +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp @@ -12,10 +12,10 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing author: Stan Moore (SNL) + Contributing author: Stan Moore (SNL), Megan McCarthy (SNL) ------------------------------------------------------------------------- */ -#include "compute_local_composition_kokkos.h" +#include "compute_local_comp_atom_kokkos.h" #include "atom_kokkos.h" #include "atom_masks.h" @@ -39,8 +39,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ template -ComputeLocalCompositionKokkos::ComputeLocalCompositionKokkos(LAMMPS *lmp, int narg, char **arg) : - ComputeLocalComposition(lmp, narg, arg) +ComputeLocalCompAtomKokkos::ComputeLocalCompAtomKokkos(LAMMPS *lmp, int narg, char **arg) : + ComputeLocalCompAtom(lmp, narg, arg) { kokkosable = 1; atomKK = (AtomKokkos *) atom; @@ -52,7 +52,7 @@ ComputeLocalCompositionKokkos::ComputeLocalCompositionKokkos(LAMMPS /* ---------------------------------------------------------------------- */ template -ComputeLocalCompositionKokkos::~ComputeLocalCompositionKokkos() +ComputeLocalCompAtomKokkos::~ComputeLocalCompAtomKokkos() { if (copymode) return; @@ -62,9 +62,9 @@ ComputeLocalCompositionKokkos::~ComputeLocalCompositionKokkos() /* ---------------------------------------------------------------------- */ template -void ComputeLocalCompositionKokkos::init() +void ComputeLocalCompAtomKokkos::init() { - ComputeLocalComposition::init(); + ComputeLocalCompAtom::init(); // adjust neighbor list request for KOKKOS @@ -77,7 +77,7 @@ void ComputeLocalCompositionKokkos::init() /* ---------------------------------------------------------------------- */ template -void ComputeLocalCompositionKokkos::compute_peratom() +void ComputeLocalCompAtomKokkos::compute_peratom() { invoked_peratom = update->ntimestep; @@ -86,17 +86,11 @@ void ComputeLocalCompositionKokkos::compute_peratom() if (atom->nmax > nmax) { memoryKK->destroy_kokkos(k_result,result); nmax = atom->nmax; - memoryKK->create_kokkos(k_result,result,nmax,2,"local_composition/atom:result"); + memoryKK->create_kokkos(k_result,result,nmax,2,"local/comp/atom:result"); d_result = k_result.view(); array_atom = result; } - // // need velocities of ghost atoms - - // atomKK->sync(Host,V_MASK); - // comm->forward_comm(this); - // atomKK->modified(Host,V_MASK); - // invoke full neighbor list (will copy or build if necessary) neighbor->build_one(list); @@ -119,8 +113,8 @@ void ComputeLocalCompositionKokkos::compute_peratom() Kokkos::deep_copy(d_result,0.0); copymode = 1; - typename Kokkos::RangePolicy policy(0,inum); - Kokkos::parallel_for("ComputeLocalComposition",policy,*this); + typename Kokkos::RangePolicy policy(0,inum); + Kokkos::parallel_for("ComputeLocalComp",policy,*this); copymode = 0; k_result.modify(); @@ -129,13 +123,11 @@ void ComputeLocalCompositionKokkos::compute_peratom() template KOKKOS_INLINE_FUNCTION -void ComputeLocalCompositionKokkos::operator()(TagComputeLocalComposition, const int &ii) const +void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalComp, const int &ii) const { double typeone_i, typeone_j; - // TODO continue to implement map (nelements instead of ntypes) - - double lcomp[ntypes]; + int lcomp[ntypes]; // get per-atom local compositions @@ -156,13 +148,13 @@ void ComputeLocalCompositionKokkos::operator()(TagComputeLocalCompos int count = 1; - typeone_i = type[i]; + itype = type[i]; for (int jj = 0; jj < jnum; jj++) { int j = d_neighbors(i,jj); j &= NEIGHMASK; - typeone_j = type[j]; + jtype = type[j]; const F_FLOAT delx = x(j,0) - xtmp; const F_FLOAT dely = x(j,1) - ytmp; @@ -170,7 +162,7 @@ void ComputeLocalCompositionKokkos::operator()(TagComputeLocalCompos const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; if (rsq < cutsq) { count++; - lcomp[typeone_j]++; + lcomp[jtype]++; } } for (int n = 0 n < 4; n++) { @@ -181,8 +173,8 @@ void ComputeLocalCompositionKokkos::operator()(TagComputeLocalCompos } namespace LAMMPS_NS { -template class ComputeLocalCompositionKokkos; +template class ComputeLocalCompAtomKokkos; #ifdef LMP_KOKKOS_GPU -template class ComputeLocalCompositionKokkos; +template class ComputeLocalCompAtomKokkos; #endif } diff --git a/src/KOKKOS/compute_local_composition_atom.h b/src/KOKKOS/compute_local_comp_atom_kokkos.h similarity index 60% rename from src/KOKKOS/compute_local_composition_atom.h rename to src/KOKKOS/compute_local_comp_atom_kokkos.h index fb0c914b36..5f9baa2af0 100644 --- a/src/KOKKOS/compute_local_composition_atom.h +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.h @@ -13,45 +13,42 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(local_composition/atom/kk,ComputeLocalCompositionAtomKokkos); -ComputeStyle(local_composition/atom/kk/device,ComputeLocalCompositionAtomKokkos); -ComputeStyle(local_composition/atom/kk/host,ComputeLocalCompositionAtomKokkos); +ComputeStyle(local/comp/atom/kk,ComputeLocalCompAtomKokkos); +ComputeStyle(local/comp/atom/kk/device,ComputeLocalCompAtomKokkos); +ComputeStyle(local/comp/atom/kk/host,ComputeLocalCompAtomKokkos); // clang-format on #else -#ifndef LMP_COMPUTE_LOCAL_COMPOSITION_ATOM_KOKKOS_H -#define LMP_COMPUTE_LOCAL_COMPOSITION_ATOM_KOKKOS_H +#ifndef LMP_COMPUTE_LOCAL_COMP_ATOM_KOKKOS_H +#define LMP_COMPUTE_LOCAL_COMP_ATOM_KOKKOS_H -#include "compute_local_composition_atom.h" +#include "compute_local_comp_atom.h" #include "kokkos_type.h" namespace LAMMPS_NS { // clang-format off -struct TagComputeLocalCompositionAtom {}; +struct TagComputeLocalCompAtom {}; // clang-format on -template class ComputeLocalCompositionAtomKokkos : public ComputeLocalCompositionAtom { +template class ComputeLocalCompAtomKokkos : public ComputeLocalCompAtom { public: typedef DeviceType device_type; typedef ArrayTypes AT; - ComputeLocalCompositionAtomKokkos(class LAMMPS *, int, char **); - ~ComputeLocalCompositionAtomKokkos() override; + ComputeLocalCompAtomKokkos(class LAMMPS *, int, char **); + ~ComputeLocalCompAtomKokkos() override; void init() override; void compute_peratom() override; KOKKOS_INLINE_FUNCTION - void operator()(TagComputeLocalCompositionAtom, const int &) const; + void operator()(TagComputeLocalCompAtom, const int &) const; private: - double adof, mvv2e, mv2d, boltz; typename AT::t_x_array x; typename AT::t_v_array v; - typename ArrayTypes::t_float_1d rmass; - typename ArrayTypes::t_float_1d mass; typename ArrayTypes::t_int_1d type; typename ArrayTypes::t_int_1d mask; From 0d875d4f8f60c4e33b132105e6b9e2acfe7d91ac Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Thu, 1 Jun 2023 18:51:31 -0600 Subject: [PATCH 10/25] Fixed up kokkos version --- src/KOKKOS/compute_local_comp_atom_kokkos.cpp | 33 ++++++++++++------- src/KOKKOS/compute_local_comp_atom_kokkos.h | 1 - 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp index 7ee63eafea..5dbe436e29 100644 --- a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp @@ -83,10 +83,11 @@ void ComputeLocalCompAtomKokkos::compute_peratom() // grow result array if necessary + int size_peratom_cols = 1 + atom->ntypes; if (atom->nmax > nmax) { memoryKK->destroy_kokkos(k_result,result); nmax = atom->nmax; - memoryKK->create_kokkos(k_result,result,nmax,2,"local/comp/atom:result"); + memoryKK->create_kokkos(k_result,result,nmax,size_peratom_cols,"local/comp/atom:result"); d_result = k_result.view(); array_atom = result; } @@ -107,13 +108,12 @@ void ComputeLocalCompAtomKokkos::compute_peratom() atomKK->sync(execution_space,X_MASK|V_MASK|RMASS_MASK|TYPE_MASK|MASK_MASK); x = atomKK->k_x.view(); type = atomKK->k_type.view(); - ntypes = atomKK->k_ntypes.view(); mask = atomKK->k_mask.view(); Kokkos::deep_copy(d_result,0.0); copymode = 1; - typename Kokkos::RangePolicy policy(0,inum); + typename Kokkos::RangePolicy policy(0,inum); Kokkos::parallel_for("ComputeLocalComp",policy,*this); copymode = 0; @@ -123,15 +123,17 @@ void ComputeLocalCompAtomKokkos::compute_peratom() template KOKKOS_INLINE_FUNCTION -void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalComp, const int &ii) const +void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, const int &ii) const { double typeone_i, typeone_j; + int ntypes = atom->ntypes; int lcomp[ntypes]; // get per-atom local compositions - for (ii = 0; ii < inum; ii++) { + int inum = list->inum; + for (int ii = 0; ii < inum; ii++) { for (int i = 0; i < ntypes; i++) lcomp[i] = 0; @@ -148,13 +150,14 @@ void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalComp, con int count = 1; - itype = type[i]; + int itype = type[i]; + lcomp[itype-1]++; for (int jj = 0; jj < jnum; jj++) { int j = d_neighbors(i,jj); j &= NEIGHMASK; - jtype = type[j]; + int jtype = type[j]; const F_FLOAT delx = x(j,0) - xtmp; const F_FLOAT dely = x(j,1) - ytmp; @@ -162,12 +165,20 @@ void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalComp, con const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; if (rsq < cutsq) { count++; - lcomp[jtype]++; + lcomp[jtype-1]++; } } - for (int n = 0 n < 4; n++) { - d_result(i,n+1) = lcomp[n] / density; - } + + // total count of atoms found in sampled radius range + + d_result(i,0) = count; + + // local comp fractions per element + + double lfac = 1.0 / count; + for (int n = 0; n < ntypes; n++) + d_result(i,n+1) = lcomp[n] * lfac; + } } } diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.h b/src/KOKKOS/compute_local_comp_atom_kokkos.h index 5f9baa2af0..2f1c6ea3d4 100644 --- a/src/KOKKOS/compute_local_comp_atom_kokkos.h +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.h @@ -48,7 +48,6 @@ template class ComputeLocalCompAtomKokkos : public ComputeLoc private: typename AT::t_x_array x; - typename AT::t_v_array v; typename ArrayTypes::t_int_1d type; typename ArrayTypes::t_int_1d mask; From 9eb32fc6b09f6ab5ae0c53edc837dff8101fc5a2 Mon Sep 17 00:00:00 2001 From: "Megan J. McCarthy" Date: Sat, 10 Jun 2023 07:54:40 -0600 Subject: [PATCH 11/25] fix memory allocation runtime error --- src/EXTRA-COMPUTE/compute_local_comp_atom.cpp | 18 ++-- src/EXTRA-COMPUTE/compute_local_comp_atom.h | 4 +- src/KOKKOS/compute_local_comp_atom_kokkos.cpp | 97 +++++++++++-------- src/KOKKOS/compute_local_comp_atom_kokkos.h | 2 + 4 files changed, 69 insertions(+), 52 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp index 50ad3ce72c..bb3f068bd7 100644 --- a/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp @@ -42,8 +42,6 @@ ComputeLocalCompAtom::ComputeLocalCompAtom(LAMMPS *lmp, int narg, char **arg) : { if (narg < 3 || narg > 5) error->all(FLERR, "Illegal compute local/comp/atom command"); - int ntypes = atom->ntypes; - cutoff = 0.0; int iarg = 3; @@ -59,6 +57,7 @@ ComputeLocalCompAtom::ComputeLocalCompAtom(LAMMPS *lmp, int narg, char **arg) : peratom_flag = 1; + ntypes = atom->ntypes; size_peratom_cols = 1 + ntypes; nmax = 0; @@ -71,6 +70,7 @@ ComputeLocalCompAtom::~ComputeLocalCompAtom() if (copymode) return; memory->destroy(result); + memory->destroy(lcomp); } /* ---------------------------------------------------------------------- */ @@ -108,6 +108,7 @@ void ComputeLocalCompAtom::init() auto req = neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); if (cutflag) req->set_cutoff(cutoff); + } /* ---------------------------------------------------------------------- */ @@ -125,6 +126,9 @@ void ComputeLocalCompAtom::compute_peratom() double xtmp, ytmp, ztmp, delx, dely, delz, rsq; int *ilist, *jlist, *numneigh, **firstneigh; int count, itype, jtype; + // int lcomp[ntypes]; + + memory->create(lcomp, ntypes, "local/comp/atom:lcomp"); invoked_peratom = update->ntimestep; @@ -153,20 +157,14 @@ void ComputeLocalCompAtom::compute_peratom() int *type = atom->type; int *mask = atom->mask; - int typeone_i, typeone_j; - - int ntypes = atom->ntypes; - - int lcomp[ntypes]; - // get per-atom local compositions for (ii = 0; ii < inum; ii++) { - for (int i = 0; i < ntypes; i++) lcomp[i] = 0; - i = ilist[ii]; + for (int m = 0; m < ntypes; m++) lcomp[m] = 0.0; + if (mask[i] & groupbit) { xtmp = x[i][0]; diff --git a/src/EXTRA-COMPUTE/compute_local_comp_atom.h b/src/EXTRA-COMPUTE/compute_local_comp_atom.h index 22e40edab9..8ec5cb685f 100644 --- a/src/EXTRA-COMPUTE/compute_local_comp_atom.h +++ b/src/EXTRA-COMPUTE/compute_local_comp_atom.h @@ -34,11 +34,13 @@ class ComputeLocalCompAtom : public Compute { double memory_usage() override; protected: - int nmax; + int nmax, ntypes; double cutoff; // global cutoff distance double cutsq; // cutoff**2 class NeighList *list; // neighbor list + int *lcomp; // peratom array to track local compositions + double **result; // peratom array of local compositions }; diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp index 5dbe436e29..426ad28e0c 100644 --- a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing author: Stan Moore (SNL), Megan McCarthy (SNL) + Contributing authors: Stan Moore (SNL), Megan McCarthy (SNL) ------------------------------------------------------------------------- */ #include "compute_local_comp_atom_kokkos.h" @@ -42,11 +42,13 @@ template ComputeLocalCompAtomKokkos::ComputeLocalCompAtomKokkos(LAMMPS *lmp, int narg, char **arg) : ComputeLocalCompAtom(lmp, narg, arg) { + kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = EMPTY_MASK; datamask_modify = EMPTY_MASK; + } /* ---------------------------------------------------------------------- */ @@ -57,6 +59,7 @@ ComputeLocalCompAtomKokkos::~ComputeLocalCompAtomKokkos() if (copymode) return; memoryKK->destroy_kokkos(k_result,result); + memoryKK->destroy_kokkos(k_lcomp,lcomp); } /* ---------------------------------------------------------------------- */ @@ -79,6 +82,7 @@ void ComputeLocalCompAtomKokkos::init() template void ComputeLocalCompAtomKokkos::compute_peratom() { + invoked_peratom = update->ntimestep; // grow result array if necessary @@ -90,8 +94,16 @@ void ComputeLocalCompAtomKokkos::compute_peratom() memoryKK->create_kokkos(k_result,result,nmax,size_peratom_cols,"local/comp/atom:result"); d_result = k_result.view(); array_atom = result; + + memoryKK->destroy_kokkos(k_lcomp,lcomp); + nmax = atom->nmax; + memoryKK->create_kokkos(k_lcomp,lcomp,nmax,"local/comp/atom:result"); + d_lcomp = k_lcomp.view(); } + memoryKK->create_kokkos(k_lcomp,lcomp,size_peratom_cols,"local/comp/atom:lcomp"); + d_lcomp = k_lcomp.view(); + // invoke full neighbor list (will copy or build if necessary) neighbor->build_one(list); @@ -105,12 +117,14 @@ void ComputeLocalCompAtomKokkos::compute_peratom() // compute properties for each atom in group // use full neighbor list to count atoms less than cutoff - atomKK->sync(execution_space,X_MASK|V_MASK|RMASS_MASK|TYPE_MASK|MASK_MASK); + atomKK->sync(execution_space,X_MASK|TYPE_MASK|MASK_MASK); x = atomKK->k_x.view(); type = atomKK->k_type.view(); mask = atomKK->k_mask.view(); - + ntypes = atom->ntypes; + Kokkos::deep_copy(d_result,0.0); + Kokkos::deep_copy(d_lcomp,0.0); copymode = 1; typename Kokkos::RangePolicy policy(0,inum); @@ -119,66 +133,67 @@ void ComputeLocalCompAtomKokkos::compute_peratom() k_result.modify(); k_result.sync_host(); + + k_lcomp.modify(); + k_lcomp.sync_host(); } template KOKKOS_INLINE_FUNCTION void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, const int &ii) const { - double typeone_i, typeone_j; - int ntypes = atom->ntypes; - int lcomp[ntypes]; + const int i = d_ilist[ii]; - // get per-atom local compositions + // initialize / reset lcomp - int inum = list->inum; - for (int ii = 0; ii < inum; ii++) { + for (int m = 0; m < ntypes; m++) d_lcomp(m) = 0; + // for (int m = 0; m < ntypes; m++) d_result(i,m) = 0; - for (int i = 0; i < ntypes; i++) lcomp[i] = 0; + if (mask[i] & groupbit) { - const int i = d_ilist[ii]; + const X_FLOAT xtmp = x(i,0); + const X_FLOAT ytmp = x(i,1); + const X_FLOAT ztmp = x(i,2); + const int jnum = d_numneigh[i]; - if (mask[i] & groupbit) { + // i atom contribution - const X_FLOAT xtmp = x(i,0); - const X_FLOAT ytmp = x(i,1); - const X_FLOAT ztmp = x(i,2); - const int jnum = d_numneigh[i]; + int count = 1; + int itype = type[i]; + d_lcomp(itype-1)++; + // d_result(i,itype-1)++; - // i atom contribution + for (int jj = 0; jj < jnum; jj++) { - int count = 1; + int j = d_neighbors(i,jj); + j &= NEIGHMASK; - int itype = type[i]; - lcomp[itype-1]++; + int jtype = type[j]; - for (int jj = 0; jj < jnum; jj++) { - int j = d_neighbors(i,jj); - j &= NEIGHMASK; - - int jtype = type[j]; - - const F_FLOAT delx = x(j,0) - xtmp; - const F_FLOAT dely = x(j,1) - ytmp; - const F_FLOAT delz = x(j,2) - ztmp; - const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < cutsq) { - count++; - lcomp[jtype-1]++; - } + const F_FLOAT delx = x(j,0) - xtmp; + const F_FLOAT dely = x(j,1) - ytmp; + const F_FLOAT delz = x(j,2) - ztmp; + const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; + if (rsq < cutsq) { + count++; + d_lcomp(jtype-1)++; + // d_result(i,jtype-1)++; } - // total count of atoms found in sampled radius range + // total count of atoms found in sampled radius range - d_result(i,0) = count; + d_result(i,0) = count; - // local comp fractions per element + // local comp fractions per + + double lfac = 1.0 / count; + + for (int n = 0; n < ntypes; n++) { + d_result(i,n+1) = d_lcomp(n+1) * lfac; + // d_result(i,n+1) = d_result(i,n+1) * lfac; + } - double lfac = 1.0 / count; - for (int n = 0; n < ntypes; n++) - d_result(i,n+1) = lcomp[n] * lfac; - } } } diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.h b/src/KOKKOS/compute_local_comp_atom_kokkos.h index 2f1c6ea3d4..8b8a74b1af 100644 --- a/src/KOKKOS/compute_local_comp_atom_kokkos.h +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.h @@ -55,7 +55,9 @@ template class ComputeLocalCompAtomKokkos : public ComputeLoc typename AT::t_int_1d d_ilist; typename AT::t_int_1d d_numneigh; + DAT::tdual_int_1d k_lcomp; DAT::tdual_float_2d k_result; + typename AT::t_int_1d d_lcomp; typename AT::t_float_2d d_result; }; From 38fd78b867ecc683531e155c9d5d7e1fa006f1c4 Mon Sep 17 00:00:00 2001 From: "Megan J. McCarthy" Date: Sat, 10 Jun 2023 09:11:09 -0600 Subject: [PATCH 12/25] factor out variable lcomp --- src/KOKKOS/compute_local_comp_atom_kokkos.cpp | 46 +++++++++---------- src/KOKKOS/compute_local_comp_atom_kokkos.h | 4 +- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp index 426ad28e0c..20caa00df0 100644 --- a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp @@ -59,7 +59,7 @@ ComputeLocalCompAtomKokkos::~ComputeLocalCompAtomKokkos() if (copymode) return; memoryKK->destroy_kokkos(k_result,result); - memoryKK->destroy_kokkos(k_lcomp,lcomp); + // memoryKK->destroy_kokkos(k_lcomp,lcomp); } /* ---------------------------------------------------------------------- */ @@ -94,15 +94,10 @@ void ComputeLocalCompAtomKokkos::compute_peratom() memoryKK->create_kokkos(k_result,result,nmax,size_peratom_cols,"local/comp/atom:result"); d_result = k_result.view(); array_atom = result; - - memoryKK->destroy_kokkos(k_lcomp,lcomp); - nmax = atom->nmax; - memoryKK->create_kokkos(k_lcomp,lcomp,nmax,"local/comp/atom:result"); - d_lcomp = k_lcomp.view(); } - memoryKK->create_kokkos(k_lcomp,lcomp,size_peratom_cols,"local/comp/atom:lcomp"); - d_lcomp = k_lcomp.view(); + // memoryKK->create_kokkos(k_lcomp,lcomp,size_peratom_cols,"local/comp/atom:lcomp"); + // d_lcomp = k_lcomp.view(); // invoke full neighbor list (will copy or build if necessary) @@ -122,9 +117,8 @@ void ComputeLocalCompAtomKokkos::compute_peratom() type = atomKK->k_type.view(); mask = atomKK->k_mask.view(); ntypes = atom->ntypes; - + Kokkos::deep_copy(d_result,0.0); - Kokkos::deep_copy(d_lcomp,0.0); copymode = 1; typename Kokkos::RangePolicy policy(0,inum); @@ -134,8 +128,6 @@ void ComputeLocalCompAtomKokkos::compute_peratom() k_result.modify(); k_result.sync_host(); - k_lcomp.modify(); - k_lcomp.sync_host(); } template @@ -145,13 +137,13 @@ void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, const int i = d_ilist[ii]; - // initialize / reset lcomp - - for (int m = 0; m < ntypes; m++) d_lcomp(m) = 0; - // for (int m = 0; m < ntypes; m++) d_result(i,m) = 0; - if (mask[i] & groupbit) { + // initialize / reset lcomp + + // for (int m = 0; m < ntypes; m++) d_lcomp(m) = 0; + // for (int m = 0; m < size_peratom_cols; m++) d_result(i,m) = 0.0; + const X_FLOAT xtmp = x(i,0); const X_FLOAT ytmp = x(i,1); const X_FLOAT ztmp = x(i,2); @@ -161,8 +153,10 @@ void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, int count = 1; int itype = type[i]; - d_lcomp(itype-1)++; - // d_result(i,itype-1)++; + + // d_lcomp(itype-1)++; + // d_result(i,itype-1) = d_result(i,itype-1) + 1; + d_result(i,itype)++; for (int jj = 0; jj < jnum; jj++) { @@ -177,8 +171,9 @@ void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; if (rsq < cutsq) { count++; - d_lcomp(jtype-1)++; - // d_result(i,jtype-1)++; + // d_lcomp(jtype-1)++; + // d_result(i,jtype) = d_result(i,jtype) + 1; + d_result(i,jtype)++; } // total count of atoms found in sampled radius range @@ -189,10 +184,11 @@ void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, double lfac = 1.0 / count; - for (int n = 0; n < ntypes; n++) { - d_result(i,n+1) = d_lcomp(n+1) * lfac; - // d_result(i,n+1) = d_result(i,n+1) * lfac; - } + // for (int n = 1; n < size_peratom_cols; n++) { + // // d_result(i,n+1) = d_lcomp(n+1) * lfac; + // d_result(i,n) = d_result(i,n) * lfac; + // // d_result(i,n+1) = 123.0; + // } } } diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.h b/src/KOKKOS/compute_local_comp_atom_kokkos.h index 8b8a74b1af..bf0f69de55 100644 --- a/src/KOKKOS/compute_local_comp_atom_kokkos.h +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.h @@ -55,9 +55,9 @@ template class ComputeLocalCompAtomKokkos : public ComputeLoc typename AT::t_int_1d d_ilist; typename AT::t_int_1d d_numneigh; - DAT::tdual_int_1d k_lcomp; +// DAT::tdual_int_1d k_lcomp; DAT::tdual_float_2d k_result; - typename AT::t_int_1d d_lcomp; +// typename AT::t_int_1d d_lcomp; typename AT::t_float_2d d_result; }; From 378ef4b23e26f570a8257206943e8df820e9e2da Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 30 Jun 2023 22:59:41 -0400 Subject: [PATCH 13/25] require CMake version 3.16 --- cmake/CMakeLists.jpeg | 5 +++-- cmake/CMakeLists.png | 4 ++-- cmake/CMakeLists.txt | 3 ++- cmake/CMakeLists.zlib | 5 +++-- examples/COUPLE/plugin/CMakeLists.txt | 5 ++--- examples/COUPLE/simple/CMakeLists.txt | 4 +++- examples/PACKAGES/pace/plugin/CMakeLists.txt | 5 ++--- examples/kim/plugin/CMakeLists.txt | 3 +-- examples/plugins/CMakeLists.txt | 5 ++--- tools/phonon/CMakeLists.spglib | 4 ++-- tools/phonon/CMakeLists.txt | 3 ++- tools/phonon/tricubic/CMakeLists.txt | 3 ++- tools/swig/CMakeLists.txt | 4 ++-- unittest/CMakeLists.txt | 5 ++--- unittest/c-library/CMakeLists.txt | 1 + unittest/commands/CMakeLists.txt | 1 + unittest/cplusplus/CMakeLists.txt | 1 + unittest/force-styles/CMakeLists.libyaml | 2 +- unittest/force-styles/CMakeLists.txt | 1 + unittest/formats/CMakeLists.txt | 1 + unittest/fortran/CMakeLists.txt | 2 ++ unittest/python/CMakeLists.txt | 9 +++++---- unittest/tools/CMakeLists.txt | 1 + unittest/utils/CMakeLists.txt | 1 + 24 files changed, 45 insertions(+), 33 deletions(-) diff --git a/cmake/CMakeLists.jpeg b/cmake/CMakeLists.jpeg index f0bd85a90d..74231eea04 100644 --- a/cmake/CMakeLists.jpeg +++ b/cmake/CMakeLists.jpeg @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.10) +# -*- CMake -*- configuration for file for building libjpeg-turbo +cmake_minimum_required(VERSION 3.16) # When using CMake 3.4 and later, don't export symbols from executables unless # the CMAKE_ENABLE_EXPORTS variable is set. if(POLICY CMP0065) @@ -612,4 +613,4 @@ else() set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}") set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c) set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c) -endif() \ No newline at end of file +endif() diff --git a/cmake/CMakeLists.png b/cmake/CMakeLists.png index 2521ab41be..0632044396 100644 --- a/cmake/CMakeLists.png +++ b/cmake/CMakeLists.png @@ -1,4 +1,4 @@ -# CMakeLists.txt +# -*- CMake -*- configuration for file for building libpng # Copyright (C) 2018 Cosmin Truta # Copyright (C) 2007,2009-2018 Glenn Randers-Pehrson @@ -18,7 +18,7 @@ # For conditions of distribution and use, see the disclaimer # and license in png.h -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) cmake_policy(VERSION 3.1) # When using CMake 3.4 and later, don't export symbols from executables unless # the CMAKE_ENABLE_EXPORTS variable is set. diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 88b7ec422e..24b08ae667 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1,8 +1,9 @@ +# -*- CMake -*- master configuration file for building LAMMPS ######################################## # CMake build system # This file is part of LAMMPS # Created by Christoph Junghans and Richard Berger -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) ######################################## # set policy to silence warnings about ignoring _ROOT but use it if(POLICY CMP0074) diff --git a/cmake/CMakeLists.zlib b/cmake/CMakeLists.zlib index a33f14ce64..8496c6d7be 100644 --- a/cmake/CMakeLists.zlib +++ b/cmake/CMakeLists.zlib @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.10) +# -*- CMake -*- configuration for file for building libz +cmake_minimum_required(VERSION 3.16) # When using CMake 3.4 and later, don't export symbols from executables unless # the CMAKE_ENABLE_EXPORTS variable is set. if(POLICY CMP0065) @@ -192,4 +193,4 @@ add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZL if(UNIX) # On unix-like platforms the library is almost always called libz set_target_properties(zlibstatic PROPERTIES OUTPUT_NAME z) -endif() \ No newline at end of file +endif() diff --git a/examples/COUPLE/plugin/CMakeLists.txt b/examples/COUPLE/plugin/CMakeLists.txt index f4064d3f65..0e0371d47b 100644 --- a/examples/COUPLE/plugin/CMakeLists.txt +++ b/examples/COUPLE/plugin/CMakeLists.txt @@ -1,9 +1,8 @@ -########################################## -# CMake build system for coupling to the LAMMPS library +# -*- CMake -*- file for example programs that use the LAMMPS library # where the library is loaded dynamically at runtime. ########################################## -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) # enforce out-of-source build if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) diff --git a/examples/COUPLE/simple/CMakeLists.txt b/examples/COUPLE/simple/CMakeLists.txt index 14c253e5a1..9e5bb1057d 100644 --- a/examples/COUPLE/simple/CMakeLists.txt +++ b/examples/COUPLE/simple/CMakeLists.txt @@ -1,4 +1,6 @@ -cmake_minimum_required(VERSION 3.10) +# -*- CMake -*- file for simple examples using the LAMMPS library interface + +cmake_minimum_required(VERSION 3.16) # enforce out-of-source build if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) diff --git a/examples/PACKAGES/pace/plugin/CMakeLists.txt b/examples/PACKAGES/pace/plugin/CMakeLists.txt index 25fa877ffc..0701a754c4 100644 --- a/examples/PACKAGES/pace/plugin/CMakeLists.txt +++ b/examples/PACKAGES/pace/plugin/CMakeLists.txt @@ -1,10 +1,9 @@ -########################################## -# CMake build system for plugin examples. +# -*- CMake -*- build system for plugin examples. # The is meant to be used as a template for plugins that are # distributed independent from the LAMMPS package. ########################################## -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(paceplugin VERSION 1.0 LANGUAGES CXX) diff --git a/examples/kim/plugin/CMakeLists.txt b/examples/kim/plugin/CMakeLists.txt index 78d117469d..367c0b5b78 100644 --- a/examples/kim/plugin/CMakeLists.txt +++ b/examples/kim/plugin/CMakeLists.txt @@ -1,5 +1,4 @@ -########################################## -# CMake build system for plugin examples. +# -*- CMake -*- file for building plugins. # The is meant to be used as a template for plugins that are # distributed independent from the LAMMPS package. ########################################## diff --git a/examples/plugins/CMakeLists.txt b/examples/plugins/CMakeLists.txt index 688835de56..a9c8f41f74 100644 --- a/examples/plugins/CMakeLists.txt +++ b/examples/plugins/CMakeLists.txt @@ -1,10 +1,9 @@ -########################################## -# CMake build system for plugin examples. +# -*- CMake -*- file for plugin examples. # The is meant to be used as a template for plugins that are # distributed independent from the LAMMPS package. ########################################## -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) # enforce out-of-source build if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) diff --git a/tools/phonon/CMakeLists.spglib b/tools/phonon/CMakeLists.spglib index 566e58a2b6..65299a18e2 100644 --- a/tools/phonon/CMakeLists.spglib +++ b/tools/phonon/CMakeLists.spglib @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.10) +# -*- CMake -*- file for building spglib for phana +cmake_minimum_required(VERSION 3.16) project(spglib C) set(CMAKE_MACOSX_RPATH 1) set(CMAKE_C_FLAGS_RELEASE "-Wall -O2") @@ -10,7 +11,6 @@ message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") set(CMAKE_POSITION_INDEPENDENT_CODE ON) - # Version numbers file(READ ${PROJECT_SOURCE_DIR}/src/version.h version_file) string(REGEX MATCH "SPGLIB_MAJOR_VERSION ([0-9]+)" spglib_major_version ${version_file}) diff --git a/tools/phonon/CMakeLists.txt b/tools/phonon/CMakeLists.txt index 60da1cc79f..f3b9e53201 100644 --- a/tools/phonon/CMakeLists.txt +++ b/tools/phonon/CMakeLists.txt @@ -1,7 +1,8 @@ +# -*- CMake -*- configuration for building the PHONON package analysis tool: phana # Support Linux from Ubuntu 20.04LTS onward, CentOS 7.x (with EPEL), # macOS, MSVC 2019 (=Version 16) -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) # set timestamp of downloaded files to that of archive if(POLICY CMP0135) diff --git a/tools/phonon/tricubic/CMakeLists.txt b/tools/phonon/tricubic/CMakeLists.txt index 190c6ceb80..f3a229c410 100644 --- a/tools/phonon/tricubic/CMakeLists.txt +++ b/tools/phonon/tricubic/CMakeLists.txt @@ -1,7 +1,8 @@ +# -*- CMake -*- configuration for building the tricubic library # Support Linux from Ubuntu 20.04LTS onward, CentOS 7.x (with EPEL), # macOS, MSVC 2019 (=Version 16) -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) # set up project project(tricubic VERSION 1.1 DESCRIPTION "Tricubic library" LANGUAGES CXX) diff --git a/tools/swig/CMakeLists.txt b/tools/swig/CMakeLists.txt index 966837dc2f..162d2702c4 100644 --- a/tools/swig/CMakeLists.txt +++ b/tools/swig/CMakeLists.txt @@ -1,7 +1,7 @@ -# CMake configuration for generating script language interfaces with SWIG +# -*- CMake -*- configuration for generating LAMMPS script language wrappers with SWIG # set minimum CMake version required and switch to new policies for SWIG -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) if(POLICY CMP0078) cmake_policy(SET CMP0078 NEW) endif() diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index f7be54f9ae..cad6c3213c 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1,10 +1,9 @@ -######################################## -# CMake build for automated testing +# -*- CMake -*- build file for automated testing # This file is part of LAMMPS # Created by Axel Kohlmeyer and Richard Berger ######################################## -# download and build googletest framework +# download and build googletest framework # cannot compile googletest anymore with the default GCC on RHEL 7.x if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)) message(FATAL_ERROR "Need GNU C++ compiler version 6.x or later for unit testing") diff --git a/unittest/c-library/CMakeLists.txt b/unittest/c-library/CMakeLists.txt index 3e5b7a8cc0..8dcb9d5c5b 100644 --- a/unittest/c-library/CMakeLists.txt +++ b/unittest/c-library/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for testing the c-library interface add_executable(test_library_open test_library_open.cpp test_main.cpp) target_link_libraries(test_library_open PRIVATE lammps GTest::GMock) diff --git a/unittest/commands/CMakeLists.txt b/unittest/commands/CMakeLists.txt index aa1bd22fa4..f6a73b56b3 100644 --- a/unittest/commands/CMakeLists.txt +++ b/unittest/commands/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for testing LAMMPS commands add_executable(test_simple_commands test_simple_commands.cpp) diff --git a/unittest/cplusplus/CMakeLists.txt b/unittest/cplusplus/CMakeLists.txt index 9199e20792..445e0fffeb 100644 --- a/unittest/cplusplus/CMakeLists.txt +++ b/unittest/cplusplus/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for testing the direct calls to individual C++ classes add_executable(test_lammps_class test_lammps_class.cpp) target_link_libraries(test_lammps_class PRIVATE lammps GTest::GMockMain) diff --git a/unittest/force-styles/CMakeLists.libyaml b/unittest/force-styles/CMakeLists.libyaml index 51e8589f7b..8d4760f18c 100644 --- a/unittest/force-styles/CMakeLists.libyaml +++ b/unittest/force-styles/CMakeLists.libyaml @@ -1,6 +1,6 @@ # Custom minimal -*- CMake -*- file for libyaml -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(libyaml VERSION 0.2.5 DESCRIPTION "LibYAML a YAML parser and emitter library" LANGUAGES C diff --git a/unittest/force-styles/CMakeLists.txt b/unittest/force-styles/CMakeLists.txt index dfffdfea0c..5742bb6436 100644 --- a/unittest/force-styles/CMakeLists.txt +++ b/unittest/force-styles/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for tests of classes computing or modifying forces find_package(YAML) if(NOT YAML_FOUND) diff --git a/unittest/formats/CMakeLists.txt b/unittest/formats/CMakeLists.txt index 5b5dd056c9..93ea2f3b32 100644 --- a/unittest/formats/CMakeLists.txt +++ b/unittest/formats/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for tests of file reading or writing classes and functions in LAMMPS add_executable(test_atom_styles test_atom_styles.cpp) target_link_libraries(test_atom_styles PRIVATE lammps GTest::GMock) diff --git a/unittest/fortran/CMakeLists.txt b/unittest/fortran/CMakeLists.txt index 6d6fe4cd54..de6b6cf7a8 100644 --- a/unittest/fortran/CMakeLists.txt +++ b/unittest/fortran/CMakeLists.txt @@ -1,3 +1,5 @@ +# -*- CMake -*- file for testing the Fortran interface to LAMMPS + include(CheckGeneratorSupport) if(NOT CMAKE_GENERATOR_SUPPORT_FORTRAN) message(STATUS "Skipping Tests for the LAMMPS Fortran Module: no Fortran support in build tool") diff --git a/unittest/python/CMakeLists.txt b/unittest/python/CMakeLists.txt index fbd7ca0672..fd18d7463d 100644 --- a/unittest/python/CMakeLists.txt +++ b/unittest/python/CMakeLists.txt @@ -1,7 +1,8 @@ -# Test calling Python from LAMMPS (and importing the LAMMPS module -# inside those functions). This can do an "anonymous" import of symbols -# from the executable, so the shared library is not needed. The -# availability of the PYTHON package is tested for inside the tester. +# -*- CMake -*- file for tests calling Python from LAMMPS (and importing +# the LAMMPS module inside those functions). This can do an "anonymous" +# import of symbols from the executable, so the shared library is not +# needed. The availability of the PYTHON package is tested for inside +# the tester. set(TEST_INPUT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/unittest/tools/CMakeLists.txt b/unittest/tools/CMakeLists.txt index 4e0180311e..15576c60c1 100644 --- a/unittest/tools/CMakeLists.txt +++ b/unittest/tools/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for tests of utily functions and classes in LAMMPS # we use python 3's subprocess module to run the tools and check the output if(CMAKE_VERSION VERSION_LESS 3.12) diff --git a/unittest/utils/CMakeLists.txt b/unittest/utils/CMakeLists.txt index 8c1a5a3f6a..c277a0353b 100644 --- a/unittest/utils/CMakeLists.txt +++ b/unittest/utils/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- CMake -*- file for tests of utily functions and classes in LAMMPS add_executable(test_tokenizer test_tokenizer.cpp) target_link_libraries(test_tokenizer PRIVATE lammps GTest::GMockMain) From 71b48253e871caa753aaadb63566d552759565da Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 30 Jun 2023 23:15:37 -0400 Subject: [PATCH 14/25] remove special case CMake code for versions before 3.16 --- cmake/CMakeLists.txt | 41 +++++++--------------------- cmake/Modules/CodingStandard.cmake | 18 ++++-------- cmake/Modules/Documentation.cmake | 24 ++++++---------- cmake/Modules/FindCythonize.cmake | 10 +------ cmake/Modules/Packages/KIM.cmake | 7 +---- cmake/Modules/Packages/MDI.cmake | 34 ++++------------------- cmake/Modules/Packages/ML-IAP.cmake | 21 +++----------- cmake/Modules/Packages/PYTHON.cmake | 34 ++++++----------------- cmake/Modules/Testing.cmake | 26 ++++-------------- examples/kim/plugin/CMakeLists.txt | 9 ++---- unittest/CMakeLists.txt | 6 +--- unittest/force-styles/CMakeLists.txt | 17 ++---------- unittest/python/CMakeLists.txt | 10 +------ unittest/tools/CMakeLists.txt | 10 ++----- 14 files changed, 57 insertions(+), 210 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 24b08ae667..3393a56682 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -22,13 +22,8 @@ endif() if(POLICY CMP0135) cmake_policy(SET CMP0135 OLD) endif() -######################################## -# Use CONFIGURE_DEPENDS as option for file(GLOB...) when available -if(CMAKE_VERSION VERSION_LESS 3.12) - unset(CONFIGURE_DEPENDS) -else() - set(CONFIGURE_DEPENDS CONFIGURE_DEPENDS) -endif() + +set(CONFIGURE_DEPENDS CONFIGURE_DEPENDS) ######################################## project(lammps CXX) @@ -466,12 +461,7 @@ option(WITH_JPEG "Enable JPEG support" ${JPEG_FOUND}) if(WITH_JPEG) find_package(JPEG REQUIRED) target_compile_definitions(lammps PRIVATE -DLAMMPS_JPEG) - if(CMAKE_VERSION VERSION_LESS 3.12) - target_include_directories(lammps PRIVATE ${JPEG_INCLUDE_DIRS}) - target_link_libraries(lammps PRIVATE ${JPEG_LIBRARIES}) - else() - target_link_libraries(lammps PRIVATE JPEG::JPEG) - endif() + target_link_libraries(lammps PRIVATE JPEG::JPEG) endif() find_package(PNG QUIET) @@ -819,20 +809,11 @@ install( # This is primarily for people that only want to use the Python wrapper. ############################################################################### if(BUILD_SHARED_LIBS) - if(CMAKE_VERSION VERSION_LESS 3.12) - # adjust so we find Python 3 versions before Python 2 on old systems with old CMake - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - else() - # backward compatibility - if(PYTHON_EXECUTABLE) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - find_package(Python COMPONENTS Interpreter) + # backward compatibility + if(PYTHON_EXECUTABLE) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) endif() + find_package(Python COMPONENTS Interpreter) if(BUILD_IS_MULTI_CONFIG) set(MY_BUILD_DIR ${CMAKE_BINARY_DIR}/$) else() @@ -941,11 +922,9 @@ if(_index GREATER -1) endif() message(STATUS "<<< Linker flags: >>>") message(STATUS "Executable name: ${LAMMPS_BINARY}") -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) - get_target_property(OPTIONS lammps LINK_OPTIONS) - if(OPTIONS) - message(STATUS "Linker options: ${OPTIONS}") - endif() +get_target_property(OPTIONS lammps LINK_OPTIONS) +if(OPTIONS) + message(STATUS "Linker options: ${OPTIONS}") endif() if(CMAKE_EXE_LINKER_FLAGS) message(STATUS "Executable linker flags: ${CMAKE_EXE_LINKER_FLAGS}") diff --git a/cmake/Modules/CodingStandard.cmake b/cmake/Modules/CodingStandard.cmake index 4efd373d22..94639c7771 100644 --- a/cmake/Modules/CodingStandard.cmake +++ b/cmake/Modules/CodingStandard.cmake @@ -1,19 +1,11 @@ -if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.5 QUIET) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) - set(Python3_VERSION ${PYTHON_VERSION_STRING}) - endif() -else() - # use default (or custom) Python executable, if version is sufficient - if(Python_VERSION VERSION_GREATER_EQUAL 3.5) - set(Python3_EXECUTABLE ${Python_EXECUTABLE}) - endif() - find_package(Python3 COMPONENTS Interpreter QUIET) +# use default (or custom) Python executable, if version is sufficient +if(Python_VERSION VERSION_GREATER_EQUAL 3.6) + set(Python3_EXECUTABLE ${Python_EXECUTABLE}) endif() +find_package(Python3 COMPONENTS Interpreter) if(Python3_EXECUTABLE) - if(Python3_VERSION VERSION_GREATER_EQUAL 3.5) + if(Python3_VERSION VERSION_GREATER_EQUAL 3.6) add_custom_target( check-whitespace ${Python3_EXECUTABLE} ${LAMMPS_TOOLS_DIR}/coding_standard/whitespace.py . diff --git a/cmake/Modules/Documentation.cmake b/cmake/Modules/Documentation.cmake index 0b01407cd9..df9bf2b449 100644 --- a/cmake/Modules/Documentation.cmake +++ b/cmake/Modules/Documentation.cmake @@ -5,25 +5,19 @@ option(BUILD_DOC "Build LAMMPS HTML documentation" OFF) if(BUILD_DOC) # Current Sphinx versions require at least Python 3.8 - if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.8 REQUIRED) - set(VIRTUALENV ${PYTHON_EXECUTABLE} -m venv) - else() - # use default (or custom) Python executable, if version is sufficient - if(Python_VERSION VERSION_GREATER_EQUAL 3.8) - set(Python3_EXECUTABLE ${Python_EXECUTABLE}) - endif() - find_package(Python3 REQUIRED COMPONENTS Interpreter) - if(Python3_VERSION VERSION_LESS 3.8) - message(FATAL_ERROR "Python 3.8 and up is required to build the HTML documentation") - endif() - set(VIRTUALENV ${Python3_EXECUTABLE} -m venv) + # use default (or custom) Python executable, if version is sufficient + if(Python_VERSION VERSION_GREATER_EQUAL 3.8) + set(Python3_EXECUTABLE ${Python_EXECUTABLE}) endif() + find_package(Python3 REQUIRED COMPONENTS Interpreter) + if(Python3_VERSION VERSION_LESS 3.8) + message(FATAL_ERROR "Python 3.8 and up is required to build the HTML documentation") + endif() + set(VIRTUALENV ${Python3_EXECUTABLE} -m venv) + find_package(Doxygen 1.8.10 REQUIRED) - file(GLOB DOC_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_DOC_DIR}/src/[^.]*.rst) - add_custom_command( OUTPUT docenv COMMAND ${VIRTUALENV} docenv diff --git a/cmake/Modules/FindCythonize.cmake b/cmake/Modules/FindCythonize.cmake index 97f0304279..fe436aef28 100644 --- a/cmake/Modules/FindCythonize.cmake +++ b/cmake/Modules/FindCythonize.cmake @@ -7,15 +7,7 @@ # adapted from https://github.com/cmarshall108/cython-cmake-example/blob/master/cmake/FindCython.cmake #============================================================================= -if(CMAKE_VERSION VERSION_LESS 3.12) - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - find_package(PythonInterp 3.6 QUIET) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python 3.6 COMPONENTS Interpreter QUIET) -endif() +find_package(Python 3.6 COMPONENTS Interpreter QUIET) # Use the Cython executable that lives next to the Python executable # if it is a local installation. diff --git a/cmake/Modules/Packages/KIM.cmake b/cmake/Modules/Packages/KIM.cmake index 995d2d9490..d724ec18fc 100644 --- a/cmake/Modules/Packages/KIM.cmake +++ b/cmake/Modules/Packages/KIM.cmake @@ -1,12 +1,7 @@ set(KIM-API_MIN_VERSION 2.1.3) find_package(CURL) if(CURL_FOUND) - if(CMAKE_VERSION VERSION_LESS 3.12) - target_include_directories(lammps PRIVATE ${CURL_INCLUDE_DIRS}) - target_link_libraries(lammps PRIVATE ${CURL_LIBRARIES}) - else() - target_link_libraries(lammps PRIVATE CURL::libcurl) - endif() + 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) diff --git a/cmake/Modules/Packages/MDI.cmake b/cmake/Modules/Packages/MDI.cmake index dc3af94a0a..447b941d99 100644 --- a/cmake/Modules/Packages/MDI.cmake +++ b/cmake/Modules/Packages/MDI.cmake @@ -26,29 +26,9 @@ if(DOWNLOAD_MDI) # detect if we have python development support and thus can enable python plugins set(MDI_USE_PYTHON_PLUGINS OFF) - if(CMAKE_VERSION VERSION_LESS 3.12) - if(NOT PYTHON_VERSION_STRING) - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - # search for interpreter first, so we have a consistent library - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - endif() - # search for the library matching the selected interpreter - set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) - find_package(PythonLibs QUIET) # Deprecated since version 3.12 - if(PYTHONLIBS_FOUND) - if(NOT (PYTHON_VERSION_STRING STREQUAL PYTHONLIBS_VERSION_STRING)) - message(FATAL_ERROR "Python Library version ${PYTHONLIBS_VERSION_STRING} does not match Interpreter version ${PYTHON_VERSION_STRING}") - endif() - set(MDI_USE_PYTHON_PLUGINS ON) - endif() - else() - find_package(Python QUIET COMPONENTS Development) - if(Python_Development_FOUND) - set(MDI_USE_PYTHON_PLUGINS ON) - endif() + find_package(Python QUIET COMPONENTS Development) + if(Python_Development_FOUND) + set(MDI_USE_PYTHON_PLUGINS ON) endif() # python plugins are not supported and thus must be always off on Windows if(CMAKE_SYSTEM_NAME STREQUAL "Windows") @@ -102,13 +82,9 @@ if(DOWNLOAD_MDI) # if compiling with python plugins we need # to add python libraries as dependency. if(MDI_USE_PYTHON_PLUGINS) - if(CMAKE_VERSION VERSION_LESS 3.12) - list(APPEND MDI_DEP_LIBS ${PYTHON_LIBRARIES}) - else() - list(APPEND MDI_DEP_LIBS Python::Python) - endif() - + list(APPEND MDI_DEP_LIBS Python::Python) endif() + # need to add support for dlopen/dlsym, except when compiling for Windows. if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows")) list(APPEND MDI_DEP_LIBS "${CMAKE_DL_LIBS}") diff --git a/cmake/Modules/Packages/ML-IAP.cmake b/cmake/Modules/Packages/ML-IAP.cmake index f8439be538..2e9a02977d 100644 --- a/cmake/Modules/Packages/ML-IAP.cmake +++ b/cmake/Modules/Packages/ML-IAP.cmake @@ -2,12 +2,7 @@ set(MLIAP_ENABLE_PYTHON_DEFAULT OFF) if(PKG_PYTHON) find_package(Cythonize QUIET) - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.14) - find_package(Python COMPONENTS NumPy QUIET) - else() - # assume we have NumPy - set(Python_NumPy_FOUND ON) - endif() + find_package(Python COMPONENTS NumPy QUIET) if(Cythonize_FOUND AND Python_NumPy_FOUND) set(MLIAP_ENABLE_PYTHON_DEFAULT ON) endif() @@ -17,20 +12,12 @@ option(MLIAP_ENABLE_PYTHON "Build ML-IAP package with Python support" ${MLIAP_EN if(MLIAP_ENABLE_PYTHON) find_package(Cythonize REQUIRED) - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.14) - find_package(Python COMPONENTS NumPy REQUIRED) - endif() + find_package(Python COMPONENTS NumPy REQUIRED) if(NOT PKG_PYTHON) message(FATAL_ERROR "Must enable PYTHON package for including Python support in ML-IAP") endif() - if(CMAKE_VERSION VERSION_LESS 3.12) - if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3.6) - message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") - endif() - else() - if(Python_VERSION VERSION_LESS 3.6) - message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") - endif() + if(Python_VERSION VERSION_LESS 3.6) + message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") endif() set(MLIAP_BINARY_DIR ${CMAKE_BINARY_DIR}/cython) diff --git a/cmake/Modules/Packages/PYTHON.cmake b/cmake/Modules/Packages/PYTHON.cmake index 4a2925fe31..59260e39d5 100644 --- a/cmake/Modules/Packages/PYTHON.cmake +++ b/cmake/Modules/Packages/PYTHON.cmake @@ -1,29 +1,11 @@ -if(CMAKE_VERSION VERSION_LESS 3.12) - if(NOT PYTHON_VERSION_STRING) - set(Python_ADDITIONAL_VERSIONS 3.12 3.11 3.10 3.9 3.8 3.7 3.6) - # search for interpreter first, so we have a consistent library - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() + +if(NOT Python_INTERPRETER) + # backward compatibility + if(PYTHON_EXECUTABLE) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) endif() - # search for the library matching the selected interpreter - set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) - find_package(PythonLibs REQUIRED) # Deprecated since version 3.12 - if(NOT (PYTHON_VERSION_STRING STREQUAL PYTHONLIBS_VERSION_STRING)) - message(FATAL_ERROR "Python Library version ${PYTHONLIBS_VERSION_STRING} does not match Interpreter version ${PYTHON_VERSION_STRING}") - endif() - target_include_directories(lammps PRIVATE ${PYTHON_INCLUDE_DIRS}) - target_link_libraries(lammps PRIVATE ${PYTHON_LIBRARIES}) -else() - if(NOT Python_INTERPRETER) - # backward compatibility - if(PYTHON_EXECUTABLE) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() - find_package(Python COMPONENTS Interpreter) - endif() - find_package(Python REQUIRED COMPONENTS Interpreter Development) - target_link_libraries(lammps PRIVATE Python::Python) + find_package(Python COMPONENTS Interpreter) endif() +find_package(Python REQUIRED COMPONENTS Interpreter Development) +target_link_libraries(lammps PRIVATE Python::Python) target_compile_definitions(lammps PRIVATE -DLMP_PYTHON) diff --git a/cmake/Modules/Testing.cmake b/cmake/Modules/Testing.cmake index 5345211178..5bb8b512d3 100644 --- a/cmake/Modules/Testing.cmake +++ b/cmake/Modules/Testing.cmake @@ -19,7 +19,7 @@ if(ENABLE_TESTING) # we need to build and link a LOT of tester executables, so it is worth checking if # a faster linker is available. requires GNU or Clang compiler, newer CMake. # also only verified with Fedora Linux > 30 and Ubuntu 18.04 or 22.04+(Ubuntu 20.04 fails) - if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) + if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))) if(((CMAKE_LINUX_DISTRO STREQUAL "Ubuntu") AND ((CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04) OR (CMAKE_DISTRO_VERSION VERSION_GREATER_EQUAL 22.04))) @@ -66,16 +66,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) mark_as_advanced(ENABLE_COVERAGE) if(ENABLE_COVERAGE) - if(CMAKE_VERSION VERSION_LESS 3.13) - if(CMAKE_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") - endif() - else() - target_compile_options(lammps PUBLIC --coverage) - target_link_options(lammps PUBLIC --coverage) - endif() + target_compile_options(lammps PUBLIC --coverage) + target_link_options(lammps PUBLIC --coverage) endif() endif() @@ -118,16 +110,8 @@ validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES) string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER) if(NOT ENABLE_SANITIZER STREQUAL "none") if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) - if(CMAKE_VERSION VERSION_LESS 3.13) - if(CMAKE_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} -fsanitize=${ENABLE_SANITIZER}") - endif() - else() - target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) - target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) - endif() + target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) else() message(WARNING "ENABLE_SANITIZER option not supported by ${CMAKE_CXX_COMPILER_ID} compilers. Ignoring.") set(ENABLE_SANITIZER "none") diff --git a/examples/kim/plugin/CMakeLists.txt b/examples/kim/plugin/CMakeLists.txt index 367c0b5b78..999214f9b8 100644 --- a/examples/kim/plugin/CMakeLists.txt +++ b/examples/kim/plugin/CMakeLists.txt @@ -3,7 +3,7 @@ # distributed independent from the LAMMPS package. ########################################## -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(kimplugin VERSION 1.0 LANGUAGES CXX) @@ -30,12 +30,7 @@ target_link_libraries(kimplugin PRIVATE KIM-API::kim-api) # need libcurl find_package(CURL) if(CURL_FOUND) - if(CMAKE_VERSION VERSION_LESS 3.12) - target_include_directories(kimplugin PRIVATE ${CURL_INCLUDE_DIRS}) - target_link_libraries(kimplugin PRIVATE ${CURL_LIBRARIES}) - else() - target_link_libraries(kimplugin PRIVATE CURL::libcurl) - endif() + target_link_libraries(kimplugin PRIVATE CURL::libcurl) target_compile_definitions(kimplugin 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) diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index cad6c3213c..ba80e654bb 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -35,11 +35,7 @@ endforeach() # must repeat handling coverage for older CMake if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND ENABLE_COVERAGE) - if(CMAKE_VERSION VERSION_LESS 3.13) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") - endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") endif() ######################################## diff --git a/unittest/force-styles/CMakeLists.txt b/unittest/force-styles/CMakeLists.txt index 5742bb6436..21a1bd3eda 100644 --- a/unittest/force-styles/CMakeLists.txt +++ b/unittest/force-styles/CMakeLists.txt @@ -20,16 +20,7 @@ function(extract_tags out yaml_file) set(${out} "${TAGS}" PARENT_SCOPE) endfunction() -if(CMAKE_VERSION VERSION_LESS 3.12) - # adjust so we find Python 3 versions before Python 2 on old systems with old CMake - set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6 3.5) - find_package(PythonInterp) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python COMPONENTS Interpreter) -endif() +find_package(Python COMPONENTS Interpreter) if(Python_EXECUTABLE) add_custom_target(check-tests ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/check_tests.py @@ -54,10 +45,8 @@ target_link_libraries(style_tests PUBLIC GTest::GMock Yaml::Yaml lammps) # propagate sanitizer options to test tools if(ENABLE_SANITIZER AND (NOT (ENABLE_SANITIZER STREQUAL "none"))) - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) - target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) - target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) - endif() + target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) endif() # unit test for error stats class diff --git a/unittest/python/CMakeLists.txt b/unittest/python/CMakeLists.txt index fd18d7463d..ed56841733 100644 --- a/unittest/python/CMakeLists.txt +++ b/unittest/python/CMakeLists.txt @@ -12,20 +12,12 @@ if(NOT BUILD_SHARED_LIBS) return() endif() -if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.6) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python COMPONENTS Interpreter Development) -endif() +find_package(Python 3.6 COMPONENTS Interpreter Development) if(PKG_PYTHON) add_executable(test_python_package test_python_package.cpp) target_link_libraries(test_python_package PRIVATE lammps GTest::GMock) target_compile_definitions(test_python_package PRIVATE -DTEST_INPUT_FOLDER=${TEST_INPUT_FOLDER}) - # this requires CMake 3.12. don't care to add backward compatibility for this. if(Python_Development_FOUND) target_compile_definitions(test_python_package PRIVATE -DTEST_HAVE_PYTHON_DEVELOPMENT=1) target_link_libraries(test_python_package PRIVATE Python::Python) diff --git a/unittest/tools/CMakeLists.txt b/unittest/tools/CMakeLists.txt index 15576c60c1..7a496722d2 100644 --- a/unittest/tools/CMakeLists.txt +++ b/unittest/tools/CMakeLists.txt @@ -1,14 +1,8 @@ # -*- CMake -*- file for tests of utily functions and classes in LAMMPS # we use python 3's subprocess module to run the tools and check the output -if(CMAKE_VERSION VERSION_LESS 3.12) - find_package(PythonInterp 3.5) # Deprecated since version 3.12 - if(PYTHONINTERP_FOUND) - set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - endif() -else() - find_package(Python 3.5 COMPONENTS Interpreter) -endif() +find_package(Python 3.6 COMPONENTS Interpreter) + get_property(BUILD_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(BUILD_IS_MULTI_CONFIG) set(LAMMPS_SHELL_EXE_DIR ${CMAKE_BINARY_DIR}/$) From b50fc0be7899538b35006b0fbfa3da49ae0c9f5c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 30 Jun 2023 23:19:53 -0400 Subject: [PATCH 15/25] remove obsolete CONFIGURE_DEPENDS backward compatibility hack --- cmake/CMakeLists.txt | 17 ++++++++--------- cmake/Modules/Documentation.cmake | 4 ++-- cmake/Modules/LAMMPSInterfacePlugin.cmake | 2 +- cmake/Modules/LAMMPSUtils.cmake | 6 +++--- cmake/Modules/Packages/COLVARS.cmake | 2 +- cmake/Modules/Packages/GPU.cmake | 14 +++++++------- cmake/Modules/Packages/KOKKOS.cmake | 2 +- cmake/Modules/Packages/LEPTON.cmake | 4 ++-- cmake/Modules/Packages/ML-IAP.cmake | 2 +- cmake/Modules/StyleHeaderUtils.cmake | 4 ++-- cmake/Modules/Testing.cmake | 2 +- cmake/Modules/Tools.cmake | 2 +- unittest/force-styles/CMakeLists.txt | 18 +++++++++--------- 13 files changed, 39 insertions(+), 40 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 3393a56682..6e4ae62ee2 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -23,7 +23,6 @@ if(POLICY CMP0135) cmake_policy(SET CMP0135 OLD) endif() -set(CONFIGURE_DEPENDS CONFIGURE_DEPENDS) ######################################## project(lammps CXX) @@ -198,8 +197,8 @@ else() endif() include(GNUInstallDirs) -file(GLOB ALL_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_SOURCE_DIR}/[^.]*.cpp) -file(GLOB MAIN_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_SOURCE_DIR}/main.cpp) +file(GLOB ALL_SOURCES CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/[^.]*.cpp) +file(GLOB MAIN_SOURCES CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/main.cpp) list(REMOVE_ITEM ALL_SOURCES ${MAIN_SOURCES}) add_library(lammps ${ALL_SOURCES}) @@ -443,7 +442,7 @@ if(PKG_MSCG OR PKG_ATC OR PKG_AWPMD OR PKG_ML-QUIP OR PKG_ML-POD OR PKG_ELECTROD find_package(BLAS) endif() if(NOT LAPACK_FOUND OR NOT BLAS_FOUND OR USE_INTERNAL_LINALG) - file(GLOB LINALG_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.cpp) + file(GLOB LINALG_SOURCES CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.cpp) add_library(linalg STATIC ${LINALG_SOURCES}) set_target_properties(linalg PROPERTIES OUTPUT_NAME lammps_linalg${LAMMPS_MACHINE}) set(BLAS_LIBRARIES "$") @@ -573,8 +572,8 @@ endforeach() foreach(PKG ${STANDARD_PACKAGES}) set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) - file(GLOB ${PKG}_SOURCES ${CONFIGURE_DEPENDS} ${${PKG}_SOURCES_DIR}/[^.]*.cpp) - file(GLOB ${PKG}_HEADERS ${CONFIGURE_DEPENDS} ${${PKG}_SOURCES_DIR}/[^.]*.h) + file(GLOB ${PKG}_SOURCES CONFIGURE_DEPENDS ${${PKG}_SOURCES_DIR}/[^.]*.cpp) + file(GLOB ${PKG}_HEADERS CONFIGURE_DEPENDS ${${PKG}_SOURCES_DIR}/[^.]*.h) # check for package files in src directory due to old make system DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS}) @@ -601,8 +600,8 @@ endforeach() foreach(PKG ${SUFFIX_PACKAGES}) set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) - file(GLOB ${PKG}_SOURCES ${CONFIGURE_DEPENDS} ${${PKG}_SOURCES_DIR}/[^.]*.cpp) - file(GLOB ${PKG}_HEADERS ${CONFIGURE_DEPENDS} ${${PKG}_SOURCES_DIR}/[^.]*.h) + file(GLOB ${PKG}_SOURCES CONFIGURE_DEPENDS ${${PKG}_SOURCES_DIR}/[^.]*.cpp) + file(GLOB ${PKG}_HEADERS CONFIGURE_DEPENDS ${${PKG}_SOURCES_DIR}/[^.]*.h) # check for package files in src directory due to old make system DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS}) @@ -616,7 +615,7 @@ endforeach() foreach(PKG_LIB POEMS ATC AWPMD H5MD) if(PKG_${PKG_LIB}) string(TOLOWER "${PKG_LIB}" PKG_LIB) - file(GLOB_RECURSE ${PKG_LIB}_SOURCES ${CONFIGURE_DEPENDS} + file(GLOB_RECURSE ${PKG_LIB}_SOURCES CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.c ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.cpp) add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) set_target_properties(${PKG_LIB} PROPERTIES OUTPUT_NAME lammps_${PKG_LIB}${LAMMPS_MACHINE}) diff --git a/cmake/Modules/Documentation.cmake b/cmake/Modules/Documentation.cmake index df9bf2b449..400109067f 100644 --- a/cmake/Modules/Documentation.cmake +++ b/cmake/Modules/Documentation.cmake @@ -16,7 +16,7 @@ if(BUILD_DOC) set(VIRTUALENV ${Python3_EXECUTABLE} -m venv) find_package(Doxygen 1.8.10 REQUIRED) - file(GLOB DOC_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_DOC_DIR}/src/[^.]*.rst) + file(GLOB DOC_SOURCES CONFIGURE_DEPENDS ${LAMMPS_DOC_DIR}/src/[^.]*.rst) add_custom_command( OUTPUT docenv @@ -74,7 +74,7 @@ if(BUILD_DOC) message(STATUS "Using already downloaded archive ${CMAKE_BINARY_DIR}/libpace.tar.gz") endif() execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf mathjax.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - file(GLOB MATHJAX_VERSION_DIR ${CONFIGURE_DEPENDS} ${CMAKE_CURRENT_BINARY_DIR}/MathJax-*) + file(GLOB MATHJAX_VERSION_DIR CONFIGURE_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/MathJax-*) execute_process(COMMAND ${CMAKE_COMMAND} -E rename ${MATHJAX_VERSION_DIR} ${DOC_BUILD_STATIC_DIR}/mathjax) endif() diff --git a/cmake/Modules/LAMMPSInterfacePlugin.cmake b/cmake/Modules/LAMMPSInterfacePlugin.cmake index c1cc613496..d064020098 100644 --- a/cmake/Modules/LAMMPSInterfacePlugin.cmake +++ b/cmake/Modules/LAMMPSInterfacePlugin.cmake @@ -65,7 +65,7 @@ endfunction(validate_option) # helper function for getting the most recently modified file or folder from a glob pattern function(get_newest_file path variable) - file(GLOB _dirs ${CONFIGURE_DEPENDS} ${path}) + file(GLOB _dirs CONFIGURE_DEPENDS ${path}) set(_besttime 2000-01-01T00:00:00) set(_bestfile "") foreach(_dir ${_dirs}) diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index 1ceec7e06e..bb5ea07609 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -41,7 +41,7 @@ endfunction() # helper function for getting the most recently modified file or folder from a glob pattern function(get_newest_file path variable) - file(GLOB _dirs ${CONFIGURE_DEPENDS} ${path}) + file(GLOB _dirs CONFIGURE_DEPENDS ${path}) set(_besttime 2000-01-01T00:00:00) set(_bestfile "") foreach(_dir ${_dirs}) @@ -80,8 +80,8 @@ endfunction() function(check_for_autogen_files source_dir) message(STATUS "Running check for auto-generated files from make-based build system") - file(GLOB SRC_AUTOGEN_FILES ${CONFIGURE_DEPENDS} ${source_dir}/style_*.h) - file(GLOB SRC_AUTOGEN_PACKAGES ${CONFIGURE_DEPENDS} ${source_dir}/packages_*.h) + file(GLOB SRC_AUTOGEN_FILES CONFIGURE_DEPENDS ${source_dir}/style_*.h) + file(GLOB SRC_AUTOGEN_PACKAGES CONFIGURE_DEPENDS ${source_dir}/packages_*.h) list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/lmpinstalledpkgs.h ${source_dir}/lmpgitversion.h) list(APPEND SRC_AUTOGEN_FILES ${SRC_AUTOGEN_PACKAGES} ${source_dir}/mliap_model_python_couple.h ${source_dir}/mliap_model_python_couple.cpp) foreach(_SRC ${SRC_AUTOGEN_FILES}) diff --git a/cmake/Modules/Packages/COLVARS.cmake b/cmake/Modules/Packages/COLVARS.cmake index 325e0e205e..745c1de026 100644 --- a/cmake/Modules/Packages/COLVARS.cmake +++ b/cmake/Modules/Packages/COLVARS.cmake @@ -1,6 +1,6 @@ set(COLVARS_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/colvars) -file(GLOB COLVARS_SOURCES ${CONFIGURE_DEPENDS} ${COLVARS_SOURCE_DIR}/[^.]*.cpp) +file(GLOB COLVARS_SOURCES CONFIGURE_DEPENDS ${COLVARS_SOURCE_DIR}/[^.]*.cpp) option(COLVARS_DEBUG "Enable debugging messages for Colvars (quite verbose)" OFF) diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake index 4a70eb7a1e..221013580f 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -39,7 +39,7 @@ if (PKG_AMOEBA) ${GPU_SOURCES_DIR}/amoeba_convolution_gpu.cpp) endif() -file(GLOB GPU_LIB_SOURCES ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp) +file(GLOB GPU_LIB_SOURCES CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cpp) file(MAKE_DIRECTORY ${LAMMPS_LIB_BINARY_DIR}/gpu) if(GPU_API STREQUAL "CUDA") @@ -68,7 +68,7 @@ if(GPU_API STREQUAL "CUDA") set(GPU_ARCH "sm_50" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)") # ensure that no *cubin.h files exist from a compile in the lib/gpu folder - file(GLOB GPU_LIB_OLD_CUBIN_HEADERS ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/*_cubin.h) + file(GLOB GPU_LIB_OLD_CUBIN_HEADERS CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/*_cubin.h) if(GPU_LIB_OLD_CUBIN_HEADERS) message(FATAL_ERROR "########################################################################\n" "Found file(s) generated by the make-based build system in lib/gpu\n" @@ -78,15 +78,15 @@ if(GPU_API STREQUAL "CUDA") "########################################################################") endif() - file(GLOB GPU_LIB_CU ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu) + file(GLOB GPU_LIB_CU CONFIGURE_DEPENDS ${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 ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp) - file(GLOB GPU_LIB_CUDPP_CU ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu) + file(GLOB GPU_LIB_CUDPP_SOURCES CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cpp) + file(GLOB GPU_LIB_CUDPP_CU CONFIGURE_DEPENDS ${LAMMPS_LIB_SOURCE_DIR}/gpu/cudpp_mini/[^.]*.cu) endif() # build arch/gencode commands for nvcc based on CUDA toolkit version and use choice @@ -201,7 +201,7 @@ elseif(GPU_API STREQUAL "OPENCL") 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 ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu) + file(GLOB GPU_LIB_CU CONFIGURE_DEPENDS ${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 @@ -331,7 +331,7 @@ elseif(GPU_API STREQUAL "HIP") endif() endif() - file(GLOB GPU_LIB_CU ${CONFIGURE_DEPENDS} ${LAMMPS_LIB_SOURCE_DIR}/gpu/[^.]*.cu ${CMAKE_CURRENT_SOURCE_DIR}/gpu/[^.]*.cu) + file(GLOB GPU_LIB_CU CONFIGURE_DEPENDS ${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 "") diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake index 8b695667ae..d30b0000f3 100644 --- a/cmake/Modules/Packages/KOKKOS.cmake +++ b/cmake/Modules/Packages/KOKKOS.cmake @@ -155,7 +155,7 @@ if(PKG_ML-IAP) # Add KOKKOS version of ML-IAP Python coupling if non-KOKKOS version is included if(MLIAP_ENABLE_PYTHON AND Cythonize_EXECUTABLE) - file(GLOB MLIAP_KOKKOS_CYTHON_SRC ${CONFIGURE_DEPENDS} ${LAMMPS_SOURCE_DIR}/KOKKOS/*.pyx) + file(GLOB MLIAP_KOKKOS_CYTHON_SRC CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/KOKKOS/*.pyx) foreach(MLIAP_CYTHON_FILE ${MLIAP_KOKKOS_CYTHON_SRC}) get_filename_component(MLIAP_CYTHON_BASE ${MLIAP_CYTHON_FILE} NAME_WE) add_custom_command(OUTPUT ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.cpp ${MLIAP_BINARY_DIR}/${MLIAP_CYTHON_BASE}.h diff --git a/cmake/Modules/Packages/LEPTON.cmake b/cmake/Modules/Packages/LEPTON.cmake index 33e14d092c..b1944c2400 100644 --- a/cmake/Modules/Packages/LEPTON.cmake +++ b/cmake/Modules/Packages/LEPTON.cmake @@ -4,7 +4,7 @@ if(LEPTON_SOURCE_DIR) endif() set(LEPTON_SOURCE_DIR ${LAMMPS_LIB_SOURCE_DIR}/lepton) -file(GLOB LEPTON_SOURCES ${CONFIGURE_DEPENDS} ${LEPTON_SOURCE_DIR}/src/[^.]*.cpp) +file(GLOB LEPTON_SOURCES CONFIGURE_DEPENDS ${LEPTON_SOURCE_DIR}/src/[^.]*.cpp) if((CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "amd64") OR (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64") OR @@ -15,7 +15,7 @@ else() endif() if(LEPTON_ENABLE_JIT) - file(GLOB ASMJIT_SOURCES ${CONFIGURE_DEPENDS} ${LEPTON_SOURCE_DIR}/asmjit/*/[^.]*.cpp) + file(GLOB ASMJIT_SOURCES CONFIGURE_DEPENDS ${LEPTON_SOURCE_DIR}/asmjit/*/[^.]*.cpp) endif() add_library(lepton STATIC ${LEPTON_SOURCES} ${ASMJIT_SOURCES}) diff --git a/cmake/Modules/Packages/ML-IAP.cmake b/cmake/Modules/Packages/ML-IAP.cmake index 2e9a02977d..d6059c44b8 100644 --- a/cmake/Modules/Packages/ML-IAP.cmake +++ b/cmake/Modules/Packages/ML-IAP.cmake @@ -21,7 +21,7 @@ if(MLIAP_ENABLE_PYTHON) endif() set(MLIAP_BINARY_DIR ${CMAKE_BINARY_DIR}/cython) - file(GLOB MLIAP_CYTHON_SRC ${CONFIGURE_DEPENDS} ${LAMMPS_SOURCE_DIR}/ML-IAP/*.pyx) + file(GLOB MLIAP_CYTHON_SRC CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/ML-IAP/*.pyx) file(MAKE_DIRECTORY ${MLIAP_BINARY_DIR}) foreach(MLIAP_CYTHON_FILE ${MLIAP_CYTHON_SRC}) get_filename_component(MLIAP_CYTHON_BASE ${MLIAP_CYTHON_FILE} NAME_WE) diff --git a/cmake/Modules/StyleHeaderUtils.cmake b/cmake/Modules/StyleHeaderUtils.cmake index 2a0a91e843..d4644bd042 100644 --- a/cmake/Modules/StyleHeaderUtils.cmake +++ b/cmake/Modules/StyleHeaderUtils.cmake @@ -1,5 +1,5 @@ function(FindStyleHeaders path style_class file_pattern headers) - file(GLOB files ${CONFIGURE_DEPENDS} "${path}/${file_pattern}*.h") + file(GLOB files CONFIGURE_DEPENDS "${path}/${file_pattern}*.h") get_property(hlist GLOBAL PROPERTY ${headers}) foreach(file_name ${files}) @@ -187,7 +187,7 @@ endfunction(DetectBuildSystemConflict) function(FindPackagesHeaders path style_class file_pattern headers) - file(GLOB files ${CONFIGURE_DEPENDS} "${path}/${file_pattern}*.h") + file(GLOB files CONFIGURE_DEPENDS "${path}/${file_pattern}*.h") get_property(plist GLOBAL PROPERTY ${headers}) foreach(file_name ${files}) diff --git a/cmake/Modules/Testing.cmake b/cmake/Modules/Testing.cmake index 5bb8b512d3..ff595d3c8f 100644 --- a/cmake/Modules/Testing.cmake +++ b/cmake/Modules/Testing.cmake @@ -6,7 +6,7 @@ if(ENABLE_TESTING) find_program(VALGRIND_BINARY NAMES valgrind) # generate custom suppression file file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/lammps.supp "\n") - file(GLOB VALGRIND_SUPPRESSION_FILES ${CONFIGURE_DEPENDS} ${LAMMPS_TOOLS_DIR}/valgrind/[^.]*.supp) + file(GLOB VALGRIND_SUPPRESSION_FILES CONFIGURE_DEPENDS ${LAMMPS_TOOLS_DIR}/valgrind/[^.]*.supp) foreach(SUPP ${VALGRIND_SUPPRESSION_FILES}) file(READ ${SUPP} SUPPRESSIONS) file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/lammps.supp "${SUPPRESSIONS}") diff --git a/cmake/Modules/Tools.cmake b/cmake/Modules/Tools.cmake index 285c5f2405..c9fd7aab60 100644 --- a/cmake/Modules/Tools.cmake +++ b/cmake/Modules/Tools.cmake @@ -26,7 +26,7 @@ if(BUILD_TOOLS) enable_language(C) get_filename_component(MSI2LMP_SOURCE_DIR ${LAMMPS_TOOLS_DIR}/msi2lmp/src ABSOLUTE) - file(GLOB MSI2LMP_SOURCES ${CONFIGURE_DEPENDS} ${MSI2LMP_SOURCE_DIR}/[^.]*.c) + file(GLOB MSI2LMP_SOURCES CONFIGURE_DEPENDS ${MSI2LMP_SOURCE_DIR}/[^.]*.c) add_executable(msi2lmp ${MSI2LMP_SOURCES}) if(STANDARD_MATH_LIB) target_link_libraries(msi2lmp PRIVATE ${STANDARD_MATH_LIB}) diff --git a/unittest/force-styles/CMakeLists.txt b/unittest/force-styles/CMakeLists.txt index 21a1bd3eda..efc75f512d 100644 --- a/unittest/force-styles/CMakeLists.txt +++ b/unittest/force-styles/CMakeLists.txt @@ -87,7 +87,7 @@ else() endif() # tests for molecular systems and related pair styles -file(GLOB MOL_PAIR_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/mol-pair-*.yaml) +file(GLOB MOL_PAIR_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/mol-pair-*.yaml) # cannot test MSM with single precision data if(FFT_SINGLE) list(FILTER MOL_PAIR_TESTS EXCLUDE REGEX "msm") @@ -105,7 +105,7 @@ foreach(TEST ${MOL_PAIR_TESTS}) endforeach() # tests for metal-like atomic systems and related pair styles -file(GLOB ATOMIC_PAIR_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/atomic-pair-*.yaml) +file(GLOB ATOMIC_PAIR_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/atomic-pair-*.yaml) foreach(TEST ${ATOMIC_PAIR_TESTS}) string(REGEX REPLACE "^.*atomic-pair-(.*)\.yaml" "AtomicPairStyle:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) @@ -119,7 +119,7 @@ foreach(TEST ${ATOMIC_PAIR_TESTS}) endforeach() # tests for Si-like manybody systems and related pair styles -file(GLOB MANYBODY_PAIR_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/manybody-pair-*.yaml) +file(GLOB MANYBODY_PAIR_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/manybody-pair-*.yaml) foreach(TEST ${MANYBODY_PAIR_TESTS}) string(REGEX REPLACE "^.*manybody-pair-(.*)\.yaml" "ManybodyPairStyle:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) @@ -136,7 +136,7 @@ endforeach() add_executable(test_bond_style test_bond_style.cpp) target_link_libraries(test_bond_style PRIVATE lammps style_tests) -file(GLOB BOND_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/bond-*.yaml) +file(GLOB BOND_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/bond-*.yaml) foreach(TEST ${BOND_TESTS}) string(REGEX REPLACE "^.*bond-(.*)\.yaml" "BondStyle:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) @@ -153,7 +153,7 @@ endforeach() add_executable(test_angle_style test_angle_style.cpp) target_link_libraries(test_angle_style PRIVATE lammps style_tests) -file(GLOB ANGLE_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/angle-*.yaml) +file(GLOB ANGLE_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/angle-*.yaml) foreach(TEST ${ANGLE_TESTS}) string(REGEX REPLACE "^.*angle-(.*)\.yaml" "AngleStyle:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) @@ -167,7 +167,7 @@ foreach(TEST ${ANGLE_TESTS}) endforeach() # kspace style tester, currently uses the pair style tool -file(GLOB KSPACE_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/kspace-*.yaml) +file(GLOB KSPACE_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/kspace-*.yaml) # cannot test MSM with single precision data if(FFT_SINGLE) list(FILTER KSPACE_TESTS EXCLUDE REGEX "msm") @@ -192,7 +192,7 @@ endif() target_link_libraries(test_fix_timestep PRIVATE lammps style_tests) # tests for timestep related fixes (time integration, thermostat, force manipulation, constraints/restraints) -file(GLOB FIX_TIMESTEP_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/fix-timestep-*.yaml) +file(GLOB FIX_TIMESTEP_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/fix-timestep-*.yaml) foreach(TEST ${FIX_TIMESTEP_TESTS}) string(REGEX REPLACE "^.*fix-timestep-(.*)\.yaml" "FixTimestep:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) @@ -213,7 +213,7 @@ endforeach() add_executable(test_dihedral_style test_dihedral_style.cpp) target_link_libraries(test_dihedral_style PRIVATE lammps style_tests) -file(GLOB DIHEDRAL_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/dihedral-*.yaml) +file(GLOB DIHEDRAL_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/dihedral-*.yaml) foreach(TEST ${DIHEDRAL_TESTS}) string(REGEX REPLACE "^.*dihedral-(.*)\.yaml" "DihedralStyle:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) @@ -230,7 +230,7 @@ endforeach() add_executable(test_improper_style test_improper_style.cpp) target_link_libraries(test_improper_style PRIVATE lammps style_tests) -file(GLOB IMPROPER_TESTS LIST_DIRECTORIES false ${CONFIGURE_DEPENDS} ${TEST_INPUT_FOLDER}/improper-*.yaml) +file(GLOB IMPROPER_TESTS LIST_DIRECTORIES false CONFIGURE_DEPENDS ${TEST_INPUT_FOLDER}/improper-*.yaml) foreach(TEST ${IMPROPER_TESTS}) string(REGEX REPLACE "^.*improper-(.*)\.yaml" "ImproperStyle:\\1" TNAME ${TEST}) extract_tags(TEST_TAGS ${TEST}) From 4a46083e88500ceac47f7954b4cfb1c904a04b74 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 30 Jun 2023 23:29:17 -0400 Subject: [PATCH 16/25] add git commit descriptor to LAMMPS version output --- cmake/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 6e4ae62ee2..aaf15166fc 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -871,8 +871,15 @@ else() endif() include(FeatureSummary) feature_summary(DESCRIPTION "The following tools and libraries have been found and configured:" WHAT PACKAGES_FOUND) +if(GIT_FOUND AND EXISTS ${LAMMPS_DIR}/.git) + execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty=-modified --always + OUTPUT_VARIABLE GIT_DESCRIBE + ERROR_QUIET + WORKING_DIRECTORY ${LAMMPS_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() message(STATUS "<<< Build configuration >>> - LAMMPS Version: ${PROJECT_VERSION} + LAMMPS Version: ${PROJECT_VERSION} ${GIT_DESCRIBE} Operating System: ${CMAKE_SYSTEM_NAME} ${CMAKE_LINUX_DISTRO} ${CMAKE_DISTRO_VERSION} CMake Version: ${CMAKE_VERSION} Build type: ${LAMMPS_BUILD_TYPE} From ef40448df6367df46b37b4f98fbd74115eb540e6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 1 Jul 2023 03:01:37 -0400 Subject: [PATCH 17/25] update docs for CMake 3.16 requirement --- doc/src/Build_cmake.rst | 16 ++++++------ doc/src/Howto_cmake.rst | 28 +++++++++++++-------- doc/src/Intro_portability.rst | 10 ++++---- doc/utils/sphinx-config/false_positives.txt | 1 + 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/doc/src/Build_cmake.rst b/doc/src/Build_cmake.rst index 9be2c33165..6c46f6d672 100644 --- a/doc/src/Build_cmake.rst +++ b/doc/src/Build_cmake.rst @@ -16,8 +16,7 @@ environments is on a :doc:`separate page `. .. note:: - LAMMPS currently requires that CMake version 3.10 or later is available; - version 3.12 or later is preferred. + LAMMPS currently requires that CMake version 3.16 or later is available. .. warning:: @@ -34,19 +33,18 @@ Advantages of using CMake ^^^^^^^^^^^^^^^^^^^^^^^^^ CMake is an alternative to compiling LAMMPS in the traditional way -through :doc:`(manually customized) makefiles ` and a recent -addition to LAMMPS thanks to the efforts of Christoph Junghans (LANL) -and Richard Berger (Temple U). Using CMake has multiple advantages that -are specifically helpful for people with limited experience in compiling -software or for people that want to modify or extend LAMMPS. +through :doc:`(manually customized) makefiles `. Using +CMake has multiple advantages that are specifically helpful for +people with limited experience in compiling software or for people +that want to modify or extend LAMMPS. - CMake can detect available hardware, tools, features, and libraries and adapt the LAMMPS default build configuration accordingly. - CMake can generate files for different build tools and integrated development environments (IDE). - CMake supports customization of settings with a command line, text - mode, or graphical user interface. No knowledge of file formats or - complex command line syntax is required. + mode, or graphical user interface. No manual editing of files, + knowledge of file formats or complex command line syntax is required. - All enabled components are compiled in a single build operation. - Automated dependency tracking for all files and configuration options. - Support for true out-of-source compilation. Multiple configurations diff --git a/doc/src/Howto_cmake.rst b/doc/src/Howto_cmake.rst index c997aa52bf..3794f8ec84 100644 --- a/doc/src/Howto_cmake.rst +++ b/doc/src/Howto_cmake.rst @@ -3,9 +3,9 @@ Using CMake with LAMMPS tutorial The support for building LAMMPS with CMake is a recent addition to LAMMPS thanks to the efforts of Christoph Junghans (LANL) and Richard -Berger (Temple U). One of the key strengths of CMake is that it is not -tied to a specific platform or build system and thus generate the files -necessary to build and develop for different build systems and on +Berger (LANL). One of the key strengths of CMake is that it is not +tied to a specific platform or build system and thus it generates the +files necessary to build and develop for different build systems and on different platforms. Note, that this applies to the build system itself not the LAMMPS code. In other words, without additional porting effort, it is not possible - for example - to compile LAMMPS with Visual C++ on @@ -14,7 +14,7 @@ necessary to program LAMMPS as a project in integrated development environments (IDE) like Eclipse, Visual Studio, QtCreator, Xcode, CodeBlocks, Kate and others. -A second important feature of CMake is, that it can detect and validate +A second important feature of CMake is that it can detect and validate available libraries, optimal settings, available support tools and so on, so that by default LAMMPS will take advantage of available tools without requiring to provide the details about how to enable/integrate @@ -32,8 +32,7 @@ program ``cmake`` (or ``cmake3``), a text mode interactive user interface (TUI) program ``ccmake`` (or ``ccmake3``), or a graphical user interface (GUI) program ``cmake-gui``. All of them are portable software available on all supported platforms and can be used -interchangeably. The minimum supported CMake version is 3.10 (3.12 or -later is recommended). +interchangeably. The minimum required CMake version is 3.16. All details about features and settings for CMake are in the `CMake online documentation `_. We focus @@ -43,11 +42,20 @@ Prerequisites ------------- This tutorial assumes that you are operating in a command-line environment -using a shell like Bash. +using a shell like Bash or Zsh. -- Linux: any Terminal window will work -- macOS: launch the Terminal application. -- Windows 10: install and run the :doc:`Windows Subsystem for Linux ` +- Linux: any Terminal window will work or text console +- macOS: launch the Terminal application +- Windows 10 or 11: install and run the :doc:`Windows Subsystem for Linux ` +- other Unix-like operating systems like FreeBSD + +.. note:: + + It is also possible to use CMake on Windows 10 or 11 through either the Microsoft + Visual Studio IDE with the bundled CMake or from the Windows command prompt using + a separately installed CMake package, both using the native Microsoft Visual C++ + compilers and (optionally) the Microsoft MPI SDK. This tutorial, however, only + covers unix-like command line interfaces. We also assume that you have downloaded and unpacked a recent LAMMPS source code package or used Git to create a clone of the LAMMPS sources on your compilation machine. diff --git a/doc/src/Intro_portability.rst b/doc/src/Intro_portability.rst index 239eacd1b7..d233d2a9ae 100644 --- a/doc/src/Intro_portability.rst +++ b/doc/src/Intro_portability.rst @@ -13,7 +13,7 @@ Programming language standards Most of the C++ code currently requires a compiler compatible with the C++11 standard, the KOKKOS package currently requires C++14. Most of -the Python code is written to be compatible with Python 3.5 or later or +the Python code is written to be compatible with Python 3.6 or later or Python 2.7. Some Python scripts *require* Python 3 and a few others still need to be ported from Python 2 to Python 3. @@ -25,7 +25,7 @@ LAMMPS can be compiled from source code using a (traditional) build system based on shell scripts, a few shell utilities (grep, sed, cat, tr) and the GNU make program. This requires running within a Bourne shell (``/bin/sh``). Alternatively, a build system with different back ends -can be created using CMake. CMake must be at least version 3.10. +can be created using CMake. CMake must be at least version 3.16. Operating systems ^^^^^^^^^^^^^^^^^ @@ -62,9 +62,9 @@ regularly tested. Portability compliance ^^^^^^^^^^^^^^^^^^^^^^ -Only a subset of the LAMMPS source code is fully compliant to all of the -above mentioned standards. This is rather typical for projects like -LAMMPS that largely depend on contributions from the user community. +Only a subset of the LAMMPS source code is *fully* compliant to *all* +of the above mentioned standards. This is rather typical for projects +like LAMMPS that largely depend on contributions from the user community. Not all contributors are trained as programmers and not all of them have access to multiple platforms for testing. As part of the continuous integration process, however, all contributions are automatically tested diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 5791288a06..4859f0e4bb 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -4089,6 +4089,7 @@ zmq zN zs zsc +Zsh zst Zstandard zstd From 2273c5c4754e22536e70f8216469582594e9f4cc Mon Sep 17 00:00:00 2001 From: "Megan J. McCarthy" Date: Thu, 27 Jul 2023 03:28:46 -0600 Subject: [PATCH 18/25] fix memory and output bugs --- src/EXTRA-COMPUTE/compute_local_comp_atom.cpp | 14 +++---- src/EXTRA-COMPUTE/compute_local_comp_atom.h | 2 +- src/KOKKOS/compute_local_comp_atom_kokkos.cpp | 38 +++++++++---------- src/KOKKOS/compute_local_comp_atom_kokkos.h | 3 -- 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp index bb3f068bd7..dbd1d04cb2 100644 --- a/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp @@ -70,7 +70,7 @@ ComputeLocalCompAtom::~ComputeLocalCompAtom() if (copymode) return; memory->destroy(result); - memory->destroy(lcomp); + } /* ---------------------------------------------------------------------- */ @@ -128,7 +128,7 @@ void ComputeLocalCompAtom::compute_peratom() int count, itype, jtype; // int lcomp[ntypes]; - memory->create(lcomp, ntypes, "local/comp/atom:lcomp"); + // memory->create(lcomp, ntypes, "local/comp/atom:lcomp"); invoked_peratom = update->ntimestep; @@ -163,7 +163,7 @@ void ComputeLocalCompAtom::compute_peratom() i = ilist[ii]; - for (int m = 0; m < ntypes; m++) lcomp[m] = 0.0; + // for (int m = 0; m < ntypes; m++) lcomp[m] = 0.0; if (mask[i] & groupbit) { @@ -178,7 +178,7 @@ void ComputeLocalCompAtom::compute_peratom() count = 1; itype = type[i]; - lcomp[itype-1]++; + result[i][itype]++; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; @@ -192,7 +192,7 @@ void ComputeLocalCompAtom::compute_peratom() rsq = delx * delx + dely * dely + delz * delz; if (rsq < cutsq) { count++; - lcomp[jtype-1]++; + result[i][jtype]++; } } @@ -203,8 +203,8 @@ void ComputeLocalCompAtom::compute_peratom() // local comp fractions per element double lfac = 1.0 / count; - for (int n = 0; n < ntypes; n++) - result[i][n+1] = lcomp[n] * lfac; + for (int n = 1; n < size_peratom_cols; n++) + result[i][n+1] *= lfac; } } diff --git a/src/EXTRA-COMPUTE/compute_local_comp_atom.h b/src/EXTRA-COMPUTE/compute_local_comp_atom.h index 8ec5cb685f..21362dc933 100644 --- a/src/EXTRA-COMPUTE/compute_local_comp_atom.h +++ b/src/EXTRA-COMPUTE/compute_local_comp_atom.h @@ -39,7 +39,7 @@ class ComputeLocalCompAtom : public Compute { double cutsq; // cutoff**2 class NeighList *list; // neighbor list - int *lcomp; // peratom array to track local compositions +// int *lcomp; // peratom array to track local compositions double **result; // peratom array of local compositions }; diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp index 20caa00df0..59f3a50d3a 100644 --- a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp @@ -58,8 +58,9 @@ ComputeLocalCompAtomKokkos::~ComputeLocalCompAtomKokkos() { if (copymode) return; - memoryKK->destroy_kokkos(k_result,result); // memoryKK->destroy_kokkos(k_lcomp,lcomp); + memoryKK->destroy_kokkos(k_result,result); + } /* ---------------------------------------------------------------------- */ @@ -109,6 +110,7 @@ void ComputeLocalCompAtomKokkos::compute_peratom() d_neighbors = k_list->d_neighbors; d_ilist = k_list->d_ilist; + // compute properties for each atom in group // use full neighbor list to count atoms less than cutoff @@ -126,8 +128,15 @@ void ComputeLocalCompAtomKokkos::compute_peratom() copymode = 0; k_result.modify(); + + // printf("k_result pre-sync: %g ", k_result.view()(0,0)); + // printf("k_result pre-sync: %g \n\n", k_result.view()(0,1)); + k_result.sync_host(); + // printf("k_result post-sync: %g ", k_result.view()(0,0)); + // printf("k_result post-sync: %g \n\n", k_result.view()(0,1)); + } template @@ -139,11 +148,6 @@ void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, if (mask[i] & groupbit) { - // initialize / reset lcomp - - // for (int m = 0; m < ntypes; m++) d_lcomp(m) = 0; - // for (int m = 0; m < size_peratom_cols; m++) d_result(i,m) = 0.0; - const X_FLOAT xtmp = x(i,0); const X_FLOAT ytmp = x(i,1); const X_FLOAT ztmp = x(i,2); @@ -151,11 +155,8 @@ void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, // i atom contribution - int count = 1; + int count = 1.0; int itype = type[i]; - - // d_lcomp(itype-1)++; - // d_result(i,itype-1) = d_result(i,itype-1) + 1; d_result(i,itype)++; for (int jj = 0; jj < jnum; jj++) { @@ -171,25 +172,22 @@ void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; if (rsq < cutsq) { count++; - // d_lcomp(jtype-1)++; - // d_result(i,jtype) = d_result(i,jtype) + 1; - d_result(i,jtype)++; + d_result(i,jtype) += 1.0; } + } // total count of atoms found in sampled radius range d_result(i,0) = count; - // local comp fractions per + // local comp fractions per atom type double lfac = 1.0 / count; - // for (int n = 1; n < size_peratom_cols; n++) { - // // d_result(i,n+1) = d_lcomp(n+1) * lfac; - // d_result(i,n) = d_result(i,n) * lfac; - // // d_result(i,n+1) = 123.0; - // } - + for (int n = 1; n < size_peratom_cols; n++) { + // double item = d_result(i,n); + d_result(i,n) *= lfac; + // d_result(i,n) = 123.0; } } } diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.h b/src/KOKKOS/compute_local_comp_atom_kokkos.h index bf0f69de55..5fb52474b2 100644 --- a/src/KOKKOS/compute_local_comp_atom_kokkos.h +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.h @@ -54,10 +54,7 @@ template class ComputeLocalCompAtomKokkos : public ComputeLoc typename AT::t_neighbors_2d d_neighbors; typename AT::t_int_1d d_ilist; typename AT::t_int_1d d_numneigh; - -// DAT::tdual_int_1d k_lcomp; DAT::tdual_float_2d k_result; -// typename AT::t_int_1d d_lcomp; typename AT::t_float_2d d_result; }; From 3657ed6beb12b1f060b1d5517a5a7dcf04ad64bd Mon Sep 17 00:00:00 2001 From: "Megan J. McCarthy" Date: Thu, 27 Jul 2023 03:35:46 -0600 Subject: [PATCH 19/25] clean up comments --- src/EXTRA-COMPUTE/compute_local_comp_atom.cpp | 7 +------ src/EXTRA-COMPUTE/compute_local_comp_atom.h | 3 --- src/KOKKOS/compute_local_comp_atom_kokkos.cpp | 16 +--------------- 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp index dbd1d04cb2..02c1444fbf 100644 --- a/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing author: Stan Moore (SNL) + Contributing authors: Megan McCarthy (SNL), Stan Moore (SNL) ------------------------------------------------------------------------- */ #include "compute_local_comp_atom.h" @@ -126,9 +126,6 @@ void ComputeLocalCompAtom::compute_peratom() double xtmp, ytmp, ztmp, delx, dely, delz, rsq; int *ilist, *jlist, *numneigh, **firstneigh; int count, itype, jtype; - // int lcomp[ntypes]; - - // memory->create(lcomp, ntypes, "local/comp/atom:lcomp"); invoked_peratom = update->ntimestep; @@ -163,8 +160,6 @@ void ComputeLocalCompAtom::compute_peratom() i = ilist[ii]; - // for (int m = 0; m < ntypes; m++) lcomp[m] = 0.0; - if (mask[i] & groupbit) { xtmp = x[i][0]; diff --git a/src/EXTRA-COMPUTE/compute_local_comp_atom.h b/src/EXTRA-COMPUTE/compute_local_comp_atom.h index 21362dc933..76d92de08d 100644 --- a/src/EXTRA-COMPUTE/compute_local_comp_atom.h +++ b/src/EXTRA-COMPUTE/compute_local_comp_atom.h @@ -38,9 +38,6 @@ class ComputeLocalCompAtom : public Compute { double cutoff; // global cutoff distance double cutsq; // cutoff**2 class NeighList *list; // neighbor list - -// int *lcomp; // peratom array to track local compositions - double **result; // peratom array of local compositions }; diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp index 59f3a50d3a..9360cbd82a 100644 --- a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing authors: Stan Moore (SNL), Megan McCarthy (SNL) + Contributing authors: Megan McCarthy (SNL), Stan Moore (SNL) ------------------------------------------------------------------------- */ #include "compute_local_comp_atom_kokkos.h" @@ -58,7 +58,6 @@ ComputeLocalCompAtomKokkos::~ComputeLocalCompAtomKokkos() { if (copymode) return; - // memoryKK->destroy_kokkos(k_lcomp,lcomp); memoryKK->destroy_kokkos(k_result,result); } @@ -97,9 +96,6 @@ void ComputeLocalCompAtomKokkos::compute_peratom() array_atom = result; } - // memoryKK->create_kokkos(k_lcomp,lcomp,size_peratom_cols,"local/comp/atom:lcomp"); - // d_lcomp = k_lcomp.view(); - // invoke full neighbor list (will copy or build if necessary) neighbor->build_one(list); @@ -110,7 +106,6 @@ void ComputeLocalCompAtomKokkos::compute_peratom() d_neighbors = k_list->d_neighbors; d_ilist = k_list->d_ilist; - // compute properties for each atom in group // use full neighbor list to count atoms less than cutoff @@ -128,15 +123,8 @@ void ComputeLocalCompAtomKokkos::compute_peratom() copymode = 0; k_result.modify(); - - // printf("k_result pre-sync: %g ", k_result.view()(0,0)); - // printf("k_result pre-sync: %g \n\n", k_result.view()(0,1)); - k_result.sync_host(); - // printf("k_result post-sync: %g ", k_result.view()(0,0)); - // printf("k_result post-sync: %g \n\n", k_result.view()(0,1)); - } template @@ -185,9 +173,7 @@ void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, double lfac = 1.0 / count; for (int n = 1; n < size_peratom_cols; n++) { - // double item = d_result(i,n); d_result(i,n) *= lfac; - // d_result(i,n) = 123.0; } } } From e958cc0ef1c160ee884f58fb7beaa59ddd4cf669 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 4 Aug 2023 08:01:57 -0400 Subject: [PATCH 20/25] silence warning about a setting that was added to silence warnings --- cmake/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 6fe43ee5a7..2ba2991c63 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -13,11 +13,6 @@ endif() if(POLICY CMP0075) cmake_policy(SET CMP0075 NEW) endif() -# set policy to silence warnings about missing executable permissions in -# pythonx.y-config when cross-compiling. review occasionally if it may be set to NEW -if(POLICY CMP0109) - cmake_policy(SET CMP0109 OLD) -endif() # set policy to silence warnings about timestamps of downloaded files. review occasionally if it may be set to NEW if(POLICY CMP0135) cmake_policy(SET CMP0135 OLD) From 1a5b9475931863f4d7b7ad88da80892b37f34304 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 4 Aug 2023 08:02:06 -0400 Subject: [PATCH 21/25] flag if we are cross-compiling --- cmake/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 2ba2991c63..5d3322a1ae 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -877,6 +877,9 @@ message(STATUS "<<< Build configuration >>> Build type: ${LAMMPS_BUILD_TYPE} Install path: ${CMAKE_INSTALL_PREFIX} Generator: ${CMAKE_GENERATOR} using ${CMAKE_MAKE_PROGRAM}") +if(CMAKE_CROSSCOMPILING) + message(STATUS "Cross compiling on ${CMAKE_HOST_SYSTEM}") +endif() ############################################################################### # Print package summary ############################################################################### From 5d3839db9f01fe8ab9fb834234ec0ec2765f6e67 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 4 Aug 2023 13:27:01 -0400 Subject: [PATCH 22/25] clean up all created files --- unittest/formats/test_file_operations.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/unittest/formats/test_file_operations.cpp b/unittest/formats/test_file_operations.cpp index f1a6ce42f5..70781509a0 100644 --- a/unittest/formats/test_file_operations.cpp +++ b/unittest/formats/test_file_operations.cpp @@ -611,6 +611,10 @@ TEST_F(FileOperationsTest, read_data_fix) EXPECT_EQ(lmp->atom->tag[GETIDX(8)], 8); EXPECT_EQ(lmp->atom->tag[GETIDX(9)], 9); EXPECT_EQ(lmp->atom->tag[GETIDX(10)], 10); + + // clean up + delete_file("test_mol_id_merge.data"); + delete_file("test_mol_id.data"); } int main(int argc, char **argv) From 4c68e3f5f379c5d93d67db6237477ab5162b6074 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Fri, 4 Aug 2023 13:29:22 -0600 Subject: [PATCH 23/25] Small tweaks --- src/.gitignore | 2 ++ src/EXTRA-COMPUTE/compute_local_comp_atom.cpp | 4 +--- src/KOKKOS/Install.sh | 2 ++ src/KOKKOS/compute_local_comp_atom_kokkos.cpp | 8 +------- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/.gitignore b/src/.gitignore index 6e2a8b92c9..115291c39a 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -580,6 +580,8 @@ /compute_ke_eff.h /compute_ke_rigid.cpp /compute_ke_rigid.h +/compute_local_comp_atom.cpp +/compute_local_comp_atom.h /compute_meso_e_atom.cpp /compute_meso_e_atom.h /compute_meso_rho_atom.cpp diff --git a/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp index 02c1444fbf..02ab91d969 100644 --- a/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing authors: Megan McCarthy (SNL), Stan Moore (SNL) + Contributing author: Megan McCarthy (SNL) ------------------------------------------------------------------------- */ #include "compute_local_comp_atom.h" @@ -70,7 +70,6 @@ ComputeLocalCompAtom::~ComputeLocalCompAtom() if (copymode) return; memory->destroy(result); - } /* ---------------------------------------------------------------------- */ @@ -108,7 +107,6 @@ void ComputeLocalCompAtom::init() auto req = neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); if (cutflag) req->set_cutoff(cutoff); - } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index ede766cbf8..a842a169c0 100755 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -96,6 +96,8 @@ action compute_coord_atom_kokkos.cpp action compute_coord_atom_kokkos.h action compute_erotate_sphere_kokkos.cpp action compute_erotate_sphere_kokkos.h +action compute_local_comp_atom_kokkos.cpp compute_local_comp_atom.cpp +action compute_local_comp_atom_kokkos.h compute_local_comp_atom.h action compute_orientorder_atom_kokkos.cpp action compute_orientorder_atom_kokkos.h action compute_temp_deform_kokkos.cpp diff --git a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp index 9360cbd82a..356efea2f1 100644 --- a/src/KOKKOS/compute_local_comp_atom_kokkos.cpp +++ b/src/KOKKOS/compute_local_comp_atom_kokkos.cpp @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing authors: Megan McCarthy (SNL), Stan Moore (SNL) + Contributing author: Megan McCarthy (SNL) ------------------------------------------------------------------------- */ #include "compute_local_comp_atom_kokkos.h" @@ -42,13 +42,11 @@ template ComputeLocalCompAtomKokkos::ComputeLocalCompAtomKokkos(LAMMPS *lmp, int narg, char **arg) : ComputeLocalCompAtom(lmp, narg, arg) { - kokkosable = 1; atomKK = (AtomKokkos *) atom; execution_space = ExecutionSpaceFromDevice::space; datamask_read = EMPTY_MASK; datamask_modify = EMPTY_MASK; - } /* ---------------------------------------------------------------------- */ @@ -59,7 +57,6 @@ ComputeLocalCompAtomKokkos::~ComputeLocalCompAtomKokkos() if (copymode) return; memoryKK->destroy_kokkos(k_result,result); - } /* ---------------------------------------------------------------------- */ @@ -82,7 +79,6 @@ void ComputeLocalCompAtomKokkos::init() template void ComputeLocalCompAtomKokkos::compute_peratom() { - invoked_peratom = update->ntimestep; // grow result array if necessary @@ -124,14 +120,12 @@ void ComputeLocalCompAtomKokkos::compute_peratom() k_result.modify(); k_result.sync_host(); - } template KOKKOS_INLINE_FUNCTION void ComputeLocalCompAtomKokkos::operator()(TagComputeLocalCompAtom, const int &ii) const { - const int i = d_ilist[ii]; if (mask[i] & groupbit) { From 5e9658aff6ff76fe55886dac158cd0801dd6cdb0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 4 Aug 2023 21:06:47 -0400 Subject: [PATCH 24/25] fix whitespace and minor documentation integration issues --- doc/src/Commands_compute.rst | 2 +- doc/src/compute_local_comp_atom.rst | 25 +++++++++++-------- src/EXTRA-COMPUTE/compute_local_comp_atom.cpp | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index 73f7373f8c..19e56fcc83 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -91,7 +91,7 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`ke/atom/eff ` * :doc:`ke/eff ` * :doc:`ke/rigid ` - * :doc:`local/comp/atom ` + * :doc:`local/comp/atom (k) ` * :doc:`mliap ` * :doc:`momentum ` * :doc:`msd ` diff --git a/doc/src/compute_local_comp_atom.rst b/doc/src/compute_local_comp_atom.rst index ad9331895e..2d0dd8c6f2 100644 --- a/doc/src/compute_local_comp_atom.rst +++ b/doc/src/compute_local_comp_atom.rst @@ -1,7 +1,10 @@ .. index:: compute local/comp/atom +.. index:: compute local/comp/atom/kk compute local/comp/atom command -====================================== +=============================== + +Accelerator Variants: *local/comp/atom/kk* Syntax """""" @@ -33,7 +36,7 @@ Examples Description """"""""""" -.. versionadded:: 24May2023 +.. versionadded:: TBD Define a computation that calculates a local composition vector for each atom. For a central atom with :math:`M` neighbors within the neighbor cutoff sphere, @@ -43,14 +46,14 @@ the sum of all compositions equals one. .. note:: - This compute uses the number of atom types, not chemical species, assigned in - :doc:`pair_coeff ` command. If an interatomic potential has two - species (i.e., Cu and Ni) assigned to four different atom types in - :doc:`pair_coeff ` (i.e., 'Cu Cu Ni Ni'), the compute will - output four fractional values. In those cases, the user may desire an extra - calculation step to consolidate per-type fractions into per-species fractions. - This calculation can be conducted within LAMMPS using another compute such as - :doc:`compute reduce `, an atom-style :doc:`variable`, or as a + This compute uses the number of atom types, not chemical species, assigned in + :doc:`pair_coeff ` command. If an interatomic potential has two + species (i.e., Cu and Ni) assigned to four different atom types in + :doc:`pair_coeff ` (i.e., 'Cu Cu Ni Ni'), the compute will + output four fractional values. In those cases, the user may desire an extra + calculation step to consolidate per-type fractions into per-species fractions. + This calculation can be conducted within LAMMPS using another compute such as + :doc:`compute reduce `, an atom-style :doc:`variable`, or as a post-processing step. ---------- @@ -91,7 +94,7 @@ Output info This compute calculates a per-atom array with :math:`1 + N` columns, where :math:`N` is the number of atom types. The first column is a count of the number of atoms used to calculate composition (including the central atom), and each subsequent -column indicates the fraction of that atom type within the cutoff sphere. +column indicates the fraction of that atom type within the cutoff sphere. These values can be accessed by any command that uses per-atom values from a compute as input. See the :doc:`Howto output ` diff --git a/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp index 02ab91d969..77c4993996 100644 --- a/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_local_comp_atom.cpp @@ -198,7 +198,7 @@ void ComputeLocalCompAtom::compute_peratom() double lfac = 1.0 / count; for (int n = 1; n < size_peratom_cols; n++) result[i][n+1] *= lfac; - + } } } From 003a207038b419fa6fa1654be45010d6b8884298 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 4 Aug 2023 22:24:48 -0400 Subject: [PATCH 25/25] possible workaround for unit test failure taken from: https://github.com/open-mpi/ompi/issues/9656 --- unittest/formats/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unittest/formats/CMakeLists.txt b/unittest/formats/CMakeLists.txt index 5b5dd056c9..9934c87ab1 100644 --- a/unittest/formats/CMakeLists.txt +++ b/unittest/formats/CMakeLists.txt @@ -40,6 +40,8 @@ set_tests_properties(TextFileReader PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${ add_executable(test_file_operations test_file_operations.cpp) target_link_libraries(test_file_operations PRIVATE lammps GTest::GMock) add_test(NAME FileOperations COMMAND test_file_operations) +# try to mitigate possible OpenMPI bug +set_tests_properties(TextFileReader PROPERTIES ENVIRONMENT "OMPI_MCA_sharedfp=\"^sm\"") add_executable(test_dump_atom test_dump_atom.cpp) target_link_libraries(test_dump_atom PRIVATE lammps GTest::GMock)