From baea964f7974afe5280578727c531aadddd42cbf Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Mon, 17 Sep 2018 15:27:30 +0200
Subject: [PATCH] Define PASTIS_LAMBA to encapsulate KOKKOS_LAMBDA

This may be temporary
---
 src/mesh/Connectivity.cpp                 |  4 ++--
 src/mesh/MeshData.hpp                     | 26 +++++++++++------------
 src/mesh/MeshNodeBoundary.hpp             |  6 +++---
 src/scheme/AcousticSolver.hpp             | 26 +++++++++++------------
 src/scheme/BlockPerfectGas.hpp            |  6 +++---
 src/scheme/BoundaryCondition.hpp          |  2 +-
 src/scheme/FiniteVolumesEulerUnknowns.hpp | 14 ++++++------
 src/utils/PastisMacros.hpp                |  8 ++++---
 8 files changed, 47 insertions(+), 45 deletions(-)

diff --git a/src/mesh/Connectivity.cpp b/src/mesh/Connectivity.cpp
index f84f3835a..9d95f2896 100644
--- a/src/mesh/Connectivity.cpp
+++ b/src/mesh/Connectivity.cpp
@@ -228,14 +228,14 @@ Connectivity(const std::vector<std::vector<unsigned int>>& cell_by_node_vector,
 
   {
     CellValue<CellType> cell_type(*this);
-    Kokkos::parallel_for(this->numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(this->numberOfCells(), PASTIS_LAMBDA(const CellId& j){
         cell_type[j] = cell_type_vector[j];
       });
     m_cell_type = cell_type;
   }
   {
     CellValue<double> inv_cell_nb_nodes(*this);
-    Kokkos::parallel_for(this->numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(this->numberOfCells(), PASTIS_LAMBDA(const CellId& j){
         const auto& cell_nodes = cell_to_node_matrix.rowConst(j);
         inv_cell_nb_nodes[j] = 1./cell_nodes.length;
       });
diff --git a/src/mesh/MeshData.hpp b/src/mesh/MeshData.hpp
index 4e177f527..0f016f0e9 100644
--- a/src/mesh/MeshData.hpp
+++ b/src/mesh/MeshData.hpp
@@ -40,7 +40,7 @@ class MeshData
           = m_mesh.connectivity().cellToNodeMatrix();
 
       CellValue<Rd> xj(m_mesh.connectivity());
-      Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+      Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
           const auto& cell_nodes = cell_to_node_matrix[j];
           xj[j] = 0.5*(xr[cell_nodes[0]]+xr[cell_nodes[1]]);
         });
@@ -54,7 +54,7 @@ class MeshData
       const auto& cell_to_node_matrix
           = m_mesh.connectivity().cellToNodeMatrix();
       CellValue<Rd> xj(m_mesh.connectivity());
-      Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+      Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
           Rd X = zero;
           const auto& cell_nodes = cell_to_node_matrix[j];
           for (size_t R=0; R<cell_nodes.size(); ++R) {
@@ -74,7 +74,7 @@ class MeshData
         = m_mesh.connectivity().cellToNodeMatrix();
 
     CellValue<double> Vj(m_mesh.connectivity());
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
         double sum_cjr_xr = 0;
         const auto& cell_nodes = cell_to_node_matrix[j];
 
@@ -98,7 +98,7 @@ class MeshData
 
       {
         NodeValuePerCell<Rd> Cjr(m_mesh.connectivity());
-        Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+        Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
             const auto& cell_nodes = cell_to_node_matrix[j];
             for (size_t R=0; R<cell_nodes.size(); ++R) {
               int Rp1 = (R+1)%cell_nodes.size();
@@ -112,7 +112,7 @@ class MeshData
 
       {
         NodeValuePerCell<double> ljr(m_mesh.connectivity());
-        Kokkos::parallel_for(m_Cjr.numberOfValues(), KOKKOS_LAMBDA(const size_t& jr){
+        Kokkos::parallel_for(m_Cjr.numberOfValues(), PASTIS_LAMBDA(const size_t& jr){
             ljr[jr] = l2Norm(m_Cjr[jr]);
           });
         m_ljr = ljr;
@@ -120,7 +120,7 @@ class MeshData
 
       {
         NodeValuePerCell<Rd> njr(m_mesh.connectivity());
-        Kokkos::parallel_for(m_Cjr.numberOfValues(), KOKKOS_LAMBDA(const size_t& jr){
+        Kokkos::parallel_for(m_Cjr.numberOfValues(), PASTIS_LAMBDA(const size_t& jr){
             njr[jr] = (1./m_ljr[jr])*m_Cjr[jr];
           });
         m_njr = njr;
@@ -132,7 +132,7 @@ class MeshData
       const auto& face_to_node_matrix
           = m_mesh.connectivity().faceToNodeMatrix();
 
-      Kokkos::parallel_for(m_mesh.numberOfFaces(), KOKKOS_LAMBDA(const FaceId& l) {
+      Kokkos::parallel_for(m_mesh.numberOfFaces(), PASTIS_LAMBDA(const FaceId& l) {
           const auto& face_nodes = face_to_node_matrix[l];
           const size_t nb_nodes = face_nodes.size();
           std::vector<Rd> dxr(nb_nodes);
@@ -164,11 +164,11 @@ class MeshData
 
       {
         NodeValuePerCell<Rd> Cjr(m_mesh.connectivity());
-        Kokkos::parallel_for(Cjr.numberOfValues(), KOKKOS_LAMBDA(const size_t& jr){
+        Kokkos::parallel_for(Cjr.numberOfValues(), PASTIS_LAMBDA(const size_t& jr){
             Cjr[jr] = zero;
           });
 
-        Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j) {
+        Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j) {
             const auto& cell_nodes = cell_to_node_matrix[j];
 
             const auto& cell_faces = cell_to_face_matrix[j];
@@ -209,7 +209,7 @@ class MeshData
 
       {
         NodeValuePerCell<double> ljr(m_mesh.connectivity());
-        Kokkos::parallel_for(m_Cjr.numberOfValues(), KOKKOS_LAMBDA(const size_t& jr){
+        Kokkos::parallel_for(m_Cjr.numberOfValues(), PASTIS_LAMBDA(const size_t& jr){
             ljr[jr] = l2Norm(m_Cjr[jr]);
           });
         m_ljr = ljr;
@@ -217,7 +217,7 @@ class MeshData
 
       {
         NodeValuePerCell<Rd> njr(m_mesh.connectivity());
-        Kokkos::parallel_for(m_Cjr.numberOfValues(), KOKKOS_LAMBDA(const size_t& jr){
+        Kokkos::parallel_for(m_Cjr.numberOfValues(), PASTIS_LAMBDA(const size_t& jr){
             njr[jr] = (1./m_ljr[jr])*m_Cjr[jr];
           });
         m_njr = njr;
@@ -271,7 +271,7 @@ class MeshData
       // in 1d Cjr are computed once for all
       {
         NodeValuePerCell<Rd> Cjr(m_mesh.connectivity());
-        Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j) {
+        Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j) {
             Cjr(j,0)=-1;
             Cjr(j,1)= 1;
           });
@@ -281,7 +281,7 @@ class MeshData
       m_njr = m_Cjr;
       {
         NodeValuePerCell<double> ljr(m_mesh.connectivity());
-        Kokkos::parallel_for(ljr.numberOfValues(), KOKKOS_LAMBDA(const size_t& jr){
+        Kokkos::parallel_for(ljr.numberOfValues(), PASTIS_LAMBDA(const size_t& jr){
             ljr[jr] = 1;
         });
         m_ljr = ljr;
diff --git a/src/mesh/MeshNodeBoundary.hpp b/src/mesh/MeshNodeBoundary.hpp
index 9b8bc4e00..a8026cc86 100644
--- a/src/mesh/MeshNodeBoundary.hpp
+++ b/src/mesh/MeshNodeBoundary.hpp
@@ -37,7 +37,7 @@ class MeshNodeBoundary
         = mesh.connectivity().faceToCellMatrix();
 
     const Array<const FaceId>& face_list = ref_face_list.faceList();
-    Kokkos::parallel_for(face_list.size(), KOKKOS_LAMBDA(const int& l){
+    Kokkos::parallel_for(face_list.size(), PASTIS_LAMBDA(const int& l){
         const auto& face_cells = face_to_cell_matrix[face_list[l]];
         if (face_cells.size()>1) {
           std::cerr << "internal faces cannot be used to define mesh boundaries\n";
@@ -64,7 +64,7 @@ class MeshNodeBoundary
     node_ids.resize(std::distance(node_ids.begin(), last));
 
     Array<NodeId> node_list(node_ids.size());
-    Kokkos::parallel_for(node_ids.size(), KOKKOS_LAMBDA(const int& r){
+    Kokkos::parallel_for(node_ids.size(), PASTIS_LAMBDA(const int& r){
         node_list[r] = node_ids[r];
       });
     m_node_list = node_list;
@@ -158,7 +158,7 @@ _checkBoundaryIsFlat(const TinyVector<2,double>& normal,
 
   const NodeValue<const R2>& xr = mesh.xr();
 
-  Kokkos::parallel_for(m_node_list.size(), KOKKOS_LAMBDA(const size_t& r) {
+  Kokkos::parallel_for(m_node_list.size(), PASTIS_LAMBDA(const size_t& r) {
       const R2& x = xr[m_node_list[r]];
       if ((x-origin,normal)>1E-13*length) {
         std::cerr << "this FlatBoundary is not flat!\n";
diff --git a/src/scheme/AcousticSolver.hpp b/src/scheme/AcousticSolver.hpp
index 0db6f75ec..389e916e0 100644
--- a/src/scheme/AcousticSolver.hpp
+++ b/src/scheme/AcousticSolver.hpp
@@ -39,7 +39,7 @@ class AcousticSolver
   computeRhoCj(const CellValue<const double>& rhoj,
                const CellValue<const double>& cj)
   {
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j) {
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j) {
         m_rhocj[j] = rhoj[j]*cj[j];
       });
     return m_rhocj;
@@ -51,7 +51,7 @@ class AcousticSolver
                   const NodeValuePerCell<const double>& ljr,
                   const NodeValuePerCell<const Rd>& njr)
   {
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j) {
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j) {
         const size_t& nb_nodes =m_Ajr.numberOfSubValues(j);
         const double& rho_c = rhocj[j];
         for (size_t r=0; r<nb_nodes; ++r) {
@@ -68,7 +68,7 @@ class AcousticSolver
     const auto& node_local_numbers_in_their_cells
         = m_connectivity.nodeLocalNumbersInTheirCells();
 
-    Kokkos::parallel_for(m_mesh.numberOfNodes(), KOKKOS_LAMBDA(const NodeId& r) {
+    Kokkos::parallel_for(m_mesh.numberOfNodes(), PASTIS_LAMBDA(const NodeId& r) {
         Rdd sum = zero;
         const auto& node_to_cell = node_to_cell_matrix[r];
         const auto& node_local_number_in_its_cells
@@ -96,7 +96,7 @@ class AcousticSolver
     const auto& node_local_numbers_in_their_cells
         = m_connectivity.nodeLocalNumbersInTheirCells();
 
-    Kokkos::parallel_for(m_mesh.numberOfNodes(), KOKKOS_LAMBDA(const NodeId& r) {
+    Kokkos::parallel_for(m_mesh.numberOfNodes(), PASTIS_LAMBDA(const NodeId& r) {
         Rd& br = m_br[r];
         br = zero;
         const auto& node_to_cell = node_to_cell_matrix[r];
@@ -144,7 +144,7 @@ class AcousticSolver
 
           const Array<const NodeId>& node_list
               = symmetry_bc.nodeList();
-          Kokkos::parallel_for(symmetry_bc.numberOfNodes(), KOKKOS_LAMBDA(const int& r_number) {
+          Kokkos::parallel_for(symmetry_bc.numberOfNodes(), PASTIS_LAMBDA(const int& r_number) {
               const NodeId r = node_list[r_number];
 
               m_Ar[r] = P*m_Ar[r]*P + nxn;
@@ -162,7 +162,7 @@ class AcousticSolver
   {
     inverse(Ar, m_inv_Ar);
     const NodeValue<const Rdd> invAr = m_inv_Ar;
-    Kokkos::parallel_for(m_mesh.numberOfNodes(), KOKKOS_LAMBDA(const NodeId& r) {
+    Kokkos::parallel_for(m_mesh.numberOfNodes(), PASTIS_LAMBDA(const NodeId& r) {
         m_ur[r]=invAr[r]*br[r];
       });
 
@@ -179,7 +179,7 @@ class AcousticSolver
     const auto& cell_to_node_matrix
         = m_mesh.connectivity().cellToNodeMatrix();
 
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j) {
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j) {
         const auto& cell_nodes = cell_to_node_matrix[j];
 
         for (size_t r=0; r<cell_nodes.size(); ++r) {
@@ -191,7 +191,7 @@ class AcousticSolver
   void inverse(const NodeValue<const Rdd>& A,
                NodeValue<Rdd>& inv_A) const
   {
-    Kokkos::parallel_for(m_mesh.numberOfNodes(), KOKKOS_LAMBDA(const NodeId& r) {
+    Kokkos::parallel_for(m_mesh.numberOfNodes(), PASTIS_LAMBDA(const NodeId& r) {
         inv_A[r] = ::inverse(A[r]);
       });
   }
@@ -258,7 +258,7 @@ class AcousticSolver
     const auto& cell_to_node_matrix
         = m_mesh.connectivity().cellToNodeMatrix();
 
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
         const auto& cell_nodes = cell_to_node_matrix[j];
 
         double S = 0;
@@ -297,7 +297,7 @@ class AcousticSolver
         = m_mesh.connectivity().cellToNodeMatrix();
 
     const CellValue<const double> inv_mj = unknowns.invMj();
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j) {
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j) {
         const auto& cell_nodes = cell_to_node_matrix[j];
 
         Rd momentum_fluxes = zero;
@@ -311,18 +311,18 @@ class AcousticSolver
         Ej[j] -= (dt*inv_mj[j]) * energy_fluxes;
       });
 
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j) {
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j) {
         ej[j] = Ej[j] - 0.5 * (uj[j],uj[j]);
       });
 
     NodeValue<Rd> mutable_xr = m_mesh.mutableXr();
-    Kokkos::parallel_for(m_mesh.numberOfNodes(), KOKKOS_LAMBDA(const NodeId& r){
+    Kokkos::parallel_for(m_mesh.numberOfNodes(), PASTIS_LAMBDA(const NodeId& r){
         mutable_xr[r] += dt*ur[r];
       });
     m_mesh_data.updateAllData();
 
     const CellValue<const double> mj = unknowns.mj();
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
         rhoj[j] = mj[j]/Vj[j];
       });
   }
diff --git a/src/scheme/BlockPerfectGas.hpp b/src/scheme/BlockPerfectGas.hpp
index 704787756..13dbfd816 100644
--- a/src/scheme/BlockPerfectGas.hpp
+++ b/src/scheme/BlockPerfectGas.hpp
@@ -34,7 +34,7 @@ public:
     const CellValue<const double>& e = m_ej;
     const CellValue<const double>& gamma = m_gammaj;
 
-    Kokkos::parallel_for(nj, KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(nj, PASTIS_LAMBDA(const CellId& j){
         const double gamma_minus_one = gamma[j]-1;
         m_pj[j] = gamma_minus_one*rho[j]*e[j];
         m_cj[j] = std::sqrt(gamma[j]*gamma_minus_one*e[j]);
@@ -48,12 +48,12 @@ public:
     const CellValue<const double>& p = m_pj;
     const CellValue<const double>& gamma = m_gammaj;
 
-    Kokkos::parallel_for(nj, KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(nj, PASTIS_LAMBDA(const CellId& j){
         m_ej[j] = p[j]/(rho[j]*(gamma[j]-1));
       });
 
     const CellValue<const double>& e = m_ej;
-    Kokkos::parallel_for(nj, KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(nj, PASTIS_LAMBDA(const CellId& j){
         m_cj[j] = std::sqrt(gamma[j]*(gamma[j]-1)*e[j]);
       });
   }
diff --git a/src/scheme/BoundaryCondition.hpp b/src/scheme/BoundaryCondition.hpp
index 2a9ac539b..ed73e14bc 100644
--- a/src/scheme/BoundaryCondition.hpp
+++ b/src/scheme/BoundaryCondition.hpp
@@ -69,7 +69,7 @@ public:
       m_number_of_faces(faces.size())
   {
     Array<unsigned int> face_list(faces.size());
-    Kokkos::parallel_for(m_number_of_faces, KOKKOS_LAMBDA(const int& f){
+    Kokkos::parallel_for(m_number_of_faces, PASTIS_LAMBDA(const int& f){
         face_list[f]=faces[f];
       });
     m_face_list = face_list;
diff --git a/src/scheme/FiniteVolumesEulerUnknowns.hpp b/src/scheme/FiniteVolumesEulerUnknowns.hpp
index 2eaaf474d..fc1178b77 100644
--- a/src/scheme/FiniteVolumesEulerUnknowns.hpp
+++ b/src/scheme/FiniteVolumesEulerUnknowns.hpp
@@ -124,7 +124,7 @@ public:
   {
     const CellValue<const Rd>& xj = m_mesh_data.xj();
 
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
         if (xj[j][0]<0.5) {
           m_rhoj[j]=1;
         } else {
@@ -132,7 +132,7 @@ public:
         }
       });
 
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
         if (xj[j][0]<0.5) {
           m_pj[j]=1;
         } else {
@@ -140,27 +140,27 @@ public:
         }
       });
 
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
         m_uj[j] = zero;
       });
 
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
         m_gammaj[j] = 1.4;
       });
 
     BlockPerfectGas block_eos(m_rhoj, m_ej, m_pj, m_gammaj, m_cj);
     block_eos.updateEandCFromRhoP();
 
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
         m_Ej[j] = m_ej[j]+0.5*(m_uj[j],m_uj[j]);
       });
 
     const CellValue<const double>& Vj = m_mesh_data.Vj();
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
         m_mj[j] = m_rhoj[j] * Vj[j];
       });
 
-    Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const CellId& j){
+    Kokkos::parallel_for(m_mesh.numberOfCells(), PASTIS_LAMBDA(const CellId& j){
         m_inv_mj[j] = 1./m_mj[j];
       });
   }
diff --git a/src/utils/PastisMacros.hpp b/src/utils/PastisMacros.hpp
index 43bade922..59d2a5795 100644
--- a/src/utils/PastisMacros.hpp
+++ b/src/utils/PastisMacros.hpp
@@ -1,5 +1,5 @@
-#ifndef PASTIS_UTILS_HPP
-#define PASTIS_UTILS_HPP
+#ifndef PASTIS_MACROS_HPP
+#define PASTIS_MACROS_HPP
 
 #include <Kokkos_Macros.hpp>
 
@@ -8,4 +8,6 @@
 #define PASTIS_INLINE KOKKOS_INLINE_FUNCTION
 #define PASTIS_FORCEINLINE KOKKOS_FORCEINLINE_FUNCTION
 
-#endif // PASTIS_UTILS_HPP
+#define PASTIS_LAMBDA KOKKOS_LAMBDA
+
+#endif // PASTIS_MACROS_HPP
-- 
GitLab