Neko
1.99.1
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
35
#include <
device/device_config.h
>
36
#include <
device/cuda/check.h
>
37
#ifdef HAVE_NVSHMEM
38
#include <nvshmem.h>
39
#include "
gs_nvshmem_kernels.h
"
40
#endif
41
42
extern
"C"
{
43
44
#ifdef HAVE_NVSHMEM
45
void
cudamalloc_nvshmem
(
void
** ptr,
size_t
size)
46
{
47
*ptr =
nvshmem_malloc
(size);
48
CUDA_CHECK
(
cudaGetLastError
());
49
cudaMemset
(*ptr, 0, size);
50
CUDA_CHECK
(
cudaGetLastError
());
51
}
52
53
void
cudafree_nvshmem
(
void
** ptr,
size_t
size)
54
{
55
nvshmem_free
(*ptr);
56
CUDA_CHECK
(
cudaGetLastError
());
57
}
58
59
void
cuda_gs_pack_and_push
(
void
*u_d,
void
*
sbuf_d
,
void
*
sdof_d
,
60
int
soffset
,
int
n,
cudaStream_t
stream,
61
int
srank
,
void
*
rbuf_d
,
int
roffset
,
int
* remote_offset,
62
int
rrank
,
int
counter,
void
*
notifyDone
,
void
*
notifyReady
,
63
int
iter)
64
65
{
66
67
const
int
nthrds
= 1024;
68
const
int
nblcks
= (n+
nthrds
-1)/
nthrds
;
69
70
pack_pushShmemKernel<real>
71
<<<
nblcks
,
nthrds
,0,stream>>>((
real
*) u_d,
72
(
real
*)
rbuf_d
+ remote_offset[iter-1],
73
(
real
*)
sbuf_d
+
soffset
,
74
(
int
*)
sdof_d
+
soffset
,
75
srank
,
rrank
, n, counter,
76
(
uint64_t
*)
notifyDone
,
77
(
uint64_t
*)
notifyReady
);
78
CUDA_CHECK
(
cudaGetLastError
());
79
}
80
81
void
cuda_gs_pack_and_push_wait
(
cudaStream_t
stream,
int
counter,
void
*
notifyDone
)
82
{
83
uint64_t
counter_
= (
uint64_t
) counter;
84
pushShmemKernelWait<<<1,1,0,stream>
>>(
counter_
,(
uint64_t
*)
notifyDone
);
85
CUDA_CHECK
(
cudaGetLastError
());
86
}
87
#endif
88
}
check.h
CUDA_CHECK
#define CUDA_CHECK(err)
Definition
check.h:6
dirichlet_apply_scalar_kernel
__global__ void dirichlet_apply_scalar_kernel(const int *__restrict__ msk, T *__restrict__ x, const T g, const int m)
Definition
dirichlet_kernel.h:42
device_config.h
real
double real
Definition
device_config.h:12
gs_nvshmem_kernels.h
src
gs
bcknd
device
cuda
gs_nvshmem.cu
Generated on Mon Sep 1 2025 03:49:14 for Neko by
1.9.8