rocprofiler-sdk/cxx/serialization.hpp Source File

rocprofiler-sdk/cxx/serialization.hpp Source File#

Rocprofiler SDK Developer API: rocprofiler-sdk/cxx/serialization.hpp Source File
Rocprofiler SDK Developer API 0.6.0
ROCm Profiling API and tools
serialization.hpp
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in all
13// copies or substantial portions of the Software.
14//
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 THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22//
23
24#pragma once
25
29#include <rocprofiler-sdk/fwd.h>
35
36#include <cereal/archives/binary.hpp>
37#include <cereal/archives/json.hpp>
38#include <cereal/archives/portable_binary.hpp>
39#include <cereal/cereal.hpp>
40#include <cereal/types/array.hpp>
41#include <cereal/types/atomic.hpp>
42#include <cereal/types/bitset.hpp>
43#include <cereal/types/chrono.hpp>
44#include <cereal/types/common.hpp>
45#include <cereal/types/complex.hpp>
46#include <cereal/types/deque.hpp>
47#include <cereal/types/functional.hpp>
48#include <cereal/types/list.hpp>
49#include <cereal/types/map.hpp>
50#include <cereal/types/optional.hpp>
51#include <cereal/types/queue.hpp>
52#include <cereal/types/set.hpp>
53#include <cereal/types/stack.hpp>
54#include <cereal/types/string.hpp>
55#include <cereal/types/unordered_map.hpp>
56#include <cereal/types/unordered_set.hpp>
57#include <cereal/types/utility.hpp>
58#include <cereal/types/variant.hpp>
59#include <cereal/types/vector.hpp>
60
61#include <string>
62#include <string_view>
63#include <utility>
64#include <vector>
65
66#define ROCP_SDK_SAVE_DATA_FIELD(FIELD) ar(make_nvp(#FIELD, data.FIELD))
67#define ROCP_SDK_SAVE_DATA_VALUE(NAME, VALUE) ar(make_nvp(NAME, data.VALUE))
68#define ROCP_SDK_SAVE_VALUE(NAME, VALUE) ar(make_nvp(NAME, VALUE))
69#define ROCP_SDK_SAVE_DATA_CSTR(FIELD) \
70 ar(make_nvp(#FIELD, std::string{data.FIELD ? data.FIELD : ""}))
71#define ROCP_SDK_SAVE_DATA_BITFIELD(NAME, VALUE) \
72 { \
73 auto _val = data.VALUE; \
74 ar(make_nvp(NAME, _val)); \
75 }
76
77#if !defined(ROCPROFILER_SDK_CEREAL_NAMESPACE_BEGIN)
78# define ROCPROFILER_SDK_CEREAL_NAMESPACE_BEGIN \
79 namespace cereal \
80 {
81#endif
82
83#if !defined(ROCPROFILER_SDK_CEREAL_NAMESPACE_END)
84# define ROCPROFILER_SDK_CEREAL_NAMESPACE_END } // namespace cereal
85#endif
86
88
89template <typename ArchiveT>
90void
91save(ArchiveT& ar, rocprofiler_context_id_t data)
92{
94}
95
96template <typename ArchiveT>
97void
98save(ArchiveT& ar, rocprofiler_agent_id_t data)
99{
101}
102
103template <typename ArchiveT>
104void
105save(ArchiveT& ar, hsa_agent_t data)
106{
108}
109
110template <typename ArchiveT>
111void
112save(ArchiveT& ar, rocprofiler_queue_id_t data)
113{
115}
116
117template <typename ArchiveT>
118void
120{
122}
123
124template <typename ArchiveT>
125void
127{
128 ROCP_SDK_SAVE_DATA_FIELD(internal);
129 ROCP_SDK_SAVE_DATA_VALUE("external", external.value);
130}
131
132template <typename ArchiveT>
133void
140
141template <typename ArchiveT>
142void
143save(ArchiveT& ar, rocprofiler_address_t data)
144{
146}
147
148template <typename ArchiveT>
149void
151{
153 ROCP_SDK_SAVE_DATA_FIELD(code_object_id);
154 ROCP_SDK_SAVE_DATA_FIELD(rocp_agent);
155 ROCP_SDK_SAVE_DATA_FIELD(hsa_agent);
157 ROCP_SDK_SAVE_DATA_FIELD(load_base);
158 ROCP_SDK_SAVE_DATA_FIELD(load_size);
159 ROCP_SDK_SAVE_DATA_FIELD(load_delta);
160 ROCP_SDK_SAVE_DATA_FIELD(storage_type);
162 {
163 ROCP_SDK_SAVE_DATA_FIELD(storage_file);
164 }
166 {
167 ROCP_SDK_SAVE_DATA_FIELD(memory_base);
168 ROCP_SDK_SAVE_DATA_FIELD(memory_size);
169 }
170}
171
172template <typename ArchiveT>
173void
175{
177 ROCP_SDK_SAVE_DATA_FIELD(kernel_id);
178 ROCP_SDK_SAVE_DATA_FIELD(code_object_id);
179 ROCP_SDK_SAVE_DATA_CSTR(kernel_name);
180 ROCP_SDK_SAVE_DATA_FIELD(kernel_object);
181 ROCP_SDK_SAVE_DATA_FIELD(kernarg_segment_size);
182 ROCP_SDK_SAVE_DATA_FIELD(kernarg_segment_alignment);
183 ROCP_SDK_SAVE_DATA_FIELD(group_segment_size);
184 ROCP_SDK_SAVE_DATA_FIELD(private_segment_size);
185 ROCP_SDK_SAVE_DATA_FIELD(sgpr_count);
186 ROCP_SDK_SAVE_DATA_FIELD(arch_vgpr_count);
187 ROCP_SDK_SAVE_DATA_FIELD(accum_vgpr_count);
188}
189
190template <typename ArchiveT>
191void
193{
195 ROCP_SDK_SAVE_DATA_FIELD(host_function_id);
196 ROCP_SDK_SAVE_DATA_FIELD(kernel_id);
197 ROCP_SDK_SAVE_DATA_FIELD(code_object_id);
198 ROCP_SDK_SAVE_DATA_FIELD(host_function);
200 ROCP_SDK_SAVE_DATA_CSTR(device_function);
201 ROCP_SDK_SAVE_DATA_FIELD(thread_limit);
202 ROCP_SDK_SAVE_DATA_FIELD(thread_ids);
203 ROCP_SDK_SAVE_DATA_FIELD(block_ids);
204 ROCP_SDK_SAVE_DATA_FIELD(block_dims);
205 ROCP_SDK_SAVE_DATA_FIELD(grid_dims);
206 ROCP_SDK_SAVE_DATA_FIELD(workgroup_size);
207}
208
209template <typename ArchiveT>
210void
212{
213 ROCP_SDK_SAVE_DATA_FIELD(uint64_t_retval);
214}
215
216template <typename ArchiveT>
217void
218save(ArchiveT& ar, const hsa_queue_t& data)
219{
220 ar(make_nvp("queue_id", data.id));
221}
222
223template <typename ArchiveT>
224void
225save(ArchiveT& ar, hsa_amd_event_scratch_alloc_start_t data)
226{
227 ar(make_nvp("queue_id", *data.queue));
228 ROCP_SDK_SAVE_DATA_FIELD(dispatch_id);
229}
230
231template <typename ArchiveT>
232void
233save(ArchiveT& ar, hsa_amd_event_scratch_alloc_end_t data)
234{
235 ar(make_nvp("queue_id", *data.queue));
236 ROCP_SDK_SAVE_DATA_FIELD(dispatch_id);
238 ROCP_SDK_SAVE_DATA_FIELD(num_slots);
240}
241
242template <typename ArchiveT>
243void
244save(ArchiveT& ar, hsa_amd_event_scratch_free_start_t data)
245{
246 ar(make_nvp("queue_id", *data.queue));
247}
248
249template <typename ArchiveT>
250void
251save(ArchiveT& ar, hsa_amd_event_scratch_free_end_t data)
252{
253 ar(make_nvp("queue_id", *data.queue));
255}
256
257template <typename ArchiveT>
258void
259save(ArchiveT& ar, hsa_amd_event_scratch_async_reclaim_start_t data)
260{
261 ar(make_nvp("queue_id", *data.queue));
262}
263
264template <typename ArchiveT>
265void
266save(ArchiveT& ar, hsa_amd_event_scratch_async_reclaim_end_t data)
267{
268 ar(make_nvp("queue_id", *data.queue));
270}
271
272template <typename ArchiveT>
273void
275{
276 ROCP_SDK_SAVE_DATA_FIELD(int64_t_retval);
277}
278
279template <typename ArchiveT>
280void
282{
284 // ROCP_SDK_SAVE_DATA_FIELD(args);
286}
287
288template <typename ArchiveT>
289void
291{
293 // ROCP_SDK_SAVE_DATA_FIELD(args);
295}
296
297template <typename ArchiveT>
298void
300{
301 ROCP_SDK_SAVE_DATA_FIELD(hipError_t_retval);
302}
303
304template <typename ArchiveT>
305void
307{
309 // ROCP_SDK_SAVE_DATA_FIELD(args);
311}
312
313template <typename ArchiveT>
314void
323
324template <typename ArchiveT>
325void
327{
329 ROCP_SDK_SAVE_DATA_FIELD(agent_id);
330 ROCP_SDK_SAVE_DATA_FIELD(queue_id);
331 ROCP_SDK_SAVE_DATA_FIELD(kernel_id);
332 ROCP_SDK_SAVE_DATA_FIELD(dispatch_id);
333 ROCP_SDK_SAVE_DATA_FIELD(private_segment_size);
334 ROCP_SDK_SAVE_DATA_FIELD(group_segment_size);
335 ROCP_SDK_SAVE_DATA_FIELD(workgroup_size);
336 ROCP_SDK_SAVE_DATA_FIELD(grid_size);
337}
338
339template <typename ArchiveT>
340void
342{
344 ROCP_SDK_SAVE_DATA_FIELD(start_timestamp);
345 ROCP_SDK_SAVE_DATA_FIELD(end_timestamp);
346 ROCP_SDK_SAVE_DATA_FIELD(dispatch_info);
347}
348
349template <typename ArchiveT>
350void
352{
354 ROCP_SDK_SAVE_DATA_FIELD(start_timestamp);
355 ROCP_SDK_SAVE_DATA_FIELD(end_timestamp);
356 ROCP_SDK_SAVE_DATA_FIELD(dst_agent_id);
357 ROCP_SDK_SAVE_DATA_FIELD(src_agent_id);
359}
360
361template <typename ArchiveT>
362void
372
373template <typename ArchiveT>
374void
376{
377 ROCP_SDK_SAVE_DATA_FIELD(ncclResult_t_retval);
378}
379
380template <typename ArchiveT>
381void
383{
385 // ROCP_SDK_SAVE_DATA_FIELD(args);
387}
388
389template <typename ArchiveT>
390void
392{
394 // ROCP_SDK_SAVE_DATA_FIELD(args);
395}
396
397template <typename ArchiveT>
398void
400{
402 ROCP_SDK_SAVE_DATA_FIELD(correlation_id);
403 ROCP_SDK_SAVE_DATA_FIELD(start_timestamp);
404 ROCP_SDK_SAVE_DATA_FIELD(end_timestamp);
405 ROCP_SDK_SAVE_DATA_FIELD(dispatch_info);
406}
407
408template <typename ArchiveT>
409void
411{
413 ROCP_SDK_SAVE_DATA_FIELD(num_records);
414 ROCP_SDK_SAVE_DATA_FIELD(correlation_id);
415 ROCP_SDK_SAVE_DATA_FIELD(start_timestamp);
416 ROCP_SDK_SAVE_DATA_FIELD(end_timestamp);
417 ROCP_SDK_SAVE_DATA_FIELD(dispatch_info);
418}
419
420template <typename ArchiveT>
421void
423{
424 ROCP_SDK_SAVE_DATA_FIELD(context_id);
425 ROCP_SDK_SAVE_DATA_FIELD(thread_id);
427 ROCP_SDK_SAVE_DATA_FIELD(operation);
428 ROCP_SDK_SAVE_DATA_FIELD(correlation_id);
430}
431
432template <typename ArchiveT, typename Tp>
433void
434save_buffer_tracing_api_record(ArchiveT& ar, Tp data)
435{
438 ROCP_SDK_SAVE_DATA_FIELD(operation);
439 ROCP_SDK_SAVE_DATA_FIELD(correlation_id);
440 ROCP_SDK_SAVE_DATA_FIELD(start_timestamp);
441 ROCP_SDK_SAVE_DATA_FIELD(end_timestamp);
442 ROCP_SDK_SAVE_DATA_FIELD(thread_id);
443}
444
445template <typename ArchiveT>
446void
451
452template <typename ArchiveT>
453void
455{
457 ROCP_SDK_SAVE_DATA_FIELD(counter_value);
458 ROCP_SDK_SAVE_DATA_FIELD(dispatch_id);
459}
460
461template <typename ArchiveT>
462void
467
468template <typename ArchiveT>
469void
474
475template <typename ArchiveT>
476void
481
482template <typename ArchiveT>
483void
485{
486 ROCP_SDK_SAVE_DATA_VALUE("kind", kind);
487 ROCP_SDK_SAVE_DATA_VALUE("device", device_num);
488 ROCP_SDK_SAVE_DATA_VALUE("task_id", task_id);
489 ROCP_SDK_SAVE_DATA_VALUE("target_id", target_id);
490}
491
492template <typename ArchiveT>
493void
495{
496 ROCP_SDK_SAVE_DATA_VALUE("host_op_id", host_op_id);
497 ROCP_SDK_SAVE_DATA_VALUE("optype", optype);
498 ROCP_SDK_SAVE_DATA_VALUE("src_device_num", src_device_num);
499 ROCP_SDK_SAVE_DATA_VALUE("dst_device_num", dst_device_num);
500 ROCP_SDK_SAVE_DATA_VALUE("bytes", bytes);
501}
502
503template <typename ArchiveT>
504void
506{
507 ROCP_SDK_SAVE_DATA_VALUE("host_op_id", host_op_id);
508 ROCP_SDK_SAVE_DATA_VALUE("device_num", device_num);
509 ROCP_SDK_SAVE_DATA_VALUE("requested_num_teams", requested_num_teams);
510}
511
512template <typename ArchiveT>
513void
515{
517
519 {
521 }
523 {
524 ROCP_SDK_SAVE_DATA_FIELD(target_data_op);
525 }
527 {
528 ROCP_SDK_SAVE_DATA_FIELD(target_kernel);
529 }
530}
531
532template <typename ArchiveT>
533void
535{
538 ROCP_SDK_SAVE_DATA_FIELD(operation);
539 ROCP_SDK_SAVE_DATA_FIELD(thread_id);
540 ROCP_SDK_SAVE_DATA_FIELD(correlation_id);
541 ROCP_SDK_SAVE_DATA_FIELD(start_timestamp);
542 ROCP_SDK_SAVE_DATA_FIELD(end_timestamp);
543 ROCP_SDK_SAVE_DATA_FIELD(dispatch_info);
544}
545
546template <typename ArchiveT>
547void
549{
552 ROCP_SDK_SAVE_DATA_FIELD(operation);
553 ROCP_SDK_SAVE_DATA_FIELD(thread_id);
554 ROCP_SDK_SAVE_DATA_FIELD(correlation_id);
555 ROCP_SDK_SAVE_DATA_FIELD(start_timestamp);
556 ROCP_SDK_SAVE_DATA_FIELD(end_timestamp);
557 ROCP_SDK_SAVE_DATA_FIELD(dst_agent_id);
558 ROCP_SDK_SAVE_DATA_FIELD(src_agent_id);
560}
561
562template <typename ArchiveT>
563void
577
578template <typename ArchiveT>
579void
581{
582 ROCP_SDK_SAVE_DATA_BITFIELD("read_fault", read_fault);
583 ROCP_SDK_SAVE_DATA_FIELD(agent_id);
585}
586
587template <typename ArchiveT>
588void
590{
591 ROCP_SDK_SAVE_DATA_BITFIELD("migrated", migrated);
592 ROCP_SDK_SAVE_DATA_FIELD(agent_id);
594}
595
596template <typename ArchiveT>
597void
599{
600 ROCP_SDK_SAVE_DATA_FIELD(start_addr);
601 ROCP_SDK_SAVE_DATA_FIELD(end_addr);
602 ROCP_SDK_SAVE_DATA_FIELD(from_agent);
603 ROCP_SDK_SAVE_DATA_FIELD(to_agent);
604 ROCP_SDK_SAVE_DATA_FIELD(prefetch_agent);
605 ROCP_SDK_SAVE_DATA_FIELD(preferred_agent);
607}
608
609template <typename ArchiveT>
610void
612{
613 ROCP_SDK_SAVE_DATA_FIELD(start_addr);
614 ROCP_SDK_SAVE_DATA_FIELD(end_addr);
615 ROCP_SDK_SAVE_DATA_FIELD(from_agent);
616 ROCP_SDK_SAVE_DATA_FIELD(to_agent);
618 ROCP_SDK_SAVE_DATA_FIELD(error_code);
619}
620
621template <typename ArchiveT>
622void
624{
625 ROCP_SDK_SAVE_DATA_FIELD(agent_id);
627}
628
629template <typename ArchiveT>
630void
632{
633 ROCP_SDK_SAVE_DATA_BITFIELD("rescheduled", rescheduled);
634 ROCP_SDK_SAVE_DATA_FIELD(agent_id);
635}
636
637template <typename ArchiveT>
638void
640{
641 ROCP_SDK_SAVE_DATA_FIELD(start_addr);
642 ROCP_SDK_SAVE_DATA_FIELD(end_addr);
643 ROCP_SDK_SAVE_DATA_FIELD(agent_id);
645}
646
647template <typename ArchiveT>
648void
650{
651 ROCP_SDK_SAVE_DATA_FIELD(dropped_events_count);
652}
653
654namespace details
655{
656template <size_t Idx>
658
659#define ROCP_SDK_SPECIALIZE_PAGE_MIGRATION_ARG(ENUM_VALUE, UNION_ARG) \
660 template <> \
661 struct save_page_migration_arg<ROCPROFILER_PAGE_MIGRATION_##ENUM_VALUE> \
662 { \
663 static constexpr auto value = ROCPROFILER_PAGE_MIGRATION_##ENUM_VALUE; \
664 template <typename ArchiveT> \
665 void operator()(ArchiveT& ar, rocprofiler_page_migration_args_t args) \
666 { \
667 ar(make_nvp(#UNION_ARG, args.UNION_ARG)); \
668 } \
669 };
670
672ROCP_SDK_SPECIALIZE_PAGE_MIGRATION_ARG(PAGE_MIGRATE_START, page_migrate_start)
673ROCP_SDK_SPECIALIZE_PAGE_MIGRATION_ARG(PAGE_MIGRATE_END, page_migrate_end)
674ROCP_SDK_SPECIALIZE_PAGE_MIGRATION_ARG(PAGE_FAULT_START, page_fault_start)
675ROCP_SDK_SPECIALIZE_PAGE_MIGRATION_ARG(PAGE_FAULT_END, page_fault_end)
676ROCP_SDK_SPECIALIZE_PAGE_MIGRATION_ARG(QUEUE_EVICTION, queue_eviction)
677ROCP_SDK_SPECIALIZE_PAGE_MIGRATION_ARG(QUEUE_RESTORE, queue_restore)
678ROCP_SDK_SPECIALIZE_PAGE_MIGRATION_ARG(UNMAP_FROM_GPU, unmap_from_gpu)
679ROCP_SDK_SPECIALIZE_PAGE_MIGRATION_ARG(DROPPED_EVENT, dropped_event)
680
681#undef ROCP_SDK_SPECIALIZE_PAGE_MIGRATION_ARG
682
683template <typename ArchiveT, size_t Idx, size_t... IdxTail>
684void
688 std::index_sequence<Idx, IdxTail...>)
689{
690 using save_page_migration_type = save_page_migration_arg<Idx>;
691 if(op == save_page_migration_type::value)
692 {
693 if constexpr(save_page_migration_type::value != ROCPROFILER_PAGE_MIGRATION_NONE)
694 save_page_migration_type{}(ar, args);
695 }
696 else if constexpr(sizeof...(IdxTail) > 0)
697 {
698 save_page_migration_args(ar, op, args, std::index_sequence<IdxTail...>{});
699 }
700}
701} // namespace details
702
703template <typename ArchiveT>
704void
706{
709 ROCP_SDK_SAVE_DATA_FIELD(operation);
710 ROCP_SDK_SAVE_DATA_FIELD(timestamp);
712 details::save_page_migration_args(
713 ar, data.operation, data.args, std::make_index_sequence<ROCPROFILER_PAGE_MIGRATION_LAST>{});
714}
715
716template <typename ArchiveT>
717void
719{
722 ROCP_SDK_SAVE_DATA_FIELD(operation);
723 ROCP_SDK_SAVE_DATA_FIELD(agent_id);
724 ROCP_SDK_SAVE_DATA_FIELD(queue_id);
725 ROCP_SDK_SAVE_DATA_FIELD(thread_id);
726 ROCP_SDK_SAVE_DATA_FIELD(start_timestamp);
727 ROCP_SDK_SAVE_DATA_FIELD(end_timestamp);
728 ROCP_SDK_SAVE_DATA_FIELD(correlation_id);
730}
731
732template <typename ArchiveT>
733void
741
742template <typename ArchiveT>
743void
744save(ArchiveT& ar, HsaCacheType data)
745{
746 ROCP_SDK_SAVE_DATA_BITFIELD("Data", ui32.Data);
747 ROCP_SDK_SAVE_DATA_BITFIELD("Instruction", ui32.Instruction);
748 ROCP_SDK_SAVE_DATA_BITFIELD("CPU", ui32.CPU);
749 ROCP_SDK_SAVE_DATA_BITFIELD("HSACU", ui32.HSACU);
750}
751
752template <typename ArchiveT>
753void
754save(ArchiveT& ar, HSA_LINKPROPERTY data)
755{
756 ROCP_SDK_SAVE_DATA_BITFIELD("Override", ui32.Override);
757 ROCP_SDK_SAVE_DATA_BITFIELD("NonCoherent", ui32.NonCoherent);
758 ROCP_SDK_SAVE_DATA_BITFIELD("NoAtomics32bit", ui32.NoAtomics32bit);
759 ROCP_SDK_SAVE_DATA_BITFIELD("NoAtomics64bit", ui32.NoAtomics64bit);
760 ROCP_SDK_SAVE_DATA_BITFIELD("NoPeerToPeerDMA", ui32.NoPeerToPeerDMA);
761}
762
763template <typename ArchiveT>
764void
765save(ArchiveT& ar, HSA_CAPABILITY data)
766{
767 ROCP_SDK_SAVE_DATA_BITFIELD("HotPluggable", ui32.HotPluggable);
768 ROCP_SDK_SAVE_DATA_BITFIELD("HSAMMUPresent", ui32.HSAMMUPresent);
769 ROCP_SDK_SAVE_DATA_BITFIELD("SharedWithGraphics", ui32.SharedWithGraphics);
770 ROCP_SDK_SAVE_DATA_BITFIELD("QueueSizePowerOfTwo", ui32.QueueSizePowerOfTwo);
771 ROCP_SDK_SAVE_DATA_BITFIELD("QueueSize32bit", ui32.QueueSize32bit);
772 ROCP_SDK_SAVE_DATA_BITFIELD("QueueIdleEvent", ui32.QueueIdleEvent);
773 ROCP_SDK_SAVE_DATA_BITFIELD("VALimit", ui32.VALimit);
774 ROCP_SDK_SAVE_DATA_BITFIELD("WatchPointsSupported", ui32.WatchPointsSupported);
775 ROCP_SDK_SAVE_DATA_BITFIELD("WatchPointsTotalBits", ui32.WatchPointsTotalBits);
776 ROCP_SDK_SAVE_DATA_BITFIELD("DoorbellType", ui32.DoorbellType);
777 ROCP_SDK_SAVE_DATA_BITFIELD("AQLQueueDoubleMap", ui32.AQLQueueDoubleMap);
778 ROCP_SDK_SAVE_DATA_BITFIELD("DebugTrapSupported", ui32.DebugTrapSupported);
779 ROCP_SDK_SAVE_DATA_BITFIELD("WaveLaunchTrapOverrideSupported",
780 ui32.WaveLaunchTrapOverrideSupported);
781 ROCP_SDK_SAVE_DATA_BITFIELD("WaveLaunchModeSupported", ui32.WaveLaunchModeSupported);
782 ROCP_SDK_SAVE_DATA_BITFIELD("PreciseMemoryOperationsSupported",
783 ui32.PreciseMemoryOperationsSupported);
784 ROCP_SDK_SAVE_DATA_BITFIELD("DEPRECATED_SRAM_EDCSupport", ui32.DEPRECATED_SRAM_EDCSupport);
785 ROCP_SDK_SAVE_DATA_BITFIELD("Mem_EDCSupport", ui32.Mem_EDCSupport);
786 ROCP_SDK_SAVE_DATA_BITFIELD("RASEventNotify", ui32.RASEventNotify);
787 ROCP_SDK_SAVE_DATA_BITFIELD("ASICRevision", ui32.ASICRevision);
788 ROCP_SDK_SAVE_DATA_BITFIELD("SRAM_EDCSupport", ui32.SRAM_EDCSupport);
789 ROCP_SDK_SAVE_DATA_BITFIELD("SVMAPISupported", ui32.SVMAPISupported);
790 ROCP_SDK_SAVE_DATA_BITFIELD("CoherentHostAccess", ui32.CoherentHostAccess);
791 ROCP_SDK_SAVE_DATA_BITFIELD("DebugSupportedFirmware", ui32.DebugSupportedFirmware);
792}
793
794template <typename ArchiveT>
795void
796save(ArchiveT& ar, HSA_MEMORYPROPERTY data)
797{
798 ROCP_SDK_SAVE_DATA_BITFIELD("HotPluggable", ui32.HotPluggable);
799 ROCP_SDK_SAVE_DATA_BITFIELD("NonVolatile", ui32.NonVolatile);
800}
801
802template <typename ArchiveT>
803void
804save(ArchiveT& ar, HSA_ENGINE_VERSION data)
805{
806 ROCP_SDK_SAVE_DATA_BITFIELD("uCodeSDMA", uCodeSDMA);
807 ROCP_SDK_SAVE_DATA_BITFIELD("uCodeRes", uCodeRes);
808}
809
810template <typename ArchiveT>
811void
812save(ArchiveT& ar, HSA_ENGINE_ID data)
813{
814 ROCP_SDK_SAVE_DATA_BITFIELD("uCode", ui32.uCode);
815 ROCP_SDK_SAVE_DATA_BITFIELD("Major", ui32.Major);
816 ROCP_SDK_SAVE_DATA_BITFIELD("Minor", ui32.Minor);
817 ROCP_SDK_SAVE_DATA_BITFIELD("Stepping", ui32.Stepping);
818}
819
820template <typename ArchiveT>
821void
823{
824 ROCP_SDK_SAVE_DATA_FIELD(processor_id_low);
827 ROCP_SDK_SAVE_DATA_FIELD(cache_line_size);
828 ROCP_SDK_SAVE_DATA_FIELD(cache_lines_per_tag);
829 ROCP_SDK_SAVE_DATA_FIELD(association);
832}
833template <typename ArchiveT>
834void
835save(ArchiveT& ar, rocprofiler_pc_t data)
836{
837 ROCP_SDK_SAVE_DATA_FIELD(code_object_id);
838 ROCP_SDK_SAVE_DATA_FIELD(code_object_offset);
839}
840
841template <typename ArchiveT>
842void
844{
845 ROCP_SDK_SAVE_DATA_BITFIELD("chiplet", chiplet);
846 ROCP_SDK_SAVE_DATA_BITFIELD("wave_id", wave_id);
847 ROCP_SDK_SAVE_DATA_BITFIELD("simd_id", simd_id);
848 ROCP_SDK_SAVE_DATA_BITFIELD("pipe_id", pipe_id);
849 ROCP_SDK_SAVE_DATA_BITFIELD("cu_or_wgp_id", cu_or_wgp_id);
850 ROCP_SDK_SAVE_DATA_BITFIELD("shader_array_id", shader_array_id);
851 ROCP_SDK_SAVE_DATA_BITFIELD("shader_engine_id", shader_engine_id);
852 ROCP_SDK_SAVE_DATA_BITFIELD("workgroup_id ", workgroup_id);
853 ROCP_SDK_SAVE_DATA_BITFIELD("vm_id", vm_id);
854 ROCP_SDK_SAVE_DATA_BITFIELD("queue_id", queue_id);
855 ROCP_SDK_SAVE_DATA_BITFIELD("microengine_id", microengine_id);
856}
857
858template <typename ArchiveT>
859void
861{
864 ROCP_SDK_SAVE_DATA_FIELD(exec_mask);
865 ROCP_SDK_SAVE_DATA_FIELD(timestamp);
866 ROCP_SDK_SAVE_DATA_FIELD(dispatch_id);
867 ROCP_SDK_SAVE_DATA_VALUE("corr_id", correlation_id);
868 ROCP_SDK_SAVE_DATA_VALUE("wrkgrp_id", workgroup_id);
869 ROCP_SDK_SAVE_DATA_BITFIELD("wave_in_grp", wave_in_group);
870}
871
872template <typename ArchiveT>
873void
875{
877 ROCP_SDK_SAVE_DATA_FIELD(version_major);
878 ROCP_SDK_SAVE_DATA_FIELD(version_minor);
879 ROCP_SDK_SAVE_DATA_FIELD(node_from);
882 ROCP_SDK_SAVE_DATA_FIELD(min_latency);
883 ROCP_SDK_SAVE_DATA_FIELD(max_latency);
884 ROCP_SDK_SAVE_DATA_FIELD(min_bandwidth);
885 ROCP_SDK_SAVE_DATA_FIELD(max_bandwidth);
886 ROCP_SDK_SAVE_DATA_FIELD(recommended_transfer_size);
888}
889
890template <typename ArchiveT>
891void
893{
894 ROCP_SDK_SAVE_DATA_FIELD(heap_type);
897 ROCP_SDK_SAVE_DATA_FIELD(mem_clk_max);
898 ROCP_SDK_SAVE_DATA_FIELD(size_in_bytes);
899}
900
901template <typename ArchiveT>
902void
911
912template <typename ArchiveT>
913void
914save(ArchiveT& ar, const rocprofiler_agent_v0_t& data)
915{
919 ROCP_SDK_SAVE_DATA_FIELD(cpu_cores_count);
920 ROCP_SDK_SAVE_DATA_FIELD(simd_count);
921 ROCP_SDK_SAVE_DATA_FIELD(mem_banks_count);
922 ROCP_SDK_SAVE_DATA_FIELD(caches_count);
923 ROCP_SDK_SAVE_DATA_FIELD(io_links_count);
924 ROCP_SDK_SAVE_DATA_FIELD(cpu_core_id_base);
925 ROCP_SDK_SAVE_DATA_FIELD(simd_id_base);
926 ROCP_SDK_SAVE_DATA_FIELD(max_waves_per_simd);
927 ROCP_SDK_SAVE_DATA_FIELD(lds_size_in_kb);
928 ROCP_SDK_SAVE_DATA_FIELD(gds_size_in_kb);
930 ROCP_SDK_SAVE_DATA_FIELD(wave_front_size);
932 ROCP_SDK_SAVE_DATA_FIELD(cu_count);
933 ROCP_SDK_SAVE_DATA_FIELD(array_count);
934 ROCP_SDK_SAVE_DATA_FIELD(num_shader_banks);
935 ROCP_SDK_SAVE_DATA_FIELD(simd_arrays_per_engine);
936 ROCP_SDK_SAVE_DATA_FIELD(cu_per_simd_array);
937 ROCP_SDK_SAVE_DATA_FIELD(simd_per_cu);
938 ROCP_SDK_SAVE_DATA_FIELD(max_slots_scratch_cu);
939 ROCP_SDK_SAVE_DATA_FIELD(gfx_target_version);
940 ROCP_SDK_SAVE_DATA_FIELD(vendor_id);
941 ROCP_SDK_SAVE_DATA_FIELD(device_id);
942 ROCP_SDK_SAVE_DATA_FIELD(location_id);
944 ROCP_SDK_SAVE_DATA_FIELD(drm_render_minor);
945 ROCP_SDK_SAVE_DATA_FIELD(num_sdma_engines);
946 ROCP_SDK_SAVE_DATA_FIELD(num_sdma_xgmi_engines);
947 ROCP_SDK_SAVE_DATA_FIELD(num_sdma_queues_per_engine);
948 ROCP_SDK_SAVE_DATA_FIELD(num_cp_queues);
949 ROCP_SDK_SAVE_DATA_FIELD(max_engine_clk_ccompute);
950 ROCP_SDK_SAVE_DATA_FIELD(max_engine_clk_fcompute);
951 ROCP_SDK_SAVE_DATA_FIELD(sdma_fw_version);
952 ROCP_SDK_SAVE_DATA_FIELD(fw_version);
953 ROCP_SDK_SAVE_DATA_FIELD(capability);
954 ROCP_SDK_SAVE_DATA_FIELD(cu_per_engine);
955 ROCP_SDK_SAVE_DATA_FIELD(max_waves_per_cu);
956 ROCP_SDK_SAVE_DATA_FIELD(family_id);
957 ROCP_SDK_SAVE_DATA_FIELD(workgroup_max_size);
958 ROCP_SDK_SAVE_DATA_FIELD(grid_max_size);
959 ROCP_SDK_SAVE_DATA_FIELD(local_mem_size);
962 ROCP_SDK_SAVE_DATA_FIELD(workgroup_max_dim);
963 ROCP_SDK_SAVE_DATA_FIELD(grid_max_dim);
965 ROCP_SDK_SAVE_DATA_CSTR(vendor_name);
966 ROCP_SDK_SAVE_DATA_CSTR(product_name);
967 ROCP_SDK_SAVE_DATA_CSTR(model_name);
969 ROCP_SDK_SAVE_DATA_FIELD(logical_node_id);
970
971 auto generate = [&](auto name, const auto* value, uint64_t size) {
972 using value_type = std::remove_const_t<std::remove_pointer_t<decltype(value)>>;
973 auto vec = std::vector<value_type>{};
974 vec.reserve(size);
975 for(uint64_t i = 0; i < size; ++i)
976 vec.emplace_back(value[i]);
977 ar(make_nvp(name, vec));
978 };
979
980 generate("mem_banks", data.mem_banks, data.mem_banks_count);
981 generate("caches", data.caches, data.caches_count);
982 generate("io_links", data.io_links, data.io_links_count);
983}
984
985template <typename ArchiveT>
986void
988{
990 ROCP_SDK_SAVE_DATA_BITFIELD("is_constant", is_constant);
991 ROCP_SDK_SAVE_DATA_BITFIELD("is_derived", is_derived);
993 ROCP_SDK_SAVE_DATA_CSTR(description);
995 ROCP_SDK_SAVE_DATA_CSTR(expression);
996}
997
998template <typename ArchiveT>
999void
1001{
1003 ROCP_SDK_SAVE_DATA_FIELD(instance_size);
1005}
1006
1007template <typename ArchiveT>
1008void
1015
1016template <typename ArchiveT>
1017void
1029
1030template <typename ArchiveT, typename EnumT, typename ValueT>
1031void
1033{
1034 ar.makeArray();
1035 for(const auto& itr : data)
1036 ar(cereal::make_nvp("entry", itr));
1037}
1038
1039template <typename ArchiveT, typename EnumT, typename ValueT>
1040void
1042{
1043 auto _name = std::string{data.name};
1044 auto _ops = std::vector<std::string>{};
1045 _ops.reserve(data.operations.size());
1046
1047 ar(cereal::make_nvp("kind", _name));
1048 for(auto itr : data.operations)
1049 _ops.emplace_back(itr);
1050 ar(cereal::make_nvp("operations", _ops));
1051}
1052
1054
1055#undef ROCP_SDK_SAVE_DATA_FIELD
1056#undef ROCP_SDK_SAVE_DATA_VALUE
1057#undef ROCP_SDK_SAVE_DATA_CSTR
1058#undef ROCP_SDK_SAVE_DATA_BITFIELD
const rocprofiler_agent_io_link_t * io_links
Definition agent.h:185
uint32_t mem_banks_count
Definition agent.h:121
uint32_t caches_count
Definition agent.h:123
const rocprofiler_agent_mem_bank_t * mem_banks
Definition agent.h:183
uint32_t io_links_count
Definition agent.h:124
const rocprofiler_agent_cache_t * caches
Definition agent.h:184
Cache information for an agent.
Definition agent.h:56
Memory bank information for an agent.
Definition agent.h:91
Stores the properties of an agent (CPU, GPU, etc.)
Definition agent.h:111
uint64_t value
usage example: store address in uint64_t format
Definition fwd.h:525
rocprofiler_page_migration_operation_t
Page migration event.
Definition fwd.h:334
@ ROCPROFILER_PAGE_MIGRATION_NONE
Unknown event.
Definition fwd.h:335
Agent Identifier.
Definition fwd.h:578
Context ID.
Definition fwd.h:539
ROCProfiler Record Correlation ID.
Definition fwd.h:555
Counter ID.
Definition fwd.h:586
Counter info struct version 0.
Definition fwd.h:742
Multi-dimensional struct of data used to describe GPU workgroup and grid sizes.
Definition fwd.h:603
ROCProfiler kernel dispatch information.
Definition fwd.h:690
ROCProfiler Profile Counting Counter Record per instance.
Definition fwd.h:720
Details for the dimension, including its size, for a counter record.
Definition fwd.h:707
Stores memory address for profiling.
Definition fwd.h:524
rocprofiler_tracing_operation_t operation
Specification of the rocprofiler_ompt_operation_t.
rocprofiler_address_t address
starting address for memory allocation
rocprofiler_page_migration_operation_t operation
ROCProfiler Buffer Correlation ID Retirement Tracer Record.
ROCProfiler Buffer HIP API Tracer Record.
ROCProfiler Buffer HSA API Tracer Record.
ROCProfiler Buffer Kernel Dispatch Tracer Record.
ROCProfiler Buffer Marker Tracer Record.
ROCProfiler Buffer Memory Allocation Tracer Record.
ROCProfiler Buffer Memory Copy Tracer Record.
ROCProfiler Buffer OMPT Tracer Record.
Additional trace data for OMPT target routines.
ROCProfiler Buffer Page Migration Tracer Record.
ROCProfiler Buffer RCCL API Record.
ROCProfiler Buffer Runtime Initialization Tracer Record.
ROCProfiler Buffer Scratch Memory Tracer Record.
rocprofiler_code_object_storage_type_t storage_type
storage type of the code object reader used to load the loaded code object
rocprofiler_address_t address
starting address for memory allocation
@ ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_MEMORY
@ ROCPROFILER_CODE_OBJECT_STORAGE_TYPE_FILE
ROCProfiler Code Object Kernel Symbol Tracer Callback Record.
ROCProfiler Code Object Load Tracer Callback Record.
ROCProfiler HIP runtime and compiler API Tracer Callback Data.
ROCProfiler HSA API Callback Data.
ROCProfiler Kernel Dispatch Callback Tracer Record.
ROCProfiler Marker Tracer Callback Data.
ROCProfiler Memory Allocation Tracer Record.
ROCProfiler Memory Copy Callback Tracer Record.
ROCProfiler OMPT Callback Data.
ROCProfiler RCCL API Callback Data.
ROCProfiler Scratch Memory Callback Data.
PC sampling configuration supported by a GPU agent.
Information about the GPU part where wave was executing at the moment of sampling.
ROCProfiler Host-Trap PC Sampling Record.
Sampled program counter.
Kernel dispatch data for profile counting callbacks.
ROCProfiler Profile Counting Counter Record Header Information.
void save_page_migration_args(ArchiveT &ar, rocprofiler_page_migration_operation_t op, rocprofiler_page_migration_args_t args, std::index_sequence< Idx, IdxTail... >)
void save(ArchiveT &ar, rocprofiler_context_id_t data)
void save_buffer_tracing_api_record(ArchiveT &ar, Tp data)
auto as_hex(Tp val, unsigned long width=0)
Definition utility.hpp:37
@ ROCPROFILER_OMPT_ID_target_submit_emi
Definition api_id.h:61
@ ROCPROFILER_OMPT_ID_target_emi
Definition api_id.h:59
@ ROCPROFILER_OMPT_ID_target_data_op_emi
Definition api_id.h:60
#define ROCP_SDK_SAVE_VALUE(NAME, VALUE)
#define ROCP_SDK_SPECIALIZE_PAGE_MIGRATION_ARG(ENUM_VALUE, UNION_ARG)
#define ROCP_SDK_SAVE_DATA_CSTR(FIELD)
#define ROCP_SDK_SAVE_DATA_BITFIELD(NAME, VALUE)
#define ROCP_SDK_SAVE_DATA_FIELD(FIELD)
#define ROCPROFILER_SDK_CEREAL_NAMESPACE_END
#define ROCPROFILER_SDK_CEREAL_NAMESPACE_BEGIN
#define ROCP_SDK_SAVE_DATA_VALUE(NAME, VALUE)
std::vector< value_type > operations
Definition name_info.hpp:61