Neko  0.9.0
A portable framework for high-order spectral element flow simulations
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, elements, n_points) &
44  bind(c, name='hip_tnsr3d_el_list')
45  use, intrinsic :: iso_c_binding
46  type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d, elements
47  integer(c_int) :: nu, nv, n_points
48  end subroutine hip_tnsr3d_el_list
49  end interface
50  interface
51  subroutine hip_tnsr3d(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, nelv) &
52  bind(c, name='hip_tnsr3d')
53  use, intrinsic :: iso_c_binding
54  type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d
55  integer(c_int) :: nu, nv, nelv
56  end subroutine hip_tnsr3d
57  end interface
58 #elif HAVE_CUDA
59  interface
60  subroutine cuda_tnsr3d_el_list(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, elements, n_points) &
61  bind(c, name='cuda_tnsr3d_el_list')
62  use, intrinsic :: iso_c_binding
63  type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d, elements
64  integer(c_int) :: nu, nv, n_points
65  end subroutine cuda_tnsr3d_el_list
66  end interface
67  interface
68  subroutine cuda_tnsr3d(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, nelv) &
69  bind(c, name='cuda_tnsr3d')
70  use, intrinsic :: iso_c_binding
71  type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d
72  integer(c_int) :: nu, nv, nelv
73  end subroutine cuda_tnsr3d
74  end interface
75 #elif HAVE_OPENCL
76  interface
77  subroutine opencl_tnsr3d_el_list(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, elements, n_points) &
78  bind(c, name='opencl_tnsr3d_el_list')
79  use, intrinsic :: iso_c_binding
80  type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d, elements
81  integer(c_int) :: nu, nv, n_points
82  end subroutine opencl_tnsr3d_el_list
83  end interface
84  interface
85  subroutine opencl_tnsr3d(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, nelv) &
86  bind(c, name='opencl_tnsr3d')
87  use, intrinsic :: iso_c_binding
88  type(c_ptr), value :: v_d, u_d, A_d, Bt_d, Ct_d
89  integer(c_int) :: nu, nv, nelv
90  end subroutine opencl_tnsr3d
91  end interface
92 #endif
93 contains
94 
95  subroutine tnsr3d_device(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, nelv)
96  type(c_ptr) :: v_d, u_d, a_d, bt_d, ct_d
97  integer(c_int) :: nu, nv, nelv
98 #ifdef HAVE_HIP
99  call hip_tnsr3d(v_d, nv, u_d, nu, a_d, bt_d, ct_d, nelv)
100 #elif HAVE_CUDA
101  call cuda_tnsr3d(v_d, nv, u_d, nu, a_d, bt_d, ct_d, nelv)
102 #elif HAVE_OPENCL
103  call opencl_tnsr3d(v_d, nv, u_d, nu, a_d, bt_d, ct_d, nelv)
104 #else
105  call neko_error('No device backend configured')
106 #endif
107  end subroutine tnsr3d_device
108 
109  subroutine tnsr3d_el_list_device(v_d, nv, u_d, nu, A_d, Bt_d, Ct_d, elements, n_points)
110  type(c_ptr) :: v_d, u_d, a_d, bt_d, ct_d, elements
111  integer(c_int) :: nu, nv, n_points
112 #ifdef HAVE_HIP
113  call hip_tnsr3d_el_list(v_d, nv, u_d, nu, a_d, bt_d, ct_d, elements, n_points)
114 #elif HAVE_CUDA
115  call cuda_tnsr3d_el_list( v_d, nv, u_d, nu, a_d, bt_d, ct_d, elements, n_points)
116 #elif HAVE_OPENCL
117  call opencl_tnsr3d_el_list( v_d, nv, u_d, nu, a_d, bt_d, ct_d, elements, n_points)
118 #else
119  call neko_error('No device backend configured')
120 #endif
121  end subroutine tnsr3d_el_list_device
122 
123 
124 end 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:49
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:75
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