dbcsr_mm_csr Module

Third layer of the dbcsr matrix-matrix multiplication. It collects the full matrix blocks, which need to be multiplied, and stores their parameters in various stacks. After a certain amount of parameters is collected it dispatches the filled stacks to either the CPU or the accelerator device. Modification history: - 2010-02-23 Moved from dbcsr_operations - 2011-11 Moved parameter-stack processing routines to dbcsr_mm_methods. - 2013-01 extensive refactoring (Ole Schuett)



Variables

Type Visibility Attributes Name Initial
character(len=*), private, parameter :: moduleN = 'dbcsr_mm_csr'
logical, private, parameter :: debug_mod = .FALSE.
logical, private, parameter :: careful_mod = .FALSE.
integer, private, parameter :: max_stack_block_size = HUGE(INT(0))

max_stack_block_size The maximal block size to be specially treated.


Derived Types

type, public ::  dbcsr_mm_csr_type

Components

Type Visibility Attributes Name Initial
type(hash_table_type), private, DIMENSION(:), POINTER :: c_hashes => Null()
integer, private :: nm_stacks = -1
integer, private :: nn_stacks = -1
integer, private :: nk_stacks = -1
integer(kind=int_4), private, DIMENSION(:), POINTER :: m_size_maps => Null()
integer(kind=int_4), private, DIMENSION(:), POINTER :: n_size_maps => Null()
integer(kind=int_4), private, DIMENSION(:), POINTER :: k_size_maps => Null()
integer, private :: max_m = -1
integer, private :: max_n = -1
integer, private :: max_k = -1
integer, private :: m_size_maps_size = -1
integer, private :: n_size_maps_size = -1
integer, private :: k_size_maps_size = -1
integer(kind=int_1), private, DIMENSION(:, :, :), POINTER :: stack_map => Null()
type(stack_descriptor_type), private, DIMENSION(:), POINTER :: stacks_descr => Null()
type(dbcsr_work_type), private, POINTER :: product_wm => Null()
integer, private, DIMENSION(:, :, :), POINTER :: stacks_data => Null()
integer, private, DIMENSION(:), POINTER :: stacks_fillcount => Null()
type(dbcsr_mm_sched_type), private :: sched = dbcsr_mm_sched_type()
logical, private :: keep_product_data = .FALSE.

type, private ::  ele_type

Types needed for the hashtable.

Components

Type Visibility Attributes Name Initial
integer, public :: c = 0
integer, public :: p = 0

type, private ::  hash_table_type

Components

Type Visibility Attributes Name Initial
type(ele_type), public, DIMENSION(:), POINTER :: table
integer, public :: nele = 0
integer, public :: nmax = 0
integer, public :: prime = 0

Functions

private elemental function my_checker_tr(row, column) result(transpose)

Determines whether a transpose must be applied

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: row

The absolute matrix row. The absolute matrix column.

integer, intent(in) :: column

The absolute matrix row. The absolute matrix column.

Return Value logical

private function matching_prime(i) result(res)

finds a prime equal or larger than i, needed at creation

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: i

Return Value integer

private pure function hash_table_get(hash_table, c) result(p)

Arguments

Type IntentOptional Attributes Name
type(hash_table_type), intent(in) :: hash_table
integer, intent(in) :: c

Return Value integer


Subroutines

public subroutine dbcsr_mm_csr_lib_init()

Initialize the library

Arguments

None

public subroutine dbcsr_mm_csr_lib_finalize()

Finalize the library

Arguments

None

public subroutine dbcsr_mm_csr_multiply(this, left, right, mi, mf, ni, nf, ki, kf, ai, af, bi, bf, m_sizes, n_sizes, k_sizes, c_local_rows, c_local_cols, c_has_symmetry, keep_sparsity, use_eps, row_max_epss, flop, a_index, b_index, a_norms, b_norms)

