DFT-EFE
 
Loading...
Searching...
No Matches
BlasLapackKernels.h
Go to the documentation of this file.
1#ifndef dftefeKernels_h
2#define dftefeKernels_h
3
7#include <vector>
8
9namespace dftefe
10{
11 namespace linearAlgebra
12 {
13 namespace blasLapack
14 {
18 template <typename ValueType1,
19 typename ValueType2,
22 {
23 public:
31 static void
32 ascale(size_type size,
33 ValueType1 alpha,
34 const ValueType2 * x,
37
45 static void
46 ascale(size_type size,
47 ValueType1 alpha,
48 const ValueType2 * x,
49 const ScalarOp & opalpha,
50 const ScalarOp & opx,
53
60 static void
62 const ValueType1 alpha,
63 const ValueType2 * x,
66 /*
67 * @brief Template for performing \f$ z_i = x_i * y_i$
68 * @param[in] size size of the array
69 * @param[in] x array
70 * @param[in] y array
71 * @param[out] z array
72 */
73 static void
75 const ValueType1 * x,
76 const ValueType2 * y,
79
80 // /*
81 // * @brief Template for performing \f$ blockedOutput_ij = blockedInput_ij * singleVectorInput_i$
82 // * @param[in] size size of the blocked Input array
83 // * @param[in] numComponets no of componets
84 // * @param[in] blockedInput blocked array
85 // * @param[in] singleVectorInput array
86 // * @param[out] blockedOutput blocked array
87 // */
88 // static void
89 // blockedHadamardProduct(const size_type vecSize,
90 // const size_type numComponents,
91 // const ValueType1 * blockedInput,
92 // const ValueType2 * singleVectorInput,
93 // scalar_type<ValueType1, ValueType2> *blockedOutput);
94
95 static void
97 const ValueType1 * x,
98 const ValueType2 * y,
99 const ScalarOp & opx,
100 const ScalarOp & opy,
103
131 static void
132 scaleStridedVarBatched(const size_type numMats,
133 const Layout layout,
134 const ScalarOp & scalarOpA,
135 const ScalarOp & scalarOpB,
136 const size_type * stridea,
137 const size_type * strideb,
138 const size_type * stridec,
139 const size_type * m,
140 const size_type * n,
141 const size_type * k,
142 const ValueType1 * dA,
143 const ValueType2 * dB,
146
171 static void
172 khatriRaoProduct(const Layout layout,
173 const size_type sizeI,
174 const size_type sizeJ,
175 const size_type sizeK,
176 const ValueType1 * A,
177 const ValueType2 * B,
180
190 static void
191 axpby(size_type size,
193 const ValueType1 * x,
195 const ValueType2 * y,
198
208 static void
209 axpbyBlocked(const size_type size,
210 const size_type blockSize,
213 const ValueType1 * x,
216 const ValueType2 * y,
219
238 static void
240 size_type numVec,
241 const ValueType1 * multiVecDataX,
242 const ValueType2 * multiVecDataY,
243 const ScalarOp & opX,
244 const ScalarOp & opY,
245 scalar_type<ValueType1, ValueType2> *multiVecDotProduct,
247 };
248
249 template <typename ValueType, dftefe::utils::MemorySpace memorySpace>
251 {
252 public:
262 static std::vector<double>
263 amaxsMultiVector(const size_type vecSize,
264 const size_type numVec,
265 ValueType const * multiVecData,
267
277 static std::vector<double>
279 size_type numVec,
280 const ValueType * multiVecData,
282 };
283
284 template <typename ValueType, dftefe::utils::MemorySpace memorySpace>
286 {
287 public:
288 };
289
290 template <typename ValueType1,
291 typename ValueType2,
292 dftefe::utils::MemorySpace memorySpace>
294 {
295 public:
296 static void
297 stridedBlockCopy(const size_type vecSize,
298 const size_type numVec,
299 const size_type srcLeadingDim,
300 const size_type srcBlockStartId,
301 const size_type dstLeadingDim,
302 const size_type dstBlockStartId,
303 const ValueType1 * copyFromVec,
304 ValueType2 * copyToVec,
306
307 static void
309 const ValueType1 *valueType1Arr,
310 ValueType2 * valueType2Arr,
312
313 static void
315 const size_type * strideSrc,
316 const size_type * strideDst,
317 const size_type * vecSizeArr,
318 const size_type * numVecArr,
319 const size_type * srcLeadingDimArr,
320 const size_type * srcBlockStartIdArr,
321 const size_type * dstLeadingDimArr,
322 const size_type * dstBlockStartIdArr,
323 const ValueType1 *copyFromVec,
324 ValueType2 * copyToVec,
326 };
327
328#ifdef DFTEFE_WITH_DEVICE
329 template <typename ValueType>
330 class CopyKernelOneValueType<ValueType,
332 {
333 public:
334 };
335
336 template <typename ValueType1, typename ValueType2>
337 class KernelsTwoValueTypes<ValueType1,
338 ValueType2,
340 {
341 public:
342 static void
343 ascale(size_type size,
344 ValueType1 alpha,
345 const ValueType2 * x,
346 scalar_type<ValueType1, ValueType2> * z,
348
349 static void
350 ascale(size_type size,
351 ValueType1 alpha,
352 const ValueType2 * x,
353 const ScalarOp & opalpha,
354 const ScalarOp & opx,
355 scalar_type<ValueType1, ValueType2> * z,
357 /*
358 * @brief Template for performing \f$ z = 1 /x$, does not check if x[i] is zero
359 * @param[in] size size of the array
360 * @param[in] x array
361 * @param[out] z array
362 */
363 static void
365 size_type size,
366 const ValueType1 alpha,
367 const ValueType2 * x,
368 scalar_type<ValueType1, ValueType2> * z,
370
371 static void
373 size_type size,
374 const ValueType1 * x,
375 const ValueType2 * y,
376 scalar_type<ValueType1, ValueType2> * z,
378
379 static void
381 size_type size,
382 const ValueType1 * x,
383 const ValueType2 * y,
384 const ScalarOp & opx,
385 const ScalarOp & opy,
386 scalar_type<ValueType1, ValueType2> * z,
388
389 static void
391 const size_type numMats,
392 const Layout layout,
393 const ScalarOp & scalarOpA,
394 const ScalarOp & scalarOpB,
395 const size_type * stridea,
396 const size_type * strideb,
397 const size_type * stridec,
398 const size_type * m,
399 const size_type * n,
400 const size_type * k,
401 const ValueType1 * dA,
402 const ValueType2 * dB,
403 scalar_type<ValueType1, ValueType2> * dC,
405
406 static void
408 const Layout layout,
409 const size_type sizeI,
410 const size_type sizeJ,
411 const size_type sizeK,
412 const ValueType1 * A,
413 const ValueType2 * B,
414 scalar_type<ValueType1, ValueType2> * Z,
416
417 static void
418 axpby(size_type size,
419 scalar_type<ValueType1, ValueType2> alpha,
420 const ValueType1 * x,
421 scalar_type<ValueType1, ValueType2> beta,
422 const ValueType2 * y,
423 scalar_type<ValueType1, ValueType2> * z,
425
426 static void
428 const size_type size,
429 const size_type blockSize,
430 const scalar_type<ValueType1, ValueType2> alpha1,
431 const scalar_type<ValueType1, ValueType2> * alpha,
432 const ValueType1 * x,
433 const scalar_type<ValueType1, ValueType2> beta1,
434 const scalar_type<ValueType1, ValueType2> * beta,
435 const ValueType2 * y,
436 scalar_type<ValueType1, ValueType2> * z,
438
439 static void
441 size_type vecSize,
442 size_type numVec,
443 const ValueType1 * multiVecDataX,
444 const ValueType2 * multiVecDataY,
445 const ScalarOp & opX,
446 const ScalarOp & opY,
447 scalar_type<ValueType1, ValueType2> *multiVecDotProduct,
449 };
450
451 template <typename ValueType>
452 class KernelsOneValueType<ValueType, dftefe::utils::MemorySpace::DEVICE>
453 {
454 public:
455 static std::vector<double>
457 const size_type vecSize,
458 const size_type numVec,
459 ValueType const * multiVecData,
460 LinAlgOpContext<dftefe::utils::MemorySpace::DEVICE> &context);
461
462
463 static std::vector<double>
465 size_type vecSize,
466 size_type numVec,
467 const ValueType * multiVecData,
468 LinAlgOpContext<dftefe::utils::MemorySpace::DEVICE> &context);
469 };
470
471 template <typename ValueType1, typename ValueType2>
472 class CopyKernelTwoValueTypes<ValueType1,
473 ValueType2,
475 {
476 public:
477 static void
479 const size_type vecSize,
480 const size_type numVec,
481 const size_type srcLeadingDim,
482 const size_type srcBlockStartId,
483 const size_type dstLeadingDim,
484 const size_type dstBlockStartId,
485 const ValueType1 * copyFromVec,
486 ValueType2 * copyToVec,
487 LinAlgOpContext<dftefe::utils::MemorySpace::DEVICE> &context);
488
489 static void
491 const size_type size,
492 const ValueType1 * valueType1Arr,
493 ValueType2 * valueType2Arr,
494 LinAlgOpContext<dftefe::utils::MemorySpace::DEVICE> &context);
495
496 static void
498 const size_type numBatch,
499 const size_type * strideSrc,
500 const size_type * strideDst,
501 const size_type * vecSizeArr,
502 const size_type * numVecArr,
503 const size_type * srcLeadingDimArr,
504 const size_type * srcBlockStartIdArr,
505 const size_type * dstLeadingDimArr,
506 const size_type * dstBlockStartIdArr,
507 const ValueType1 *copyFromVec,
508 ValueType2 * copyToVec,
509 LinAlgOpContext<dftefe::utils::MemorySpace::DEVICE> &context);
510 };
511
512#endif
513
514 } // namespace blasLapack
515 } // namespace linearAlgebra
516} // namespace dftefe
517
518#endif // dftefeKernels_h
Definition: LinAlgOpContext.h:52
static void varBatchedStridedBlockCopy(const size_type numBatch, const size_type *strideSrc, const size_type *strideDst, const size_type *vecSizeArr, const size_type *numVecArr, const size_type *srcLeadingDimArr, const size_type *srcBlockStartIdArr, const size_type *dstLeadingDimArr, const size_type *dstBlockStartIdArr, const ValueType1 *copyFromVec, ValueType2 *copyToVec, LinAlgOpContext< memorySpace > &context)
Definition: BlasLapackKernels.cpp:619
static void stridedBlockCopy(const size_type vecSize, const size_type numVec, const size_type srcLeadingDim, const size_type srcBlockStartId, const size_type dstLeadingDim, const size_type dstBlockStartId, const ValueType1 *copyFromVec, ValueType2 *copyToVec, LinAlgOpContext< memorySpace > &context)
Definition: BlasLapackKernels.cpp:565
static void copyValueType1ArrToValueType2Arr(const size_type size, const ValueType1 *valueType1Arr, ValueType2 *valueType2Arr, LinAlgOpContext< memorySpace > &context)
Definition: BlasLapackKernels.cpp:662
static std::vector< double > nrms2MultiVector(size_type vecSize, size_type numVec, const ValueType *multiVecData, LinAlgOpContext< memorySpace > &context)
Template for computing norms of all the numVec vectors in a multi Vector.
Definition: BlasLapackKernels.cpp:542
static std::vector< double > amaxsMultiVector(const size_type vecSize, const size_type numVec, ValueType const *multiVecData, LinAlgOpContext< memorySpace > &context)
Template for computing norms of all the numVec vectors in a multi Vector.
Definition: BlasLapackKernels.cpp:514
namespace class for BlasLapack kernels not present in blaspp.
Definition: BlasLapackKernels.h:22
static void scaleStridedVarBatched(const size_type numMats, const Layout layout, const ScalarOp &scalarOpA, const ScalarOp &scalarOpB, const size_type *stridea, const size_type *strideb, const size_type *stridec, const size_type *m, const size_type *n, const size_type *k, const ValueType1 *dA, const ValueType2 *dB, scalar_type< ValueType1, ValueType2 > *dC, LinAlgOpContext< memorySpace > &context)
Template for performing hadamard product of two columns of batches of matrix A and B having num col A...
Definition: BlasLapackKernels.cpp:264
static void axpby(size_type size, scalar_type< ValueType1, ValueType2 > alpha, const ValueType1 *x, scalar_type< ValueType1, ValueType2 > beta, const ValueType2 *y, scalar_type< ValueType1, ValueType2 > *z, LinAlgOpContext< memorySpace > &context)
Template for performing .
Definition: BlasLapackKernels.cpp:373
static void ascale(size_type size, ValueType1 alpha, const ValueType2 *x, const ScalarOp &opalpha, const ScalarOp &opx, scalar_type< ValueType1, ValueType2 > *z, LinAlgOpContext< memorySpace > &context)
Template for performing alpha z = \alpha x$.
Definition: BlasLapackKernels.cpp:91
static void hadamardProduct(size_type size, const ValueType1 *x, const ValueType2 *y, scalar_type< ValueType1, ValueType2 > *z, LinAlgOpContext< memorySpace > &context)
Template for performing z_i = x_i * y_i$.
Definition: BlasLapackKernels.cpp:187
static void dotMultiVector(size_type vecSize, size_type numVec, const ValueType1 *multiVecDataX, const ValueType2 *multiVecDataY, const ScalarOp &opX, const ScalarOp &opY, scalar_type< ValueType1, ValueType2 > *multiVecDotProduct, LinAlgOpContext< memorySpace > &context)
Template for computing dot products numVec vectors in a multi Vector.
Definition: BlasLapackKernels.cpp:427
static void axpbyBlocked(const size_type size, const size_type blockSize, const scalar_type< ValueType1, ValueType2 > alpha1, const scalar_type< ValueType1, ValueType2 > *alpha, const ValueType1 *x, const scalar_type< ValueType1, ValueType2 > beta1, const scalar_type< ValueType1, ValueType2 > *beta, const ValueType2 *y, scalar_type< ValueType1, ValueType2 > *z, LinAlgOpContext< memorySpace > &context)
Template for performing .
Definition: BlasLapackKernels.cpp:395
static void khatriRaoProduct(const Layout layout, const size_type sizeI, const size_type sizeJ, const size_type sizeK, const ValueType1 *A, const ValueType2 *B, scalar_type< ValueType1, ValueType2 > *Z, LinAlgOpContext< memorySpace > &context)
Template for performing In column major storage format: , where is matrix, is ,...
Definition: BlasLapackKernels.cpp:340
void reciprocalX(size_type n, const ValueType1 alpha, ValueType2 const *x, scalar_type< ValueType1, ValueType2 > *y, LinAlgOpContext< memorySpace > &context)
Template for computing the multiplicative inverse of all the elements of x, does not check if any ele...
Definition: BlasLapack.t.cpp:78
Layout
Definition: BlasLapackTypedef.h:161
typeInternal::scalar_type< ValueType1, ValueType2 > scalar_type
Definition: BlasLapackTypedef.h:183
ScalarOp
Definition: BlasLapackTypedef.h:169
MemorySpace
Definition: MemorySpaceType.h:37
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
std::uint64_t size_type
Definition: TypeConfig.h:9