diff options
| author | Dietrich Geisler <dag368@cornell.edu> | 2020-08-12 13:39:08 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-12 10:39:08 -0700 |
| commit | e1ea7ed2f9b8cfcf19258a05d270de4db03fec22 (patch) | |
| tree | da87da6f4dd8adb39a44b0bfae342ed1dba04b58 /examples | |
| parent | 12b0fc64103c63c33daaedf8a8c2ee05de35dcc5 (diff) | |
GPU Foreach Parsing and Checking (#1482)
This PR introduces parsing and semantic checking for a GPU foreach loop
for heterogeneouis programming. A GPU foreach loop takes the form:
```
__GPU_FOREACH(renderer, gridDims, LAMBDA(uint3 dispatchThreadID) {
kernelCall(args, ...); });
```
And will allow the host code to call into a kernel with the correct
renderer and grid dimensions. This commit also introduces a hack to
unify types in the heterogeneous hello world file, which will hopefully
be amended in the future.
Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/heterogeneous-hello-world/main.cpp | 2 | ||||
| -rw-r--r-- | examples/heterogeneous-hello-world/shader.slang | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/examples/heterogeneous-hello-world/main.cpp b/examples/heterogeneous-hello-world/main.cpp index 47df20dc5..6bb1bc071 100644 --- a/examples/heterogeneous-hello-world/main.cpp +++ b/examples/heterogeneous-hello-world/main.cpp @@ -35,7 +35,7 @@ #include "gfx/render.h" #include "gfx/d3d11/render-d3d11.h" #include "gfx/window.h" -#include "../../prelude/slang-cpp-types.h"; +#include "../../prelude/slang-cpp-types.h" using namespace gfx; // We create global ref pointers to avoid dereferencing values diff --git a/examples/heterogeneous-hello-world/shader.slang b/examples/heterogeneous-hello-world/shader.slang index a9ad66cc7..6b56c8700 100644 --- a/examples/heterogeneous-hello-world/shader.slang +++ b/examples/heterogeneous-hello-world/shader.slang @@ -1,10 +1,10 @@ // shader.slang //TEST_INPUT:ubuffer(random(float, 4096, -1.0, 1.0), stride=4):name=ioBuffer -RWStructuredBuffer<float> ioBuffer; +RWStructuredBuffer<float> convertBuffer(Ptr<gfx::BufferResource> x); [numthreads(4, 1, 1)] -void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +void computeMain(uniform RWStructuredBuffer<float> ioBuffer, uint3 dispatchThreadID : SV_DispatchThreadID) { uint tid = dispatchThreadID.x; @@ -69,6 +69,8 @@ public bool executeComputation() { let window = createWindow(windowWidth, windowHeight); let renderer = createRenderer(windowWidth, windowHeight, window); let structuredBuffer = createStructuredBuffer(renderer, initialArray); + __GPU_FOREACH(renderer, uint3(4, 1, 1), LAMBDA(uint3 dispatchThreadID) + { computeMain(convertBuffer(structuredBuffer), dispatchThreadID) ; }); let shaderProgram = loadShaderProgram(renderer); let descriptorSetLayout = buildDescriptorSetLayout(renderer); let pipelineLayout = buildPipeline(renderer, descriptorSetLayout); |
