Initial Gaussian grid implementation

This commit is contained in:
rohskopf
2023-06-24 15:56:54 -06:00
parent 5e01ffe6a6
commit fc5e583c56
4 changed files with 160 additions and 19 deletions

View File

@ -0,0 +1,85 @@
/* ----------------------------------------------------------------------
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: Drew Rohskopf (SNL)
------------------------------------------------------------------------- */
#include "compute_gaussian_grid_local_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 <cmath>
#include <cstring>
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
template<class DeviceType>
ComputeGaussianGridLocalKokkos<DeviceType>::ComputeGaussianGridLocalKokkos(LAMMPS *lmp, int narg, char **arg) :
ComputeGaussianGridLocal(lmp, narg, arg)
{
kokkosable = 1;
atomKK = (AtomKokkos *) atom;
execution_space = ExecutionSpaceFromDevice<DeviceType>::space;
datamask_read = EMPTY_MASK;
datamask_modify = EMPTY_MASK;
}
/* ---------------------------------------------------------------------- */
template<class DeviceType>
ComputeGaussianGridLocalKokkos<DeviceType>::~ComputeGaussianGridLocalKokkos()
{
if (copymode) return;
//memoryKK->destroy_kokkos(k_result,result);
}
/* ---------------------------------------------------------------------- */
template<class DeviceType>
void ComputeGaussianGridLocalKokkos<DeviceType>::init()
{
ComputeGaussianGridLocal::init();
}
/* ---------------------------------------------------------------------- */
template<class DeviceType>
void ComputeGaussianGridLocalKokkos<DeviceType>::compute_local()
{
printf(">>> compute_local Kokkos\n");
}
namespace LAMMPS_NS {
template class ComputeGaussianGridLocalKokkos<LMPDeviceType>;
#ifdef LMP_KOKKOS_GPU
template class ComputeGaussianGridLocalKokkos<LMPHostType>;
#endif
}

View File

@ -0,0 +1,75 @@
/* -*- 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(gaussian/grid/local/kk,ComputeGaussianGridLocalKokkos<LMPDeviceType>);
ComputeStyle(gaussian/grid/local/kk/device,ComputeGaussianGridLocalKokkos<LMPDeviceType>);
ComputeStyle(gaussian/grid/local/kk/host,ComputeGaussianGridLocalKokkos<LMPHostType>);
// clang-format on
#else
#ifndef LMP_COMPUTE_GAUSSIAN_GRID_LOCAL_KOKKOS_H
#define LMP_COMPUTE_GAUSSIAN_GRID_LOCAL_KOKKOS_H
#include "compute_gaussian_grid_local.h"
#include "kokkos_type.h"
namespace LAMMPS_NS {
// clang-format off
//struct TagComputeGaussianGridLocal {};
// clang-format on
template <class DeviceType> class ComputeGaussianGridLocalKokkos : public ComputeGaussianGridLocal {
public:
typedef DeviceType device_type;
typedef ArrayTypes<DeviceType> AT;
ComputeGaussianGridLocalKokkos(class LAMMPS *, int, char **);
~ComputeGaussianGridLocalKokkos() override;
void init() override;
void compute_local() override;
//KOKKOS_INLINE_FUNCTION
//void operator()(TagComputeGaussianGridLocal const int &) const;
private:
//double adof, mvv2e, mv2d, boltz;
Kokkos::View<double*, DeviceType> d_radelem; // element radii
Kokkos::View<int*, DeviceType> d_ninside; // ninside for all atoms in list
Kokkos::View<int*, DeviceType> d_map; // mapping from atom types to elements
/*
typename AT::t_x_array x;
typename AT::t_v_array v;
typename ArrayTypes<DeviceType>::t_float_1d rmass;
typename ArrayTypes<DeviceType>::t_float_1d mass;
typename ArrayTypes<DeviceType>::t_int_1d type;
typename ArrayTypes<DeviceType>::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

View File

@ -252,14 +252,6 @@ class ComputeSNAGridKokkos : public ComputeSNAGrid {
typename AT::t_float_2d d_grid;
typename AT::t_float_2d d_gridall;
//DAT::tdual_float_4d k_gridlocal;
//typedef Kokkos::DualView<real_type****, Kokkos::LayoutLeft, DeviceType> t_gridlocal_4d;
//typedef Kokkos::View<real_type****, DeviceType> t_4d;
// should we use LMPDeviceType below?
//typedef Kokkos::DualView<LMP_FLOAT****, LMPDeviceType> tdual_float_4d;
//typedef tdual_float_4d::t_dev tdev_float_4d;
//tdual_float_4d k_gridlocal;
//tdev_float_4d d_gridlocal;
DAT::tdual_float_4d k_gridlocal;
typename AT::t_float_4d d_gridlocal;

View File

@ -168,22 +168,11 @@ void ComputeSNAGridKokkos<DeviceType, real_type, vector_length>::setup()
ComputeGrid::set_grid_local();
// allocate arrays
//printf(">>> Allocating gridall.\n");
//printf(">>> %d %d\n", size_array_rows, size_array_cols);
//memoryKK->create_kokkos(k_grid,grid, size_array_rows, size_array_cols, "grid:grid");
memoryKK->create_kokkos(k_gridall, gridall, size_array_rows, size_array_cols, "grid:gridall");
//printf(">>> Allocated gridall.\n");
// do not use or allocate gridlocal for now
gridlocal_allocated = 0;
/*
if (nxlo <= nxhi && nylo <= nyhi && nzlo <= nzhi) {
gridlocal_allocated = 1;
memoryKK->create4d_offset_kokkos(k_gridlocal, gridlocal, size_array_cols, nzlo, nzhi, nylo,
nyhi, nxlo, nxhi, "grid:gridlocal");
}
*/
array = gridall;
d_gridlocal = k_gridlocal.template view<DeviceType>();