dbcsr_mm_3d Module

3D matrix-matrix multiplication. Modification history: - 2016-08 Code organization (Alfio Lazzaro). - 2017-02 Remove clusters (Alfio Lazzaro).



Variables

Type Visibility Attributes Name Initial
character(len=*), private, parameter :: moduleN = 'dbcsr_mm_3d'
logical, private, parameter :: debug_mod = .FALSE.
logical, private, parameter :: careful_mod = .FALSE.
type(dbcsr_buffers), private, TARGET, SAVE :: buffers_win
type(dbcsr_buffers), private, TARGET, SAVE :: buffers_1
type(dbcsr_buffers), private, TARGET, SAVE :: buffers_2
integer, private, parameter :: idata = 1
integer, private, parameter :: imeta = 2
integer, private, parameter :: ilocal_proc = 1
type(dbcsr_layers_3D_C_reduction), private, SAVE :: layers_3D_C_reduction
logical, private, DIMENSION(2), TARGET, SAVE :: do_win_create_left
logical, private, DIMENSION(2), TARGET, SAVE :: do_win_create_right
integer, private, ALLOCATABLE, DIMENSION(:) :: left_total_row_counts
integer, private, ALLOCATABLE, DIMENSION(:, :), TARGET :: left_local_images_size
integer, private, ALLOCATABLE, DIMENSION(:, :), TARGET :: right_local_images_size
integer, private, DIMENSION(:, :, :, :), POINTER, CONTIGUOUS :: left_images_size => Null()
integer, private, DIMENSION(:, :, :, :), POINTER, CONTIGUOUS :: right_images_size => Null()
integer, private, ALLOCATABLE, DIMENSION(:), TARGET :: g2l_map_cols
integer, private, ALLOCATABLE, DIMENSION(:), TARGET :: g2l_map_rows
type(mp_request_type), private :: request_count_rows
type(mp_request_type), private, DIMENSION(2) :: requests
type(mp_request_type), private, DIMENSION(2) :: requests_win_create
type(mp_request_type), public :: request_sync_mult = mp_request_null
type(dbcsr_data_obj), private, TARGET, SAVE :: make_buffers_data_recv
type(dbcsr_data_obj), private, TARGET, SAVE :: make_buffers_data_send
integer, private, DIMENSION(:), POINTER, CONTIGUOUS :: make_buffers_meta_recv => Null()
integer, private, DIMENSION(:), POINTER, CONTIGUOUS :: make_buffers_meta_send => Null()

Derived Types

type, private ::  dbcsr_buffer

Components

Type Visibility Attributes Name Initial
type(dbcsr_data_obj), public :: DATA = dbcsr_data_obj()
type(dbcsr_data_obj), public :: data_before_resize = dbcsr_data_obj()
type(dbcsr_data_obj), public :: trs_stackbuf = dbcsr_data_obj()
integer, public :: vprow = -1
integer, public :: vpcol = -1
integer, public :: myproc = -1
type(mp_comm_type), public :: grp = mp_comm_null
type(mp_comm_type), public :: subgrp = mp_comm_null
type(mp_win_type), public :: data_win = mp_win_type()
type(mp_win_type), public :: meta_win = mp_win_type()
integer, public, DIMENSION(:), POINTER, CONTIGUOUS :: meta => Null()
integer, public, DIMENSION(:), POINTER, CONTIGUOUS :: meta_before_resize => Null()
integer, public, DIMENSION(:), POINTER, CONTIGUOUS :: meta_red3D => Null()
type(mp_request_type), public, DIMENSION(2) :: get_requests = mp_request_null
integer, public :: meta_size = -1
integer, public :: num_layers_3D = 1
integer, public :: coord3D = 1
type(dbcsr_type), public :: matrix = dbcsr_type()
logical, public :: is_valid = .FALSE.
logical, public :: is_comm = .FALSE.
logical, public :: has_rma_win = .FALSE.

type, private ::  dbcsr_buffers

Components

Type Visibility Attributes Name Initial
type(dbcsr_buffer), public :: left = dbcsr_buffer()
type(dbcsr_buffer), public :: right = dbcsr_buffer()

type, private ::  mn_local_sizes

Components

Type Visibility Attributes Name Initial
integer, public, DIMENSION(:), POINTER, CONTIGUOUS :: sizes => Null()

type, private ::  dbcsr_layers_3D_C_reduction

Components

