Neko 1.99.2
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#endif
96contains
97
98 subroutine tnsr3d_device(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, nelv)
99 type(c_ptr) :: v_d, u_d, a_d, bt_d, ct_d
100 integer(c_int) :: nu, nv, nelv
101#ifdef HAVE_HIP
102 call hip_tnsr3d(v_d, nv, u_d, nu, a_d, bt_d, ct_d, nelv)
103#elif HAVE_CUDA
104 call cuda_tnsr3d(v_d, nv, u_d, nu, a_d, bt_d, ct_d, nelv)
105#elif HAVE_OPENCL
106 call opencl_tnsr3d(v_d, nv, u_d, nu, a_d, bt_d, ct_d, nelv)
107#else
108 call neko_error('No device backend configured')
109#endif
110 end subroutine tnsr3d_device
111
112 subroutine tnsr3d_el_list_device(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, &
113 elements, n_points)
114 type(c_ptr) :: v_d, u_d, a_d, bt_d, ct_d, elements
115 integer(c_int) :: nu, nv, n_points
116#ifdef HAVE_HIP
117 call hip_tnsr3d_el_list(v_d, nv, u_d, nu, a_d, bt_d, ct_d, elements, &
118 n_points)
119#elif HAVE_CUDA
120 call cuda_tnsr3d_el_list(v_d, nv, u_d, nu, a_d, bt_d, ct_d, elements, &
121 n_points)
122#elif HAVE_OPENCL
123 call opencl_tnsr3d_el_list(v_d, nv, u_d, nu, a_d, bt_d, ct_d, elements, &
124 n_points)
125#else
126 call neko_error('No device backend configured')
127#endif
128 end subroutine tnsr3d_el_list_device
129
130
131end 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