Only check lock if counter collection is used
Only check the lock if counter collection is being attempted by the profiler. Not when it is loaded. SWDEV-474455 Change-Id: Ie14de3c8db57e0cbd279ffca51c333a375ca8654 Signed-off-by: Benjamin Welton <bewelton@amd.com>
This commit is contained in:
committed by
Saurabh Verma
parent
95ed584e6d
commit
0be3e07388
@@ -325,6 +325,23 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_create_filter(
|
||||
// rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_FILTER_DATA_CORRUPTED); if (error_code == 0)
|
||||
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_FILTER_DATA_MISMATCH);
|
||||
auto& rocprofiler_singleton = rocprofiler::ROCProfiler_Singleton::GetInstance();
|
||||
switch (filter_kind) {
|
||||
case ROCPROFILER_COUNTERS_COLLECTION:
|
||||
case ROCPROFILER_COUNTERS_SAMPLER:
|
||||
try{
|
||||
ProfilingLock::Lock(PROFILER_V2_LOCK);
|
||||
}catch(std::exception& e){
|
||||
std::cout << e.what();
|
||||
abort();
|
||||
}
|
||||
break;
|
||||
case ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION:
|
||||
case ROCPROFILER_PC_SAMPLING_COLLECTION:
|
||||
case ROCPROFILER_ATT_TRACE_COLLECTION:
|
||||
case ROCPROFILER_SPM_COLLECTION:
|
||||
case ROCPROFILER_API_TRACE:
|
||||
break;
|
||||
}
|
||||
if (!rocprofiler_singleton.FindSession(session_id))
|
||||
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
|
||||
*filter_id = rocprofiler_singleton
|
||||
@@ -507,6 +524,12 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_device_profiling_session_create
|
||||
int cpu_index, int gpu_index) {
|
||||
API_METHOD_PREFIX
|
||||
std::vector<std::string> counters(counter_names, counter_names + num_counters);
|
||||
try {
|
||||
ProfilingLock::Lock(PROFILER_V2_LOCK);
|
||||
} catch (std::exception& e) {
|
||||
std::cout << e.what();
|
||||
abort();
|
||||
}
|
||||
*session_id =
|
||||
rocprofiler::ROCProfiler_Singleton::GetInstance().CreateDeviceProfilingSession(counters, cpu_index, gpu_index);
|
||||
API_METHOD_SUFFIX
|
||||
@@ -618,7 +641,6 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
|
||||
uint64_t failed_tool_count, const char* const* failed_tool_names) {
|
||||
if (started) rocprofiler::fatal("HSA Tool started already!");
|
||||
started = true;
|
||||
ProfilingLock::Lock(PROFILER_V2_LOCK);
|
||||
rocprofiler::HSASupport_Singleton::GetInstance().HSAInitialize(table);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -229,6 +229,9 @@
|
||||
<metric name="TOTAL_16_OPS" expr=(SQ_INSTS_VALU_FMA_F16*2+SQ_INSTS_VALU_ADD_F16+SQ_INSTS_VALU_MUL_F16+SQ_INSTS_VALU_TRANS_F16)*64+((SQ_INSTS_VALU_MFMA_MOPS_F16+SQ_INSTS_VALU_MFMA_MOPS_BF16)*512) descr="The number of 16 bits OPS executed"></metric>
|
||||
<metric name="TOTAL_32_OPS" expr=(SQ_INSTS_VALU_FMA_F32*2+SQ_INSTS_VALU_INT32+SQ_INSTS_VALU_ADD_F32+SQ_INSTS_VALU_MUL_F32+SQ_INSTS_VALU_TRANS_F32)*64+(SQ_INSTS_VALU_MFMA_MOPS_F32*512) descr="The number of 32 bits OPS executed"></metric>
|
||||
<metric name="TOTAL_64_OPS" expr=(SQ_INSTS_VALU_FMA_F64*2+SQ_INSTS_VALU_INT64+SQ_INSTS_VALU_ADD_F64+SQ_INSTS_VALU_MUL_F64)*64+(SQ_INSTS_VALU_MFMA_MOPS_F64*512) descr="The number of 64 bits OPS executed"></metric>
|
||||
<metric name="ACTIVE_CYCLES" expr=GRBM_GUI_ACTIVE descr="Active Cycles"></metric>
|
||||
<metric name="ELAPSED_CYCLES" expr=GRBM_COUNT descr="Elapsed Cycles"></metric>
|
||||
<metric name="ACTIVE_WAVES" expr=SQ_WAVES descr="Active Waves"></metric>
|
||||
|
||||
<metric name="AggSysCycles" expr=GRBM_GUI_ACTIVE*CU_NUM descr="Unit: cycles"></metric>
|
||||
## IP Block Utilization Metrics
|
||||
@@ -482,6 +485,9 @@
|
||||
<metric name="TOTAL_16_OPS" expr=(SQ_INSTS_VALU_FMA_F16*2+SQ_INSTS_VALU_ADD_F16+SQ_INSTS_VALU_MUL_F16+SQ_INSTS_VALU_TRANS_F16)*64+((SQ_INSTS_VALU_MFMA_MOPS_F16+SQ_INSTS_VALU_MFMA_MOPS_BF16)*512) descr="The number of 16 bits OPS executed"></metric>
|
||||
<metric name="TOTAL_32_OPS" expr=(SQ_INSTS_VALU_FMA_F32*2+SQ_INSTS_VALU_INT32+SQ_INSTS_VALU_ADD_F32+SQ_INSTS_VALU_MUL_F32+SQ_INSTS_VALU_TRANS_F32)*64+(SQ_INSTS_VALU_MFMA_MOPS_F32*512) descr="The number of 32 bits OPS executed"></metric>
|
||||
<metric name="TOTAL_64_OPS" expr=(SQ_INSTS_VALU_FMA_F64*2+SQ_INSTS_VALU_INT64+SQ_INSTS_VALU_ADD_F64+SQ_INSTS_VALU_MUL_F64)*64+(SQ_INSTS_VALU_MFMA_MOPS_F64*512) descr="The number of 64 bits OPS executed"></metric>
|
||||
<metric name="ACTIVE_CYCLES" expr=GRBM_GUI_ACTIVE/XCC_NUM descr="Active Cycles"></metric>
|
||||
<metric name="ELAPSED_CYCLES" expr=GRBM_COUNT/XCC_NUM descr="Elapsed Cycles"></metric>
|
||||
<metric name="ACTIVE_WAVES" expr=SQ_WAVES descr="Active Waves"></metric>
|
||||
</gfx940_expr>
|
||||
|
||||
<gfx10_expr>
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <sstream>
|
||||
#include <sstream>
|
||||
#include <cstring>
|
||||
#include "util/exception.h"
|
||||
#include "profiling_lock.h"
|
||||
#include <stdexcept>
|
||||
|
||||
#define ROCPROFILER_LOCK_FILE "/tmp/rocprofiler_process.lock"
|
||||
#define ROCPROFILER_PID_FILE "/tmp/rocprofiler.pid"
|
||||
@@ -67,12 +67,12 @@ bool check_process_exists(int pid) {
|
||||
}
|
||||
|
||||
void terminate_current_profiler_instance() {
|
||||
EXC_RAISING(
|
||||
0,
|
||||
"\nA profiling instance already exists! Multiple profiling instances are not "
|
||||
"allowed.\nCheck "
|
||||
<< ROCPROFILER_PID_FILE
|
||||
<< " and kill the process, delete this .pid file and try again.\nTerminating ...\n");
|
||||
std::stringstream oss;
|
||||
oss << "\nA profiling instance already exists! Multiple profiling instances are not "
|
||||
<< "allowed.\nCheck " << ROCPROFILER_PID_FILE
|
||||
<< " and kill the process, delete this .pid file and try again.\nTerminating "
|
||||
"...\n";
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,8 @@ void ProfilingLock::Lock(LockMode mode) {
|
||||
bool is_standalone_mode_v1 = check_standalone_mode() && (mode == PROFILER_V1_LOCK);
|
||||
|
||||
ProfilingLock* profiling_lock = Instance();
|
||||
// Check if we have already locked in this process
|
||||
if (profiling_lock->already_locked.exchange(true)) return;
|
||||
if (file_exists(profiling_lock->pid_file)) {
|
||||
profiling_lock->lock = acquire_lock(profiling_lock->lock_file);
|
||||
if (profiling_lock->lock < 1) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
#ifndef _SRC_CORE_PROFILING_LOCK_H
|
||||
#define _SRC_CORE_PROFILING_LOCK_H
|
||||
#include <atomic>
|
||||
|
||||
enum LockMode{
|
||||
PROFILER_V1_LOCK,
|
||||
@@ -18,6 +19,7 @@ private:
|
||||
|
||||
const char *lock_file;
|
||||
const char *pid_file;
|
||||
std::atomic<bool> already_locked{false};
|
||||
int lock;
|
||||
};
|
||||
|
||||
|
||||
@@ -394,7 +394,6 @@ 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();
|
||||
|
||||
@@ -488,6 +487,7 @@ PUBLIC_API hsa_status_t rocprofiler_open(hsa_agent_t agent, rocprofiler_feature_
|
||||
uint32_t feature_count, rocprofiler_t** handle,
|
||||
uint32_t mode, rocprofiler_properties_t* properties) {
|
||||
API_METHOD_PREFIX
|
||||
ProfilingLock::Lock(PROFILER_V1_LOCK);
|
||||
rocprofiler::util::HsaRsrcFactory* hsa_rsrc = &rocprofiler::util::HsaRsrcFactory::Instance();
|
||||
const rocprofiler::util::AgentInfo* agent_info = hsa_rsrc->GetAgentInfo(agent);
|
||||
if (agent_info == NULL) {
|
||||
@@ -673,6 +673,7 @@ rocprofiler_pool_open(hsa_agent_t agent, // GPU handle
|
||||
rocprofiler_pool_properties_t* properties) // pool properties
|
||||
{
|
||||
API_METHOD_PREFIX
|
||||
ProfilingLock::Lock(PROFILER_V1_LOCK);
|
||||
rocprofiler::util::HsaRsrcFactory* hsa_rsrc = &rocprofiler::util::HsaRsrcFactory::Instance();
|
||||
const rocprofiler::util::AgentInfo* agent_info = hsa_rsrc->GetAgentInfo(agent);
|
||||
if (agent_info == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user