Neko  0.9.99
A portable framework for high-order spectral element flow simulations
filters_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
37  use, intrinsic :: iso_c_binding, only: c_ptr
38  use utils, only: neko_error
39 
40  use cuda_filters, only: &
42  use hip_filters, only: &
44  use opencl_filters, only: &
46 
47  implicit none
48 
49 contains
50 
51  ! ========================================================================== !
52  ! Internal functions and subroutines
53  ! ========================================================================== !
54 
56  subroutine smooth_step_device(x, edge0, edge1, n)
57  type(c_ptr), intent(inout) :: x
58  real(kind=rp), intent(in) :: edge0, edge1
59  integer, intent(in) :: n
60 
61 #if HAVE_HIP == 1
62  call hip_smooth_step(x, edge0, edge1, n)
63 #elif HAVE_CUDA == 1
64  call cuda_smooth_step(x, edge0, edge1, n)
65 #elif HAVE_OPENCL == 1
66  call opencl_smooth_step(x, edge0, edge1, n)
67 #else
68  call neko_error(&
69  "Smooth step function not implemented for the current device.")
70 #endif
71 
72  end subroutine smooth_step_device
73 
75  subroutine step_function_device(x, x_step, value0, value1, n)
76  type(c_ptr), intent(inout) :: x
77  real(kind=rp), intent(in) :: x_step, value0, value1
78  integer, intent(in) :: n
79 
80 #if HAVE_HIP == 1
81  call hip_step_function(x, x_step, value0, value1, n)
82 #elif HAVE_CUDA == 1
83  call cuda_step_function(x, x_step, value0, value1, n)
84 #elif HAVE_OPENCL == 1
85  call opencl_step_function(x, x_step, value0, value1, n)
86 #else
87  call neko_error(&
88  "Step function not implemented for the current device.")
89 #endif
90 
91  end subroutine step_function_device
92 
94  subroutine permeability_device(x, k_0, k_1, q, n)
95  type(c_ptr), intent(inout) :: x
96  real(kind=rp), intent(in) :: k_0, k_1, q
97  integer, intent(in) :: n
98 
99 #if HAVE_HIP == 1
100  call hip_permeability(x, k_0, k_1, q, n)
101 #elif HAVE_CUDA == 1
102  call cuda_permeability(x, k_0, k_1, q, n)
103 #elif HAVE_OPENCL == 1
104  call opencl_permeability(x, k_0, k_1, q, n)
105 #else
106  call neko_error(&
107  "Permeability function not implemented for the current device.")
108 #endif
109 
110  end subroutine permeability_device
111 
112 
113 end module filters_device
Cuda interface binding for filters.
Device implementations of the filter functions.
subroutine permeability_device(x, k_0, k_1, q, n)
Apply a permeability function to a scalar.
subroutine smooth_step_device(x, edge0, edge1, n)
Apply a smooth step function to a scalar.
subroutine step_function_device(x, x_step, value0, value1, n)
Apply a step function to a scalar.
Hip interface binding for filters.
Definition: hip_filters.f90:34
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 filters.
Utilities.
Definition: utils.f90:35