44#if defined(NEKTAR_ENABLE_DEVICE) && defined(DEVICE_COMPILE_ONLY)
49 const unsigned int nq1)
53 return 2 * nq0 * nq1 + std::max(nq0 * nq1, 2 * nq0 + 2 * nq1) +
58 return 3 * nq0 * nq1 + std::max(nq0, nq1);
65inline unsigned int FwdTransBCSharedMemorySize(
const unsigned int nm0,
66 const unsigned int nq0)
68 return 2 * nq0 +
nm0 * nq0;
73inline unsigned int FwdTransBCSharedMemorySize(
75 const unsigned int nm1,
const unsigned int nmTot,
const unsigned int nq0,
76 const unsigned int nq1)
78 const unsigned int wspsize = FwdTransBCWorkSpaceSize2D(shapeType, nq0, nq1);
82 return wspsize +
nm0 * nq0 +
nm1 * nq1;
86 return wspsize +
nm0 * nq0 +
nmTot * nq1 + nq0 * nq1;
96template <
bool DEFORMED,
typename TthreadBlock,
typename TData>
98 const unsigned int nm0,
const unsigned int nq0,
100 const unsigned int offset_seg,
const TData *
NEK_RESTRICT invintmass,
106 const unsigned int idx0 = getLocalIdx(
threadBlock);
107 const unsigned int stride = getLocalRange(
threadBlock);
111 const unsigned int nmBndSeg = 2;
112 const unsigned int nmInt =
nm0 - nmBndSeg;
117 for (
unsigned int i = idx0; i < nmBndSeg; i += stride)
119 unsigned int idBnd = i == 0 ? 0 : nq0 - 1;
130 for (
unsigned int i = idx0; i < nq0; i += stride)
132 if constexpr (DEFORMED)
134 wsp2[i] = (
in[i] - wsp2[i]) *
jac[i] * w0[i];
138 wsp2[i] = (
in[i] - wsp2[i]) * w0[i];
147 IProductWRTBaseSegSumFacTOPKernel<false, false>(
152 Nektar::MatVecSumFacTOPKernel<false, false>(
153 nmInt, invintmass, wsp1 + offset_seg,
out + offset_seg,
threadBlock);
156template <
bool DEFORMED,
typename TthreadBlock,
typename TData>
158 const unsigned int nm0,
const unsigned int nm1,
const unsigned int nmTot,
159 const unsigned int nq0,
const unsigned int nq1,
162 const unsigned int offset_seg,
const TData *
NEK_RESTRICT invintmass0,
165 const unsigned int nmTotInt,
const unsigned int *iMap,
173 const unsigned int idx0 = getLocalIdx(
threadBlock);
174 const unsigned int stride = getLocalRange(
threadBlock);
177 const unsigned int nqTot = nq0 * nq1;
178 const unsigned int nmEdgeTot = 2 *
nm0 + 2 *
nm1;
181 for (
unsigned int i = idx0; i < nq0; i += stride)
184 wsp1[i + nq0 + nq1] =
in[nq0 * (nq1 - 1) + i];
186 for (
unsigned int i = idx0; i < nq1; i += stride)
188 wsp1[i + nq0] =
in[nq0 - 1 + i * nq0];
189 wsp1[i + 2 * nq0 + nq1] =
in[i * nq0];
193 for (
unsigned int i = idx0; i < nmEdgeTot; i += stride)
204 FwdTransBCSegSumFacTOPKernel<false>(
nm0, nq0, basis0, w0, offset_seg,
205 invintmass0, tJac, wsp1, wsp2, wsp3,
207 FwdTransBCSegSumFacTOPKernel<false>(
nm1, nq1, basis1, w1, offset_seg,
208 invintmass1, tJac + 1, wsp1 + nq0,
210 FwdTransBCSegSumFacTOPKernel<false>(
211 nm0, nq0, basis0, w0, offset_seg, invintmass0, tJac + 2,
213 FwdTransBCSegSumFacTOPKernel<false>(
214 nm1, nq1, basis1, w1, offset_seg, invintmass1, tJac + 3,
218 for (
unsigned int j = idx0; j < nmEdgeTot; j += stride)
220 out[tMap[j]] = tSign[j] * wsp2[j];
227 BwdTransQuadSumFacTOPKernel<false>(
nm0,
nm1, nq0, nq1, nqTot, basis0,
231 for (
unsigned int idx = idx0; idx < nqTot; idx += stride)
233 const unsigned int i = idx % nq0;
234 const unsigned int j = idx / nq0;
235 if constexpr (DEFORMED)
237 wsp1[idx] = (
in[idx] - wsp1[idx]) *
jac[idx] * w0[i] * w1[j];
241 wsp1[idx] = (
in[idx] - wsp1[idx]) * w0[i] * w1[j];
249 IProductWRTBaseQuadSumFacTOPKernel<false, false>(
250 nm0,
nm1,
nmTot, nq0, nq1, nqTot, basis0, basis1, wsp1, wsp2, wsp3,
255 for (
unsigned int j = idx0; j < nmTotInt; j += stride)
257 wsp1[j] = wsp2[iMap[j]];
264 Nektar::MatVecSumFacTOPKernel<false, false>(nmTotInt, invintmass, wsp1,
268 for (
unsigned int j = idx0; j < nmTotInt; j += stride)
270 out[iMap[j]] = wsp2[j];
277template <
bool DEFORMED,
typename TthreadBlock,
typename TData>
279 const unsigned int nm0,
const unsigned int nm1,
const unsigned int nmTot,
280 const unsigned int nq0,
const unsigned int nq1,
const bool isModified,
284 const unsigned int offset_seg,
const TData *
NEK_RESTRICT invintmass0,
286 const int *
NEK_RESTRICT tSign,
const unsigned int nmTotInt,
287 const unsigned int *iMap,
const TData *
NEK_RESTRICT invintmass,
294 const unsigned int idx0 = getLocalIdx(
threadBlock);
295 const unsigned int stride = getLocalRange(
threadBlock);
298 const unsigned int nqTot = nq0 * nq1;
299 const unsigned int nmEdgeTot =
nm0 + 2 *
nm1;
303 for (
unsigned int i = idx0; i < nq0; i += stride)
308 tmp = 0.0, tmp2 = 0.0;
309 for (
unsigned int j = 0u; j < nq1; j++)
311 tmp +=
in[nq0 - 1 + j * nq0] * interp1to0T[j * nq0 + i];
312 tmp2 +=
in[j * nq0] * interp1to0T[j * nq0 + i];
317 wsp1[i + 2 * nq0] = tmp2;
324 for (
unsigned int i = idx0; i < nmEdgeTot; i += stride)
334 FwdTransBCSegSumFacTOPKernel<false>(
nm0, nq0, basis0, w0, offset_seg,
335 invintmass0, tJac, wsp1, wsp2, wsp3,
337 FwdTransBCSegSumFacTOPKernel<false>(
nm0, nq0, basis0, w0, offset_seg,
338 invintmass0, tJac + 1, wsp1 + nq0,
342 for (
unsigned int j = idx0; j < 2 *
nm0; j += stride)
344 out[tMap[j]] = tSign[j] * wsp2[j];
347 FwdTransBCSegSumFacTOPKernel<false>(
348 nm0, nq0, basis0, w0, offset_seg, invintmass0, tJac + 2,
352 for (
unsigned int j = idx0; j <
nm0; j += stride)
361 BwdTransTriSumFacTOPKernel<false>(
nm0,
nm1, nq0, nq1, nqTot, isModified,
362 basis0, basis1,
out, wsp1, wsp2,
366 for (
unsigned int idx = idx0; idx < nqTot; idx += stride)
368 const unsigned int i = idx % nq0;
369 const unsigned int j = idx / nq0;
370 if constexpr (DEFORMED)
372 wsp1[idx] = (
in[idx] - wsp1[idx]) *
jac[idx] * w0[i] * w1[j];
376 wsp1[idx] = (
in[idx] - wsp1[idx]) * w0[i] * w1[j];
384 IProductWRTBaseTriSumFacTOPKernel<false, false>(
385 nm0,
nm1,
nmTot, nq0, nq1, nqTot, isModified, index0, basis0, basis1,
390 for (
unsigned int j = idx0; j < nmTotInt; j += stride)
392 wsp1[j] = wsp2[iMap[j]];
399 Nektar::MatVecSumFacTOPKernel<false, false>(nmTotInt, invintmass, wsp1,
403 for (
unsigned int j = idx0; j < nmTotInt; j += stride)
405 out[iMap[j]] = wsp2[j];
412template <
bool DEFORMED,
typename TthreadBlock,
typename TData>
414 const unsigned int nm0,
const unsigned int nq0,
const size_t nelmt,
416 const unsigned int offset_seg,
const TData *
NEK_RESTRICT invintmass,
422 const unsigned int jacsize = DEFORMED ? nq0 : 1u;
426 TData *s_basis0 = (TData *)
shmemptr + 2 * nq0;
436 const TData *jacptr =
jac + jacsize *
e;
437 const TData *inptr =
in + nq0 *
e;
442 TData *s_wsp2 =
s_wsp1 + nq0;
444 FwdTransBCSegSumFacTOPKernel<DEFORMED>(
445 nm0, nq0, s_basis0, w0, offset_seg, invintmass, jacptr, inptr,
454 typename TthreadBlock,
typename TData>
456 const unsigned int nm0,
const unsigned int nm1,
const unsigned int nmTot,
457 const unsigned int nq0,
const unsigned int nq1,
const size_t nelmt,
458 const bool isModified,
const unsigned int *
NEK_RESTRICT index0,
461 const TData *
NEK_RESTRICT interp1to0,
const unsigned int offset_seg,
465 const unsigned int nmTotInt,
const unsigned int *iMap,
471 const unsigned int nqTot = nq0 * nq1;
472 const unsigned int jacsize = DEFORMED ? nqTot : 1u;
474 unsigned int nEdges = 0;
484 const unsigned int *tmapptr = tMap;
485 const int *tsignptr = tSign;
486 const unsigned int *imapptr = iMap;
490 const unsigned int nmode1 =
494 (TData *)
shmemptr + FwdTransBCWorkSpaceSize2D(SHAPE_TYPE, nq0, nq1);
495 TData *s_basis1 = s_basis0 +
nm0 * nq0;
496 TData *s_interp1to0 = s_basis1 + nmode1 * nq1;
498 const unsigned int idx0 = getLocalIdx(
threadBlock);
499 const unsigned int stride = getLocalRange(
threadBlock);
503 LoadToSharedMemory(nmode1 * nq1, basis1, s_basis1,
threadBlock);
507 for (
unsigned int idx = idx0; idx < nq0 * nq1; idx += stride)
509 s_interp1to0[(idx % nq1) * nq0 + idx / nq1] = interp1to0[idx];
518 const TData *tjacptr = tJac + nEdges *
e;
519 const TData *massintptr =
520 (DEFORMED) ? invintmass + nmTotInt * nmTotInt *
e : invintmass;
521 const TData *jacptr =
jac + jacsize *
e;
522 const TData *inptr =
in + nqTot *
e;
529 TData *s_wsp2 =
s_wsp1 + std::max(nqTot, 2 * nq0 + 2 * nq1);
530 TData *s_wsp3 = s_wsp2 + nqTot;
531 TData *s_wsp4 = s_wsp3 + nqTot;
533 FwdTransBCQuadSumFacTOPKernel<DEFORMED>(
534 nm0,
nm1,
nmTot, nq0, nq1, s_basis0, s_basis1, w0, w1,
535 offset_seg, invintmass0, invintmass1, tjacptr, tmapptr,
536 tsignptr, nmTotInt, imapptr, massintptr, jacptr, inptr, outptr,
543 TData *s_wsp2 =
s_wsp1 + nqTot;
544 TData *s_wsp3 = s_wsp2 + nqTot;
545 TData *s_wsp4 = s_wsp3 + nqTot;
547 FwdTransBCTriSumFacTOPKernel<DEFORMED>(
548 nm0,
nm1,
nmTot, nq0, nq1, isModified, index0, s_basis0,
549 s_basis1, w0, w1, s_interp1to0, offset_seg, invintmass0,
550 tjacptr, tmapptr, tsignptr, nmTotInt, imapptr, massintptr,
551 jacptr, inptr, outptr,
s_wsp1, s_wsp2, s_wsp3, s_wsp4,
561template <
bool DEFORMED,
typename TthreadBlock,
typename TData>
563 const unsigned int nm0,
const unsigned int nq0,
const size_t nelmt,
565 const unsigned int offset_seg,
const TData *
NEK_RESTRICT invintmass,
572 FwdTransBC1DKernel<DEFORMED>(
nm0, nq0,
nelmt, basis0, w0, offset_seg,
579 typename TthreadBlock,
typename TData>
581 const unsigned int nm0,
const unsigned int nm1,
const unsigned int nmTot,
582 const unsigned int nq0,
const unsigned int nq1,
const size_t nelmt,
583 const bool isModified,
const unsigned int *
NEK_RESTRICT index0,
586 const TData *
NEK_RESTRICT interp1to0,
const unsigned int offsetSeg,
590 const unsigned int nmTotInt,
const unsigned int *iMap,
597 FwdTransBC2DKernel<SHAPE_TYPE, DEFORMED>(
598 nm0,
nm1,
nmTot, nq0, nq1,
nelmt, isModified, index0, basis0, basis1,
599 w0, w1, interp1to0, offsetSeg, invintmass0, invintmass1, tJac, tMap,
#define NEK_DEVICE_INLINE
#define NEK_HOSTDEVICE_INLINE
#define NEK_DEVICE_KERNEL
Device SumFacTOP kernels of the backward transform: one element, or a group of them,...
Device SumFacTOP kernels of the inner product with the basis: one element, or a group of them,...
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
static NEK_FORCE_INLINE void FwdTransBC1DKernel(const unsigned int nm0, const unsigned int nq0, const typename simd_type::scalarType *basis0, const typename simd_type::scalarType *w0, const unsigned int offset_seg, const simd_type *invintmass, const simd_type *jac, const simd_type *in, simd_type *out, simd_type *wsp1, simd_type *wsp2)
FETCH_SHARED_MEMORY(shmemptr)
static NEK_FORCE_INLINE void FwdTransBC2DKernel(const unsigned int nm0, const unsigned int nm1, const unsigned int nq0, const unsigned int nq1, const bool isModified, const typename simd_type::scalarType *basis0, const typename simd_type::scalarType *basis1, const typename simd_type::scalarType *w0, const typename simd_type::scalarType *w1, const typename simd_type::scalarType *interp1to0, const unsigned int offset_seg, const simd_type *invintmass0, const simd_type *invintmass1, const simd_type *tJac, const unsigned int *tMap, const int *tSign, const unsigned int nmTotInt, const unsigned int *iMap, const simd_type *invintmass, const simd_type *jac, const simd_type *in, simd_type *out, simd_type *wsp1, simd_type *wsp2, simd_type *wsp3, simd_type *wsp4)
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
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
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