@@ -44,6 +44,7 @@ module SELF_MappedScalar_3D
44
44
procedure ,public :: SetInteriorFromEquation = > SetInteriorFromEquation_MappedScalar3D
45
45
46
46
procedure ,public :: SideExchange = > SideExchange_MappedScalar3D
47
+ procedure ,private :: MPIExchangeAsync = > MPIExchangeAsync_MappedScalar3D
47
48
48
49
generic,public :: MappedGradient = > MappedGradient_MappedScalar3D
49
50
procedure ,private :: MappedGradient_MappedScalar3D
@@ -187,6 +188,68 @@ subroutine SetInteriorFromEquation_MappedScalar3D(this,geometry,time)
187
188
188
189
end subroutine SetInteriorFromEquation_MappedScalar3D
189
190
191
+ subroutine MPIExchangeAsync_MappedScalar3D (this ,mesh ,resetCount )
192
+ implicit none
193
+ class(MappedScalar3D),intent (inout ) :: this
194
+ type (Mesh3D),intent (inout ) :: mesh
195
+ logical ,intent (in ) :: resetCount
196
+ ! Local
197
+ integer :: e1,s1,e2,s2,ivar
198
+ integer :: globalSideId,r2,tag
199
+ integer :: iError
200
+ integer :: msgCount
201
+ real (prec),pointer :: boundary(:,:,:,:,:)
202
+ real (prec),pointer :: extboundary(:,:,:,:,:)
203
+
204
+ if (resetCount) then
205
+ msgCount = 0
206
+ else
207
+ msgCount = mesh% decomp% msgCount
208
+ endif
209
+ call c_f_pointer(this% boundary_gpu,boundary,[this% interp% N+1 ,this% interp% N+1 ,6 ,this% nelem,this% nvar])
210
+ call c_f_pointer(this% extboundary_gpu,extboundary,[this% interp% N+1 ,this% interp% N+1 ,6 ,this% nelem,this% nvar])
211
+
212
+ do ivar = 1 ,this% nvar
213
+ do e1 = 1 ,this% nElem
214
+ do s1 = 1 ,6
215
+
216
+ e2 = mesh% sideInfo(3 ,s1,e1) ! Neighbor Element
217
+ if (e2 > 0 ) then
218
+ r2 = mesh% decomp% elemToRank(e2) ! Neighbor Rank
219
+
220
+ if (r2 /= mesh% decomp% rankId) then
221
+
222
+ s2 = mesh% sideInfo(4 ,s1,e1)/ 10
223
+ globalSideId = abs (mesh% sideInfo(2 ,s1,e1))
224
+ ! create unique tag for each side and each variable
225
+ tag = globalsideid+ mesh% nUniqueSides* (ivar-1 )
226
+
227
+ msgCount = msgCount+1
228
+ call MPI_IRECV(extBoundary(:,:,s1,e1,ivar), &
229
+ (this% interp% N+1 )* (this% interp% N+1 ), &
230
+ mesh% decomp% mpiPrec, &
231
+ r2,tag, &
232
+ mesh% decomp% mpiComm, &
233
+ mesh% decomp% requests(msgCount),iError)
234
+
235
+ msgCount = msgCount+1
236
+ call MPI_ISEND(boundary(:,:,s1,e1,ivar), &
237
+ (this% interp% N+1 )* (this% interp% N+1 ), &
238
+ mesh% decomp% mpiPrec, &
239
+ r2,tag, &
240
+ mesh% decomp% mpiComm, &
241
+ mesh% decomp% requests(msgCount),iError)
242
+ endif
243
+ endif
244
+
245
+ enddo
246
+ enddo
247
+ enddo
248
+
249
+ mesh% decomp% msgCount = msgCount
250
+
251
+ end subroutine MPIExchangeAsync_MappedScalar3D
252
+
190
253
subroutine SideExchange_MappedScalar3D (this ,mesh )
191
254
implicit none
192
255
class(MappedScalar3D),intent (inout ) :: this
@@ -196,16 +259,21 @@ subroutine SideExchange_MappedScalar3D(this,mesh)
196
259
197
260
offset = mesh% decomp% offsetElem(mesh% decomp% rankId+1 )
198
261
199
- ! call this%MPIExchangeAsync(mesh%decomp,mesh,resetCount=.true.)
262
+ if (mesh% decomp% mpiEnabled) then
263
+ call this% MPIExchangeAsync(mesh,resetCount= .true. )
264
+ endif
200
265
201
266
call SideExchange_3D_gpu(this% extboundary_gpu, &
202
267
this% boundary_gpu,mesh% sideinfo_gpu,mesh% decomp% elemToRank_gpu, &
203
268
mesh% decomp% rankid,offset,this% interp% N,this% nvar,this% nelem)
204
269
205
- ! call decomp%FinalizeMPIExchangeAsync()
206
-
207
- ! Apply side flips for data exchanged with MPI
208
- ! call this%ApplyFlip(decomp,mesh)
270
+ if (mesh% decomp% mpiEnabled) then
271
+ call mesh% decomp% FinalizeMPIExchangeAsync()
272
+ ! Apply side flips for data exchanged with MPI
273
+ call ApplyFlip_3D_gpu(this% extboundary_gpu,mesh% sideInfo_gpu, &
274
+ mesh% decomp% elemToRank_gpu,mesh% decomp% rankId, &
275
+ offset,this% interp% N,this% nVar,this% nElem)
276
+ endif
209
277
210
278
end subroutine SideExchange_MappedScalar3D
211
279
0 commit comments