72#if defined(NEKTAR_ENABLE_DEVICE) && defined(DEVICE_COMPILE_ONLY)
79 typename TSizeParameter1D,
80 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
81 IsSizeParameter1D_v<TSizeParameter1D>,
84inline constexpr size_t HelmholtzWorkSpaceSize(
85 const size_t nelmt,
const unsigned int ncoord,
86 const TSizeParameter1D sizeParam1D)
90 const unsigned int nq0 = sizeParam1D.nq0();
94 wspsize = (1 + ncoord) * nq0 *
nelmt;
105 typename TSizeParameter2D,
106 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
107 IsSizeParameter2D_v<TSizeParameter2D>,
110inline constexpr size_t HelmholtzWorkSpaceSize(
111 const size_t nelmt,
const unsigned int ncoord,
112 const TSizeParameter2D sizeParam2D)
116 const unsigned int nm0 = sizeParam2D.nm0();
117 const unsigned int nq1 = sizeParam2D.nq1();
121 wspsize = ((1 + ncoord) * sizeParam2D.nqTot() + nq1) *
nelmt;
126 ((1 + ncoord) * sizeParam2D.nqTot() + std::max(nq1,
nm0)) *
nelmt;
130 const unsigned int nmTot = sizeParam2D.nmTot();
133 ((1 + ncoord) * sizeParam2D.nqTot() + std::max(nq1,
nm0) +
nmTot) *
145 typename TSizeParameter3D,
146 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
147 IsSizeParameter3D_v<TSizeParameter3D>,
150inline constexpr size_t HelmholtzWorkSpaceSize(
151 const size_t nelmt, [[maybe_unused]]
const unsigned int ncoord,
152 const TSizeParameter3D sizeParam3D)
156 const unsigned int nm0 = sizeParam3D.nm0();
157 const unsigned int nm1 = sizeParam3D.nm1();
158 const unsigned int nq1 = sizeParam3D.nq1();
159 const unsigned int nq2 = sizeParam3D.nq2();
163 wspsize = (4 * sizeParam3D.nqTot() + nq1 * nq2 + nq2) *
nelmt;
168 (4 * sizeParam3D.nqTot() + nq1 * nq2 + std::max(nq2,
nm0)) *
nelmt;
172 const unsigned int nmTot = sizeParam3D.nmTot();
175 (4 * sizeParam3D.nqTot() + nq1 * nq2 + std::max(nq2,
nm0) +
nmTot) *
180 wspsize = (4 * sizeParam3D.nqTot() + std::max(nq1 * nq2,
nm0 *
nm1) +
181 std::max(nq2,
nm0)) *
186 const unsigned int nmTot = sizeParam3D.nmTot();
188 wspsize = (4 * sizeParam3D.nqTot() + std::max(nq1 * nq2,
nm0 *
nm1) +
194 wspsize = (4 * sizeParam3D.nqTot() + std::max(nq1 * nq2,
nm0 *
nm1) +
195 std::max(nq2,
nm0)) *
200 const unsigned int nmTot = sizeParam3D.nmTot();
202 wspsize = (4 * sizeParam3D.nqTot() + std::max(nq1 * nq2,
nm0 *
nm1) +
219 typename TData,
typename TSizeParameter1D,
220 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
221 IsSizeParameter1D_v<TSizeParameter1D>,
224inline constexpr unsigned int HelmholtzSharedMemorySize(
225 const unsigned int ncoord,
const TSizeParameter1D sizeParam1D,
229 ?
static_cast<unsigned int>(
230 HelmholtzWorkSpaceSize<SHAPE_TYPE, Implementation>(
241 typename TData,
typename TSizeParameter2D,
242 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
243 IsSizeParameter2D_v<TSizeParameter2D>,
246inline constexpr unsigned int HelmholtzSharedMemorySize(
247 const unsigned int ncoord,
const TSizeParameter2D sizeParam2D,
250 const unsigned int wspSize =
252 ?
static_cast<unsigned int>(
253 HelmholtzWorkSpaceSize<SHAPE_TYPE, Implementation>(
264 const unsigned int nq0 = sizeParam2D.nq0();
265 const unsigned int nq1 = sizeParam2D.nq1();
267 return nq0 + nq1 + wspSize;
277 typename TData,
typename TSizeParameter3D,
278 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
279 IsSizeParameter3D_v<TSizeParameter3D>,
282inline constexpr unsigned int HelmholtzSharedMemorySize(
283 const unsigned int ncoord,
const TSizeParameter3D sizeParam3D,
286 const unsigned int nq0 = sizeParam3D.nq0();
287 const unsigned int nq1 = sizeParam3D.nq1();
288 const unsigned int nq2 = sizeParam3D.nq2();
290 const unsigned int wspSize =
292 ?
static_cast<unsigned int>(
293 HelmholtzWorkSpaceSize<SHAPE_TYPE, Implementation>(
304 return nq0 + 2 * nq1 + nq2 + wspSize;
309 return nq0 + nq2 + wspSize;
314 return nq0 + nq1 + nq2 + wspSize;
322template <
bool DEFORMED,
bool VARCOEFF,
typename TData>
324 const unsigned int ilane,
const unsigned int ncoord,
const unsigned int nq0,
327 const TData *
NEK_RESTRICT diffCoeff,
const size_t varDiffCoeffSize,
331 const size_t diffCoeffStride = VARCOEFF ? varDiffCoeffSize : 1;
334 TData metric[3] = {0.0};
335 if constexpr (!DEFORMED && !VARCOEFF)
341 metric[0] = diffCoeff[0] * df[ilane];
343 else if (ncoord == 2)
345 metric[0] = diffCoeff[0] * df[ilane] +
346 diffCoeff[1] * df[
warpsize + ilane];
347 metric[1] = diffCoeff[1] * df[ilane] +
348 diffCoeff[2] * df[
warpsize + ilane];
350 else if (ncoord == 3)
352 metric[0] = diffCoeff[0] * df[ilane] +
353 diffCoeff[1] * df[
warpsize + ilane] +
354 diffCoeff[3] * df[2 *
warpsize + ilane];
355 metric[1] = diffCoeff[1] * df[ilane] +
356 diffCoeff[2] * df[
warpsize + ilane] +
357 diffCoeff[4] * df[2 *
warpsize + ilane];
358 metric[2] = diffCoeff[3] * df[ilane] +
359 diffCoeff[4] * df[
warpsize + ilane] +
360 diffCoeff[5] * df[2 *
warpsize + ilane];
365 for (
unsigned int i = 0u; i < nq0; ++i)
367 const unsigned int index =
warpsize * i + ilane;
368 const unsigned int dfindex =
369 DEFORMED ? ncoord *
warpsize * i + ilane : ilane;
371 if constexpr (DEFORMED || VARCOEFF)
373 const size_t diffCoeffIndex = VARCOEFF ? index : 0;
378 metric[0] = diffCoeff[diffCoeffIndex] * df[dfindex];
380 else if (ncoord == 2)
382 metric[0] = diffCoeff[diffCoeffIndex] * df[dfindex] +
383 diffCoeff[diffCoeffStride + diffCoeffIndex] *
386 diffCoeff[diffCoeffStride + diffCoeffIndex] *
388 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
391 else if (ncoord == 3)
394 diffCoeff[diffCoeffIndex] * df[dfindex] +
395 diffCoeff[diffCoeffStride + diffCoeffIndex] *
397 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
400 diffCoeff[diffCoeffStride + diffCoeffIndex] *
402 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
404 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
407 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
409 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
411 diffCoeff[5 * diffCoeffStride + diffCoeffIndex] *
418 for (
unsigned int k = 0u; k < ncoord; ++k)
422 sum += metric[k] *
in[k * inoffset + index];
426 sum += df[k *
warpsize + dfindex] *
in[k * inoffset + index];
430 if constexpr (DEFORMED)
432 bwd[index] *= lambda *
jac[index] * w0[i];
437 bwd[index] *= lambda *
jac[0] * w0[i];
450 const unsigned int ilane,
const unsigned int ncoord,
const unsigned int nq0,
451 const unsigned int nq1,
const size_t inoffset,
const TData *
NEK_RESTRICT w0,
459 const size_t diffCoeffStride = VARCOEFF ? varDiffCoeffSize : 1;
462 const unsigned int ndf = 2 * ncoord;
464 TData metric[6] = {0.0};
465 if constexpr (!DEFORMED && !VARCOEFF)
471 metric[0] = diffCoeff[0] * df[ilane] +
472 diffCoeff[1] * df[2 *
warpsize + ilane];
473 metric[1] = diffCoeff[0] * df[1 *
warpsize + ilane] +
474 diffCoeff[1] * df[3 *
warpsize + ilane];
475 metric[2] = diffCoeff[1] * df[ilane] +
476 diffCoeff[2] * df[2 *
warpsize + ilane];
477 metric[3] = diffCoeff[1] * df[1 *
warpsize + ilane] +
478 diffCoeff[2] * df[3 *
warpsize + ilane];
480 else if (ncoord == 3)
482 metric[0] = diffCoeff[0] * df[ilane] +
483 diffCoeff[1] * df[2 *
warpsize + ilane] +
484 diffCoeff[3] * df[4 *
warpsize + ilane];
485 metric[1] = diffCoeff[0] * df[1 *
warpsize + ilane] +
486 diffCoeff[1] * df[3 *
warpsize + ilane] +
487 diffCoeff[3] * df[5 *
warpsize + ilane];
488 metric[2] = diffCoeff[1] * df[ilane] +
489 diffCoeff[2] * df[2 *
warpsize + ilane] +
490 diffCoeff[4] * df[4 *
warpsize + ilane];
491 metric[3] = diffCoeff[1] * df[1 *
warpsize + ilane] +
492 diffCoeff[2] * df[3 *
warpsize + ilane] +
493 diffCoeff[4] * df[5 *
warpsize + ilane];
494 metric[4] = diffCoeff[3] * df[ilane] +
495 diffCoeff[4] * df[2 *
warpsize + ilane] +
496 diffCoeff[5] * df[4 *
warpsize + ilane];
497 metric[5] = diffCoeff[3] * df[1 *
warpsize + ilane] +
498 diffCoeff[4] * df[3 *
warpsize + ilane] +
499 diffCoeff[5] * df[5 *
warpsize + ilane];
504 for (
unsigned int j = 0u, cnt_ji = 0u; j < nq1; ++j)
506 for (
unsigned int i = 0u; i < nq0; ++i, ++cnt_ji)
508 const unsigned int index =
warpsize * cnt_ji + ilane;
509 const unsigned int dfindex =
510 DEFORMED ? ndf *
warpsize * cnt_ji + ilane : ilane;
512 if constexpr (DEFORMED || VARCOEFF)
514 const size_t diffCoeffIndex = VARCOEFF ? index : 0;
520 diffCoeff[diffCoeffIndex] * df[dfindex] +
521 diffCoeff[diffCoeffStride + diffCoeffIndex] *
524 diffCoeff[diffCoeffIndex] *
526 diffCoeff[diffCoeffStride + diffCoeffIndex] *
529 diffCoeff[diffCoeffStride + diffCoeffIndex] *
531 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
534 diffCoeff[diffCoeffStride + diffCoeffIndex] *
536 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
539 else if (ncoord == 3)
542 diffCoeff[diffCoeffIndex] * df[dfindex] +
543 diffCoeff[diffCoeffStride + diffCoeffIndex] *
545 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
548 diffCoeff[diffCoeffIndex] *
550 diffCoeff[diffCoeffStride + diffCoeffIndex] *
552 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
555 diffCoeff[diffCoeffStride + diffCoeffIndex] *
557 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
559 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
562 diffCoeff[diffCoeffStride + diffCoeffIndex] *
564 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
566 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
569 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
571 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
573 diffCoeff[5 * diffCoeffStride + diffCoeffIndex] *
576 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
578 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
580 diffCoeff[5 * diffCoeffStride + diffCoeffIndex] *
586 TData sum1 = 0.0, sum2 = 0.0;
589 TData tmp =
in[index];
590 sum1 += metric[0u] * tmp;
591 sum2 += metric[1u] * tmp;
592 tmp =
in[inoffset + index];
593 sum1 += metric[2u] * tmp;
594 sum2 += metric[3u] * tmp;
597 tmp =
in[2u * inoffset + index];
598 sum1 += metric[4u] * tmp;
599 sum2 += metric[5u] * tmp;
604 TData tmp =
in[index];
605 sum1 += df[0u *
warpsize + dfindex] * tmp;
606 sum2 += df[1u *
warpsize + dfindex] * tmp;
607 tmp =
in[inoffset + index];
608 sum1 += df[2u *
warpsize + dfindex] * tmp;
609 sum2 += df[3u *
warpsize + dfindex] * tmp;
612 tmp =
in[2u * inoffset + index];
613 sum1 += df[4u *
warpsize + dfindex] * tmp;
614 sum2 += df[5u *
warpsize + dfindex] * tmp;
618 TData tmpQ = w0[i] * w1[j];
619 if constexpr (DEFORMED)
628 bwd[index] *= lambda * tmpQ;
633 out0[index] = sum1 * tmpQ;
634 out1[index] = sum2 * tmpQ;
639 out0[index] = (sum1 + sum2 * f0[i]) * f1[j] * tmpQ;
640 out1[index] = sum2 * tmpQ;
653 const unsigned int ilane,
const unsigned int nq0,
const unsigned int nq1,
654 const unsigned int nq2,
const size_t inoffset,
const TData *
NEK_RESTRICT w0,
665 const size_t diffCoeffStride = VARCOEFF ? varDiffCoeffSize : 1;
668 constexpr unsigned int ndf = 9u;
670 TData metric[9] = {0.0};
671 if constexpr (!DEFORMED && !VARCOEFF)
675 metric[0] = diffCoeff[0] * df[ilane] +
676 diffCoeff[1] * df[3 *
warpsize + ilane] +
677 diffCoeff[3] * df[6 *
warpsize + ilane];
678 metric[1] = diffCoeff[0] * df[1 *
warpsize + ilane] +
679 diffCoeff[1] * df[4 *
warpsize + ilane] +
680 diffCoeff[3] * df[7 *
warpsize + ilane];
681 metric[2] = diffCoeff[0] * df[2 *
warpsize + ilane] +
682 diffCoeff[1] * df[5 *
warpsize + ilane] +
683 diffCoeff[3] * df[8 *
warpsize + ilane];
684 metric[3] = diffCoeff[1] * df[ilane] +
685 diffCoeff[2] * df[3 *
warpsize + ilane] +
686 diffCoeff[4] * df[6 *
warpsize + ilane];
687 metric[4] = diffCoeff[1] * df[1 *
warpsize + ilane] +
688 diffCoeff[2] * df[4 *
warpsize + ilane] +
689 diffCoeff[4] * df[7 *
warpsize + ilane];
690 metric[5] = diffCoeff[1] * df[2 *
warpsize + ilane] +
691 diffCoeff[2] * df[5 *
warpsize + ilane] +
692 diffCoeff[4] * df[8 *
warpsize + ilane];
693 metric[6] = diffCoeff[3] * df[ilane] +
694 diffCoeff[4] * df[3 *
warpsize + ilane] +
695 diffCoeff[5] * df[6 *
warpsize + ilane];
696 metric[7] = diffCoeff[3] * df[1 *
warpsize + ilane] +
697 diffCoeff[4] * df[4 *
warpsize + ilane] +
698 diffCoeff[5] * df[7 *
warpsize + ilane];
699 metric[8] = diffCoeff[3] * df[2 *
warpsize + ilane] +
700 diffCoeff[4] * df[5 *
warpsize + ilane] +
701 diffCoeff[5] * df[8 *
warpsize + ilane];
705 for (
unsigned int k = 0u, cnt_kji = 0u; k < nq2; ++k)
707 for (
unsigned int j = 0u; j < nq1; ++j)
709 for (
unsigned int i = 0u; i < nq0; ++i, ++cnt_kji)
711 const unsigned int index =
warpsize * cnt_kji + ilane;
712 const unsigned int dfindex =
713 DEFORMED ? ndf *
warpsize * cnt_kji + ilane : ilane;
715 if constexpr (DEFORMED || VARCOEFF)
717 const size_t diffCoeffIndex = VARCOEFF ? index : 0;
721 diffCoeff[diffCoeffIndex] * df[dfindex] +
722 diffCoeff[diffCoeffStride + diffCoeffIndex] *
724 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
727 diffCoeff[diffCoeffIndex] *
729 diffCoeff[diffCoeffStride + diffCoeffIndex] *
731 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
734 diffCoeff[diffCoeffIndex] *
736 diffCoeff[diffCoeffStride + diffCoeffIndex] *
738 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
741 diffCoeff[diffCoeffStride + diffCoeffIndex] *
743 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
745 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
748 diffCoeff[diffCoeffStride + diffCoeffIndex] *
750 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
752 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
755 diffCoeff[diffCoeffStride + diffCoeffIndex] *
757 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
759 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
762 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
764 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
766 diffCoeff[5 * diffCoeffStride + diffCoeffIndex] *
769 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
771 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
773 diffCoeff[5 * diffCoeffStride + diffCoeffIndex] *
776 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
778 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
780 diffCoeff[5 * diffCoeffStride + diffCoeffIndex] *
785 TData sum1 = 0.0, sum2 = 0.0, sum3 = 0.0;
788 TData tmp =
in[index];
789 sum1 += metric[0u] * tmp;
790 sum2 += metric[1u] * tmp;
791 sum3 += metric[2u] * tmp;
792 tmp =
in[inoffset + index];
793 sum1 += metric[3u] * tmp;
794 sum2 += metric[4u] * tmp;
795 sum3 += metric[5u] * tmp;
796 tmp =
in[2u * inoffset + index];
797 sum1 += metric[6u] * tmp;
798 sum2 += metric[7u] * tmp;
799 sum3 += metric[8u] * tmp;
803 TData tmp =
in[index];
804 sum1 += df[0u *
warpsize + dfindex] * tmp;
805 sum2 += df[1u *
warpsize + dfindex] * tmp;
806 sum3 += df[2u *
warpsize + dfindex] * tmp;
807 tmp =
in[inoffset + index];
808 sum1 += df[3u *
warpsize + dfindex] * tmp;
809 sum2 += df[4u *
warpsize + dfindex] * tmp;
810 sum3 += df[5u *
warpsize + dfindex] * tmp;
811 tmp =
in[2u * inoffset + index];
812 sum1 += df[6u *
warpsize + dfindex] * tmp;
813 sum2 += df[7u *
warpsize + dfindex] * tmp;
814 sum3 += df[8u *
warpsize + dfindex] * tmp;
817 TData tmpQ = w0[i] * w1[j] * w2[k];
818 if constexpr (DEFORMED)
827 bwd[index] *= lambda * tmpQ;
831 out0[index] = sum1 * tmpQ;
832 out1[index] = sum2 * tmpQ;
833 out2[index] = sum3 * tmpQ;
838 TData tmp = f2[k] * tmpQ;
839 out0[index] = (sum1 + (sum2 + sum3) * f0[i]) * f1m[j] * tmp;
840 out1[index] = (sum2 + sum3 * f1[j]) * tmp;
841 out2[index] = sum3 * tmpQ;
846 out0[index] = (sum1 + sum3 * f0[i]) * f2[k] * tmpQ;
847 out1[index] = sum2 * tmpQ;
848 out2[index] = sum3 * tmpQ;
853 TData tmp = f2[k] * tmpQ;
854 out0[index] = (sum1 + sum3 * f0[i]) * tmp;
855 out1[index] = (sum2 + sum3 * f1[j]) * tmp;
856 out2[index] = sum3 * tmpQ;
870 bool DEFORMED,
bool VARCOEFF,
typename TSizeParameter1D,
871 typename TthreadBlock,
typename TData,
typename TUseSharedWsp,
872 std::enable_if_t<std::is_same_v<Implementation, SumFac>,
bool>
875 (GetMaxThreadPerBlock<Implementation, TSizeParameter1D>()))
877 const TSizeParameter1D sizeParam1D, const
unsigned int ncoord,
879 [[maybe_unused]] const
bool isModified,
885 const TData *
NEK_RESTRICT diffCoeff, const
size_t varDiffCoeffSize,
890 static_assert(IsSizeParameter1D_v<TSizeParameter1D>,
891 "Template argument must be either of type "
892 "NonTemplatedSizeParameter1D or TemplatedSizeParameter1D.");
896 const unsigned int nm0 = sizeParam1D.nm0();
897 const unsigned int nq0 = sizeParam1D.nq0();
899 const unsigned int ndf = ncoord;
900 const unsigned int dfsize = DEFORMED ? nq0 : 1u;
901 const unsigned int jacsize = DEFORMED ? nq0 : 1u;
907 const unsigned int ncomp = getBlockRange<1>(
threadBlock);
911 TData *wspbase = isShared ? (TData *)
shmemptr :
wsp;
918 const TData *diffCoeffPtr =
922 const TData *dfptr = df + ndf * dfsize *
warpsize * iwarp;
923 const TData *jacptr =
928 const size_t wspOffset =
930 const size_t derivOffset =
932 TData *bwd = wspbase + nq0 * wspOffset;
933 TData *deriv = wspbase + nq0 * wspNelmt + nq0 * derivOffset;
934 BwdTransSegSumFacKernel<false>(ilane,
nm0, nq0, basis0, inptr, bwd);
935 PhysDeriv1DSumFacKernel<DEFORMED>(
936 ilane, ncoord, nq0, derivNelmt * nq0, D0, dfptr, bwd, deriv);
937 ApplyMetric1DSumFacKernel<DEFORMED, VARCOEFF>(
938 ilane, ncoord, nq0, derivNelmt * nq0, w0, dfptr, jacptr,
939 diffCoeffPtr, varDiffCoeffSize, deriv, deriv, bwd, lambda);
940 SumDerivTensor1DKernel<false, true>(ilane, nq0, D0, deriv, bwd);
941 IProductWRTBaseSegSumFacKernel<false, false>(
942 ilane,
nm0, nq0, basis0, bwd, outptr, (TData)1.0);
956 bool DEFORMED,
bool VARCOEFF,
typename TSizeParameter2D,
957 typename TthreadBlock,
typename TData,
typename TUseSharedWsp,
958 std::enable_if_t<std::is_same_v<Implementation, SumFac>,
bool>
961 (GetMaxThreadPerBlock<Implementation, TSizeParameter2D>()))
963 const TSizeParameter2D sizeParam2D, const
unsigned int ncoord,
966 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index0,
973 const
size_t varDiffCoeffSize, const
unsigned int nhomo,
978 static_assert(IsSizeParameter2D_v<TSizeParameter2D>,
979 "Template argument must be either of type "
980 "NonTemplatedSizeParameter2D or TemplatedSizeParameter2D.");
986 const unsigned int nm0 = sizeParam2D.nm0();
987 const unsigned int nm1 = sizeParam2D.nm1();
988 const unsigned int nmTot = sizeParam2D.nmTot();
989 const unsigned int nq0 = sizeParam2D.nq0();
990 const unsigned int nq1 = sizeParam2D.nq1();
991 const unsigned int nqTot = sizeParam2D.nqTot();
993 const unsigned int ndf = 2 * ncoord;
994 const unsigned int dfsize = DEFORMED ? nqTot : 1u;
995 const unsigned int jacsize = DEFORMED ? nqTot : 1u;
1010 TData *s_f0 =
nullptr;
1011 TData *s_f1 =
nullptr;
1033 const unsigned int ncomp = getBlockRange<1>(
threadBlock);
1037 TData *wspbase = isShared ?
s_wsp :
wsp;
1038 const size_t wspNelmt = isShared ?
warpsize :
nelmt * ncomp;
1044 const TData *diffCoeffPtr =
1045 VARCOEFF ? diffCoeff +
1048 const TData *dfptr = df + ndf * dfsize *
warpsize * iwarp;
1049 const TData *jacptr =
1054 const size_t wspOffset =
1056 const size_t derivOffset =
1058 TData *bwd = wspbase + nqTot * wspOffset;
1059 TData *deriv = wspbase + nqTot * wspNelmt + nqTot * derivOffset;
1060 TData *deriv0 = deriv;
1061 TData *deriv1 = deriv + nqTot * derivNelmt;
1064 wspbase + (1 + ncoord) * nqTot * wspNelmt +
nmTot * wspOffset;
1067 ((1 + ncoord) * nqTot + (isNodal ?
nmTot : 0u)) * wspNelmt +
1070 if constexpr (isNodal)
1075 BwdTrans2DSumFacKernel<SHAPE_TYPE, false>(
1076 ilane,
nm0,
nm1, nq0, nq1, isModified, basis0, basis1,
1077 isNodal ? modal : inptr, bwd, wsp0);
1079 PhysDeriv2DSumFacKernel<SHAPE_TYPE, DEFORMED>(
1080 ilane, ncoord, nq0, nq1, derivNelmt * nqTot, D0, D1, s_f0, s_f1,
1082 ApplyMetric2DSumFacKernel<SHAPE_TYPE, DEFORMED, VARCOEFF>(
1083 ilane, ncoord, nq0, nq1, derivNelmt * nqTot, w0, w1, s_f0, s_f1,
1084 dfptr, jacptr, diffCoeffPtr, varDiffCoeffSize, deriv, deriv0,
1085 deriv1, bwd, lambda);
1086 SumDerivTensor2DKernel<false, true>(ilane, nq0, nq1, D0, D1, deriv0,
1088 IProductWRTBase2DSumFacKernel<SHAPE_TYPE, false, false>(
1089 ilane,
nm0,
nm1, nq0, nq1, isModified, basis0, basis1, bwd,
1090 isNodal ? modal : outptr, wsp0, (TData)1.0);
1092 if constexpr (isNodal)
1095 MatVecKernel<false, true>(ilane,
nmTot, nodToMod, modal,
1111 bool DEFORMED,
bool VARCOEFF,
typename TSizeParameter3D,
1112 typename TthreadBlock,
typename TData,
typename TUseSharedWsp,
1113 std::enable_if_t<std::is_same_v<Implementation, SumFac>,
bool>
1116 (GetMaxThreadPerBlock<Implementation, TSizeParameter3D>()))
1118 const TSizeParameter3D sizeParam3D,
1119 [[maybe_unused]] const
unsigned int ncoord, const
size_t nelmt,
1122 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index0,
1123 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index1,
1124 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index2,
1125 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index3,
1134 const TData *
NEK_RESTRICT diffCoeff, const
size_t varDiffCoeffSize,
1139 static_assert(IsSizeParameter3D_v<TSizeParameter3D>,
1140 "Template argument must be either of type "
1141 "NonTemplatedSizeParameter3D or TemplatedSizeParameter3D.");
1149 const unsigned int nm0 = sizeParam3D.nm0();
1150 const unsigned int nm1 = sizeParam3D.nm1();
1151 const unsigned int nm2 = sizeParam3D.nm2();
1152 const unsigned int nmTot = sizeParam3D.nmTot();
1153 const unsigned int nq0 = sizeParam3D.nq0();
1154 const unsigned int nq1 = sizeParam3D.nq1();
1155 const unsigned int nq2 = sizeParam3D.nq2();
1156 const unsigned int nqTot = sizeParam3D.nqTot();
1158 constexpr unsigned int ndf = 9u;
1159 const unsigned int dfsize = DEFORMED ? nqTot : 1u;
1160 const unsigned int jacsize = DEFORMED ? nqTot : 1u;
1185 TData *s_f0 =
nullptr;
1186 TData *s_f1 =
nullptr;
1187 TData *s_f1m =
nullptr;
1188 TData *s_f2 =
nullptr;
1242 const unsigned int ncomp = getBlockRange<1>(
threadBlock);
1246 TData *wspbase = isShared ?
s_wsp :
wsp;
1247 const size_t wspNelmt = isShared ?
warpsize :
nelmt * ncomp;
1253 const TData *diffCoeffPtr =
1254 VARCOEFF ? diffCoeff +
1257 const TData *dfptr = df + ndf * dfsize *
warpsize * iwarp;
1258 const TData *jacptr =
1263 const size_t wspOffset =
1265 const size_t derivOffset =
1267 TData *bwd = wspbase + nqTot * wspOffset;
1268 TData *deriv = wspbase + nqTot * wspNelmt + nqTot * derivOffset;
1269 TData *deriv0 = deriv;
1270 TData *deriv1 = deriv + nqTot * derivNelmt;
1271 TData *deriv2 = deriv + 2 * nqTot * derivNelmt;
1273 TData *modal = wspbase + 4 * nqTot * wspNelmt +
nmTot * wspOffset;
1274 TData *wsp0 = wspbase +
1275 (4 * nqTot + (isNodal ?
nmTot : 0u)) * wspNelmt +
1279 (4 * nqTot + (isNodal ?
nmTot : 0u) +
wsp0Size) * wspNelmt +
1282 if constexpr (isNodal)
1287 BwdTrans3DSumFacKernel<SHAPE_TYPE, false>(
1288 ilane,
nm0,
nm1,
nm2, nq0, nq1, nq2, isModified, basis0, basis1,
1289 basis2, isNodal ? modal : inptr, bwd, wsp0, wsp1);
1290 PhysDeriv3DSumFacKernel<SHAPE_TYPE, DEFORMED>(
1291 ilane, nq0, nq1, nq2, derivNelmt * nqTot, D0, D1, D2, s_f0,
1292 s_f1, s_f1m, s_f2, dfptr, bwd, deriv);
1293 ApplyMetric3DSumFacKernel<SHAPE_TYPE, DEFORMED, VARCOEFF>(
1294 ilane, nq0, nq1, nq2, derivNelmt * nqTot, w0, w1, w2, s_f0,
1295 s_f1, s_f1m, s_f2, dfptr, jacptr, diffCoeffPtr,
1296 varDiffCoeffSize, deriv, deriv0, deriv1, deriv2, bwd, lambda);
1297 SumDerivTensor3DKernel<true, true>(ilane, nq0, nq1, nq2, D0, D1, D2,
1298 deriv0, deriv1, deriv2, bwd);
1299 IProductWRTBase3DSumFacKernel<SHAPE_TYPE, false, false>(
1300 ilane,
nm0,
nm1,
nm2, nq0, nq1, nq2, isModified, basis0, basis1,
1301 basis2, bwd, isNodal ? modal : outptr, wsp0, wsp1, (TData)1.0);
1303 if constexpr (isNodal)
1306 MatVecKernel<false, true>(ilane,
nmTot, nodToMod, modal,
#define NEK_DEVICE_INLINE
#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,...
Device SumFac kernels of the physical derivative: one element per warp lane.
std::map< int64_t, double > sum
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
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
static NEK_FORCE_INLINE void HelmholtzKernelLauncher(const TSizeParameter1D sizeParam1D, const bool isModified, const unsigned int ncoord, const bool useDiffCoeff, const typename simd_type::scalarType *diffCoeff, const simd_type *varDiffCoeff, const size_t varDiffCoeffSize, const typename simd_type::scalarType *basis0, const typename simd_type::scalarType *D0, const typename simd_type::scalarType *w0, const simd_type *NtoM, const simd_type *NtoMTrans, const simd_type *jac, const simd_type *df, simd_type *deriv0, simd_type *bwd, const simd_type *in, simd_type *out, const typename simd_type::scalarType lambda)
1D launcher stringing together the five sum-factorised stages for one element group.
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