Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
device_RAMP_mapping.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 private
39
44
45#if HAVE_HIP
46
47#elif HAVE_CUDA
48
49 interface
50 subroutine cuda_convex_down_ramp_mapping_apply(f_min, f_max, q, &
51 X_out_d, X_in_d, n) &
52 bind(c, name = 'cuda_convex_down_RAMP_mapping_apply')
53 import c_rp, c_ptr, c_int
54 real(c_rp) :: f_min
55 real(c_rp) :: f_max
56 real(c_rp) :: q
57 type(c_ptr), value :: X_out_d
58 type(c_ptr), value :: X_in_d
59 integer(c_int) :: n
61 end interface
62
63 interface
65 dF_dX_in_d, dF_dX_out_d, X_in_d, n) &
66 bind(c, name = 'cuda_convex_down_RAMP_mapping_apply_backward')
67 import c_rp, c_ptr, c_int
68 real(c_rp) :: f_min
69 real(c_rp) :: f_max
70 real(c_rp) :: q
71 type(c_ptr), value :: dF_dX_in_d
72 type(c_ptr), value :: dF_dX_out_d
73 type(c_ptr), value :: X_in_d
74 integer(c_int) :: n
76 end interface
77
78 interface
79 subroutine cuda_convex_up_ramp_mapping_apply(f_min, f_max, q, &
80 X_out_d, X_in_d, n) &
81 bind(c, name = 'cuda_convex_up_RAMP_mapping_apply')
82 import c_rp, c_ptr, c_int
83 real(c_rp) :: f_min
84 real(c_rp) :: f_max
85 real(c_rp) :: q
86 type(c_ptr), value :: X_out_d
87 type(c_ptr), value :: X_in_d
88 integer(c_int) :: n
90 end interface
91
92 interface
93 subroutine cuda_convex_up_ramp_mapping_apply_backward(f_min, f_max, q, &
94 dF_dX_in_d, dF_dX_out_d, X_in_d, n) &
95 bind(c, name = 'cuda_convex_up_RAMP_mapping_apply_backward')
96 import c_rp, c_ptr, c_int
97 real(c_rp) :: f_min
98 real(c_rp) :: f_max
99 real(c_rp) :: q
100 type(c_ptr), value :: dF_dX_in_d
101 type(c_ptr), value :: dF_dX_out_d
102 type(c_ptr), value :: X_in_d
103 integer(c_int) :: n
105 end interface
106#elif HAVE_OPENCL
107
108#endif
109
110contains
111
112 subroutine device_convex_down_ramp_mapping_apply(f_min, f_max, q, &
113 X_out_d, X_in_d, n)
114 real(kind=rp), intent(in) :: f_min
115 real(kind=rp), intent(in) :: f_max
116 real(kind=rp), intent(in) :: q
117 type(c_ptr) :: x_out_d
118 type(c_ptr) :: x_in_d
119 integer :: n
120#if HAVE_CUDA
121 call cuda_convex_down_ramp_mapping_apply(f_min, f_max, q, &
122 x_out_d, x_in_d, n)
123#else
124 call neko_error('No device backend configured')
125#endif
127
129 dF_dX_in_d, dF_dX_out_d, X_in_d, n)
130 real(kind=rp), intent(in) :: f_min
131 real(kind=rp), intent(in) :: f_max
132 real(kind=rp), intent(in) :: q
133 type(c_ptr) :: df_dx_in_d
134 type(c_ptr) :: df_dx_out_d
135 type(c_ptr) :: x_in_d
136 integer :: n
137#if HAVE_CUDA
139 df_dx_in_d, df_dx_out_d, x_in_d, n)
140#else
141 call neko_error('No device backend configured')
142#endif
144
145 subroutine device_convex_up_ramp_mapping_apply(f_min, f_max, q, &
146 X_out_d, X_in_d, n)
147 real(kind=rp), intent(in) :: f_min
148 real(kind=rp), intent(in) :: f_max
149 real(kind=rp), intent(in) :: q
150 type(c_ptr) :: x_out_d
151 type(c_ptr) :: x_in_d
152 integer :: n
153#if HAVE_CUDA
154 call cuda_convex_up_ramp_mapping_apply(f_min, f_max, q, &
155 x_out_d, x_in_d, n)
156#else
157 call neko_error('No device backend configured')
158#endif
160
162 dF_dX_in_d, dF_dX_out_d, X_in_d, n)
163 real(kind=rp), intent(in) :: f_min
164 real(kind=rp), intent(in) :: f_max
165 real(kind=rp), intent(in) :: q
166 type(c_ptr) :: df_dx_in_d
167 type(c_ptr) :: df_dx_out_d
168 type(c_ptr) :: x_in_d
169 integer :: n
170#if HAVE_CUDA
171 call cuda_convex_up_ramp_mapping_apply_backward(f_min, f_max, q, &
172 df_dx_in_d, df_dx_out_d, x_in_d, n)
173#else
174 call neko_error('No device backend configured')
175#endif
177end module device_ramp_mapping
subroutine, public device_convex_up_ramp_mapping_apply(f_min, f_max, q, x_out_d, x_in_d, n)
subroutine, public device_convex_down_ramp_mapping_apply(f_min, f_max, q, x_out_d, x_in_d, n)
subroutine, public device_convex_up_ramp_mapping_apply_backward(f_min, f_max, q, df_dx_in_d, df_dx_out_d, x_in_d, n)
subroutine, public device_convex_down_ramp_mapping_apply_backward(f_min, f_max, q, df_dx_in_d, df_dx_out_d, x_in_d, n)