intel: INTEL_MEASURE cpu mode
INTEL_MEASURE normally measures timing of GPU events. However, it is sometimes useful to instead measure when these gfx API calls were requested of the driver. INTEL_MEASURE cpu can be used in in conjunction with other driver debug capabilities, like INTEL_DEBUG=pc for analyzing stalls/flushes or when debugger is attached, to track which frame you're currently on or where in the frame you're at. Initial commit, without plumbing into anv/iris. "INTEL_MEASURE=cpu" will collect a cpu timestamp for each INTEL_MEASURE event instead of GPU timestamps. Reviewed-by: Mark Janes <markjanes@swizzler.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21505>
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "dev/intel_device_info.h"
|
||||
#include "util/os_time.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/macros.h"
|
||||
|
||||
@@ -97,6 +98,7 @@ intel_measure_init(struct intel_measure_device *device)
|
||||
const char *interval_s = strstr(env_copy, "interval=");
|
||||
const char *batch_size_s = strstr(env_copy, "batch_size=");
|
||||
const char *buffer_size_s = strstr(env_copy, "buffer_size=");
|
||||
const char *cpu_s = strstr(env_copy, "cpu");
|
||||
while (true) {
|
||||
char *sep = strrchr(env_copy, ',');
|
||||
if (sep == NULL)
|
||||
@@ -206,10 +208,19 @@ intel_measure_init(struct intel_measure_device *device)
|
||||
config.buffer_size = buffer_size;
|
||||
}
|
||||
|
||||
fputs("draw_start,draw_end,frame,batch,"
|
||||
"event_index,event_count,type,count,vs,tcs,tes,"
|
||||
"gs,fs,cs,ms,ts,framebuffer,idle_us,time_us\n",
|
||||
config.file);
|
||||
if (cpu_s) {
|
||||
config.cpu_measure = true;
|
||||
}
|
||||
|
||||
if (!config.cpu_measure)
|
||||
fputs("draw_start,draw_end,frame,batch,"
|
||||
"event_index,event_count,type,count,vs,tcs,tes,"
|
||||
"gs,fs,cs,ms,ts,framebuffer,idle_us,time_us\n",
|
||||
config.file);
|
||||
else
|
||||
fputs("draw_start,frame,batch,event_index,event_count,"
|
||||
"type,count\n",
|
||||
config.file);
|
||||
}
|
||||
|
||||
device->config = NULL;
|
||||
@@ -616,6 +627,25 @@ print_combined_results(struct intel_measure_device *measure_device,
|
||||
(double)duration_time_ns / 1000.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data for a cpu event.
|
||||
*/
|
||||
void
|
||||
intel_measure_print_cpu_result(unsigned int frame,
|
||||
unsigned int batch_count,
|
||||
unsigned int event_index,
|
||||
unsigned int event_count,
|
||||
unsigned int count,
|
||||
const char* event_name)
|
||||
{
|
||||
assert(config.cpu_measure);
|
||||
uint64_t start_ns = os_time_get_nano();
|
||||
|
||||
fprintf(config.file, "%"PRIu64",%u,%3u,%3u,%u,%s,%u\n",
|
||||
start_ns, frame, batch_count, event_index, event_count,
|
||||
event_name, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty the ringbuffer of events that can be printed.
|
||||
*/
|
||||
|
||||
@@ -100,6 +100,9 @@ struct intel_measure_config {
|
||||
|
||||
/* true when snapshots are currently being collected */
|
||||
bool enabled;
|
||||
|
||||
/* Measure CPU timing, not GPU timing */
|
||||
bool cpu_measure;
|
||||
};
|
||||
|
||||
struct intel_measure_batch;
|
||||
@@ -164,6 +167,12 @@ void intel_measure_frame_transition(unsigned frame);
|
||||
bool intel_measure_ready(struct intel_measure_batch *batch);
|
||||
|
||||
struct intel_device_info;
|
||||
void intel_measure_print_cpu_result(unsigned int frame,
|
||||
unsigned int batch_count,
|
||||
unsigned int event_index,
|
||||
unsigned int event_count,
|
||||
unsigned int count,
|
||||
const char* event_name);
|
||||
void intel_measure_gather(struct intel_measure_device *device,
|
||||
const struct intel_device_info *info);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user