Skip to content

Loop unrolling hints #12

@tetsuo-cpp

Description

@tetsuo-cpp

Summary

Add pragma-style annotations for loop unrolling to enable compiler-driven performance optimization.

Motivation

Inner loops in GPU kernels (especially the K-dimension loop in matmul) benefit significantly from unrolling. The compiler can sometimes unroll automatically, but explicit hints give more control.

Design considerations

Possible syntax approaches:

\ Attribute-style before loop
#UNROLL 4
DO ... LOOP

\ Or a dedicated word
4 UNROLL-DO ... LOOP

Implementation notes

  • Could map to LLVM loop metadata (llvm.loop.unroll.count)
  • Or use MLIR's affine.for with unroll attributes
  • Need to decide if this is a parser-level annotation or a runtime construct
  • Should support both full unroll and partial unroll (by factor)

Priority

Nice to have — performance optimization for inner loops.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions