dbcsr_mm_cannon Module

First layer of the dbcsr matrix-matrix multiplication. It performs the MPI parallelization according to Cannon's algorithm. Modification history: - 2010-02-23 Moved from dbcsr_operations - 2011-11 Moved parameter-stack processing routines to dbcsr_mm_methods. - 2013-01 reorganized code (Ole Schuett)



Contents


Variables

TypeVisibilityAttributesNameInitial
character(len=*), private, parameter:: moduleN ='dbcsr_mm_cannon'
logical, private, parameter:: debug_mod =.FALSE.
logical, private, parameter:: careful_mod =.FALSE.

Interfaces

private interface dbcsr_switch


Subroutines

public subroutine make_m2s(matrix, m2s, rdist, dense_rdist, use_dense_mult, ab_dense, predistribute, f_k, l_k, f_row, l_row, f_col, l_col, row_blk_size, col_blk_size, k_vmap, m_map, n_map, alpha)

Make images from the matrix (left or right)

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_type), intent(in) :: matrix
type(dbcsr_2d_array_type), intent(out), POINTER:: m2s
type(dbcsr_imagedistribution_obj), intent(inout) :: rdist
type(dbcsr_imagedistribution_obj), intent(inout) :: dense_rdist
logical, intent(in) :: use_dense_mult
logical, intent(in) :: ab_dense
character, intent(in) :: predistribute
integer, intent(in) :: f_k
integer, intent(in) :: l_k
integer, intent(in) :: f_row
integer, intent(in) :: l_row
integer, intent(in) :: f_col
integer, intent(in) :: l_col
type(array_i1d_obj), intent(inout) :: row_blk_size
type(array_i1d_obj), intent(inout) :: col_blk_size
type(array_i1d_obj), intent(in) :: k_vmap
type(array_i1d_obj), intent(in) :: m_map
type(array_i1d_obj), intent(in) :: n_map
type(dbcsr_scalar_type), intent(in), optional :: alpha

private subroutine dbcsr_make_images(source, normalized, target_image_dist, predistribute, no_copy_data, scale_value)

Creates row and column images of a matrix.

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_type), intent(in) :: source

input matrix

type(dbcsr_2d_array_type), intent(out) :: normalized

image array of the normalized matrix

type(dbcsr_imagedistribution_obj), intent(in) :: target_image_dist

normalize to this image distribution

character, intent(in), optional :: predistribute

predistribute data for multiplication

logical, intent(in), optional :: no_copy_data

try to not merge data at the end

type(dbcsr_scalar_type), intent(in), optional :: scale_value

scale with this value

private subroutine make_images(ism, ums, target_imgdist, desymmetrize, predistribute, no_copy_data, scale_value)

Makes column-based and row-based images of a matrix.

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_type), intent(in) :: ism

input symmetric matrix

type(dbcsr_2d_array_type), intent(out) :: ums

normalized matrices

type(dbcsr_imagedistribution_obj), intent(in) :: target_imgdist

image distribution to normalize to

logical, intent(in), optional :: desymmetrize

desymmetrize a symmetric matrix

character, intent(in), optional :: predistribute

predistribute data for multiplication

logical, intent(in), optional :: no_copy_data

try to not merge data at the end

type(dbcsr_scalar_type), intent(in), optional :: scale_value

scale with this value

private subroutine dbcsr_make_images_dense(images, new_rdist, row_map, col_map, join_cols, join_rows, new_template)

Makes dense matrices for the image matrices.

Read more…

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_2d_array_type), intent(inout) :: images

current (undense) matrix images, output is the dense matrix images

type(dbcsr_imagedistribution_obj), intent(inout) :: new_rdist

the new image distribution for dense matrices

type(array_i1d_obj), intent(in) :: row_map

mapping of current (undense) rows to dense rows mapping of current (undense) columns to dense columns

type(array_i1d_obj), intent(in) :: col_map

mapping of current (undense) rows to dense rows mapping of current (undense) columns to dense columns

logical, intent(in) :: join_cols

make columns dense, default is yes make rows dense, default is yes

logical, intent(in) :: join_rows

make columns dense, default is yes make rows dense, default is yes

type(dbcsr_type), intent(in) :: new_template

template dense matrix for creating image matrices

public subroutine multiply_cannon(left_set, right_set, product_matrix, retain_sparsity, filter_eps, flop, keep_product_data)

Multiplies two DBCSR matrices

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_2d_array_type), POINTER:: left_set

set of imaged left matrices set of imaged right matrices

