57 void *b1,
void *b2,
void *b3,
60 const dim3 nthrds(1024, 1, 1);
61 const dim3 nblcks(((*n)+1024 - 1)/ 1024, 1, 1);
65 <<<nblcks, nthrds, 0, stream>>>((
real *) a1, (
real *) a2, (
real *) a3,
72 void *z1,
void *z2,
void *z3,
73 void *po1,
void *po2,
void *po3,
76 const dim3 nthrds(1024, 1, 1);
77 const dim3 nblcks(((*n)+1024 - 1)/ 1024, 1, 1);
81 <<<nblcks, nthrds, 0, stream>>>((
real *) p1, (
real *) p2, (
real *) p3,
90 void *p1,
void *p2,
void *p3,
91 void *alpha,
int *p_cur,
int *n) {
93 const dim3 nthrds(1024, 1, 1);
94 const dim3 nblcks(((*n)+1024 - 1)/ 1024, 1, 1);
98 <<<nblcks, nthrds, 0, stream>>>((
real *) x1, (
real *) x2, (
real *) x3,
99 (
const real **) p1, (
const real **) p2,
100 (
const real **) p3, (
const real *) alpha,
106 void *c1,
void *c2,
void *c3,
void *alpha_d ,
107 real *alpha,
int *p_cur,
int * n) {
109 const dim3 nthrds(1024, 1, 1);
110 const dim3 nblcks(((*n)+1024 - 1)/ 1024, 1, 1);
111 const int nb = ((*n) + 1024 - 1)/ 1024;
120 fusedcg_cpld_buf[1] = (*alpha);
123 real *alpha_d_p_cur = ((
real *) alpha_d) + ((*p_cur - 1));
124 CUDA_CHECK(cudaMemcpyAsync(alpha_d_p_cur, &fusedcg_cpld_buf[1],
125 sizeof(
real), cudaMemcpyHostToDevice,
130 <<<nblcks, nthrds, 0, stream>>>((
real *) a1, (
real *) a2, (
real *) a3,
133 (
real *) fusedcg_cpld_buf_d, *n);
139#ifdef HAVE_DEVICE_MPI
140 cudaStreamSynchronize(stream);
144 if (
sizeof(
real) ==
sizeof(
float)) {
145 nvshmemx_float_sum_reduce_on_stream(NVSHMEM_TEAM_WORLD,
146 (
float *) fusedcg_cpld_buf_d,
147 (
float *) fusedcg_cpld_buf_d,
150 else if (
sizeof(
real) ==
sizeof(
double)) {
151 nvshmemx_double_sum_reduce_on_stream(NVSHMEM_TEAM_WORLD,
152 (
double *) fusedcg_cpld_buf_d,
153 (
double *) fusedcg_cpld_buf_d,
157 CUDA_CHECK(cudaMemcpyAsync(fusedcg_cpld_buf, fusedcg_cpld_buf_d,
158 sizeof(
real), cudaMemcpyDeviceToHost, stream));
159 cudaStreamSynchronize(stream);
161 CUDA_CHECK(cudaMemcpyAsync(fusedcg_cpld_buf, fusedcg_cpld_buf_d,
sizeof(
real),
162 cudaMemcpyDeviceToHost, stream));
163 cudaStreamSynchronize(stream);
166 return fusedcg_cpld_buf[0];
void cuda_buffer_reserve(cuda_buffer_t *buf, size_t size)
struct cuda_buffer cuda_buffer_t
#define CUDA_BUFFER_INIT_SYMM
__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)
__global__ void reduce_kernel(T *bufred, const int n)
void device_mpi_allreduce(void *buf_d, void *buf, int count, int nbytes, int op)
void cuda_fusedcg_cpld_update_x(void *x1, void *x2, void *x3, void *p1, void *p2, void *p3, void *alpha, int *p_cur, int *n)
void cuda_fusedcg_cpld_part1(void *a1, void *a2, void *a3, void *b1, void *b2, void *b3, void *tmp, int *n)
real cuda_fusedcg_cpld_part2(void *a1, void *a2, void *a3, void *b, void *c1, void *c2, void *c3, void *alpha_d, real *alpha, int *p_cur, int *n)
cuda_buffer_t fusedcg_cpld_redbuf
void cuda_fusedcg_cpld_update_p(void *p1, void *p2, void *p3, void *z1, void *z2, void *z3, void *po1, void *po2, void *po3, real *beta, int *n)