Neko  0.8.99
A portable framework for high-order spectral element flow simulations
device_symmetry.F90
Go to the documentation of this file.
1 ! Copyright (c) 2021-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 num_types
35  use utils
36  use, intrinsic :: iso_c_binding
37  implicit none
38 
39 #ifdef HAVE_HIP
40  interface
41  subroutine hip_symmetry_apply_vector(xmsk, ymsk, zmsk, x, y, z, m, n, l) &
42  bind(c, name='hip_symmetry_apply_vector')
43  use, intrinsic :: iso_c_binding
44  implicit none
45  integer(c_int) :: m, n, l
46  type(c_ptr), value :: xmsk, ymsk, zmsk, x, y, z
47  end subroutine hip_symmetry_apply_vector
48  end interface
49 #elif HAVE_CUDA
50  interface
51  subroutine cuda_symmetry_apply_vector(xmsk, ymsk, zmsk, x, y, z, m, n, l) &
52  bind(c, name='cuda_symmetry_apply_vector')
53  use, intrinsic :: iso_c_binding
54  implicit none
55  integer(c_int) :: m, n, l
56  type(c_ptr), value :: xmsk, ymsk, zmsk, x, y, z
57  end subroutine cuda_symmetry_apply_vector
58  end interface
59 #elif HAVE_OPENCL
60  interface
61  subroutine opencl_symmetry_apply_vector(xmsk, ymsk, zmsk, x, y, z, m, n, l) &
62  bind(c, name='opencl_symmetry_apply_vector')
63  use, intrinsic :: iso_c_binding
64  implicit none
65  integer(c_int) :: m, n, l
66  type(c_ptr), value :: xmsk, ymsk, zmsk, x, y, z
67  end subroutine opencl_symmetry_apply_vector
68  end interface
69 #endif
70 
71 contains
72 
73  subroutine device_symmetry_apply_vector(xmsk, ymsk, zmsk, x, y, z, m, n, l)
74  integer, intent(in) :: m, n, l
75  type(c_ptr) :: xmsk, ymsk, zmsk, x, y, z
76 
77 #ifdef HAVE_HIP
78  call hip_symmetry_apply_vector(xmsk, ymsk, zmsk, x, y, z, m, n, l)
79 #elif HAVE_CUDA
80  call cuda_symmetry_apply_vector(xmsk, ymsk, zmsk, x, y, z, m, n, l)
81 #elif HAVE_OPENCL
82  call opencl_symmetry_apply_vector(xmsk, ymsk, zmsk, x, y, z, m, n, l)
83 #else
84  call neko_error('No device backend configured')
85 #endif
86 
87  end subroutine device_symmetry_apply_vector
88 
89 end module device_symmetry
subroutine device_symmetry_apply_vector(xmsk, ymsk, zmsk, x, y, z, m, n, l)
Utilities.
Definition: utils.f90:35
void opencl_symmetry_apply_vector(void *xmsk, void *ymsk, void *zmsk, void *x, void *y, void *z, int *m, int *n, int *l)
Definition: symmetry.c:54
void cuda_symmetry_apply_vector(void *xmsk, void *ymsk, void *zmsk, void *x, void *y, void *z, int *m, int *n, int *l)
Definition: symmetry.cu:47