dbcsr_tensor_test Module

General methods for testing DBCSR tensors.



Variables

Type Visibility Attributes Name Initial
character(len=*), private, parameter :: moduleN = 'dbcsr_tensor_test'
integer, private, SAVE :: randmat_counter = 0
integer, private, parameter :: rand_seed_init = 12341313

Interfaces

  • private subroutine dist_sparse_tensor_to_repl_dense_2d_array_r_dp(tensor, array)

    Transform a distributed sparse tensor to a replicated dense array. This is only useful for testing tensor contraction by matrix multiplication of dense arrays.

    Arguments

    Type IntentOptional Attributes Name
    type(dbcsr_t_type), intent(inout) :: tensor
    real(kind=real_8), intent(out), ALLOCATABLE, DIMENSION(:,:) :: array
  • private subroutine dist_sparse_tensor_to_repl_dense_3d_array_r_dp(tensor, array)

    Transform a distributed sparse tensor to a replicated dense array. This is only useful for testing tensor contraction by matrix multiplication of dense arrays.

    Arguments

    Type IntentOptional Attributes Name
    type(dbcsr_t_type), intent(inout) :: tensor
    real(kind=real_8), intent(out), ALLOCATABLE, DIMENSION(:,:,:) :: array
  • private subroutine dist_sparse_tensor_to_repl_dense_4d_array_r_dp(tensor, array)

    Transform a distributed sparse tensor to a replicated dense array. This is only useful for testing tensor contraction by matrix multiplication of dense arrays.

    Arguments

    Type IntentOptional Attributes Name
    type(dbcsr_t_type), intent(inout) :: tensor
    real(kind=real_8), intent(out), ALLOCATABLE, DIMENSION(:,:,:,:) :: array

Functions

private function dbcsr_t_equal(tensor1, tensor2)

check if two (arbitrarily mapped and distributed) tensors are equal.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_t_type), intent(inout) :: tensor1
type(dbcsr_t_type), intent(inout) :: tensor2

Return Value logical

private pure function blocks_equal(block1, block2)

check if two blocks are equal

Arguments

Type IntentOptional Attributes Name
type(block_nd), intent(in) :: block1
type(block_nd), intent(in) :: block2

Return Value logical

private pure function factorial(n)

Compute factorial

Arguments

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

Return Value integer

private function sizes_2d(nd_sizes, map1, map2)

mapped sizes in 2d

Arguments

Type IntentOptional Attributes Name
integer, intent(in), DIMENSION(:) :: nd_sizes
integer, intent(in), DIMENSION(:) :: map1
integer, intent(in), DIMENSION(:) :: map2

Return Value integer, DIMENSION(2)

public function dbcsr_t_checksum(tensor, local, pos)

checksum of a tensor consistent with dbcsr_checksum

Arguments

Type IntentOptional Attributes Name
type(dbcsr_t_type), intent(in) :: tensor
logical, intent(in), optional :: local
logical, intent(in), optional :: pos

Return Value real(kind=real_8)


Subroutines

private subroutine permute(n, p)

Compute all permutations p of (1, 2, ..., n)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
integer, intent(out), DIMENSION(n, factorial(n)) :: p

public subroutine dbcsr_t_test_formats(ndims, mp_comm, unit_nr, verbose, blk_size_1, blk_size_2, blk_size_3, blk_size_4, blk_ind_1, blk_ind_2, blk_ind_3, blk_ind_4)

Test equivalence of all tensor formats, using a random distribution.

Arguments

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

tensor rank

type(mp_comm_type), intent(in) :: mp_comm
integer, intent(in) :: unit_nr

output unit, needs to be a valid unit number on all mpi ranks

logical, intent(in) :: verbose

if .TRUE., print all tensor blocks

integer, intent(in), optional, DIMENSION(:) :: blk_size_1

block sizes along respective dimension

integer, intent(in), optional, DIMENSION(:) :: blk_size_2

block sizes along respective dimension

integer, intent(in), optional, DIMENSION(:) :: blk_size_3

block sizes along respective dimension

integer, intent(in), optional, DIMENSION(:) :: blk_size_4

block sizes along respective dimension

integer, intent(in), optional, DIMENSION(:) :: blk_ind_1

index along respective dimension of non-zero blocks

integer, intent(in), optional, DIMENSION(:) :: blk_ind_2

index along respective dimension of non-zero blocks

integer, intent(in), optional, DIMENSION(:) :: blk_ind_3

index along respective dimension of non-zero blocks

integer, intent(in), optional, DIMENSION(:) :: blk_ind_4

