96#if defined(NEKTAR_ENABLE_DEVICE) && defined(DEVICE_COMPILE_ONLY)
116 typename TSizeParameter1D,
117 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
118 IsSizeParameter1D_v<TSizeParameter1D>,
121inline constexpr size_t MassWorkSpaceSize(
const size_t nelmt,
122 const TSizeParameter1D sizeParam1D)
126 const unsigned int nq0 = sizeParam1D.nq0();
130 wspsize = nq0 *
nelmt;
160 typename TSizeParameter2D,
161 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
162 IsSizeParameter2D_v<TSizeParameter2D>,
165inline constexpr size_t MassWorkSpaceSize(
const size_t nelmt,
166 const TSizeParameter2D sizeParam2D)
170 const unsigned int nm0 = sizeParam2D.nm0();
171 const unsigned int nq1 = sizeParam2D.nq1();
175 wspsize = (sizeParam2D.nqTot() + nq1) *
nelmt;
179 wspsize = (sizeParam2D.nqTot() + std::max(nq1,
nm0)) *
nelmt;
183 const unsigned int nmTot = sizeParam2D.nmTot();
185 wspsize = (sizeParam2D.nqTot() + std::max(nq1,
nm0) +
nmTot) *
nelmt;
217 typename TSizeParameter3D,
218 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
219 IsSizeParameter3D_v<TSizeParameter3D>,
222inline constexpr size_t MassWorkSpaceSize(
const size_t nelmt,
223 const TSizeParameter3D sizeParam3D)
227 const unsigned int nm0 = sizeParam3D.nm0();
228 const unsigned int nm1 = sizeParam3D.nm1();
229 const unsigned int nq1 = sizeParam3D.nq1();
230 const unsigned int nq2 = sizeParam3D.nq2();
234 wspsize = (sizeParam3D.nqTot() + nq1 * nq2 + nq2) *
nelmt;
238 const unsigned int nm01 = (2u *
nm1 -
nm0 + 1u) *
nm0 / 2u;
240 wspsize = (sizeParam3D.nqTot() + std::max(nq1 * nq2, nm01) +
241 std::max(nq2,
nm0)) *
246 const unsigned int nmTot = sizeParam3D.nmTot();
247 const unsigned int nm01 = (2u *
nm1 -
nm0 + 1u) *
nm0 / 2u;
249 wspsize = (sizeParam3D.nqTot() + std::max(nq1 * nq2, nm01) +
255 wspsize = (sizeParam3D.nqTot() + std::max(nq1 * nq2,
nm0 *
nm1) +
256 std::max(nq2,
nm0)) *
261 const unsigned int nmTot = sizeParam3D.nmTot();
263 wspsize = (sizeParam3D.nqTot() + std::max(nq1 * nq2,
nm0 *
nm1) +
269 wspsize = (sizeParam3D.nqTot() + std::max(nq1 * nq2,
nm0 *
nm1) +
270 std::max(nq2,
nm0)) *
275 const unsigned int nmTot = sizeParam3D.nmTot();
277 wspsize = (sizeParam3D.nqTot() + std::max(nq1 * nq2,
nm0 *
nm1) +
308 typename TData,
typename TSizeParameter1D,
309 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
310 IsSizeParameter1D_v<TSizeParameter1D>,
313inline constexpr unsigned int MassSharedMemorySize(
314 const TSizeParameter1D sizeParam1D,
const unsigned int elmtsPerBlock,
318 ?
static_cast<unsigned int>(
319 MassWorkSpaceSize<SHAPE_TYPE, Implementation>(
327 typename TData,
typename TSizeParameter2D,
328 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
329 IsSizeParameter2D_v<TSizeParameter2D>,
332inline constexpr unsigned int MassSharedMemorySize(
333 const TSizeParameter2D sizeParam2D,
const unsigned int elmtsPerBlock,
337 ?
static_cast<unsigned int>(
338 MassWorkSpaceSize<SHAPE_TYPE, Implementation>(
346 typename TData,
typename TSizeParameter3D,
347 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
348 IsSizeParameter3D_v<TSizeParameter3D>,
351inline constexpr unsigned int MassSharedMemorySize(
352 const TSizeParameter3D sizeParam3D,
const unsigned int elmtsPerBlock,
356 ?
static_cast<unsigned int>(
357 MassWorkSpaceSize<SHAPE_TYPE, Implementation>(
417 bool SCALE,
bool APPEND,
bool DEFORMED,
typename TSizeParameter1D,
418 typename TthreadBlock,
typename TData,
typename TUseSharedWsp,
419 std::enable_if_t<std::is_same_v<Implementation, SumFac>,
bool>
422 (GetMaxThreadPerBlock<Implementation, TSizeParameter1D>()))
425 [[maybe_unused]] const
bool isModified,
435 static_assert(IsSizeParameter1D_v<TSizeParameter1D>,
436 "Template argument must be either of type "
437 "NonTemplatedSizeParameter1D or TemplatedSizeParameter1D.");
441 const unsigned int nm0 = sizeParam1D.nm0();
442 const unsigned int nq0 = sizeParam1D.nq0();
444 const unsigned int jacsize = DEFORMED ? nq0 : 1u;
453 TData *wspbase = isShared ? (TData *)
shmemptr :
wsp;
458 const TData *jacptr =
463 const size_t wspOffset =
465 TData *wspptr = wspbase + nq0 * wspOffset;
466 BwdTransSegSumFacKernel<false>(ilane,
nm0, nq0, basis0, inptr,
468 IProductWRTBaseSegSumFacKernel<SCALE, APPEND, DEFORMED>(
469 ilane,
nm0, nq0, basis0, w0, jacptr, wspptr, outptr, scale);
537 bool SCALE,
bool APPEND,
bool DEFORMED,
typename TSizeParameter2D,
538 typename TthreadBlock,
typename TData,
typename TUseSharedWsp,
539 std::enable_if_t<std::is_same_v<Implementation, SumFac>,
bool>
542 (GetMaxThreadPerBlock<Implementation, TSizeParameter2D>()))
544 const TSizeParameter2D sizeParam2D, const
size_t nelmt,
547 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index0,
555 static_assert(IsSizeParameter2D_v<TSizeParameter2D>,
556 "Template argument must be either of type "
557 "NonTemplatedSizeParameter2D or TemplatedSizeParameter2D.");
563 const unsigned int nm0 = sizeParam2D.nm0();
564 const unsigned int nm1 = sizeParam2D.nm1();
565 const unsigned int nmTot = sizeParam2D.nmTot();
566 const unsigned int nq0 = sizeParam2D.nq0();
567 const unsigned int nq1 = sizeParam2D.nq1();
568 const unsigned int nqTot = sizeParam2D.nqTot();
570 const unsigned int jacsize = DEFORMED ? nqTot : 1u;
587 const unsigned int ncomp = getBlockRange<1>(
threadBlock);
591 TData *wspbase = isShared ? (TData *)
shmemptr :
wsp;
597 const TData *jacptr =
602 const size_t wspOffset =
604 TData *bwd = wspbase + nqTot * wspOffset;
605 TData *modal = wspbase + nqTot * wspNelmt +
nmTot * wspOffset;
606 TData *wsp0 = wspbase +
607 (nqTot + (isNodal ?
nmTot : 0u)) * wspNelmt +
610 if constexpr (isNodal)
615 BwdTrans2DSumFacKernel<SHAPE_TYPE, false>(
616 ilane,
nm0,
nm1, nq0, nq1, isModified, basis0, basis1,
617 isNodal ? modal : inptr, bwd, wsp0);
619 IProductWRTBase2DSumFacKernel<SHAPE_TYPE, SCALE, APPEND && !isNodal,
621 ilane,
nm0,
nm1, nq0, nq1, isModified, basis0, basis1, w0, w1,
622 jacptr, bwd, isNodal ? modal : outptr, wsp0, scale);
624 if constexpr (isNodal)
627 MatVecKernel<APPEND, true>(ilane,
nmTot, nodToMod, modal,
707 bool SCALE,
bool APPEND,
bool DEFORMED,
typename TSizeParameter3D,
708 typename TthreadBlock,
typename TData,
typename TUseSharedWsp,
709 std::enable_if_t<std::is_same_v<Implementation, SumFac>,
bool>
712 (GetMaxThreadPerBlock<Implementation, TSizeParameter3D>()))
714 const TSizeParameter3D sizeParam3D, const
size_t nelmt,
717 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index0,
718 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index1,
719 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index2,
720 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index3,
729 static_assert(IsSizeParameter3D_v<TSizeParameter3D>,
730 "Template argument must be either of type "
731 "NonTemplatedSizeParameter3D or TemplatedSizeParameter3D.");
739 const unsigned int nm0 = sizeParam3D.nm0();
740 const unsigned int nm1 = sizeParam3D.nm1();
741 const unsigned int nm2 = sizeParam3D.nm2();
742 const unsigned int nmTot = sizeParam3D.nmTot();
743 const unsigned int nq0 = sizeParam3D.nq0();
744 const unsigned int nq1 = sizeParam3D.nq1();
745 const unsigned int nq2 = sizeParam3D.nq2();
746 const unsigned int nqTot = sizeParam3D.nqTot();
748 const unsigned int jacsize = DEFORMED ? nqTot : 1u;
775 const unsigned int ncomp = getBlockRange<1>(
threadBlock);
779 TData *wspbase = isShared ? (TData *)
shmemptr :
wsp;
785 const TData *jacptr =
790 const size_t wspOffset =
792 TData *bwd = wspbase + nqTot * wspOffset;
793 TData *modal = wspbase + nqTot * wspNelmt +
nmTot * wspOffset;
794 TData *wsp0 = wspbase +
795 (nqTot + (isNodal ?
nmTot : 0u)) * wspNelmt +
802 if constexpr (isNodal)
807 BwdTrans3DSumFacKernel<SHAPE_TYPE, false>(
808 ilane,
nm0,
nm1,
nm2, nq0, nq1, nq2, isModified, basis0, basis1,
809 basis2, isNodal ? modal : inptr, bwd, wsp0, wsp1);
811 IProductWRTBase3DSumFacKernel<SHAPE_TYPE, SCALE, APPEND && !isNodal,
813 ilane,
nm0,
nm1,
nm2, nq0, nq1, nq2, isModified, basis0, basis1,
814 basis2, w0, w1, w2, jacptr, bwd, isNodal ? modal : outptr, wsp0,
817 if constexpr (isNodal)
820 MatVecKernel<APPEND, true>(ilane,
nmTot, nodToMod, modal,
#define NEK_DEVICE_KERNEL
Device SumFac kernels of the backward transform: one element per thread, with the sum-factorisation i...
Device SumFac kernels of the inner product with the basis: one element per thread,...
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 const bool const bool unsigned char const TthreadBlock & threadBlock
NEK_DEVICE_KERNEL void __LAUNCH_BOUNDS__((GetMaxThreadPerBlock< Implementation, TTraceSizeParameter1D >())) IProductWRTPhysNormalDerivTraceKernelLauncher(const TTraceSizeParameter1D sizeParam1D
The one-dimensional lift: over a segment's two vertices, one lane per element.
constexpr unsigned int warpsize
static NEK_FORCE_INLINE void MassKernelLauncher(const TSizeParameter1D sizeParam1D, const bool isModified, const typename simd_type::scalarType *basis0, const typename simd_type::scalarType *w0, const simd_type *NtoM, const simd_type *NtoMTrans, const simd_type *jac, simd_type *bwd, const simd_type *in, simd_type *out, typename simd_type::scalarType scale=1.0)
1D launcher: backward transform then inner product with the basis for one element group of segments.
FETCH_SHARED_MEMORY(shmemptr)
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 useSharedMemoryWsp
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 in
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 const bool const bool unsigned char * shmemptr
DispatchWorkSpace(useSharedMemoryWsp, [&](const auto isShared) { TData *wspbase=isShared ?(TData *) shmemptr+tableSize :wsp;while(e< nelmt) { const size_t ilane=e % warpsize;const size_t iwarp=e/warpsize;const TData *inptr=in+numDataIn *(nelmt *c+warpsize *iwarp);TData *outptr=out+numDataOut *(nelmt *c+warpsize *iwarp);const size_t wspOffset=isShared ? 0 :nelmt *c+warpsize *iwarp;TData *wspptr=wspbase+(edgeSize+numDataOut) *wspOffset;TData *volptr=wspptr+edgeSize *warpsize;const unsigned int off1=warpsize *2 *tnq00;const unsigned int joff1=(DEFORMED) ? off1 :warpsize *2;for(unsigned int d=0;d< 2;++d) { const bool useD1=CompNeedsCollapsedFac(SHAPE_TYPE, d, 1);const TData *jacptr=jac+d *jacCompStride+numDataJac *warpsize *iwarp;if(!(append||d > 0)) { for(unsigned int p=0;p< numDataOut;++p) { outptr[warpsize *p+ilane]=0.0;} } { TData *dst=useD1 ? volptr :outptr;if(useD1) { for(unsigned int p=0;p< numDataOut;++p) { dst[warpsize *p+ilane]=0.0;} } const TData *nb=(0==d) ? dnbasis0 :nbasis0;const TData *tb=(traceDir0==d) ? dtbasis0 :tbasis0;const bool coll=(traceDir0==d) ? false :isColl0;const bool endp=(0==d) ? false :endPtsColl0;if(endp) { IPWRTPhysTraceEdgeN0Kernel< true, DEFORMED >(ilane, 0, 2, 2, nm0, nm1, nb, tnq00, tb, tw0, jacptr, wspptr, inptr, dst, coll);} else { IPWRTPhysTraceEdgeN0Kernel< false, DEFORMED >(ilane, 0, 2, 2, nm0, nm1, nb, tnq00, tb, tw0, jacptr, wspptr, inptr, dst, coll);} if(useD1) { ScaleAddCollapsedFacKernel(ilane, nm0, nm1, 1u, true, false, s_twoOver1, s_twoOver1, volptr, outptr);} } { const TData *nb=(1==d) ? dnbasis1 :nbasis1;const TData *tb=(traceDir1==d) ? dtbasis1 :tbasis1;const bool coll=(traceDir1==d) ? false :isColl1;const bool endp=(1==d) ? false :endPtsColl1;if(endp) { IPWRTPhysTraceEdgeN1Kernel< true, DEFORMED >(ilane, 0, nedgeN1, nedgeN1, nm0, nm1, nb, tnq10, tb, tw1, jacptr+joff1, wspptr, inptr+off1, outptr, coll);} else { IPWRTPhysTraceEdgeN1Kernel< false, DEFORMED >(ilane, 0, nedgeN1, nedgeN1, nm0, nm1, nb, tnq10, tb, tw1, jacptr+joff1, wspptr, inptr+off1, outptr, coll);} } } e+=getGlobalRange< 0 >(threadBlock);} })
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int elmtsPerBlock
const unsigned int wsp1Size
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 wsp
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 jac
const unsigned int wsp0Size
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t nelmt
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 NEK_FORCE_INLINE void MatVecKernel(const unsigned int n, const simd_type *Mat, const simd_type *in, simd_type *out)
static constexpr unsigned int warpSize