type(dbcsr_2d_array_type), POINTER:: right_set

set of imaged left matrices set of imaged right matrices

type(dbcsr_type), intent(inout) :: product_matrix

DBCSR product matrix

logical, intent(in), optional :: retain_sparsity

retain the sparsity of the existing product matrix; default is no

real(kind=real_8), intent(in), optional :: filter_eps
integer(kind=int_8), intent(out) :: flop

effective flop

logical, intent(in) :: keep_product_data

private subroutine setup_buffer_matrices(buffer_set, buff_nrows, buff_ncols, source_matrix, index_size, data_size)

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_2d_array_type), intent(out) :: buffer_set
integer, intent(in) :: buff_nrows
integer, intent(in) :: buff_ncols
type(dbcsr_type), intent(in) :: source_matrix
integer, intent(in) :: index_size
integer, intent(in), optional :: data_size

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

TypeIntentOptionalAttributesName
type(dbcsr_2d_array_type), intent(inout) :: buffer_set
integer, intent(in) :: index_size
integer, intent(in) :: data_size

private subroutine setup_rec_index_2d(matrix_set, n_rows, n_cols)

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_2d_array_type), intent(inout) :: matrix_set
integer, intent(in) :: n_rows
integer, intent(in) :: n_cols

private subroutine call_rec_sort_index(m, n, nblks, idx)

Used to thunk a call to rec_sort_index

Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: m
integer, intent(in) :: n
integer, intent(in) :: nblks
integer, intent(inout), DIMENSION(3, 1:nblks):: idx

private subroutine dbcsr_switch_sets(set1p, set2p)

Switches pointers between two matrix sets

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_2d_array_type), POINTER:: set1p
type(dbcsr_2d_array_type), POINTER:: set2p

private subroutine dbcsr_switch_d_ptrs(area1p, area2p)

Switches pointers between two data areas

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_data_obj), POINTER:: area1p
type(dbcsr_data_obj), POINTER:: area2p

private subroutine prepare_buffers_d(negate_real, negate_imaginary, iter, row, col, blk, blk_p, bp, row_size, col_size, nze, nsymmetries, symmetry_i, stored_row, stored_col, tr_row_size, tr_col_size, tr, row_img, col_img, nrow_images, ncol_images, row_img_dist, col_img_dist, predist_type_fwd, blacs2mpi, target_imgdist, prow, pcol, rowi, coli, row_dist, col_dist, dst_p, sm_pos, myt_smp, metalen, sd_pos, myt_sdp, send_meta, sd_disp, data_area, send_data_area, scale_neg_one, scale_value)

Prepare buffers for multiplications

Arguments

TypeIntentOptionalAttributesName
logical, intent(in) :: negate_real
logical, intent(in) :: negate_imaginary
type(dbcsr_iterator), intent(inout) :: iter
integer, intent(inout) :: row
integer, intent(inout) :: col
integer, intent(inout) :: blk
integer, intent(inout) :: blk_p
integer, intent(inout) :: bp
integer, intent(inout) :: row_size
integer, intent(inout) :: col_size
integer, intent(inout) :: nze
integer, intent(in) :: nsymmetries
integer, intent(inout) :: symmetry_i
integer, intent(inout) :: stored_row
integer, intent(inout) :: stored_col
integer, intent(inout) :: tr_row_size
integer, intent(inout) :: tr_col_size
logical, intent(inout) :: tr
integer, intent(inout) :: row_img
integer, intent(inout) :: col_img
integer, intent(in) :: nrow_images
integer, intent(in) :: ncol_images
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: row_img_dist
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: col_img_dist
character, intent(in) :: predist_type_fwd
integer, intent(in), DIMENSION(:, :), CONTIGUOUS, POINTER:: blacs2mpi
type(dbcsr_imagedistribution_obj), intent(in) :: target_imgdist
integer, intent(inout) :: prow
integer, intent(inout) :: pcol
integer, intent(inout) :: rowi
integer, intent(inout) :: coli
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: row_dist
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: col_dist
integer, intent(inout) :: dst_p
integer, intent(inout) :: sm_pos
integer, intent(inout), DIMENSION(:), ALLOCATABLE:: myt_smp
integer, intent(in) :: metalen
integer, intent(inout) :: sd_pos
integer, intent(inout), DIMENSION(:), ALLOCATABLE:: myt_sdp
integer, intent(inout), DIMENSION(:), ALLOCATABLE:: send_meta
integer, intent(in), DIMENSION(:), ALLOCATABLE:: sd_disp
real(kind=real_8), intent(in), DIMENSION(:), CONTIGUOUS:: data_area
type(dbcsr_data_obj), intent(inout) :: send_data_area
type(dbcsr_scalar_type), intent(in) :: scale_neg_one
type(dbcsr_scalar_type), intent(in), optional :: scale_value