index along respective dimension of non-zero blocks

public subroutine dbcsr_t_setup_test_tensor(tensor, mp_comm, enumerate, blk_ind_1, blk_ind_2, blk_ind_3, blk_ind_4)

Allocate and fill test tensor - entries are enumerated by their index s.t. they only depend on global properties of the tensor but not on distribution, matrix representation, etc.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_t_type), intent(inout) :: tensor
type(mp_comm_type), intent(in) :: mp_comm

communicator

logical, intent(in) :: enumerate
integer, intent(in), optional, DIMENSION(:) :: blk_ind_1

index along respective dimension of non-zero blocks

integer, intent(in), optional, DIMENSION(:) :: blk_ind_2

index along respective dimension of non-zero blocks

integer, intent(in), optional, DIMENSION(:) :: blk_ind_3

index along respective dimension of non-zero blocks

integer, intent(in), optional, DIMENSION(:) :: blk_ind_4

index along respective dimension of non-zero blocks

private subroutine enumerate_block_elements(blk_size, blk_offset, tensor_size, blk_2, blk_3, blk_4)

Enumerate tensor entries in block \blk_2 block values for 2 dimensions \blk_3 block values for 3 dimensions

Arguments

Type IntentOptional Attributes Name
integer, intent(in), DIMENSION(:) :: blk_size

size of block block offset (indices of first element) global tensor sizes

integer, intent(in), DIMENSION(:) :: blk_offset

size of block block offset (indices of first element) global tensor sizes

integer, intent(in), DIMENSION(:) :: tensor_size

size of block block offset (indices of first element) global tensor sizes

real(kind=real_8), intent(out), optional, DIMENSION(:,:) :: blk_2
real(kind=real_8), intent(out), optional, DIMENSION(:,:,:) :: blk_3
real(kind=real_8), intent(out), optional, DIMENSION(:,:,:,:) :: blk_4

private subroutine dist_sparse_tensor_to_repl_dense_2d_array_r_dp(tensor, array)

Transform a distributed sparse tensor to a replicated dense array. This is only useful for testing tensor contraction by matrix multiplication of dense arrays.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_t_type), intent(inout) :: tensor
real(kind=real_8), intent(out), ALLOCATABLE, DIMENSION(:,:) :: array

private subroutine dist_sparse_tensor_to_repl_dense_3d_array_r_dp(tensor, array)

Transform a distributed sparse tensor to a replicated dense array. This is only useful for testing tensor contraction by matrix multiplication of dense arrays.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_t_type), intent(inout) :: tensor
real(kind=real_8), intent(out), ALLOCATABLE, DIMENSION(:,:,:) :: array

private subroutine dist_sparse_tensor_to_repl_dense_4d_array_r_dp(tensor, array)

Transform a distributed sparse tensor to a replicated dense array. This is only useful for testing tensor contraction by matrix multiplication of dense arrays.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_t_type), intent(inout) :: tensor
real(kind=real_8), intent(out), ALLOCATABLE, DIMENSION(:,:,:,:) :: array

public subroutine dbcsr_t_contract_test(alpha, tensor_1, tensor_2, beta, tensor_3, contract_1, notcontract_1, contract_2, notcontract_2, map_1, map_2, unit_nr, bounds_1, bounds_2, bounds_3, log_verbose, write_int)

test tensor contraction

Read more…

Arguments

Type IntentOptional Attributes Name
type(dbcsr_scalar_type), intent(in) :: alpha
type(dbcsr_t_type), intent(inout) :: tensor_1
type(dbcsr_t_type), intent(inout) :: tensor_2
type(dbcsr_scalar_type), intent(in) :: beta
type(dbcsr_t_type), intent(inout) :: tensor_3
integer, intent(in), DIMENSION(:) :: contract_1
integer, intent(in), DIMENSION(:) :: notcontract_1
integer, intent(in), DIMENSION(:) :: contract_2
integer, intent(in), DIMENSION(:) :: notcontract_2
integer, intent(in), DIMENSION(:) :: map_1
integer, intent(in), DIMENSION(:) :: map_2
integer, intent(in) :: unit_nr
integer, optional, DIMENSION(2, SIZE(contract_1)) :: bounds_1
integer, optional, DIMENSION(2, SIZE(notcontract_1)) :: bounds_2
integer, optional, DIMENSION(2, SIZE(notcontract_2)) :: bounds_3
logical, intent(in), optional :: log_verbose
logical, intent(in), optional :: write_int

public subroutine dbcsr_t_reset_randmat_seed()

Reset the seed used for generating random matrices to default value

Arguments

None