USER-DPD Kokkos: turn one_type optimization into a template specialization

This commit is contained in:
Tim Mattox
2017-03-03 10:38:45 -05:00
parent 7e78921c96
commit a7e8550962
2 changed files with 23 additions and 12 deletions

View File

@ -454,7 +454,7 @@ void PairMultiLucyRXKokkos<DeviceType>::computeLocalDensity()
const double pi = MathConst::MY_PI;
const bool newton_pair = force->newton_pair;
one_type = (atom->ntypes == 1);
const bool one_type = (atom->ntypes == 1);
// Special cut-off values for when there's only one type.
cutsq_type11 = cutsq[1][1];
@ -471,14 +471,26 @@ void PairMultiLucyRXKokkos<DeviceType>::computeLocalDensity()
if (neighflag == HALF) {
if (newton_pair)
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXComputeLocalDensity<HALF,1> >(0,inum),*this);
if (one_type)
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXComputeLocalDensity<HALF,1,true> >(0,inum),*this);
else
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXComputeLocalDensity<HALF,1,false> >(0,inum),*this);
else
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXComputeLocalDensity<HALF,0> >(0,inum),*this);
if (one_type)
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXComputeLocalDensity<HALF,0,true> >(0,inum),*this);
else
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXComputeLocalDensity<HALF,0,false> >(0,inum),*this);
} else if (neighflag == HALFTHREAD) {
if (newton_pair)
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXComputeLocalDensity<HALFTHREAD,1> >(0,inum),*this);
if (one_type)
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXComputeLocalDensity<HALFTHREAD,1,true> >(0,inum),*this);
else
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXComputeLocalDensity<HALFTHREAD,1,false> >(0,inum),*this);
else
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXComputeLocalDensity<HALFTHREAD,0> >(0,inum),*this);
if (one_type)
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXComputeLocalDensity<HALFTHREAD,0,true> >(0,inum),*this);
else
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType, TagPairMultiLucyRXComputeLocalDensity<HALFTHREAD,0,false> >(0,inum),*this);
}
atomKK->modified(execution_space,DPDRHO_MASK);
@ -498,9 +510,9 @@ void PairMultiLucyRXKokkos<DeviceType>::operator()(TagPairMultiLucyRXZero, const
}
template<class DeviceType>
template<int NEIGHFLAG, int NEWTON_PAIR>
template<int NEIGHFLAG, int NEWTON_PAIR, bool ONE_TYPE>
KOKKOS_INLINE_FUNCTION
void PairMultiLucyRXKokkos<DeviceType>::operator()(TagPairMultiLucyRXComputeLocalDensity<NEIGHFLAG,NEWTON_PAIR>, const int &ii) const {
void PairMultiLucyRXKokkos<DeviceType>::operator()(TagPairMultiLucyRXComputeLocalDensity<NEIGHFLAG,NEWTON_PAIR,ONE_TYPE>, const int &ii) const {
// The rho array is atomic for Half/Thread neighbor style
@ -528,7 +540,7 @@ void PairMultiLucyRXKokkos<DeviceType>::operator()(TagPairMultiLucyRXComputeLoca
const double delz = ztmp - x(j,2);
const double rsq = delx*delx + dely*dely + delz*delz;
if (one_type) {
if (ONE_TYPE) {
if (rsq < cutsq_type11) {
const double rcut = rcut_type11;
const double r_over_rcut = sqrt(rsq) / rcut;

View File

@ -39,7 +39,7 @@ struct TagPairMultiLucyRXCompute{};
struct TagPairMultiLucyRXZero{};
template<int NEIGHFLAG, int NEWTON_PAIR>
template<int NEIGHFLAG, int NEWTON_PAIR, bool ONE_TYPE>
struct TagPairMultiLucyRXComputeLocalDensity{};
template<class DeviceType>
@ -88,9 +88,9 @@ class PairMultiLucyRXKokkos : public PairMultiLucyRX {
KOKKOS_INLINE_FUNCTION
void operator()(TagPairMultiLucyRXZero, const int&) const;
template<int NEIGHFLAG, int NEWTON_PAIR>
template<int NEIGHFLAG, int NEWTON_PAIR, bool ONE_TYPE>
KOKKOS_INLINE_FUNCTION
void operator()(TagPairMultiLucyRXComputeLocalDensity<NEIGHFLAG,NEWTON_PAIR>, const int&) const;
void operator()(TagPairMultiLucyRXComputeLocalDensity<NEIGHFLAG,NEWTON_PAIR,ONE_TYPE>, const int&) const;
template<int NEIGHFLAG, int NEWTON_PAIR>
KOKKOS_INLINE_FUNCTION
@ -103,7 +103,6 @@ class PairMultiLucyRXKokkos : public PairMultiLucyRX {
int neighflag;
int eflag,vflag;
bool one_type;
double cutsq_type11;
double rcut_type11;
double factor_type11;