fill_hash_tables Subroutine

private subroutine fill_hash_tables(hashes, matrix, block_estimate, row_map, col_map)

Fills row hashtable from an existing matrix.

Arguments

Type IntentOptional Attributes Name
type(hash_table_type), intent(inout), DIMENSION(:) :: hashes
type(dbcsr_type), intent(in) :: matrix
integer :: block_estimate

guess for the number of blocks in the product matrix, can be zero

integer, intent(in), DIMENSION(:) :: row_map
integer, intent(in), DIMENSION(:) :: col_map

Source Code

   SUBROUTINE fill_hash_tables(hashes, matrix, block_estimate, row_map, col_map)
      !! Fills row hashtable from an existing matrix.

      TYPE(hash_table_type), DIMENSION(:), INTENT(inout) :: hashes
      TYPE(dbcsr_type), INTENT(IN)                       :: matrix
      INTEGER                                            :: block_estimate
         !! guess for the number of blocks in the product matrix, can be zero
      INTEGER, DIMENSION(:), INTENT(IN)                  :: row_map, col_map

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

      INTEGER                                            :: col, handle, i, imat, n_rows, row

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

      CALL timeset(routineN, handle)
      imat = 1
!$    imat = OMP_GET_THREAD_NUM() + 1
      n_rows = matrix%nblkrows_local
      IF (SIZE(hashes) /= n_rows) &
         DBCSR_ABORT("Local row count mismatch")
      DO row = 1, n_rows
         ! create the hash table row with a reasonable initial size
         CALL hash_table_create(hashes(row), &
                                MAX(8, (3*block_estimate)/MAX(1, n_rows)))
      END DO
      ! We avoid using the iterator because we will use the existing
      ! work matrix instead of the BCSR index.
      DO i = 1, matrix%wms(imat)%lastblk
         row = matrix%wms(imat)%row_i(i)
         col = matrix%wms(imat)%col_i(i)
         row = row_map(row)
         col = col_map(col)
         CALL hash_table_add(hashes(row), col, i)
      END DO
      CALL timestop(handle)
   END SUBROUTINE fill_hash_tables