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>
This commit is contained in:
Benjamin Welton
2024-01-11 23:35:12 -08:00
committed by GitHub
parent 78dd471110
commit ef71cc38c1
9 changed files with 225 additions and 15 deletions
@@ -20,6 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <glog/logging.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include "lib/common/synchronized.hpp"
@@ -49,7 +50,7 @@ rocprofiler_create_profile_config(rocprofiler_agent_t agent,
std::shared_ptr<rocprofiler::counters::profile_config> config =
std::make_shared<rocprofiler::counters::profile_config>();
const auto& id_map = rocprofiler::counters::getMetricIdMap();
const auto& id_map = *CHECK_NOTNULL(rocprofiler::counters::getMetricIdMap());
for(size_t i = 0; i < counters_count; i++)
{