Merge branch 'gridcomm-tiled' of github.com:lammps/lammps into gridcomm-tiled

This commit is contained in:
Steve Plimpton 2020-08-14 09:41:37 -06:00
commit 71e0646063
7 changed files with 654 additions and 356 deletions

File diff suppressed because it is too large Load Diff

View File

@ -14,83 +14,63 @@
#ifndef LMP_GRIDCOMM_KOKKOS_H
#define LMP_GRIDCOMM_KOKKOS_H
#include "pointers.h"
#include "gridcomm.h"
#include "kokkos_type.h"
#include "fftdata_kokkos.h"
#ifdef FFT_SINGLE
typedef float FFT_SCALAR;
#define MPI_FFT_SCALAR MPI_FLOAT
#else
typedef double FFT_SCALAR;
#define MPI_FFT_SCALAR MPI_DOUBLE
#endif
namespace LAMMPS_NS {
template<class DeviceType>
class GridCommKokkos : protected Pointers {
class GridCommKokkos : public GridComm {
public:
typedef DeviceType device_type;
typedef ArrayTypes<DeviceType> AT;
typedef FFTArrayTypes<DeviceType> FFT_AT;
GridCommKokkos(class LAMMPS *, MPI_Comm, int, int,
int, int, int, int, int, int,
int, int, int, int, int, int,
int, int, int, int, int, int);
GridCommKokkos(class LAMMPS *, MPI_Comm, int, int,
int, int, int, int, int, int,
int, int, int, int, int, int,
int, int, int, int, int, int,
int, int, int, int, int, int);
GridCommKokkos(class LAMMPS *, MPI_Comm, int, int, int,
int, int, int, int, int, int,
int, int, int, int, int, int);
GridCommKokkos(class LAMMPS *, MPI_Comm, int, int, int, int,
int, int, int, int, int, int,
int, int, int, int, int, int,
int, int, int, int, int, int);
~GridCommKokkos();
void ghost_notify();
int ghost_overlap();
void setup();
void forward_comm(class KSpace *, int);
void reverse_comm(class KSpace *, int);
double memory_usage();
void setup(int &, int &);
int ghost_adjacent();
void forward_comm_kspace(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
void reverse_comm_kspace(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
private:
int me;
int nforward,nreverse;
MPI_Comm gridcomm;
MPI_Request request;
DAT::tdual_int_2d k_swap_packlist;
DAT::tdual_int_2d k_swap_unpacklist;
// in = inclusive indices of 3d grid chunk that I own
// out = inclusive indices of 3d grid chunk I own plus ghosts I use
// proc = 6 neighbor procs that surround me
// ghost = # of my owned grid planes needed from me
// by each of 6 neighbor procs to become their ghost planes
DAT::tdual_int_2d k_send_packlist;
int inxlo,inxhi,inylo,inyhi,inzlo,inzhi;
int outxlo,outxhi,outylo,outyhi,outzlo,outzhi;
int outxlo_max,outxhi_max,outylo_max,outyhi_max,outzlo_max,outzhi_max;
int procxlo,procxhi,procylo,procyhi,proczlo,proczhi;
int ghostxlo,ghostxhi,ghostylo,ghostyhi,ghostzlo,ghostzhi;
DAT::tdual_int_2d k_recv_unpacklist;
int nbuf;
//FFT_SCALAR *buf1,*buf2;
FFT_DAT::tdual_FFT_SCALAR_1d k_buf1;
FFT_DAT::tdual_FFT_SCALAR_1d k_buf2;
DAT::tdual_int_2d k_copy_packlist;
DAT::tdual_int_2d k_copy_unpacklist;
struct Swap {
int sendproc; // proc to send to for forward comm
int recvproc; // proc to recv from for forward comm
int npack; // # of datums to pack
int nunpack; // # of datums to unpack
//int *packlist; // 3d array offsets to pack
//int *unpacklist; // 3d array offsets to unpack
};
// -------------------------------------------
// internal methods
// -------------------------------------------
DAT::tdual_int_2d k_packlist;
DAT::tdual_int_2d k_unpacklist;
void setup_regular(int &, int &);
void setup_tiled(int &, int &);
int nswap;
Swap *swap;
void forward_comm_kspace_regular(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
void forward_comm_kspace_tiled(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
void reverse_comm_kspace_regular(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
void reverse_comm_kspace_tiled(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
int indices(DAT::tdual_int_2d &, int, int, int, int, int, int, int);
void grow_swap();
int indices_kokkos(DAT::tdual_int_2d &, int, int, int, int, int, int, int);
};
}

View File

@ -24,9 +24,9 @@ class KokkosBaseFFT {
//Kspace
virtual void pack_forward_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, DAT::tdual_int_2d &, int) {};
virtual void unpack_forward_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, DAT::tdual_int_2d &, int) {};
virtual void unpack_forward_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, int, DAT::tdual_int_2d &, int) {};
virtual void pack_reverse_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, DAT::tdual_int_2d &, int) {};
virtual void unpack_reverse_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, DAT::tdual_int_2d &, int) {};
virtual void unpack_reverse_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, int, DAT::tdual_int_2d &, int) {};
};
}

