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:
@@ -36,7 +36,8 @@ set_tests_properties(
|
||||
PASS_REGULAR_EXPRESSION
|
||||
"Test C tool \\(priority=0\\) is using rocprofiler-sdk v([0-9]+\\.[0-9]+\\.[0-9]+)"
|
||||
FAIL_REGULAR_EXPRESSION
|
||||
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")
|
||||
"${ROCPROFILER_DEFAULT_FAIL_REGEX}|Internal thread for rocprofiler-sdk should not be created"
|
||||
)
|
||||
|
||||
# this test uses ROCP_TOOL_LIBRARIES instead of LD_PRELOAD
|
||||
add_test(NAME test-c-tool-rocp-tool-lib-execute COMMAND $<TARGET_FILE:transpose> 1)
|
||||
@@ -59,4 +60,5 @@ set_tests_properties(
|
||||
PASS_REGULAR_EXPRESSION
|
||||
"Test C tool \\(priority=0\\) is using rocprofiler-sdk v([0-9]+\\.[0-9]+\\.[0-9]+)"
|
||||
FAIL_REGULAR_EXPRESSION
|
||||
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")
|
||||
"${ROCPROFILER_DEFAULT_FAIL_REGEX}|Internal thread for rocprofiler-sdk should not be created"
|
||||
)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user