private subroutine prepare_buffers_s(negate_real, negate_imaginary, iter, row, col, blk, blk_p, bp, row_size, col_size, nze, nsymmetries, symmetry_i, stored_row, stored_col, tr_row_size, tr_col_size, tr, row_img, col_img, nrow_images, ncol_images, row_img_dist, col_img_dist, predist_type_fwd, blacs2mpi, target_imgdist, prow, pcol, rowi, coli, row_dist, col_dist, dst_p, sm_pos, myt_smp, metalen, sd_pos, myt_sdp, send_meta, sd_disp, data_area, send_data_area, scale_neg_one, scale_value)

Prepare buffers for multiplications

Arguments

TypeIntentOptionalAttributesName
logical, intent(in) :: negate_real
logical, intent(in) :: negate_imaginary
type(dbcsr_iterator), intent(inout) :: iter
integer, intent(inout) :: row
integer, intent(inout) :: col
integer, intent(inout) :: blk
integer, intent(inout) :: blk_p
integer, intent(inout) :: bp
integer, intent(inout) :: row_size
integer, intent(inout) :: col_size
integer, intent(inout) :: nze
integer, intent(in) :: nsymmetries
integer, intent(inout) :: symmetry_i
integer, intent(inout) :: stored_row
integer, intent(inout) :: stored_col
integer, intent(inout) :: tr_row_size
integer, intent(inout) :: tr_col_size
logical, intent(inout) :: tr
integer, intent(inout) :: row_img
integer, intent(inout) :: col_img
integer, intent(in) :: nrow_images
integer, intent(in) :: ncol_images
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: row_img_dist
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: col_img_dist
character, intent(in) :: predist_type_fwd
integer, intent(in), DIMENSION(:, :), CONTIGUOUS, POINTER:: blacs2mpi
type(dbcsr_imagedistribution_obj), intent(in) :: target_imgdist
integer, intent(inout) :: prow
integer, intent(inout) :: pcol
integer, intent(inout) :: rowi
integer, intent(inout) :: coli
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: row_dist
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: col_dist
integer, intent(inout) :: dst_p
integer, intent(inout) :: sm_pos
integer, intent(inout), DIMENSION(:), ALLOCATABLE:: myt_smp
integer, intent(in) :: metalen
integer, intent(inout) :: sd_pos
integer, intent(inout), DIMENSION(:), ALLOCATABLE:: myt_sdp
integer, intent(inout), DIMENSION(:), ALLOCATABLE:: send_meta
integer, intent(in), DIMENSION(:), ALLOCATABLE:: sd_disp
real(kind=real_4), intent(in), DIMENSION(:), CONTIGUOUS:: data_area
type(dbcsr_data_obj), intent(inout) :: send_data_area
type(dbcsr_scalar_type), intent(in) :: scale_neg_one
type(dbcsr_scalar_type), intent(in), optional :: scale_value

private subroutine prepare_buffers_z(negate_real, negate_imaginary, iter, row, col, blk, blk_p, bp, row_size, col_size, nze, nsymmetries, symmetry_i, stored_row, stored_col, tr_row_size, tr_col_size, tr, row_img, col_img, nrow_images, ncol_images, row_img_dist, col_img_dist, predist_type_fwd, blacs2mpi, target_imgdist, prow, pcol, rowi, coli, row_dist, col_dist, dst_p, sm_pos, myt_smp, metalen, sd_pos, myt_sdp, send_meta, sd_disp, data_area, send_data_area, scale_neg_one, scale_value)

Prepare buffers for multiplications

Arguments