A wrapper around dbcsr_mm_csr_multiply_low to avoid expensive dereferencings.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_mm_csr_type), intent(inout) :: this
type(dbcsr_type), intent(in) :: left
type(dbcsr_type), intent(in) :: right
integer, intent(in) :: mi
integer, intent(in) :: mf
integer, intent(in) :: ni
integer, intent(in) :: nf
integer, intent(in) :: ki
integer, intent(in) :: kf
integer, intent(in) :: ai
integer, intent(in) :: af
integer, intent(in) :: bi
integer, intent(in) :: bf
integer, intent(inout), DIMENSION(:) :: m_sizes
integer, intent(inout), DIMENSION(:) :: n_sizes
integer, intent(inout), DIMENSION(:) :: k_sizes
integer, intent(inout), DIMENSION(:) :: c_local_rows
integer, intent(inout), DIMENSION(:) :: c_local_cols
logical, intent(inout) :: c_has_symmetry
logical, intent(inout) :: keep_sparsity
logical, intent(inout) :: use_eps
real(kind=sp), DIMENSION(:) :: row_max_epss
integer(kind=int_8), intent(inout) :: flop
integer, intent(in), DIMENSION(1:3, 1:af) :: a_index
integer, intent(in), DIMENSION(1:3, 1:bf) :: b_index
real(kind=sp), DIMENSION(:), POINTER :: a_norms
real(kind=sp), DIMENSION(:), POINTER :: b_norms

private subroutine dbcsr_mm_csr_multiply_low(this, left, right, mi, mf, ki, kf, ai, af, bi, bf, c_row_i, c_col_i, c_blk_p, lastblk, datasize, m_sizes, n_sizes, k_sizes, c_local_rows, c_local_cols, c_has_symmetry, keep_sparsity, use_eps, row_max_epss, flop, row_size_maps, col_size_maps, k_size_maps, row_size_maps_size, col_size_maps_size, k_size_maps_size, nm_stacks, nn_stacks, nk_stacks, stack_map, stacks_data, stacks_fillcount, c_hashes, a_index, b_index, a_norms, b_norms)

Performs multiplication of smaller submatrices.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_mm_csr_type), intent(inout) :: this
type(dbcsr_type), intent(in) :: left
type(dbcsr_type), intent(in) :: right
integer, intent(in) :: mi
integer, intent(in) :: mf
integer, intent(in) :: ki
integer, intent(in) :: kf
integer, intent(in) :: ai
integer, intent(in) :: af
integer, intent(in) :: bi
integer, intent(in) :: bf
integer, intent(inout), DIMENSION(:) :: c_row_i
integer, intent(inout), DIMENSION(:) :: c_col_i
integer, intent(inout), DIMENSION(:) :: c_blk_p
integer, intent(inout) :: lastblk
integer, intent(inout) :: datasize
integer, intent(in), DIMENSION(:) :: m_sizes
integer, intent(in), DIMENSION(:) :: n_sizes
integer, intent(in), DIMENSION(:) :: k_sizes
integer, intent(in), DIMENSION(:) :: c_local_rows
integer, intent(in), DIMENSION(:) :: c_local_cols
logical, intent(in) :: c_has_symmetry
logical, intent(in) :: keep_sparsity
logical, intent(in) :: use_eps
real(kind=sp), DIMENSION(:) :: row_max_epss
integer(kind=int_8), intent(inout) :: flop
integer(kind=int_4), intent(in), DIMENSION(0:row_size_maps_size - 1) :: row_size_maps
integer(kind=int_4), intent(in), DIMENSION(0:col_size_maps_size - 1) :: col_size_maps
integer(kind=int_4), intent(in), DIMENSION(0:k_size_maps_size - 1) :: k_size_maps
integer, intent(in) :: row_size_maps_size
integer, intent(in) :: col_size_maps_size
integer, intent(in) :: k_size_maps_size
integer, intent(in) :: nm_stacks
integer, intent(in) :: nn_stacks
integer, intent(in) :: nk_stacks
integer(kind=int_1), intent(in), DIMENSION(nn_stacks + 1, nk_stacks + 1, nm_stacks + 1) :: stack_map
integer, intent(inout), DIMENSION(:, :, :) :: stacks_data
integer, intent(inout), DIMENSION(:) :: stacks_fillcount
type(hash_table_type), intent(inout), DIMENSION(:) :: c_hashes
integer, intent(in), DIMENSION(1:3, 1:af) :: a_index
integer, intent(in), DIMENSION(1:3, 1:bf) :: b_index
real(kind=sp), DIMENSION(:), POINTER :: a_norms
real(kind=sp), DIMENSION(:), POINTER :: b_norms

