summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-cpp.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-09-18 11:40:59 -0400
committerGitHub <noreply@github.com>2019-09-18 11:40:59 -0400
commit31c7abcc27a33d63ac8d335387a0ce7b3ad74954 (patch)
tree3b4254df7bdbf8b497aa8a3e5f08f8927c1afbc6 /source/slang/slang-emit-cpp.cpp
parent3af404da7f7f125464b78159940cb3fc06e69cc5 (diff)
Improvements to testing and ABI for CPU (#1057)
* WIP: Improving CPU performance/ABI * Optionally output code on CPU for groupThreadID and groupID. * Added ability to set compute dispatch size on command line for render-test. Dispatch compute tests taking into account dispatch size. Added test for semantics are working. * Test using GroupRange. * Fix problem with adding \n for externa diagnostic - to do it if there isn't a \n at the end. Change the ouput order (put result before) so last value is diagnostic string. * Made GroupRange the default exposed CPU ABI entry point style. Removed CPU_EXECUTE test style -as tested via the now cross platform render-test * Split out execution from setup for execution to improve perf. * For better code coverage/testing test all styles of CPU compute entry point. * Improve documentation for ABI changes for CPU code. Add 'expecting' to error message from review. * Fix small typos.
Diffstat (limited to 'source/slang/slang-emit-cpp.cpp')
-rw-r--r--source/slang/slang-emit-cpp.cpp38
1 files changed, 12 insertions, 26 deletions
diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp
index 1a6a46fc5..8f3e2f2e5 100644
--- a/source/slang/slang-emit-cpp.cpp
+++ b/source/slang/slang-emit-cpp.cpp
@@ -2830,8 +2830,13 @@ void CPPSourceEmitter::emitModuleImpl(IRModule* module)
String funcName = getFuncName(func);
- {
- _emitEntryPointDefinitionStart(func, entryPointGlobalParams, funcName, UnownedStringSlice::fromLiteral("ComputeVaryingInput"));
+ {
+ StringBuilder builder;
+ builder << funcName << "_Thread";
+
+ String threadFuncName = builder;
+
+ _emitEntryPointDefinitionStart(func, entryPointGlobalParams, threadFuncName, UnownedStringSlice::fromLiteral("ComputeThreadVaryingInput"));
if (m_semanticUsedFlags & SemanticUsedFlag::GroupThreadID)
{
@@ -2854,7 +2859,7 @@ void CPPSourceEmitter::emitModuleImpl(IRModule* module)
_emitEntryPointDefinitionEnd(func);
}
- // Emit the group version which runs for all elements in a thread group
+ // Emit the group version which runs for all elements in *single* thread group
{
StringBuilder builder;
builder << getFuncName(func);
@@ -2865,7 +2870,7 @@ void CPPSourceEmitter::emitModuleImpl(IRModule* module)
_emitEntryPointDefinitionStart(func, entryPointGlobalParams, groupFuncName, UnownedStringSlice::fromLiteral("ComputeVaryingInput"));
m_writer->emit("const uint3 start = ");
- _emitInitAxisValues(sizeAlongAxis, UnownedStringSlice::fromLiteral("varyingInput->groupID"), UnownedStringSlice());
+ _emitInitAxisValues(sizeAlongAxis, UnownedStringSlice::fromLiteral("varyingInput->startGroupID"), UnownedStringSlice());
if (m_semanticUsedFlags & SemanticUsedFlag::GroupThreadID)
{
@@ -2874,7 +2879,7 @@ void CPPSourceEmitter::emitModuleImpl(IRModule* module)
if (m_semanticUsedFlags & SemanticUsedFlag::GroupID)
{
- m_writer->emit("context.groupID = varyingInput->groupID;\n");
+ m_writer->emit("context.groupID = varyingInput->startGroupID;\n");
}
m_writer->emit("context.dispatchThreadID = start;\n");
@@ -2882,34 +2887,15 @@ void CPPSourceEmitter::emitModuleImpl(IRModule* module)
_emitEntryPointDefinitionEnd(func);
}
- // Emit the group version which runs for all elements in a thread group
+ // Emit the main version - which takes a dispatch size
{
- StringBuilder builder;
- builder << getFuncName(func);
- builder << "_GroupRange";
-
- String groupRangeFuncName = builder;
-
- _emitEntryPointDefinitionStart(func, entryPointGlobalParams, groupRangeFuncName, UnownedStringSlice::fromLiteral("GroupComputeVaryingInput"));
+ _emitEntryPointDefinitionStart(func, entryPointGlobalParams, funcName, UnownedStringSlice::fromLiteral("ComputeVaryingInput"));
m_writer->emit("const uint3 start = ");
_emitInitAxisValues(sizeAlongAxis, UnownedStringSlice::fromLiteral("varyingInput->startGroupID"), UnownedStringSlice());
m_writer->emit("const uint3 end = ");
_emitInitAxisValues(sizeAlongAxis, UnownedStringSlice::fromLiteral("varyingInput->endGroupID"), UnownedStringSlice());
-#if 0
- // Not needed as will be emitted as part of the loop
- m_writer->emit("context.dispatchThreadID = start;\n");
- if (m_semanticUsedFlags & SemanticUsedFlag::GroupThreadID)
- {
- m_writer->emit("context.groupDispatchThreadID = start;");
- }
- if (m_semanticUsedFlags & SemanticUsedFlag::GroupID)
- {
- m_writer->emit("context.groupID = varyingInput->startGroupID;\n");
- }
-#endif
-
_emitEntryPointGroupRange(sizeAlongAxis, funcName);
_emitEntryPointDefinitionEnd(func);
}