Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Nektar::Math::MathHelper Class Reference

#include <MathHelper.hpp>

Public Member Functions

 MathHelper (void)
 
 MathHelper (const std::string &defaultExecSpace)
 
Math::MathHelper & operator= (const Math::MathHelper &rhs)
 
template<typename T >
LIB_MATH_EXPORT void zero (T &x, const std::string &execSpace="")
 
template<typename TData , typename T >
LIB_MATH_EXPORT void fill (const TData &val, T &x, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void fillUniform (RandomGenerator &gen, const typename T::value_type a, const typename T::value_type b, T &x, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void fillNormal (RandomGenerator &gen, const typename T::value_type mean, const typename T::value_type sigma, T &x, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void copy (T &x, T &y, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void abs (T &x, T &y, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void neg (T &x, T &y, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void sqrt (T &x, T &y, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void add (T &x, T &y, T &z, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void sub (T &x, T &y, T &z, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void mul (const typename T::value_type alpha, T &x, T &y, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void mul (T &x, T &y, T &z, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void div (const typename T::value_type alpha, T &x, T &y, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void div (T &x, T &y, T &z, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void daxpy (const typename T::value_type alpha, T &x, T &y, T &z, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void daxpby (const typename T::value_type alpha, T &x, const typename T::value_type beta, T &y, T &z, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void daxpbypz (const typename T::value_type alpha, T &x, const typename T::value_type beta, T &y, T &z, T &w, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void daxpbypcz (const typename T::value_type alpha, T &x, const typename T::value_type beta, T &y, const typename T::value_type gamma, T &z, T &w, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT void linearCombination (const std::vector< typename T::value_type > &alpha, const std::vector< T * > &x, T &y, const bool append, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT T::value_type reduceSum (T &x, const std::string &execSpace="")
 
template<typename M , typename T >
LIB_MATH_EXPORT T::value_type reduceSum (M &mask, T &x, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT T::value_type reduceMax (T &x, const std::string &execSpace="")
 
template<typename M , typename T >
LIB_MATH_EXPORT T::value_type reduceMax (M &mask, T &x, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT T::value_type reduceMin (T &x, const std::string &execSpace="")
 
template<typename M , typename T >
LIB_MATH_EXPORT T::value_type reduceMin (M &mask, T &x, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT T::value_type ddot (T &x, T &y, const std::string &execSpace="")
 
template<typename M , typename T >
LIB_MATH_EXPORT T::value_type ddot (M &mask, T &x, T &y, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT std::array< typename T::value_type, 2 > ddot2 (T &x, T &y, T &z, const std::string &execSpace="")
 
template<typename M , typename T >
LIB_MATH_EXPORT std::array< typename T::value_type, 2 > ddot2 (M &mask, T &x, T &y, T &z, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT T::value_type l1norm (T &x, const std::string &execSpace="")
 
template<typename M , typename T >
LIB_MATH_EXPORT T::value_type l1norm (M &mask, T &x, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT T::value_type l2norm (T &, const std::string &execSpace="")
 
template<typename M , typename T >
LIB_MATH_EXPORT T::value_type l2norm (M &mask, T &, const std::string &execSpace="")
 
template<typename T >
LIB_MATH_EXPORT T::value_type linfnorm (T &x, const std::string &execSpace="")
 
template<typename M , typename T >
LIB_MATH_EXPORT T::value_type linfnorm (M &mask, T &x, const std::string &execSpace="")
 
template<typename T >
void zero (T &x, const std::string &execSpace)
 
template<typename TData , typename T >
void fill (const TData &val, T &x, const std::string &execSpace)
 
template<typename T >
void fillUniform (RandomGenerator &gen, const typename T::value_type a, const typename T::value_type b, T &x, const std::string &execSpace)
 
template<typename T >
void fillNormal (RandomGenerator &gen, const typename T::value_type mean, const typename T::value_type sigma, T &x, const std::string &execSpace)
 
template<typename T >
void copy (T &x, T &y, const std::string &execSpace)
 
template<typename T >
void abs (T &x, T &y, const std::string &execSpace)
 
template<typename T >
void neg (T &x, T &y, const std::string &execSpace)
 
template<typename T >
void sqrt (T &x, T &y, const std::string &execSpace)
 
template<typename T >
void add (T &x, T &y, T &z, const std::string &execSpace)
 
template<typename T >
void sub (T &x, T &y, T &z, const std::string &execSpace)
 
template<typename T >
void mul (const typename T::value_type alpha, T &x, T &y, const std::string &execSpace)
 
template<typename T >
void mul (T &x, T &y, T &z, const std::string &execSpace)
 
template<typename T >
void div (const typename T::value_type alpha, T &x, T &y, const std::string &execSpace)
 
template<typename T >
void div (T &x, T &y, T &z, const std::string &execSpace)
 
template<typename T >
void daxpy (const typename T::value_type alpha, T &x, T &y, T &z, const std::string &execSpace)
 
template<typename T >
void daxpby (const typename T::value_type alpha, T &x, const typename T::value_type beta, T &y, T &z, const std::string &execSpace)
 
template<typename T >
void daxpbypz (const typename T::value_type alpha, T &x, const typename T::value_type beta, T &y, T &z, T &w, const std::string &execSpace)
 
template<typename T >
void daxpbypcz (const typename T::value_type alpha, T &x, const typename T::value_type beta, T &y, const typename T::value_type gamma, T &z, T &w, const std::string &execSpace)
 
template<typename T >
void linearCombination (const std::vector< typename T::value_type > &alpha, const std::vector< T * > &x, T &y, const bool append, const std::string &execSpace)
 
template<typename T >
T::value_type reduceSum (T &x, const std::string &execSpace)
 
template<typename M , typename T >
T::value_type reduceSum (M &mask, T &x, const std::string &execSpace)
 
template<typename T >
T::value_type reduceMax (T &x, const std::string &execSpace)
 
template<typename M , typename T >
T::value_type reduceMax (M &mask, T &x, const std::string &execSpace)
 
template<typename T >
T::value_type reduceMin (T &x, const std::string &execSpace)
 
template<typename M , typename T >
T::value_type reduceMin (M &mask, T &x, const std::string &execSpace)
 
template<typename T >
T::value_type ddot (T &x, T &y, const std::string &execSpace)
 
template<typename M , typename T >
T::value_type ddot (M &mask, T &x, T &y, const std::string &execSpace)
 
template<typename T >
std::array< typename T::value_type, 2 > ddot2 (T &x, T &y, T &z, const std::string &execSpace)
 
template<typename M , typename T >
std::array< typename T::value_type, 2 > ddot2 (M &mask, T &x, T &y, T &z, const std::string &execSpace)
 
template<typename T >
T::value_type l1norm (T &x, const std::string &execSpace)
 
template<typename M , typename T >
T::value_type l1norm (M &mask, T &x, const std::string &execSpace)
 
template<typename T >
T::value_type l2norm (T &x, const std::string &execSpace)
 
template<typename M , typename T >
T::value_type l2norm (M &mask, T &x, const std::string &execSpace)
 
template<typename T >
T::value_type linfnorm (T &x, const std::string &execSpace)
 
template<typename M , typename T >
T::value_type linfnorm (M &mask, T &x, const std::string &execSpace)
 

Private Attributes

std::string m_defaultExecSpace
 

Detailed Description

Definition at line 49 of file MathHelper.hpp.

Constructor & Destructor Documentation

◆ MathHelper() [1/2]

Nektar::Math::MathHelper::MathHelper ( void  )
inline

Definition at line 52 of file MathHelper.hpp.

52 : m_defaultExecSpace("Serial")
53 {
54 }

◆ MathHelper() [2/2]

Nektar::Math::MathHelper::MathHelper ( const std::string &  defaultExecSpace)
inline

Definition at line 56 of file MathHelper.hpp.

57 : m_defaultExecSpace(defaultExecSpace)
58 {
59 }

Member Function Documentation

◆ abs() [1/2]

template<typename T >
void Nektar::Math::MathHelper::abs ( T &  x,
T &  y,
const std::string &  execSpace 
)

Definition at line 187 of file MathHelperDef.hpp.

188{
189 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
190
191 if (execSpace0 == "Serial")
192 {
193 Nektar::Math::abs<NektarSpaces::Serial>(x, y);
194 }
195#if defined(NEKTAR_ENABLE_SIMD)
196 else if (execSpace0 == "AVX")
197 {
198 Nektar::Math::abs<NektarSpaces::AVX>(x, y);
199 }
200#endif
201#if defined(NEKTAR_ENABLE_DEVICE)
202 else if (execSpace0 == "Device")
203 {
204 Nektar::Math::abs<NektarSpaces::Device>(x, y);
205 }
206#endif
207 else
208 {
209 ASSERTL0(false, "Unknown Execution space: " + execSpace)
210 }
211}
#define ASSERTL0(condition, msg)

References ASSERTL0, and m_defaultExecSpace.

◆ abs() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::abs ( T &  x,
T &  y,
const std::string &  execSpace = "" 
)

◆ add() [1/2]

template<typename T >
void Nektar::Math::MathHelper::add ( T &  x,
T &  y,
T &  z,
const std::string &  execSpace 
)

Definition at line 268 of file MathHelperDef.hpp.

269{
270 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
271
272 if (execSpace0 == "Serial")
273 {
274 Nektar::Math::add<NektarSpaces::Serial>(x, y, z);
275 }
276#if defined(NEKTAR_ENABLE_SIMD)
277 else if (execSpace0 == "AVX")
278 {
279 Nektar::Math::add<NektarSpaces::AVX>(x, y, z);
280 }
281#endif
282#if defined(NEKTAR_ENABLE_DEVICE)
283 else if (execSpace0 == "Device")
284 {
285 Nektar::Math::add<NektarSpaces::Device>(x, y, z);
286 }
287#endif
288 else
289 {
290 ASSERTL0(false, "Unknown Execution space: " + execSpace)
291 }
292}

References ASSERTL0, and m_defaultExecSpace.

◆ add() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::add ( T &  x,
T &  y,
T &  z,
const std::string &  execSpace = "" 
)

◆ copy() [1/2]

template<typename T >
void Nektar::Math::MathHelper::copy ( T &  x,
T &  y,
const std::string &  execSpace 
)

Definition at line 160 of file MathHelperDef.hpp.

161{
162 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
163
164 if (execSpace0 == "Serial")
165 {
166 Nektar::Math::copy<NektarSpaces::Serial>(x, y);
167 }
168#if defined(NEKTAR_ENABLE_SIMD)
169 else if (execSpace0 == "AVX")
170 {
171 Nektar::Math::copy<NektarSpaces::AVX>(x, y);
172 }
173#endif
174#if defined(NEKTAR_ENABLE_DEVICE)
175 else if (execSpace0 == "Device")
176 {
177 Nektar::Math::copy<NektarSpaces::Device>(x, y);
178 }
179#endif
180 else
181 {
182 ASSERTL0(false, "Unknown Execution space: " + execSpace)
183 }
184}

References ASSERTL0, and m_defaultExecSpace.

◆ copy() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::copy ( T &  x,
T &  y,
const std::string &  execSpace = "" 
)

◆ daxpby() [1/2]

template<typename T >
void Nektar::Math::MathHelper::daxpby ( const typename T::value_type  alpha,
T &  x,
const typename T::value_type  beta,
T &  y,
T &  z,
const std::string &  execSpace 
)

Definition at line 460 of file MathHelperDef.hpp.

463{
464 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
465
466 if (execSpace0 == "Serial")
467 {
468 Nektar::Math::daxpby<NektarSpaces::Serial>(alpha, x, beta, y, z);
469 }
470#if defined(NEKTAR_ENABLE_SIMD)
471 else if (execSpace0 == "AVX")
472 {
473 Nektar::Math::daxpby<NektarSpaces::AVX>(alpha, x, beta, y, z);
474 }
475#endif
476#if defined(NEKTAR_ENABLE_DEVICE)
477 else if (execSpace0 == "Device")
478 {
479 Nektar::Math::daxpby<NektarSpaces::Device>(alpha, x, beta, y, z);
480 }
481#endif
482 else
483 {
484 ASSERTL0(false, "Unknown Execution space: " + execSpace)
485 }
486}
@ beta
Gauss Radau pinned at x=-1,.
Definition PointsType.h:59

References ASSERTL0, Nektar::LibUtilities::beta, and m_defaultExecSpace.

◆ daxpby() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::daxpby ( const typename T::value_type  alpha,
T &  x,
const typename T::value_type  beta,
T &  y,
T &  z,
const std::string &  execSpace = "" 
)

◆ daxpbypcz() [1/2]

template<typename T >
void Nektar::Math::MathHelper::daxpbypcz ( const typename T::value_type  alpha,
T &  x,
const typename T::value_type  beta,
T &  y,
const typename T::value_type  gamma,
T &  z,
T &  w,
const std::string &  execSpace 
)

Definition at line 518 of file MathHelperDef.hpp.

522{
523 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
524
525 if (execSpace0 == "Serial")
526 {
527 Nektar::Math::daxpbypcz<NektarSpaces::Serial>(alpha, x, beta, y, gamma,
528 z, w);
529 }
530#if defined(NEKTAR_ENABLE_SIMD)
531 else if (execSpace0 == "AVX")
532 {
533 Nektar::Math::daxpbypcz<NektarSpaces::AVX>(alpha, x, beta, y, gamma, z,
534 w);
535 }
536#endif
537#if defined(NEKTAR_ENABLE_DEVICE)
538 else if (execSpace0 == "Device")
539 {
540 Nektar::Math::daxpbypcz<NektarSpaces::Device>(alpha, x, beta, y, gamma,
541 z, w);
542 }
543#endif
544 else
545 {
546 ASSERTL0(false, "Unknown Execution space: " + execSpace)
547 }
548}

References ASSERTL0, Nektar::LibUtilities::beta, and m_defaultExecSpace.

◆ daxpbypcz() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::daxpbypcz ( const typename T::value_type  alpha,
T &  x,
const typename T::value_type  beta,
T &  y,
const typename T::value_type  gamma,
T &  z,
T &  w,
const std::string &  execSpace = "" 
)

◆ daxpbypz() [1/2]

template<typename T >
void Nektar::Math::MathHelper::daxpbypz ( const typename T::value_type  alpha,
T &  x,
const typename T::value_type  beta,
T &  y,
T &  z,
T &  w,
const std::string &  execSpace 
)

Definition at line 489 of file MathHelperDef.hpp.

492{
493 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
494
495 if (execSpace0 == "Serial")
496 {
497 Nektar::Math::daxpbypz<NektarSpaces::Serial>(alpha, x, beta, y, z, w);
498 }
499#if defined(NEKTAR_ENABLE_SIMD)
500 else if (execSpace0 == "AVX")
501 {
502 Nektar::Math::daxpbypz<NektarSpaces::AVX>(alpha, x, beta, y, z, w);
503 }
504#endif
505#if defined(NEKTAR_ENABLE_DEVICE)
506 else if (execSpace0 == "Device")
507 {
508 Nektar::Math::daxpbypz<NektarSpaces::Device>(alpha, x, beta, y, z, w);
509 }
510#endif
511 else
512 {
513 ASSERTL0(false, "Unknown Execution space: " + execSpace)
514 }
515}

References ASSERTL0, Nektar::LibUtilities::beta, and m_defaultExecSpace.

◆ daxpbypz() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::daxpbypz ( const typename T::value_type  alpha,
T &  x,
const typename T::value_type  beta,
T &  y,
T &  z,
T &  w,
const std::string &  execSpace = "" 
)

◆ daxpy() [1/2]

template<typename T >
void Nektar::Math::MathHelper::daxpy ( const typename T::value_type  alpha,
T &  x,
T &  y,
T &  z,
const std::string &  execSpace 
)

Definition at line 432 of file MathHelperDef.hpp.

434{
435 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
436
437 if (execSpace0 == "Serial")
438 {
439 Nektar::Math::daxpy<NektarSpaces::Serial>(alpha, x, y, z);
440 }
441#if defined(NEKTAR_ENABLE_SIMD)
442 else if (execSpace0 == "AVX")
443 {
444 Nektar::Math::daxpy<NektarSpaces::AVX>(alpha, x, y, z);
445 }
446#endif
447#if defined(NEKTAR_ENABLE_DEVICE)
448 else if (execSpace0 == "Device")
449 {
450 Nektar::Math::daxpy<NektarSpaces::Device>(alpha, x, y, z);
451 }
452#endif
453 else
454 {
455 ASSERTL0(false, "Unknown Execution space: " + execSpace)
456 }
457}

References ASSERTL0, and m_defaultExecSpace.

◆ daxpy() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::daxpy ( const typename T::value_type  alpha,
T &  x,
T &  y,
T &  z,
const std::string &  execSpace = "" 
)

◆ ddot() [1/4]

template<typename M , typename T >
T::value_type Nektar::Math::MathHelper::ddot ( M &  mask,
T &  x,
T &  y,
const std::string &  execSpace 
)

Definition at line 894 of file MathHelperDef.hpp.

896{
897 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
898
899 typename T::value_type out = 0.0;
900 if (execSpace0 == "Serial")
901 {
902 Nektar::Math::ddot<NektarSpaces::Serial>(mask, x, y, &out);
903 }
904#if defined(NEKTAR_ENABLE_SIMD)
905 else if (execSpace0 == "AVX")
906 {
907 Nektar::Math::ddot<NektarSpaces::AVX>(mask, x, y, &out);
908 }
909#endif
910#if defined(NEKTAR_ENABLE_DEVICE)
911 else if (execSpace0 == "Device")
912 {
913 const unsigned int streamID = internalReductionStreamID;
914 if (internalDeviceBuffer == nullptr)
915 {
916 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
917 streamID);
918 Nektar::hostMallocPinned(&internalHostBuffer,
919 internalMaxDataSizeByte);
921 }
922 Nektar::Math::ddot<NektarSpaces::Device>(
923 mask, x, y, (typename T::value_type *)internalDeviceBuffer);
924 Nektar::deviceMemcpy<eDeviceToHost>(
925 internalHostBuffer, internalDeviceBuffer,
926 sizeof(typename T::value_type), streamID);
927 out = *(typename T::value_type *)internalHostBuffer;
928 }
929#endif
930 else
931 {
932 ASSERTL0(false, "Unknown Execution space: " + execSpace)
933 }
934
935 return out;
936}
constexpr unsigned int internalReductionStreamID
Definition Math.hpp:47
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int const unsigned int const unsigned int const unsigned int const size_t const TData *NEK_RESTRICT const TData *NEK_RESTRICT const TUseSharedWsp TData *NEK_RESTRICT const TData *NEK_RESTRICT TData *NEK_RESTRICT out
static void nekStreamSynchronize(const unsigned int streamID)
Definition Backends.hpp:428
void deviceMalloc(TData **src, const size_t size, const unsigned int streamID, const MemAllocType memAllocType=eHostPageable)
void hostMallocPinned(TData **src, const size_t size)

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ ddot() [2/4]

template<typename M , typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::ddot ( M &  mask,
T &  x,
T &  y,
const std::string &  execSpace = "" 
)

◆ ddot() [3/4]

template<typename T >
T::value_type Nektar::Math::MathHelper::ddot ( T &  x,
T &  y,
const std::string &  execSpace 
)

Definition at line 849 of file MathHelperDef.hpp.

851{
852 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
853
854 typename T::value_type out = 0.0;
855 if (execSpace0 == "Serial")
856 {
857 Nektar::Math::ddot<NektarSpaces::Serial>(x, y, &out);
858 }
859#if defined(NEKTAR_ENABLE_SIMD)
860 else if (execSpace0 == "AVX")
861 {
862 Nektar::Math::ddot<NektarSpaces::AVX>(x, y, &out);
863 }
864#endif
865#if defined(NEKTAR_ENABLE_DEVICE)
866 else if (execSpace0 == "Device")
867 {
868 const unsigned int streamID = internalReductionStreamID;
869 if (internalDeviceBuffer == nullptr)
870 {
871 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
872 streamID);
873 Nektar::hostMallocPinned(&internalHostBuffer,
874 internalMaxDataSizeByte);
876 }
877 Nektar::Math::ddot<NektarSpaces::Device>(
878 x, y, (typename T::value_type *)internalDeviceBuffer);
879 Nektar::deviceMemcpy<eDeviceToHost>(
880 internalHostBuffer, internalDeviceBuffer,
881 sizeof(typename T::value_type), streamID);
882 out = *(typename T::value_type *)internalHostBuffer;
883 }
884#endif
885 else
886 {
887 ASSERTL0(false, "Unknown Execution space: " + execSpace)
888 }
889
890 return out;
891}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ ddot() [4/4]

template<typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::ddot ( T &  x,
T &  y,
const std::string &  execSpace = "" 
)

◆ ddot2() [1/4]

template<typename M , typename T >
std::array< typename T::value_type, 2 > Nektar::Math::MathHelper::ddot2 ( M &  mask,
T &  x,
T &  y,
T &  z,
const std::string &  execSpace 
)

Definition at line 985 of file MathHelperDef.hpp.

987{
988 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
989
990 std::array<typename T::value_type, 2> out = {0.0, 0.0};
991 if (execSpace0 == "Serial")
992 {
993 Nektar::Math::ddot2<NektarSpaces::Serial>(mask, x, y, z, out.data());
994 }
995#if defined(NEKTAR_ENABLE_SIMD)
996 else if (execSpace0 == "AVX")
997 {
998 Nektar::Math::ddot2<NektarSpaces::AVX>(mask, x, y, z, out.data());
999 }
1000#endif
1001#if defined(NEKTAR_ENABLE_DEVICE)
1002 else if (execSpace0 == "Device")
1003 {
1004 const unsigned int streamID = internalReductionStreamID;
1005 if (internalDeviceBuffer == nullptr)
1006 {
1007 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
1008 streamID);
1009 Nektar::hostMallocPinned(&internalHostBuffer,
1010 internalMaxDataSizeByte);
1012 }
1013 Nektar::Math::ddot2<NektarSpaces::Device>(
1014 mask, x, y, z, (typename T::value_type *)internalDeviceBuffer);
1015 Nektar::deviceMemcpy<eDeviceToHost>(
1016 internalHostBuffer, internalDeviceBuffer,
1017 2 * sizeof(typename T::value_type), streamID);
1018 out[0] = ((typename T::value_type *)internalHostBuffer)[0];
1019 out[1] = ((typename T::value_type *)internalHostBuffer)[1];
1020 }
1021#endif
1022 else
1023 {
1024 ASSERTL0(false, "Unknown Execution space: " + execSpace)
1025 }
1026
1027 return out;
1028}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ ddot2() [2/4]

template<typename M , typename T >
LIB_MATH_EXPORT std::array< typename T::value_type, 2 > Nektar::Math::MathHelper::ddot2 ( M &  mask,
T &  x,
T &  y,
T &  z,
const std::string &  execSpace = "" 
)

◆ ddot2() [3/4]

template<typename T >
std::array< typename T::value_type, 2 > Nektar::Math::MathHelper::ddot2 ( T &  x,
T &  y,
T &  z,
const std::string &  execSpace 
)

Definition at line 939 of file MathHelperDef.hpp.

941{
942 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
943
944 std::array<typename T::value_type, 2> out = {0.0, 0.0};
945 if (execSpace0 == "Serial")
946 {
947 Nektar::Math::ddot2<NektarSpaces::Serial>(x, y, z, out.data());
948 }
949#if defined(NEKTAR_ENABLE_SIMD)
950 else if (execSpace0 == "AVX")
951 {
952 Nektar::Math::ddot2<NektarSpaces::AVX>(x, y, z, out.data());
953 }
954#endif
955#if defined(NEKTAR_ENABLE_DEVICE)
956 else if (execSpace0 == "Device")
957 {
958 const unsigned int streamID = internalReductionStreamID;
959 if (internalDeviceBuffer == nullptr)
960 {
961 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
962 streamID);
963 Nektar::hostMallocPinned(&internalHostBuffer,
964 internalMaxDataSizeByte);
966 }
967 Nektar::Math::ddot2<NektarSpaces::Device>(
968 x, y, z, (typename T::value_type *)internalDeviceBuffer);
969 Nektar::deviceMemcpy<eDeviceToHost>(
970 internalHostBuffer, internalDeviceBuffer,
971 2 * sizeof(typename T::value_type), streamID);
972 out[0] = ((typename T::value_type *)internalHostBuffer)[0];
973 out[1] = ((typename T::value_type *)internalHostBuffer)[1];
974 }
975#endif
976 else
977 {
978 ASSERTL0(false, "Unknown Execution space: " + execSpace)
979 }
980
981 return out;
982}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ ddot2() [4/4]

template<typename T >
LIB_MATH_EXPORT std::array< typename T::value_type, 2 > Nektar::Math::MathHelper::ddot2 ( T &  x,
T &  y,
T &  z,
const std::string &  execSpace = "" 
)

◆ div() [1/4]

template<typename T >
void Nektar::Math::MathHelper::div ( const typename T::value_type  alpha,
T &  x,
T &  y,
const std::string &  execSpace 
)

Definition at line 377 of file MathHelperDef.hpp.

379{
380 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
381
382 if (execSpace0 == "Serial")
383 {
384 Nektar::Math::div<NektarSpaces::Serial>(alpha, x, y);
385 }
386#if defined(NEKTAR_ENABLE_SIMD)
387 else if (execSpace0 == "AVX")
388 {
389 Nektar::Math::div<NektarSpaces::AVX>(alpha, x, y);
390 }
391#endif
392#if defined(NEKTAR_ENABLE_DEVICE)
393 else if (execSpace0 == "Device")
394 {
395 Nektar::Math::div<NektarSpaces::Device>(alpha, x, y);
396 }
397#endif
398 else
399 {
400 ASSERTL0(false, "Unknown Execution space: " + execSpace)
401 }
402}

References ASSERTL0, and m_defaultExecSpace.

◆ div() [2/4]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::div ( const typename T::value_type  alpha,
T &  x,
T &  y,
const std::string &  execSpace = "" 
)

◆ div() [3/4]

template<typename T >
void Nektar::Math::MathHelper::div ( T &  x,
T &  y,
T &  z,
const std::string &  execSpace 
)

Definition at line 405 of file MathHelperDef.hpp.

406{
407 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
408
409 if (execSpace0 == "Serial")
410 {
411 Nektar::Math::div<NektarSpaces::Serial>(x, y, z);
412 }
413#if defined(NEKTAR_ENABLE_SIMD)
414 else if (execSpace0 == "AVX")
415 {
416 Nektar::Math::div<NektarSpaces::AVX>(x, y, z);
417 }
418#endif
419#if defined(NEKTAR_ENABLE_DEVICE)
420 else if (execSpace0 == "Device")
421 {
422 Nektar::Math::div<NektarSpaces::Device>(x, y, z);
423 }
424#endif
425 else
426 {
427 ASSERTL0(false, "Unknown Execution space: " + execSpace)
428 }
429}

References ASSERTL0, and m_defaultExecSpace.

◆ div() [4/4]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::div ( T &  x,
T &  y,
T &  z,
const std::string &  execSpace = "" 
)

◆ fill() [1/2]

template<typename TData , typename T >
void Nektar::Math::MathHelper::fill ( const TData &  val,
T &  x,
const std::string &  execSpace 
)

Definition at line 73 of file MathHelperDef.hpp.

74{
75 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
76
77 if (execSpace0 == "Serial")
78 {
79 Nektar::Math::fill<NektarSpaces::Serial>(val, x);
80 }
81#if defined(NEKTAR_ENABLE_SIMD)
82 else if (execSpace0 == "AVX")
83 {
84 Nektar::Math::fill<NektarSpaces::AVX>(val, x);
85 }
86#endif
87#if defined(NEKTAR_ENABLE_DEVICE)
88 else if (execSpace0 == "Device")
89 {
90 Nektar::Math::fill<NektarSpaces::Device>(val, x);
91 }
92#endif
93 else
94 {
95 ASSERTL0(false, "Unknown Execution space: " + execSpace)
96 }
97}

References ASSERTL0, and m_defaultExecSpace.

◆ fill() [2/2]

template<typename TData , typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::fill ( const TData &  val,
T &  x,
const std::string &  execSpace = "" 
)

◆ fillNormal() [1/2]

template<typename T >
void Nektar::Math::MathHelper::fillNormal ( RandomGenerator &  gen,
const typename T::value_type  mean,
const typename T::value_type  sigma,
T &  x,
const std::string &  execSpace 
)

Definition at line 130 of file MathHelperDef.hpp.

134{
135 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
136
137 if (execSpace0 == "Serial")
138 {
139 Nektar::Math::fillNormal<NektarSpaces::Serial>(gen, mean, sigma, x);
140 }
141#if defined(NEKTAR_ENABLE_SIMD)
142 else if (execSpace0 == "AVX")
143 {
144 Nektar::Math::fillNormal<NektarSpaces::AVX>(gen, mean, sigma, x);
145 }
146#endif
147#if defined(NEKTAR_ENABLE_DEVICE)
148 else if (execSpace0 == "Device")
149 {
150 Nektar::Math::fillNormal<NektarSpaces::Device>(gen, mean, sigma, x);
151 }
152#endif
153 else
154 {
155 ASSERTL0(false, "Unknown Execution space: " + execSpace)
156 }
157}

References ASSERTL0, and m_defaultExecSpace.

◆ fillNormal() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::fillNormal ( RandomGenerator &  gen,
const typename T::value_type  mean,
const typename T::value_type  sigma,
T &  x,
const std::string &  execSpace = "" 
)

◆ fillUniform() [1/2]

template<typename T >
void Nektar::Math::MathHelper::fillUniform ( RandomGenerator &  gen,
const typename T::value_type  a,
const typename T::value_type  b,
T &  x,
const std::string &  execSpace 
)

Definition at line 100 of file MathHelperDef.hpp.

104{
105 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
106
107 if (execSpace0 == "Serial")
108 {
109 Nektar::Math::fillUniform<NektarSpaces::Serial>(gen, a, b, x);
110 }
111#if defined(NEKTAR_ENABLE_SIMD)
112 else if (execSpace0 == "AVX")
113 {
114 Nektar::Math::fillUniform<NektarSpaces::AVX>(gen, a, b, x);
115 }
116#endif
117#if defined(NEKTAR_ENABLE_DEVICE)
118 else if (execSpace0 == "Device")
119 {
120 Nektar::Math::fillUniform<NektarSpaces::Device>(gen, a, b, x);
121 }
122#endif
123 else
124 {
125 ASSERTL0(false, "Unknown Execution space: " + execSpace)
126 }
127}

References ASSERTL0, and m_defaultExecSpace.

◆ fillUniform() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::fillUniform ( RandomGenerator &  gen,
const typename T::value_type  a,
const typename T::value_type  b,
T &  x,
const std::string &  execSpace = "" 
)

◆ l1norm() [1/4]

template<typename M , typename T >
T::value_type Nektar::Math::MathHelper::l1norm ( M &  mask,
T &  x,
const std::string &  execSpace 
)

Definition at line 1075 of file MathHelperDef.hpp.

1077{
1078 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
1079
1080 typename T::value_type out = 0.0;
1081 if (execSpace0 == "Serial")
1082 {
1083 Nektar::Math::l1norm<NektarSpaces::Serial>(mask, x, &out);
1084 }
1085#if defined(NEKTAR_ENABLE_SIMD)
1086 else if (execSpace0 == "AVX")
1087 {
1088 Nektar::Math::l1norm<NektarSpaces::AVX>(mask, x, &out);
1089 }
1090#endif
1091#if defined(NEKTAR_ENABLE_DEVICE)
1092 else if (execSpace0 == "Device")
1093 {
1094 const unsigned int streamID = internalReductionStreamID;
1095 if (internalDeviceBuffer == nullptr)
1096 {
1097 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
1098 streamID);
1099 Nektar::hostMallocPinned(&internalHostBuffer,
1100 internalMaxDataSizeByte);
1102 }
1103 Nektar::Math::l1norm<NektarSpaces::Device>(
1104 mask, x, (typename T::value_type *)internalDeviceBuffer);
1105 Nektar::deviceMemcpy<eDeviceToHost>(
1106 internalHostBuffer, internalDeviceBuffer,
1107 sizeof(typename T::value_type), streamID);
1108 out = *(typename T::value_type *)internalHostBuffer;
1109 }
1110#endif
1111 else
1112 {
1113 ASSERTL0(false, "Unknown Execution space: " + execSpace)
1114 }
1115
1116 return out;
1117}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ l1norm() [2/4]

template<typename M , typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::l1norm ( M &  mask,
T &  x,
const std::string &  execSpace = "" 
)

◆ l1norm() [3/4]

template<typename T >
T::value_type Nektar::Math::MathHelper::l1norm ( T &  x,
const std::string &  execSpace 
)

Definition at line 1031 of file MathHelperDef.hpp.

1032{
1033 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
1034
1035 typename T::value_type out = 0.0;
1036 if (execSpace0 == "Serial")
1037 {
1038 Nektar::Math::l1norm<NektarSpaces::Serial>(x, &out);
1039 }
1040#if defined(NEKTAR_ENABLE_SIMD)
1041 else if (execSpace0 == "AVX")
1042 {
1043 Nektar::Math::l1norm<NektarSpaces::AVX>(x, &out);
1044 }
1045#endif
1046#if defined(NEKTAR_ENABLE_DEVICE)
1047 else if (execSpace0 == "Device")
1048 {
1049 const unsigned int streamID = internalReductionStreamID;
1050 if (internalDeviceBuffer == nullptr)
1051 {
1052 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
1053 streamID);
1054 Nektar::hostMallocPinned(&internalHostBuffer,
1055 internalMaxDataSizeByte);
1057 }
1058 Nektar::Math::l1norm<NektarSpaces::Device>(
1059 x, (typename T::value_type *)internalDeviceBuffer);
1060 Nektar::deviceMemcpy<eDeviceToHost>(
1061 internalHostBuffer, internalDeviceBuffer,
1062 sizeof(typename T::value_type), streamID);
1063 out = *(typename T::value_type *)internalHostBuffer;
1064 }
1065#endif
1066 else
1067 {
1068 ASSERTL0(false, "Unknown Execution space: " + execSpace)
1069 }
1070
1071 return out;
1072}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ l1norm() [4/4]

template<typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::l1norm ( T &  x,
const std::string &  execSpace = "" 
)

◆ l2norm() [1/4]

template<typename M , typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::l2norm ( M &  mask,
T &  ,
const std::string &  execSpace = "" 
)

◆ l2norm() [2/4]

template<typename M , typename T >
T::value_type Nektar::Math::MathHelper::l2norm ( M &  mask,
T &  x,
const std::string &  execSpace 
)

Definition at line 1164 of file MathHelperDef.hpp.

1166{
1167 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
1168
1169 typename T::value_type out = 0.0;
1170 if (execSpace0 == "Serial")
1171 {
1172 Nektar::Math::l2norm<NektarSpaces::Serial>(mask, x, &out);
1173 }
1174#if defined(NEKTAR_ENABLE_SIMD)
1175 else if (execSpace0 == "AVX")
1176 {
1177 Nektar::Math::l2norm<NektarSpaces::AVX>(mask, x, &out);
1178 }
1179#endif
1180#if defined(NEKTAR_ENABLE_DEVICE)
1181 else if (execSpace0 == "Device")
1182 {
1183 const unsigned int streamID = internalReductionStreamID;
1184 if (internalDeviceBuffer == nullptr)
1185 {
1186 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
1187 streamID);
1188 Nektar::hostMallocPinned(&internalHostBuffer,
1189 internalMaxDataSizeByte);
1191 }
1192 Nektar::Math::l2norm<NektarSpaces::Device>(
1193 mask, x, (typename T::value_type *)internalDeviceBuffer);
1194 Nektar::deviceMemcpy<eDeviceToHost>(
1195 internalHostBuffer, internalDeviceBuffer,
1196 sizeof(typename T::value_type), streamID);
1197 out = *(typename T::value_type *)internalHostBuffer;
1198 }
1199#endif
1200 else
1201 {
1202 ASSERTL0(false, "Unknown Execution space: " + execSpace)
1203 }
1204
1205 return out;
1206}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ l2norm() [3/4]

template<typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::l2norm ( T &  ,
const std::string &  execSpace = "" 
)

◆ l2norm() [4/4]

template<typename T >
T::value_type Nektar::Math::MathHelper::l2norm ( T &  x,
const std::string &  execSpace 
)

Definition at line 1120 of file MathHelperDef.hpp.

1121{
1122 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
1123
1124 typename T::value_type out = 0.0;
1125 if (execSpace0 == "Serial")
1126 {
1127 Nektar::Math::l2norm<NektarSpaces::Serial>(x, &out);
1128 }
1129#if defined(NEKTAR_ENABLE_SIMD)
1130 else if (execSpace0 == "AVX")
1131 {
1132 Nektar::Math::l2norm<NektarSpaces::AVX>(x, &out);
1133 }
1134#endif
1135#if defined(NEKTAR_ENABLE_DEVICE)
1136 else if (execSpace0 == "Device")
1137 {
1138 const unsigned int streamID = internalReductionStreamID;
1139 if (internalDeviceBuffer == nullptr)
1140 {
1141 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
1142 streamID);
1143 Nektar::hostMallocPinned(&internalHostBuffer,
1144 internalMaxDataSizeByte);
1146 }
1147 Nektar::Math::l2norm<NektarSpaces::Device>(
1148 x, (typename T::value_type *)internalDeviceBuffer);
1149 Nektar::deviceMemcpy<eDeviceToHost>(
1150 internalHostBuffer, internalDeviceBuffer,
1151 sizeof(typename T::value_type), streamID);
1152 out = *(typename T::value_type *)internalHostBuffer;
1153 }
1154#endif
1155 else
1156 {
1157 ASSERTL0(false, "Unknown Execution space: " + execSpace)
1158 }
1159
1160 return out;
1161}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ linearCombination() [1/2]

template<typename T >
void Nektar::Math::MathHelper::linearCombination ( const std::vector< typename T::value_type > &  alpha,
const std::vector< T * > &  x,
T &  y,
const bool  append,
const std::string &  execSpace 
)

Definition at line 551 of file MathHelperDef.hpp.

554{
555 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
556
557 if (execSpace0 == "Serial")
558 {
559 Nektar::Math::linearCombination<NektarSpaces::Serial>(alpha, x, y,
560 append);
561 }
562#if defined(NEKTAR_ENABLE_SIMD)
563 else if (execSpace0 == "AVX")
564 {
565 Nektar::Math::linearCombination<NektarSpaces::AVX>(alpha, x, y, append);
566 }
567#endif
568#if defined(NEKTAR_ENABLE_DEVICE)
569 else if (execSpace0 == "Device")
570 {
571 Nektar::Math::linearCombination<NektarSpaces::Device>(alpha, x, y,
572 append);
573 }
574#endif
575 else
576 {
577 ASSERTL0(false, "Unknown Execution space: " + execSpace)
578 }
579}

References ASSERTL0, and m_defaultExecSpace.

◆ linearCombination() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::linearCombination ( const std::vector< typename T::value_type > &  alpha,
const std::vector< T * > &  x,
T &  y,
const bool  append,
const std::string &  execSpace = "" 
)

◆ linfnorm() [1/4]

template<typename M , typename T >
T::value_type Nektar::Math::MathHelper::linfnorm ( M &  mask,
T &  x,
const std::string &  execSpace 
)

Definition at line 1253 of file MathHelperDef.hpp.

1255{
1256 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
1257
1258 typename T::value_type out = 0.0;
1259 if (execSpace0 == "Serial")
1260 {
1261 Nektar::Math::linfnorm<NektarSpaces::Serial>(mask, x, &out);
1262 }
1263#if defined(NEKTAR_ENABLE_SIMD)
1264 else if (execSpace0 == "AVX")
1265 {
1266 Nektar::Math::linfnorm<NektarSpaces::AVX>(mask, x, &out);
1267 }
1268#endif
1269#if defined(NEKTAR_ENABLE_DEVICE)
1270 else if (execSpace0 == "Device")
1271 {
1272 const unsigned int streamID = internalReductionStreamID;
1273 if (internalDeviceBuffer == nullptr)
1274 {
1275 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
1276 streamID);
1277 Nektar::hostMallocPinned(&internalHostBuffer,
1278 internalMaxDataSizeByte);
1280 }
1281 Nektar::Math::linfnorm<NektarSpaces::Device>(
1282 mask, x, (typename T::value_type *)internalDeviceBuffer);
1283 Nektar::deviceMemcpy<eDeviceToHost>(
1284 internalHostBuffer, internalDeviceBuffer,
1285 sizeof(typename T::value_type), streamID);
1286 out = *(typename T::value_type *)internalHostBuffer;
1287 }
1288#endif
1289 else
1290 {
1291 ASSERTL0(false, "Unknown Execution space: " + execSpace)
1292 }
1293
1294 return out;
1295}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ linfnorm() [2/4]

template<typename M , typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::linfnorm ( M &  mask,
T &  x,
const std::string &  execSpace = "" 
)

◆ linfnorm() [3/4]

template<typename T >
T::value_type Nektar::Math::MathHelper::linfnorm ( T &  x,
const std::string &  execSpace 
)

Definition at line 1209 of file MathHelperDef.hpp.

1210{
1211 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
1212
1213 typename T::value_type out = 0.0;
1214 if (execSpace0 == "Serial")
1215 {
1216 Nektar::Math::linfnorm<NektarSpaces::Serial>(x, &out);
1217 }
1218#if defined(NEKTAR_ENABLE_SIMD)
1219 else if (execSpace0 == "AVX")
1220 {
1221 Nektar::Math::linfnorm<NektarSpaces::AVX>(x, &out);
1222 }
1223#endif
1224#if defined(NEKTAR_ENABLE_DEVICE)
1225 else if (execSpace0 == "Device")
1226 {
1227 const unsigned int streamID = internalReductionStreamID;
1228 if (internalDeviceBuffer == nullptr)
1229 {
1230 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
1231 streamID);
1232 Nektar::hostMallocPinned(&internalHostBuffer,
1233 internalMaxDataSizeByte);
1235 }
1236 Nektar::Math::linfnorm<NektarSpaces::Device>(
1237 x, (typename T::value_type *)internalDeviceBuffer);
1238 Nektar::deviceMemcpy<eDeviceToHost>(
1239 internalHostBuffer, internalDeviceBuffer,
1240 sizeof(typename T::value_type), streamID);
1241 out = *(typename T::value_type *)internalHostBuffer;
1242 }
1243#endif
1244 else
1245 {
1246 ASSERTL0(false, "Unknown Execution space: " + execSpace)
1247 }
1248
1249 return out;
1250}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ linfnorm() [4/4]

template<typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::linfnorm ( T &  x,
const std::string &  execSpace = "" 
)

◆ mul() [1/4]

template<typename T >
void Nektar::Math::MathHelper::mul ( const typename T::value_type  alpha,
T &  x,
T &  y,
const std::string &  execSpace 
)

Definition at line 322 of file MathHelperDef.hpp.

324{
325 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
326
327 if (execSpace0 == "Serial")
328 {
329 Nektar::Math::mul<NektarSpaces::Serial>(alpha, x, y);
330 }
331#if defined(NEKTAR_ENABLE_SIMD)
332 else if (execSpace0 == "AVX")
333 {
334 Nektar::Math::mul<NektarSpaces::AVX>(alpha, x, y);
335 }
336#endif
337#if defined(NEKTAR_ENABLE_DEVICE)
338 else if (execSpace0 == "Device")
339 {
340 Nektar::Math::mul<NektarSpaces::Device>(alpha, x, y);
341 }
342#endif
343 else
344 {
345 ASSERTL0(false, "Unknown Execution space: " + execSpace)
346 }
347}

References ASSERTL0, and m_defaultExecSpace.

◆ mul() [2/4]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::mul ( const typename T::value_type  alpha,
T &  x,
T &  y,
const std::string &  execSpace = "" 
)

◆ mul() [3/4]

template<typename T >
void Nektar::Math::MathHelper::mul ( T &  x,
T &  y,
T &  z,
const std::string &  execSpace 
)

Definition at line 350 of file MathHelperDef.hpp.

351{
352 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
353
354 if (execSpace0 == "Serial")
355 {
356 Nektar::Math::mul<NektarSpaces::Serial>(x, y, z);
357 }
358#if defined(NEKTAR_ENABLE_SIMD)
359 else if (execSpace0 == "AVX")
360 {
361 Nektar::Math::mul<NektarSpaces::AVX>(x, y, z);
362 }
363#endif
364#if defined(NEKTAR_ENABLE_DEVICE)
365 else if (execSpace0 == "Device")
366 {
367 Nektar::Math::mul<NektarSpaces::Device>(x, y, z);
368 }
369#endif
370 else
371 {
372 ASSERTL0(false, "Unknown Execution space: " + execSpace)
373 }
374}

References ASSERTL0, and m_defaultExecSpace.

◆ mul() [4/4]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::mul ( T &  x,
T &  y,
T &  z,
const std::string &  execSpace = "" 
)

◆ neg() [1/2]

template<typename T >
void Nektar::Math::MathHelper::neg ( T &  x,
T &  y,
const std::string &  execSpace 
)

Definition at line 214 of file MathHelperDef.hpp.

215{
216 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
217
218 if (execSpace0 == "Serial")
219 {
220 Nektar::Math::neg<NektarSpaces::Serial>(x, y);
221 }
222#if defined(NEKTAR_ENABLE_SIMD)
223 else if (execSpace0 == "AVX")
224 {
225 Nektar::Math::neg<NektarSpaces::AVX>(x, y);
226 }
227#endif
228#if defined(NEKTAR_ENABLE_DEVICE)
229 else if (execSpace0 == "Device")
230 {
231 Nektar::Math::neg<NektarSpaces::Device>(x, y);
232 }
233#endif
234 else
235 {
236 ASSERTL0(false, "Unknown Execution space: " + execSpace)
237 }
238}

References ASSERTL0, and m_defaultExecSpace.

◆ neg() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::neg ( T &  x,
T &  y,
const std::string &  execSpace = "" 
)

◆ operator=()

Math::MathHelper & Nektar::Math::MathHelper::operator= ( const Math::MathHelper &  rhs)
inline

Definition at line 61 of file MathHelper.hpp.

62 {
63 m_defaultExecSpace = rhs.m_defaultExecSpace;
64 return *this;
65 }

References m_defaultExecSpace.

◆ reduceMax() [1/4]

template<typename M , typename T >
T::value_type Nektar::Math::MathHelper::reduceMax ( M &  mask,
T &  x,
const std::string &  execSpace 
)

Definition at line 715 of file MathHelperDef.hpp.

717{
718 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
719
720 typename T::value_type out = 0.0;
721 if (execSpace0 == "Serial")
722 {
723 Nektar::Math::reduceMax<NektarSpaces::Serial>(mask, x, &out);
724 }
725#if defined(NEKTAR_ENABLE_SIMD)
726 else if (execSpace0 == "AVX")
727 {
728 Nektar::Math::reduceMax<NektarSpaces::AVX>(mask, x, &out);
729 }
730#endif
731#if defined(NEKTAR_ENABLE_DEVICE)
732 else if (execSpace0 == "Device")
733 {
734 const unsigned int streamID = internalReductionStreamID;
735 if (internalDeviceBuffer == nullptr)
736 {
737 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
738 streamID);
739 Nektar::hostMallocPinned(&internalHostBuffer,
740 internalMaxDataSizeByte);
742 }
743 Nektar::Math::reduceMax<NektarSpaces::Device>(
744 mask, x, (typename T::value_type *)internalDeviceBuffer);
745 Nektar::deviceMemcpy<eDeviceToHost>(
746 internalHostBuffer, internalDeviceBuffer,
747 sizeof(typename T::value_type), streamID);
748 out = *(typename T::value_type *)internalHostBuffer;
749 }
750#endif
751 else
752 {
753 ASSERTL0(false, "Unknown Execution space: " + execSpace)
754 }
755
756 return out;
757}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ reduceMax() [2/4]

template<typename M , typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::reduceMax ( M &  mask,
T &  x,
const std::string &  execSpace = "" 
)

◆ reduceMax() [3/4]

template<typename T >
T::value_type Nektar::Math::MathHelper::reduceMax ( T &  x,
const std::string &  execSpace 
)

Definition at line 671 of file MathHelperDef.hpp.

672{
673 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
674
675 typename T::value_type out = 0.0;
676 if (execSpace0 == "Serial")
677 {
678 Nektar::Math::reduceMax<NektarSpaces::Serial>(x, &out);
679 }
680#if defined(NEKTAR_ENABLE_SIMD)
681 else if (execSpace0 == "AVX")
682 {
683 Nektar::Math::reduceMax<NektarSpaces::AVX>(x, &out);
684 }
685#endif
686#if defined(NEKTAR_ENABLE_DEVICE)
687 else if (execSpace0 == "Device")
688 {
689 const unsigned int streamID = internalReductionStreamID;
690 if (internalDeviceBuffer == nullptr)
691 {
692 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
693 streamID);
694 Nektar::hostMallocPinned(&internalHostBuffer,
695 internalMaxDataSizeByte);
697 }
698 Nektar::Math::reduceMax<NektarSpaces::Device>(
699 x, (typename T::value_type *)internalDeviceBuffer);
700 Nektar::deviceMemcpy<eDeviceToHost>(
701 internalHostBuffer, internalDeviceBuffer,
702 sizeof(typename T::value_type), streamID);
703 out = *(typename T::value_type *)internalHostBuffer;
704 }
705#endif
706 else
707 {
708 ASSERTL0(false, "Unknown Execution space: " + execSpace)
709 }
710
711 return out;
712}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ reduceMax() [4/4]

template<typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::reduceMax ( T &  x,
const std::string &  execSpace = "" 
)

◆ reduceMin() [1/4]

template<typename M , typename T >
T::value_type Nektar::Math::MathHelper::reduceMin ( M &  mask,
T &  x,
const std::string &  execSpace 
)

Definition at line 804 of file MathHelperDef.hpp.

806{
807 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
808
809 typename T::value_type out = 0.0;
810 if (execSpace0 == "Serial")
811 {
812 Nektar::Math::reduceMin<NektarSpaces::Serial>(mask, x, &out);
813 }
814#if defined(NEKTAR_ENABLE_SIMD)
815 else if (execSpace0 == "AVX")
816 {
817 Nektar::Math::reduceMin<NektarSpaces::AVX>(mask, x, &out);
818 }
819#endif
820#if defined(NEKTAR_ENABLE_DEVICE)
821 else if (execSpace0 == "Device")
822 {
823 const unsigned int streamID = internalReductionStreamID;
824 if (internalDeviceBuffer == nullptr)
825 {
826 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
827 streamID);
828 Nektar::hostMallocPinned(&internalHostBuffer,
829 internalMaxDataSizeByte);
831 }
832 Nektar::Math::reduceMin<NektarSpaces::Device>(
833 mask, x, (typename T::value_type *)internalDeviceBuffer);
834 Nektar::deviceMemcpy<eDeviceToHost>(
835 internalHostBuffer, internalDeviceBuffer,
836 sizeof(typename T::value_type), streamID);
837 out = *(typename T::value_type *)internalHostBuffer;
838 }
839#endif
840 else
841 {
842 ASSERTL0(false, "Unknown Execution space: " + execSpace)
843 }
844
845 return out;
846}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ reduceMin() [2/4]

template<typename M , typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::reduceMin ( M &  mask,
T &  x,
const std::string &  execSpace = "" 
)

◆ reduceMin() [3/4]

template<typename T >
T::value_type Nektar::Math::MathHelper::reduceMin ( T &  x,
const std::string &  execSpace 
)

Definition at line 760 of file MathHelperDef.hpp.

761{
762 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
763
764 typename T::value_type out = 0.0;
765 if (execSpace0 == "Serial")
766 {
767 Nektar::Math::reduceMin<NektarSpaces::Serial>(x, &out);
768 }
769#if defined(NEKTAR_ENABLE_SIMD)
770 else if (execSpace0 == "AVX")
771 {
772 Nektar::Math::reduceMin<NektarSpaces::AVX>(x, &out);
773 }
774#endif
775#if defined(NEKTAR_ENABLE_DEVICE)
776 else if (execSpace0 == "Device")
777 {
778 const unsigned int streamID = internalReductionStreamID;
779 if (internalDeviceBuffer == nullptr)
780 {
781 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
782 streamID);
783 Nektar::hostMallocPinned(&internalHostBuffer,
784 internalMaxDataSizeByte);
786 }
787 Nektar::Math::reduceMin<NektarSpaces::Device>(
788 x, (typename T::value_type *)internalDeviceBuffer);
789 Nektar::deviceMemcpy<eDeviceToHost>(
790 internalHostBuffer, internalDeviceBuffer,
791 sizeof(typename T::value_type), streamID);
792 out = *(typename T::value_type *)internalHostBuffer;
793 }
794#endif
795 else
796 {
797 ASSERTL0(false, "Unknown Execution space: " + execSpace)
798 }
799
800 return out;
801}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ reduceMin() [4/4]

template<typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::reduceMin ( T &  x,
const std::string &  execSpace = "" 
)

◆ reduceSum() [1/4]

template<typename M , typename T >
T::value_type Nektar::Math::MathHelper::reduceSum ( M &  mask,
T &  x,
const std::string &  execSpace 
)

Definition at line 626 of file MathHelperDef.hpp.

628{
629 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
630
631 typename T::value_type out = 0.0;
632 if (execSpace0 == "Serial")
633 {
634 Nektar::Math::reduceSum<NektarSpaces::Serial>(mask, x, &out);
635 }
636#if defined(NEKTAR_ENABLE_SIMD)
637 else if (execSpace0 == "AVX")
638 {
639 Nektar::Math::reduceSum<NektarSpaces::AVX>(mask, x, &out);
640 }
641#endif
642#if defined(NEKTAR_ENABLE_DEVICE)
643 else if (execSpace0 == "Device")
644 {
645 const unsigned int streamID = internalReductionStreamID;
646 if (internalDeviceBuffer == nullptr)
647 {
648 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
649 streamID);
650 Nektar::hostMallocPinned(&internalHostBuffer,
651 internalMaxDataSizeByte);
653 }
654 Nektar::Math::reduceSum<NektarSpaces::Device>(
655 mask, x, (typename T::value_type *)internalDeviceBuffer);
656 Nektar::deviceMemcpy<eDeviceToHost>(
657 internalHostBuffer, internalDeviceBuffer,
658 sizeof(typename T::value_type), streamID);
659 out = *(typename T::value_type *)internalHostBuffer;
660 }
661#endif
662 else
663 {
664 ASSERTL0(false, "Unknown Execution space: " + execSpace)
665 }
666
667 return out;
668}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ reduceSum() [2/4]

template<typename M , typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::reduceSum ( M &  mask,
T &  x,
const std::string &  execSpace = "" 
)

◆ reduceSum() [3/4]

template<typename T >
T::value_type Nektar::Math::MathHelper::reduceSum ( T &  x,
const std::string &  execSpace 
)

Definition at line 582 of file MathHelperDef.hpp.

583{
584 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
585
586 typename T::value_type out = 0.0;
587 if (execSpace0 == "Serial")
588 {
589 Nektar::Math::reduceSum<NektarSpaces::Serial>(x, &out);
590 }
591#if defined(NEKTAR_ENABLE_SIMD)
592 else if (execSpace0 == "AVX")
593 {
594 Nektar::Math::reduceSum<NektarSpaces::AVX>(x, &out);
595 }
596#endif
597#if defined(NEKTAR_ENABLE_DEVICE)
598 else if (execSpace0 == "Device")
599 {
600 const unsigned int streamID = internalReductionStreamID;
601 if (internalDeviceBuffer == nullptr)
602 {
603 Nektar::deviceMalloc(&internalDeviceBuffer, internalMaxDataSizeByte,
604 streamID);
605 Nektar::hostMallocPinned(&internalHostBuffer,
606 internalMaxDataSizeByte);
608 }
609 Nektar::Math::reduceSum<NektarSpaces::Device>(
610 x, (typename T::value_type *)internalDeviceBuffer);
611 Nektar::deviceMemcpy<eDeviceToHost>(
612 internalHostBuffer, internalDeviceBuffer,
613 sizeof(typename T::value_type), streamID);
614 out = *(typename T::value_type *)internalHostBuffer;
615 }
616#endif
617 else
618 {
619 ASSERTL0(false, "Unknown Execution space: " + execSpace)
620 }
621
622 return out;
623}

References ASSERTL0, Nektar::deviceMalloc(), Nektar::hostMallocPinned(), Nektar::Math::internalReductionStreamID, m_defaultExecSpace, and Nektar::nekStreamSynchronize().

◆ reduceSum() [4/4]

template<typename T >
LIB_MATH_EXPORT T::value_type Nektar::Math::MathHelper::reduceSum ( T &  x,
const std::string &  execSpace = "" 
)

◆ sqrt() [1/2]

template<typename T >
void Nektar::Math::MathHelper::sqrt ( T &  x,
T &  y,
const std::string &  execSpace 
)

Definition at line 241 of file MathHelperDef.hpp.

242{
243 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
244
245 if (execSpace0 == "Serial")
246 {
247 Nektar::Math::sqrt<NektarSpaces::Serial>(x, y);
248 }
249#if defined(NEKTAR_ENABLE_SIMD)
250 else if (execSpace0 == "AVX")
251 {
252 Nektar::Math::sqrt<NektarSpaces::AVX>(x, y);
253 }
254#endif
255#if defined(NEKTAR_ENABLE_DEVICE)
256 else if (execSpace0 == "Device")
257 {
258 Nektar::Math::sqrt<NektarSpaces::Device>(x, y);
259 }
260#endif
261 else
262 {
263 ASSERTL0(false, "Unknown Execution space: " + execSpace)
264 }
265}

References ASSERTL0, and m_defaultExecSpace.

◆ sqrt() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::sqrt ( T &  x,
T &  y,
const std::string &  execSpace = "" 
)

◆ sub() [1/2]

template<typename T >
void Nektar::Math::MathHelper::sub ( T &  x,
T &  y,
T &  z,
const std::string &  execSpace 
)

Definition at line 295 of file MathHelperDef.hpp.

296{
297 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
298
299 if (execSpace0 == "Serial")
300 {
301 Nektar::Math::sub<NektarSpaces::Serial>(x, y, z);
302 }
303#if defined(NEKTAR_ENABLE_SIMD)
304 else if (execSpace0 == "AVX")
305 {
306 Nektar::Math::sub<NektarSpaces::AVX>(x, y, z);
307 }
308#endif
309#if defined(NEKTAR_ENABLE_DEVICE)
310 else if (execSpace0 == "Device")
311 {
312 Nektar::Math::sub<NektarSpaces::Device>(x, y, z);
313 }
314#endif
315 else
316 {
317 ASSERTL0(false, "Unknown Execution space: " + execSpace)
318 }
319}

References ASSERTL0, and m_defaultExecSpace.

◆ sub() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::sub ( T &  x,
T &  y,
T &  z,
const std::string &  execSpace = "" 
)

◆ zero() [1/2]

template<typename T >
void Nektar::Math::MathHelper::zero ( T &  x,
const std::string &  execSpace 
)

Definition at line 46 of file MathHelperDef.hpp.

47{
48 auto execSpace0 = execSpace == "" ? m_defaultExecSpace : execSpace;
49
50 if (execSpace0 == "Serial")
51 {
52 Nektar::Math::zero<NektarSpaces::Serial>(x);
53 }
54#if defined(NEKTAR_ENABLE_SIMD)
55 else if (execSpace0 == "AVX")
56 {
57 Nektar::Math::zero<NektarSpaces::AVX>(x);
58 }
59#endif
60#if defined(NEKTAR_ENABLE_DEVICE)
61 else if (execSpace0 == "Device")
62 {
63 Nektar::Math::zero<NektarSpaces::Device>(x);
64 }
65#endif
66 else
67 {
68 ASSERTL0(false, "Unknown Execution space: " + execSpace)
69 }
70}

References ASSERTL0, and m_defaultExecSpace.

◆ zero() [2/2]

template<typename T >
LIB_MATH_EXPORT void Nektar::Math::MathHelper::zero ( T &  x,
const std::string &  execSpace = "" 
)

Member Data Documentation

◆ m_defaultExecSpace

std::string Nektar::Math::MathHelper::m_defaultExecSpace
private