public subroutine dbcsr_mm_csr_init(this, left, right, product, m_sizes, n_sizes, block_estimate, right_row_blk_size, nlayers, keep_product_data)

Initializes a multiplication cycle for new set of C-blocks.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_mm_csr_type), intent(inout) :: this
type(dbcsr_type), intent(in), optional :: left
type(dbcsr_type), intent(in), optional :: right
type(dbcsr_type), intent(inout) :: product
integer, DIMENSION(:), POINTER :: m_sizes
integer, DIMENSION(:), POINTER :: n_sizes
integer, intent(in) :: block_estimate
integer, intent(in), DIMENSION(:) :: right_row_blk_size
integer, optional :: nlayers
logical, intent(in) :: keep_product_data

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

public subroutine dbcsr_mm_csr_finalize(this)

Finalizes a multiplication cycle for a set of C-blocks.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_mm_csr_type), intent(inout) :: this

public subroutine dbcsr_mm_csr_dev2host_init(this)

Arguments

Type IntentOptional Attributes Name
type(dbcsr_mm_csr_type), intent(inout) :: this

public subroutine dbcsr_mm_csr_red3D(this, meta_buffer, data_buffer, flop, m_sizes, n_sizes, g2l_map_rows, g2l_map_cols, original_lastblk, keep_sparsity)

Make the reduction of the 3D layers in the local csr object

Arguments

Type IntentOptional Attributes Name
type(dbcsr_mm_csr_type), intent(inout) :: this
integer, intent(in), DIMENSION(:), TARGET :: meta_buffer
type(dbcsr_data_obj), intent(in) :: data_buffer
integer(kind=int_8), intent(inout) :: flop
integer, intent(in), DIMENSION(:) :: m_sizes
integer, intent(in), DIMENSION(:) :: n_sizes
integer, intent(in), DIMENSION(:) :: g2l_map_rows
integer, intent(in), DIMENSION(:) :: g2l_map_cols
integer, intent(in) :: original_lastblk
logical, intent(in) :: keep_sparsity

public subroutine dbcsr_mm_csr_purge_stacks(this, left, right)

Arguments

Type IntentOptional Attributes Name
type(dbcsr_mm_csr_type), intent(inout) :: this
type(dbcsr_type), intent(in) :: left
type(dbcsr_type), intent(in) :: right

private subroutine flush_stacks(this, left, right, purge)

Arguments

Type IntentOptional Attributes Name
type(dbcsr_mm_csr_type), intent(inout) :: this
type(dbcsr_type), intent(in) :: left
type(dbcsr_type), intent(in) :: right
logical, intent(in), optional :: purge

private subroutine build_csr_index(mi, mf, ai, af, row_p, blk_info, list_index, nnorms, csr_norms, list_norms)

Builds and sorts a CSR index from a list index.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: mi
integer, intent(in) :: mf
integer, intent(in) :: ai
integer, intent(in) :: af
integer, intent(out), DIMENSION(mi:mf + 1) :: row_p
integer, intent(out), DIMENSION(2, 1:af - ai + 1) :: blk_info
integer, intent(in), DIMENSION(3, 1:af) :: list_index
integer, intent(in) :: nnorms
real(kind=sp), intent(out), DIMENSION(1:af - ai + 1) :: csr_norms
real(kind=sp), intent(in), DIMENSION(:) :: list_norms

private subroutine hash_table_create(hash_table, table_size)

create a hash_table of given initial size. the hash table will expand as needed (but this requires rehashing)

Arguments

Type IntentOptional Attributes Name
type(hash_table_type) :: hash_table
integer, intent(in) :: table_size

private subroutine hash_table_release(hash_table)

Arguments

Type IntentOptional Attributes Name
type(hash_table_type) :: hash_table

private recursive subroutine hash_table_add(hash_table, c, p)

add a pair (c,p) to the hash table

Arguments

Type IntentOptional Attributes Name
type(hash_table_type), intent(inout) :: hash_table
integer, intent(in) :: c

this value is being hashed this is being stored

integer, intent(in) :: p

this value is being hashed this is being stored