Skip to content

Commit

Permalink
Loop: Add missing device/host declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Jul 23, 2023
1 parent 9047df5 commit 186828e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Loop/src/loop.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -819,16 +819,18 @@ struct GF3D2layout {
GF3D2layout(GF3D2layout &&) = default;
GF3D2layout &operator=(const GF3D2layout &) = default;
GF3D2layout &operator=(GF3D2layout &&) = default;
GF3D2layout(const vect<int, dim> &imin, const vect<int, dim> &imax,
const vect<int, dim> &ash)
CCTK_DEVICE CCTK_HOST GF3D2layout(const vect<int, dim> &imin,
const vect<int, dim> &imax,
const vect<int, dim> &ash)
:
#ifdef CCTK_DEBUG
imin(imin), imax(imax), ash(ash),
#endif
dj(di * ash[0]), dk(dj * ash[1]), np(dk * ash[2]),
off(imin[0] * di + imin[1] * dj + imin[2] * dk) {
}
GF3D2layout(const vect<int, dim> &imin, const vect<int, dim> &imax)
CCTK_DEVICE CCTK_HOST GF3D2layout(const vect<int, dim> &imin,
const vect<int, dim> &imax)
: GF3D2layout(imin, imax, imax - imin) {
#ifdef CCTK_DEBUG
if (np > 0) {
Expand All @@ -837,8 +839,9 @@ struct GF3D2layout {
}
#endif
}
GF3D2layout(const cGH *restrict cctkGH, const vect<int, dim> &indextype,
const vect<int, dim> &nghostzones) {
CCTK_DEVICE CCTK_HOST GF3D2layout(const cGH *restrict cctkGH,
const vect<int, dim> &indextype,
const vect<int, dim> &nghostzones) {
for (int d = 0; d < dim; ++d)
assert(indextype[d] == 0 || indextype[d] == 1);
for (int d = 0; d < dim; ++d) {
Expand All @@ -857,11 +860,12 @@ struct GF3D2layout {
2 * (cctkGH->cctk_nghostzones[d] - nghostzones[d]);
*this = GF3D2layout(imin, imax, ash);
}
GF3D2layout(const cGH *restrict cctkGH, const vect<int, dim> &indextype)
CCTK_DEVICE CCTK_HOST GF3D2layout(const cGH *restrict cctkGH,
const vect<int, dim> &indextype)
: GF3D2layout(cctkGH, indextype,
{cctkGH->cctk_nghostzones[0], cctkGH->cctk_nghostzones[1],
cctkGH->cctk_nghostzones[2]}) {}
bool operator==(const GF3D2layout &other) const {
CCTK_DEVICE CCTK_HOST bool operator==(const GF3D2layout &other) const {
bool iseq = true;
#ifdef CCTK_DEBUG
iseq &= std::equal_to<vect<int, dim> >()(imin, other.imin) &&
Expand All @@ -872,6 +876,9 @@ struct GF3D2layout {
iseq &= off == other.off;
return iseq;
}
CCTK_DEVICE CCTK_HOST bool operator!=(const GF3D2layout &other) const {
return !(*this == other);
}
CCTK_DEVICE CCTK_HOST int linear(int i, int j, int k) const {
// These index checks prevent vectorization. We thus only enable
// them in debug mode.
Expand Down

0 comments on commit 186828e

Please sign in to comment.