buffer_matrices_ensure_size Subroutine

private subroutine buffer_matrices_ensure_size(buffer_set, index_size, data_size)

Enlarge left_set and right_set to hold any a/b-panel. left_set and right_set are created by make_images to hold the a/b-panels used for the initial cannon-tick. This routine ensures that these buffers can hold any a/b-panel occurring during a matrix multiply and makes them therefore suitable as buffers for the entire cannon algorithm. This saves memory since no separate buffers for the first cannon-tick have to be allocated.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_2d_array_type), intent(inout) :: buffer_set
integer, intent(in) :: index_size
integer, intent(in) :: data_size

Source Code

   SUBROUTINE buffer_matrices_ensure_size(buffer_set, index_size, data_size)
      !! Enlarge left_set and right_set to hold any a/b-panel.
      !! left_set and right_set are created by make_images to hold the a/b-panels
      !! used for the initial cannon-tick. This routine ensures that these buffers
      !! can hold any a/b-panel occurring during a matrix multiply and makes them
      !! therefore suitable as buffers for the entire cannon algorithm.
      !! This saves memory since no separate buffers for the first cannon-tick
      !! have to be allocated.

      TYPE(dbcsr_2d_array_type), INTENT(INOUT)           :: buffer_set
      INTEGER, INTENT(IN)                                :: index_size, data_size

      CHARACTER(len=*), PARAMETER :: routineN = 'buffer_matrices_ensure_size'

      INTEGER                                            :: col_image, handle, row_image

!   ---------------------------------------------------------------------------

      CALL timeset(routineN, handle)

      DO row_image = 1, SIZE(buffer_set%mats, 1)
         DO col_image = 1, SIZE(buffer_set%mats, 2)
            CALL dbcsr_data_ensure_size(buffer_set%mats(row_image, col_image)%data_area, &
                                        data_size)
            CALL ensure_array_size(buffer_set%mats(row_image, col_image)%index, &
                                   ub=index_size, &
                                   memory_type=dbcsr_get_index_memory_type(buffer_set%mats(row_image, col_image)))
            CALL dbcsr_repoint_index(buffer_set%mats(row_image, col_image))
         END DO
      END DO
      CALL timestop(handle)
   END SUBROUTINE buffer_matrices_ensure_size