From a07279b4f6e9d31f514df4f49b9dc2dce90c236b Mon Sep 17 00:00:00 2001 From: OUDOT Marie-Pierre Date: Fri, 24 Sep 2021 11:53:31 +0200 Subject: [PATCH 1/2] Correct bug on SetupTimeLoopK when no k=0 value --- .../cea/nabla/generator/ir/IrArgOrVarFactory.xtend | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/plugins/fr.cea.nabla/src/fr/cea/nabla/generator/ir/IrArgOrVarFactory.xtend b/plugins/fr.cea.nabla/src/fr/cea/nabla/generator/ir/IrArgOrVarFactory.xtend index 42cf6eaec..0a799cb9b 100644 --- a/plugins/fr.cea.nabla/src/fr/cea/nabla/generator/ir/IrArgOrVarFactory.xtend +++ b/plugins/fr.cea.nabla/src/fr/cea/nabla/generator/ir/IrArgOrVarFactory.xtend @@ -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) @@ -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) @@ -245,14 +244,6 @@ class IrArgOrVarFactory return irV } - private def existsInitTimeIteratorRef(Iterable l) - { - for (argOrVarRef : l) - if (argOrVarRef.timeIterators.exists[x | x instanceof InitTimeIteratorRef]) - return true - return false - } - private def existsInitTimeIteratorRefForTimeIterator(Iterable l, TimeIterator ti) { for (argOrVarRef : l) From af019470a4399a71d926dde79e9a704121b76ec0 Mon Sep 17 00:00:00 2001 From: OUDOT Marie-Pierre Date: Fri, 24 Sep 2021 11:57:31 +0200 Subject: [PATCH 2/2] Add test for SetUpTimeLoopK when no k=0 value --- .../kokkos-team/iteration/Iteration.cc | 159 ++++++++++++++---- .../kokkos-team/iteration/Iteration.h | 25 ++- .../src-gen-cpp/kokkos/iteration/Iteration.cc | 117 +++++++++---- .../src-gen-cpp/kokkos/iteration/Iteration.h | 23 ++- .../src-gen-cpp/openmp/iteration/Iteration.cc | 136 ++++++++++----- .../src-gen-cpp/openmp/iteration/Iteration.h | 21 ++- .../sequential/iteration/Iteration.cc | 117 +++++++++---- .../sequential/iteration/Iteration.h | 21 ++- .../stl-thread/iteration/Iteration.cc | 117 +++++++++---- .../stl-thread/iteration/Iteration.h | 21 ++- .../src-gen-java/iteration/Iteration.java | 132 +++++++++++---- .../src-gen/iteration/Iteration.tex | 18 +- tests/NabLabTests/src/iteration/Iteration.n | 19 ++- 13 files changed, 673 insertions(+), 253 deletions(-) diff --git a/tests/NabLabTests/src-gen-cpp/kokkos-team/iteration/Iteration.cc b/tests/NabLabTests/src-gen-cpp/kokkos-team/iteration/Iteration.cc index 802b131c9..49baa107a 100644 --- a/tests/NabLabTests/src-gen-cpp/kokkos-team/iteration/Iteration.cc +++ b/tests/NabLabTests/src-gen-cpp/kokkos-team/iteration/Iteration.cc @@ -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) @@ -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)); @@ -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)); @@ -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; }); } } @@ -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 { @@ -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 { @@ -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); }); @@ -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 { @@ -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 @@ -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) { @@ -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 { @@ -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 @@ -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); }); } } @@ -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(); diff --git a/tests/NabLabTests/src-gen-cpp/kokkos-team/iteration/Iteration.h b/tests/NabLabTests/src-gen-cpp/kokkos-team/iteration/Iteration.h index 10854d82a..1ed74f1d5 100644 --- a/tests/NabLabTests/src-gen-cpp/kokkos-team/iteration/Iteration.h +++ b/tests/NabLabTests/src-gen-cpp/kokkos-team/iteration/Iteration.h @@ -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 @@ -94,11 +98,16 @@ class Iteration Kokkos::View*> X; Kokkos::View u_n; Kokkos::View u_nplus1; - Kokkos::View v_n; - Kokkos::View v_nplus1; - Kokkos::View v_nplus1_k; - Kokkos::View v_nplus1_kplus1; - Kokkos::View v_nplus1_k0; + Kokkos::View v1_n; + Kokkos::View v1_nplus1; + Kokkos::View v1_nplus1_k; + Kokkos::View v1_nplus1_kplus1; + Kokkos::View v1_nplus1_k0; + Kokkos::View v2_n; + Kokkos::View v2_nplus1; + Kokkos::View v2_n0; + Kokkos::View v2_nplus1_k; + Kokkos::View v2_nplus1_kplus1; Kokkos::View w_n; Kokkos::View w_nplus1; Kokkos::View w_nplus1_l; diff --git a/tests/NabLabTests/src-gen-cpp/kokkos/iteration/Iteration.cc b/tests/NabLabTests/src-gen-cpp/kokkos/iteration/Iteration.cc index 5bb4bf98e..f5d0430c5 100644 --- a/tests/NabLabTests/src-gen-cpp/kokkos/iteration/Iteration.cc +++ b/tests/NabLabTests/src-gen-cpp/kokkos/iteration/Iteration.cc @@ -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) @@ -85,28 +90,54 @@ void Iteration::iniU() 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() noexcept +void Iteration::iniV1() noexcept { Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& cCells) { - 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() noexcept +{ + Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& cCells) + { + 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::updateV1() noexcept +{ + Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& cCells) + { + 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::updateV() noexcept +void Iteration::updateV2() noexcept { Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& cCells) { - v_nplus1_kplus1(cCells) = v_nplus1_k(cCells) + 1.5; + v2_nplus1_kplus1(cCells) = v2_nplus1_k(cCells) + 2; }); } @@ -125,31 +156,39 @@ void Iteration::updateW() 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() noexcept { Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& i1Cells) { - v_nplus1_k(i1Cells) = v_nplus1_k0(i1Cells); + v1_nplus1_k(i1Cells) = v1_nplus1_k0(i1Cells); + }); + Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& i1Cells) + { + 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 { t_n = t_n0; + Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& i1Cells) + { + 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 { @@ -158,7 +197,8 @@ void Iteration::executeTimeLoopK() noexcept do { k++; - updateV(); // @1.0 + updateV1(); // @1.0 + updateV2(); // @1.0 // Evaluate loop condition with variables at time n @@ -166,15 +206,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 { @@ -190,7 +234,7 @@ void Iteration::executeTimeLoopN() noexcept << setiosflags(std::ios::scientific) << setprecision(8) << setw(16) << t_n << __RESET__; computeTn(); // @1.0 - iniV(); // @1.0 + iniV1(); // @1.0 setUpTimeLoopK(); // @2.0 executeTimeLoopK(); // @3.0 tearDownTimeLoopK(); // @4.0 @@ -211,7 +255,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) { @@ -238,27 +286,31 @@ 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() noexcept { Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& i1Cells) { - v_nplus1(i1Cells) = v_nplus1_kplus1(i1Cells); + v1_nplus1(i1Cells) = v1_nplus1_kplus1(i1Cells); + }); + Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& i1Cells) + { + 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() noexcept { Kokkos::parallel_for(nbCells, KOKKOS_LAMBDA(const size_t& cCells) { - w_nplus1_l0(cCells) = v_nplus1(cCells); + w_nplus1_l0(cCells) = v1_nplus1(cCells); }); } @@ -347,6 +399,7 @@ void Iteration::simulate() iniTime(); // @1.0 iniU(); // @1.0 + iniV2(); // @1.0 setUpTimeLoopN(); // @2.0 executeTimeLoopN(); // @3.0 diff --git a/tests/NabLabTests/src-gen-cpp/kokkos/iteration/Iteration.h b/tests/NabLabTests/src-gen-cpp/kokkos/iteration/Iteration.h index 7eff86f1a..a9e6b49a1 100644 --- a/tests/NabLabTests/src-gen-cpp/kokkos/iteration/Iteration.h +++ b/tests/NabLabTests/src-gen-cpp/kokkos/iteration/Iteration.h @@ -39,9 +39,13 @@ class Iteration KOKKOS_INLINE_FUNCTION void iniU() noexcept; KOKKOS_INLINE_FUNCTION - void iniV() noexcept; + void iniV1() noexcept; KOKKOS_INLINE_FUNCTION - void updateV() noexcept; + void iniV2() noexcept; + KOKKOS_INLINE_FUNCTION + void updateV1() noexcept; + KOKKOS_INLINE_FUNCTION + void updateV2() noexcept; KOKKOS_INLINE_FUNCTION void updateW() noexcept; KOKKOS_INLINE_FUNCTION @@ -85,11 +89,16 @@ class Iteration Kokkos::View*> X; Kokkos::View u_n; Kokkos::View u_nplus1; - Kokkos::View v_n; - Kokkos::View v_nplus1; - Kokkos::View v_nplus1_k; - Kokkos::View v_nplus1_kplus1; - Kokkos::View v_nplus1_k0; + Kokkos::View v1_n; + Kokkos::View v1_nplus1; + Kokkos::View v1_nplus1_k; + Kokkos::View v1_nplus1_kplus1; + Kokkos::View v1_nplus1_k0; + Kokkos::View v2_n; + Kokkos::View v2_nplus1; + Kokkos::View v2_n0; + Kokkos::View v2_nplus1_k; + Kokkos::View v2_nplus1_kplus1; Kokkos::View w_n; Kokkos::View w_nplus1; Kokkos::View w_nplus1_l; diff --git a/tests/NabLabTests/src-gen-cpp/openmp/iteration/Iteration.cc b/tests/NabLabTests/src-gen-cpp/openmp/iteration/Iteration.cc index 8e3b78ef7..2adf525f0 100644 --- a/tests/NabLabTests/src-gen-cpp/openmp/iteration/Iteration.cc +++ b/tests/NabLabTests/src-gen-cpp/openmp/iteration/Iteration.cc @@ -16,11 +16,16 @@ Iteration::Iteration(CartesianMesh2D& aMesh) , X(nbNodes) , u_n(nbCells) , u_nplus1(nbCells) -, v_n(nbCells) -, v_nplus1(nbCells) -, v_nplus1_k(nbCells) -, v_nplus1_kplus1(nbCells) -, v_nplus1_k0(nbCells) +, v1_n(nbCells) +, v1_nplus1(nbCells) +, v1_nplus1_k(nbCells) +, v1_nplus1_kplus1(nbCells) +, v1_nplus1_k0(nbCells) +, v2_n(nbCells) +, v2_nplus1(nbCells) +, v2_n0(nbCells) +, v2_nplus1_k(nbCells) +, v2_nplus1_kplus1(nbCells) , w_n(nbCells) , w_nplus1(nbCells) , w_nplus1_l(nbCells) @@ -86,30 +91,58 @@ void Iteration::iniU() 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() noexcept +void Iteration::iniV1() noexcept { - #pragma omp parallel for shared(v_nplus1_k0) + #pragma omp parallel for shared(v1_nplus1_k0) for (size_t cCells=0; cCells> X; std::vector u_n; std::vector u_nplus1; - std::vector v_n; - std::vector v_nplus1; - std::vector v_nplus1_k; - std::vector v_nplus1_kplus1; - std::vector v_nplus1_k0; + std::vector v1_n; + std::vector v1_nplus1; + std::vector v1_nplus1_k; + std::vector v1_nplus1_kplus1; + std::vector v1_nplus1_k0; + std::vector v2_n; + std::vector v2_nplus1; + std::vector v2_n0; + std::vector v2_nplus1_k; + std::vector v2_nplus1_kplus1; std::vector w_n; std::vector w_nplus1; std::vector w_nplus1_l; diff --git a/tests/NabLabTests/src-gen-cpp/sequential/iteration/Iteration.cc b/tests/NabLabTests/src-gen-cpp/sequential/iteration/Iteration.cc index fa7f81e35..6b9cdc924 100644 --- a/tests/NabLabTests/src-gen-cpp/sequential/iteration/Iteration.cc +++ b/tests/NabLabTests/src-gen-cpp/sequential/iteration/Iteration.cc @@ -16,11 +16,16 @@ Iteration::Iteration(CartesianMesh2D& aMesh) , X(nbNodes) , u_n(nbCells) , u_nplus1(nbCells) -, v_n(nbCells) -, v_nplus1(nbCells) -, v_nplus1_k(nbCells) -, v_nplus1_kplus1(nbCells) -, v_nplus1_k0(nbCells) +, v1_n(nbCells) +, v1_nplus1(nbCells) +, v1_nplus1_k(nbCells) +, v1_nplus1_kplus1(nbCells) +, v1_nplus1_k0(nbCells) +, v2_n(nbCells) +, v2_nplus1(nbCells) +, v2_n0(nbCells) +, v2_nplus1_k(nbCells) +, v2_nplus1_kplus1(nbCells) , w_n(nbCells) , w_nplus1(nbCells) , w_nplus1_l(nbCells) @@ -85,28 +90,54 @@ void Iteration::iniU() 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() noexcept +void Iteration::iniV1() noexcept { for (size_t cCells=0; cCells> X; std::vector u_n; std::vector u_nplus1; - std::vector v_n; - std::vector v_nplus1; - std::vector v_nplus1_k; - std::vector v_nplus1_kplus1; - std::vector v_nplus1_k0; + std::vector v1_n; + std::vector v1_nplus1; + std::vector v1_nplus1_k; + std::vector v1_nplus1_kplus1; + std::vector v1_nplus1_k0; + std::vector v2_n; + std::vector v2_nplus1; + std::vector v2_n0; + std::vector v2_nplus1_k; + std::vector v2_nplus1_kplus1; std::vector w_n; std::vector w_nplus1; std::vector w_nplus1_l; diff --git a/tests/NabLabTests/src-gen-cpp/stl-thread/iteration/Iteration.cc b/tests/NabLabTests/src-gen-cpp/stl-thread/iteration/Iteration.cc index 42e3de895..5a20fb7a4 100644 --- a/tests/NabLabTests/src-gen-cpp/stl-thread/iteration/Iteration.cc +++ b/tests/NabLabTests/src-gen-cpp/stl-thread/iteration/Iteration.cc @@ -16,11 +16,16 @@ Iteration::Iteration(CartesianMesh2D& aMesh) , X(nbNodes) , u_n(nbCells) , u_nplus1(nbCells) -, v_n(nbCells) -, v_nplus1(nbCells) -, v_nplus1_k(nbCells) -, v_nplus1_kplus1(nbCells) -, v_nplus1_k0(nbCells) +, v1_n(nbCells) +, v1_nplus1(nbCells) +, v1_nplus1_k(nbCells) +, v1_nplus1_kplus1(nbCells) +, v1_nplus1_k0(nbCells) +, v2_n(nbCells) +, v2_nplus1(nbCells) +, v2_n0(nbCells) +, v2_nplus1_k(nbCells) +, v2_nplus1_kplus1(nbCells) , w_n(nbCells) , w_nplus1(nbCells) , w_nplus1_l(nbCells) @@ -85,28 +90,54 @@ void Iteration::iniU() 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() noexcept +void Iteration::iniV1() noexcept { parallel_exec(nbCells, [&](const size_t& cCells) { - 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() noexcept +{ + parallel_exec(nbCells, [&](const size_t& cCells) + { + 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::updateV1() noexcept +{ + parallel_exec(nbCells, [&](const size_t& cCells) + { + 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::updateV() noexcept +void Iteration::updateV2() noexcept { parallel_exec(nbCells, [&](const size_t& cCells) { - v_nplus1_kplus1[cCells] = v_nplus1_k[cCells] + 1.5; + v2_nplus1_kplus1[cCells] = v2_nplus1_k[cCells] + 2; }); } @@ -125,31 +156,39 @@ void Iteration::updateW() 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() noexcept { parallel_exec(nbCells, [&](const size_t& i1Cells) { - v_nplus1_k[i1Cells] = v_nplus1_k0[i1Cells]; + v1_nplus1_k[i1Cells] = v1_nplus1_k0[i1Cells]; + }); + parallel_exec(nbCells, [&](const size_t& i1Cells) + { + 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 { t_n = t_n0; + parallel_exec(nbCells, [&](const size_t& i1Cells) + { + 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 { @@ -158,7 +197,8 @@ void Iteration::executeTimeLoopK() noexcept do { k++; - updateV(); // @1.0 + updateV1(); // @1.0 + updateV2(); // @1.0 // Evaluate loop condition with variables at time n @@ -166,15 +206,19 @@ void Iteration::executeTimeLoopK() noexcept parallel_exec(nbCells, [&](const size_t& i1Cells) { - v_nplus1_k[i1Cells] = v_nplus1_kplus1[i1Cells]; + v1_nplus1_k[i1Cells] = v1_nplus1_kplus1[i1Cells]; + }); + parallel_exec(nbCells, [&](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 { @@ -190,7 +234,7 @@ void Iteration::executeTimeLoopN() noexcept << setiosflags(std::ios::scientific) << setprecision(8) << setw(16) << t_n << __RESET__; computeTn(); // @1.0 - iniV(); // @1.0 + iniV1(); // @1.0 setUpTimeLoopK(); // @2.0 executeTimeLoopK(); // @3.0 tearDownTimeLoopK(); // @4.0 @@ -211,7 +255,11 @@ void Iteration::executeTimeLoopN() noexcept }); parallel_exec(nbCells, [&](const size_t& i1Cells) { - v_n[i1Cells] = v_nplus1[i1Cells]; + v1_n[i1Cells] = v1_nplus1[i1Cells]; + }); + parallel_exec(nbCells, [&](const size_t& i1Cells) + { + v2_n[i1Cells] = v2_nplus1[i1Cells]; }); parallel_exec(nbCells, [&](const size_t& i1Cells) { @@ -238,27 +286,31 @@ 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() noexcept { parallel_exec(nbCells, [&](const size_t& i1Cells) { - v_nplus1[i1Cells] = v_nplus1_kplus1[i1Cells]; + v1_nplus1[i1Cells] = v1_nplus1_kplus1[i1Cells]; + }); + parallel_exec(nbCells, [&](const size_t& i1Cells) + { + 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() noexcept { parallel_exec(nbCells, [&](const size_t& cCells) { - w_nplus1_l0[cCells] = v_nplus1[cCells]; + w_nplus1_l0[cCells] = v1_nplus1[cCells]; }); } @@ -336,6 +388,7 @@ void Iteration::simulate() iniTime(); // @1.0 iniU(); // @1.0 + iniV2(); // @1.0 setUpTimeLoopN(); // @2.0 executeTimeLoopN(); // @3.0 diff --git a/tests/NabLabTests/src-gen-cpp/stl-thread/iteration/Iteration.h b/tests/NabLabTests/src-gen-cpp/stl-thread/iteration/Iteration.h index d1aa7ad74..727db723c 100644 --- a/tests/NabLabTests/src-gen-cpp/stl-thread/iteration/Iteration.h +++ b/tests/NabLabTests/src-gen-cpp/stl-thread/iteration/Iteration.h @@ -33,8 +33,10 @@ class Iteration void computeTn() noexcept; void iniTime() noexcept; void iniU() noexcept; - void iniV() noexcept; - void updateV() noexcept; + void iniV1() noexcept; + void iniV2() noexcept; + void updateV1() noexcept; + void updateV2() noexcept; void updateW() noexcept; void setUpTimeLoopK() noexcept; void setUpTimeLoopN() noexcept; @@ -67,11 +69,16 @@ class Iteration std::vector> X; std::vector u_n; std::vector u_nplus1; - std::vector v_n; - std::vector v_nplus1; - std::vector v_nplus1_k; - std::vector v_nplus1_kplus1; - std::vector v_nplus1_k0; + std::vector v1_n; + std::vector v1_nplus1; + std::vector v1_nplus1_k; + std::vector v1_nplus1_kplus1; + std::vector v1_nplus1_k0; + std::vector v2_n; + std::vector v2_nplus1; + std::vector v2_n0; + std::vector v2_nplus1_k; + std::vector v2_nplus1_kplus1; std::vector w_n; std::vector w_nplus1; std::vector w_nplus1_l; diff --git a/tests/NabLabTests/src-gen-java/iteration/Iteration.java b/tests/NabLabTests/src-gen-java/iteration/Iteration.java index f1158fc89..fc63e6b58 100644 --- a/tests/NabLabTests/src-gen-java/iteration/Iteration.java +++ b/tests/NabLabTests/src-gen-java/iteration/Iteration.java @@ -35,11 +35,16 @@ public final class Iteration double[][] X; double[] u_n; double[] u_nplus1; - double[] v_n; - double[] v_nplus1; - double[] v_nplus1_k; - double[] v_nplus1_kplus1; - double[] v_nplus1_k0; + double[] v1_n; + double[] v1_nplus1; + double[] v1_nplus1_k; + double[] v1_nplus1_kplus1; + double[] v1_nplus1_k0; + double[] v2_n; + double[] v2_nplus1; + double[] v2_n0; + double[] v2_nplus1_k; + double[] v2_nplus1_kplus1; double[] w_n; double[] w_nplus1; double[] w_nplus1_l; @@ -64,11 +69,16 @@ public Iteration(CartesianMesh2D aMesh) X = new double[nbNodes][2]; u_n = new double[nbCells]; u_nplus1 = new double[nbCells]; - v_n = new double[nbCells]; - v_nplus1 = new double[nbCells]; - v_nplus1_k = new double[nbCells]; - v_nplus1_kplus1 = new double[nbCells]; - v_nplus1_k0 = new double[nbCells]; + v1_n = new double[nbCells]; + v1_nplus1 = new double[nbCells]; + v1_nplus1_k = new double[nbCells]; + v1_nplus1_kplus1 = new double[nbCells]; + v1_nplus1_k0 = new double[nbCells]; + v2_n = new double[nbCells]; + v2_nplus1 = new double[nbCells]; + v2_n0 = new double[nbCells]; + v2_nplus1_k = new double[nbCells]; + v2_nplus1_kplus1 = new double[nbCells]; w_n = new double[nbCells]; w_nplus1 = new double[nbCells]; w_nplus1_l = new double[nbCells]; @@ -124,28 +134,54 @@ protected void iniU() } /** - * 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 */ - protected void iniV() + protected void iniV1() { IntStream.range(0, nbCells).parallel().forEach(cCells -> { - 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 + */ + protected void iniV2() + { + IntStream.range(0, nbCells).parallel().forEach(cCells -> + { + v2_n0[cCells] = 1.0; + }); + } + + /** + * Job updateV1 called @1.0 in executeTimeLoopK method. + * In variables: v1_nplus1_k + * Out variables: v1_nplus1_kplus1 + */ + protected void updateV1() + { + IntStream.range(0, nbCells).parallel().forEach(cCells -> + { + 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 */ - protected void updateV() + protected void updateV2() { IntStream.range(0, nbCells).parallel().forEach(cCells -> { - v_nplus1_kplus1[cCells] = v_nplus1_k[cCells] + 1.5; + v2_nplus1_kplus1[cCells] = v2_nplus1_k[cCells] + 2; }); } @@ -164,31 +200,39 @@ protected void updateW() /** * 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 */ protected void setUpTimeLoopK() { IntStream.range(0, nbCells).parallel().forEach(i1Cells -> { - v_nplus1_k[i1Cells] = v_nplus1_k0[i1Cells]; + v1_nplus1_k[i1Cells] = v1_nplus1_k0[i1Cells]; + }); + IntStream.range(0, nbCells).parallel().forEach(i1Cells -> + { + 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 */ protected void setUpTimeLoopN() { t_n = t_n0; + IntStream.range(0, nbCells).parallel().forEach(i1Cells -> + { + 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 */ protected void executeTimeLoopK() { @@ -199,22 +243,27 @@ protected void executeTimeLoopK() k++; System.out.printf("Start iteration k: %5d\n", k); - updateV(); // @1.0 + updateV1(); // @1.0 + updateV2(); // @1.0 // Evaluate loop condition with variables at time n continueLoop = (k + 1 < maxIterK); IntStream.range(0, nbCells).parallel().forEach(i1Cells -> { - v_nplus1_k[i1Cells] = v_nplus1_kplus1[i1Cells]; + v1_nplus1_k[i1Cells] = v1_nplus1_kplus1[i1Cells]; + }); + IntStream.range(0, nbCells).parallel().forEach(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 */ protected void executeTimeLoopN() { @@ -226,7 +275,7 @@ protected void executeTimeLoopN() System.out.printf("START ITERATION n: %5d - t: %5.5f - deltat: %5.5f\n", n, t_n, deltat); computeTn(); // @1.0 - iniV(); // @1.0 + iniV1(); // @1.0 setUpTimeLoopK(); // @2.0 executeTimeLoopK(); // @3.0 tearDownTimeLoopK(); // @4.0 @@ -246,7 +295,11 @@ protected void executeTimeLoopN() }); IntStream.range(0, nbCells).parallel().forEach(i1Cells -> { - v_n[i1Cells] = v_nplus1[i1Cells]; + v1_n[i1Cells] = v1_nplus1[i1Cells]; + }); + IntStream.range(0, nbCells).parallel().forEach(i1Cells -> + { + v2_n[i1Cells] = v2_nplus1[i1Cells]; }); IntStream.range(0, nbCells).parallel().forEach(i1Cells -> { @@ -259,27 +312,31 @@ protected void executeTimeLoopN() /** * 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 */ protected void tearDownTimeLoopK() { IntStream.range(0, nbCells).parallel().forEach(i1Cells -> { - v_nplus1[i1Cells] = v_nplus1_kplus1[i1Cells]; + v1_nplus1[i1Cells] = v1_nplus1_kplus1[i1Cells]; + }); + IntStream.range(0, nbCells).parallel().forEach(i1Cells -> + { + 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 */ protected void iniW() { IntStream.range(0, nbCells).parallel().forEach(cCells -> { - w_nplus1_l0[cCells] = v_nplus1[cCells]; + w_nplus1_l0[cCells] = v1_nplus1[cCells]; }); } @@ -353,6 +410,7 @@ public void simulate() System.out.println("Start execution of iteration"); iniTime(); // @1.0 iniU(); // @1.0 + iniV2(); // @1.0 setUpTimeLoopN(); // @2.0 executeTimeLoopN(); // @3.0 System.out.println("End of execution of iteration"); diff --git a/tests/NabLabTests/src-gen/iteration/Iteration.tex b/tests/NabLabTests/src-gen/iteration/Iteration.tex index 19f393d7a..fddb90a3b 100644 --- a/tests/NabLabTests/src-gen/iteration/Iteration.tex +++ b/tests/NabLabTests/src-gen/iteration/Iteration.tex @@ -19,16 +19,24 @@ \section{IniU} $\texttt{IniU} : \forall{c\in cells()}, \ u^{n}_{c} = 0.0$ -\section{IniV} -$\texttt{IniV} : \forall{c\in cells()}, \ v^{n+1, k=0}_{c} = u^{n}_{c} + 1$ +\section{IniV1} +$\texttt{IniV1} : \forall{c\in cells()}, \ v1^{n+1, k=0}_{c} = u^{n}_{c} + 1$ -\section{UpdateV} -$\texttt{UpdateV} : \forall{c\in cells()}, \ v^{n+1, k+1}_{c} = v^{n+1, k}_{c} + 1.5$ +\section{UpdateV1} +$\texttt{UpdateV1} : \forall{c\in cells()}, \ v1^{n+1, k+1}_{c} = v1^{n+1, k}_{c} + 1.5$ + + +\section{IniV2} +$\texttt{IniV2} : \forall{c\in cells()}, \ v2^{n=0}_{c} = 1.0$ + + +\section{UpdateV2} +$\texttt{UpdateV2} : \forall{c\in cells()}, \ v2^{n+1, k+1}_{c} = v2^{n+1, k}_{c} + 2$ \section{IniW} -$\texttt{IniW} : \forall{c\in cells()}, \ w^{n+1, l=0}_{c} = v^{n+1}_{c}$ +$\texttt{IniW} : \forall{c\in cells()}, \ w^{n+1, l=0}_{c} = v1^{n+1}_{c}$ \section{UpdateW} diff --git a/tests/NabLabTests/src/iteration/Iteration.n b/tests/NabLabTests/src/iteration/Iteration.n index 7439f159d..3e997de0b 100644 --- a/tests/NabLabTests/src/iteration/Iteration.n +++ b/tests/NabLabTests/src/iteration/Iteration.n @@ -20,11 +20,10 @@ let ℝ δt = 1.0; ℝ t; ℝ[2] X{nodes}; ℝ u{cells}; // Temperature -ℝ v{cells}; // vn+1 computed with iteration on k +ℝ v1{cells}; // vn+1 computed with iteration on k (exists k=0) +ℝ v2{cells}; // vn+1 computed with iteration on k (not exists k=0) ℝ w{cells}; // wn+1 computed with iteration on l -//iterate n while (t^{n+1} < maxTime && n+1 < maxIter), k while (k+1 < maxIterK); - iterate n while (t^{n+1} < maxTime && n+1 < maxIter), { k while (k+1 < maxIterK); l while (l+1 < maxIterL); @@ -32,10 +31,16 @@ iterate n while (t^{n+1} < maxTime && n+1 < maxIter), { IniTime: t^{n=0} = 0.0; IniU: ∀c∈cells(), u^{n}{c} = 0.0; -IniV: ∀c∈cells(), v^{n+1, k=0}{c} = u^{n}{c} + 1; -UpdateV: ∀c∈cells(), v^{n+1, k+1}{c} = v^{n+1, k}{c} + 1.5; -IniW: ∀c∈cells(), w^{n+1, l=0}{c} = v^{n+1}{c}; + +IniV1: ∀c∈cells(), v1^{n+1, k=0}{c} = u^{n}{c} + 1; +UpdateV1: ∀c∈cells(), v1^{n+1, k+1}{c} = v1^{n+1, k}{c} + 1.5; + +IniV2: ∀c∈cells(), v2^{n=0}{c} = 1.0; +UpdateV2: ∀c∈cells(), v2^{n+1, k+1}{c} = v2^{n+1, k}{c} + 2; + +IniW: ∀c∈cells(), w^{n+1, l=0}{c} = v1^{n+1}{c}; + UpdateW: ∀c∈cells(), w^{n+1, l+1}{c} = w^{n+1, l}{c} + 2.5; UpdateU: ∀c∈cells(), u^{n+1}{c} = w^{n+1}{c}; -//UpdateU: ∀c∈cells(), u^{n+1}{c} = v^{n+1}{c}; + ComputeTn: t^{n+1} = t^{n} + δt;