Type Visibility Attributes Name Initial
type(mp_comm_type), public :: grp = mp_comm_null
type(mp_comm_type), public :: grp3D = mp_comm_null
type(mp_comm_type), public :: rowgrp3D = mp_comm_null
integer, public :: num_layers_3D = 1
integer, public :: max_num_layers_3D = 1
integer, public :: side3D = HUGE(1)
type(dbcsr_data_obj), public, DIMENSION(:), ALLOCATABLE :: data_red3D
integer, public :: data_type = -1

Functions

private pure function get_rank3D(myprow, mypcol, nprows, side3D)

Return the rank of the 3D layer (3D communicator for C), Column-major order

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: myprow
integer, intent(in) :: mypcol
integer, intent(in) :: nprows
integer, intent(in) :: side3D

Return Value integer

public pure function get_max_layers_3D()

Arguments

None

Return Value integer


Subroutines

public subroutine dbcsr_make_buffers(matrix, imgdist, is_left, f_row, l_row, f_col, l_col, otf_filtering, alpha)

Prepare orig images for MPI windows

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(in) :: matrix
type(dbcsr_imagedistribution_obj), intent(in) :: imgdist
logical, intent(in) :: is_left
integer, intent(in) :: f_row
integer, intent(in) :: l_row
integer, intent(in) :: f_col
integer, intent(in) :: l_col
logical, intent(in) :: otf_filtering
type(dbcsr_scalar_type), intent(in), optional :: alpha

private subroutine make_buffers(matrix, imgdist, is_left, f_row, l_row, f_col, l_col, otf_filtering, scale_value)

Prepare orig images for MPI windows

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(in) :: matrix
type(dbcsr_imagedistribution_obj), intent(in) :: imgdist
logical, intent(in) :: is_left
integer, intent(in) :: f_row
integer, intent(in) :: l_row
integer, intent(in) :: f_col
integer, intent(in) :: l_col
logical, intent(in) :: otf_filtering
type(dbcsr_scalar_type), intent(in), optional :: scale_value

private subroutine make_layers_3D_AB(my_num_layers_3D, side3D, mp_obj, is_left, buffer)

Make communicators for A and B matrices

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: my_num_layers_3D
integer, intent(in) :: side3D
type(dbcsr_mp_obj), intent(in) :: mp_obj
logical, intent(in) :: is_left
type(dbcsr_buffer), intent(inout) :: buffer

public subroutine make_layers_3D_C_reduction(my_num_layers_3D, mp_obj)

Make communicators for 3D layers for C-reduction

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: my_num_layers_3D
type(dbcsr_mp_obj), intent(inout) :: mp_obj

public subroutine release_layers_3D_C_reduction(release_buffers)

Release communicators for 3D layers for C-reduction

Arguments

Type IntentOptional Attributes Name
logical, optional :: release_buffers

public subroutine multiply_3D(imgdist_left, imgdist_right, matrix_left, matrix_right, product_matrix, retain_sparsity, filter_eps, flop, keep_product_data)

Multiplies two DBCSR matrices (experimental MPI algorithm). This algorithm is experimental and it should be not used in production runs.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_imagedistribution_obj), intent(inout) :: imgdist_left
type(dbcsr_imagedistribution_obj), intent(inout) :: imgdist_right
type(dbcsr_type), intent(in) :: matrix_left
type(dbcsr_type), intent(in) :: matrix_right
type(dbcsr_type), intent(inout), TARGET :: 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 win_setup(buffer, do_win_create, request)

Arguments

Type IntentOptional Attributes Name
type(dbcsr_buffer), intent(inout) :: buffer
logical, intent(inout), DIMENSION(:) :: do_win_create
type(mp_request_type), intent(inout) :: request

private subroutine row_col_3D_reflected(irow3D, icol3D, nrows3D, ncols3D, shift3D)

Apply reflected order, i.e. row increasing value for odd col value, row decreasing value for even col value

Arguments

Type IntentOptional Attributes Name
integer, intent(inout) :: irow3D
integer, intent(inout) :: icol3D
integer, intent(in) :: nrows3D
integer, intent(in) :: ncols3D
integer, intent(in) :: shift3D

private subroutine setup_buffers(buffer_1, buffer_2, buffers, nbuffers, data_size, meta_size, matrix, imgdist)

Arguments

