Neko 1.99.1
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
46 implicit none
47
48contains
49
50 ! ========================================================================== !
51 ! Internal functions and subroutines
52 ! ========================================================================== !
53
55 subroutine smooth_step_device(x, edge0, edge1, n)
56 type(c_ptr), intent(inout) :: x
57 real(kind=rp), intent(in) :: edge0, edge1
58 integer, intent(in) :: n
59
60#if HAVE_HIP == 1
61 call hip_smooth_step(x, edge0, edge1, n)
62#elif HAVE_CUDA == 1
63 call cuda_smooth_step(x, edge0, edge1, n)
64#elif HAVE_OPENCL == 1
65 call opencl_smooth_step(x, edge0, edge1, n)
66#else
67 call neko_error(&
68 "Smooth step function not implemented for the current device.")
69#endif
70
71 end subroutine smooth_step_device
72
74 subroutine step_function_device(x, x_step, value0, value1, n)
75 type(c_ptr), intent(inout) :: x
76 real(kind=rp), intent(in) :: x_step, value0, value1
77 integer, intent(in) :: n
78
79#if HAVE_HIP == 1
80 call hip_step_function(x, x_step, value0, value1, n)
81#elif HAVE_CUDA == 1
82 call cuda_step_function(x, x_step, value0, value1, n)
83#elif HAVE_OPENCL == 1
84 call opencl_step_function(x, x_step, value0, value1, n)
85#else
86 call neko_error(&
87 "Step function not implemented for the current device.")
88#endif
89
90 end subroutine step_function_device
91
93 subroutine permeability_device(x, k_0, k_1, q, n)
94 type(c_ptr), intent(inout) :: x
95 real(kind=rp), intent(in) :: k_0, k_1, q
96 integer, intent(in) :: n
97
98#if HAVE_HIP == 1
99 call hip_permeability(x, k_0, k_1, q, n)
100#elif HAVE_CUDA == 1
101 call cuda_permeability(x, k_0, k_1, q, n)
102#elif HAVE_OPENCL == 1
103 call opencl_permeability(x, k_0, k_1, q, n)
104#else
105 call neko_error(&
106 "Permeability function not implemented for the current device.")
107#endif
108
109 end subroutine permeability_device
110
111
112end 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.
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