warp icon indicating copy to clipboard operation
warp copied to clipboard

[REQ] Force specific loops to remain unrolled

Open lmtss opened this issue 11 months ago • 2 comments

Description

Force specific loops to remain unrolled, similar to HLSL's [loop].

Context

I am developing iterative algorithms that typically require over 20 iterations, a number determined empirically and not intended for dynamic configuration. However, since this iteration count is treated as a compile-time constant, the loops are fully unrolled by the compiler. This results in excessive code expansion and significantly prolonged compilation times.

lmtss avatar Dec 24 '25 15:12 lmtss

Hi @lmtss, can you provide some more details about the problem being encountered? Based on the request, you probably know about the max_unroll parameter, which can either be set globally or on a per-module basis. Is this setting working correctly?

Or does your loop made use of wp.static() and you're running into the restriction where loops containing wp.static() expressions are forced to be unrolled? (set wp.config.verbose = True to verify). Some code to look at would be helpful, thanks.

shi-eric avatar Jan 02 '26 15:01 shi-eric

Hi @lmtss, can you provide some more details about the problem being encountered? Based on the request, you probably know about the max_unroll parameter, which can either be set globally or on a per-module basis. Is this setting working correctly?

Or does your loop made use of wp.static() and you're running into the restriction where loops containing wp.static() expressions are forced to be unrolled? (set wp.config.verbose = True to verify). Some code to look at would be helpful, thanks.

  • Admittedly, while I was aware of the max_unroll parameter, I didn’t realize it could be set per module. That might indeed solve my problem. Thanks for your response.
  • I’ve been checking the generated PTX to determine whether loops are unrolled, though it’s possible that my interpretation of the code was incorrect — I’ll look into this more carefully. I will try to reproduce the issue in a simpler case.

lmtss avatar Jan 02 '26 16:01 lmtss