forked from lijiext/lammps
Fix issues in Kokkos npair_halffull and npair_skip
This commit is contained in:
parent
52d3e98f3b
commit
9e35e76b8c
|
@ -59,18 +59,21 @@ void NPairHalffullKokkos<DeviceType,NEWTON>::build(NeighList *list)
|
|||
|
||||
NeighListKokkos<DeviceType>* k_list = static_cast<NeighListKokkos<DeviceType>*>(list);
|
||||
k_list->maxneighs = k_list_full->maxneighs; // simple, but could be made more memory efficient
|
||||
k_list->grow(inum_full);
|
||||
k_list->grow(atom->nmax);
|
||||
d_ilist = k_list->d_ilist;
|
||||
d_numneigh = k_list->d_numneigh;
|
||||
d_neighbors = k_list->d_neighbors;
|
||||
|
||||
// loop over parent full list
|
||||
|
||||
copymode = 1;
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagNPairHalffullCompute>(0,inum_full),*this);
|
||||
|
||||
list->inum = k_list_full->inum;
|
||||
list->gnum = k_list_full->gnum;
|
||||
k_list->k_ilist.template modify<DeviceType>();
|
||||
|
||||
copymode = 0;
|
||||
}
|
||||
|
||||
template<class DeviceType, int NEWTON>
|
||||
|
|
|
@ -156,8 +156,6 @@ class NPairHalffullKokkos : public NPair {
|
|||
typename AT::t_neighbors_2d d_neighbors;
|
||||
typename AT::t_int_1d d_ilist;
|
||||
typename AT::t_int_1d d_numneigh;
|
||||
|
||||
ExecutionSpace execution_space;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -54,12 +54,12 @@ void NPairSkipKokkos<DeviceType>::build(NeighList *list)
|
|||
d_numneigh_skip = k_list_skip->d_numneigh;
|
||||
d_neighbors_skip = k_list_skip->d_neighbors;
|
||||
|
||||
int num_skip = list->listskip->inum;
|
||||
num_skip = list->listskip->inum;
|
||||
if (list->ghost) num_skip += list->listskip->gnum;
|
||||
|
||||
NeighListKokkos<DeviceType>* k_list = static_cast<NeighListKokkos<DeviceType>*>(list);
|
||||
k_list->maxneighs = k_list_skip->maxneighs; // simple, but could be made more memory efficient
|
||||
k_list->grow(num_skip);
|
||||
k_list->grow(atom->nmax);
|
||||
d_ilist = k_list->d_ilist;
|
||||
d_numneigh = k_list->d_numneigh;
|
||||
d_neighbors = k_list->d_neighbors;
|
||||
|
@ -83,13 +83,12 @@ void NPairSkipKokkos<DeviceType>::build(NeighList *list)
|
|||
k_iskip.sync<DeviceType>();
|
||||
k_ijskip.sync<DeviceType>();
|
||||
|
||||
Kokkos::deep_copy(d_inum,0);
|
||||
|
||||
// loop over atoms in other list
|
||||
// skip I atom entirely if iskip is set for type[I]
|
||||
// skip I,J pair if ijskip is set for type[I],type[J]
|
||||
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagNPairSkipCompute>(0,num_skip),*this);
|
||||
copymode = 1;
|
||||
Kokkos::parallel_scan(Kokkos::RangePolicy<DeviceType, TagNPairSkipCompute>(0,num_skip),*this);
|
||||
|
||||
auto h_inum = Kokkos::create_mirror_view(d_inum);
|
||||
Kokkos::deep_copy(h_inum,d_inum);
|
||||
|
@ -101,34 +100,41 @@ void NPairSkipKokkos<DeviceType>::build(NeighList *list)
|
|||
list->inum = num;
|
||||
list->gnum = inum - num;
|
||||
}
|
||||
copymode = 0;
|
||||
}
|
||||
|
||||
template<class DeviceType>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void NPairSkipKokkos<DeviceType>::operator()(TagNPairSkipCompute, const int &ii) const {
|
||||
void NPairSkipKokkos<DeviceType>::operator()(TagNPairSkipCompute, const int &ii, int &inum, const bool &final) const {
|
||||
|
||||
const int i = d_ilist_skip(ii);
|
||||
const int itype = type(i);
|
||||
if (d_iskip(itype)) return;
|
||||
|
||||
int n = 0;
|
||||
if (final) {
|
||||
|
||||
// loop over parent non-skip list
|
||||
int n = 0;
|
||||
|
||||
const int jnum = d_numneigh_skip(i);
|
||||
const AtomNeighbors neighbors_i = AtomNeighbors(&d_neighbors(i,0),d_numneigh(i),
|
||||
&d_neighbors(i,1)-&d_neighbors(i,0));
|
||||
// loop over parent non-skip list
|
||||
|
||||
for (int jj = 0; jj < jnum; jj++) {
|
||||
const int joriginal = d_neighbors_skip(i,jj);
|
||||
int j = joriginal & NEIGHMASK;
|
||||
if (d_ijskip(itype,type(j))) continue;
|
||||
neighbors_i(n++) = joriginal;
|
||||
const int jnum = d_numneigh_skip(i);
|
||||
const AtomNeighbors neighbors_i = AtomNeighbors(&d_neighbors(i,0),d_numneigh(i),
|
||||
&d_neighbors(i,1)-&d_neighbors(i,0));
|
||||
|
||||
for (int jj = 0; jj < jnum; jj++) {
|
||||
const int joriginal = d_neighbors_skip(i,jj);
|
||||
int j = joriginal & NEIGHMASK;
|
||||
if (d_ijskip(itype,type(j))) continue;
|
||||
neighbors_i(n++) = joriginal;
|
||||
}
|
||||
|
||||
d_numneigh(i) = n;
|
||||
d_ilist(inum) = i;
|
||||
if (ii == num_skip-1)
|
||||
d_inum() = inum+1;
|
||||
}
|
||||
|
||||
d_numneigh(i) = n;
|
||||
const int inum = Kokkos::atomic_fetch_add(&d_inum(),1);
|
||||
d_ilist(inum) = i;
|
||||
inum++;
|
||||
}
|
||||
|
||||
template<class DeviceType>
|
||||
|
|
|
@ -66,13 +66,13 @@ class NPairSkipKokkos : public NPair {
|
|||
void build(class NeighList *);
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagNPairSkipCompute, const int&) const;
|
||||
void operator()(TagNPairSkipCompute, const int&, int&, const bool&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagNPairSkipCountLocal, const int&, int&) const;
|
||||
|
||||
private:
|
||||
int nlocal;
|
||||
int nlocal,num_skip;
|
||||
|
||||
typename AT::t_int_1d_randomread type;
|
||||
|
||||
|
@ -90,8 +90,6 @@ class NPairSkipKokkos : public NPair {
|
|||
DAT::tdual_int_2d k_ijskip;
|
||||
typename AT::t_int_1d d_iskip;
|
||||
typename AT::t_int_2d d_ijskip;
|
||||
|
||||
ExecutionSpace execution_space;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -32,12 +32,16 @@ NPair::NPair(LAMMPS *lmp)
|
|||
last_build = -1;
|
||||
mycutneighsq = NULL;
|
||||
molecular = atom->molecular;
|
||||
copymode = 0;
|
||||
execution_space = Host;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
NPair::~NPair()
|
||||
{
|
||||
if (copymode) return;
|
||||
|
||||
memory->destroy(mycutneighsq);
|
||||
}
|
||||
|
||||
|
|
|
@ -134,6 +134,9 @@ class NPair : protected Pointers {
|
|||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
int copymode;
|
||||
ExecutionSpace execution_space;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue