diff --git a/src/algebra/TinyMatrix.hpp b/src/algebra/TinyMatrix.hpp index eda3b5f19c3f7950bda6acce50a3e39b7c9f2cec..8ef511660f1fbc3760ab82b63f3603c517634524 100644 --- a/src/algebra/TinyMatrix.hpp +++ b/src/algebra/TinyMatrix.hpp @@ -1,6 +1,7 @@ #ifndef TINY_MATRIX_HPP #define TINY_MATRIX_HPP +#include <PastisMacros.hpp> #include <PastisAssert.hpp> #include <Kokkos_Core.hpp> @@ -16,14 +17,14 @@ private: T m_values[N*N]; static_assert((N>0),"TinyMatrix size must be strictly positive"); - KOKKOS_FORCEINLINE_FUNCTION + PASTIS_FORCEINLINE constexpr size_t _index(const size_t& i, const size_t& j) const noexcept { return std::move(i*N+j); } template <typename... Args> - KOKKOS_FORCEINLINE_FUNCTION + PASTIS_FORCEINLINE constexpr void _unpackVariadicInput(const T& t, Args&&... args) noexcept { m_values[N*N-1-sizeof...(args)] = t; @@ -33,7 +34,7 @@ private: } public: - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix operator-() const { TinyMatrix opposed; @@ -43,14 +44,14 @@ public: return std::move(opposed); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr friend TinyMatrix operator*(const T& t, const TinyMatrix& A) { TinyMatrix B = A; return std::move(B *= t); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix& operator*=(const T& t) { for (size_t i=0; i<N*N; ++i) { @@ -59,7 +60,7 @@ public: return *this; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix operator*(const TinyMatrix& B) const { const TinyMatrix& A = *this; @@ -76,7 +77,7 @@ public: return std::move(AB); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector<N,T> operator*(const TinyVector<N,T>& x) const { const TinyMatrix& A = *this; @@ -91,7 +92,7 @@ public: return std::move(Ax); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr friend std::ostream& operator<<(std::ostream& os, const TinyMatrix& A) { if constexpr(N==1) { @@ -111,7 +112,7 @@ public: return os; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr bool operator==(const TinyMatrix& A) const { for (size_t i=0; i<N*N; ++i) { @@ -120,13 +121,13 @@ public: return true; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr bool operator!=(const TinyMatrix& A) const { return not this->operator==(A); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix operator+(const TinyMatrix& A) const { TinyMatrix sum; @@ -136,7 +137,7 @@ public: return std::move(sum); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix operator+(TinyMatrix&& A) const { for (size_t i=0; i<N*N; ++i) { @@ -145,7 +146,7 @@ public: return std::move(A); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix operator-(const TinyMatrix& A) const { TinyMatrix difference; @@ -155,7 +156,7 @@ public: return std::move(difference); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix operator-(TinyMatrix&& A) const { for (size_t i=0; i<N*N; ++i) { @@ -164,7 +165,7 @@ public: return std::move(A); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix& operator+=(const TinyMatrix& A) { for (size_t i=0; i<N*N; ++i) { @@ -173,7 +174,7 @@ public: return *this; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix& operator-=(const TinyMatrix& A) { for (size_t i=0; i<N*N; ++i) { @@ -182,21 +183,21 @@ public: return *this; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr T& operator()(const size_t& i, const size_t& j) noexcept(NO_ASSERT) { Assert((i<N) and (j<N)); return m_values[_index(i,j)]; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr const T& operator()(const size_t& i, const size_t& j) const noexcept(NO_ASSERT) { Assert((i<N) and (j<N)); return m_values[_index(i,j)]; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix& operator=(const ZeroType& z) noexcept { static_assert(std::is_arithmetic<T>(),"Cannot assign 'zero' value for non-arithmetic types"); @@ -206,7 +207,7 @@ public: return *this; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix& operator=(const IdentityType& I) noexcept { static_assert(std::is_arithmetic<T>(),"Cannot assign 'identity' value for non-arithmetic types"); @@ -218,7 +219,7 @@ public: return *this; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix& operator=(const TinyMatrix& A) noexcept { for (size_t i=0; i<N*N; ++i) { @@ -227,24 +228,24 @@ public: return *this; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix& operator=(TinyMatrix&& A) noexcept = default; template <typename... Args> - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix(const T& t, Args&&... args) noexcept { static_assert(sizeof...(args)==N*N-1, "wrong number of parameters"); this->_unpackVariadicInput(t, args...); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix() noexcept { ; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix(const ZeroType& z) noexcept { static_assert(std::is_arithmetic<T>(),"Cannot construct from 'zero' value for non-arithmetic types"); @@ -253,7 +254,7 @@ public: } } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix(const IdentityType& I) noexcept { static_assert(std::is_arithmetic<T>(),"Cannot construct from 'identity' value for non-arithmetic types"); @@ -264,7 +265,7 @@ public: } } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyMatrix(const TinyMatrix& A) noexcept { for (size_t i=0; i<N*N; ++i) { @@ -272,15 +273,15 @@ public: } } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE TinyMatrix(TinyMatrix&& A) noexcept = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ~TinyMatrix()=default; }; template <size_t N, typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr TinyMatrix<N,T> tensorProduct(const TinyVector<N,T>& x, const TinyVector<N,T>& y) { @@ -294,7 +295,7 @@ constexpr TinyMatrix<N,T> tensorProduct(const TinyVector<N,T>& x, } template <size_t N, typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr T det(const TinyMatrix<N,T>& A) { static_assert(std::is_arithmetic<T>::value, "determinent is not defined for non arithmetic types"); @@ -338,7 +339,7 @@ constexpr T det(const TinyMatrix<N,T>& A) } template <typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr T det(const TinyMatrix<1,T>& A) { static_assert(std::is_arithmetic<T>::value, "determinent is not defined for non arithmetic types"); @@ -346,7 +347,7 @@ constexpr T det(const TinyMatrix<1,T>& A) } template <typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr T det(const TinyMatrix<2,T>& A) { static_assert(std::is_arithmetic<T>::value, "determinent is not defined for non arithmetic types"); @@ -354,7 +355,7 @@ constexpr T det(const TinyMatrix<2,T>& A) } template <typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr T det(const TinyMatrix<3,T>& A) { static_assert(std::is_arithmetic<T>::value, "determinent is not defined for non arithmetic types"); @@ -365,7 +366,7 @@ constexpr T det(const TinyMatrix<3,T>& A) } template <size_t N, typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr TinyMatrix<N-1,T> getMinor(const TinyMatrix<N,T>& A, const size_t& I, const size_t& J) @@ -393,11 +394,11 @@ constexpr TinyMatrix<N-1,T> getMinor(const TinyMatrix<N,T>& A, } template <size_t N, typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr TinyMatrix<N,T> inverse(const TinyMatrix<N,T>& A); template <typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr TinyMatrix<1,T> inverse(const TinyMatrix<1,T>& A) { static_assert(std::is_arithmetic<T>::value, "inverse is not defined for non arithmetic types"); @@ -408,7 +409,7 @@ constexpr TinyMatrix<1,T> inverse(const TinyMatrix<1,T>& A) } template <size_t N, typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr T cofactor(const TinyMatrix<N,T>& A, const size_t& i, const size_t& j) @@ -420,7 +421,7 @@ constexpr T cofactor(const TinyMatrix<N,T>& A, } template <typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr TinyMatrix<2,T> inverse(const TinyMatrix<2,T>& A) { static_assert(std::is_arithmetic<T>::value, "inverse is not defined for non arithmetic types"); @@ -436,7 +437,7 @@ constexpr TinyMatrix<2,T> inverse(const TinyMatrix<2,T>& A) template <typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr TinyMatrix<3,T> inverse(const TinyMatrix<3,T>& A) { static_assert(std::is_arithmetic<T>::value, "inverse is not defined for non arithmetic types"); diff --git a/src/algebra/TinyVector.hpp b/src/algebra/TinyVector.hpp index c783bb7968696c120f96ef82014a5443639871d9..988d5f0ea45e68c840199c03c626ffc61f119e90 100644 --- a/src/algebra/TinyVector.hpp +++ b/src/algebra/TinyVector.hpp @@ -3,10 +3,13 @@ #include <iostream> +#include <PastisMacros.hpp> #include <PastisAssert.hpp> -#include <Kokkos_Core.hpp> + #include <Types.hpp> +#include <cmath> + template <size_t N, typename T=double> class TinyVector { @@ -15,7 +18,7 @@ class TinyVector static_assert((N>0),"TinyVector size must be strictly positive"); template <typename... Args> - KOKKOS_FORCEINLINE_FUNCTION + PASTIS_FORCEINLINE constexpr void _unpackVariadicInput(const T& t, Args&&... args) noexcept { m_values[N-1-sizeof...(args)] = t; @@ -25,7 +28,7 @@ class TinyVector } public: - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector operator-() const { TinyVector opposed; @@ -35,13 +38,13 @@ class TinyVector return std::move(opposed); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr size_t dimension() const { return N; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr bool operator==(const TinyVector& v) const { for (size_t i=0; i<N; ++i) { @@ -50,13 +53,13 @@ class TinyVector return true; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr bool operator!=(const TinyVector& v) const { return not this->operator==(v); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr T operator,(const TinyVector& v) const { T t = m_values[0]*v.m_values[0]; @@ -66,7 +69,7 @@ class TinyVector return std::move(t); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector& operator*=(const T& t) { for (size_t i=0; i<N; ++i) { @@ -75,21 +78,21 @@ class TinyVector return *this; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr friend TinyVector operator*(const T& t, const TinyVector& v) { TinyVector w = v; return std::move(w*=t); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr friend TinyVector operator*(const T& t, TinyVector&& v) { v *= t; return std::move(v); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr friend std::ostream& operator<<(std::ostream& os, const TinyVector& v) { os << '(' << v.m_values[0]; @@ -100,7 +103,7 @@ class TinyVector return os; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector operator+(const TinyVector& v) const { TinyVector sum; @@ -110,7 +113,7 @@ class TinyVector return std::move(sum); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector operator+(TinyVector&& v) const { for (size_t i=0; i<N; ++i) { @@ -119,7 +122,7 @@ class TinyVector return std::move(v); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector operator-(const TinyVector& v) const { TinyVector difference; @@ -129,7 +132,7 @@ class TinyVector return std::move(difference); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector operator-(TinyVector&& v) const { for (size_t i=0; i<N; ++i) { @@ -138,7 +141,7 @@ class TinyVector return std::move(v); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector& operator+=(const TinyVector& v) { for (size_t i=0; i<N; ++i) { @@ -147,7 +150,7 @@ class TinyVector return *this; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector& operator-=(const TinyVector& v) { for (size_t i=0; i<N; ++i) { @@ -156,21 +159,21 @@ class TinyVector return *this; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr T& operator[](const size_t& i) noexcept(NO_ASSERT) { Assert(i<N); return m_values[i]; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr const T& operator[](const size_t& i) const noexcept(NO_ASSERT) { Assert(i<N); return m_values[i]; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector& operator=(const ZeroType& z) noexcept { static_assert(std::is_arithmetic<T>(),"Cannot assign 'zero' value for non-arithmetic types"); @@ -180,7 +183,7 @@ class TinyVector return *this; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const TinyVector& operator=(const TinyVector& v) noexcept { for (size_t i=0; i<N; ++i) { @@ -189,24 +192,24 @@ class TinyVector return *this; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector& operator=(TinyVector&& v) noexcept = default; template <typename... Args> - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector(const T& t, Args&&... args) noexcept { static_assert(sizeof...(args)==N-1, "wrong number of parameters"); this->_unpackVariadicInput(t, args...); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector() noexcept { ; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector(const ZeroType& z) noexcept { static_assert(std::is_arithmetic<T>(),"Cannot construct from 'zero' value for non-arithmetic types"); @@ -215,7 +218,7 @@ class TinyVector } } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector(const TinyVector& v) noexcept { for (size_t i=0; i<N; ++i) { @@ -223,15 +226,15 @@ class TinyVector } } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE constexpr TinyVector(TinyVector&& v) noexcept = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ~TinyVector() noexcept = default; }; template <size_t N, typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr T l2Norm(const TinyVector<N,T>& x) { static_assert(std::is_arithmetic<T>(),"Cannot compute L2 norm for non-arithmetic types"); @@ -241,7 +244,7 @@ constexpr T l2Norm(const TinyVector<N,T>& x) // Cross product is only defined for K^3 vectors template <typename T> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE constexpr TinyVector<3,T> crossProduct(const TinyVector<3,T>& u, const TinyVector<3,T>& v) { TinyVector<3,T> cross_product(u[1]*v[2]-u[2]*v[1], diff --git a/src/mesh/Connectivity.hpp b/src/mesh/Connectivity.hpp index cfcb7f67909e2c7668bb11d842eb5437e57734c2..4c83d4adc02cc241d328eb8b22f06c6c66a1ef1f 100644 --- a/src/mesh/Connectivity.hpp +++ b/src/mesh/Connectivity.hpp @@ -1,6 +1,7 @@ #ifndef CONNECTIVITY_HPP #define CONNECTIVITY_HPP +#include <PastisMacros.hpp> #include <PastisAssert.hpp> #include <TinyVector.hpp> @@ -70,14 +71,14 @@ class ConnectivityFace<2> return os; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE bool operator==(const ConnectivityFace& f) const { return ((m_node0_id == f.m_node0_id) and (m_node1_id == f.m_node1_id)); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE bool operator<(const ConnectivityFace& f) const { return ((m_node0_id<f.m_node0_id) or @@ -85,13 +86,13 @@ class ConnectivityFace<2> (m_node1_id<f.m_node1_id))); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ConnectivityFace& operator=(const ConnectivityFace&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ConnectivityFace& operator=(ConnectivityFace&&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ConnectivityFace(const std::vector<unsigned int>& given_node_id_list) { Assert(given_node_id_list.size()==2); @@ -101,13 +102,13 @@ class ConnectivityFace<2> m_node1_id = max; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ConnectivityFace(const ConnectivityFace&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ConnectivityFace(ConnectivityFace&&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ~ConnectivityFace() = default; }; @@ -139,19 +140,19 @@ class ConnectivityFace<3> return os; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const bool& reversed() const { return m_reversed; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const std::vector<unsigned int>& nodeIdList() const { return m_node_id_list; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE std::vector<unsigned int> _sort(const std::vector<unsigned int>& node_list) { const auto min_id = std::min_element(node_list.begin(), node_list.end()); @@ -172,7 +173,7 @@ class ConnectivityFace<3> return rotated_node_list; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ConnectivityFace(const std::vector<unsigned int>& given_node_id_list) : m_reversed(false), m_node_id_list(_sort(given_node_id_list)) @@ -194,7 +195,7 @@ class ConnectivityFace<3> return false; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE bool operator<(const ConnectivityFace& f) const { const size_t min_nb_nodes = std::min(f.m_node_id_list.size(), m_node_id_list.size()); @@ -205,23 +206,23 @@ class ConnectivityFace<3> return m_node_id_list.size() < f.m_node_id_list.size(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ConnectivityFace& operator=(const ConnectivityFace&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ConnectivityFace& operator=(ConnectivityFace&&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ConnectivityFace(const ConnectivityFace&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ConnectivityFace(ConnectivityFace&&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ConnectivityFace() = delete; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ~ConnectivityFace() = default; }; @@ -272,7 +273,7 @@ class Connectivity final void _computeCellFaceAndFaceNodeConnectivities(); template <typename SubItemValuePerItemType> - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const SubItemValuePerItemType& _lazzyBuildItemNumberInTheirChild(const SubItemValuePerItemType& sub_item_value_per_item) const { @@ -287,7 +288,7 @@ class Connectivity final friend class ConnectivityComputer; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const ConnectivityMatrix& _getMatrix(const ItemType& item_type_0, const ItemType& item_type_1) const { @@ -304,7 +305,7 @@ class Connectivity final public: - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const bool& isConnectivityMatrixBuilt(const ItemType& item_type_0, const ItemType& item_type_1) const { @@ -314,7 +315,7 @@ class Connectivity final } template <ItemType source_item_type, ItemType target_item_type> - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto getItemToItemMatrix() const { return ItemToItemMatrix<source_item_type, @@ -322,93 +323,93 @@ class Connectivity final target_item_type)); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto cellToFaceMatrix() const { return this->template getItemToItemMatrix<ItemType::cell, ItemType::face>(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto cellToEdgeMatrix() const { return this->template getItemToItemMatrix<ItemType::cell, ItemType::edge>(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto cellToNodeMatrix() const { return this->template getItemToItemMatrix<ItemType::cell, ItemType::node>(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto faceToCellMatrix() const { return this->template getItemToItemMatrix<ItemType::face, ItemType::cell>(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto faceToEdgeMatrix() const { return this->template getItemToItemMatrix<ItemType::face, ItemType::edge>(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto faceToNodeMatrix() const { return this->template getItemToItemMatrix<ItemType::face, ItemType::node>(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto edgeToCellMatrix() const { return this->template getItemToItemMatrix<ItemType::edge, ItemType::cell>(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto edgeToFaceMatrix() const { return this->template getItemToItemMatrix<ItemType::edge, ItemType::face>(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto edgeToNodeMatrix() const { return this->template getItemToItemMatrix<ItemType::edge, ItemType::node>(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto nodeToCellMatrix() const { return this->template getItemToItemMatrix<ItemType::node, ItemType::cell>(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto nodeToFaceMatrix() const { return this->template getItemToItemMatrix<ItemType::node, ItemType::face>(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto nodeToEdgeMatrix() const { return this->template getItemToItemMatrix<ItemType::node, ItemType::edge>(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& cellFaceIsReversed() const { static_assert(dimension>1, "reversed faces makes no sense in dimension 1"); return m_cell_face_is_reversed; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& cellLocalNumbersInTheirNodes() const { return _lazzyBuildItemNumberInTheirChild(m_cell_local_numbers_in_their_nodes); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& cellLocalNumbersInTheirEdges() const { if constexpr (dimension>2) { @@ -418,7 +419,7 @@ class Connectivity final } } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& cellLocalNumbersInTheirFaces() const { if constexpr (dimension>1) { @@ -428,7 +429,7 @@ class Connectivity final } } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& faceLocalNumbersInTheirCells() const { if constexpr(dimension>1) { @@ -438,21 +439,21 @@ class Connectivity final } } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& faceLocalNumbersInTheirEdges() const { static_assert(dimension>2,"this function has no meaning in 1d or 2d"); return _lazzyBuildItemNumberInTheirChild(m_face_local_numbers_in_their_edges); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& faceLocalNumbersInTheirNodes() const { static_assert(dimension>1,"this function has no meaning in 1d"); return _lazzyBuildItemNumberInTheirChild(m_face_local_numbers_in_their_nodes); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& edgeLocalNumbersInTheirCells() const { if constexpr (dimension>2) { @@ -462,34 +463,34 @@ class Connectivity final } } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& edgeLocalNumbersInTheirFaces() const { static_assert(dimension>2, "this function has no meaning in 1d or 2d"); return _lazzyBuildItemNumberInTheirChild(m_edge_local_numbers_in_their_faces); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& edgeLocalNumbersInTheirNodes() const { static_assert(dimension>2, "this function has no meaning in 1d or 2d"); return _lazzyBuildItemNumberInTheirChild(m_edge_local_numbers_in_their_nodes); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& nodeLocalNumbersInTheirCells() const { return _lazzyBuildItemNumberInTheirChild(m_node_local_numbers_in_their_cells); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& nodeLocalNumbersInTheirEdges() const { static_assert(dimension>2, "this function has no meaning in 1d or 2d"); return _lazzyBuildItemNumberInTheirChild(m_node_local_numbers_in_their_edges); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto& nodeLocalNumbersInTheirFaces() const { static_assert(dimension>1,"this function has no meaning in 1d"); @@ -526,7 +527,7 @@ class Connectivity final return m_ref_node_list[i]; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t numberOfNodes() const final { const auto& node_to_cell_matrix @@ -534,7 +535,7 @@ class Connectivity final return node_to_cell_matrix.numRows(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t numberOfEdges() const final { const auto& edge_to_node_matrix @@ -542,7 +543,7 @@ class Connectivity final return edge_to_node_matrix.numRows(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t numberOfFaces() const final { const auto& face_to_node_matrix @@ -550,7 +551,7 @@ class Connectivity final return face_to_node_matrix.numRows(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t numberOfCells() const final { const auto& cell_to_node_matrix diff --git a/src/mesh/ConnectivityComputer.cpp b/src/mesh/ConnectivityComputer.cpp index aa6f5c56ae612133afc3040d84fd6fe3c807b507..8c087e3baf65cec60ae10c5a130e51748dfe19e5 100644 --- a/src/mesh/ConnectivityComputer.cpp +++ b/src/mesh/ConnectivityComputer.cpp @@ -5,7 +5,7 @@ template <typename ConnectivityType> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE ConnectivityMatrix ConnectivityComputer:: computeConnectivityMatrix(const ConnectivityType& connectivity, const ItemType& item_type, diff --git a/src/mesh/ConnectivityMatrix.hpp b/src/mesh/ConnectivityMatrix.hpp index 4387070d0bc9ffc91e88f16c160b87a65e176925..b8fa1e009a6f5f32a00c2e4defdc742b9872b899 100644 --- a/src/mesh/ConnectivityMatrix.hpp +++ b/src/mesh/ConnectivityMatrix.hpp @@ -30,31 +30,31 @@ class ConnectivityMatrix return m_host_matrix.row_map; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto numEntries() const { return m_host_matrix.entries.extent(0); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto numRows() const { return m_host_matrix.numRows(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto rowConst(const size_t& j) const { return m_host_matrix.rowConst(j); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto rowMap(const size_t& j) const { return m_host_matrix.row_map[j]; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ConnectivityMatrix(const std::vector<std::vector<unsigned int>>& initializer) : m_host_matrix{Kokkos::create_staticcrsgraph<HostMatrix>("connectivity_matrix", initializer)}, m_is_built{true} diff --git a/src/mesh/GmshReader.cpp b/src/mesh/GmshReader.cpp index ea003eb9b6c41d7f049c648ab62b01a01b0add26..f187da556f28f8e4d0661077f6e397d8ce11b8f7 100644 --- a/src/mesh/GmshReader.cpp +++ b/src/mesh/GmshReader.cpp @@ -1,4 +1,5 @@ #include <GmshReader.hpp> +#include <PastisMacros.hpp> #include <iostream> #include <fstream> @@ -17,7 +18,8 @@ #include <iomanip> template<typename T> -inline std::string stringify(const T & t) +PASTIS_INLINE +std::string stringify(const T & t) { std::ostringstream oss; oss << t; @@ -25,7 +27,8 @@ inline std::string stringify(const T & t) } template<> -inline std::string stringify<std::string>(const std::string& t) +PASTIS_INLINE +std::string stringify<std::string>(const std::string& t) { return t; } diff --git a/src/mesh/IConnectivity.hpp b/src/mesh/IConnectivity.hpp index e27c2ef08bf13e7e9946c095da1cb628027e3a44..f60db961d80f939c64139f8746a674e4ce4de91e 100644 --- a/src/mesh/IConnectivity.hpp +++ b/src/mesh/IConnectivity.hpp @@ -33,28 +33,28 @@ class IConnectivity }; template <> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE size_t IConnectivity::numberOf<ItemType::node>() const { return this->numberOfNodes(); } template <> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE size_t IConnectivity::numberOf<ItemType::edge>() const { return this->numberOfEdges(); } template <> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE size_t IConnectivity::numberOf<ItemType::face>() const { return this->numberOfFaces(); } template <> -KOKKOS_INLINE_FUNCTION +PASTIS_INLINE size_t IConnectivity::numberOf<ItemType::cell>() const { return this->numberOfCells(); diff --git a/src/mesh/ItemToItemMatrix.hpp b/src/mesh/ItemToItemMatrix.hpp index 510c421fc9c1a67d0565d4b5e5e3e08c91c4ccd9..70240b8efa1a4b96739b1b6814778d2fdb65e84d 100644 --- a/src/mesh/ItemToItemMatrix.hpp +++ b/src/mesh/ItemToItemMatrix.hpp @@ -23,38 +23,38 @@ class ItemToItemMatrix public: - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t size() const { return m_row.length; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE TargetItemId operator[](const size_t& j) const { return m_row(j); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE SubItemList(const RowType& row) : m_row{row} { ; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE SubItemList& operator=(const SubItemList&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE SubItemList& operator=(SubItemList&&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE SubItemList(const SubItemList&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE SubItemList(SubItemList&&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ~SubItemList() = default; }; @@ -62,7 +62,7 @@ class ItemToItemMatrix const ConnectivityMatrix& m_connectivity_matrix; public: - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto operator[](const SourceItemId& source_id) const { using RowType = decltype(m_connectivity_matrix.rowConst(source_id)); @@ -70,7 +70,7 @@ class ItemToItemMatrix } template <typename IndexType> - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const auto operator[](const IndexType& source_id) const { static_assert(std::is_same<IndexType, SourceItemId>(), @@ -79,26 +79,26 @@ class ItemToItemMatrix return SubItemList<RowType>(m_connectivity_matrix.rowConst(source_id)); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ItemToItemMatrix(const ConnectivityMatrix& connectivity_matrix) : m_connectivity_matrix{connectivity_matrix} { ; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ItemToItemMatrix& operator=(const ItemToItemMatrix&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ItemToItemMatrix& operator=(ItemToItemMatrix&&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ItemToItemMatrix(ItemToItemMatrix&&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ItemToItemMatrix(const ItemToItemMatrix&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ~ItemToItemMatrix() = default; }; diff --git a/src/mesh/ItemType.hpp b/src/mesh/ItemType.hpp index 965f888b1b7315f28f5132b0457b86ca1e85b210..1b5f3cb452e898dc957ff7f96fb07c4955312f16 100644 --- a/src/mesh/ItemType.hpp +++ b/src/mesh/ItemType.hpp @@ -13,8 +13,8 @@ enum class ItemType cell = 3 }; -inline constexpr -std::string_view itemName(const ItemType& item_type) +PASTIS_INLINE +constexpr std::string_view itemName(const ItemType& item_type) { std::string_view name; switch(item_type){ @@ -44,7 +44,8 @@ struct ItemTypeId {}; template <> struct ItemTypeId<1> { - inline static constexpr size_t itemTId(const ItemType& item_type) { + PASTIS_INLINE + static constexpr size_t itemTId(const ItemType& item_type) { size_t i = std::numeric_limits<size_t>::max(); switch(item_type) { case ItemType::cell: { @@ -66,7 +67,8 @@ struct ItemTypeId<1> template <> struct ItemTypeId<2> { - inline static constexpr size_t itemTId(const ItemType& item_type) { + PASTIS_INLINE + static constexpr size_t itemTId(const ItemType& item_type) { size_t i = std::numeric_limits<size_t>::max(); switch(item_type) { case ItemType::cell: { @@ -91,7 +93,8 @@ struct ItemTypeId<2> template <> struct ItemTypeId<3> { - inline static constexpr size_t itemTId(const ItemType& item_type) { + PASTIS_INLINE + static constexpr size_t itemTId(const ItemType& item_type) { size_t i = std::numeric_limits<size_t>::max(); switch(item_type) { case ItemType::cell: { diff --git a/src/mesh/ItemValue.hpp b/src/mesh/ItemValue.hpp index 77eb1cb37d9998fb1af6e4a27d05ff7fcdb60077..754f66ac7e450af35cf5d89e6c22b4f040c4a661 100644 --- a/src/mesh/ItemValue.hpp +++ b/src/mesh/ItemValue.hpp @@ -31,13 +31,13 @@ class ItemValue item_type>; public: - KOKKOS_FORCEINLINE_FUNCTION + PASTIS_FORCEINLINE const bool& isBuilt() const { return m_is_built; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t size() const { Assert(m_is_built); @@ -46,7 +46,7 @@ class ItemValue // Following Kokkos logic, these classes are view and const view does allow // changes in data - KOKKOS_FORCEINLINE_FUNCTION + PASTIS_FORCEINLINE DataType& operator[](const ItemId& i) const { Assert(m_is_built); @@ -61,7 +61,7 @@ class ItemValue return m_values[i]; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t numberOfItems() const { Assert(m_is_built); @@ -69,7 +69,7 @@ class ItemValue } template <typename DataType2> - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ItemValue& operator=(const ItemValue<DataType2, item_type>& value_per_item) { @@ -88,7 +88,7 @@ class ItemValue } template <typename DataType2> - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ItemValue(const ItemValue<DataType2, item_type>& value_per_item) { this->operator=(value_per_item); diff --git a/src/mesh/Mesh.hpp b/src/mesh/Mesh.hpp index 0188d507cb2d463b899e3e318b5a75a002b152e4..c21910e7a5bb24f08ec1106db08793912ee0bc7b 100644 --- a/src/mesh/Mesh.hpp +++ b/src/mesh/Mesh.hpp @@ -27,50 +27,50 @@ private: NodeValue<Rd> m_mutable_xr; public: - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const size_t meshDimension() const { return dimension; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const Connectivity& connectivity() const { return *m_connectivity; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t numberOfNodes() const { return m_connectivity->numberOfNodes(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t numberOfFaces() const { return m_connectivity->numberOfFaces(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t numberOfCells() const { return m_connectivity->numberOfCells(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const NodeValue<const Rd>& xr() const { return m_xr; } [[deprecated("should rework this class: quite ugly")]] - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE NodeValue<Rd> mutableXr() const { return m_mutable_xr; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE Mesh(const std::shared_ptr<Connectivity>& connectivity, NodeValue<Rd>& xr) : m_connectivity{connectivity}, diff --git a/src/mesh/MeshData.hpp b/src/mesh/MeshData.hpp index 1a07f1bcc0e477a0141e0ab7d4f7065aad633336..4e177f527e0758184d586e6d48000de89bf65f6e 100644 --- a/src/mesh/MeshData.hpp +++ b/src/mesh/MeshData.hpp @@ -30,7 +30,7 @@ class MeshData CellValue<const Rd> m_xj; CellValue<const double> m_Vj; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE void _updateCenter() { // Computes vertices isobarycenter if constexpr (dimension == 1) { @@ -66,7 +66,7 @@ class MeshData } } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE void _updateVolume() { const NodeValue<const Rd>& xr = m_mesh.xr(); @@ -86,7 +86,7 @@ class MeshData m_Vj = Vj; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE void _updateCjr() { if constexpr (dimension == 1) { // Cjr/njr/ljr are constant overtime diff --git a/src/mesh/MeshNodeBoundary.hpp b/src/mesh/MeshNodeBoundary.hpp index 0a4b9ec63ff74b71e25342144871c34e3236c163..9b8bc4e00c5c6abeae4a07be8fad5f08b093666a 100644 --- a/src/mesh/MeshNodeBoundary.hpp +++ b/src/mesh/MeshNodeBoundary.hpp @@ -96,16 +96,19 @@ class MeshFlatNodeBoundary const Rd m_outgoing_normal; template <typename MeshType> - inline Rd _getNormal(const MeshType& mesh); + PASTIS_INLINE + Rd _getNormal(const MeshType& mesh); template <typename MeshType> - inline void _checkBoundaryIsFlat(const TinyVector<2,double>& normal, - const TinyVector<2,double>& xmin, - const TinyVector<2,double>& xmax, - const MeshType& mesh) const; + PASTIS_INLINE + void _checkBoundaryIsFlat(const TinyVector<2,double>& normal, + const TinyVector<2,double>& xmin, + const TinyVector<2,double>& xmax, + const MeshType& mesh) const; template <typename MeshType> - inline Rd _getOutgoingNormal(const MeshType& mesh); + PASTIS_INLINE + Rd _getOutgoingNormal(const MeshType& mesh); public: const Rd& outgoingNormal() const { @@ -166,7 +169,8 @@ _checkBoundaryIsFlat(const TinyVector<2,double>& normal, template <> template <typename MeshType> -inline TinyVector<1,double> +PASTIS_INLINE +TinyVector<1,double> MeshFlatNodeBoundary<1>:: _getNormal(const MeshType& mesh) { @@ -183,7 +187,8 @@ _getNormal(const MeshType& mesh) template <> template <typename MeshType> -inline TinyVector<2,double> +PASTIS_INLINE +TinyVector<2,double> MeshFlatNodeBoundary<2>:: _getNormal(const MeshType& mesh) { @@ -225,7 +230,8 @@ _getNormal(const MeshType& mesh) template <> template <typename MeshType> -inline TinyVector<3,double> +PASTIS_INLINE +TinyVector<3,double> MeshFlatNodeBoundary<3>:: _getNormal(const MeshType& mesh) { @@ -309,7 +315,8 @@ _getNormal(const MeshType& mesh) template <> template <typename MeshType> -inline TinyVector<1,double> +PASTIS_INLINE +TinyVector<1,double> MeshFlatNodeBoundary<1>:: _getOutgoingNormal(const MeshType& mesh) { @@ -344,7 +351,8 @@ _getOutgoingNormal(const MeshType& mesh) template <> template <typename MeshType> -inline TinyVector<2,double> +PASTIS_INLINE +TinyVector<2,double> MeshFlatNodeBoundary<2>:: _getOutgoingNormal(const MeshType& mesh) { @@ -379,7 +387,8 @@ _getOutgoingNormal(const MeshType& mesh) template <> template <typename MeshType> -inline TinyVector<3,double> +PASTIS_INLINE +TinyVector<3,double> MeshFlatNodeBoundary<3>:: _getOutgoingNormal(const MeshType& mesh) { diff --git a/src/mesh/SubItemValuePerItem.hpp b/src/mesh/SubItemValuePerItem.hpp index 3853038a1822ccd5bc6e4eb6d5c2d2696c8876ba..afe1ee4fa99277a199cafeee9aceac935dee4400 100644 --- a/src/mesh/SubItemValuePerItem.hpp +++ b/src/mesh/SubItemValuePerItem.hpp @@ -53,25 +53,25 @@ class SubItemValuePerItem<DataType, using data_type = DataType; private: - KOKKOS_RESTRICT DataType* const m_sub_values; + PASTIS_RESTRICT DataType* const m_sub_values; const size_t m_size; public: - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const DataType& operator[](const size_t& i) const { Assert(i<m_size); return m_sub_values[i]; } - KOKKOS_FORCEINLINE_FUNCTION + PASTIS_FORCEINLINE DataType& operator[](const size_t& i) { Assert(i<m_size); return m_sub_values[i]; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const size_t& size() const { return m_size; @@ -79,10 +79,10 @@ class SubItemValuePerItem<DataType, SubView(const SubView&) = delete; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE SubView(SubView&&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE SubView(const Array<DataType>& values, const size_t& begin, const size_t& end) @@ -94,7 +94,7 @@ class SubItemValuePerItem<DataType, } }; - KOKKOS_FORCEINLINE_FUNCTION + PASTIS_FORCEINLINE const bool& isBuilt() const { return m_is_built; @@ -102,7 +102,7 @@ class SubItemValuePerItem<DataType, // Following Kokkos logic, these classes are view and const view does allow // changes in data - KOKKOS_FORCEINLINE_FUNCTION + PASTIS_FORCEINLINE DataType& operator()(const ItemId& j, const size_t& r) const { Assert(m_is_built); @@ -110,7 +110,7 @@ class SubItemValuePerItem<DataType, } template <typename IndexType> - KOKKOS_FORCEINLINE_FUNCTION + PASTIS_FORCEINLINE DataType& operator()(const IndexType& j, const size_t& r) const { static_assert(std::is_same<IndexType, size_t>(), @@ -118,7 +118,7 @@ class SubItemValuePerItem<DataType, return m_values[m_host_row_map(size_t{j})+r]; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t numberOfValues() const { Assert(m_is_built); @@ -127,7 +127,7 @@ class SubItemValuePerItem<DataType, // Following Kokkos logic, these classes are view and const view does allow // changes in data - KOKKOS_FORCEINLINE_FUNCTION + PASTIS_FORCEINLINE DataType& operator[](const size_t& i) const { Assert(m_is_built); @@ -142,7 +142,7 @@ class SubItemValuePerItem<DataType, return m_values[i]; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t numberOfItems() const { Assert(m_is_built); @@ -150,14 +150,14 @@ class SubItemValuePerItem<DataType, return m_host_row_map.extent(0); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t numberOfSubValues(const size_t& i_cell) const { Assert(m_is_built); return m_host_row_map(i_cell+1)-m_host_row_map(i_cell); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE SubView itemValues(const size_t& i_cell) { Assert(m_is_built); @@ -168,7 +168,7 @@ class SubItemValuePerItem<DataType, // Following Kokkos logic, these classes are view and const view does allow // changes in data - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE SubView itemValues(const size_t& i_cell) const { Assert(m_is_built); @@ -178,7 +178,7 @@ class SubItemValuePerItem<DataType, } template <typename DataType2> - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE SubItemValuePerItem& operator=(const SubItemValuePerItem<DataType2, sub_item_type, item_type>& sub_item_value_per_item) { @@ -198,7 +198,7 @@ class SubItemValuePerItem<DataType, } template <typename DataType2> - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE SubItemValuePerItem(const SubItemValuePerItem<DataType2, sub_item_type, item_type>& sub_item_value_per_item) { this->operator=(sub_item_value_per_item); diff --git a/src/scheme/AcousticSolver.hpp b/src/scheme/AcousticSolver.hpp index 375828f41a86eef02f1d7fe87e48bb6ff4388223..0db6f75ec44c12e77a0199a9cdad6f0e735839d2 100644 --- a/src/scheme/AcousticSolver.hpp +++ b/src/scheme/AcousticSolver.hpp @@ -34,7 +34,7 @@ class AcousticSolver using Rdd = TinyMatrix<dimension>; private: - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const CellValue<const double> computeRhoCj(const CellValue<const double>& rhoj, const CellValue<const double>& cj) @@ -45,7 +45,7 @@ class AcousticSolver return m_rhocj; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE void computeAjr(const CellValue<const double>& rhocj, const NodeValuePerCell<const Rd>& Cjr, const NodeValuePerCell<const double>& ljr, @@ -60,7 +60,7 @@ class AcousticSolver }); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const NodeValue<const Rdd> computeAr(const NodeValuePerCell<const Rdd>& Ajr) { const auto& node_to_cell_matrix @@ -85,7 +85,7 @@ class AcousticSolver return m_Ar; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE const NodeValue<const Rd> computeBr(const NodeValuePerCell<Rdd>& Ajr, const NodeValuePerCell<const Rd>& Cjr, @@ -196,7 +196,7 @@ class AcousticSolver }); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE void computeExplicitFluxes(const NodeValue<const Rd>& xr, const CellValue<const Rd>& xj, const CellValue<const double>& rhoj, @@ -250,7 +250,7 @@ class AcousticSolver ; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE double acoustic_dt(const CellValue<const double>& Vj, const CellValue<const double>& cj) const { diff --git a/src/scheme/BoundaryCondition.hpp b/src/scheme/BoundaryCondition.hpp index 8747cb0c5cff48ca787e4186638cb03902966ca7..2a9ac539b9d61b8238b0c06ffa48df1e55ec79bd 100644 --- a/src/scheme/BoundaryCondition.hpp +++ b/src/scheme/BoundaryCondition.hpp @@ -125,16 +125,16 @@ public: return *m_boundary_condition; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE BoundaryConditionHandler& operator=(BoundaryConditionHandler&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE BoundaryConditionHandler(const BoundaryConditionHandler&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE BoundaryConditionHandler(BoundaryConditionHandler&&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE BoundaryConditionHandler(std::shared_ptr<BoundaryCondition> boundary_condition) : m_boundary_condition(boundary_condition) { diff --git a/src/utils/Array.hpp b/src/utils/Array.hpp index e72efb042c5c9006960a15dfd20c87ed29c29d82..bfcb6231dca981bf2a10898fecce79343d5a0167 100644 --- a/src/utils/Array.hpp +++ b/src/utils/Array.hpp @@ -1,9 +1,11 @@ #ifndef ARRAY_HPP #define ARRAY_HPP -#include <PastisAssert.hpp> +#include <PastisMacros.hpp> #include <Kokkos_Core.hpp> +#include <PastisAssert.hpp> + template <typename DataType> class Array { @@ -18,20 +20,20 @@ class Array friend Array<std::add_const_t<DataType>>; public: - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE size_t size() const { return m_values.extent(0); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE DataType& operator[](const index_type& i) const { Assert(i<m_values.extent(0)); return m_values[i]; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE Array(const size_t& size) : m_values("anonymous", size) { @@ -40,7 +42,7 @@ class Array } template <typename DataType2> - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE Array& operator=(const Array<DataType2>& array) { // ensures that DataType is the same as source DataType2 @@ -54,29 +56,29 @@ class Array return *this; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE Array& operator=(const Array&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE Array& operator=(Array&&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE Array() = default; template <typename DataType2> - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE Array(const Array<DataType2>& array) { this->operator=(array); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE Array(Array&&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE Array(const Array&) = default; - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ~Array() = default; }; diff --git a/src/utils/ArrayUtils.hpp b/src/utils/ArrayUtils.hpp index 9a55abfebde94b4ab53adff473c52907ec5385f8..26f4b623307497b6bae7b7f0416b5eef322284d7 100644 --- a/src/utils/ArrayUtils.hpp +++ b/src/utils/ArrayUtils.hpp @@ -1,6 +1,7 @@ #ifndef ARRAY_UTILS_HPP #define ARRAY_UTILS_HPP +#include <PastisMacros.hpp> #include <Kokkos_Core.hpp> template <typename ArrayType> @@ -12,7 +13,7 @@ class ReduceMin using index_type = typename ArrayType::index_type; public: - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE operator data_type() { data_type reduced_value; @@ -20,7 +21,7 @@ class ReduceMin return reduced_value; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE void operator()(const index_type& i, data_type& data) const { if (m_array[i] < data) { @@ -28,7 +29,7 @@ class ReduceMin } } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE void join(volatile data_type& dst, const volatile data_type& src) const { @@ -37,20 +38,20 @@ class ReduceMin } } - KOKKOS_INLINE_FUNCTION void - init(data_type& value) const + PASTIS_INLINE + void init(data_type& value) const { value = std::numeric_limits<data_type>::max(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ReduceMin(const ArrayType& array) : m_array(array) { ; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ~ReduceMin() = default; }; @@ -64,7 +65,7 @@ class ReduceMax using index_type = typename ArrayType::index_type; public: - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE operator data_type() { data_type reduced_value; @@ -72,7 +73,7 @@ class ReduceMax return reduced_value; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE void operator()(const index_type& i, data_type& data) const { if (m_array[i] > data) { @@ -80,7 +81,7 @@ class ReduceMax } } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE void join(volatile data_type& dst, const volatile data_type& src) const { @@ -89,20 +90,20 @@ class ReduceMax } } - KOKKOS_INLINE_FUNCTION void - init(data_type& value) const + PASTIS_INLINE + void init(data_type& value) const { value = -std::numeric_limits<data_type>::max(); } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ReduceMax(const ArrayType& array) : m_array(array) { ; } - KOKKOS_INLINE_FUNCTION + PASTIS_INLINE ~ReduceMax() = default; }; diff --git a/src/utils/FPEManager.cpp b/src/utils/FPEManager.cpp index 253ef99c37c34493296a71dfd96d47cf4e2d1c76..d4a4247682afa9f72c771933dcf091e00010d4bc 100644 --- a/src/utils/FPEManager.cpp +++ b/src/utils/FPEManager.cpp @@ -1,4 +1,5 @@ #include <FPEManager.hpp> +#include <PastisMacros.hpp> #include <pastis_config.hpp> #include <rang.hpp> @@ -12,7 +13,8 @@ // Public domain polyfill for feenableexcept on OS X // http://www-personal.umich.edu/~williams/archive/computation/fe-handling-example.c -inline int feenableexcept(unsigned int excepts) +PASTIS_INLINE +int feenableexcept(unsigned int excepts) { static fenv_t fenv; unsigned int new_excepts = excepts & FE_ALL_EXCEPT; @@ -31,7 +33,8 @@ inline int feenableexcept(unsigned int excepts) return fesetenv(&fenv) ? -1 : old_excepts; } -inline int fedisableexcept(unsigned int excepts) +PASTIS_INLINE +int fedisableexcept(unsigned int excepts) { static fenv_t fenv; unsigned int new_excepts = excepts & FE_ALL_EXCEPT; diff --git a/src/utils/PastisMacros.hpp b/src/utils/PastisMacros.hpp new file mode 100644 index 0000000000000000000000000000000000000000..43bade922351898b2a8ef4c3b28f32e81fdf9ee2 --- /dev/null +++ b/src/utils/PastisMacros.hpp @@ -0,0 +1,11 @@ +#ifndef PASTIS_UTILS_HPP +#define PASTIS_UTILS_HPP + +#include <Kokkos_Macros.hpp> + +#define PASTIS_RESTRICT KOKKOS_RESTRICT + +#define PASTIS_INLINE KOKKOS_INLINE_FUNCTION +#define PASTIS_FORCEINLINE KOKKOS_FORCEINLINE_FUNCTION + +#endif // PASTIS_UTILS_HPP diff --git a/tests/test_ItemType.cpp b/tests/test_ItemType.cpp index 096dbdaf5b8a85099c8ec892a15c7f6ceb1000ca..600b0882ed26b1f506484a913e1168b26fa173fd 100644 --- a/tests/test_ItemType.cpp +++ b/tests/test_ItemType.cpp @@ -1,4 +1,5 @@ #include <catch.hpp> +#include <PastisMacros.hpp> #include <ItemType.hpp>