remove blocking collect

This commit is contained in:
Cloud Han 2022-01-28 11:55:42 +08:00
parent f6769ecb91
commit c9fb07ffe5
2 changed files with 5 additions and 12 deletions

View File

@ -21,7 +21,6 @@
#define TracyCLZoneSetEvent(e) #define TracyCLZoneSetEvent(e)
#define TracyCLCollect(c) #define TracyCLCollect(c)
#define TracyCLBlockingCollect(c)
namespace tracy namespace tracy
{ {
@ -136,7 +135,7 @@ namespace tracy {
Profiler::QueueSerialFinish(); Profiler::QueueSerialFinish();
} }
void Collect(bool blocking) void Collect()
{ {
ZoneScopedC(Color::Red4); ZoneScopedC(Color::Red4);
@ -166,12 +165,7 @@ namespace tracy {
assert(false && "clGetEventInfo failed, maybe a TracyCLZone is not paired with TracyCLZoneSetEvent"); assert(false && "clGetEventInfo failed, maybe a TracyCLZone is not paired with TracyCLZoneSetEvent");
continue; continue;
} }
if (eventStatus != CL_COMPLETE) if (eventStatus != CL_COMPLETE) return;
{
if (!blocking)
return;
TRACY_CL_CHECK_ERROR(clWaitForEvents(1, &eventInfo.event));
}
cl_int eventInfoQuery = (eventInfo.phase == EventPhase::Begin) cl_int eventInfoQuery = (eventInfo.phase == EventPhase::Begin)
? CL_PROFILING_COMMAND_START ? CL_PROFILING_COMMAND_START
@ -359,8 +353,7 @@ using TracyCLCtx = tracy::OpenCLCtx*;
#define TracyCLNamedZoneSetEvent(varname, event) varname.SetEvent(event) #define TracyCLNamedZoneSetEvent(varname, event) varname.SetEvent(event)
#define TracyCLZoneSetEvent(event) __tracy_gpu_zone.SetEvent(event) #define TracyCLZoneSetEvent(event) __tracy_gpu_zone.SetEvent(event)
#define TracyCLCollect(ctx) ctx->Collect(/*blocking=*/false) #define TracyCLCollect(ctx) ctx->Collect()
#define TracyCLBlockingCollect(ctx) ctx->Collect(/*blocking=*/true)
#endif #endif

View File

@ -200,8 +200,8 @@ int main()
}) / (durations.size() - 1.0f); }) / (durations.size() - 1.0f);
std::cout << "VectorAdd runtime avg: " << avg << "us, std: " << sqrt(stddev2) << "us over " << numLaunchs << " runs." << std::endl; std::cout << "VectorAdd runtime avg: " << avg << "us, std: " << sqrt(stddev2) << "us over " << numLaunchs << " runs." << std::endl;
// Use blocking collect will ensure all queued events is finished // User should ensure all events are finished, in this case, collect after the clFinish will do the trick.
TracyCLBlockingCollect(tracyCLCtx); TracyCLCollect(tracyCLCtx);
{ {
ZoneScopedN("Checking results"); ZoneScopedN("Checking results");