Sets up pointers for IJ solver.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
impure subroutine hypre_obj_SetupPointersIJ(this) !> Sets up pointers for IJ solver. use leapCuda implicit none class(hypre_obj), intent(inout) :: this !! Hypre machinery ! Work variables integer :: stp integer :: nval integer :: Ng(3) #ifdef USE_GPU integer :: ierr integer :: stat #endif ! Determine the dimensionality of the problem associate (lo=>this%block%lo, hi =>this%block%hi) ! Get number of grid points in each direction call this%parallel%Max(hi(1),Ng(1)) call this%parallel%Max(Ng(1)-lo(1)+1,Ng(1)) call this%parallel%Max(hi(2),Ng(2)) call this%parallel%Max(Ng(2)-lo(2)+1,Ng(2)) call this%parallel%Max(hi(3),Ng(3)) call this%parallel%Max(Ng(3)-lo(3)+1,Ng(3)) end associate ! Determine stencil size stp = 1 ! Diangonal entry if (Ng(1).gt.1) stp = stp + 2*this%stm ! upper/lower diagonal entries in x1-dir if (Ng(2).gt.1) stp = stp + 2*this%stm ! upper/lower diagonal entries in x2-dir if (Ng(3).gt.1) stp = stp + 2*this%stm ! upper/lower diagonal entries in x3-dir nval = (this%block%hi(3)-this%block%lo(3)+1) & * (this%block%hi(2)-this%block%lo(2)+1) & * (this%block%hi(1)-this%block%lo(1)+1) #ifdef USE_GPU ! Allocate data on GPU's Unified Memory stat = device_malloc_managed(int(nval * wp, leapI8), this%p_rhs_values) stat = device_malloc_managed(int(nval * wp, leapI8), this%p_sol_values) stat = device_malloc_managed(int(nval * 4, leapI8), this%p_rows) stat = device_malloc_managed(int(stp * wp, leapI8), this%p_values) stat = device_malloc_managed(int(stp * 4, leapI8), this%p_cols) stat = device_malloc_managed(int(2 * 4, leapI8), this%p_tmpi) ! Assigns the target of the C pointes to the Fortran pointers ! and specifies the shape. call c_f_pointer(this%p_rhs_values, this%rhs_values, [nval]) call c_f_pointer(this%p_sol_values, this%sol_values, [nval]) call c_f_pointer(this%p_rows, this%rows, [nval]) call c_f_pointer(this%p_values, this%values, [stp]) call c_f_pointer(this%p_cols, this%cols, [stp]) call c_f_pointer(this%p_tmpi, this%tmpi, [2]) #else allocate(this%rhs_values(nval)) allocate(this%sol_values(nval)) allocate(this%values(stp)) allocate(this%rows(nval)) allocate(this%cols(stp)) allocate(this%tmpi(2)) #endif #ifdef USE_GPU ! Instruct HYPRE to run on GPU call HYPRE_SetMemoryLocation(HYPRE_MEMORY_DEVICE, ierr) call HYPRE_SetExecutionPolicy(HYPRE_EXEC_DEVICE, ierr) ! Use HYPRE's SpGEMM instead of vendor implementation call HYPRE_SetSpGemmUseVendor(0, ierr) #endif end subroutine hypre_obj_SetupPointersIJ