From 2340fcd50c4e4509a73e63d58be061461b9332d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20COPPENS?= Date: Mon, 29 Jun 2026 11:54:17 +0200 Subject: [PATCH 1/8] [Kokkos] Ported Champ_Face_VDF_implementation::valeur_aux_elems_compo CPU and CUDA versions pass and fail the same regression tests. In the CUDA version, 5 test cases are skipped. --- .../Champs/Champ_Face_VDF_implementation.cpp | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/VDF/Champs/Champ_Face_VDF_implementation.cpp b/src/VDF/Champs/Champ_Face_VDF_implementation.cpp index e62dd7f992..8aa7ffd89e 100644 --- a/src/VDF/Champs/Champ_Face_VDF_implementation.cpp +++ b/src/VDF/Champs/Champ_Face_VDF_implementation.cpp @@ -182,17 +182,21 @@ DoubleTab& Champ_Face_VDF_implementation::valeur_aux_faces_post_impl(const Domai return result; } -DoubleVect& Champ_Face_VDF_implementation::valeur_aux_elems_compo(const DoubleTab& positions, const IntVect& les_polys, DoubleVect& val, int ncomp) const +DoubleVect& Champ_Face_VDF_implementation::valeur_aux_elems_compo(const DoubleTab& tab_positions, const IntVect& tab_les_polys, DoubleVect& tab_val, int ncomp) const { - assert(val.size_totale() >= les_polys.size()); + assert(tab_val.size_totale() >= tab_les_polys.size()); const int D = Objet_U::dimension; - const DoubleTab& coord = domaine_vdf().domaine().coord_sommets(); - const IntTab& f_s = domaine_vdf().face_sommets(), &e_f = domaine_vdf().elem_faces(); - const DoubleTab& vals = le_champ().valeurs(); - int size = les_polys.size(); - ToDo_Kokkos("critical"); - for(int p = 0; p < size; p++) - { + int size = tab_les_polys.size(); + + CDoubleTabView positions = tab_positions.view_ro(); + CIntArrView les_polys = tab_les_polys.view_ro(); + DoubleArrView val = tab_val.view_wo(); + + CDoubleTabView coord = domaine_vdf().domaine().coord_sommets().view_ro(); + CIntTabView f_s = domaine_vdf().face_sommets().view_ro(); + CIntTabView e_f = domaine_vdf().elem_faces().view_ro(); + CDoubleArrView vals = static_cast(le_champ().valeurs()).view_ro(); + Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),range_1D(0, size), KOKKOS_LAMBDA(const int p){ int e = les_polys(p); if (e<0) { @@ -205,8 +209,9 @@ DoubleVect& Champ_Face_VDF_implementation::valeur_aux_elems_compo(const DoubleTa const double psi = (positions(p, ncomp) - coord(som0, ncomp)) / (coord(som1, ncomp) - coord(som0, ncomp)); val(p) = interpolation(val1, val2, psi); } - } - return val; + }); + end_gpu_timer(__KERNEL_NAME__); + return tab_val; } double Champ_Face_VDF_implementation::valeur_a_elem_compo(const DoubleVect& position, int e, int d) const From eeef8bed34783b8ff83e4095041dc03e2a593f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20COPPENS?= Date: Tue, 7 Jul 2026 12:48:03 +0000 Subject: [PATCH 2/8] [Kokkos] Ported first loop in Champ_Face_VDF_implementation.cpp/Champ_Face_VDF_implementation::trace --- .../Champs/Champ_Face_VDF_implementation.cpp | 68 ++++++++++--------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/src/VDF/Champs/Champ_Face_VDF_implementation.cpp b/src/VDF/Champs/Champ_Face_VDF_implementation.cpp index 8aa7ffd89e..d16e8c6006 100644 --- a/src/VDF/Champs/Champ_Face_VDF_implementation.cpp +++ b/src/VDF/Champs/Champ_Face_VDF_implementation.cpp @@ -498,7 +498,7 @@ int Champ_Face_VDF_implementation::imprime_Face(Sortie& os, int ncomp) const return 1; } -DoubleTab& Champ_Face_VDF_implementation::trace(const Frontiere_dis_base& fr, const DoubleTab& y, DoubleTab& x,int distant) const +DoubleTab& Champ_Face_VDF_implementation::trace(const Frontiere_dis_base& fr, const DoubleTab& tab_y, DoubleTab& tab_x,int distant) const { assert(distant==0); const Front_VF& fr_vf=ref_cast(Front_VF, fr); @@ -508,36 +508,38 @@ DoubleTab& Champ_Face_VDF_implementation::trace(const Frontiere_dis_base& fr, co const IntTab& elem_faces = zvdf.elem_faces(); int elem1,elem2; int face,i,f1,f2,f3,f4; + int num_first_face = fr_vf.num_premiere_face(); int nb_faces = fr_vf.nb_faces(); - if (x.dimension(0)!=nb_faces) + if (tab_x.dimension(0)!=nb_faces) { Cerr << "The number of faces " << nb_faces << " on the remote boundary " << fr.le_nom() << finl; - Cerr << "does not match the number of faces " << x.dimension(0) << " on the local boundary." << finl; + Cerr << "does not match the number of faces " << tab_x.dimension(0) << " on the local boundary." << finl; Cerr << "Please, check if the boundary condition is not applied on wrong boundaries." << finl; Process::exit(); } // assert(x.dimension(1)==Objet_U::dimension); - if (x.dimension(1) == 1) + if (tab_x.dimension(1) == 1) { - ToDo_Kokkos("critical"); - for (i=0; i(tab_y).view_ro(); + Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_faces), KOKKOS_LAMBDA(const int k){ + int l_face = num_first_face + k; + x(k,0) = y(l_face); + }); + end_gpu_timer(__KERNEL_NAME__); + return tab_x; } ToDo_Kokkos("critical"); - for (i=0; i Date: Tue, 7 Jul 2026 12:58:16 +0000 Subject: [PATCH 3/8] [Kokkos] Ported second loop in Champ_Face_VDF_implementation.cpp/Champ_Face_VDF_implementation::trace --- .../Champs/Champ_Face_VDF_implementation.cpp | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/VDF/Champs/Champ_Face_VDF_implementation.cpp b/src/VDF/Champs/Champ_Face_VDF_implementation.cpp index d16e8c6006..f51ebf37a5 100644 --- a/src/VDF/Champs/Champ_Face_VDF_implementation.cpp +++ b/src/VDF/Champs/Champ_Face_VDF_implementation.cpp @@ -503,7 +503,8 @@ DoubleTab& Champ_Face_VDF_implementation::trace(const Frontiere_dis_base& fr, co assert(distant==0); const Front_VF& fr_vf=ref_cast(Front_VF, fr); const Domaine_VDF& zvdf=domaine_vdf(); - const IntVect& ori = zvdf.orientation(); + const IntVect& tab_ori = zvdf.orientation(); + CIntArrView ori = zvdf.orientation().view_ro(); const IntTab& face_voisins = zvdf.face_voisins(); const IntTab& elem_faces = zvdf.elem_faces(); int elem1,elem2; @@ -519,10 +520,10 @@ DoubleTab& Champ_Face_VDF_implementation::trace(const Frontiere_dis_base& fr, co } // assert(x.dimension(1)==Objet_U::dimension); + DoubleTabView x = tab_x.view_wo(); + CDoubleArrView y = static_cast(tab_y).view_ro(); if (tab_x.dimension(1) == 1) { - DoubleTabView x = tab_x.view_wo(); - CDoubleArrView y = static_cast(tab_y).view_ro(); Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_faces), KOKKOS_LAMBDA(const int k){ int l_face = num_first_face + k; x(k,0) = y(l_face); @@ -530,12 +531,10 @@ DoubleTab& Champ_Face_VDF_implementation::trace(const Frontiere_dis_base& fr, co end_gpu_timer(__KERNEL_NAME__); return tab_x; } - ToDo_Kokkos("critical"); - for (i=0; i Date: Tue, 7 Jul 2026 14:00:05 +0000 Subject: [PATCH 4/8] [Kokkos] Ported third loop in Champ_Face_VDF_implementation.cpp/Champ_Face_VDF_implementation::trace Champ_Face_VDF_implementation::trace fully ported. Compiles successfully on CUDA --- .../Champs/Champ_Face_VDF_implementation.cpp | 227 +++++++++--------- 1 file changed, 113 insertions(+), 114 deletions(-) diff --git a/src/VDF/Champs/Champ_Face_VDF_implementation.cpp b/src/VDF/Champs/Champ_Face_VDF_implementation.cpp index f51ebf37a5..5150b523f3 100644 --- a/src/VDF/Champs/Champ_Face_VDF_implementation.cpp +++ b/src/VDF/Champs/Champ_Face_VDF_implementation.cpp @@ -503,12 +503,9 @@ DoubleTab& Champ_Face_VDF_implementation::trace(const Frontiere_dis_base& fr, co assert(distant==0); const Front_VF& fr_vf=ref_cast(Front_VF, fr); const Domaine_VDF& zvdf=domaine_vdf(); - const IntVect& tab_ori = zvdf.orientation(); CIntArrView ori = zvdf.orientation().view_ro(); - const IntTab& face_voisins = zvdf.face_voisins(); - const IntTab& elem_faces = zvdf.elem_faces(); - int elem1,elem2; - int face,i,f1,f2,f3,f4; + CIntTabView face_voisins = zvdf.face_voisins().view_ro(); + CIntTabView elem_faces = zvdf.elem_faces().view_ro(); int num_first_face = fr_vf.num_premiere_face(); int nb_faces = fr_vf.nb_faces(); if (tab_x.dimension(0)!=nb_faces) @@ -525,119 +522,121 @@ DoubleTab& Champ_Face_VDF_implementation::trace(const Frontiere_dis_base& fr, co if (tab_x.dimension(1) == 1) { Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_faces), KOKKOS_LAMBDA(const int k){ - int l_face = num_first_face + k; - x(k,0) = y(l_face); + int face = num_first_face + k; + x(k,0) = y(face); }); end_gpu_timer(__KERNEL_NAME__); return tab_x; } - Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_faces), KOKKOS_LAMBDA (const int k){ - int l_face = num_first_face + k; - x(k, ori[l_face]) = y(l_face); - }); - ToDo_Kokkos("critical"); - for (i=0; i Date: Thu, 9 Jul 2026 08:48:18 +0000 Subject: [PATCH 5/8] [Kokkos] Ported Op_Dift_VDF_Elem_base::calculer_dt_stab_elem Compiles successfully on CPU-only and CUDA. Successful tests cases :14/16 Successful tests cases in parallel mode :10/14 24 test cases run in 17 s ( 1 s/test), so less than 1 hours 1 test cases skipped List of unsuccessful tests cases : Marche3D_les_jdd5 Marche3D_les_jdd6 QC_centre4_VDF QC_centre4_VDF_Turb_Null --- .../Op_Dift_VDF_Elem_base.cpp | 88 +++++++++++++------ 1 file changed, 60 insertions(+), 28 deletions(-) diff --git a/src/VDF/Operateurs/Op_Diff_Dift/Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp b/src/VDF/Operateurs/Op_Diff_Dift/Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp index c15b7e1dca..e809972393 100644 --- a/src/VDF/Operateurs/Op_Diff_Dift/Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp +++ b/src/VDF/Operateurs/Op_Diff_Dift/Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp @@ -32,37 +32,69 @@ double Op_Dift_VDF_Elem_base::calculer_dt_stab_elem() const { double dt_stab, coef = -1.e10; const Domaine_VDF& domaine_VDF = iter_->domaine(); - const IntTab& elem_faces = domaine_VDF.elem_faces(); - const DoubleVect& alpha_t = diffusivite_turbulente().valeurs(); + Domaine_VDF_View dom_view(domaine_VDF); + CIntTabView elem_faces = domaine_VDF.elem_faces().view_ro(); + const DoubleVect& tab_alpha_t = diffusivite_turbulente().valeurs(); + CDoubleArrView alpha_t = tab_alpha_t.view_ro(); bool is_concentration = (equation().que_suis_je().debute_par("Convection_Diffusion_Concentration") || equation().que_suis_je().debute_par("Convection_Diffusion_Espece")); - ArrOfInt numfa(2*dimension); - ToDo_Kokkos("critical"); - for (int elem = 0; elem < domaine_VDF.nb_elem(); elem++) + const int dimension = Objet_U::dimension; + ArrOfInt tab_numfa(2*dimension); + IntArrView numfa = tab_numfa.view_rw(); + int nb_elem = domaine_VDF.nb_elem(); + // Prefetch alpha_(elem) on host to avoid virtual function inside Kokkok lambda + DoubleArrView alpha_view; + for (int elem = 0; elem < nb_elem; elem++) { - // choix du facteur - double rcp = 1.; - if (!is_concentration) - { - const int Ccp = sub_type(Champ_Uniforme, mon_equation->milieu().capacite_calorifique()); - const int Cr = sub_type(Champ_Uniforme, mon_equation->milieu().masse_volumique()); - const DoubleTab& tab_Cp = mon_equation->milieu().capacite_calorifique().valeurs(); - const DoubleTab& tab_r = mon_equation->milieu().masse_volumique().valeurs(); - rcp = tab_r(Cr ? 0 : elem, 0) * tab_Cp(Ccp ? 0 : elem, 0); - } - - double moy = 0.; - for (int i = 0; i < 2 * dimension; i++) numfa[i] = elem_faces(elem, i); - - // XXX : E Saikali j'ai corrige pour multi inco parce que c'etait 1/dx et pas 1/dx^2 ... donc attention si ecart ! - // c'etait comme ca : for (int d = 0; d < dimension; d++) moy += 1. / (domaine_VDF.dist_face(numfa[d], numfa[dimension + d], d)); - for (int d = 0; d < dimension; d++) - { - const double hd = domaine_VDF.dist_face(numfa[d], numfa[dimension + d], d); - moy += 1. / (hd * hd); - } - const double alpha_local = (alpha_(elem) + alpha_t(elem)) / rcp * moy; - coef = std::max(coef, alpha_local); + alpha_view(elem) = alpha_(elem); + } + if (!is_concentration) + { + const int Ccp = sub_type(Champ_Uniforme, mon_equation->milieu().capacite_calorifique()); + const int Cr = sub_type(Champ_Uniforme, mon_equation->milieu().masse_volumique()); + CDoubleTabView tab_Cp = mon_equation->milieu().capacite_calorifique().valeurs().view_ro(); + CDoubleTabView tab_r = mon_equation->milieu().masse_volumique().valeurs().view_ro(); + Kokkos::parallel_reduce(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_elem), KOKKOS_LAMBDA (const int elem, double& local_max){ + double rcp = tab_r(Cr ? 0 : elem, 0) * tab_Cp(Ccp ? 0 : elem, 0); + + double moy = 0.; + for (int i = 0; i < 2 * dimension; i++) numfa[i] = elem_faces(elem, i); + + // XXX : E Saikali j'ai corrige pour multi inco parce que c'etait 1/dx et pas 1/dx^2 ... donc attention si ecart ! + // c'etait comme ca : for (int d = 0; d < dimension; d++) moy += 1. / (domaine_VDF.dist_face(numfa[d], numfa[dimension + d], d)); + for (int d = 0; d < dimension; d++) + { + const double hd = dom_view.dist_face(numfa[d], numfa[dimension + d], d); + moy += 1. / (hd * hd); + } + const double alpha_local = (alpha_view(elem) + alpha_t(elem)) / rcp * moy; + local_max = std::max(coef, alpha_local); + }, + Kokkos::Max(coef) + ); + end_gpu_timer(__KERNEL_NAME__); + } + else + { + Kokkos::parallel_reduce(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_elem), KOKKOS_LAMBDA (const int elem, double& local_max){ + double rcp = 1.0f; + + double moy = 0.; + for (int i = 0; i < 2 * dimension; i++) numfa[i] = elem_faces(elem, i); + + // XXX : E Saikali j'ai corrige pour multi inco parce que c'etait 1/dx et pas 1/dx^2 ... donc attention si ecart ! + // c'etait comme ca : for (int d = 0; d < dimension; d++) moy += 1. / (domaine_VDF.dist_face(numfa[d], numfa[dimension + d], d)); + for (int d = 0; d < dimension; d++) + { + const double hd = dom_view.dist_face(numfa[d], numfa[dimension + d], d); + moy += 1. / (hd * hd); + } + const double alpha_local = (alpha_view(elem) + alpha_t(elem)) / rcp * moy; + local_max = std::max(coef, alpha_local); + }, + Kokkos::Max(coef) + ); + end_gpu_timer(__KERNEL_NAME__); } coef = Process::mp_max(coef); From ec76159f5f5feb3a4405c2f6fa65532560db984c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20COPPENS?= Date: Fri, 10 Jul 2026 12:39:01 +0000 Subject: [PATCH 6/8] [Kokkos] Ported src/Kernel/VF/Champs/Champ_front_softanalytique.cpp:107 Successful tests cases :56/113 Successful tests cases in parallel mode :44/82 180 test cases run in 3.56824e+09 s ( 19823558 s/test), so less than 991178 hours 91 test cases skipped --- .../VF/Champs/Champ_front_softanalytique.cpp | 65 ++++++++++++------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/src/Kernel/VF/Champs/Champ_front_softanalytique.cpp b/src/Kernel/VF/Champs/Champ_front_softanalytique.cpp index 1904c040d6..a6b497a073 100644 --- a/src/Kernel/VF/Champs/Champ_front_softanalytique.cpp +++ b/src/Kernel/VF/Champs/Champ_front_softanalytique.cpp @@ -16,6 +16,7 @@ #include #include #include +#include Implemente_instanciable(Champ_front_softanalytique,"Champ_front_fonc_xyz",Ch_front_var_stationnaire); // XD champ_front_fonc_xyz front_field_base champ_front_fonc_xyz 0 Boundary field which is not constant in space. @@ -93,39 +94,53 @@ int Champ_front_softanalytique::initialiser(double temps, const Champ_Inc_base& if (!Ch_front_var_stationnaire::initialiser(temps,inco)) return 0; - int dim=nb_comp(); - double x,y,z; // int nbsf=faces.nb_som_faces(); - int k; - DoubleTab& tab=valeurs(); + int dim=nb_comp(); + DoubleTab& tab_tab=valeurs(); + DoubleTabView tab = tab_tab.view_wo(); const Domaine_VF& domaine_vf=ref_cast(Domaine_VF,frontiere_dis().domaine_dis()); - const DoubleTab& xv=domaine_vf.xv(); + CDoubleTabView xv = domaine_vf.xv().view_ro(); const Front_VF& le_bord = ref_cast(Front_VF,frontiere_dis()); - int nb_faces_bord_tot=le_bord.nb_faces_tot(); - ToDo_Kokkos("critical"); - for (int ind_face=0; ind_face1) - y=xv(face,1); - if(dimension>2) - z=xv(face,2); - - for( k=0; k 1) + y = xv(face, 1); + if(dimension > 2) + z = xv(face, 2); + + fxyzk.setVar(0, x, threadId); + fxyzk.setVar(1, y, threadId); + fxyzk.setVar(2, z, threadId); + tab(i, k) = fxyzk.eval(threadId); + fxyzk.release(threadId); + //Cout << " x y z " << x << " " << y << " " << z << " " << tab(i,k) << finl; + }); + end_gpu_timer(__KERNEL_NAME__); } - tab.echange_espace_virtuel(); + tab_tab.echange_espace_virtuel(); return 1; } From ed63100118e06da44ee47eb7583cfd5f3a6b3f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Coppens?= Date: Sun, 19 Jul 2026 09:12:30 +0200 Subject: [PATCH 7/8] [Kokkos] Local variable dimension's name is not allowed to shadow member variable Objet_U's::dimension's name. --- src/Kernel/VF/Champs/Champ_front_softanalytique.cpp | 8 ++++---- .../Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Kernel/VF/Champs/Champ_front_softanalytique.cpp b/src/Kernel/VF/Champs/Champ_front_softanalytique.cpp index a6b497a073..65d895c758 100644 --- a/src/Kernel/VF/Champs/Champ_front_softanalytique.cpp +++ b/src/Kernel/VF/Champs/Champ_front_softanalytique.cpp @@ -107,12 +107,12 @@ int Champ_front_softanalytique::initialiser(double temps, const Champ_Inc_base& int nb_faces_bord_tot = le_bord.nb_faces_tot(); int premiere_face = le_bord.num_premiere_face(); CIntArrView faces_virt = le_bord.frontiere().get_faces_virt().view_ro(); - const int dimension = Objet_U::dimension; + const int l_dimension = Objet_U::dimension; for(int k = 0; k < dim; k++) { ParserView fxyzk(fxyz[k]); fxyzk.parseString(); - Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), nb_faces_bord_tot, KOKKOS_LAMBDA(const int i) + Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), static_cast(nb_faces_bord_tot), KOKKOS_LAMBDA(const int i) { double x,y,z; int threadId = fxyzk.acquire(); @@ -125,9 +125,9 @@ int Champ_front_softanalytique::initialiser(double temps, const Champ_Inc_base& x = y = z = 0; x = xv(face, 0); - if(dimension > 1) + if(l_dimension > 1) y = xv(face, 1); - if(dimension > 2) + if(l_dimension > 2) z = xv(face, 2); fxyzk.setVar(0, x, threadId); diff --git a/src/VDF/Operateurs/Op_Diff_Dift/Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp b/src/VDF/Operateurs/Op_Diff_Dift/Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp index e809972393..1c79177331 100644 --- a/src/VDF/Operateurs/Op_Diff_Dift/Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp +++ b/src/VDF/Operateurs/Op_Diff_Dift/Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp @@ -38,8 +38,8 @@ double Op_Dift_VDF_Elem_base::calculer_dt_stab_elem() const CDoubleArrView alpha_t = tab_alpha_t.view_ro(); bool is_concentration = (equation().que_suis_je().debute_par("Convection_Diffusion_Concentration") || equation().que_suis_je().debute_par("Convection_Diffusion_Espece")); - const int dimension = Objet_U::dimension; - ArrOfInt tab_numfa(2*dimension); + const int l_dimension = Objet_U::dimension; + ArrOfInt tab_numfa(2*l_dimension); IntArrView numfa = tab_numfa.view_rw(); int nb_elem = domaine_VDF.nb_elem(); // Prefetch alpha_(elem) on host to avoid virtual function inside Kokkok lambda From c3d6a10011b569f0525d132ba25c9b4e5d3ba0d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Coppens?= Date: Sun, 19 Jul 2026 10:20:40 +0200 Subject: [PATCH 8/8] [Formatter] Corrected formatting of previous changes --- .../VF/Champs/Champ_front_softanalytique.cpp | 6 +- .../Champs/Champ_Face_VDF_implementation.cpp | 46 +++++++------ .../Op_Dift_VDF_Elem_base.cpp | 68 ++++++++++--------- 3 files changed, 63 insertions(+), 57 deletions(-) diff --git a/src/Kernel/VF/Champs/Champ_front_softanalytique.cpp b/src/Kernel/VF/Champs/Champ_front_softanalytique.cpp index 65d895c758..59edeb2adf 100644 --- a/src/Kernel/VF/Champs/Champ_front_softanalytique.cpp +++ b/src/Kernel/VF/Champs/Champ_front_softanalytique.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -* Copyright (c) 2022, CEA +* Copyright (c) 2026, CEA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -136,8 +136,8 @@ int Champ_front_softanalytique::initialiser(double temps, const Champ_Inc_base& tab(i, k) = fxyzk.eval(threadId); fxyzk.release(threadId); //Cout << " x y z " << x << " " << y << " " << z << " " << tab(i,k) << finl; - }); - end_gpu_timer(__KERNEL_NAME__); + }); + end_gpu_timer(__KERNEL_NAME__); } tab_tab.echange_espace_virtuel(); diff --git a/src/VDF/Champs/Champ_Face_VDF_implementation.cpp b/src/VDF/Champs/Champ_Face_VDF_implementation.cpp index 5150b523f3..513d4c6a6a 100644 --- a/src/VDF/Champs/Champ_Face_VDF_implementation.cpp +++ b/src/VDF/Champs/Champ_Face_VDF_implementation.cpp @@ -196,21 +196,22 @@ DoubleVect& Champ_Face_VDF_implementation::valeur_aux_elems_compo(const DoubleTa CIntTabView f_s = domaine_vdf().face_sommets().view_ro(); CIntTabView e_f = domaine_vdf().elem_faces().view_ro(); CDoubleArrView vals = static_cast(le_champ().valeurs()).view_ro(); - Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),range_1D(0, size), KOKKOS_LAMBDA(const int p){ - int e = les_polys(p); - if (e<0) - { - val(p) = 0; - } - else - { - const double val1 = vals(e_f(e, ncomp)), val2 = vals(e_f(e, D + ncomp)); - const int som0 = f_s(e_f(e, ncomp), 0), som1 = f_s(e_f(e, D + ncomp), 0); - const double psi = (positions(p, ncomp) - coord(som0, ncomp)) / (coord(som1, ncomp) - coord(som0, ncomp)); - val(p) = interpolation(val1, val2, psi); - } - }); - end_gpu_timer(__KERNEL_NAME__); + Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__),range_1D(0, size), KOKKOS_LAMBDA(const int p) + { + int e = les_polys(p); + if (e<0) + { + val(p) = 0; + } + else + { + const double val1 = vals(e_f(e, ncomp)), val2 = vals(e_f(e, D + ncomp)); + const int som0 = f_s(e_f(e, ncomp), 0), som1 = f_s(e_f(e, D + ncomp), 0); + const double psi = (positions(p, ncomp) - coord(som0, ncomp)) / (coord(som1, ncomp) - coord(som0, ncomp)); + val(p) = interpolation(val1, val2, psi); + } + }); + end_gpu_timer(__KERNEL_NAME__); return tab_val; } @@ -504,7 +505,7 @@ DoubleTab& Champ_Face_VDF_implementation::trace(const Frontiere_dis_base& fr, co const Front_VF& fr_vf=ref_cast(Front_VF, fr); const Domaine_VDF& zvdf=domaine_vdf(); CIntArrView ori = zvdf.orientation().view_ro(); - CIntTabView face_voisins = zvdf.face_voisins().view_ro(); + CIntTabView face_voisins = zvdf.face_voisins().view_ro(); CIntTabView elem_faces = zvdf.elem_faces().view_ro(); int num_first_face = fr_vf.num_premiere_face(); int nb_faces = fr_vf.nb_faces(); @@ -521,20 +522,23 @@ DoubleTab& Champ_Face_VDF_implementation::trace(const Frontiere_dis_base& fr, co CDoubleArrView y = static_cast(tab_y).view_ro(); if (tab_x.dimension(1) == 1) { - Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_faces), KOKKOS_LAMBDA(const int k){ - int face = num_first_face + k; - x(k,0) = y(face); + Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_faces), KOKKOS_LAMBDA(const int k) + { + int face = num_first_face + k; + x(k,0) = y(face); }); end_gpu_timer(__KERNEL_NAME__); return tab_x; } - Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_faces), KOKKOS_LAMBDA (const int k){ + Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_faces), KOKKOS_LAMBDA (const int k) + { int face = num_first_face + k; x(k, ori[face]) = y(face); }); end_gpu_timer(__KERNEL_NAME__); const int dim = Objet_U::dimension; - Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_faces), KOKKOS_LAMBDA (const int k){ + Kokkos::parallel_for(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_faces), KOKKOS_LAMBDA (const int k) + { int f1, f2, f3, f4; int face=num_first_face + k; int elem1 = face_voisins(face, 0); diff --git a/src/VDF/Operateurs/Op_Diff_Dift/Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp b/src/VDF/Operateurs/Op_Diff_Dift/Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp index 1c79177331..94574c24d4 100644 --- a/src/VDF/Operateurs/Op_Diff_Dift/Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp +++ b/src/VDF/Operateurs/Op_Diff_Dift/Op_Diff_Dift_base/Op_Dift_VDF_Elem_base.cpp @@ -32,7 +32,7 @@ double Op_Dift_VDF_Elem_base::calculer_dt_stab_elem() const { double dt_stab, coef = -1.e10; const Domaine_VDF& domaine_VDF = iter_->domaine(); - Domaine_VDF_View dom_view(domaine_VDF); + Domaine_VDF_View dom_view(domaine_VDF); CIntTabView elem_faces = domaine_VDF.elem_faces().view_ro(); const DoubleVect& tab_alpha_t = diffusivite_turbulente().valeurs(); CDoubleArrView alpha_t = tab_alpha_t.view_ro(); @@ -54,46 +54,48 @@ double Op_Dift_VDF_Elem_base::calculer_dt_stab_elem() const const int Cr = sub_type(Champ_Uniforme, mon_equation->milieu().masse_volumique()); CDoubleTabView tab_Cp = mon_equation->milieu().capacite_calorifique().valeurs().view_ro(); CDoubleTabView tab_r = mon_equation->milieu().masse_volumique().valeurs().view_ro(); - Kokkos::parallel_reduce(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_elem), KOKKOS_LAMBDA (const int elem, double& local_max){ - double rcp = tab_r(Cr ? 0 : elem, 0) * tab_Cp(Ccp ? 0 : elem, 0); - - double moy = 0.; - for (int i = 0; i < 2 * dimension; i++) numfa[i] = elem_faces(elem, i); - - // XXX : E Saikali j'ai corrige pour multi inco parce que c'etait 1/dx et pas 1/dx^2 ... donc attention si ecart ! - // c'etait comme ca : for (int d = 0; d < dimension; d++) moy += 1. / (domaine_VDF.dist_face(numfa[d], numfa[dimension + d], d)); - for (int d = 0; d < dimension; d++) - { - const double hd = dom_view.dist_face(numfa[d], numfa[dimension + d], d); - moy += 1. / (hd * hd); - } - const double alpha_local = (alpha_view(elem) + alpha_t(elem)) / rcp * moy; - local_max = std::max(coef, alpha_local); + Kokkos::parallel_reduce(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_elem), KOKKOS_LAMBDA (const int elem, double& local_max) + { + double rcp = tab_r(Cr ? 0 : elem, 0) * tab_Cp(Ccp ? 0 : elem, 0); + + double moy = 0.; + for (int i = 0; i < 2 * dimension; i++) numfa[i] = elem_faces(elem, i); + + // XXX : E Saikali j'ai corrige pour multi inco parce que c'etait 1/dx et pas 1/dx^2 ... donc attention si ecart ! + // c'etait comme ca : for (int d = 0; d < dimension; d++) moy += 1. / (domaine_VDF.dist_face(numfa[d], numfa[dimension + d], d)); + for (int d = 0; d < dimension; d++) + { + const double hd = dom_view.dist_face(numfa[d], numfa[dimension + d], d); + moy += 1. / (hd * hd); + } + const double alpha_local = (alpha_view(elem) + alpha_t(elem)) / rcp * moy; + local_max = std::max(coef, alpha_local); }, Kokkos::Max(coef) - ); + ); end_gpu_timer(__KERNEL_NAME__); } else { - Kokkos::parallel_reduce(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_elem), KOKKOS_LAMBDA (const int elem, double& local_max){ - double rcp = 1.0f; - - double moy = 0.; - for (int i = 0; i < 2 * dimension; i++) numfa[i] = elem_faces(elem, i); - - // XXX : E Saikali j'ai corrige pour multi inco parce que c'etait 1/dx et pas 1/dx^2 ... donc attention si ecart ! - // c'etait comme ca : for (int d = 0; d < dimension; d++) moy += 1. / (domaine_VDF.dist_face(numfa[d], numfa[dimension + d], d)); - for (int d = 0; d < dimension; d++) - { - const double hd = dom_view.dist_face(numfa[d], numfa[dimension + d], d); - moy += 1. / (hd * hd); - } - const double alpha_local = (alpha_view(elem) + alpha_t(elem)) / rcp * moy; - local_max = std::max(coef, alpha_local); + Kokkos::parallel_reduce(start_gpu_timer(__KERNEL_NAME__), range_1D(0, nb_elem), KOKKOS_LAMBDA (const int elem, double& local_max) + { + double rcp = 1.0f; + + double moy = 0.; + for (int i = 0; i < 2 * dimension; i++) numfa[i] = elem_faces(elem, i); + + // XXX : E Saikali j'ai corrige pour multi inco parce que c'etait 1/dx et pas 1/dx^2 ... donc attention si ecart ! + // c'etait comme ca : for (int d = 0; d < dimension; d++) moy += 1. / (domaine_VDF.dist_face(numfa[d], numfa[dimension + d], d)); + for (int d = 0; d < dimension; d++) + { + const double hd = dom_view.dist_face(numfa[d], numfa[dimension + d], d); + moy += 1. / (hd * hd); + } + const double alpha_local = (alpha_view(elem) + alpha_t(elem)) / rcp * moy; + local_max = std::max(coef, alpha_local); }, Kokkos::Max(coef) - ); + ); end_gpu_timer(__KERNEL_NAME__); }