Skip to content

Commit

Permalink
Update MDrangePolicy more consistently.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkestene committed May 1, 2024
1 parent da6add6 commit 40f55a4
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 384 deletions.
123 changes: 50 additions & 73 deletions src/muscl/HydroInitFunctors2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,20 @@ class InitImplodeFunctor2D : public HydroBaseFunctor2D

// static method which does it all: create and execute functor
static void
apply(HydroParams params, ImplodeParams iparams, DataArray2d Udata, int nbCells)
apply(HydroParams params, ImplodeParams iparams, DataArray2d Udata)
{
InitImplodeFunctor2D functor(params, iparams, Udata);
Kokkos::parallel_for("InitImplodeFunctor2D", Kokkos::RangePolicy<>(0, nbCells), functor);
Kokkos::parallel_for(
"InitImplodeFunctor2D",
Kokkos::MDRangePolicy<Kokkos::Rank<2>>({ 0, 0 }, { params.isize, params.jsize }),
functor);
}

KOKKOS_INLINE_FUNCTION
void
operator()(const int & index) const
operator()(const int & i, const int & j) const
{

const int isize = params.isize;
const int jsize = params.jsize;
const int ghostWidth = params.ghostWidth;

#ifdef USE_MPI
Expand All @@ -77,9 +78,6 @@ class InitImplodeFunctor2D : public HydroBaseFunctor2D

const real_t gamma0 = params.settings.gamma0;

int i, j;
index2coord(index, i, j, isize, jsize);

real_t x = xmin + dx / 2 + (i + nx * i_mpi - ghostWidth) * dx;
real_t y = ymin + dy / 2 + (j + ny * j_mpi - ghostWidth) * dy;

Expand Down Expand Up @@ -139,19 +137,20 @@ class InitBlastFunctor2D : public HydroBaseFunctor2D

// static method which does it all: create and execute functor
static void
apply(HydroParams params, BlastParams bParams, DataArray2d Udata, int nbCells)
apply(HydroParams params, BlastParams bParams, DataArray2d Udata)
{
InitBlastFunctor2D functor(params, bParams, Udata);
Kokkos::parallel_for("InitBlastFunctor2D", Kokkos::RangePolicy<>(0, nbCells), functor);
Kokkos::parallel_for(
"InitBlastFunctor2D",
Kokkos::MDRangePolicy<Kokkos::Rank<2>>({ 0, 0 }, { params.isize, params.jsize }),
functor);
}

KOKKOS_INLINE_FUNCTION
void
operator()(const int & index) const
operator()(const int & i, const int & j) const
{

const int isize = params.isize;
const int jsize = params.jsize;
const int ghostWidth = params.ghostWidth;

#ifdef USE_MPI
Expand All @@ -167,6 +166,7 @@ class InitBlastFunctor2D : public HydroBaseFunctor2D

const real_t xmin = params.xmin;
const real_t ymin = params.ymin;

const real_t dx = params.dx;
const real_t dy = params.dy;

Expand All @@ -182,9 +182,6 @@ class InitBlastFunctor2D : public HydroBaseFunctor2D
const real_t blast_pressure_in = bParams.blast_pressure_in;
const real_t blast_pressure_out = bParams.blast_pressure_out;

int i, j;
index2coord(index, i, j, isize, jsize);

real_t x = xmin + dx / 2 + (i + nx * i_mpi - ghostWidth) * dx;
real_t y = ymin + dy / 2 + (j + ny * j_mpi - ghostWidth) * dy;

Expand Down Expand Up @@ -228,20 +225,20 @@ class InitKelvinHelmholtzFunctor2D : public HydroBaseFunctor2D

// static method which does it all: create and execute functor
static void
apply(HydroParams params, KHParams khParams, DataArray2d Udata, int nbCells)
apply(HydroParams params, KHParams khParams, DataArray2d Udata)
{
InitKelvinHelmholtzFunctor2D functor(params, khParams, Udata);
Kokkos::parallel_for(
"InitKelvinHelmholtzFunctor2D", Kokkos::RangePolicy<>(0, nbCells), functor);
"InitKelvinHelmholtzFunctor2D",
Kokkos::MDRangePolicy<Kokkos::Rank<2>>({ 0, 0 }, { params.isize, params.jsize }),
functor);
}

KOKKOS_INLINE_FUNCTION
void
operator()(const int & index) const
operator()(const int & i, const int & j) const
{

const int isize = params.isize;
const int jsize = params.jsize;
const int ghostWidth = params.ghostWidth;

#ifdef USE_MPI
Expand Down Expand Up @@ -271,9 +268,6 @@ class InitKelvinHelmholtzFunctor2D : public HydroBaseFunctor2D
const real_t ampl = khParams.amplitude;
const real_t pressure = khParams.pressure;

int i, j;
index2coord(index, i, j, isize, jsize);

real_t x = xmin + dx / 2 + (i + nx * i_mpi - ghostWidth) * dx;
real_t y = ymin + dy / 2 + (j + ny * j_mpi - ghostWidth) * dy;

Expand Down Expand Up @@ -366,19 +360,20 @@ class InitGreshoVortexFunctor2D : public HydroBaseFunctor2D

// static method which does it all: create and execute functor
static void
apply(HydroParams params, GreshoParams gvParams, DataArray2d Udata, int nbCells)
apply(HydroParams params, GreshoParams gvParams, DataArray2d Udata)
{
InitGreshoVortexFunctor2D functor(params, gvParams, Udata);
Kokkos::parallel_for("InitGreshoVortexFunctor2D", Kokkos::RangePolicy<>(0, nbCells), functor);
Kokkos::parallel_for(
"InitGreshoVortexFunctor2D",
Kokkos::MDRangePolicy<Kokkos::Rank<2>>({ 0, 0 }, { params.isize, params.jsize }),
functor);
}

KOKKOS_INLINE_FUNCTION
void
operator()(const int & index) const
operator()(const int & i, const int & j) const
{

const int isize = params.isize;
const int jsize = params.jsize;
const int ghostWidth = params.ghostWidth;

#ifdef USE_MPI
Expand Down Expand Up @@ -406,9 +401,6 @@ class InitGreshoVortexFunctor2D : public HydroBaseFunctor2D

const real_t p0 = rho0 / (gamma0 * Ma * Ma);

int i, j;
index2coord(index, i, j, isize, jsize);

real_t x = xmin + dx / 2 + (i + nx * i_mpi - ghostWidth) * dx;
real_t y = ymin + dy / 2 + (j + ny * j_mpi - ghostWidth) * dy;

Expand Down Expand Up @@ -490,20 +482,20 @@ class InitFourQuadrantFunctor2D : public HydroBaseFunctor2D
HydroState U2,
HydroState U3,
real_t xt,
real_t yt,
int nbCells)
real_t yt)
{
InitFourQuadrantFunctor2D functor(params, Udata, configNumber, U0, U1, U2, U3, xt, yt);
Kokkos::parallel_for("InitFourQuadrantFunctor2D", Kokkos::RangePolicy<>(0, nbCells), functor);
Kokkos::parallel_for(
"InitFourQuadrantFunctor2D",
Kokkos::MDRangePolicy<Kokkos::Rank<2>>({ 0, 0 }, { params.isize, params.jsize }),
functor);
}

KOKKOS_INLINE_FUNCTION
void
operator()(const int & index) const
operator()(const int & i, const int & j) const
{

const int isize = params.isize;
const int jsize = params.jsize;
const int ghostWidth = params.ghostWidth;

#ifdef USE_MPI
Expand All @@ -522,9 +514,6 @@ class InitFourQuadrantFunctor2D : public HydroBaseFunctor2D
const real_t dx = params.dx;
const real_t dy = params.dy;

int i, j;
index2coord(index, i, j, isize, jsize);

real_t x = xmin + dx / 2 + (i + nx * i_mpi - ghostWidth) * dx;
real_t y = ymin + dy / 2 + (j + ny * j_mpi - ghostWidth) * dy;

Expand Down Expand Up @@ -591,20 +580,20 @@ class InitIsentropicVortexFunctor2D : public HydroBaseFunctor2D

// static method which does it all: create and execute functor
static void
apply(HydroParams params, IsentropicVortexParams iparams, DataArray2d Udata, int nbCells)
apply(HydroParams params, IsentropicVortexParams iparams, DataArray2d Udata)
{
InitIsentropicVortexFunctor2D functor(params, iparams, Udata);
Kokkos::parallel_for(
"InitIsentropicVortexFunctor2D", Kokkos::RangePolicy<>(0, nbCells), functor);
"InitIsentropicVortexFunctor2D",
Kokkos::MDRangePolicy<Kokkos::Rank<2>>({ 0, 0 }, { params.isize, params.jsize }),
functor);
}

KOKKOS_INLINE_FUNCTION
void
operator()(const int & index) const
operator()(const int & i, const int & j) const
{

const int isize = params.isize;
const int jsize = params.jsize;
const int ghostWidth = params.ghostWidth;

#ifdef USE_MPI
Expand All @@ -625,9 +614,6 @@ class InitIsentropicVortexFunctor2D : public HydroBaseFunctor2D

const real_t gamma0 = params.settings.gamma0;

int i, j;
index2coord(index, i, j, isize, jsize);

real_t x = xmin + dx / 2 + (i + nx * i_mpi - ghostWidth) * dx;
real_t y = ymin + dy / 2 + (j + ny * j_mpi - ghostWidth) * dy;

Expand Down Expand Up @@ -699,19 +685,18 @@ class RayleighTaylorInstabilityFunctor2D : public HydroBaseFunctor2D
DataArray2d Udata,
VectorField2d gravity)
{
uint64_t nbCells = params.isize * params.jsize;
RayleighTaylorInstabilityFunctor2D functor(params, rtiparams, Udata, gravity);
Kokkos::parallel_for(
"RayleighTaylorInstabilityFunctor2D", Kokkos::RangePolicy<>(0, nbCells), functor);
"RayleighTaylorInstabilityFunctor2D",
Kokkos::MDRangePolicy<Kokkos::Rank<2>>({ 0, 0 }, { params.isize, params.jsize }),
functor);
}

