Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
tensor_device.F90
Go to the documentation of this file.
1! Copyright (c) 2022, 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_ptr, c_int
36 implicit none
37 private
38
40
41#ifdef HAVE_HIP
42 interface
43 subroutine hip_tnsr3d_el_list(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, &
44 elements, n_points) &
45 bind(c, name = 'hip_tnsr3d_el_list')
46 use, intrinsic :: iso_c_binding
47 type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d, elements
48 integer(c_int) :: nu, nv, n_points
49 end subroutine hip_tnsr3d_el_list
50 end interface
51 interface
52 subroutine hip_tnsr3d(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, nelv) &
53 bind(c, name = 'hip_tnsr3d')
54 use, intrinsic :: iso_c_binding
55 type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d
56 integer(c_int) :: nu, nv, nelv
57 end subroutine hip_tnsr3d
58 end interface
59#elif HAVE_CUDA
60 interface
61 subroutine cuda_tnsr3d_el_list(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, &
62 elements, n_points) &
63 bind(c, name = 'cuda_tnsr3d_el_list')
64 use, intrinsic :: iso_c_binding
65 type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d, elements
66 integer(c_int) :: nu, nv, n_points
67 end subroutine cuda_tnsr3d_el_list
68 end interface
69 interface
70 subroutine cuda_tnsr3d(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, nelv) &
71 bind(c, name = 'cuda_tnsr3d')
72 use, intrinsic :: iso_c_binding
73 type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d
74 integer(c_int) :: nu, nv, nelv
75 end subroutine cuda_tnsr3d
76 end interface
77#elif HAVE_OPENCL
78 interface
79 subroutine opencl_tnsr3d_el_list(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, &
80 elements, n_points) &
81 bind(c, name = 'opencl_tnsr3d_el_list')
82 use, intrinsic :: iso_c_binding
83 type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d, elements
84 integer(c_int) :: nu, nv, n_points
85 end subroutine opencl_tnsr3d_el_list
86 end interface
87 interface
88 subroutine opencl_tnsr3d(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, nelv) &
89 bind(c, name = 'opencl_tnsr3d')
90 use, intrinsic :: iso_c_binding
91 type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d
92 integer(c_int) :: nu, nv, nelv
93 end subroutine opencl_tnsr3d
94 end interface
95#elif HAVE_METAL
96 interface
97 subroutine metal_tnsr3d_el_list(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, &
98 elements, n_points) &
99 bind(c, name = 'metal_tnsr3d_el_list')
100 use, intrinsic :: iso_c_binding
101 type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d, elements
102 integer(c_int) :: nu, nv, n_points
103 end subroutine metal_tnsr3d_el_list
104 end interface
105 interface
106 subroutine metal_tnsr3d(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, nelv) &
107 bind(c, name = 'metal_tnsr3d')
108 use, intrinsic :: iso_c_binding
109 type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d
110 integer(c_int) :: nu, nv, nelv
111 end subroutine metal_tnsr3d
112 end interface
113#endif
114contains
115
116 subroutine tnsr3d_device(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, nelv)
117 type(c_ptr) :: v_d, u_d, a_d, bt_d, ct_d
118 integer(c_int) :: nu, nv, nelv
119#ifdef HAVE_HIP
120 call hip_tnsr3d(v_d, nv, u_d, nu, a_d, bt_d, ct_d, nelv)
121#elif HAVE_CUDA
122 call cuda_tnsr3d(v_d, nv, u_d, nu, a_d, bt_d, ct_d, nelv)
123#elif HAVE_OPENCL
124 call opencl_tnsr3d(v_d, nv, u_d, nu, a_d, bt_d, ct_d, nelv)
125#elif HAVE_METAL
126 call metal_tnsr3d(v_d, nv, u_d, nu, a_d, bt_d, ct_d, nelv)
127#else
128 call neko_error('No device backend configured')
129#endif
130 end subroutine tnsr3d_device
131
132 subroutine tnsr3d_el_list_device(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, &
133 elements, n_points)
134 type(c_ptr) :: v_d, u_d, a_d, bt_d, ct_d, elements
135 integer(c_int) :: nu, nv, n_points
136#ifdef HAVE_HIP
137 call hip_tnsr3d_el_list(v_d, nv, u_d, nu, a_d, bt_d, ct_d, elements, &
138 n_points)
139#elif HAVE_CUDA
140 call cuda_tnsr3d_el_list(v_d, nv, u_d, nu, a_d, bt_d, ct_d, elements, &
141 n_points)
142#elif HAVE_OPENCL
143 call opencl_tnsr3d_el_list(v_d, nv, u_d, nu, a_d, bt_d, ct_d, elements, &
144 n_points)
145#elif HAVE_METAL
146 call metal_tnsr3d_el_list(v_d, nv, u_d, nu, a_d, bt_d, ct_d, elements, &
147 n_points)
148#else
149 call neko_error('No device backend configured')
150#endif
151 end subroutine tnsr3d_el_list_device
152
153
154end module tensor_device
subroutine, public tnsr3d_el_list_device(v_d, nv, u_d, nu, a_d, bt_d, ct_d, elements, n_points)
subroutine, public tnsr3d_device(v_d, nv, u_d, nu, a_d, bt_d, ct_d, nelv)
Utilities.
Definition utils.f90:35
void opencl_tnsr3d(void *v, int *nv, void *u, int *nu, void *A, void *Bt, void *Ct, int *nel)
Definition tensor.c:51
void opencl_tnsr3d_el_list(void *v, int *nv, void *u, int *nu, void *A, void *Bt, void *Ct, int *elements, int *n_points)
Definition tensor.c:102
void cuda_tnsr3d(void *v, int *nv, void *u, int *nu, void *A, void *Bt, void *Ct, int *nel)
Definition tensor.cu:49
void cuda_tnsr3d_el_list(void *v, int *nv, void *u, int *nu, void *A, void *Bt, void *Ct, int *elements, int *n_points)
Definition tensor.cu:99