1#ifndef __KRYLOV_FUSEDCG_CPLD_KERNEL_H__
2#define __KRYLOV_FUSEDCG_CPLD_KERNEL_H__
53 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
54 const int str = blockDim.x * gridDim.x;
56 for (
int i = idx;
i < n;
i+= str) {
57 tmp[
i] = a1[
i]*b1[
i] + a2[
i]*b2[
i] + a3[
i]*b3[
i];
69 const T * __restrict__ z1,
70 const T * __restrict__ z2,
71 const T * __restrict__ z3,
72 const T * __restrict__ po1,
73 const T * __restrict__ po2,
74 const T * __restrict__ po3,
78 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
79 const int str = blockDim.x * gridDim.x;
81 for (
int i = idx;
i < n;
i+= str) {
82 p1[
i] = beta*po1[
i] + z1[
i];
83 p2[
i] = beta*po2[
i] + z2[
i];
84 p3[
i] = beta*po3[
i] + z3[
i];
99 const T * __restrict__ alpha,
103 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
104 const int str = blockDim.x * gridDim.x;
106 for (
int i = idx;
i < n;
i+= str) {
110 for (
int j = 0;
j < p_cur;
j ++) {
111 tmp1 += p1[
j][
i] * alpha[
j];
112 tmp2 += p2[
j][
i] * alpha[
j];
113 tmp3 += p3[
j][
i] * alpha[
j];
129 const T * __restrict__ b,
130 const T * __restrict__ c1,
131 const T * __restrict__ c2,
132 const T * __restrict__ c3,
137 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
138 const int str = blockDim.x * gridDim.x;
143 __shared__ T buf[32];
146 for (
int i = idx;
i < n;
i+= str) {
147 T rt1 = a1[
i] - alpha * c1[
i];
148 T rt2 = a2[
i] - alpha * c2[
i];
149 T rt3 = a3[
i] - alpha * c3[
i];
150 tmp = tmp + ((rt1*rt1 + rt2*rt2 + rt3*rt3) * b[
i]);
162 tmp = (threadIdx.x < blockDim.x /
NEKO_WAVE_SIZE) ? buf[lane] : 0;
167 if (threadIdx.x == 0) {
168 buf_h[blockIdx.x] = tmp;
__global__ void fusedcg_cpld_update_p_kernel(T *__restrict__ p1, T *__restrict__ p2, T *__restrict__ p3, const T *__restrict__ z1, const T *__restrict__ z2, const T *__restrict__ z3, const T *__restrict__ po1, const T *__restrict__ po2, const T *__restrict__ po3, const T beta, const int n)
__global__ void fusedcg_cpld_part2_kernel(T *__restrict__ a1, T *__restrict__ a2, T *__restrict__ a3, const T *__restrict__ b, const T *__restrict__ c1, const T *__restrict__ c2, const T *__restrict__ c3, const T alpha, T *buf_h, const int n)
__global__ void fusedcg_cpld_update_x_kernel(T *__restrict__ x1, T *__restrict__ x2, T *__restrict__ x3, const T **p1, const T **p2, const T **p3, const T *__restrict__ alpha, const int p_cur, const int n)
__global__ void fusedcg_cpld_part1_kernel(T *__restrict__ a1, T *__restrict__ a2, T *__restrict__ a3, T *__restrict__ b1, T *__restrict__ b2, T *__restrict__ b3, T *__restrict__ tmp, const int n)
__inline__ __device__ T reduce_warp(T val)