Skip to content

Commit 4c316ff

Browse files
committed
Add SPM context tool support and output format support
1 parent efcb2fb commit 4c316ff

File tree

22 files changed

+356
-23
lines changed

22 files changed

+356
-23
lines changed

projects/rocprofiler-sdk/source/include/rocprofiler-sdk/cxx/serialization/save.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <rocprofiler-sdk/counters.h>
3333
#include <rocprofiler-sdk/device_counting_service.h>
3434
#include <rocprofiler-sdk/dispatch_counting_service.h>
35+
#include <rocprofiler-sdk/experimental/spm.h>
3536
#include <rocprofiler-sdk/external_correlation.h>
3637
#include <rocprofiler-sdk/fwd.h>
3738
#include <rocprofiler-sdk/hip.h>
@@ -524,6 +525,15 @@ save(ArchiveT& ar, rocprofiler_dispatch_counting_service_data_t data)
524525
ROCP_SDK_SAVE_DATA_FIELD(dispatch_info);
525526
}
526527

528+
template <typename ArchiveT>
529+
void
530+
save(ArchiveT& ar, rocprofiler_spm_dispatch_counting_service_data_t data)
531+
{
532+
ROCP_SDK_SAVE_DATA_FIELD(size);
533+
ROCP_SDK_SAVE_DATA_FIELD(correlation_id);
534+
ROCP_SDK_SAVE_DATA_FIELD(dispatch_info);
535+
}
536+
527537
template <typename ArchiveT>
528538
void
529539
save(ArchiveT& ar, rocprofiler_dispatch_counting_service_record_t data)
@@ -577,6 +587,17 @@ save(ArchiveT& ar, rocprofiler_counter_record_t data)
577587
ROCP_SDK_SAVE_DATA_FIELD(dispatch_id);
578588
}
579589

590+
template <typename ArchiveT>
591+
void
592+
save(ArchiveT& ar, rocprofiler_spm_counter_record_t data)
593+
{
594+
ROCP_SDK_SAVE_DATA_FIELD(dispatch_id);
595+
ROCP_SDK_SAVE_DATA_FIELD(id);
596+
ROCP_SDK_SAVE_DATA_FIELD(agent_id);
597+
ROCP_SDK_SAVE_DATA_FIELD(timestamp);
598+
ROCP_SDK_SAVE_DATA_FIELD(value);
599+
}
600+
580601
template <typename ArchiveT>
581602
void
582603
save(ArchiveT& ar, rocprofiler_buffer_tracing_hip_api_record_t data)

projects/rocprofiler-sdk/source/lib/output/buffered_output.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ using rccl_buffered_output_t =
185185
buffered_output<rocprofiler_buffer_tracing_rccl_api_record_t, domain_type::RCCL>;
186186
using counter_collection_buffered_output_t =
187187
buffered_output<tool_counter_record_t, domain_type::COUNTER_COLLECTION>;
188+
using spm_counter_collection_buffered_output_t =
189+
buffered_output<tool_spm_counter_record_t, domain_type::SPM_COUNTER_COLLECTION>;
190+
using spm_counter_records_buffered_output_t =
191+
buffered_output<tool_spm_counter_value_t, domain_type::SPM_COUNTER_VALUES>;
188192
using scratch_memory_buffered_output_t =
189193
buffered_output<rocprofiler_buffer_tracing_scratch_memory_record_t,
190194
domain_type::SCRATCH_MEMORY>;

