Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
device_math_ext.f90
Go to the documentation of this file.
1! Copyright (c) 2021-2023, 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 num_types, only: rp, c_rp
36 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
37 implicit none
38
39#if HAVE_HIP
40
41#elif HAVE_CUDA
42
43 interface
44 subroutine cuda_copy_mask(a_d, b_d, size, mask_d, mask_size) &
45 bind(c, name = 'cuda_copy_mask')
46 import c_rp, c_int, c_ptr
47 type(c_ptr), value :: a_d
48 type(c_ptr), value :: b_d
49 integer(c_int) :: size
50 type(c_ptr), value :: mask_d
51 integer(c_int) :: mask_size
52 end subroutine cuda_copy_mask
53 end interface
54 interface
55 subroutine cuda_cadd_mask(a_d, c, size, mask_d, mask_size) &
56 bind(c, name = 'cuda_cadd_mask')
57 import c_rp, c_int, c_ptr
58 type(c_ptr), value :: a_d
59 real(c_rp) :: c
60 integer(c_int) :: size
61 type(c_ptr), value :: mask_d
62 integer(c_int) :: mask_size
63 end subroutine cuda_cadd_mask
64 end interface
65 interface
66 subroutine cuda_invcol1_mask(a_d, size, mask_d, mask_size) &
67 bind(c, name = 'cuda_invcol1_mask')
68 import c_rp, c_int, c_ptr
69 type(c_ptr), value :: a_d
70 integer(c_int) :: size
71 type(c_ptr), value :: mask_d
72 integer(c_int) :: mask_size
73 end subroutine cuda_invcol1_mask
74 end interface
75 interface
76 subroutine cuda_col2_mask(a_d, b_d, size, mask_d, mask_size) &
77 bind(c, name = 'cuda_col2_mask')
78 import c_rp, c_int, c_ptr
79 type(c_ptr), value :: a_d
80 type(c_ptr), value :: b_d
81 integer(c_int) :: size
82 type(c_ptr), value :: mask_d
83 integer(c_int) :: mask_size
84 end subroutine cuda_col2_mask
85 end interface
86 interface
87 subroutine cuda_col3_mask(a_d, b_d, c_d, size, mask_d, mask_size) &
88 bind(c, name = 'cuda_col3_mask')
89 import c_rp, c_int, c_ptr
90 type(c_ptr), value :: a_d
91 type(c_ptr), value :: b_d
92 type(c_ptr), value :: c_d
93 integer(c_int) :: size
94 type(c_ptr), value :: mask_d
95 integer(c_int) :: mask_size
96 end subroutine cuda_col3_mask
97 end interface
98 interface
99 subroutine cuda_sub3_mask(a_d, b_d, c_d, size, mask_d, mask_size) &
100 bind(c, name = 'cuda_sub3_mask')
101 import c_rp, c_int, c_ptr
102 type(c_ptr), value :: a_d
103 type(c_ptr), value :: b_d
104 type(c_ptr), value :: c_d
105 integer(c_int) :: size
106 type(c_ptr), value :: mask_d
107 integer(c_int) :: mask_size
108 end subroutine cuda_sub3_mask
109 end interface
110
111#elif HAVE_OPENCL
112
113#endif
114
115contains
116
117 subroutine device_copy_mask(a_d, b_d, size, mask_d, mask_size)
118 type(c_ptr) :: a_d
119 type(c_ptr) :: b_d
120 integer :: size
121 type(c_ptr) :: mask_d
122 integer :: mask_size
123#if HAVE_CUDA
124 call cuda_copy_mask(a_d, b_d, size, mask_d, mask_size)
125#else
126 call neko_error('No device backend configured for device_copy_mask')
127#endif
128 end subroutine device_copy_mask
129
130 subroutine device_cadd_mask(a_d, c, size, mask_d, mask_size)
131 type(c_ptr) :: a_d
132 real(kind=rp), intent(in) :: c
133 integer :: size
134 type(c_ptr) :: mask_d
135 integer :: mask_size
136#if HAVE_CUDA
137 call cuda_cadd_mask(a_d, c, size, mask_d, mask_size)
138#else
139 call neko_error('No device backend configured for device_cadd_mask')
140#endif
141 end subroutine device_cadd_mask
142
143 subroutine device_invcol1_mask(a_d, size, mask_d, mask_size)
144 type(c_ptr) :: a_d
145 integer :: size
146 type(c_ptr) :: mask_d
147 integer :: mask_size
148#if HAVE_CUDA
149 call cuda_invcol1_mask(a_d, size, mask_d, mask_size)
150#else
151 call neko_error('No device backend configured for device_invcol1_mask')
152#endif
153 end subroutine device_invcol1_mask
154
155 subroutine device_col2_mask(a_d, b_d, size, mask_d, mask_size)
156 type(c_ptr) :: a_d
157 type(c_ptr) :: b_d
158 integer :: size
159 type(c_ptr) :: mask_d
160 integer :: mask_size
161#if HAVE_CUDA
162 call cuda_col2_mask(a_d, b_d, size, mask_d, mask_size)
163#else
164 call neko_error('No device backend configured for device_col2_mask')
165#endif
166 end subroutine device_col2_mask
167
168 subroutine device_col3_mask(a_d, b_d, c_d, size, mask_d, mask_size)
169 type(c_ptr) :: a_d
170 type(c_ptr) :: b_d
171 type(c_ptr) :: c_d
172 integer :: size
173 type(c_ptr) :: mask_d
174 integer :: mask_size
175#if HAVE_CUDA
176 call cuda_col3_mask(a_d, b_d, c_d, size, mask_d, mask_size)
177#else
178 call neko_error('No device backend configured for device_col3_mask')
179#endif
180 end subroutine device_col3_mask
181
182 subroutine device_sub3_mask(a_d, b_d, c_d, size, mask_d, mask_size)
183 type(c_ptr) :: a_d
184 type(c_ptr) :: b_d
185 type(c_ptr) :: c_d
186 integer :: size
187 type(c_ptr) :: mask_d
188 integer :: mask_size
189#if HAVE_CUDA
190 call cuda_sub3_mask(a_d, b_d, c_d, size, mask_d, mask_size)
191#else
192 call neko_error('No device backend configured for device_sub3_mask')
193#endif
194 end subroutine device_sub3_mask
195
196
197end module device_math_ext
subroutine device_copy_mask(a_d, b_d, size, mask_d, mask_size)
subroutine device_cadd_mask(a_d, c, size, mask_d, mask_size)
subroutine device_sub3_mask(a_d, b_d, c_d, size, mask_d, mask_size)
subroutine device_col2_mask(a_d, b_d, size, mask_d, mask_size)
subroutine device_col3_mask(a_d, b_d, c_d, size, mask_d, mask_size)
subroutine device_invcol1_mask(a_d, size, mask_d, mask_size)