From b3e6f1b2cffa8def593e97a00576eeba0f947ebc Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 25 Mar 2020 16:45:56 -0400 Subject: Unroll target improvements (#1291) * Add unroll support for CUDA, and preliminary for C++. Document [unroll] support. * Fix loop-unroll to run on CPU, and test on CPU and elsewhere. Fix bug in emitting loop unroll condition. * Improved comment. * Added support for vk/glsl loop unrolling. --- docs/target-compatibility.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'docs/target-compatibility.md') diff --git a/docs/target-compatibility.md b/docs/target-compatibility.md index 64695c09c..e8edeeaf5 100644 --- a/docs/target-compatibility.md +++ b/docs/target-compatibility.md @@ -34,6 +34,7 @@ Items with ^ means there is some discussion about support later in the document | tex.Load | Yes | Yes | Yes | Limited ^ | Yes | Full bool | Yes | Yes | Yes | No | Yes ^ | Mesh Shader | No | No + | No + | No | No +| `[unroll]` | Yes | Yes | Yes ^ | Yes | Limited + ## Half Type @@ -114,3 +115,14 @@ tex.Load is only supported on CUDA for Texture1D. Additionally CUDA only allows Means fully featured bool support. CUDA has issues around bool because there isn't a vector bool type built in. Currently bool aliases to an int vector type. On CPU there are some issues in so far as bool's size is not well defined in size an alignment. Most C++ compilers now use a byte to represent a bool. In the past it has been backed by an int on some compilers. + +## `[unroll]` + +The unroll attribute allows for unrolling `for` loops. At the moment the feature is dependent on downstream compiler support which is mixed. In the longer term the intention is for Slang to contain it's own loop unroller - and therefore not be dependent on the feature on downstream compilers. + +On C++ this attribute becomes SLANG_UNROLL which is defined in the prelude. This can be predefined if there is a suitable mechanism, if there isn't a definition SLANG_UNROLL will be an empty definition. + +On GLSL and VK targets loop unrolling uses the [GL_EXT_control_flow_attributes](https://github.com/KhronosGroup/GLSL/blob/master/extensions/ext/GL_EXT_control_flow_attributes.txt) extension. + +Slang does have a cross target mechanism to [unroll loops](language-reference/06-statements.md), in the section `Compile-Time For Statement`. + -- cgit v1.2.3