Type IntentOptional Attributes Name
type(dbcsr_buffer), intent(inout), TARGET :: buffer_1
type(dbcsr_buffer), intent(inout), TARGET :: buffer_2
type(dbcsr_buffer), intent(inout), ALLOCATABLE, DIMENSION(:) :: buffers
integer, intent(in) :: nbuffers
integer, intent(in) :: data_size
integer, intent(in) :: meta_size
type(dbcsr_type), intent(in) :: matrix
type(dbcsr_imagedistribution_obj), intent(inout) :: imgdist

private subroutine setup_buffer_matrix_image(matrix, imgdist, template_matrix, data_buffer, meta_buffer)

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: matrix
type(dbcsr_imagedistribution_obj), intent(inout) :: imgdist
type(dbcsr_type), intent(in) :: template_matrix
type(dbcsr_data_obj), intent(inout) :: data_buffer
integer, intent(in), DIMENSION(:), TARGET, CONTIGUOUS :: meta_buffer

private subroutine swap_buffers(buffers_1, buffers_2)

Arguments

Type IntentOptional Attributes Name
type(dbcsr_buffer), intent(inout) :: buffers_1
type(dbcsr_buffer), intent(inout) :: buffers_2

private subroutine rma_transfer(recv_vproc, nimages, size_layers3D, displ_layers3D, buffer, meta_win, data_win, data_get, data_type_byte, buffer_win, layer3D, nlayers3D)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: recv_vproc
integer, intent(in) :: nimages
integer, intent(in), DIMENSION(:) :: size_layers3D
integer, intent(in), DIMENSION(:) :: displ_layers3D
type(dbcsr_buffer), intent(inout) :: buffer
type(mp_win_type), intent(in) :: meta_win
type(mp_win_type), intent(in) :: data_win
type(dbcsr_data_obj), intent(inout) :: data_get
integer, intent(in) :: data_type_byte
type(dbcsr_buffer), intent(in) :: buffer_win
integer, intent(in) :: layer3D
integer, intent(in) :: nlayers3D

private subroutine setup_rec_index_images(meta_buffer, img_nblks_rows, img_nblks_cols, refs_size, refs_displ, size_index, has_threads)

Arguments

Type IntentOptional Attributes Name
integer, intent(inout), DIMENSION(:) :: meta_buffer
integer, intent(in), DIMENSION(:) :: img_nblks_rows
integer, intent(in), DIMENSION(:) :: img_nblks_cols
integer, intent(in), DIMENSION(:) :: refs_size
integer, intent(in), DIMENSION(:) :: refs_displ
integer, intent(in) :: size_index
logical, intent(in) :: has_threads

private subroutine buffer_init(buffer, data_type, data_size, meta_size, num_data, data_memory_type, trs_memory_type)

Init buffer

Arguments

Type IntentOptional Attributes Name
type(dbcsr_buffer), intent(inout) :: buffer
integer, intent(in) :: data_type
integer, intent(in) :: data_size
integer, intent(in) :: meta_size
integer, intent(in), optional :: num_data
type(dbcsr_memtype_type), intent(in) :: data_memory_type
type(dbcsr_memtype_type), intent(in), optional :: trs_memory_type

public subroutine buffers_release()

Release all buffers

Arguments

None

private subroutine buffer_release(buffer)

Release buffer

Arguments

Type IntentOptional Attributes Name
type(dbcsr_buffer), intent(inout) :: buffer

private subroutine make_meta(buffer, ntotal_images, vprow, vpcol, imgdist, do_merge_rows, global_indices, nthreads)

Create meta indices

Arguments

Type IntentOptional Attributes Name
type(dbcsr_buffer), intent(inout) :: buffer
integer, intent(in) :: ntotal_images
integer, intent(in) :: vprow
integer, intent(in) :: vpcol
type(dbcsr_imagedistribution_obj), intent(inout) :: imgdist
logical, intent(in) :: do_merge_rows
integer, intent(in), DIMENSION(:) :: global_indices
integer, intent(in), optional :: nthreads

private subroutine remap_layers3D(refs_size, refs_size_layers3D, refs_displ_layers3D, data_size, meta_size)

Remap the 4-rank array in a 3-rank array by introducing the virtual coordinate

Arguments

Type IntentOptional Attributes Name
integer, intent(in), DIMENSION(:, :, :, :), CONTIGUOUS, POINTER :: refs_size
integer, intent(out), DIMENSION(:, :, :), CONTIGUOUS, POINTER :: refs_size_layers3D
integer, intent(out), DIMENSION(:, :, :), CONTIGUOUS, POINTER :: refs_displ_layers3D
integer, intent(out) :: data_size
integer, intent(out) :: meta_size