Skip to content

Commit

Permalink
i915-perf: set a different default colors to GPU timeline events
Browse files Browse the repository at this point in the history
By default we're currently using the same color for all GPU timeline
events. But some i915 driver versions don't have tracepoint support to
build correlation back to the process that submitted the work, so that
we can use the process' color.

So just assign a default color so that we can at least tell items
apart on the timeline.
  • Loading branch information
llandwerlin-intel authored and mikesart committed Jan 8, 2021
1 parent a84bd85 commit edf388d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
25 changes: 24 additions & 1 deletion src/gpuvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2162,13 +2162,36 @@ void TraceEvents::init_i915_perf_event( trace_event_t &event )

void TraceEvents::update_i915_perf_colors()
{
// The pid field of i915-perf events is the GPU context ID. Assign each of
// them a color in case we can't find a process related to them.
std::unordered_set< int > all_gpu_contexts;
for ( const uint32_t event_id : m_i915.perf_locs )
{
const trace_event_t &i915_perf_event = m_events[ event_id ];

if ( all_gpu_contexts.find( i915_perf_event.pid ) == all_gpu_contexts.end() )
all_gpu_contexts.insert( i915_perf_event.pid );
}

uint32_t idx = 0;
std::map< int, uint32_t > gpu_context_to_color;
for ( auto context_id : all_gpu_contexts )
{
ImVec4 color( 0.0f, 0.0f, 0.0f, 1.0f );
ImGui::ColorConvertHSVtoRGB( (float) idx++ / all_gpu_contexts.size(), 1.0, 0.5,
color.x, color.y, color.z );
gpu_context_to_color.insert( std::make_pair( context_id, ImGui::ColorConvertFloat4ToU32( color ) ) );
}

// Go through all i915-perf events and assign the color of the process
// that submitted the workload to the GPU timeline event.
for ( const uint32_t event_id : m_i915.perf_locs )
{
trace_event_t &i915_perf_event = m_events[ event_id ];

if ( m_i915.perf_to_req_in.m_map.find( i915_perf_event.id ) == m_i915.perf_to_req_in.m_map.end() )
{
i915_perf_event.color = s_clrs().get( col_Graph_Bari915Execute );
i915_perf_event.color = gpu_context_to_color[ i915_perf_event.pid ];
}
else
{
Expand Down
1 change: 0 additions & 1 deletion src/gpuvis_colors.inl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ _XTAG( col_Graph_TaskRunning, 0x4fff00ff, "Sched_switch task running block" )
_XTAG( col_Graph_TaskSleeping, 0x4fffff00, "Sched_switch task sleeping block" )

_XTAG( col_Graph_Bari915ReqWait, 0x4f0000ff, "i915 reqwait bar" )
_XTAG( col_Graph_i915Perf, 0xff9b9400, "i915-perf bar" )

_XTAG( col_Graph_Bari915Queue, 0xc81d740c, "Request queued waiting to be added" )
_XTAG( col_Graph_Bari915SubmitDelay, 0xc8f8552e, "Requests waiting on fences and dependencies before they are runnable" )
Expand Down
2 changes: 1 addition & 1 deletion src/gpuvis_i915_perfcounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ I915PerfCounters::get_process( const trace_event_t &i915_perf_event )
{
i915_perf_process process;
process.label = "<unknown>";
process.color = s_clrs().get( col_Graph_i915Perf );
process.color = i915_perf_event.color;

uint32_t *req_event_id = m_trace_events->m_i915.perf_to_req_in.get_val( i915_perf_event.id );

Expand Down

0 comments on commit edf388d

Please sign in to comment.