SDK: counter collection serialization per device (#1157)

Migrates profiler_serializer class in QueueController to have an instance per-agent instead of one globally. Other changes in this commit are to allow for maps of the queues associated with each agent to be passed to profiler_serializer when it is turned on/off. Existing test cases cover whether or not the kernels are serialized (multistream app). New test case added to show that this serialization only occurs on a per device level with a kernel launched on one device waiting for a value to be set on the other.
Этот коммит содержится в:
Benjamin Welton
2024-10-25 13:13:36 -07:00
коммит произвёл GitHub
родитель 5e1643cf81
Коммит 4a5b1d98c2
13 изменённых файлов: 275 добавлений и 51 удалений
+31 -1
Просмотреть файл
@@ -22,6 +22,7 @@
#include "client.hpp"
#include <cstdint>
#include <fstream>
#include <functional>
#include <iostream>
@@ -74,6 +75,13 @@ get_buffer()
return buf;
}
std::unordered_map<uint64_t, std::vector<rocprofiler_record_dimension_info_t>>**
dimension_cache()
{
static std::unordered_map<uint64_t, std::vector<rocprofiler_record_dimension_info_t>>* cache;
return &cache;
}
/**
* For a given counter, query the dimensions that it has. Typically you will
* want to call this function once to get the dimensions and cache them.
@@ -81,6 +89,20 @@ get_buffer()
std::vector<rocprofiler_record_dimension_info_t>
counter_dimensions(rocprofiler_counter_id_t counter)
{
if(*dimension_cache() == nullptr) return {};
if((*dimension_cache())->count(counter.handle) > 0)
{
return (*dimension_cache())->at(counter.handle);
}
return {};
}
void
fill_dimension_cache(rocprofiler_counter_id_t counter)
{
assert(*dimension_cache() != nullptr);
std::vector<rocprofiler_record_dimension_info_t> dims;
rocprofiler_available_dimensions_cb_t cb =
[](rocprofiler_counter_id_t,
@@ -97,7 +119,7 @@ counter_dimensions(rocprofiler_counter_id_t counter)
};
ROCPROFILER_CALL(rocprofiler_iterate_counter_dimensions(counter, cb, &dims),
"Could not iterate counter dimensions");
return dims;
(*dimension_cache())->emplace(counter.handle, dims);
}
/**
@@ -251,6 +273,7 @@ build_profile_for_agent(rocprofiler_agent_id_t agent,
{
std::clog << "Counter: " << counter.handle << " " << version.name << "\n";
collect_counters.push_back(counter);
fill_dimension_cache(counter);
}
}
@@ -375,6 +398,10 @@ tool_fini(void* user_data)
auto* output_stream = static_cast<std::ostream*>(user_data);
*output_stream << std::flush;
if(output_stream != &std::cout && output_stream != &std::cerr) delete output_stream;
auto* tmp_ptr = *dimension_cache();
*dimension_cache() = nullptr;
delete tmp_ptr;
}
} // namespace
@@ -416,6 +443,9 @@ rocprofiler_configure(uint32_t version,
&tool_fini,
static_cast<void*>(output_stream)};
*dimension_cache() =
new std::unordered_map<uint64_t, std::vector<rocprofiler_record_dimension_info_t>>();
// return pointer to configure data
return &cfg;
}