[REQ] Force specific loops to remain unrolled
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.
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.
Hi @lmtss, can you provide some more details about the problem being encountered? Based on the request, you probably know about the
max_unrollparameter, 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 containingwp.static()expressions are forced to be unrolled? (setwp.config.verbose = Trueto 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.