88 void *alpha_d ,
real *alpha,
int *p_cur,
int * n) {
90 const dim3 nthrds(1024, 1, 1);
91 const dim3 nblcks(((*n)+1024 - 1)/ 1024, 1, 1);
92 const int nb = ((*n) + 1024 - 1)/ 1024;
101 fusedcg_buf[1] = (*alpha);
104 real *alpha_d_p_cur = ((
real *) alpha_d) + ((*p_cur - 1));
105 CUDA_CHECK(cudaMemcpyAsync(alpha_d_p_cur, &fusedcg_buf[1],
sizeof(
real),
106 cudaMemcpyHostToDevice, stream));
110 <<<nblcks, nthrds, 0, stream>>>((
real *) a, (
real *) b,
112 (
real *) fusedcg_buf_d, * n);
121 CUDA_CHECK(cudaMemcpyAsync(fusedcg_buf, fusedcg_buf_d,
sizeof(
real),
122 cudaMemcpyDeviceToHost, stream));
123 cudaStreamSynchronize(stream);
125 if (
sizeof(
real) ==
sizeof(
float)) {
126 nvshmemx_float_sum_reduce_on_stream(NVSHMEM_TEAM_WORLD,
127 (
float *) fusedcg_buf_d,
128 (
float *) fusedcg_buf_d, 1, stream);
130 else if (
sizeof(
real) ==
sizeof(
double)) {
131 nvshmemx_double_sum_reduce_on_stream(NVSHMEM_TEAM_WORLD,
132 (
double *) fusedcg_buf_d,
133 (
double *) fusedcg_buf_d, 1, stream);
136 CUDA_CHECK(cudaMemcpyAsync(fusedcg_buf, fusedcg_buf_d,
137 sizeof(
real), cudaMemcpyDeviceToHost, stream));
138 cudaStreamSynchronize(stream);
140 cudaStreamSynchronize(stream);
144 CUDA_CHECK(cudaMemcpyAsync(fusedcg_buf, fusedcg_buf_d,
sizeof(
real),
145 cudaMemcpyDeviceToHost, stream));
146 cudaStreamSynchronize(stream);
149 return fusedcg_buf[0];
__global__ void fusedcg_part2_kernel(T *__restrict__ a, const T *__restrict__ b, const T *__restrict__ c, const T alpha, T *buf_h, const int n)
real cuda_fusedcg_part2(void *a, void *b, void *c, void *alpha_d, real *alpha, int *p_cur, int *n)