Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
mappings_device.F90
Go to the documentation of this file.
1! Copyright (c) 2024, 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!
35 use num_types, only : rp, c_rp
36 use, intrinsic :: iso_c_binding, only : c_ptr
37 use utils, only : neko_error
38
39 use cuda_mappings, only : &
41 use hip_mappings, only : &
43 use opencl_mappings, only : &
45 use metal_mappings, only : &
47
48 implicit none
49
50contains
51
52 ! ========================================================================== !
53 ! Internal functions and subroutines
54 ! ========================================================================== !
55
57 subroutine smooth_step_device(x, edge0, edge1, n)
58 type(c_ptr), intent(inout) :: x
59 real(kind=rp), intent(in) :: edge0, edge1
60 integer, intent(in) :: n
61
62#if HAVE_HIP == 1
63 call hip_smooth_step(x, edge0, edge1, n)
64#elif HAVE_CUDA == 1
65 call cuda_smooth_step(x, edge0, edge1, n)
66#elif HAVE_OPENCL == 1
67 call opencl_smooth_step(x, edge0, edge1, n)
68#elif HAVE_METAL
69 call metal_smooth_step(x, edge0, edge1, n)
70#else
71 call neko_error(&
72 "Smooth step function not implemented for the current device.")
73#endif
74
75 end subroutine smooth_step_device
76
78 subroutine step_function_device(x, x_step, value0, value1, n)
79 type(c_ptr), intent(inout) :: x
80 real(kind=rp), intent(in) :: x_step, value0, value1
81 integer, intent(in) :: n
82
83#if HAVE_HIP == 1
84 call hip_step_function(x, x_step, value0, value1, n)
85#elif HAVE_CUDA == 1
86 call cuda_step_function(x, x_step, value0, value1, n)
87#elif HAVE_OPENCL == 1
88 call opencl_step_function(x, x_step, value0, value1, n)
89#elif HAVE_METAL
90 call metal_step_function(x, x_step, value0, value1, n)
91#else
92 call neko_error(&
93 "Step function not implemented for the current device.")
94#endif
95
96 end subroutine step_function_device
97
99 subroutine permeability_device(x, k_0, k_1, q, n)
100 type(c_ptr), intent(inout) :: x
101 real(kind=rp), intent(in) :: k_0, k_1, q
102 integer, intent(in) :: n
103
104#if HAVE_HIP == 1
105 call hip_permeability(x, k_0, k_1, q, n)
106#elif HAVE_CUDA == 1
107 call cuda_permeability(x, k_0, k_1, q, n)
108#elif HAVE_OPENCL == 1
109 call opencl_permeability(x, k_0, k_1, q, n)
110#elif HAVE_METAL
111 call metal_permeability(x, k_0, k_1, q, n)
112#else
113 call neko_error(&
114 "Permeability function not implemented for the current device.")
115#endif
116
117 end subroutine permeability_device
118
119
120end module mappings_device
Cuda interface binding for mappings.
Hip interface binding for mappings.
Device implementations of the mapping functions.
subroutine permeability_device(x, k_0, k_1, q, n)
Apply a permeability function to a scalar.
subroutine step_function_device(x, x_step, value0, value1, n)
Apply a step function to a scalar.
subroutine smooth_step_device(x, edge0, edge1, n)
Apply a smooth step function to a scalar.
Metal interface binding for mappings.
integer, parameter, public c_rp
Definition num_types.f90:13
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
OpenCL interface binding for mappings.
Utilities.
Definition utils.f90:35