summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorvenkataram-nv <vedavamadath@nvidia.com>2024-08-13 11:44:19 -0700
committerGitHub <noreply@github.com>2024-08-13 11:44:19 -0700
commitf4ff4236e1eb80a8274b219d6e4c3813c15be9cd (patch)
tree90a5f3db2e0630cda2f5e95d14c0db9cee516233 /source
parentee052a9e9bd7c0d233816556ebe8f0078bd9ec4d (diff)
GitHub action benchmark (#4804)
Adds a new Github CI action for benchmarking the slangc compiler on the MDL shaders. For now, the results are only dumped to the output of the CI, which can be later viewed through raw logs. The next step is to use github-action-benchmark to push these results into a page which will show the benchmark results over time as commits are pushed.
Diffstat (limited to 'source')
-rw-r--r--source/core/slang-performance-profiler.cpp9
-rw-r--r--source/core/slang-performance-profiler.h4
-rw-r--r--source/slang/slang-compiler.cpp2
-rw-r--r--source/slang/slang.cpp12
4 files changed, 22 insertions, 5 deletions
diff --git a/source/core/slang-performance-profiler.cpp b/source/core/slang-performance-profiler.cpp
index b480e1c8e..f08b4998d 100644
--- a/source/core/slang-performance-profiler.cpp
+++ b/source/core/slang-performance-profiler.cpp
@@ -31,11 +31,14 @@ namespace Slang
}
virtual void getResult(StringBuilder& out) override
{
- for (auto func : data)
+ char buffer[512];
+ for (const auto& func : data)
{
- out << func.key << ": \t";
+ memset(buffer, 0, sizeof(buffer));
+ snprintf(buffer, sizeof(buffer), "[*] %30s", func.key);
+ out << buffer << " \t";
auto milliseconds = std::chrono::duration_cast< std::chrono::milliseconds >(func.value.duration);
- out << func.value.invocationCount << "\t" << milliseconds.count() << "ms\n";
+ out << func.value.invocationCount << " \t" << milliseconds.count() << "ms\n";
}
}
virtual void clear() override
diff --git a/source/core/slang-performance-profiler.h b/source/core/slang-performance-profiler.h
index 71b34d262..9895793c4 100644
--- a/source/core/slang-performance-profiler.h
+++ b/source/core/slang-performance-profiler.h
@@ -68,7 +68,9 @@ private:
List<ProfileInfo> m_profilEntries;
};
-#define SLANG_PROFILE PerformanceProfilerFuncRAIIContext _profileContext(__func__)
+#define SLANG_PROFILE PerformanceProfilerFuncRAIIContext _profileContext(__func__)
+#define SLANG_PROFILE_SECTION(s) PerformanceProfilerFuncRAIIContext _profileContext##s(#s)
+
}
#endif
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 1ef17df1d..f5b7ff428 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -3,6 +3,7 @@
#include "../core/slang-basic.h"
#include "../core/slang-platform.h"
#include "../core/slang-io.h"
+#include "../core/slang-performance-profiler.h"
#include "../core/slang-string-util.h"
#include "../core/slang-hex-dump-util.h"
#include "../core/slang-riff.h"
@@ -2297,6 +2298,7 @@ namespace Slang
void EndToEndCompileRequest::generateOutput()
{
+ SLANG_PROFILE;
generateOutput(getSpecializedGlobalAndEntryPointsComponentType());
// If we are in command-line mode, we might be expected to actually
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 9ba02ee50..81171fdcc 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -2742,6 +2742,7 @@ static void _outputIncludes(const List<SourceFile*>& sourceFiles, SourceManager*
void FrontEndCompileRequest::parseTranslationUnit(
TranslationUnitRequest* translationUnit)
{
+ SLANG_PROFILE;
if (translationUnit->isChecked)
return;
@@ -2924,6 +2925,7 @@ void FrontEndCompileRequest::checkAllTranslationUnits()
void FrontEndCompileRequest::generateIR()
{
+ SLANG_PROFILE;
SLANG_AST_BUILDER_RAII(getLinkage()->getASTBuilder());
// Our task in this function is to generate IR code
@@ -3021,6 +3023,7 @@ static SourceLanguage inferSourceLanguage(FrontEndCompileRequest* request)
SlangResult FrontEndCompileRequest::executeActionsInner()
{
+ SLANG_PROFILE_SECTION(frontEndExecute);
SLANG_AST_BUILDER_RAII(getLinkage()->getASTBuilder());
for (TranslationUnitRequest* translationUnit : translationUnits)
@@ -3046,7 +3049,11 @@ SlangResult FrontEndCompileRequest::executeActionsInner()
return SLANG_FAIL;
// Perform semantic checking on the whole collection
- checkAllTranslationUnits();
+ {
+ SLANG_PROFILE_SECTION(SemanticChecking);
+ checkAllTranslationUnits();
+ }
+
if (getSink()->getErrorCount() != 0)
return SLANG_FAIL;
@@ -3172,6 +3179,7 @@ void EndToEndCompileRequest::init()
SlangResult EndToEndCompileRequest::executeActionsInner()
{
+ SLANG_PROFILE_SECTION(endToEndActions);
// If no code-generation target was specified, then try to infer one from the source language,
// just to make sure we can do something reasonable when invoked from the command line.
//
@@ -6303,6 +6311,7 @@ SlangResult EndToEndCompileRequest::compile()
if (getOptionSet().getBoolOption(CompilerOptionName::ReportDownstreamTime))
{
getSession()->getCompilerElapsedTime(&totalStartTime, &downstreamStartTime);
+ PerformanceProfiler::getProfiler()->clear();
}
#if !defined(SLANG_DEBUG_INTERNAL_ERROR)
// By default we'd like to catch as many internal errors as possible,
@@ -6317,6 +6326,7 @@ SlangResult EndToEndCompileRequest::compile()
try
{
+ SLANG_PROFILE_SECTION(compileInner);
res = executeActions();
}
catch (const AbortCompilationException& e)