-
Notifications
You must be signed in to change notification settings - Fork 6
/
advec_cell_driver.cuf
172 lines (147 loc) · 8 KB
/
advec_cell_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
!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 Cell centred advection driver.
!> @author Wayne Gaudin
!> @details Invokes the user selected advection kernel.
MODULE advec_cell_driver_module
CONTAINS
SUBROUTINE advec_cell_driver(chunk,sweep_number,dir)
USE clover_module
USE advec_cell_kernel_module
use cudafor
IMPLICIT NONE
type(dim3) :: ac_grid, ac_block
INTEGER :: chunk,sweep_number,dir
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
if (dir == 1) then
ac_block = dim3(32,8,1)
ac_grid = dim3(ceiling((xmax-xmin+5.)/ac_block%x), ceiling((ymax-ymin+5.)/ac_block%y), 1)
CALL advec_cell_kernel_1x<<<ac_grid, ac_block>>>(xmin, &
xmax, &
ymin, &
ymax, &
sweep_number, &
chunks(chunk)%field%volume, &
chunks(chunk)%field%vol_flux_x, &
chunks(chunk)%field%vol_flux_y, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array2 )
ac_block = dim3(32,8,1)
ac_grid = dim3(ceiling((xmax-xmin+3.)/ac_block%x), ceiling((ymax-ymin+1.)/ac_block%y), 1)
CALL advec_cell_kernel_2x<<<ac_grid, ac_block>>>(xmin, &
xmax, &
ymin, &
ymax, &
chunks(chunk)%field%vertexdx, &
chunks(chunk)%field%density1, &
chunks(chunk)%field%energy1, &
chunks(chunk)%field%mass_flux_x, &
chunks(chunk)%field%vol_flux_x, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array7 )
ac_block = dim3(32,8,1)
ac_grid = dim3(ceiling((xmax-xmin+1.)/ac_block%x), ceiling((ymax-ymin+1.)/ac_block%y), 1)
CALL advec_cell_kernel_3x<<<ac_grid, ac_block>>>(xmin, &
xmax, &
ymin, &
ymax, &
chunks(chunk)%field%density1, &
chunks(chunk)%field%energy1, &
chunks(chunk)%field%mass_flux_x, &
chunks(chunk)%field%vol_flux_x, &
chunks(chunk)%field%work_array1, &
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 )
else ! dir == 2
ac_block = dim3(32,8,1)
ac_grid = dim3(ceiling((xmax-xmin+5.)/ac_block%x), ceiling((ymax-ymin+5.)/ac_block%y), 1)
CALL advec_cell_kernel_1y<<<ac_grid, ac_block>>>(xmin, &
xmax, &
ymin, &
ymax, &
sweep_number, &
chunks(chunk)%field%volume, &
chunks(chunk)%field%vol_flux_x, &
chunks(chunk)%field%vol_flux_y, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array2 )
ac_block = dim3(32,8,1)
ac_grid = dim3(ceiling((xmax-xmin+1.)/ac_block%x), ceiling((ymax-ymin+3.)/ac_block%y), 1)
CALL advec_cell_kernel_2y<<<ac_grid, ac_block>>>(xmin, &
xmax, &
ymin, &
ymax, &
chunks(chunk)%field%vertexdy, &
chunks(chunk)%field%density1, &
chunks(chunk)%field%energy1, &
chunks(chunk)%field%mass_flux_y, &
chunks(chunk)%field%vol_flux_y, &
chunks(chunk)%field%work_array1, &
chunks(chunk)%field%work_array7 )
ac_block = dim3(32,8,1)
ac_grid = dim3(ceiling((xmax-xmin+1.)/ac_block%x), ceiling((ymax-ymin+1.)/ac_block%y), 1)
CALL advec_cell_kernel_3y<<<ac_grid, ac_block>>>(xmin, &
xmax, &
ymin, &
ymax, &
chunks(chunk)%field%density1, &
chunks(chunk)%field%energy1, &
chunks(chunk)%field%mass_flux_y, &
chunks(chunk)%field%vol_flux_y, &
chunks(chunk)%field%work_array1, &
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 )
end if
else
CALL advec_cell_kernel(chunks(chunk)%field%x_min, &
chunks(chunk)%field%x_max, &
chunks(chunk)%field%y_min, &
chunks(chunk)%field%y_max, &
dir, &
sweep_number, &
chunks(chunk)%field%vertexdx, &
chunks(chunk)%field%vertexdy, &
chunks(chunk)%field%volume, &
chunks(chunk)%field%density1, &
chunks(chunk)%field%energy1, &
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%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 )
endif
ENDIF
END SUBROUTINE advec_cell_driver
END MODULE advec_cell_driver_module