Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/cea-hpc/NabLab
Browse files Browse the repository at this point in the history
  • Loading branch information
lelandaisb committed Oct 15, 2021
2 parents f06af6c + e843a1d commit b9c310b
Show file tree
Hide file tree
Showing 14 changed files with 675 additions and 264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class IrArgOrVarFactory
else
{
// Fill time loop variables for all iterators
val boolean existsInitTi = existsInitTimeIteratorRef(vRefsWithTimeIterators)
for (ti : vTimeIterators)
{
val boolean existsInitTiForTi = existsInitTimeIteratorRefForTimeIterator(vRefsWithTimeIterators, ti)
Expand All @@ -93,13 +92,13 @@ class IrArgOrVarFactory
val tiSetUpJob = tlJobs.findFirst[name == ti.setUpTimeLoopJobName]
if (tiSetUpJob !== null)
{
if (initTiVar !== null)
if (existsInitTiForTi)
{
addAffectation(tiSetUpJob, initTiVar, currentTiVar)
tiSetUpJob.inVars += initTiVar
tiSetUpJob.outVars += currentTiVar
}
else if (parentTi !== null && !existsInitTi) // inner time iterator
else if (parentTi !== null) // inner time iterator
{
val parentCurrentTiVar = createIrTimeVariable(v, parentTi, currentTimeIteratorName, currentTimeIteratorIndex)
addAffectation(tiSetUpJob, parentCurrentTiVar, currentTiVar)
Expand Down Expand Up @@ -245,14 +244,6 @@ class IrArgOrVarFactory
return irV
}

private def existsInitTimeIteratorRef(Iterable<ArgOrVarRef> l)
{
for (argOrVarRef : l)
if (argOrVarRef.timeIterators.exists[x | x instanceof InitTimeIteratorRef])
return true
return false
}

private def existsInitTimeIteratorRefForTimeIterator(Iterable<ArgOrVarRef> l, TimeIterator ti)
{
for (argOrVarRef : l)
Expand Down
159 changes: 125 additions & 34 deletions tests/NabLabTests/src-gen-cpp/kokkos-team/iteration/Iteration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ Iteration::Iteration(CartesianMesh2D& aMesh)
, X("X", nbNodes)
, u_n("u_n", nbCells)
, u_nplus1("u_nplus1", nbCells)
, v_n("v_n", nbCells)
, v_nplus1("v_nplus1", nbCells)
, v_nplus1_k("v_nplus1_k", nbCells)
, v_nplus1_kplus1("v_nplus1_kplus1", nbCells)
, v_nplus1_k0("v_nplus1_k0", nbCells)
, v1_n("v1_n", nbCells)
, v1_nplus1("v1_nplus1", nbCells)
, v1_nplus1_k("v1_nplus1_k", nbCells)
, v1_nplus1_kplus1("v1_nplus1_kplus1", nbCells)
, v1_nplus1_k0("v1_nplus1_k0", nbCells)
, v2_n("v2_n", nbCells)
, v2_nplus1("v2_nplus1", nbCells)
, v2_n0("v2_n0", nbCells)
, v2_nplus1_k("v2_nplus1_k", nbCells)
, v2_nplus1_kplus1("v2_nplus1_kplus1", nbCells)
, w_n("w_n", nbCells)
, w_nplus1("w_nplus1", nbCells)
, w_nplus1_l("w_nplus1_l", nbCells)
Expand Down Expand Up @@ -115,11 +120,11 @@ void Iteration::iniU(const member_type& teamMember) noexcept
}

/**
* Job iniV called @1.0 in executeTimeLoopN method.
* Job iniV1 called @1.0 in executeTimeLoopN method.
* In variables: u_n
* Out variables: v_nplus1_k0
* Out variables: v1_nplus1_k0
*/
void Iteration::iniV(const member_type& teamMember) noexcept
void Iteration::iniV1(const member_type& teamMember) noexcept
{
{
const auto teamWork(computeTeamWorkRange(teamMember, nbCells));
Expand All @@ -129,17 +134,37 @@ void Iteration::iniV(const member_type& teamMember) noexcept
Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, teamWork.second), KOKKOS_LAMBDA(const size_t& cCellsTeam)
{
int cCells(cCellsTeam + teamWork.first);
v_nplus1_k0(cCells) = u_n(cCells) + 1;
v1_nplus1_k0(cCells) = u_n(cCells) + 1;
});
}
}

/**
* Job updateV called @1.0 in executeTimeLoopK method.
* In variables: v_nplus1_k
* Out variables: v_nplus1_kplus1
* Job iniV2 called @1.0 in simulate method.
* In variables:
* Out variables: v2_n0
*/
void Iteration::iniV2(const member_type& teamMember) noexcept
{
{
const auto teamWork(computeTeamWorkRange(teamMember, nbCells));
if (!teamWork.second)
return;

Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, teamWork.second), KOKKOS_LAMBDA(const size_t& cCellsTeam)
{
int cCells(cCellsTeam + teamWork.first);
v2_n0(cCells) = 1.0;
});
}
}

