SWDEV-457922: Temporary fix to prevent multiple instances of either rocprofiler v1 or v2 to be running, whether it's interception or standalone mode.

The fix works by using a pid file and a lock file, similar to how firefox prevents multiple instances.

Change-Id: I4974a80bf920eaf0376a53410573c1cc74ec17ac


[ROCm/rocprofiler commit: 056156135d]
This commit is contained in:
Saurabh Verma
2024-05-17 18:32:06 -05:00
parent d7c2fa8867
commit c41bbe21d0
7 changed files with 176 additions and 4 deletions
@@ -39,6 +39,7 @@ THE SOFTWARE.
#include "util/exception.h"
#include "util/hsa_rsrc_factory.h"
#include "util/logger.h"
#include "core/profiling_lock.h"
#define PUBLIC_API __attribute__((visibility("default")))
#define CONSTRUCTOR_API __attribute__((constructor))
@@ -393,6 +394,7 @@ ROCPROFILER_EXPORT extern const uint32_t HSA_AMD_TOOL_PRIORITY = 25;
PUBLIC_API bool OnLoad(HsaApiTable* table, uint64_t runtime_version, uint64_t failed_tool_count,
const char* const* failed_tool_names) {
ONLOAD_TRACE_BEG();
ProfilingLock::Lock(PROFILER_V1_LOCK);
rocprofiler::SaveHsaApi(table);
rocprofiler::ProxyQueue::InitFactory();