projects/rocprofiler-sdk/source/lib/output/counter_info.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ namespace rocprofiler
3838
{
3939
namespace tool
4040
{
41-
constexpr auto type = domain_type::COUNTER_VALUES;
41+
constexpr auto counter_value = domain_type::COUNTER_VALUES;
42+
constexpr auto spm_counter_value = domain_type::SPM_COUNTER_VALUES;
4243

4344
tool_counter_record_t::container_type
4445
tool_counter_record_t::read() const
4546
{
4647
if(!record.fpos) return container_type{};
4748

48-
auto& _tmp_file = CHECK_NOTNULL(get_tmp_file_buffer<tool_counter_value_t>(type))->file;
49+
auto& _tmp_file = CHECK_NOTNULL(get_tmp_file_buffer<tool_counter_value_t>(counter_value))->file;
4950
return _tmp_file.read<tool_counter_value_t>(*record.fpos);
5051
}
5152

@@ -54,8 +55,28 @@ tool_counter_record_t::write(const tool_counter_record_t::container_type& _data)
5455
{
5556
if(_data.empty()) return;
5657

57-
auto& _tmp_file = CHECK_NOTNULL(get_tmp_file_buffer<tool_counter_value_t>(type))->file;
58+
auto& _tmp_file = CHECK_NOTNULL(get_tmp_file_buffer<tool_counter_value_t>(counter_value))->file;
5859
record.fpos = _tmp_file.write<tool_counter_value_t>(_data.data(), _data.size());
5960
}
61+
62+
tool_spm_counter_record_t::container_type
63+
tool_spm_counter_record_t::read() const
64+
{
65+
if(!record.fpos) return container_type{};
66+
67+
auto& _tmp_file =
68+
CHECK_NOTNULL(get_tmp_file_buffer<tool_spm_counter_value_t>(spm_counter_value))->file;
69+
return _tmp_file.read<tool_spm_counter_value_t>(*record.fpos);
70+
}
71+
72+
void
73+
tool_spm_counter_record_t::write(const tool_spm_counter_record_t::container_type& _data)
74+
{
75+
if(_data.empty()) return;
76+
77+
auto& _tmp_file =
78+
CHECK_NOTNULL(get_tmp_file_buffer<tool_spm_counter_value_t>(spm_counter_value))->file;
79+
record.fpos = _tmp_file.write<tool_spm_counter_value_t>(_data.data(), _data.size());
80+
}
6081
} // namespace tool
6182
} // namespace rocprofiler

projects/rocprofiler-sdk/source/lib/output/counter_info.hpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,44 @@ struct tool_counter_record_t
113113
container_type read() const;
114114
void write(const container_type& data);
115115
};
116+
117+
struct tool_spm_counter_value_t
118+
{
119+
rocprofiler_counter_id_t id = {};
120+
uint64_t value = 0;
121+
rocprofiler_timestamp_t timestamp = 0;
122+
rocprofiler_counter_instance_id_t instance_id = {};
123+
124+
template <typename ArchiveT>
125+
void save(ArchiveT& ar) const
126+
{
127+
ar(cereal::make_nvp("counter_id", id));
128+
ar(cereal::make_nvp("value", value));
129+
ar(cereal::make_nvp("timestamp", timestamp));
130+
ar(cereal::make_nvp("instance_id", instance_id));
131+
}
132+
};
133+
134+
struct tool_spm_counter_record_t
135+
{
136+
using container_type = std::vector<tool_spm_counter_value_t>;
137+
138+
uint64_t thread_id = 0;
139+
serialized_counter_record_t record = {};
140+
rocprofiler_spm_dispatch_counting_service_data_t dispatch_data = {};
141+
142+
template <typename ArchiveT>
143+
void save(ArchiveT& ar) const
144+
{
145+
auto tmp = read();
146+
ar(cereal::make_nvp("thread_id", thread_id));
147+
ar(cereal::make_nvp("dispatch_data", dispatch_data));
148+
ar(cereal::make_nvp("records", tmp));
149+
}
150+
151+
container_type read() const;
152+
void write(const container_type& data);
153+
};
116154
} // namespace tool
117155
} // namespace rocprofiler
118156

projects/rocprofiler-sdk/source/lib/output/domain_type.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ DEFINE_BUFFER_TYPE_NAME(PC_SAMPLING_STOCHASTIC,
6767
"PC_SAMPLING_STOCHASTIC",
6868
"pc_sampling_stochastic",
6969
"pc_sampling_stochastic_stats")
70+
DEFINE_BUFFER_TYPE_NAME(SPM_COUNTER_COLLECTION,
71+
"SPM_COUNTER_COLLECTION",
72+
"spm_counter_collection",
73+
"spm_counter_collection_stats")
74+
DEFINE_BUFFER_TYPE_NAME(SPM_COUNTER_VALUES,
75+
"SPM_COUNTER_VALUES",
76+
"SPM_counter_values",
77+
"SPM_counter_values") // unused
7078

