Fix init order for getMetricIdMap (#341)

* Fix init order for getMetricIdMap

Ensure that getMetricIdMap() stays valid until the destruction
of the counting service. Adds a test to ensure that this behavior
is maintained (this test fails without this change).

* source formatting (clang-format v11) (#343)

Co-authored-by: bwelton <bwelton@users.noreply.github.com>

* cmake formatting (cmake-format) (#342)

Co-authored-by: bwelton <bwelton@users.noreply.github.com>

* Remove threading

* Update usage of rocprofiler::counters::get{Metric,MetricId}Map()

- uses common::static_object

* Update counter init_order testing

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: bwelton <bwelton@users.noreply.github.com>
Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
Этот коммит содержится в:
Benjamin Welton
2024-01-11 23:35:12 -08:00
коммит произвёл GitHub
родитель 78dd471110
Коммит ef71cc38c1
9 изменённых файлов: 225 добавлений и 15 удалений
+3 -2
Просмотреть файл
@@ -20,6 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <rocprofiler-sdk/fwd.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <fmt/core.h>
@@ -45,7 +46,7 @@ extern "C" {
rocprofiler_status_t ROCPROFILER_API
rocprofiler_query_counter_name(rocprofiler_counter_id_t counter_id, const char** name, size_t* size)
{
const auto& id_map = rocprofiler::counters::getMetricIdMap();
const auto& id_map = *CHECK_NOTNULL(rocprofiler::counters::getMetricIdMap());
if(const auto* metric_ptr = rocprofiler::common::get_val(id_map, counter_id.handle))
{
@@ -75,7 +76,7 @@ rocprofiler_query_counter_instance_count(rocprofiler_agent_t agent,
rocprofiler_counter_id_t counter_id,
size_t* instance_count)
{
const auto& id_map = rocprofiler::counters::getMetricIdMap();
const auto& id_map = *CHECK_NOTNULL(rocprofiler::counters::getMetricIdMap());
const auto* metric_ptr = rocprofiler::common::get_val(id_map, counter_id.handle);
if(!metric_ptr) return ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND;