Neko 1.99.5
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
gs_nvshmem.cu
Go to the documentation of this file.
1/*
2 Copyright (c) 2024-2025, The Neko Authors
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 * Redistributions in binary form must reproduce the above
13 copyright notice, this list of conditions and the following
14 disclaimer in the documentation and/or other materials provided
15 with the distribution.
16
17 * Neither the name of the authors nor the names of its
18 contributors may be used to endorse or promote products derived
19 from this software without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 POSSIBILITY OF SUCH DAMAGE.
33*/
34
36#include <device/cuda/check.h>
37#ifdef HAVE_NVSHMEM
38#include <nvshmem.h>
39#include "gs_nvshmem_kernels.h"
40#endif
41
42extern "C" {
43
44#ifdef HAVE_NVSHMEM
45 void cudamalloc_nvshmem(void** ptr, size_t size)
46 {
47 *ptr = nvshmem_malloc(size);
49 cudaMemset(*ptr, 0, size);
51 }
52
53 void cudafree_nvshmem(void** ptr, size_t size)
54 {
55 nvshmem_free(*ptr);
57 }
58
66 void cuda_gs_pack_and_push(void *u_d, void *sbuf_d, void *sdof_d,
67 int soffset, int n, cudaStream_t stream,
68 int destRank, void *rbuf_d, int roffset,
69 int iter, void *done_d, void *ready_d,
70 int mype)
71 {
72 const int nthrds = 1024;
73
75 <<<1,nthrds,0,stream>>>((real *) u_d,
76 (real *) rbuf_d + roffset,
77 (real *) sbuf_d + soffset,
78 (int *) sdof_d + soffset,
79 destRank, n, (uint64_t) iter,
80 (uint64_t *) done_d + mype,
83 }
84
89 void cuda_gs_pack_and_push_wait(cudaStream_t stream, int iter,
90 void *done_d, int srcRank)
91 {
93 (uint64_t *) done_d + srcRank);
95 }
96
102 void cuda_gs_post_ready(cudaStream_t stream, int iter, void *ready_d,
103 int mype, int srcRank)
104 {
106 (uint64_t) iter, srcRank);
108 }
109
115 void cuda_gs_pack_and_push_vec(void *u_d, void *sbuf_d, void *sdof_d,
116 int soffset, int n, int nc, int ns,
117 cudaStream_t stream, int destRank,
118 void *rbuf_d, int roffset, int iter,
119 void *done_d, void *ready_d, int mype)
120 {
121 const int nthrds = 1024;
122
124 <<<1,nthrds,0,stream>>>((real *) u_d,
125 (real *) rbuf_d + nc*roffset,
126 (real *) sbuf_d + nc*soffset,
127 (int *) sdof_d + soffset,
128 destRank, n, nc, ns, (uint64_t) iter,
129 (uint64_t *) done_d + mype,
132 }
133#endif
134}
__global__ void ale_add_kinematics_kernel(const int n, T *__restrict__ wx, T *__restrict__ wy, T *__restrict__ wz, const T *__restrict__ x_ref, const T *__restrict__ y_ref, const T *__restrict__ z_ref, const T *__restrict__ phi, const T *__restrict__ x, const T *__restrict__ y, const T *__restrict__ z, const kinematics_params_t kin_params)
#define CUDA_CHECK(err)
Definition check.h:6
double real