ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
dgemm_vbatch.h
Go to the documentation of this file.
1#ifndef ABACUS_SOURCE_HAMILT_MODULE_GINT_KERNEL_DGEMM_VBATCH_H
2#define ABACUS_SOURCE_HAMILT_MODULE_GINT_KERNEL_DGEMM_VBATCH_H
3
4#include <cuda_runtime.h>
5
6// Shape-exact batched GEMM dispatchers.
7//
8// Every (A_i, B_i, C_i) in the batch has exactly the same (m, n, k); the
9// caller (phi_operator_gpu.cu) guarantees this by bucketing atom pairs on
10// (nw1, nw2) before calling in. The scalar m/n/k drive tile-ladder selection,
11// grid sizing, and the kernel itself -- there is no per-batch-id M/N/K
12// indirection.
13//
14// The C output is always double, independent of T. For T=float the per-item
15// inner products accumulate in fp32, but the cross-item accumulation into a
16// shared C element is done with a device-side fp64 atomicAdd (see the kernels'
17// store loop), so summing many atom-pair contributions into the same
18// hr_gint / phi_dm element does not drift. For T=double, A, B and C are all
19// double.
20
21// C(batch) = alpha * A(batch) * B(batch) + C(batch)
22template <typename T>
24 int m,
25 int n,
26 int k,
27 const T *const *A_array_d,
28 const int *lda_d,
29 const T *const *B_array_d,
30 const int *ldb_d,
31 double **C_array_d,
32 const int *ldc_d,
33 int batchCount,
34 cudaStream_t stream,
35 const T *alpha = nullptr);
36
37// C(batch) = alpha * A(batch)^T * B(batch) + C(batch)
38template <typename T>
40 int m,
41 int n,
42 int k,
43 const T *const *A_array_d,
44 const int *lda_d,
45 const T *const *B_array_d,
46 const int *ldb_d,
47 double **C_array_d,
48 const int *ldc_d,
49 int batchCount,
50 cudaStream_t stream,
51 const T *alpha = nullptr);
52
53#endif // ABACUS_SOURCE_HAMILT_MODULE_GINT_KERNEL_DGEMM_VBATCH_H
void gemm_tn_vbatch(int m, int n, int k, const T *const *A_array_d, const int *lda_d, const T *const *B_array_d, const int *ldb_d, double **C_array_d, const int *ldc_d, int batchCount, cudaStream_t stream, const T *alpha=nullptr)
void gemm_nn_vbatch(int m, int n, int k, const T *const *A_array_d, const int *lda_d, const T *const *B_array_d, const int *ldb_d, double **C_array_d, const int *ldc_d, int batchCount, cudaStream_t stream, const T *alpha=nullptr)
#define T
Definition exp.cpp:237