/**
* Job updateV1 called @1.0 in executeTimeLoopK method.
* In variables: v1_nplus1_k
* Out variables: v1_nplus1_kplus1
*/
void Iteration::updateV(const member_type& teamMember) noexcept
void Iteration::updateV1(const member_type& teamMember) noexcept
{
{
const auto teamWork(computeTeamWorkRange(teamMember, nbCells));
Expand All @@ -149,7 +174,27 @@ void Iteration::updateV(const member_type& teamMember) noexcept
Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, teamWork.second), KOKKOS_LAMBDA(const size_t& cCellsTeam)
{
int cCells(cCellsTeam + teamWork.first);
v_nplus1_kplus1(cCells) = v_nplus1_k(cCells) + 1.5;
v1_nplus1_kplus1(cCells) = v1_nplus1_k(cCells) + 1.5;
});
}
}

/**
* Job updateV2 called @1.0 in executeTimeLoopK method.
* In variables: v2_nplus1_k
* Out variables: v2_nplus1_kplus1
*/
void Iteration::updateV2(const member_type& teamMember) noexcept
{
{
const auto teamWork(computeTeamWorkRange(teamMember, nbCells));
if (!teamWork.second)
return;

Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, teamWork.second), KOKKOS_LAMBDA(const size_t& cCellsTeam)
{
int cCells(cCellsTeam + teamWork.first);
v2_nplus1_kplus1(cCells) = v2_nplus1_k(cCells) + 2;
});
}
}
Expand All @@ -176,8 +221,8 @@ void Iteration::updateW(const member_type& teamMember) noexcept

/**
* Job setUpTimeLoopK called @2.0 in executeTimeLoopN method.
* In variables: v_nplus1_k0
* Out variables: v_nplus1_k
* In variables: v1_nplus1_k0, v2_n
* Out variables: v1_nplus1_k, v2_nplus1_k
*/
void Iteration::setUpTimeLoopK(const member_type& teamMember) noexcept
{
Expand All @@ -189,25 +234,47 @@ void Iteration::setUpTimeLoopK(const member_type& teamMember) noexcept
Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, teamWork.second), KOKKOS_LAMBDA(const size_t& i1CellsTeam)
{
int i1Cells(i1CellsTeam + teamWork.first);
v_nplus1_k(i1Cells) = v_nplus1_k0(i1Cells);
v1_nplus1_k(i1Cells) = v1_nplus1_k0(i1Cells);
});
}
{
const auto teamWork(computeTeamWorkRange(teamMember, nbCells));
if (!teamWork.second)
return;

Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, teamWork.second), KOKKOS_LAMBDA(const size_t& i1CellsTeam)
{
int i1Cells(i1CellsTeam + teamWork.first);
v2_nplus1_k(i1Cells) = v2_n(i1Cells);
});
}
}

