@@ -93,6 +93,8 @@ class RocProfilerService
93
93
std::map<uint64_t , std::string> m_kernel_info;
94
94
std::mutex m_kernel_info_mutex;
95
95
96
+ std::map<uint64_t , const rocprofiler_agent_t *> agent_info_map;
97
+
96
98
Channel m_channel;
97
99
98
100
static RocProfilerService* s_instance;
@@ -103,8 +105,6 @@ class RocProfilerService
103
105
104
106
static rocprofiler_buffer_id_t activity_buf;
105
107
106
- static std::map<uint64_t , const rocprofiler_agent_t *> s_agents;
107
-
108
108
void create_attributes (Caliper* c)
109
109
{
110
110
Attribute subs_attr = c->get_attribute (" subscription_event" );
@@ -211,7 +211,7 @@ class RocProfilerService
211
211
212
212
const char * kernel_name = s_instance->get_kernel_name (record->dispatch_info .kernel_id );
213
213
214
- uint64_t agent = s_agents .at (record->dispatch_info .agent_id .handle )->logical_node_id ;
214
+ uint64_t agent = s_instance-> agent_info_map .at (record->dispatch_info .agent_id .handle )->logical_node_id ;
215
215
216
216
const Variant data[] = {
217
217
Variant (CALI_TYPE_STRING, activity_name, len),
@@ -250,8 +250,8 @@ class RocProfilerService
250
250
&len
251
251
));
252
252
253
- uint64_t src_agent = s_agents .at (record->src_agent_id .handle )->logical_node_id ;
254
- uint64_t dst_agent = s_agents .at (record->dst_agent_id .handle )->logical_node_id ;
253
+ uint64_t src_agent = s_instance-> agent_info_map .at (record->src_agent_id .handle )->logical_node_id ;
254
+ uint64_t dst_agent = s_instance-> agent_info_map .at (record->dst_agent_id .handle )->logical_node_id ;
255
255
256
256
const Variant data[] = {
257
257
Variant (CALI_TYPE_STRING, activity_name, len),
@@ -378,6 +378,26 @@ class RocProfilerService
378
378
m_enable_snapshot_timestamps = config.get (" enable_snapshot_timestamps" ).to_bool ();
379
379
380
380
create_attributes (c);
381
+
382
+ // initialize rocprofiler agents
383
+ //
384
+
385
+ rocprofiler_query_available_agents_cb_t iterate_agents =
386
+ [](rocprofiler_agent_version_t , const void ** agents_arr, size_t num_agents, void * usr) {
387
+ for (size_t i = 0 ; i < num_agents; ++i) {
388
+ const auto * agent_v = static_cast <const rocprofiler_agent_v0_t *>(agents_arr[i]);
389
+ RocProfilerService* instance = static_cast <RocProfilerService*>(usr);
390
+ instance->agent_info_map .emplace (agent_v->id .handle , agent_v);
391
+ }
392
+ return ROCPROFILER_STATUS_SUCCESS;
393
+ };
394
+
395
+ ROCPROFILER_CALL (rocprofiler_query_available_agents (
396
+ ROCPROFILER_AGENT_INFO_VERSION_0,
397
+ iterate_agents,
398
+ sizeof (rocprofiler_agent_t ),
399
+ this
400
+ ));
381
401
}
382
402
383
403
public:
@@ -455,21 +475,6 @@ class RocProfilerService
455
475
nullptr
456
476
));
457
477
458
- rocprofiler_query_available_agents_cb_t iterate_agents =
459
- [](rocprofiler_agent_version_t , const void ** agents_arr, size_t num_agents, void *) {
460
- for (size_t i = 0 ; i < num_agents; ++i) {
461
- const auto * agent_v = static_cast <const rocprofiler_agent_v0_t *>(agents_arr[i]);
462
- s_agents.emplace (agent_v->id .handle , agent_v);
463
- }
464
- return ROCPROFILER_STATUS_SUCCESS;
465
- };
466
-
467
- ROCPROFILER_CALL (rocprofiler_query_available_agents (
468
- ROCPROFILER_AGENT_INFO_VERSION_0,
469
- iterate_agents,
470
- sizeof (rocprofiler_agent_t ),
471
- nullptr
472
- ));
473
478
// auto client_thread = rocprofiler_callback_thread_t{};
474
479
// ROCPROFILER_CALL(
475
480
// rocprofiler_create_callback_thread(&client_thread));
@@ -535,8 +540,6 @@ rocprofiler_context_id_t RocProfilerService::rocprofiler_ctx = {};
535
540
536
541
rocprofiler_buffer_id_t RocProfilerService::activity_buf = {};
537
542
538
- std::map<uint64_t , const rocprofiler_agent_t *> RocProfilerService::s_agents;
539
-
540
543
const char * RocProfilerService::s_spec = R"json(
541
544
{
542
545
"name": "rocprofiler",
0 commit comments