Scheduling

FPy’s scheduling language allows users to transform FPy functions using various small and reusable strategies. These strategies can be combined to create more complex transformations.

The available strategies are found in the fpy2.strategies module:

fpy2.strategies.simplify(func: Function, *, enable_const_fold: bool = True, enable_const_prop: bool = True, enable_copy_prop: bool = True, enable_dead_code_elim: bool = True) Function

Applies simplifying transformations to the function:

  • constant folding

  • constant propagation

  • copy propagation

  • dead code elimination

fpy2.strategies.split(func: Function, factor: int | str, where: int | None = None, *, strategy: SplitLoopStrategy = SplitLoopStrategy.STRICT, temp_id: str = 't', outer_id: str = 'i', inner_id: str = 'i')
fpy2.strategies.unroll_for(func: Function, where: int | None = None, times: int = 1, *, strategy: ForUnrollStrategy = ForUnrollStrategy.STRICT, temp_id: str = 't', len_id: str = 'n', idx_id: str = 'i') Function

Unroll for loops in the function.

Parameters:
  • where (int | None) – The index of the for loop to unroll. If None, unroll all for loops.

  • times (int) – The number of times to unroll the loop.

fpy2.strategies.unroll_while(func: Function, where: int | None = None, times: int = 1) Function

Unroll while loops in the function.

Parameters:
  • func (Function) – The function to transform.

  • where (int | None) – The index of the while loop to unroll. If None, unroll all while loops.

  • times (int) – The number of times to unroll the loop.

Returns:

The transformed function.

Return type:

Function