74#if defined(NEKTAR_ENABLE_DEVICE) && defined(DEVICE_COMPILE_ONLY)
81 typename TSizeParameter1D,
82 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
83 IsSizeParameter1D_v<TSizeParameter1D>,
86inline constexpr size_t LaplacianWorkSpaceSize(
87 const size_t nelmt,
const unsigned int ncoord,
88 const TSizeParameter1D sizeParam1D)
92 const unsigned int nq0 = sizeParam1D.nq0();
96 wspsize = (1 + ncoord) * nq0 *
nelmt;
104 typename TSizeParameter2D,
105 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
106 IsSizeParameter2D_v<TSizeParameter2D>,
109inline constexpr size_t LaplacianWorkSpaceSize(
110 const size_t nelmt,
const unsigned int ncoord,
111 const TSizeParameter2D sizeParam2D)
115 const unsigned int nm0 = sizeParam2D.nm0();
116 const unsigned int nq1 = sizeParam2D.nq1();
120 wspsize = ((1 + ncoord) * sizeParam2D.nqTot() + nq1) *
nelmt;
125 ((1 + ncoord) * sizeParam2D.nqTot() + std::max(nq1,
nm0)) *
nelmt;
129 const unsigned int nmTot = sizeParam2D.nmTot();
132 ((1 + ncoord) * sizeParam2D.nqTot() + std::max(nq1,
nm0) +
nmTot) *
141 typename TSizeParameter3D,
142 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
143 IsSizeParameter3D_v<TSizeParameter3D>,
146inline constexpr size_t LaplacianWorkSpaceSize(
147 const size_t nelmt, [[maybe_unused]]
const unsigned int ncoord,
148 const TSizeParameter3D sizeParam3D)
152 const unsigned int nm0 = sizeParam3D.nm0();
153 const unsigned int nm1 = sizeParam3D.nm1();
154 const unsigned int nq1 = sizeParam3D.nq1();
155 const unsigned int nq2 = sizeParam3D.nq2();
159 wspsize = (4 * sizeParam3D.nqTot() + nq1 * nq2 + nq2) *
nelmt;
164 (4 * sizeParam3D.nqTot() + nq1 * nq2 + std::max(nq2,
nm0)) *
nelmt;
168 const unsigned int nmTot = sizeParam3D.nmTot();
171 (4 * sizeParam3D.nqTot() + nq1 * nq2 + std::max(nq2,
nm0) +
nmTot) *
176 wspsize = (4 * sizeParam3D.nqTot() + std::max(nq1 * nq2,
nm0 *
nm1) +
177 std::max(nq2,
nm0)) *
182 const unsigned int nmTot = sizeParam3D.nmTot();
184 wspsize = (4 * sizeParam3D.nqTot() + std::max(nq1 * nq2,
nm0 *
nm1) +
190 wspsize = (4 * sizeParam3D.nqTot() + std::max(nq1 * nq2,
nm0 *
nm1) +
191 std::max(nq2,
nm0)) *
196 const unsigned int nmTot = sizeParam3D.nmTot();
198 wspsize = (4 * sizeParam3D.nqTot() + std::max(nq1 * nq2,
nm0 *
nm1) +
214 typename TData,
typename TSizeParameter1D,
215 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
216 IsSizeParameter1D_v<TSizeParameter1D>,
219inline constexpr unsigned int LaplacianSharedMemorySize(
220 const unsigned int ncoord,
const TSizeParameter1D sizeParam1D,
224 ?
static_cast<unsigned int>(
225 LaplacianWorkSpaceSize<SHAPE_TYPE, Implementation>(
233 typename TData,
typename TSizeParameter2D,
234 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
235 IsSizeParameter2D_v<TSizeParameter2D>,
238inline constexpr unsigned int LaplacianSharedMemorySize(
239 const unsigned int ncoord,
const TSizeParameter2D sizeParam2D,
242 unsigned int shmemsize = 0;
247 const unsigned int nq0 = sizeParam2D.nq0();
248 const unsigned int nq1 = sizeParam2D.nq1();
250 shmemsize = nq0 + nq1;
255 shmemsize +=
static_cast<unsigned int>(
256 LaplacianWorkSpaceSize<SHAPE_TYPE, Implementation>(
266 typename TData,
typename TSizeParameter3D,
267 std::enable_if_t<std::is_same_v<Implementation, SumFac> &&
268 IsSizeParameter3D_v<TSizeParameter3D>,
271inline constexpr unsigned int LaplacianSharedMemorySize(
272 const unsigned int ncoord,
const TSizeParameter3D sizeParam3D,
275 const unsigned int nq0 = sizeParam3D.nq0();
276 const unsigned int nq1 = sizeParam3D.nq1();
277 const unsigned int nq2 = sizeParam3D.nq2();
279 unsigned int shmemsize = 0;
284 shmemsize = nq0 + 2 * nq1 + nq2;
289 shmemsize = nq0 + nq2;
294 shmemsize = nq0 + nq1 + nq2;
299 shmemsize +=
static_cast<unsigned int>(
300 LaplacianWorkSpaceSize<SHAPE_TYPE, Implementation>(
310template <
bool DEFORMED,
bool VARCOEFF,
typename TData>
312 const unsigned int ilane,
const unsigned int ncoord,
const unsigned int nq0,
315 const TData *
NEK_RESTRICT diffCoeff,
const size_t varDiffCoeffSize,
318 const size_t diffCoeffStride = VARCOEFF ? varDiffCoeffSize : 1;
321 TData metric[3] = {0.0};
322 if constexpr (!DEFORMED && !VARCOEFF)
328 metric[0] = diffCoeff[0] * df[ilane];
330 else if (ncoord == 2)
332 metric[0] = diffCoeff[0] * df[ilane] +
333 diffCoeff[1] * df[
warpsize + ilane];
334 metric[1] = diffCoeff[1] * df[ilane] +
335 diffCoeff[2] * df[
warpsize + ilane];
337 else if (ncoord == 3)
339 metric[0] = diffCoeff[0] * df[ilane] +
340 diffCoeff[1] * df[
warpsize + ilane] +
341 diffCoeff[3] * df[2 *
warpsize + ilane];
342 metric[1] = diffCoeff[1] * df[ilane] +
343 diffCoeff[2] * df[
warpsize + ilane] +
344 diffCoeff[4] * df[2 *
warpsize + ilane];
345 metric[2] = diffCoeff[3] * df[ilane] +
346 diffCoeff[4] * df[
warpsize + ilane] +
347 diffCoeff[5] * df[2 *
warpsize + ilane];
352 for (
unsigned int i = 0u; i < nq0; ++i)
354 const unsigned int index =
warpsize * i + ilane;
355 const unsigned int dfindex =
356 DEFORMED ? ncoord *
warpsize * i + ilane : ilane;
358 if constexpr (DEFORMED || VARCOEFF)
360 const size_t diffCoeffIndex = VARCOEFF ? index : 0;
365 metric[0] = diffCoeff[diffCoeffIndex] * df[dfindex];
367 else if (ncoord == 2)
369 metric[0] = diffCoeff[diffCoeffIndex] * df[dfindex] +
370 diffCoeff[diffCoeffStride + diffCoeffIndex] *
373 diffCoeff[diffCoeffStride + diffCoeffIndex] *
375 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
378 else if (ncoord == 3)
381 diffCoeff[diffCoeffIndex] * df[dfindex] +
382 diffCoeff[diffCoeffStride + diffCoeffIndex] *
384 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
387 diffCoeff[diffCoeffStride + diffCoeffIndex] *
389 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
391 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
394 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
396 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
398 diffCoeff[5 * diffCoeffStride + diffCoeffIndex] *
405 for (
unsigned int k = 0u; k < ncoord; ++k)
409 sum += metric[k] *
in[k * inoffset + index];
413 sum += df[k *
warpsize + dfindex] *
in[k * inoffset + index];
417 if constexpr (DEFORMED)
434 const unsigned int ilane,
const unsigned int ncoord,
const unsigned int nq0,
435 const unsigned int nq1,
const size_t inoffset,
const TData *
NEK_RESTRICT w0,
442 const size_t diffCoeffStride = VARCOEFF ? varDiffCoeffSize : 1;
445 const unsigned int ndf = 2 * ncoord;
447 TData metric[6] = {0.0};
448 if constexpr (!DEFORMED && !VARCOEFF)
454 metric[0] = diffCoeff[0] * df[ilane] +
455 diffCoeff[1] * df[2 *
warpsize + ilane];
456 metric[1] = diffCoeff[0] * df[1 *
warpsize + ilane] +
457 diffCoeff[1] * df[3 *
warpsize + ilane];
458 metric[2] = diffCoeff[1] * df[ilane] +
459 diffCoeff[2] * df[2 *
warpsize + ilane];
460 metric[3] = diffCoeff[1] * df[1 *
warpsize + ilane] +
461 diffCoeff[2] * df[3 *
warpsize + ilane];
463 else if (ncoord == 3)
465 metric[0] = diffCoeff[0] * df[ilane] +
466 diffCoeff[1] * df[2 *
warpsize + ilane] +
467 diffCoeff[3] * df[4 *
warpsize + ilane];
468 metric[1] = diffCoeff[0] * df[1 *
warpsize + ilane] +
469 diffCoeff[1] * df[3 *
warpsize + ilane] +
470 diffCoeff[3] * df[5 *
warpsize + ilane];
471 metric[2] = diffCoeff[1] * df[ilane] +
472 diffCoeff[2] * df[2 *
warpsize + ilane] +
473 diffCoeff[4] * df[4 *
warpsize + ilane];
474 metric[3] = diffCoeff[1] * df[1 *
warpsize + ilane] +
475 diffCoeff[2] * df[3 *
warpsize + ilane] +
476 diffCoeff[4] * df[5 *
warpsize + ilane];
477 metric[4] = diffCoeff[3] * df[ilane] +
478 diffCoeff[4] * df[2 *
warpsize + ilane] +
479 diffCoeff[5] * df[4 *
warpsize + ilane];
480 metric[5] = diffCoeff[3] * df[1 *
warpsize + ilane] +
481 diffCoeff[4] * df[3 *
warpsize + ilane] +
482 diffCoeff[5] * df[5 *
warpsize + ilane];
487 for (
unsigned int j = 0u, cnt_ji = 0u; j < nq1; ++j)
489 for (
unsigned int i = 0u; i < nq0; ++i, ++cnt_ji)
491 const unsigned int index =
warpsize * cnt_ji + ilane;
492 const unsigned int dfindex =
493 DEFORMED ? ndf *
warpsize * cnt_ji + ilane : ilane;
495 if constexpr (DEFORMED || VARCOEFF)
497 const size_t diffCoeffIndex = VARCOEFF ? index : 0;
503 diffCoeff[diffCoeffIndex] * df[dfindex] +
504 diffCoeff[diffCoeffStride + diffCoeffIndex] *
507 diffCoeff[diffCoeffIndex] *
509 diffCoeff[diffCoeffStride + diffCoeffIndex] *
512 diffCoeff[diffCoeffStride + diffCoeffIndex] *
514 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
517 diffCoeff[diffCoeffStride + diffCoeffIndex] *
519 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
522 else if (ncoord == 3)
525 diffCoeff[diffCoeffIndex] * df[dfindex] +
526 diffCoeff[diffCoeffStride + diffCoeffIndex] *
528 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
531 diffCoeff[diffCoeffIndex] *
533 diffCoeff[diffCoeffStride + diffCoeffIndex] *
535 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
538 diffCoeff[diffCoeffStride + diffCoeffIndex] *
540 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
542 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
545 diffCoeff[diffCoeffStride + diffCoeffIndex] *
547 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
549 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
552 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
554 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
556 diffCoeff[5 * diffCoeffStride + diffCoeffIndex] *
559 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
561 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
563 diffCoeff[5 * diffCoeffStride + diffCoeffIndex] *
569 TData sum1 = 0.0, sum2 = 0.0;
572 TData tmp =
in[index];
573 sum1 += metric[0u] * tmp;
574 sum2 += metric[1u] * tmp;
575 tmp =
in[inoffset + index];
576 sum1 += metric[2u] * tmp;
577 sum2 += metric[3u] * tmp;
580 tmp =
in[2u * inoffset + index];
581 sum1 += metric[4u] * tmp;
582 sum2 += metric[5u] * tmp;
587 TData tmp =
in[index];
588 sum1 += df[0u *
warpsize + dfindex] * tmp;
589 sum2 += df[1u *
warpsize + dfindex] * tmp;
590 tmp =
in[inoffset + index];
591 sum1 += df[2u *
warpsize + dfindex] * tmp;
592 sum2 += df[3u *
warpsize + dfindex] * tmp;
595 tmp =
in[2u * inoffset + index];
596 sum1 += df[4u *
warpsize + dfindex] * tmp;
597 sum2 += df[5u *
warpsize + dfindex] * tmp;
601 TData tmpQ = w0[i] * w1[j];
602 if constexpr (DEFORMED)
614 out0[index] = sum1 * tmpQ;
615 out1[index] = sum2 * tmpQ;
620 out0[index] = (sum1 + sum2 * f0[i]) * f1[j] * tmpQ;
621 out1[index] = sum2 * tmpQ;
633 const unsigned int ilane,
const unsigned int nq0,
const unsigned int nq1,
634 const unsigned int nq2,
const size_t inoffset,
const TData *
NEK_RESTRICT w0,
645 const size_t diffCoeffStride = VARCOEFF ? varDiffCoeffSize : 1;
648 constexpr unsigned int ndf = 9u;
650 TData metric[9] = {0.0};
651 if constexpr (!DEFORMED && !VARCOEFF)
655 metric[0] = diffCoeff[0] * df[ilane] +
656 diffCoeff[1] * df[3 *
warpsize + ilane] +
657 diffCoeff[3] * df[6 *
warpsize + ilane];
658 metric[1] = diffCoeff[0] * df[1 *
warpsize + ilane] +
659 diffCoeff[1] * df[4 *
warpsize + ilane] +
660 diffCoeff[3] * df[7 *
warpsize + ilane];
661 metric[2] = diffCoeff[0] * df[2 *
warpsize + ilane] +
662 diffCoeff[1] * df[5 *
warpsize + ilane] +
663 diffCoeff[3] * df[8 *
warpsize + ilane];
664 metric[3] = diffCoeff[1] * df[ilane] +
665 diffCoeff[2] * df[3 *
warpsize + ilane] +
666 diffCoeff[4] * df[6 *
warpsize + ilane];
667 metric[4] = diffCoeff[1] * df[1 *
warpsize + ilane] +
668 diffCoeff[2] * df[4 *
warpsize + ilane] +
669 diffCoeff[4] * df[7 *
warpsize + ilane];
670 metric[5] = diffCoeff[1] * df[2 *
warpsize + ilane] +
671 diffCoeff[2] * df[5 *
warpsize + ilane] +
672 diffCoeff[4] * df[8 *
warpsize + ilane];
673 metric[6] = diffCoeff[3] * df[ilane] +
674 diffCoeff[4] * df[3 *
warpsize + ilane] +
675 diffCoeff[5] * df[6 *
warpsize + ilane];
676 metric[7] = diffCoeff[3] * df[1 *
warpsize + ilane] +
677 diffCoeff[4] * df[4 *
warpsize + ilane] +
678 diffCoeff[5] * df[7 *
warpsize + ilane];
679 metric[8] = diffCoeff[3] * df[2 *
warpsize + ilane] +
680 diffCoeff[4] * df[5 *
warpsize + ilane] +
681 diffCoeff[5] * df[8 *
warpsize + ilane];
685 for (
unsigned int k = 0u, cnt_kji = 0u; k < nq2; ++k)
687 for (
unsigned int j = 0u; j < nq1; ++j)
689 for (
unsigned int i = 0u; i < nq0; ++i, ++cnt_kji)
691 const unsigned int index =
warpsize * cnt_kji + ilane;
692 const unsigned int dfindex =
693 DEFORMED ? ndf *
warpsize * cnt_kji + ilane : ilane;
695 if constexpr (DEFORMED || VARCOEFF)
697 const size_t diffCoeffIndex = VARCOEFF ? index : 0;
701 diffCoeff[diffCoeffIndex] * df[dfindex] +
702 diffCoeff[diffCoeffStride + diffCoeffIndex] *
704 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
707 diffCoeff[diffCoeffIndex] *
709 diffCoeff[diffCoeffStride + diffCoeffIndex] *
711 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
714 diffCoeff[diffCoeffIndex] *
716 diffCoeff[diffCoeffStride + diffCoeffIndex] *
718 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
721 diffCoeff[diffCoeffStride + diffCoeffIndex] *
723 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
725 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
728 diffCoeff[diffCoeffStride + diffCoeffIndex] *
730 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
732 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
735 diffCoeff[diffCoeffStride + diffCoeffIndex] *
737 diffCoeff[2 * diffCoeffStride + diffCoeffIndex] *
739 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
742 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
744 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
746 diffCoeff[5 * diffCoeffStride + diffCoeffIndex] *
749 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
751 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
753 diffCoeff[5 * diffCoeffStride + diffCoeffIndex] *
756 diffCoeff[3 * diffCoeffStride + diffCoeffIndex] *
758 diffCoeff[4 * diffCoeffStride + diffCoeffIndex] *
760 diffCoeff[5 * diffCoeffStride + diffCoeffIndex] *
765 TData sum1 = 0.0, sum2 = 0.0, sum3 = 0.0;
768 TData tmp =
in[index];
769 sum1 += metric[0u] * tmp;
770 sum2 += metric[1u] * tmp;
771 sum3 += metric[2u] * tmp;
772 tmp =
in[inoffset + index];
773 sum1 += metric[3u] * tmp;
774 sum2 += metric[4u] * tmp;
775 sum3 += metric[5u] * tmp;
776 tmp =
in[2u * inoffset + index];
777 sum1 += metric[6u] * tmp;
778 sum2 += metric[7u] * tmp;
779 sum3 += metric[8u] * tmp;
783 TData tmp =
in[index];
784 sum1 += df[0u *
warpsize + dfindex] * tmp;
785 sum2 += df[1u *
warpsize + dfindex] * tmp;
786 sum3 += df[2u *
warpsize + dfindex] * tmp;
787 tmp =
in[inoffset + index];
788 sum1 += df[3u *
warpsize + dfindex] * tmp;
789 sum2 += df[4u *
warpsize + dfindex] * tmp;
790 sum3 += df[5u *
warpsize + dfindex] * tmp;
791 tmp =
in[2u * inoffset + index];
792 sum1 += df[6u *
warpsize + dfindex] * tmp;
793 sum2 += df[7u *
warpsize + dfindex] * tmp;
794 sum3 += df[8u *
warpsize + dfindex] * tmp;
797 TData tmpQ = w0[i] * w1[j] * w2[k];
798 if constexpr (DEFORMED)
809 out0[index] = sum1 * tmpQ;
810 out1[index] = sum2 * tmpQ;
811 out2[index] = sum3 * tmpQ;
816 TData tmp = f2[k] * tmpQ;
817 out0[index] = (sum1 + (sum2 + sum3) * f0[i]) * f1m[j] * tmp;
818 out1[index] = (sum2 + sum3 * f1[j]) * tmp;
819 out2[index] = sum3 * tmpQ;
824 out0[index] = (sum1 + sum3 * f0[i]) * f2[k] * tmpQ;
825 out1[index] = sum2 * tmpQ;
826 out2[index] = sum3 * tmpQ;
831 TData tmp = f2[k] * tmpQ;
832 out0[index] = (sum1 + sum3 * f0[i]) * tmp;
833 out1[index] = (sum2 + sum3 * f1[j]) * tmp;
834 out2[index] = sum3 * tmpQ;
846 bool DEFORMED,
bool VARCOEFF,
typename TSizeParameter1D,
847 typename TthreadBlock,
typename TData,
typename TUseSharedWsp,
848 std::enable_if_t<std::is_same_v<Implementation, SumFac>,
bool>
851 (GetMaxThreadPerBlock<Implementation, TSizeParameter1D>()))
853 const TSizeParameter1D sizeParam1D, const
unsigned int ncoord,
855 [[maybe_unused]] const
bool isModified,
861 const TData *
NEK_RESTRICT diffCoeff, const
size_t varDiffCoeffSize,
866 static_assert(IsSizeParameter1D_v<TSizeParameter1D>,
867 "Template argument must be either of type "
868 "NonTemplatedSizeParameter1D or TemplatedSizeParameter1D.");
872 const unsigned int nm0 = sizeParam1D.nm0();
873 const unsigned int nq0 = sizeParam1D.nq0();
875 const unsigned int ndf = ncoord;
876 const unsigned int dfsize = DEFORMED ? nq0 : 1u;
877 const unsigned int jacsize = DEFORMED ? nq0 : 1u;
883 const unsigned int ncomp = getBlockRange<1>(
threadBlock);
887 TData *wspbase = isShared ? (TData *)
shmemptr :
wsp;
894 const TData *diffCoeffPtr =
898 const TData *dfptr = df + ndf * dfsize *
warpsize * iwarp;
899 const TData *jacptr =
904 const size_t wspOffset =
906 const size_t derivOffset =
908 TData *bwd = wspbase + nq0 * wspOffset;
909 TData *deriv = wspbase + nq0 * wspNelmt + nq0 * derivOffset;
910 BwdTransSegSumFacKernel<false>(ilane,
nm0, nq0, basis0, inptr, bwd);
911 PhysDeriv1DSumFacKernel<DEFORMED>(
912 ilane, ncoord, nq0, derivNelmt * nq0, D0, dfptr, bwd, deriv);
913 ApplyMetric1DSumFacKernel<DEFORMED, VARCOEFF>(
914 ilane, ncoord, nq0, derivNelmt * nq0, w0, dfptr, jacptr,
915 diffCoeffPtr, varDiffCoeffSize, deriv, deriv);
916 SumDerivTensor1DKernel<false, false>(ilane, nq0, D0, deriv, bwd,
918 IProductWRTBaseSegSumFacKernel<false, false>(
919 ilane,
nm0, nq0, basis0, bwd, outptr, (TData)1.0);
931 bool DEFORMED,
bool VARCOEFF,
typename TSizeParameter2D,
932 typename TthreadBlock,
typename TData,
typename TUseSharedWsp,
933 std::enable_if_t<std::is_same_v<Implementation, SumFac>,
bool>
936 (GetMaxThreadPerBlock<Implementation, TSizeParameter2D>()))
938 const TSizeParameter2D sizeParam2D, const
unsigned int ncoord,
941 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index0,
948 const
size_t varDiffCoeffSize, const
unsigned int nhomo,
953 static_assert(IsSizeParameter2D_v<TSizeParameter2D>,
954 "Template argument must be either of type "
955 "NonTemplatedSizeParameter2D or TemplatedSizeParameter2D.");
961 const unsigned int nm0 = sizeParam2D.nm0();
962 const unsigned int nm1 = sizeParam2D.nm1();
963 const unsigned int nmTot = sizeParam2D.nmTot();
964 const unsigned int nq0 = sizeParam2D.nq0();
965 const unsigned int nq1 = sizeParam2D.nq1();
966 const unsigned int nqTot = sizeParam2D.nqTot();
968 const unsigned int ndf = 2 * ncoord;
969 const unsigned int dfsize = DEFORMED ? nqTot : 1u;
970 const unsigned int jacsize = DEFORMED ? nqTot : 1u;
985 TData *s_f0 =
nullptr;
986 TData *s_f1 =
nullptr;
1006 const unsigned int ncomp = getBlockRange<1>(
threadBlock);
1011 TData *wspbase = isShared ?
s_wsp :
wsp;
1012 const size_t wspNelmt = isShared ?
warpsize :
nelmt * ncomp;
1018 const TData *diffCoeffPtr =
1019 VARCOEFF ? diffCoeff +
1022 const TData *dfptr = df + ndf * dfsize *
warpsize * iwarp;
1023 const TData *jacptr =
1028 const size_t wspOffset =
1030 const size_t derivOffset =
1032 TData *bwd = wspbase + nqTot * wspOffset;
1033 TData *deriv = wspbase + nqTot * wspNelmt + nqTot * derivOffset;
1034 TData *deriv0 = deriv;
1035 TData *deriv1 = deriv + nqTot * derivNelmt;
1038 wspbase + (1 + ncoord) * nqTot * wspNelmt +
nmTot * wspOffset;
1041 ((1 + ncoord) * nqTot + (isNodal ?
nmTot : 0u)) * wspNelmt +
1044 if constexpr (isNodal)
1049 BwdTrans2DSumFacKernel<SHAPE_TYPE, false>(
1050 ilane,
nm0,
nm1, nq0, nq1, isModified, basis0, basis1,
1051 isNodal ? modal : inptr, bwd, wsp0);
1053 PhysDeriv2DSumFacKernel<SHAPE_TYPE, DEFORMED>(
1054 ilane, ncoord, nq0, nq1, derivNelmt * nqTot, D0, D1, s_f0, s_f1,
1056 ApplyMetric2DSumFacKernel<SHAPE_TYPE, DEFORMED, VARCOEFF>(
1057 ilane, ncoord, nq0, nq1, derivNelmt * nqTot, w0, w1, s_f0, s_f1,
1058 dfptr, jacptr, diffCoeffPtr, varDiffCoeffSize, deriv, deriv0,
1060 SumDerivTensor2DKernel<false, false>(ilane, nq0, nq1, D0, D1,
1061 deriv0, deriv1, bwd);
1062 IProductWRTBase2DSumFacKernel<SHAPE_TYPE, false, false>(
1063 ilane,
nm0,
nm1, nq0, nq1, isModified, basis0, basis1, bwd,
1064 isNodal ? modal : outptr, wsp0, (TData)1.0);
1066 if constexpr (isNodal)
1069 MatVecKernel<false, true>(ilane,
nmTot, nodToMod, modal,
1083 bool DEFORMED,
bool VARCOEFF,
typename TSizeParameter3D,
1084 typename TthreadBlock,
typename TData,
typename TUseSharedWsp,
1085 std::enable_if_t<std::is_same_v<Implementation, SumFac>,
bool>
1088 (GetMaxThreadPerBlock<Implementation, TSizeParameter3D>()))
1090 const TSizeParameter3D sizeParam3D,
1091 [[maybe_unused]] const
unsigned int ncoord, const
size_t nelmt,
1094 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index0,
1095 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index1,
1096 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index2,
1097 [[maybe_unused]] const
unsigned int *
NEK_RESTRICT index3,
1106 const TData *
NEK_RESTRICT diffCoeff, const
size_t varDiffCoeffSize,
1111 static_assert(IsSizeParameter3D_v<TSizeParameter3D>,
1112 "Template argument must be either of type "
1113 "NonTemplatedSizeParameter3D or TemplatedSizeParameter3D.");
1121 const unsigned int nm0 = sizeParam3D.nm0();
1122 const unsigned int nm1 = sizeParam3D.nm1();
1123 const unsigned int nm2 = sizeParam3D.nm2();
1124 const unsigned int nmTot = sizeParam3D.nmTot();
1125 const unsigned int nq0 = sizeParam3D.nq0();
1126 const unsigned int nq1 = sizeParam3D.nq1();
1127 const unsigned int nq2 = sizeParam3D.nq2();
1128 const unsigned int nqTot = sizeParam3D.nqTot();
1130 constexpr unsigned int ndf = 9u;
1131 const unsigned int dfsize = DEFORMED ? nqTot : 1u;
1132 const unsigned int jacsize = DEFORMED ? nqTot : 1u;
1157 TData *s_f0 =
nullptr;
1158 TData *s_f1 =
nullptr;
1159 TData *s_f1m =
nullptr;
1160 TData *s_f2 =
nullptr;
1212 const unsigned int ncomp = getBlockRange<1>(
threadBlock);
1217 TData *wspbase = isShared ?
s_wsp :
wsp;
1218 const size_t wspNelmt = isShared ?
warpsize :
nelmt * ncomp;
1224 const TData *diffCoeffPtr =
1225 VARCOEFF ? diffCoeff +
1228 const TData *dfptr = df + ndf * dfsize *
warpsize * iwarp;
1229 const TData *jacptr =
1234 const size_t wspOffset =
1236 const size_t derivOffset =
1238 TData *bwd = wspbase + nqTot * wspOffset;
1239 TData *deriv = wspbase + nqTot * wspNelmt + nqTot * derivOffset;
1240 TData *deriv0 = deriv;
1241 TData *deriv1 = deriv + nqTot * derivNelmt;
1242 TData *deriv2 = deriv + 2 * nqTot * derivNelmt;
1244 TData *modal = wspbase + 4 * nqTot * wspNelmt +
nmTot * wspOffset;
1245 TData *wsp0 = wspbase +
1246 (4 * nqTot + (isNodal ?
nmTot : 0u)) * wspNelmt +
1250 (4 * nqTot + (isNodal ?
nmTot : 0u) +
wsp0Size) * wspNelmt +
1253 if constexpr (isNodal)
1258 BwdTrans3DSumFacKernel<SHAPE_TYPE, false>(
1259 ilane,
nm0,
nm1,
nm2, nq0, nq1, nq2, isModified, basis0, basis1,
1260 basis2, isNodal ? modal : inptr, bwd, wsp0, wsp1);
1261 PhysDeriv3DSumFacKernel<SHAPE_TYPE, DEFORMED>(
1262 ilane, nq0, nq1, nq2, derivNelmt * nqTot, D0, D1, D2, s_f0,
1263 s_f1, s_f1m, s_f2, dfptr, bwd, deriv);
1264 ApplyMetric3DSumFacKernel<SHAPE_TYPE, DEFORMED, VARCOEFF>(
1265 ilane, nq0, nq1, nq2, derivNelmt * nqTot, w0, w1, w2, s_f0,
1266 s_f1, s_f1m, s_f2, dfptr, jacptr, diffCoeffPtr,
1267 varDiffCoeffSize, deriv, deriv0, deriv1, deriv2);
1268 SumDerivTensor3DKernel<false, false>(
1269 ilane, nq0, nq1, nq2, D0, D1, D2, deriv0, deriv1, deriv2, bwd);
1270 IProductWRTBase3DSumFacKernel<SHAPE_TYPE, false, false>(
1271 ilane,
nm0,
nm1,
nm2, nq0, nq1, nq2, isModified, basis0, basis1,
1272 basis2, bwd, isNodal ? modal : outptr, wsp0, wsp1, (TData)1.0);
1274 if constexpr (isNodal)
1277 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 LaplacianKernelLauncher(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)
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