Use multiple inheritance to remove accelerator_kokkos.h out of pair.h
This commit is contained in:
1
src/.gitignore
vendored
1
src/.gitignore
vendored
@ -25,6 +25,7 @@
|
||||
/kokkos.h
|
||||
/kokkos_type.h
|
||||
/kokkos_few.h
|
||||
/kokkos_base.h
|
||||
|
||||
/manifold*.cpp
|
||||
/manifold*.h
|
||||
|
||||
@ -124,8 +124,9 @@ action improper_harmonic_kokkos.cpp improper_harmonic.cpp
|
||||
action improper_harmonic_kokkos.h improper_harmonic.h
|
||||
action kokkos.cpp
|
||||
action kokkos.h
|
||||
action kokkos_type.h
|
||||
action kokkos_base.h
|
||||
action kokkos_few.h
|
||||
action kokkos_type.h
|
||||
action memory_kokkos.h
|
||||
action modify_kokkos.cpp
|
||||
action modify_kokkos.h
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include "dump.h"
|
||||
#include "output.h"
|
||||
#include "modify.h"
|
||||
#include "kokkos_base.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -379,6 +380,7 @@ void CommKokkos::forward_comm_pair_device(Pair *pair)
|
||||
MPI_Request request;
|
||||
|
||||
int nsize = pair->comm_forward;
|
||||
KokkosBase* pairKKBase = (KokkosBase*) pair;
|
||||
|
||||
for (iswap = 0; iswap < nswap; iswap++) {
|
||||
int n = MAX(max_buf_pair,nsize*sendnum[iswap]);
|
||||
@ -391,7 +393,7 @@ void CommKokkos::forward_comm_pair_device(Pair *pair)
|
||||
|
||||
// pack buffer
|
||||
|
||||
n = pair->pack_forward_comm_kokkos(sendnum[iswap],k_sendlist,
|
||||
n = pairKKBase->pack_forward_comm_kokkos(sendnum[iswap],k_sendlist,
|
||||
iswap,k_buf_send_pair,pbc_flag[iswap],pbc[iswap]);
|
||||
|
||||
// exchange with another proc
|
||||
@ -408,7 +410,7 @@ void CommKokkos::forward_comm_pair_device(Pair *pair)
|
||||
|
||||
// unpack buffer
|
||||
|
||||
pair->unpack_forward_comm_kokkos(recvnum[iswap],firstrecv[iswap],k_buf_recv_pair);
|
||||
pairKKBase->unpack_forward_comm_kokkos(recvnum[iswap],firstrecv[iswap],k_buf_recv_pair);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
36
src/KOKKOS/kokkos_base.h
Normal file
36
src/KOKKOS/kokkos_base.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef KOKKOS_BASE_H
|
||||
#define KOKKOS_BASE_H
|
||||
|
||||
#include "kokkos_type.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class KokkosBase {
|
||||
public:
|
||||
KokkosBase() {}
|
||||
virtual int pack_forward_comm_kokkos(int, DAT::tdual_int_2d,
|
||||
int, DAT::tdual_xfloat_1d &,
|
||||
int, int *) {return 0;};
|
||||
virtual void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d &) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
*/
|
||||
@ -14,15 +14,14 @@
|
||||
#ifndef LMP_MEMORY_KOKKOS_H
|
||||
#define LMP_MEMORY_KOKKOS_H
|
||||
|
||||
#ifdef LMP_KOKKOS
|
||||
#include "memory.h"
|
||||
#include "kokkos_type.h"
|
||||
#endif
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class MemoryKokkos : public Memory {
|
||||
public:
|
||||
MemoryKokkos::MemoryKokkos(class LAMMPS *lmp) : Memory(lmp) {}
|
||||
MemoryKokkos(class LAMMPS *lmp) : Memory(lmp) {}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Kokkos versions of create/grow/destroy multi-dimensional arrays
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "neighbor_kokkos.h"
|
||||
#include "atom.h"
|
||||
#include "atom_kokkos.h"
|
||||
#include "pair.h"
|
||||
#include "fix.h"
|
||||
#include "neigh_request.h"
|
||||
|
||||
@ -24,6 +24,7 @@ PairStyle(eam/alloy/kk/host,PairEAMAlloyKokkos<LMPHostType>)
|
||||
#define LMP_PAIR_EAM_ALLOY_KOKKOS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "kokkos_base.h"
|
||||
#include "pair_kokkos.h"
|
||||
#include "pair_eam.h"
|
||||
#include "neigh_list_kokkos.h"
|
||||
@ -49,7 +50,7 @@ struct TagPairEAMAlloyKernelC{};
|
||||
// Cannot use virtual inheritance on the GPU
|
||||
|
||||
template<class DeviceType>
|
||||
class PairEAMAlloyKokkos : public PairEAM {
|
||||
class PairEAMAlloyKokkos : public PairEAM, public KokkosBase {
|
||||
public:
|
||||
enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF};
|
||||
enum {COUL_FLAG=0};
|
||||
@ -59,7 +60,7 @@ class PairEAMAlloyKokkos : public PairEAM {
|
||||
|
||||
PairEAMAlloyKokkos(class LAMMPS *);
|
||||
virtual ~PairEAMAlloyKokkos();
|
||||
virtual void compute(int, int);
|
||||
void compute(int, int);
|
||||
void init_style();
|
||||
void *extract(const char *, int &) { return NULL; }
|
||||
void coeff(int, char **);
|
||||
@ -107,11 +108,11 @@ class PairEAMAlloyKokkos : public PairEAM {
|
||||
const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx,
|
||||
const F_FLOAT &dely, const F_FLOAT &delz) const;
|
||||
|
||||
virtual int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&,
|
||||
int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&,
|
||||
int, int *);
|
||||
virtual void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&);
|
||||
virtual int pack_forward_comm(int, int *, double *, int, int *);
|
||||
virtual void unpack_forward_comm(int, int, double *);
|
||||
void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&);
|
||||
int pack_forward_comm(int, int *, double *, int, int *);
|
||||
void unpack_forward_comm(int, int, double *);
|
||||
int pack_reverse_comm(int, int, double *);
|
||||
void unpack_reverse_comm(int, int *, double *);
|
||||
|
||||
@ -148,7 +149,7 @@ class PairEAMAlloyKokkos : public PairEAM {
|
||||
t_ffloat_2d_n7_randomread d_rhor_spline;
|
||||
t_ffloat_2d_n7_randomread d_z2r_spline;
|
||||
|
||||
virtual void file2array();
|
||||
void file2array();
|
||||
void file2array_alloy();
|
||||
void array2spline();
|
||||
void interpolate(int, double, double *, t_host_ffloat_2d_n7, int);
|
||||
|
||||
@ -24,6 +24,7 @@ PairStyle(eam/fs/kk/host,PairEAMFSKokkos<LMPHostType>)
|
||||
#define LMP_PAIR_EAM_FS_KOKKOS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "kokkos_base.h"
|
||||
#include "pair_kokkos.h"
|
||||
#include "pair_eam.h"
|
||||
#include "neigh_list_kokkos.h"
|
||||
@ -49,7 +50,7 @@ struct TagPairEAMFSKernelC{};
|
||||
// Cannot use virtual inheritance on the GPU
|
||||
|
||||
template<class DeviceType>
|
||||
class PairEAMFSKokkos : public PairEAM {
|
||||
class PairEAMFSKokkos : public PairEAM, public KokkosBase {
|
||||
public:
|
||||
enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF};
|
||||
enum {COUL_FLAG=0};
|
||||
@ -59,7 +60,7 @@ class PairEAMFSKokkos : public PairEAM {
|
||||
|
||||
PairEAMFSKokkos(class LAMMPS *);
|
||||
virtual ~PairEAMFSKokkos();
|
||||
virtual void compute(int, int);
|
||||
void compute(int, int);
|
||||
void init_style();
|
||||
void *extract(const char *, int &) { return NULL; }
|
||||
void coeff(int, char **);
|
||||
@ -107,11 +108,11 @@ class PairEAMFSKokkos : public PairEAM {
|
||||
const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx,
|
||||
const F_FLOAT &dely, const F_FLOAT &delz) const;
|
||||
|
||||
virtual int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&,
|
||||
int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&,
|
||||
int, int *);
|
||||
virtual void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&);
|
||||
virtual int pack_forward_comm(int, int *, double *, int, int *);
|
||||
virtual void unpack_forward_comm(int, int, double *);
|
||||
void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&);
|
||||
int pack_forward_comm(int, int *, double *, int, int *);
|
||||
void unpack_forward_comm(int, int, double *);
|
||||
int pack_reverse_comm(int, int, double *);
|
||||
void unpack_reverse_comm(int, int *, double *);
|
||||
|
||||
@ -148,7 +149,7 @@ class PairEAMFSKokkos : public PairEAM {
|
||||
t_ffloat_2d_n7_randomread d_rhor_spline;
|
||||
t_ffloat_2d_n7_randomread d_z2r_spline;
|
||||
|
||||
virtual void file2array();
|
||||
void file2array();
|
||||
void file2array_fs();
|
||||
void array2spline();
|
||||
void interpolate(int, double, double *, t_host_ffloat_2d_n7, int);
|
||||
|
||||
@ -24,6 +24,7 @@ PairStyle(eam/kk/host,PairEAMKokkos<LMPHostType>)
|
||||
#define LMP_PAIR_EAM_KOKKOS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "kokkos_base.h"
|
||||
#include "pair_kokkos.h"
|
||||
#include "pair_eam.h"
|
||||
#include "neigh_list_kokkos.h"
|
||||
@ -47,7 +48,7 @@ template<int NEIGHFLAG, int NEWTON_PAIR, int EVFLAG>
|
||||
struct TagPairEAMKernelC{};
|
||||
|
||||
template<class DeviceType>
|
||||
class PairEAMKokkos : public PairEAM {
|
||||
class PairEAMKokkos : public PairEAM, public KokkosBase {
|
||||
public:
|
||||
enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF};
|
||||
enum {COUL_FLAG=0};
|
||||
@ -57,7 +58,7 @@ class PairEAMKokkos : public PairEAM {
|
||||
|
||||
PairEAMKokkos(class LAMMPS *);
|
||||
virtual ~PairEAMKokkos();
|
||||
virtual void compute(int, int);
|
||||
void compute(int, int);
|
||||
void init_style();
|
||||
void *extract(const char *, int &) { return NULL; }
|
||||
|
||||
@ -104,11 +105,11 @@ class PairEAMKokkos : public PairEAM {
|
||||
const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx,
|
||||
const F_FLOAT &dely, const F_FLOAT &delz) const;
|
||||
|
||||
virtual int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&,
|
||||
int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&,
|
||||
int, int *);
|
||||
virtual void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&);
|
||||
virtual int pack_forward_comm(int, int *, double *, int, int *);
|
||||
virtual void unpack_forward_comm(int, int, double *);
|
||||
void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&);
|
||||
int pack_forward_comm(int, int *, double *, int, int *);
|
||||
void unpack_forward_comm(int, int, double *);
|
||||
int pack_reverse_comm(int, int, double *);
|
||||
void unpack_reverse_comm(int, int *, double *);
|
||||
|
||||
@ -146,7 +147,7 @@ class PairEAMKokkos : public PairEAM {
|
||||
t_ffloat_2d_n7_randomread d_z2r_spline;
|
||||
void interpolate(int, double, double *, t_host_ffloat_2d_n7, int);
|
||||
|
||||
virtual void file2array();
|
||||
void file2array();
|
||||
void array2spline();
|
||||
|
||||
typename AT::t_neighbors_2d d_neighbors;
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include "error.h"
|
||||
#include "respa.h"
|
||||
#include "atom_masks.h"
|
||||
#include "kokkos.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#include "reaxc_defs.h"
|
||||
#include "reaxc_lookup.h"
|
||||
#include "reaxc_tool_box.h"
|
||||
#include "modify.h"
|
||||
|
||||
|
||||
#define TEAMSIZE 128
|
||||
|
||||
@ -91,9 +91,9 @@ class NeighborKokkos : public Neighbor {
|
||||
~NeighborKokkos() {}
|
||||
};
|
||||
|
||||
class MemoryKokkos : public MemoryBrick {
|
||||
class MemoryKokkos : public Memory {
|
||||
public:
|
||||
MemoryKokkos(class LAMMPS *lmp) : MemoryBrick(lmp) {}
|
||||
MemoryKokkos(class LAMMPS *lmp) : Memory(lmp) {}
|
||||
~MemoryKokkos() {}
|
||||
void grow_kokkos(tagint **, tagint **, int, int, const char*) {}
|
||||
};
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "compute_aggregate_atom.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec.h"
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "compute_orientorder_atom.h"
|
||||
#include "atom.h"
|
||||
#include "update.h"
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "comm.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace MathConst;
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
#define LMP_PAIR_H
|
||||
|
||||
#include "pointers.h"
|
||||
#include "accelerator_kokkos.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
@ -165,10 +164,6 @@ class Pair : protected Pointers {
|
||||
|
||||
virtual int pack_forward_comm(int, int *, double *, int, int *) {return 0;}
|
||||
virtual void unpack_forward_comm(int, int, double *) {}
|
||||
virtual int pack_forward_comm_kokkos(int, DAT::tdual_int_2d,
|
||||
int, DAT::tdual_xfloat_1d &,
|
||||
int, int *) {return 0;};
|
||||
virtual void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d &) {}
|
||||
virtual int pack_reverse_comm(int, int, double *) {return 0;}
|
||||
virtual void unpack_reverse_comm(int, int *, double *) {}
|
||||
virtual double memory_usage();
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include "force.h"
|
||||
#include "universe.h"
|
||||
#include "error.h"
|
||||
#include "domain.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user