View File

@ -2568,7 +2568,7 @@ void PPPMKokkos<DeviceType>::operator()(TagPPPM_fieldforce_peratom, const int &i
------------------------------------------------------------------------- */
template<class DeviceType>
void PPPMKokkos<DeviceType>::pack_forward_kspace_kokkos(int flag, FFT_DAT::tdual_FFT_SCALAR_1d &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index)
void PPPMKokkos<DeviceType>::pack_forward_grid_kokkos(int flag, FFT_DAT::tdual_FFT_SCALAR_1d &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index)
{
typename AT::t_int_2d_um d_list = k_list.view<DeviceType>();
d_list_index = Kokkos::subview(d_list,index,Kokkos::ALL());
@ -2624,11 +2624,12 @@ void PPPMKokkos<DeviceType>::operator()(TagPPPM_pack_forward2, const int &i) con
------------------------------------------------------------------------- */
template<class DeviceType>
void PPPMKokkos<DeviceType>::unpack_forward_kspace_kokkos(int flag, FFT_DAT::tdual_FFT_SCALAR_1d &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index)
void PPPMKokkos<DeviceType>::unpack_forward_grid_kokkos(int flag, FFT_DAT::tdual_FFT_SCALAR_1d &k_buf, int offset, int nlist, DAT::tdual_int_2d &k_list, int index)
{
typename AT::t_int_2d_um d_list = k_list.view<DeviceType>();
d_list_index = Kokkos::subview(d_list,index,Kokkos::ALL());
d_buf = k_buf.view<DeviceType>();
unpack_offset = offset;
nx = (nxhi_out-nxlo_out+1);
ny = (nyhi_out-nylo_out+1);
@ -2652,9 +2653,9 @@ void PPPMKokkos<DeviceType>::operator()(TagPPPM_unpack_forward1, const int &i) c
const int iz = (int) (dlist/(nx*ny));
const int iy = (int) ((dlist - iz*nx*ny)/nx);
const int ix = d_list_index[i] - iz*nx*ny - iy*nx;
d_vdx_brick(iz,iy,ix) = d_buf[3*i];
d_vdy_brick(iz,iy,ix) = d_buf[3*i+1];
d_vdz_brick(iz,iy,ix) = d_buf[3*i+2];
d_vdx_brick(iz,iy,ix) = d_buf[3*i + unpack_offset];
d_vdy_brick(iz,iy,ix) = d_buf[3*i+1 + unpack_offset];
d_vdz_brick(iz,iy,ix) = d_buf[3*i+2 + unpack_offset];
}
template<class DeviceType>
@ -2681,7 +2682,7 @@ void PPPMKokkos<DeviceType>::operator()(TagPPPM_unpack_forward2, const int &i) c
------------------------------------------------------------------------- */
template<class DeviceType>
void PPPMKokkos<DeviceType>::pack_reverse_kspace_kokkos(int flag, FFT_DAT::tdual_FFT_SCALAR_1d &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index)
void PPPMKokkos<DeviceType>::pack_reverse_grid_kokkos(int flag, FFT_DAT::tdual_FFT_SCALAR_1d &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index)
{
typename AT::t_int_2d_um d_list = k_list.view<DeviceType>();
d_list_index = Kokkos::subview(d_list,index,Kokkos::ALL());
@ -2711,11 +2712,12 @@ void PPPMKokkos<DeviceType>::operator()(TagPPPM_pack_reverse, const int &i) cons
------------------------------------------------------------------------- */
template<class DeviceType>
void PPPMKokkos<DeviceType>::unpack_reverse_kspace_kokkos(int flag, FFT_DAT::tdual_FFT_SCALAR_1d &k_buf, int nlist, DAT::tdual_int_2d &k_list, int index)
void PPPMKokkos<DeviceType>::unpack_reverse_grid_kokkos(int flag, FFT_DAT::tdual_FFT_SCALAR_1d &k_buf, int offset, int nlist, DAT::tdual_int_2d &k_list, int index)
{
typename AT::t_int_2d_um d_list = k_list.view<DeviceType>();
d_list_index = Kokkos::subview(d_list,index,Kokkos::ALL());
d_buf = k_buf.view<DeviceType>();
unpack_offset = offset;
nx = (nxhi_out-nxlo_out+1);
ny = (nyhi_out-nylo_out+1);
@ -2733,7 +2735,7 @@ void PPPMKokkos<DeviceType>::operator()(TagPPPM_unpack_reverse, const int &i) co
const int iz = (int) (dlist/(nx*ny));
const int iy = (int) ((dlist - iz*nx*ny)/nx);
const int ix = d_list_index[i] - iz*nx*ny - iy*nx;
d_density_brick(iz,iy,ix) += d_buf[i];
d_density_brick(iz,iy,ix) += d_buf[i + unpack_offset];
}
/* ----------------------------------------------------------------------

View File

@ -311,6 +311,7 @@ class PPPMKokkos : public PPPM, public KokkosBaseFFT {
int nx,ny,nz;
typename AT::t_int_1d_um d_list_index;
typename FFT_AT::t_FFT_SCALAR_1d_um d_buf;
int unpack_offset;
DAT::tdual_int_scalar k_flag;
@ -404,9 +405,9 @@ class PPPMKokkos : public PPPM, public KokkosBaseFFT {
// grid communication
void pack_forward_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, DAT::tdual_int_2d &, int);
void unpack_forward_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, DAT::tdual_int_2d &, int);
void unpack_forward_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, int, DAT::tdual_int_2d &, int);
void pack_reverse_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, DAT::tdual_int_2d &, int);
void unpack_reverse_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, DAT::tdual_int_2d &, int);
void unpack_reverse_kspace_kokkos(int, FFT_DAT::tdual_FFT_SCALAR_1d &, int, int, DAT::tdual_int_2d &, int);
// triclinic

View File

@ -1095,8 +1095,8 @@ void GridComm::grow_overlap()
/* ----------------------------------------------------------------------
create 1d list of offsets into 3d array section (xlo:xhi,ylo:yhi,zlo:zhi)
assume 3d array is allocated as (outxlo_max:outxhi_max,outylo_max:outyhi_max,
outzlo_max:outzhi_max)
assume 3d array is allocated as (fullxlo:fullxhi,fullylo:fullyhi,
fullzlo:fullzhi)
------------------------------------------------------------------------- */
int GridComm::indices(int *&list,

View File

@ -27,15 +27,15 @@ class GridComm : protected Pointers {
int, int, int, int, int, int,
int, int, int, int, int, int,
int, int, int, int, int, int);
~GridComm();
void setup(int &, int &);
int ghost_adjacent();
void forward_comm_kspace(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
void reverse_comm_kspace(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
virtual ~GridComm();
virtual void setup(int &, int &);
virtual int ghost_adjacent();
virtual void forward_comm_kspace(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
virtual void reverse_comm_kspace(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
private:
protected:
int me,nprocs;
int layout; // REGULAR or TILED
MPI_Comm gridcomm; // communicator for this class
@ -181,24 +181,24 @@ class GridComm : protected Pointers {
int, int, int, int, int, int,
int, int, int, int, int, int,
int, int, int, int, int, int);
void setup_regular(int &, int &);
void setup_tiled(int &, int &);
virtual void setup_regular(int &, int &);
virtual void setup_tiled(int &, int &);
void ghost_box_drop(int *, int *);
void box_drop_grid(int *, int, int, int &, int *);
int ghost_adjacent_regular();
int ghost_adjacent_tiled();
void forward_comm_kspace_regular(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
void forward_comm_kspace_tiled(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
void reverse_comm_kspace_regular(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
void reverse_comm_kspace_tiled(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
virtual void forward_comm_kspace_regular(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
virtual void forward_comm_kspace_tiled(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
virtual void reverse_comm_kspace_regular(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
virtual void reverse_comm_kspace_tiled(class KSpace *, int, int, int,
void *, void *, MPI_Datatype);
void grow_swap();
virtual void grow_swap();
void grow_overlap();
int indices(int *&, int, int, int, int, int, int);