From bacf73cc68af8b7654cc920b07635f926b785b84 Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Tue, 4 Jun 2024 18:24:12 -0700 Subject: Add APIs to get profile of compile time (#4242) * Add APIs to get profile of compile time Add serial time measurement Add profiler to measure lots of stages in slang compilation, and it can accumulate the time spent in each thread in multi-threads case and finally report a serial timing info. * Add invocation times to the profiler * Simplify the profiler and provide a 'clear' option Change the profiler design to only return the thread_local profiler to user. We create a ISlangProfiler interface to carry the thread_local variable PerformanceProfilerImpl profiler to user. In addition, we provide a new option in the input parameter to control whether or not user want to clear the previous profile data. So spGetCompileProfile() can always returns a fresh new profiling data. * Change to use slang container List Stop using std::vector, instead use slang's container List. Generate a UUID for ISlangProfiler --- source/slang/slang.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 66e75a282..f820bf8cd 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -6245,6 +6245,25 @@ void const* EndToEndCompileRequest::getEntryPointCode(int entryPointIndex, size_ return (void*)blob->getBufferPointer(); } +SlangResult EndToEndCompileRequest::getCompileTimeProfile(ISlangProfiler** compileTimeProfile, bool shouldClear) +{ + if (compileTimeProfile == nullptr) + { + return SLANG_E_INVALID_ARG; + } + + SlangProfiler* profiler = new SlangProfiler(PerformanceProfiler::getProfiler()); + + if (shouldClear) + { + PerformanceProfiler::getProfiler()->clear(); + } + + ComPtr result(profiler); + *compileTimeProfile = result.detach(); + return SLANG_OK; +} + static SlangResult _getEntryPointResult( EndToEndCompileRequest* req, int entryPointIndex, -- cgit v1.2.3