# dbcsr_t_batched_contract_init Subroutine

## public subroutine dbcsr_t_batched_contract_init(tensor, batch_range_1, batch_range_2, batch_range_3, batch_range_4)

Initialize batched contraction for this tensor.

Explanation: A batched contraction is a contraction performed in several consecutive steps by specification of bounds in dbcsr_t_contract. This can be used to reduce memory by a large factor. The routines dbcsr_t_batched_contract_init and dbcsr_t_batched_contract_finalize should be called to define the scope of a batched contraction as this enables important optimizations (adapting communication scheme to batches and adapting process grid to multiplication algorithm). The routines dbcsr_t_batched_contract_init and dbcsr_t_batched_contract_finalize must be called before the first and after the last contraction step on all 3 tensors.

Requirements: - the tensors are in a compatible matrix layout (see documentation of dbcsr_t_contract, note 2 & 3). If they are not, process grid optimizations are disabled and a warning is issued. - within the scope of a batched contraction, it is not allowed to access or change tensor data except by calling the routines dbcsr_t_contract & dbcsr_t_copy. - the bounds affecting indices of the smallest tensor must not change in the course of a batched contraction (todo: get rid of this requirement).

Side effects: - the parallel layout (process grid and distribution) of all tensors may change. In order to disable the process grid optimization including this side effect, call this routine only on the smallest of the 3 tensors.

### Arguments

Type IntentOptional Attributes Name
type(dbcsr_t_type), intent(inout) :: tensor
integer, intent(in), optional, DIMENSION(:) :: batch_range_1

For internal load balancing optimizations, optionally specify the index ranges of batched contraction. batch_range_i refers to the ith tensor dimension and contains all block indices starting a new range. The size should be the number of ranges plus one, the last element being the block index plus one of the last block in the last range.

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

For internal load balancing optimizations, optionally specify the index ranges of batched contraction. batch_range_i refers to the ith tensor dimension and contains all block indices starting a new range. The size should be the number of ranges plus one, the last element being the block index plus one of the last block in the last range.

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

For internal load balancing optimizations, optionally specify the index ranges of batched contraction. batch_range_i refers to the ith tensor dimension and contains all block indices starting a new range. The size should be the number of ranges plus one, the last element being the block index plus one of the last block in the last range.

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

For internal load balancing optimizations, optionally specify the index ranges of batched contraction. batch_range_i refers to the ith tensor dimension and contains all block indices starting a new range. The size should be the number of ranges plus one, the last element being the block index plus one of the last block in the last range.