2 * Copyright © 2020 Valve Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 #include "radv_private.h"
28 #include "util/u_process.h"
30 #include <amdgpu_drm.h>
32 #define SQTT_FILE_MAGIC_NUMBER 0x50303042
33 #define SQTT_FILE_VERSION_MAJOR 1
34 #define SQTT_FILE_VERSION_MINOR 4
36 #define SQTT_GPU_NAME_MAX_SIZE 256
37 #define SQTT_MAX_NUM_SE 32
38 #define SQTT_SA_PER_SE 2
41 SQTT_VERSION_NONE
= 0x0,
42 SQTT_VERSION_1_0
= 0x1,
43 SQTT_VERSION_1_1
= 0x2,
44 SQTT_VERSION_2_0
= 0x3, /* GFX6 */
45 SQTT_VERSION_2_1
= 0x4, /* GFX7 */
46 SQTT_VERSION_2_2
= 0x5, /* GFX8 */
47 SQTT_VERSION_2_3
= 0x6, /* GFX9 */
48 SQTT_VERSION_2_4
= 0x7 /* GFX10 */
54 enum sqtt_file_chunk_type
{
55 SQTT_FILE_CHUNK_TYPE_ASIC_INFO
,
56 SQTT_FILE_CHUNK_TYPE_SQTT_DESC
,
57 SQTT_FILE_CHUNK_TYPE_SQTT_DATA
,
58 SQTT_FILE_CHUNK_TYPE_API_INFO
,
59 SQTT_FILE_CHUNK_TYPE_ISA_DATABASE
,
60 SQTT_FILE_CHUNK_TYPE_QUEUE_EVENT_TIMINGS
,
61 SQTT_FILE_CHUNK_TYPE_CLOCK_CALIBRATION
,
62 SQTT_FILE_CHUNK_TYPE_CPU_INFO
,
63 SQTT_FILE_CHUNK_TYPE_SPM_DB
,
64 SQTT_FILE_CHUNK_TYPE_CODE_OBJECT_DATABASE
,
65 SQTT_FILE_CHUNK_TYPE_CODE_OBJECT_LOADER_EVENTS
,
66 SQTT_FILE_CHUNK_TYPE_PSO_CORRELATION
,
67 SQTT_FILE_CHUNK_TYPE_INSTRUMENTATION_TABLE
,
68 SQTT_FILE_CHUNK_TYPE_COUNT
71 struct sqtt_file_chunk_id
{
72 enum sqtt_file_chunk_type type
: 8;
74 int32_t reserved
: 16;
77 struct sqtt_file_chunk_header
{
78 struct sqtt_file_chunk_id chunk_id
;
79 uint16_t minor_version
;
80 uint16_t major_version
;
81 int32_t size_in_bytes
;
88 struct sqtt_file_header_flags
{
91 int32_t is_semaphore_queue_timing_etw
: 1;
92 int32_t no_queue_semaphore_timestamps
: 1;
93 int32_t reserved
: 30;
100 struct sqtt_file_header
{
101 uint32_t magic_number
;
102 uint32_t version_major
;
103 uint32_t version_minor
;
104 struct sqtt_file_header_flags flags
;
105 int32_t chunk_offset
;
109 int32_t day_in_month
;
114 int32_t is_daylight_savings
;
117 static_assert(sizeof(struct sqtt_file_header
) == 56,
118 "sqtt_file_header doesn't match RGP spec");
121 radv_sqtt_fill_header(struct sqtt_file_header
*header
)
123 struct tm
*timep
, result
;
126 header
->magic_number
= SQTT_FILE_MAGIC_NUMBER
;
127 header
->version_major
= SQTT_FILE_VERSION_MAJOR
;
128 header
->version_minor
= SQTT_FILE_VERSION_MINOR
;
129 header
->flags
.value
= 0;
130 header
->flags
.is_semaphore_queue_timing_etw
= 1;
131 header
->flags
.no_queue_semaphore_timestamps
= 0;
132 header
->chunk_offset
= sizeof(*header
);
135 timep
= localtime_r(&raw_time
, &result
);
137 header
->second
= timep
->tm_sec
;
138 header
->minute
= timep
->tm_min
;
139 header
->hour
= timep
->tm_hour
;
140 header
->day_in_month
= timep
->tm_mday
;
141 header
->month
= timep
->tm_mon
;
142 header
->year
= timep
->tm_year
;
143 header
->day_in_week
= timep
->tm_wday
;
144 header
->day_in_year
= timep
->tm_yday
;
145 header
->is_daylight_savings
= timep
->tm_isdst
;
151 struct sqtt_file_chunk_cpu_info
{
152 struct sqtt_file_chunk_header header
;
153 uint32_t vendor_id
[4];
154 uint32_t processor_brand
[12];
155 uint32_t reserved
[2];
156 uint64_t cpu_timestamp_freq
;
157 uint32_t clock_speed
;
158 uint32_t num_logical_cores
;
159 uint32_t num_physical_cores
;
160 uint32_t system_ram_size
;
163 static_assert(sizeof(struct sqtt_file_chunk_cpu_info
) == 112,
164 "sqtt_file_chunk_cpu_info doesn't match RGP spec");
167 radv_sqtt_fill_cpu_info(struct sqtt_file_chunk_cpu_info
*chunk
)
169 chunk
->header
.chunk_id
.type
= SQTT_FILE_CHUNK_TYPE_CPU_INFO
;
170 chunk
->header
.chunk_id
.index
= 0;
171 chunk
->header
.major_version
= 0;
172 chunk
->header
.minor_version
= 0;
173 chunk
->header
.size_in_bytes
= sizeof(*chunk
);
175 chunk
->cpu_timestamp_freq
= 1000000000; /* tick set to 1ns */
177 /* TODO: fill with real info. */
179 strncpy((char *)chunk
->vendor_id
, "Unknown", sizeof(chunk
->vendor_id
));
180 strncpy((char *)chunk
->processor_brand
, "Unknown", sizeof(chunk
->processor_brand
));
181 chunk
->clock_speed
= 0;
182 chunk
->num_logical_cores
= 0;
183 chunk
->num_physical_cores
= 0;
184 chunk
->system_ram_size
= 0;
190 enum sqtt_file_chunk_asic_info_flags
192 SQTT_FILE_CHUNK_ASIC_INFO_FLAG_SC_PACKER_NUMBERING
= (1 << 0),
193 SQTT_FILE_CHUNK_ASIC_INFO_FLAG_PS1_EVENT_TOKENS_ENABLED
= (1 << 1)
197 SQTT_GPU_TYPE_UNKNOWN
= 0x0,
198 SQTT_GPU_TYPE_INTEGRATED
= 0x1,
199 SQTT_GPU_TYPE_DISCRETE
= 0x2,
200 SQTT_GPU_TYPE_VIRTUAL
= 0x3
203 enum sqtt_gfxip_level
{
204 SQTT_GFXIP_LEVEL_NONE
= 0x0,
205 SQTT_GFXIP_LEVEL_GFXIP_6
= 0x1,
206 SQTT_GFXIP_LEVEL_GFXIP_7
= 0x2,
207 SQTT_GFXIP_LEVEL_GFXIP_8
= 0x3,
208 SQTT_GFXIP_LEVEL_GFXIP_8_1
= 0x4,
209 SQTT_GFXIP_LEVEL_GFXIP_9
= 0x5,
210 SQTT_GFXIP_LEVEL_GFXIP_10_1
= 0x7,
213 enum sqtt_memory_type
{
214 SQTT_MEMORY_TYPE_UNKNOWN
= 0x0,
215 SQTT_MEMORY_TYPE_DDR
= 0x1,
216 SQTT_MEMORY_TYPE_DDR2
= 0x2,
217 SQTT_MEMORY_TYPE_DDR3
= 0x3,
218 SQTT_MEMORY_TYPE_DDR4
= 0x4,
219 SQTT_MEMORY_TYPE_GDDR3
= 0x10,
220 SQTT_MEMORY_TYPE_GDDR4
= 0x11,
221 SQTT_MEMORY_TYPE_GDDR5
= 0x12,
222 SQTT_MEMORY_TYPE_GDDR6
= 0x13,
223 SQTT_MEMORY_TYPE_HBM
= 0x20,
224 SQTT_MEMORY_TYPE_HBM2
= 0x21,
225 SQTT_MEMORY_TYPE_HBM3
= 0x22,
228 struct sqtt_file_chunk_asic_info
{
229 struct sqtt_file_chunk_header header
;
231 uint64_t trace_shader_core_clock
;
232 uint64_t trace_memory_clock
;
234 int32_t device_revision_id
;
235 int32_t vgprs_per_simd
;
236 int32_t sgprs_per_simd
;
237 int32_t shader_engines
;
238 int32_t compute_unit_per_shader_engine
;
239 int32_t simd_per_compute_unit
;
240 int32_t wavefronts_per_simd
;
241 int32_t minimum_vgpr_alloc
;
242 int32_t vgpr_alloc_granularity
;
243 int32_t minimum_sgpr_alloc
;
244 int32_t sgpr_alloc_granularity
;
245 int32_t hardware_contexts
;
246 enum sqtt_gpu_type gpu_type
;
247 enum sqtt_gfxip_level gfxip_level
;
250 int32_t gds_per_shader_engine
;
252 int32_t ce_ram_size_graphics
;
253 int32_t ce_ram_size_compute
;
254 int32_t max_number_of_dedicated_cus
;
256 int32_t vram_bus_width
;
257 int32_t l2_cache_size
;
258 int32_t l1_cache_size
;
260 char gpu_name
[SQTT_GPU_NAME_MAX_SIZE
];
262 float texture_per_clock
;
263 float prims_per_clock
;
264 float pixels_per_clock
;
265 uint64_t gpu_timestamp_frequency
;
266 uint64_t max_shader_core_clock
;
267 uint64_t max_memory_clock
;
268 uint32_t memory_ops_per_clock
;
269 enum sqtt_memory_type memory_chip_type
;
270 uint32_t lds_granularity
;
271 uint16_t cu_mask
[SQTT_MAX_NUM_SE
][SQTT_SA_PER_SE
];
276 static_assert(sizeof(struct sqtt_file_chunk_asic_info
) == 720,
277 "sqtt_file_chunk_asic_info doesn't match RGP spec");
279 static enum sqtt_gfxip_level
280 radv_chip_class_to_sqtt_gfxip_level(enum chip_class chip_class
)
282 switch (chip_class
) {
284 return SQTT_GFXIP_LEVEL_GFXIP_6
;
286 return SQTT_GFXIP_LEVEL_GFXIP_7
;
288 return SQTT_GFXIP_LEVEL_GFXIP_8
;
290 return SQTT_GFXIP_LEVEL_GFXIP_9
;
292 return SQTT_GFXIP_LEVEL_GFXIP_10_1
;
294 unreachable("Invalid chip class");
298 static enum sqtt_memory_type
299 radv_vram_type_to_sqtt_memory_type(uint32_t vram_type
)
302 case AMDGPU_VRAM_TYPE_UNKNOWN
:
303 return SQTT_MEMORY_TYPE_UNKNOWN
;
304 case AMDGPU_VRAM_TYPE_DDR2
:
305 return SQTT_MEMORY_TYPE_DDR2
;
306 case AMDGPU_VRAM_TYPE_DDR3
:
307 return SQTT_MEMORY_TYPE_DDR3
;
308 case AMDGPU_VRAM_TYPE_DDR4
:
309 return SQTT_MEMORY_TYPE_DDR4
;
310 case AMDGPU_VRAM_TYPE_GDDR5
:
311 return SQTT_MEMORY_TYPE_GDDR5
;
312 case AMDGPU_VRAM_TYPE_HBM
:
313 return SQTT_MEMORY_TYPE_HBM
;
314 case AMDGPU_VRAM_TYPE_GDDR6
:
315 return SQTT_MEMORY_TYPE_GDDR6
;
316 case AMDGPU_VRAM_TYPE_GDDR1
:
317 case AMDGPU_VRAM_TYPE_GDDR3
:
318 case AMDGPU_VRAM_TYPE_GDDR4
:
320 unreachable("Invalid vram type");
325 radv_fill_sqtt_asic_info(struct radv_device
*device
,
326 struct sqtt_file_chunk_asic_info
*chunk
)
328 struct radeon_info
*rad_info
= &device
->physical_device
->rad_info
;
330 chunk
->header
.chunk_id
.type
= SQTT_FILE_CHUNK_TYPE_ASIC_INFO
;
331 chunk
->header
.chunk_id
.index
= 0;
332 chunk
->header
.major_version
= 0;
333 chunk
->header
.minor_version
= 4;
334 chunk
->header
.size_in_bytes
= sizeof(*chunk
);
338 /* All chips older than GFX9 are affected by the "SPI not
339 * differentiating pkr_id for newwave commands" bug.
341 if (rad_info
->chip_class
< GFX9
)
342 chunk
->flags
|= SQTT_FILE_CHUNK_ASIC_INFO_FLAG_SC_PACKER_NUMBERING
;
344 /* Only FIJI and GFX9+ support PS1 events. */
345 if (rad_info
->family
== CHIP_FIJI
|| rad_info
->chip_class
>= GFX9
)
346 chunk
->flags
|= SQTT_FILE_CHUNK_ASIC_INFO_FLAG_PS1_EVENT_TOKENS_ENABLED
;
348 chunk
->trace_shader_core_clock
= rad_info
->max_shader_clock
* 1000000;
349 chunk
->trace_memory_clock
= rad_info
->max_memory_clock
* 1000000;
351 chunk
->device_id
= rad_info
->pci_id
;
352 chunk
->device_revision_id
= rad_info
->pci_rev_id
;
353 chunk
->vgprs_per_simd
= rad_info
->num_physical_wave64_vgprs_per_simd
;
354 chunk
->sgprs_per_simd
= rad_info
->num_physical_sgprs_per_simd
;
355 chunk
->shader_engines
= rad_info
->max_se
;
356 chunk
->compute_unit_per_shader_engine
= rad_info
->num_good_cu_per_sh
;
357 chunk
->simd_per_compute_unit
= rad_info
->num_simd_per_compute_unit
;
358 chunk
->wavefronts_per_simd
= rad_info
->max_wave64_per_simd
;
360 chunk
->minimum_vgpr_alloc
= rad_info
->min_vgpr_alloc
;
361 chunk
->vgpr_alloc_granularity
= rad_info
->wave64_vgpr_alloc_granularity
;
362 chunk
->minimum_sgpr_alloc
= rad_info
->min_sgpr_alloc
;
363 chunk
->sgpr_alloc_granularity
= rad_info
->sgpr_alloc_granularity
;
365 chunk
->hardware_contexts
= 8;
366 chunk
->gpu_type
= rad_info
->has_dedicated_vram
? SQTT_GPU_TYPE_DISCRETE
: SQTT_GPU_TYPE_INTEGRATED
;
367 chunk
->gfxip_level
= radv_chip_class_to_sqtt_gfxip_level(rad_info
->chip_class
);
368 chunk
->gpu_index
= 0;
370 chunk
->max_number_of_dedicated_cus
= 0;
371 chunk
->ce_ram_size
= rad_info
->ce_ram_size
;
372 chunk
->ce_ram_size_graphics
= 0;
373 chunk
->ce_ram_size_compute
= 0;
375 chunk
->vram_bus_width
= rad_info
->vram_bit_width
;
376 chunk
->vram_size
= rad_info
->vram_size
;
377 chunk
->l2_cache_size
= rad_info
->l2_cache_size
;
378 chunk
->l1_cache_size
= rad_info
->l1_cache_size
;
379 chunk
->lds_size
= rad_info
->lds_size_per_workgroup
;
381 strncpy(chunk
->gpu_name
, device
->physical_device
->name
, SQTT_GPU_NAME_MAX_SIZE
);
383 chunk
->alu_per_clock
= 0.0;
384 chunk
->texture_per_clock
= 0.0;
385 chunk
->prims_per_clock
= 0.0;
386 chunk
->pixels_per_clock
= 0.0;
388 chunk
->gpu_timestamp_frequency
= rad_info
->clock_crystal_freq
* 1000;
389 chunk
->max_shader_core_clock
= rad_info
->max_shader_clock
* 1000000;
390 chunk
->max_memory_clock
= rad_info
->max_memory_clock
* 1000000;
391 chunk
->memory_ops_per_clock
= 0;
392 chunk
->memory_chip_type
= radv_vram_type_to_sqtt_memory_type(rad_info
->vram_type
);
393 chunk
->lds_granularity
= rad_info
->lds_granularity
;
395 for (unsigned se
= 0; se
< 32; se
++) {
396 for (unsigned sa
= 0; sa
< 2; sa
++) {
397 chunk
->cu_mask
[se
][sa
] = 0; /* TODO */
406 SQTT_API_TYPE_DIRECTX_12
,
407 SQTT_API_TYPE_VULKAN
,
408 SQTT_API_TYPE_GENERIC
,
412 enum sqtt_instruction_trace_mode
414 SQTT_INSTRUCTION_TRACE_DISABLED
= 0x0,
415 SQTT_INSTRUCTION_TRACE_FULL_FRAME
= 0x1,
416 SQTT_INSTRUCTION_TRACE_API_PSO
= 0x2,
419 enum sqtt_profiling_mode
{
420 SQTT_PROFILING_MODE_PRESENT
= 0x0,
421 SQTT_PROFILING_MODE_USER_MARKERS
= 0x1,
422 SQTT_PROFILING_MODE_INDEX
= 0x2,
423 SQTT_PROFILING_MODE_TAG
= 0x3,
426 union sqtt_profiling_mode_data
{
430 } user_marker_profiling_data
;
435 } index_profiling_data
;
442 } tag_profiling_data
;
445 union sqtt_instruction_trace_data
{
447 uint64_t api_pso_filter
;
456 struct sqtt_file_chunk_api_info
{
457 struct sqtt_file_chunk_header header
;
458 enum sqtt_api_type api_type
;
459 uint16_t major_version
;
460 uint16_t minor_version
;
461 enum sqtt_profiling_mode profiling_mode
;
463 union sqtt_profiling_mode_data profiling_mode_data
;
464 enum sqtt_instruction_trace_mode instruction_trace_mode
;
466 union sqtt_instruction_trace_data instruction_trace_data
;
469 static_assert(sizeof(struct sqtt_file_chunk_api_info
) == 1064,
470 "sqtt_file_chunk_api_info doesn't match RGP spec");
473 radv_sqtt_fill_api_info(struct sqtt_file_chunk_api_info
*chunk
)
475 chunk
->header
.chunk_id
.type
= SQTT_FILE_CHUNK_TYPE_API_INFO
;
476 chunk
->header
.chunk_id
.index
= 0;
477 chunk
->header
.major_version
= 0;
478 chunk
->header
.minor_version
= 1;
479 chunk
->header
.size_in_bytes
= sizeof(*chunk
);
481 chunk
->api_type
= SQTT_API_TYPE_VULKAN
;
482 chunk
->major_version
= 0;
483 chunk
->minor_version
= 0;
484 chunk
->profiling_mode
= SQTT_PROFILING_MODE_PRESENT
;
485 chunk
->instruction_trace_mode
= SQTT_INSTRUCTION_TRACE_DISABLED
;
491 struct sqtt_file_chunk_sqtt_desc
{
492 struct sqtt_file_chunk_header header
;
493 int32_t shader_engine_index
;
494 enum sqtt_version sqtt_version
;
497 int32_t instrumentation_version
;
500 int16_t instrumentation_spec_version
;
501 int16_t instrumentation_api_version
;
502 int32_t compute_unit_index
;
507 static_assert(sizeof(struct sqtt_file_chunk_sqtt_desc
) == 32,
508 "sqtt_file_chunk_sqtt_desc doesn't match RGP spec");
510 static enum sqtt_version
511 radv_chip_class_to_sqtt_version(enum chip_class chip_class
)
513 switch (chip_class
) {
515 return SQTT_VERSION_2_0
;
517 return SQTT_VERSION_2_1
;
519 return SQTT_VERSION_2_2
;
521 return SQTT_VERSION_2_3
;
523 return SQTT_VERSION_2_4
;
525 unreachable("Invalid chip class");
530 radv_sqtt_fill_sqtt_desc(struct radv_device
*device
,
531 struct sqtt_file_chunk_sqtt_desc
*chunk
,
533 int32_t shader_engine_index
,
534 int32_t compute_unit_index
)
536 chunk
->header
.chunk_id
.type
= SQTT_FILE_CHUNK_TYPE_SQTT_DESC
;
537 chunk
->header
.chunk_id
.index
= chunk_index
;
538 chunk
->header
.major_version
= 0;
539 chunk
->header
.minor_version
= 2;
540 chunk
->header
.size_in_bytes
= sizeof(*chunk
);
542 chunk
->sqtt_version
= radv_chip_class_to_sqtt_version(device
->physical_device
->rad_info
.chip_class
);
543 chunk
->shader_engine_index
= shader_engine_index
;
544 chunk
->v1
.instrumentation_spec_version
= 0;
545 chunk
->v1
.instrumentation_api_version
= 0;
546 chunk
->v1
.compute_unit_index
= compute_unit_index
;
552 struct sqtt_file_chunk_sqtt_data
{
553 struct sqtt_file_chunk_header header
;
554 int32_t offset
; /* in bytes */
555 int32_t size
; /* in bytes */
558 static_assert(sizeof(struct sqtt_file_chunk_sqtt_data
) == 24,
559 "sqtt_file_chunk_sqtt_data doesn't match RGP spec");
562 radv_sqtt_fill_sqtt_data(struct sqtt_file_chunk_sqtt_data
*chunk
,
563 int32_t chunk_index
, int32_t offset
, int32_t size
)
565 chunk
->header
.chunk_id
.type
= SQTT_FILE_CHUNK_TYPE_SQTT_DATA
;
566 chunk
->header
.chunk_id
.index
= chunk_index
;
567 chunk
->header
.major_version
= 0;
568 chunk
->header
.minor_version
= 0;
569 chunk
->header
.size_in_bytes
= sizeof(*chunk
) + size
;
571 chunk
->offset
= sizeof(*chunk
) + offset
;
576 radv_sqtt_dump_data(struct radv_device
*device
,
577 const struct radv_thread_trace
*thread_trace
,
580 struct sqtt_file_chunk_asic_info asic_info
= {};
581 struct sqtt_file_chunk_cpu_info cpu_info
= {};
582 struct sqtt_file_chunk_api_info api_info
= {};
583 struct sqtt_file_header header
= {};
584 size_t file_offset
= 0;
586 /* SQTT header file. */
587 radv_sqtt_fill_header(&header
);
588 file_offset
+= sizeof(header
);
589 fwrite(&header
, sizeof(header
), 1, output
);
591 /* SQTT cpu chunk. */
592 radv_sqtt_fill_cpu_info(&cpu_info
);
593 file_offset
+= sizeof(cpu_info
);
594 fwrite(&cpu_info
, sizeof(cpu_info
), 1, output
);
596 /* SQTT asic chunk. */
597 radv_fill_sqtt_asic_info(device
, &asic_info
);
598 file_offset
+= sizeof(asic_info
);
599 fwrite(&asic_info
, sizeof(asic_info
), 1, output
);
601 /* SQTT api chunk. */
602 radv_sqtt_fill_api_info(&api_info
);
603 file_offset
+= sizeof(api_info
);
604 fwrite(&api_info
, sizeof(api_info
), 1, output
);
607 for (unsigned i
= 0; i
< thread_trace
->num_traces
; i
++) {
608 const struct radv_thread_trace_se
*se
= &thread_trace
->traces
[i
];
609 const struct radv_thread_trace_info
*info
= &se
->info
;
610 struct sqtt_file_chunk_sqtt_desc desc
= {};
611 struct sqtt_file_chunk_sqtt_data data
= {};
612 uint64_t size
= info
->cur_offset
* 32; /* unit of 32 bytes */
614 /* SQTT desc chunk. */
615 radv_sqtt_fill_sqtt_desc(device
, &desc
, i
,
618 file_offset
+= sizeof(desc
);
619 fwrite(&desc
, sizeof(desc
), 1, output
);
621 /* SQTT data chunk. */
622 radv_sqtt_fill_sqtt_data(&data
, i
, file_offset
, size
);
623 file_offset
+= sizeof(data
);
624 fwrite(&data
, sizeof(data
), 1, output
);
626 /* Copy thread trace data generated by the hardware. */
628 fwrite(se
->data_ptr
, size
, 1, output
);
634 radv_dump_thread_trace(struct radv_device
*device
,
635 const struct radv_thread_trace
*thread_trace
)
643 now
= *localtime(&t
);
645 snprintf(filename
, sizeof(filename
), "/tmp/%s_%04d.%02d.%02d_%02d.%02d.rgp",
646 util_get_process_name(), 1900 + now
.tm_year
, now
.tm_mon
+ 1,
647 now
.tm_mday
, now
.tm_hour
, now
.tm_min
);
649 f
= fopen(filename
, "w+");
653 radv_sqtt_dump_data(device
, thread_trace
, f
);
655 fprintf(stderr
, "Thread trace capture saved to '%s'\n", filename
);