Skip to content

Commit

Permalink
Update: to use pinned host memory for async transfers.
Browse files Browse the repository at this point in the history
Also update focal external reference accordingly.
  • Loading branch information
LKedward committed Jan 19, 2020
1 parent 386b3c6 commit f824618
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion external/focal
18 changes: 11 additions & 7 deletions src/lbmocl.f90
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ program lbmocl
use LBM_Tecplot_Output
use Focal
use iso_fortran_env, only: sp=>real32, dp=>real64
use iso_c_binding, only: c_int64_t
implicit none

! ------------------ VARIABLE DECLARATIONS ------------------
Expand Down Expand Up @@ -47,7 +46,7 @@ program lbmocl
type(fclDeviceInt32) :: bcFlags_d

! VARS: Host arrays
real(sp), allocatable :: rho(:,:), u(:,:), v(:,:)
real(sp), pointer :: rho(:,:), u(:,:), v(:,:)

! VARS: Profiling
integer(c_int64_t) :: collideTavg, boundariesTavg, streamTavg
Expand Down Expand Up @@ -90,10 +89,6 @@ program lbmocl
call printConfiguration(caseNum,ni,nj,nIter,saveFreq,outputFile,outputMode,&
dx, dt, tau)

! Allocate host arrays
allocate(rho(npts,nSave))
allocate(u(npts,nSave))
allocate(v(npts,nSave))

! Create context with specified vendor
call fclSetDefaultContext(fclCreateContext(vendor=trim(adjustl(cl_vendor))))
Expand All @@ -115,6 +110,15 @@ program lbmocl
! Create an additional asynchronous command queue for host transfers
asyncQ = fclCreateCommandQ(devices(1),enableProfiling=.true.,outOfOrderExec=.true.,blockingRead=.false.)

! Allocate host arrays using pinned (non-paged) memory
call fclAllocHost(rho,[npts,nSave])
call fclAllocHost(u,[npts,nSave])
call fclAllocHost(v,[npts,nSave])

! allocate(rho(npts,nSave))
! allocate(u(npts,nSave))
! allocate(v(npts,nSave))

! Load and compile OpenCL source
call fclGetKernelResource(programSource)
prog = fclCompileProgram(programSource) !,'-cl-nv-verbose')
Expand Down Expand Up @@ -181,7 +185,7 @@ program lbmocl

! Transfer to host using out-of-order asynchronous queue
! (Two dependencies: calcVars kernel and last data transfer)
call fclSetDependency(asyncQ,depends(2),hold=.true.)
call fclSetDependency(asyncQ,depends,hold=.true.)
rho(:,it/saveFreq) = rho_d
u(:,it/saveFreq) = u_d
v(:,it/saveFreq) = v_d
Expand Down

0 comments on commit f824618

Please sign in to comment.