StageSolutionForTransfer_DGModel3D Subroutine

public subroutine StageSolutionForTransfer_DGModel3D(this)

Stage the pre-regrid solution on the DEVICE, replacing the base implementation's device-to-host copy of the whole field. Pair with ApplyTransferPlan, which consumes the staged copy:

call model%StageSolutionForTransfer()
call model%Regrid(newMesh,newGeom)
call model%ApplyTransferPlan(plan,interp,eFirst,eLast)

The staging buffer is model-owned and grows monotonically, so a settled adapting run performs no allocation in this path; it is released in Free.

Arguments

TypeIntentOptionalAttributesName
class(DGModel3D), intent(inout) :: this

Calls

proc~~stagesolutionfortransfer_dgmodel3d~~CallsGraph proc~stagesolutionfortransfer_dgmodel3d StageSolutionForTransfer_DGModel3D interface~hipfree hipFree proc~stagesolutionfortransfer_dgmodel3d->interface~hipfree proc~gpucheck gpuCheck proc~stagesolutionfortransfer_dgmodel3d->proc~gpucheck interface~hipmalloc hipMalloc proc~stagesolutionfortransfer_dgmodel3d->interface~hipmalloc interface~hipmemcpy hipMemcpy proc~stagesolutionfortransfer_dgmodel3d->interface~hipmemcpy

Contents


Source Code

  subroutine StageSolutionForTransfer_DGModel3D(this)
    !! Stage the pre-regrid solution on the DEVICE, replacing the base implementation's
    !! device-to-host copy of the whole field. Pair with ApplyTransferPlan, which consumes the
    !! staged copy:
    !!
    !!     call model%StageSolutionForTransfer()
    !!     call model%Regrid(newMesh,newGeom)
    !!     call model%ApplyTransferPlan(plan,interp,eFirst,eLast)
    !!
    !! The staging buffer is model-owned and grows monotonically, so a settled adapting run
    !! performs no allocation in this path; it is released in Free.
    implicit none
    class(DGModel3D),intent(inout) :: this
    ! Local
    integer(c_size_t) :: nbytes

    nbytes = int(this%solution%interp%N+1,c_size_t)*(this%solution%interp%N+1)* &
             (this%solution%interp%N+1)*this%solution%nElem*this%nvar*prec

    if(nbytes > this%xferAllocBytes) then
      if(c_associated(this%xferOld_gpu)) call gpuCheck(hipFree(this%xferOld_gpu))
      call gpuCheck(hipMalloc(this%xferOld_gpu,nbytes))
      this%xferAllocBytes = nbytes
    endif

    call gpuCheck(hipMemcpy(this%xferOld_gpu,this%solution%interior_gpu,nbytes, &
                            hipMemcpyDeviceToDevice))

    ! Remember the staged field's element count: it is the stride the transfer kernel must use
    ! to index the staged buffer, and it is no longer recoverable from the model after Regrid.
    this%xferNOld = this%solution%nElem

  endsubroutine StageSolutionForTransfer_DGModel3D