7179
#undef DEFINE_BUFFER_TYPE_NAME
7280

projects/rocprofiler-sdk/source/lib/output/domain_type.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ enum class domain_type
4040
ROCDECODE,
4141
ROCJPEG,
4242
PC_SAMPLING_STOCHASTIC,
43+
SPM_COUNTER_COLLECTION,
44+
SPM_COUNTER_VALUES,
4345
LAST,
4446
};
4547

projects/rocprofiler-sdk/source/lib/output/generateCSV.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,6 @@ generate_csv(const output_config& cfg,
625625
const auto* kernel_info = tool_metadata.get_kernel_symbol(kernel_id);
626626
auto lds_block_size_v =
627627
(kernel_info->group_segment_size + (lds_block_size - 1)) & ~(lds_block_size - 1);
628-
629628
auto magnitude = [](rocprofiler_dim3_t dims) { return (dims.x * dims.y * dims.z); };
630629
auto row_ss = std::stringstream{};
631630
for(auto& [counter_id, counter_value] : counter_id_value)
@@ -1014,5 +1013,13 @@ generate_csv(const output_config& cfg,
10141013
ofs << _row.str() << std::flush;
10151014
}
10161015
}
1016+
1017+
void
1018+
generate_csv(const output_config& /* cfg*/,
1019+
const metadata& /*tool_metadata*/,
1020+
const generator<tool_spm_counter_record_t>& /*data*/,
1021+
const stats_entry_t& /*stats*/)
1022+
{}
1023+
10171024
} // namespace tool
10181025
} // namespace rocprofiler

projects/rocprofiler-sdk/source/lib/output/generateCSV.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ generate_csv(const output_config&
117117
const generator<rocprofiler_tool_pc_sampling_stochastic_record_t>& data,
118118
const stats_entry_t& stats);
119119

120+
void
121+
generate_csv(const output_config& cfg,
122+
const metadata& tool_metadata,
123+
const generator<tool_spm_counter_record_t>& data,
124+
const stats_entry_t& stats);
125+
120126
void
121127
generate_csv(const output_config& cfg,
122128
const metadata& tool_metadata,

projects/rocprofiler-sdk/source/lib/output/generateJSON.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ write_json(
198198
const generator<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t>& rocdecode_api_gen,
199199
const generator<rocprofiler_buffer_tracing_rocjpeg_api_record_t>& rocjpeg_api_gen,
200200
const generator<rocprofiler_tool_pc_sampling_host_trap_record_t>& pc_sampling_host_trap_gen,
201-
const generator<rocprofiler_tool_pc_sampling_stochastic_record_t>& pc_sampling_stochastic_gen)
201+
const generator<rocprofiler_tool_pc_sampling_stochastic_record_t>& pc_sampling_stochastic_gen,
202+
const generator<tool_spm_counter_record_t>& spm_gen)
202203
{
203204
// summary
204205
{
@@ -224,6 +225,7 @@ write_json(
224225
json_ar.setNextName("callback_records");
225226
json_ar.startNode();
226227
json_ar(cereal::make_nvp("counter_collection", counter_collection_gen));
228+
json_ar(cereal::make_nvp("SPM", spm_gen));
227229
json_ar.finishNode();
228230
}
229231

projects/rocprofiler-sdk/source/lib/output/generateJSON.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ write_json(
9898
const generator<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t>& rocdecode_api_gen,
9999
const generator<rocprofiler_buffer_tracing_rocjpeg_api_record_t>& rocjpeg_api_gen,
100100
const generator<rocprofiler_tool_pc_sampling_host_trap_record_t>& pc_sampling_host_trap_gen,
101-
const generator<rocprofiler_tool_pc_sampling_stochastic_record_t>& pc_sampling_stochastic_gen);
101+
const generator<rocprofiler_tool_pc_sampling_stochastic_record_t>& pc_sampling_stochastic_gen,
102+
const generator<tool_spm_counter_record_t>& spm_gen);
102103
} // namespace tool
103104
} // namespace rocprofiler

0 commit comments

Comments
 (0)