/**
* Job setUpTimeLoopN called @2.0 in simulate method.
* In variables: t_n0
* Out variables: t_n
* In variables: t_n0, v2_n0
* Out variables: t_n, v2_n
*/
void Iteration::setUpTimeLoopN() noexcept
void Iteration::setUpTimeLoopN(const member_type& teamMember) noexcept
{
t_n = t_n0;
{
const auto teamWork(computeTeamWorkRange(teamMember, nbCells));
if (!teamWork.second)
return;

Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, teamWork.second), KOKKOS_LAMBDA(const size_t& i1CellsTeam)
{
int i1Cells(i1CellsTeam + teamWork.first);
v2_n(i1Cells) = v2_n0(i1Cells);
});
}
}

/**
* Job executeTimeLoopK called @3.0 in executeTimeLoopN method.
* In variables: v_nplus1_k
* Out variables: v_nplus1_kplus1
* In variables: v1_nplus1_k, v2_nplus1_k
* Out variables: v1_nplus1_kplus1, v2_nplus1_kplus1
*/
void Iteration::executeTimeLoopK() noexcept
{
Expand All @@ -223,7 +290,8 @@ void Iteration::executeTimeLoopK() noexcept
// @1.0
Kokkos::parallel_for(team_policy, KOKKOS_LAMBDA(member_type thread)
{
updateV(thread);
updateV1(thread);
updateV2(thread);
});


Expand All @@ -232,15 +300,19 @@ void Iteration::executeTimeLoopK() noexcept

Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& i1Cells)
{
v_nplus1_k(i1Cells) = v_nplus1_kplus1(i1Cells);
v1_nplus1_k(i1Cells) = v1_nplus1_kplus1(i1Cells);
});
Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& i1Cells)
{
v2_nplus1_k(i1Cells) = v2_nplus1_kplus1(i1Cells);
});
} while (continueLoop);
}

/**
* Job executeTimeLoopN called @3.0 in simulate method.
* In variables: t_n, u_n, v_n, w_n
* Out variables: t_nplus1, u_nplus1, v_nplus1, w_nplus1
* In variables: t_n, u_n, v1_n, v2_n, w_n
* Out variables: t_nplus1, u_nplus1, v1_nplus1, v2_nplus1, w_nplus1
*/
void Iteration::executeTimeLoopN() noexcept
{
Expand All @@ -264,7 +336,7 @@ void Iteration::executeTimeLoopN() noexcept
{
if (thread.league_rank() == 0)
Kokkos::single(Kokkos::PerTeam(thread), KOKKOS_LAMBDA(){computeTn();});
iniV(thread);
iniV1(thread);
});

// @2.0
Expand Down Expand Up @@ -320,7 +392,11 @@ void Iteration::executeTimeLoopN() noexcept
});
Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& i1Cells)
{
v_n(i1Cells) = v_nplus1(i1Cells);
v1_n(i1Cells) = v1_nplus1(i1Cells);
});
Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& i1Cells)
{
v2_n(i1Cells) = v2_nplus1(i1Cells);
});
Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& i1Cells)
{
Expand All @@ -347,8 +423,8 @@ void Iteration::executeTimeLoopN() noexcept

/**
* Job tearDownTimeLoopK called @4.0 in executeTimeLoopN method.
* In variables: v_nplus1_kplus1
* Out variables: v_nplus1
* In variables: v1_nplus1_kplus1, v2_nplus1_kplus1
* Out variables: v1_nplus1, v2_nplus1
*/
void Iteration::tearDownTimeLoopK(const member_type& teamMember) noexcept
{
Expand All @@ -360,14 +436,25 @@ void Iteration::tearDownTimeLoopK(const member_type& teamMember) noexcept
Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, teamWork.second), KOKKOS_LAMBDA(const size_t& i1CellsTeam)
{
int i1Cells(i1CellsTeam + teamWork.first);
v_nplus1(i1Cells) = v_nplus1_kplus1(i1Cells);
v1_nplus1(i1Cells) = v1_nplus1_kplus1(i1Cells);
});
}
{
const auto teamWork(computeTeamWorkRange(teamMember, nbCells));
if (!teamWork.second)
return;

Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, teamWork.second), KOKKOS_LAMBDA(const size_t& i1CellsTeam)
{
int i1Cells(i1CellsTeam + teamWork.first);
v2_nplus1(i1Cells) = v2_nplus1_kplus1(i1Cells);
});
}
}