TypeIntentOptionalAttributesName
logical, intent(in) :: negate_real
logical, intent(in) :: negate_imaginary
type(dbcsr_iterator), intent(inout) :: iter
integer, intent(inout) :: row
integer, intent(inout) :: col
integer, intent(inout) :: blk
integer, intent(inout) :: blk_p
integer, intent(inout) :: bp
integer, intent(inout) :: row_size
integer, intent(inout) :: col_size
integer, intent(inout) :: nze
integer, intent(in) :: nsymmetries
integer, intent(inout) :: symmetry_i
integer, intent(inout) :: stored_row
integer, intent(inout) :: stored_col
integer, intent(inout) :: tr_row_size
integer, intent(inout) :: tr_col_size
logical, intent(inout) :: tr
integer, intent(inout) :: row_img
integer, intent(inout) :: col_img
integer, intent(in) :: nrow_images
integer, intent(in) :: ncol_images
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: row_img_dist
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: col_img_dist
character, intent(in) :: predist_type_fwd
integer, intent(in), DIMENSION(:, :), CONTIGUOUS, POINTER:: blacs2mpi
type(dbcsr_imagedistribution_obj), intent(in) :: target_imgdist
integer, intent(inout) :: prow
integer, intent(inout) :: pcol
integer, intent(inout) :: rowi
integer, intent(inout) :: coli
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: row_dist
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: col_dist
integer, intent(inout) :: dst_p
integer, intent(inout) :: sm_pos
integer, intent(inout), DIMENSION(:), ALLOCATABLE:: myt_smp
integer, intent(in) :: metalen
integer, intent(inout) :: sd_pos
integer, intent(inout), DIMENSION(:), ALLOCATABLE:: myt_sdp
integer, intent(inout), DIMENSION(:), ALLOCATABLE:: send_meta
integer, intent(in), DIMENSION(:), ALLOCATABLE:: sd_disp
complex(kind=real_8), intent(in), DIMENSION(:), CONTIGUOUS:: data_area
type(dbcsr_data_obj), intent(inout) :: send_data_area
type(dbcsr_scalar_type), intent(in) :: scale_neg_one
type(dbcsr_scalar_type), intent(in), optional :: scale_value

private subroutine prepare_buffers_c(negate_real, negate_imaginary, iter, row, col, blk, blk_p, bp, row_size, col_size, nze, nsymmetries, symmetry_i, stored_row, stored_col, tr_row_size, tr_col_size, tr, row_img, col_img, nrow_images, ncol_images, row_img_dist, col_img_dist, predist_type_fwd, blacs2mpi, target_imgdist, prow, pcol, rowi, coli, row_dist, col_dist, dst_p, sm_pos, myt_smp, metalen, sd_pos, myt_sdp, send_meta, sd_disp, data_area, send_data_area, scale_neg_one, scale_value)

Prepare buffers for multiplications

Arguments

TypeIntentOptionalAttributesName
logical, intent(in) :: negate_real
logical, intent(in) :: negate_imaginary
type(dbcsr_iterator), intent(inout) :: iter
integer, intent(inout) :: row
integer, intent(inout) :: col
integer, intent(inout) :: blk
integer, intent(inout) :: blk_p
integer, intent(inout) :: bp
integer, intent(inout) :: row_size
integer, intent(inout) :: col_size
integer, intent(inout) :: nze
integer, intent(in) :: nsymmetries
integer, intent(inout) :: symmetry_i
integer, intent(inout) :: stored_row
integer, intent(inout) :: stored_col
integer, intent(inout) :: tr_row_size
integer, intent(inout) :: tr_col_size
logical, intent(inout) :: tr
integer, intent(inout) :: row_img
integer, intent(inout) :: col_img
integer, intent(in) :: nrow_images
integer, intent(in) :: ncol_images
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: row_img_dist
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: col_img_dist
character, intent(in) :: predist_type_fwd
integer, intent(in), DIMENSION(:, :), CONTIGUOUS, POINTER:: blacs2mpi
type(dbcsr_imagedistribution_obj), intent(in) :: target_imgdist
integer, intent(inout) :: prow
integer, intent(inout) :: pcol
integer, intent(inout) :: rowi
integer, intent(inout) :: coli
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: row_dist
integer, intent(in), DIMENSION(:), CONTIGUOUS, POINTER:: col_dist
integer, intent(inout) :: dst_p
integer, intent(inout) :: sm_pos
integer, intent(inout), DIMENSION(:), ALLOCATABLE:: myt_smp
integer, intent(in) :: metalen
integer, intent(inout) :: sd_pos
integer, intent(inout), DIMENSION(:), ALLOCATABLE:: myt_sdp
integer, intent(inout), DIMENSION(:), ALLOCATABLE:: send_meta
integer, intent(in), DIMENSION(:), ALLOCATABLE:: sd_disp
complex(kind=real_4), intent(in), DIMENSION(:), CONTIGUOUS:: data_area
type(dbcsr_data_obj), intent(inout) :: send_data_area
type(dbcsr_scalar_type), intent(in) :: scale_neg_one
type(dbcsr_scalar_type), intent(in), optional :: scale_value