loki.transformations.loop_blocking module

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)

split_loop_region(routine: Subroutine, loop: Loop, block_size: int, data_region)

Blocks a loop inside a data region and puts the data region inside the outer loop.

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)

  • data_region (PragmaRegion,) – data region containing the loop to be blocked

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.