SDK: No bg thread if no clients use SDK (#123)

* SDK: No bg thread if no clients use SDK

* Update CHANGELOG

---------

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
This commit is contained in:
Madsen, Jonathan
2025-02-06 08:34:56 -06:00
committed by GitHub
orang tua 90ae424c57
melakukan 0fbe6cc7b6
5 mengubah file dengan 73 tambahan dan 26 penghapusan
+28
Melihat File
@@ -34,6 +34,29 @@
#include <rocprofiler-sdk/registration.h>
#include <rocprofiler-sdk/rocprofiler.h>
#include <stdio.h>
#include <stdlib.h>
static void
thread_precreate(rocprofiler_runtime_library_t lib, void* tool_data)
{
uint32_t* priority = (uint32_t*) tool_data;
if(priority && *priority == 0)
{
fprintf(
stderr,
"Internal thread for rocprofiler-sdk should not be created when all tools return NULL "
"from rocprofiler_configure\n");
fflush(stderr);
abort();
}
(void) lib;
}
static uint32_t tool_priority = 0;
rocprofiler_tool_configure_result_t*
rocprofiler_configure(uint32_t version,
const char* runtime_version,
@@ -43,6 +66,8 @@ rocprofiler_configure(uint32_t version,
// set the client name
id->name = "Test C tool";
tool_priority = priority;
// compute major/minor/patch version info
uint32_t major = version / 10000;
uint32_t minor = (version % 10000) / 100;
@@ -57,6 +82,9 @@ rocprofiler_configure(uint32_t version,
patch,
runtime_version);
rocprofiler_at_internal_thread_create(
thread_precreate, NULL, ROCPROFILER_LIBRARY, &tool_priority);
// return pointer to configure data
return NULL;
}