ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
exx_batch_op.h
Go to the documentation of this file.
1#ifndef EXX_BATCH_OP_H
2#define EXX_BATCH_OP_H
3
5
6#include <complex>
7
8namespace hamilt
9{
10
11// Batched elementwise / gather-scatter kernels and batched FFT helpers for
12// the n-band inner loop of OperatorEXXPW. All bands of one (iq, m_iband)
13// pair are processed with a single kernel launch / batched FFT instead of
14// one launch per band. The generic implementation (exx_batch_op.cpp) runs on
15// the host with plain loops and FFTW plans; the CUDA explicit
16// specializations (kernels/cuda/exx_batch_op.cu) run the same operations on
17// the GPU with kernels and cuFFT. Instantiated for std::complex<float> and
18// std::complex<double>.
19
20// out[n*nrxx + i] = nk_real_all[n*nrxx + i] * conj(mq_real[i]) / omega
21template <typename T, typename Device>
23 const int nbands,
24 const int nrxx,
25 const T *nk_real_all,
26 const T *mq_real,
27 const double omega,
28 T *out);
29
30// pw[n*npw + ig] = box[n*nxyz + box_map[ig]] / nxyz (real -> recip, gather)
31template <typename T, typename Device>
33 const int nbands,
34 const int npw,
35 const int nxyz,
36 const int *box_map,
37 const T *box,
38 T *pw);
39
40// pw[n*npw + ig] *= pot[ig]
41template <typename T, typename Real, typename Device>
43 const int nbands,
44 const int npw,
45 const Real *pot,
46 T *pw);
47
48// box[n*nxyz + box_map[ig]] = pw[n*npw + ig] (recip -> real, scatter; box pre-zeroed)
49template <typename T, typename Device>
51 const int nbands,
52 const int npw,
53 const int nxyz,
54 const int *box_map,
55 const T *pw,
56 T *box);
57
58// data[n*nrxx + i] *= mq_real[i]
59template <typename T, typename Device>
61 const int nbands,
62 const int nrxx,
63 const T *mq_real,
64 T *data);
65
66// out[n*out_stride + ig] += factor / nxyz * box[n*nxyz + box_map[ig]] (real -> recip, gather + accumulate)
67template <typename T, typename Real, typename Device>
69 const int nbands,
70 const int npwk,
71 const int nxyz,
72 const int *box_map,
73 const T *box,
74 const Real factor,
75 T *out,
76 const int out_stride);
77
78// box[n*nxyz + map[ig]] = psi[n*psi_stride + ig] (scatter PW coefficients into the box; box pre-zeroed)
79template <typename T, typename Device>
81 const int nbands,
82 const int npwk,
83 const int nxyz,
84 const int *map,
85 const T *psi,
86 const int psi_stride,
87 T *box);
88
89// Batched in-place 3D complex-to-complex FFT over the (nx, ny, nz) grid,
90// batch = nbands transforms with contiguous distance nx*ny*nz, matching the
91// layout of cufftPlan3d used in FFT_CUDA.
92template <typename T, typename Device>
94 void **plan,
95 const int nx,
96 const int ny,
97 const int nz,
98 const int batch);
99
100// forward = FFT_FORWARD, otherwise FFT_BACKWARD (unnormalized, as in FFT_CUDA)
101template <typename T, typename Device>
102void exx_batch_fft_exec(void *plan, T *data, const bool forward);
103
104template <typename T, typename Device>
106
107} // namespace hamilt
108
109#endif // EXX_BATCH_OP_H
#define T
Definition exp.cpp:237
Definition wf_op.cpp:6
void exx_batch_gather_pw(const int nbands, const int npw, const int nxyz, const int *box_map, const T *box, T *pw)
Definition exx_batch_op.cpp:37
void exx_batch_fft_exec(void *plan, T *data, const bool forward)
void exx_batch_gather_accum(const int nbands, const int npwk, const int nxyz, const int *box_map, const T *box, const Real factor, T *out, const int out_stride)
Definition exx_batch_op.cpp:113
void exx_batch_density_real(const int nbands, const int nrxx, const T *nk_real_all, const T *mq_real, const double omega, T *out)
Definition exx_batch_op.cpp:15
void exx_batch_fft_plan_create(void **plan, const int nx, const int ny, const int nz, const int batch)
void exx_batch_fft_plan_destroy(void **plan)
void exx_batch_mul_real(const int nbands, const int nrxx, const T *mq_real, T *data)
Definition exx_batch_op.cpp:96
void exx_batch_mul_pot(const int nbands, const int npw, const Real *pot, T *pw)
Definition exx_batch_op.cpp:59
void exx_batch_scatter_pw(const int nbands, const int npw, const int nxyz, const int *box_map, const T *pw, T *box)
Definition exx_batch_op.cpp:76
void exx_batch_scatter_wfc(const int nbands, const int npwk, const int nxyz, const int *map, const T *psi, const int psi_stride, T *box)
Definition exx_batch_op.cpp:136