# loki.transformations.loop_blocking

Functions

`block_loop_arrays`(routine, splitting_vars, ...) | Replaces arrays inside the inner loop with blocked counterparts.
`blocked_shape`(a, blocking_indices, block_size) | calculates the dimensions for a blocked version of the array.
`blocked_type`(a) |
`replace_indices`(dimensions, indices, ...) | Returns a new dimension object with all occurences of indices changed to replacement_index.
`split_loop`(routine, loop, block_size) | Blocks a loop by splitting it into an outer loop and inner loop of size block_size.

Classes

`LoopSplittingVariables`(loop_var, block_size) | This class holds the loop splitting variables, e.g. outer loop block sizes and iteration bounds.

split_loop(routine: Subroutine, loop: Loop, block_size: int)

  Blocks a loop by splitting it into an outer loop and inner loop of size block_size.

  Parameters:

    - routine (`Subroutine`) – Subroutine object containing the loop. New variables introduced in the loop splitting will be declared in the body of routine.

    - loop (`Loop`) – Loop to be split.

    - block_size (int) – inner loop size (size of blocking blocks)

block_loop_arrays(routine: Subroutine, splitting_vars, inner_loop: Loop, outer_loop: Loop, blocking_indices)

  Replaces arrays inside the inner loop with blocked counterparts.

  This routine declares array variables to hold the blocks of the arrays used inside the loop and replaces array variables inside the loop with their blocked counterparts. An array is blocked with the leading dimensions

  Parameters:

    - routine (Subroutine) – routine in which the blocking variables should be added.

    - blocking_indices (tuple or list of str) – list of the index variables that arrays inside the loop should be blocked by.

    - inner_loop (`Loop`) – inner loop after loop splitting

    - outer_loop (`Loop`) – outer loop body after loop splitting

    - blocking_indices –

      Variable names of the indexes that should be blocked if in array

        expressions.