Neko 1.99.2
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
device_neumann.F90
Go to the documentation of this file.
1! Copyright (c) 2025, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
34 use utils, only : neko_error
35 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
36 implicit none
37 private
38
39#ifdef HAVE_HIP
40 interface
41 subroutine hip_neumann_apply_scalar(msk, facet, x, flux, area, &
42 lx, m, strm) &
43 bind(c, name='hip_neumann_apply_scalar')
44 use, intrinsic :: iso_c_binding
45 implicit none
46 integer(c_int) :: m, lx
47 type(c_ptr), value :: msk, facet, x, flux, area, strm
48 end subroutine hip_neumann_apply_scalar
49
50 subroutine hip_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y,&
51 flux_z, area, lx, m, strm) &
52 bind(c, name='hip_neumann_apply_vector')
53 use, intrinsic :: iso_c_binding
54 implicit none
55 integer(c_int) :: m, lx
56 type(c_ptr), value :: msk, facet, x, y, z, flux_x, flux_y, flux_z, &
57 area, strm
58 end subroutine hip_neumann_apply_vector
59 end interface
60#elif HAVE_CUDA
61 interface
62 subroutine cuda_neumann_apply_scalar(msk, facet, x, flux, area, &
63 lx, m, strm) &
64 bind(c, name='cuda_neumann_apply_scalar')
65 use, intrinsic :: iso_c_binding
66 implicit none
67 integer(c_int) :: m, lx
68 type(c_ptr), value :: msk, facet, x, flux, area, strm
69 end subroutine cuda_neumann_apply_scalar
70
71 subroutine cuda_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, &
72 flux_z, area, lx, m, strm) &
73 bind(c, name='cuda_neumann_apply_vector')
74 use, intrinsic :: iso_c_binding
75 implicit none
76 integer(c_int) :: m, lx
77 type(c_ptr), value :: msk, facet, x, y, z, flux_x, flux_y, flux_z, &
78 area, strm
79 end subroutine cuda_neumann_apply_vector
80 end interface
81#elif HAVE_OPENCL
82 interface
83 subroutine opencl_neumann_apply_scalar(msk, facet, x, flux, area, &
84 lx, m, strm) &
85 bind(c, name='opencl_neumann_apply_scalar')
86 use, intrinsic :: iso_c_binding
87 implicit none
88 integer(c_int) :: m, lx
89 type(c_ptr), value :: msk, facet, x, flux, area, strm
90 end subroutine opencl_neumann_apply_scalar
91
92 subroutine opencl_neumann_apply_vector(msk, facet, x, y, z, flux_x, &
93 flux_y, flux_z, area, lx, m, strm) &
94 bind(c, name='opencl_neumann_apply_vector')
95 use, intrinsic :: iso_c_binding
96 implicit none
97 integer(c_int) :: m, lx
98 type(c_ptr), value :: msk, facet, x, y, z, flux_x, flux_y, flux_z, &
99 area, strm
100 end subroutine opencl_neumann_apply_vector
101 end interface
102#endif
103
105
106contains
107
108 subroutine device_neumann_apply_scalar(msk, facet, x, flux, area, lx, m, strm)
109 integer, intent(in) :: m, lx
110 type(c_ptr) :: msk, facet, x, flux, area, strm
111
112 if (m .lt. 1) return
113#ifdef HAVE_HIP
114 call hip_neumann_apply_scalar(msk, facet, x, flux, area, lx, m, strm)
115#elif HAVE_CUDA
116 call cuda_neumann_apply_scalar(msk, facet, x, flux, area, lx, m, strm)
117#elif HAVE_OPENCL
118 call opencl_neumann_apply_scalar(msk, facet, x, flux, area, lx, m, strm)
119#else
120 call neko_error('No device backend configured')
121#endif
122
123 end subroutine device_neumann_apply_scalar
124
125 subroutine device_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, &
126 flux_z, area, lx, m, strm)
127 integer, intent(in) :: m, lx
128 type(c_ptr) :: msk, facet, x, y, z, flux_x, flux_y, flux_z, area, strm
129
130 if (m .lt. 1) return
131#ifdef HAVE_HIP
132 call hip_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, flux_z, &
133 area, lx, m, strm)
134#elif HAVE_CUDA
135 call cuda_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, &
136 flux_z, area, lx, m, strm)
137#elif HAVE_OPENCL
138 call opencl_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, &
139 flux_z, area, lx, m, strm)
140#else
141 call neko_error('No device backend configured')
142#endif
143
144 end subroutine device_neumann_apply_vector
145
146end module device_neumann
subroutine, public device_neumann_apply_scalar(msk, facet, x, flux, area, lx, m, strm)
subroutine, public device_neumann_apply_vector(msk, facet, x, y, z, flux_x, flux_y, flux_z, area, lx, m, strm)
Utilities.
Definition utils.f90:35
void opencl_neumann_apply_vector(void *msk, void *facet, void *x, void *y, void *z, void *flux_x, void *flux_y, void *flux_z, void *area, int *lx, int *m, cl_command_queue cmd_queue)
Definition neumann.c:86
void opencl_neumann_apply_scalar(void *msk, void *facet, void *x, void *flux, void *area, int *lx, int *m, cl_command_queue cmd_queue)
Definition neumann.c:52
void cuda_neumann_apply_scalar(void *msk, void *facet, void *x, void *flux, void *area, int *lx, int *m, cudaStream_t strm)
Definition neumann.cu:44
void cuda_neumann_apply_vector(void *msk, void *facet, void *x, void *y, void *z, void *flux_x, void *flux_y, void *flux_z, void *area, int *lx, int *m, cudaStream_t strm)
Definition neumann.cu:66