/**
* Job iniW called @5.0 in executeTimeLoopN method.
* In variables: v_nplus1
* In variables: v1_nplus1
* Out variables: w_nplus1_l0
*/
void Iteration::iniW(const member_type& teamMember) noexcept
Expand All @@ -380,7 +467,7 @@ void Iteration::iniW(const member_type& teamMember) noexcept
Kokkos::parallel_for(Kokkos::TeamThreadRange(teamMember, teamWork.second), KOKKOS_LAMBDA(const size_t& cCellsTeam)
{
int cCells(cCellsTeam + teamWork.first);
w_nplus1_l0(cCells) = v_nplus1(cCells);
w_nplus1_l0(cCells) = v1_nplus1(cCells);
});
}
}
Expand Down Expand Up @@ -511,10 +598,14 @@ void Iteration::simulate()
if (thread.league_rank() == 0)
Kokkos::single(Kokkos::PerTeam(thread), KOKKOS_LAMBDA(){iniTime();});
iniU(thread);
iniV2(thread);
});

// @2.0
setUpTimeLoopN();
Kokkos::parallel_for(team_policy, KOKKOS_LAMBDA(member_type thread)
{
setUpTimeLoopN(thread);
});

// @3.0
executeTimeLoopN();
Expand Down
25 changes: 17 additions & 8 deletions tests/NabLabTests/src-gen-cpp/kokkos-team/iteration/Iteration.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,19 @@ class Iteration
KOKKOS_INLINE_FUNCTION
void iniU(const member_type& teamMember) noexcept;
KOKKOS_INLINE_FUNCTION
void iniV(const member_type& teamMember) noexcept;
void iniV1(const member_type& teamMember) noexcept;
KOKKOS_INLINE_FUNCTION
void updateV(const member_type& teamMember) noexcept;
void iniV2(const member_type& teamMember) noexcept;
KOKKOS_INLINE_FUNCTION
void updateV1(const member_type& teamMember) noexcept;
KOKKOS_INLINE_FUNCTION
void updateV2(const member_type& teamMember) noexcept;
KOKKOS_INLINE_FUNCTION
void updateW(const member_type& teamMember) noexcept;
KOKKOS_INLINE_FUNCTION
void setUpTimeLoopK(const member_type& teamMember) noexcept;
KOKKOS_INLINE_FUNCTION
void setUpTimeLoopN() noexcept;
void setUpTimeLoopN(const member_type& teamMember) noexcept;
KOKKOS_INLINE_FUNCTION
void executeTimeLoopK() noexcept;
KOKKOS_INLINE_FUNCTION
Expand Down Expand Up @@ -94,11 +98,16 @@ class Iteration
Kokkos::View<RealArray1D<2>*> X;
Kokkos::View<double*> u_n;
Kokkos::View<double*> u_nplus1;
Kokkos::View<double*> v_n;
Kokkos::View<double*> v_nplus1;
Kokkos::View<double*> v_nplus1_k;
Kokkos::View<double*> v_nplus1_kplus1;
Kokkos::View<double*> v_nplus1_k0;
Kokkos::View<double*> v1_n;
Kokkos::View<double*> v1_nplus1;
Kokkos::View<double*> v1_nplus1_k;
Kokkos::View<double*> v1_nplus1_kplus1;
Kokkos::View<double*> v1_nplus1_k0;
Kokkos::View<double*> v2_n;
Kokkos::View<double*> v2_nplus1;
Kokkos::View<double*> v2_n0;
Kokkos::View<double*> v2_nplus1_k;
Kokkos::View<double*> v2_nplus1_kplus1;
Kokkos::View<double*> w_n;
Kokkos::View<double*> w_nplus1;
Kokkos::View<double*> w_nplus1_l;
Expand Down
Loading

0 comments on commit b9c310b

Please sign in to comment.