-
Notifications
You must be signed in to change notification settings - Fork 6
/
advec_mom_driver.cuf
202 lines (174 loc) · 10.1 KB
/
advec_mom_driver.cuf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
!Crown Copyright 2012 AWE.
!
! This file is part of CloverLeaf.
!
! CloverLeaf is free software: you can redistribute it and/or modify it under
! the terms of the GNU General Public License as published by the
! Free Software Foundation, either version 3 of the License, or (at your option)
! any later version.
!
! CloverLeaf is distributed in the hope that it will be useful, but
! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
! FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
! details.
!
! You should have received a copy of the GNU General Public License along with
! CloverLeaf. If not, see http://www.gnu.org/licenses/.
!> @brief Momentum advection driver
!> @author Wayne Gaudin
!> @details Invokes the user specified momentum advection kernel.
MODULE advec_mom_driver_module
CONTAINS
SUBROUTINE advec_mom_driver(chunk,which_vel,direction,sweep_number)
USE clover_module
USE advec_mom_kernel_mod
use cudafor
IMPLICIT NONE
type(dim3) :: am_grid, am_block
INTEGER :: chunk,which_vel,direction,sweep_number, mom_sweep
integer :: xmin, xmax, ymin, ymax, istat
IF(chunks(chunk)%task.EQ.parallel%task) THEN
if (use_cuda_fortran) then
xmin = chunks(chunk)%field%x_min
xmax = chunks(chunk)%field%x_max
ymin = chunks(chunk)%field%y_min
ymax = chunks(chunk)%field%y_max
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+5.)/(am_block%x)), ceiling((ymax-ymin+5.)/am_block%y), 1)
mom_sweep=direction+2*(sweep_number-1)
call advec_mom_kernel_1<<<am_grid, am_block>>>(xmin, xmax, ymin, ymax, mom_sweep, &
chunks(chunk)%field%vol_flux_x, &
chunks(chunk)%field%vol_flux_y, &
chunks(chunk)%field%volume, &
chunks(chunk)%field%work_array6, &
chunks(chunk)%field%work_array7)
if (direction == 1) then ! call the *x kernels
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+5.)/(am_block%x)), ceiling((ymax-ymin+2.)/am_block%y), 1)
call advec_mom_kernel_2x<<<am_grid, am_block>>>(xmin, xmax, ymin, ymax, &
chunks(chunk)%field%mass_flux_x, &
chunks(chunk)%field%density1, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array7)
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+4.)/am_block%x), ceiling((ymax-ymin+2.)/am_block%y), 1)
call advec_mom_kernel_3x<<<am_grid, am_block>>>(xmin, xmax, ymin, ymax, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array3)
if (which_vel == 1) then ! use xvel1
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+3.)/am_block%x), ceiling((ymax-ymin+2.)/am_block%y), 1)
call advec_mom_kernel_4x<<<am_grid,am_block>>>(xmin, xmax, ymin, ymax, &
chunks(chunk)%field%xvel1, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array3, &
chunks(chunk)%field%work_array5, &
chunks(chunk)%field%celldx)
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+2.)/am_block%x), ceiling((ymax-ymin+2.)/am_block%y), 1)
call advec_mom_kernel_5x<<<am_grid,am_block>>>(xmin, xmax, ymin, ymax, &
chunks(chunk)%field%xvel1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array3, &
chunks(chunk)%field%work_array5)
else ! use yvel1
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+3.)/am_block%x), ceiling((ymax-ymin+2.)/am_block%y), 1)
call advec_mom_kernel_4x<<<am_grid,am_block>>>(xmin, xmax, ymin, ymax, &
chunks(chunk)%field%yvel1, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array3, &
chunks(chunk)%field%work_array5, &
chunks(chunk)%field%celldx)
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+2.)/am_block%x), ceiling((ymax-ymin+2.)/am_block%y), 1)
call advec_mom_kernel_5x<<<am_grid,am_block>>>(xmin, xmax, ymin, ymax, &
chunks(chunk)%field%yvel1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array3, &
chunks(chunk)%field%work_array5)
end if
else if (direction == 2) then ! call y kernels
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+2.)/(am_block%x)), ceiling((ymax-ymin+5.)/am_block%y), 1)
call advec_mom_kernel_2y<<<am_grid, am_block>>>(xmin, xmax, ymin, ymax, &
chunks(chunk)%field%mass_flux_y, &
chunks(chunk)%field%density1, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array7)
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+2.)/am_block%x), ceiling((ymax-ymin+4.)/am_block%y), 1)
call advec_mom_kernel_3y<<<am_grid, am_block>>>(xmin, xmax, ymin, ymax, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array3)
if (which_vel == 1) then ! use xvel1
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+2.)/(am_block%x)), ceiling((ymax-ymin+3.)/am_block%y), 1)
call advec_mom_kernel_4y<<<am_grid,am_block>>>(xmin, xmax, ymin, ymax, &
chunks(chunk)%field%xvel1, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array3, &
chunks(chunk)%field%work_array5, &
chunks(chunk)%field%celldy)
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+2.)/am_block%x), ceiling((ymax-ymin+2.)/am_block%y), 1)
call advec_mom_kernel_5y<<<am_grid,am_block>>>(xmin, xmax, ymin, ymax, &
chunks(chunk)%field%xvel1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array3, &
chunks(chunk)%field%work_array5)
else ! use yvel1
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+2.)/am_block%x), ceiling((ymax-ymin+3.)/am_block%y), 1)
call advec_mom_kernel_4y<<<am_grid,am_block>>>(xmin, xmax, ymin, ymax, &
chunks(chunk)%field%yvel1, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array3, &
chunks(chunk)%field%work_array5, &
chunks(chunk)%field%celldy)
am_block = dim3(32,8,1)
am_grid = dim3(ceiling((xmax-xmin+2.)/am_block%x), ceiling((ymax-ymin+2.)/am_block%y), 1)
call advec_mom_kernel_5y<<<am_grid,am_block>>>(xmin, xmax, ymin, ymax, &
chunks(chunk)%field%yvel1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array3, &
chunks(chunk)%field%work_array5)
end if
end if
else ! use regular fortran
CALL advec_mom_kernel(chunks(chunk)%field%x_min, &
chunks(chunk)%field%x_max, &
chunks(chunk)%field%y_min, &
chunks(chunk)%field%y_max, &
chunks(chunk)%field%xvel1, &
chunks(chunk)%field%yvel1, &
chunks(chunk)%field%mass_flux_x, &
chunks(chunk)%field%vol_flux_x, &
chunks(chunk)%field%mass_flux_y, &
chunks(chunk)%field%vol_flux_y, &
chunks(chunk)%field%volume, &
chunks(chunk)%field%density1, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array2, &
chunks(chunk)%field%work_array3, &
chunks(chunk)%field%work_array4, &
chunks(chunk)%field%work_array5, &
chunks(chunk)%field%work_array6, &
chunks(chunk)%field%work_array7, &
chunks(chunk)%field%celldx, &
chunks(chunk)%field%celldy, &
which_vel, &
sweep_number, &
direction )
end if
ENDIF
END SUBROUTINE advec_mom_driver
END MODULE advec_mom_driver_module