KOKKOS_INLINE_FUNCTION
void
operator()(const int & index) const
operator()(const int & i, const int & j) const
{

const int isize = params.isize;
const int jsize = params.jsize;
const int ghostWidth = params.ghostWidth;

#ifdef USE_MPI
Expand Down Expand Up @@ -739,9 +724,6 @@ class RayleighTaylorInstabilityFunctor2D : public HydroBaseFunctor2D

const real_t gamma0 = params.settings.gamma0;

int i, j;
index2coord(index, i, j, isize, jsize);

real_t x = xmin + dx / 2 + (i + nx * i_mpi - ghostWidth) * dx;
real_t y = ymin + dy / 2 + (j + ny * j_mpi - ghostWidth) * dy;

Expand Down Expand Up @@ -827,18 +809,18 @@ class RisingBubbleFunctor2D : public HydroBaseFunctor2D
static void
apply(HydroParams params, RisingBubbleParams rbparams, DataArray2d Udata, VectorField2d gravity)
{
uint64_t nbCells = params.isize * params.jsize;
RisingBubbleFunctor2D functor(params, rbparams, Udata, gravity);
Kokkos::parallel_for("RisingBubbleFunctor2D", Kokkos::RangePolicy<>(0, nbCells), functor);
Kokkos::parallel_for(
"RisingBubbleFunctor2D",
Kokkos::MDRangePolicy<Kokkos::Rank<2>>({ 0, 0 }, { params.isize, params.jsize }),
functor);
}

KOKKOS_INLINE_FUNCTION
void
operator()(const int & index) const
operator()(const int & i, const int & j) const
{

const int isize = params.isize;
const int jsize = params.jsize;
const int ghostWidth = params.ghostWidth;

#ifdef USE_MPI
Expand All @@ -863,9 +845,6 @@ class RisingBubbleFunctor2D : public HydroBaseFunctor2D

const real_t gamma0 = params.settings.gamma0;

int i, j;
index2coord(index, i, j, isize, jsize);

real_t x = xmin + dx / 2 + (i + nx * i_mpi - ghostWidth) * dx;
real_t y = ymin + dy / 2 + (j + ny * j_mpi - ghostWidth) * dy;

Expand Down Expand Up @@ -948,18 +927,19 @@ class InitDiskFunctor2D : public HydroBaseFunctor2D
DataArray2d Udata,
VectorField2d gravity)
{
uint64_t nbCells = params.isize * params.jsize;
InitDiskFunctor2D functor(params, dparams, grav, Udata, gravity);
Kokkos::parallel_for("InitDiskFunctor2D", Kokkos::RangePolicy<>(0, nbCells), functor);
Kokkos::parallel_for(
"InitDiskFunctor2D",
Kokkos::MDRangePolicy<Kokkos::Rank<2>>({ 0, 0 }, { params.isize, params.jsize }),

functor);
}

KOKKOS_INLINE_FUNCTION
void
operator()(const int & index) const
operator()(const int & i, const int & j) const
{

const int isize = params.isize;
const int jsize = params.jsize;
const int ghostWidth = params.ghostWidth;

#ifdef USE_MPI
Expand Down Expand Up @@ -991,9 +971,6 @@ class InitDiskFunctor2D : public HydroBaseFunctor2D
const real_t rho_contrast = dparams.contrast_density;
const real_t contrast_width = dparams.contrast_width;

int i, j;
index2coord(index, i, j, isize, jsize);

real_t x = xmin + dx / 2 + (i + nx * i_mpi - ghostWidth) * dx - xc;
real_t y = ymin + dy / 2 + (j + ny * j_mpi - ghostWidth) * dy - yc;
real_t z = 0;
Expand Down
Loading

0 comments on commit 40f55a4

Please sign in to comment.