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
34!
35module device_math_ext
36 use utils, only: neko_error
37 use num_types, only: rp, c_rp
38 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
39 implicit none
40
41#if HAVE_HIP
42
43 interface
44 subroutine hip_cadd_mask(a_d, c, size, mask_d, mask_size) &
45 bind(c, name = 'hip_cadd_mask')
46 import c_rp, c_int, c_ptr
47 type(c_ptr), value :: a_d
48 real(c_rp) :: c
49 integer(c_int) :: size
50 type(c_ptr), value :: mask_d
51 integer(c_int) :: mask_size
52 end subroutine hip_cadd_mask
53 end interface
54 interface
55 subroutine hip_invcol1_mask(a_d, size, mask_d, mask_size) &
56 bind(c, name = 'hip_invcol1_mask')
57 import c_rp, c_int, c_ptr
58 type(c_ptr), value :: a_d
59 integer(c_int) :: size
60 type(c_ptr), value :: mask_d
61 integer(c_int) :: mask_size
62 end subroutine hip_invcol1_mask
63 end interface
64 interface
65 subroutine hip_col2_mask(a_d, b_d, size, mask_d, mask_size) &
66 bind(c, name = 'hip_col2_mask')
67 import c_rp, c_int, c_ptr
68 type(c_ptr), value :: a_d
69 type(c_ptr), value :: b_d
70 integer(c_int) :: size
71 type(c_ptr), value :: mask_d
72 integer(c_int) :: mask_size
73 end subroutine hip_col2_mask
74 end interface
75 interface
76 subroutine hip_col3_mask(a_d, b_d, c_d, size, mask_d, mask_size) &
77 bind(c, name = 'hip_col3_mask')
78 import c_rp, c_int, c_ptr
79 type(c_ptr), value :: a_d
80 type(c_ptr), value :: b_d
81 type(c_ptr), value :: c_d
82 integer(c_int) :: size
83 type(c_ptr), value :: mask_d
84 integer(c_int) :: mask_size
85 end subroutine hip_col3_mask
86 end interface
87 interface
88 subroutine hip_sub3_mask(a_d, b_d, c_d, size, mask_d, mask_size) &
89 bind(c, name = 'hip_sub3_mask')
90 import c_rp, c_int, c_ptr
91 type(c_ptr), value :: a_d
92 type(c_ptr), value :: b_d
93 type(c_ptr), value :: c_d
94 integer(c_int) :: size
95 type(c_ptr), value :: mask_d
96 integer(c_int) :: mask_size
97 end subroutine hip_sub3_mask
98 end interface
99
100#elif HAVE_CUDA
101
102 interface
103 subroutine cuda_cadd_mask(a_d, c, size, mask_d, mask_size) &
104 bind(c, name = 'cuda_cadd_mask')
105 import c_rp, c_int, c_ptr
106 type(c_ptr), value :: a_d
107 real(c_rp) :: c
108 integer(c_int) :: size
109 type(c_ptr), value :: mask_d
110 integer(c_int) :: mask_size
111 end subroutine cuda_cadd_mask
112 end interface
113 interface
114 subroutine cuda_invcol1_mask(a_d, size, mask_d, mask_size) &
115 bind(c, name = 'cuda_invcol1_mask')
116 import c_rp, c_int, c_ptr
117 type(c_ptr), value :: a_d
118 integer(c_int) :: size
119 type(c_ptr), value :: mask_d
120 integer(c_int) :: mask_size
121 end subroutine cuda_invcol1_mask
122 end interface
123 interface
124 subroutine cuda_col2_mask(a_d, b_d, size, mask_d, mask_size) &
125 bind(c, name = 'cuda_col2_mask')
126 import c_rp, c_int, c_ptr
127 type(c_ptr), value :: a_d
128 type(c_ptr), value :: b_d
129 integer(c_int) :: size
130 type(c_ptr), value :: mask_d
131 integer(c_int) :: mask_size
132 end subroutine cuda_col2_mask
133 end interface
134 interface
135 subroutine cuda_col3_mask(a_d, b_d, c_d, size, mask_d, mask_size) &
136 bind(c, name = 'cuda_col3_mask')
137 import c_rp, c_int, c_ptr
138 type(c_ptr), value :: a_d
139 type(c_ptr), value :: b_d
140 type(c_ptr), value :: c_d
141 integer(c_int) :: size
142 type(c_ptr), value :: mask_d
143 integer(c_int) :: mask_size
144 end subroutine cuda_col3_mask
145 end interface
146 interface
147 subroutine cuda_sub3_mask(a_d, b_d, c_d, size, mask_d, mask_size) &
148 bind(c, name = 'cuda_sub3_mask')
149 import c_rp, c_int, c_ptr
150 type(c_ptr), value :: a_d
151 type(c_ptr), value :: b_d
152 type(c_ptr), value :: c_d
153 integer(c_int) :: size
154 type(c_ptr), value :: mask_d
155 integer(c_int) :: mask_size
156 end subroutine cuda_sub3_mask
157 end interface
158
159#elif HAVE_OPENCL
160
161#endif
162
163contains
164
165 subroutine device_cadd_mask(a_d, c, size, mask_d, mask_size)
166 type(c_ptr) :: a_d
167 real(kind=rp), intent(in) :: c
168 integer :: size
169 type(c_ptr) :: mask_d
170 integer :: mask_size
171#if HAVE_HIP
172 call hip_cadd_mask(a_d, c, size, mask_d, mask_size)
173#elif HAVE_CUDA
174 call cuda_cadd_mask(a_d, c, size, mask_d, mask_size)
175#else
176 call neko_error('No device backend configured for device_cadd_mask')
177#endif
178 end subroutine device_cadd_mask
179
180 subroutine device_invcol1_mask(a_d, size, mask_d, mask_size)
181 type(c_ptr) :: a_d
182 integer :: size
183 type(c_ptr) :: mask_d
184 integer :: mask_size
185#if HAVE_HIP
186 call hip_invcol1_mask(a_d, size, mask_d, mask_size)
187#elif HAVE_CUDA
188 call cuda_invcol1_mask(a_d, size, mask_d, mask_size)
189#else
190 call neko_error('No device backend configured for device_invcol1_mask')
191#endif
192 end subroutine device_invcol1_mask
193
194 subroutine device_col2_mask(a_d, b_d, size, mask_d, mask_size)
195 type(c_ptr) :: a_d
196 type(c_ptr) :: b_d
197 integer :: size
198 type(c_ptr) :: mask_d
199 integer :: mask_size
200#if HAVE_HIP
201 call hip_col2_mask(a_d, b_d, size, mask_d, mask_size)
202#elif HAVE_CUDA
203 call cuda_col2_mask(a_d, b_d, size, mask_d, mask_size)
204#else
205 call neko_error('No device backend configured for device_col2_mask')
206#endif
207 end subroutine device_col2_mask
208
209 subroutine device_col3_mask(a_d, b_d, c_d, size, mask_d, mask_size)
210 type(c_ptr) :: a_d
211 type(c_ptr) :: b_d
212 type(c_ptr) :: c_d
213 integer :: size
214 type(c_ptr) :: mask_d
215 integer :: mask_size
216#if HAVE_HIP
217 call hip_col3_mask(a_d, b_d, c_d, size, mask_d, mask_size)
218#elif HAVE_CUDA
219 call cuda_col3_mask(a_d, b_d, c_d, size, mask_d, mask_size)
220#else
221 call neko_error('No device backend configured for device_col3_mask')
222#endif
223 end subroutine device_col3_mask
224
225 subroutine device_sub3_mask(a_d, b_d, c_d, size, mask_d, mask_size)
226 type(c_ptr) :: a_d
227 type(c_ptr) :: b_d
228 type(c_ptr) :: c_d
229 integer :: size
230 type(c_ptr) :: mask_d
231 integer :: mask_size
232#if HAVE_HIP
233 call hip_sub3_mask(a_d, b_d, c_d, size, mask_d, mask_size)
234#elif HAVE_CUDA
235 call cuda_sub3_mask(a_d, b_d, c_d, size, mask_d, mask_size)
236#else
237 call neko_error('No device backend configured for device_sub3_mask')
238#endif
239 end subroutine device_sub3_mask
240
241end module device_math_ext