Removing ROCMTools naming from ROCProfiler project

Change-Id: Ibd6211e031157f68a1bc3dd8dd77385e695cb700
This commit is contained in:
Ammar ELWazir
2023-05-30 19:21:14 +00:00
committed by Ammar ELWazir
parent 54222bb4ae
commit 4bcef6b8de
85 changed files with 749 additions and 743 deletions
+1 -1
View File
@@ -153,7 +153,7 @@ file(GLOB ROCPROFILER_PROFILER_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/
file(GLOB ROCPROFILER_TRACER_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/tracer/*.cpp)
file(GLOB ROCPROFILER_ROCTRACER_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/tracer/src/*.cpp)
file(GLOB ROCPROFILER_ATT_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/att/att.cpp)
file(GLOB ROCPROFILER_CLASS_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rocmtool.cpp)
file(GLOB ROCPROFILER_CLASS_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rocprofiler_singleton.cpp)
file(GLOB ROCPROFILER_SPM_SRC_FILES ${PROJECT_SOURCE_DIR}/src/core/session/spm/spm.cpp)
@@ -18,7 +18,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. */
#include "rocmtool.h"
#include "rocprofiler_singleton.h"
#include <sys/syscall.h>
#include <unistd.h>
@@ -40,23 +40,23 @@ extern std::mutex sessions_pending_signal_lock;
static inline uint32_t GetTid() { return syscall(__NR_gettid); }
namespace rocmtools {
namespace rocprofiler {
rocmtool* rocmtool_obj;
ROCProfiler_Singleton* rocprofiler_singleton;
// Constructor of rocmtool
// Constructor of ROCProfiler
// Takes the buffer size, a buffer callback function and a buffer flush
// interval to allocate a buffer pool using GenericStorage Also takes the
// replay mode (application replay/kernel replay/user replay) to set the replay
// mode for the rocmtool class object
rocmtool::rocmtool() : current_session_id_(rocprofiler_session_id_t{0}) {}
// mode for the rocprofiler class object
ROCProfiler_Singleton::ROCProfiler_Singleton() : current_session_id_(rocprofiler_session_id_t{0}) {}
// Destructor of rocmtool
// Destructor of rocprofiler_singleton
// deletes the buffer pool
// Iterates over its session map and resets each session in its internal
// session map and clears them from the map. Pops labels from the range stack
// and deletes the stack.
rocmtool::~rocmtool() {
ROCProfiler_Singleton::~ROCProfiler_Singleton() {
// {
// std::lock_guard<std::mutex> lock(session_map_lock_);
// if (!sessions_.empty()) {
@@ -69,31 +69,31 @@ rocmtool::~rocmtool() {
Counter::ClearBasicCounters();
}
bool rocmtool::FindAgent(rocprofiler_agent_id_t agent_id) { return true; }
size_t rocmtool::GetAgentInfoSize(rocprofiler_agent_info_kind_t kind, rocprofiler_agent_id_t agent_id) {
bool ROCProfiler_Singleton::FindAgent(rocprofiler_agent_id_t agent_id) { return true; }
size_t ROCProfiler_Singleton::GetAgentInfoSize(rocprofiler_agent_info_kind_t kind, rocprofiler_agent_id_t agent_id) {
return 0;
}
const char* rocmtool::GetAgentInfo(rocprofiler_agent_info_kind_t kind,
const char* ROCProfiler_Singleton::GetAgentInfo(rocprofiler_agent_info_kind_t kind,
rocprofiler_agent_id_t agent_id) {
return "";
}
// TODO(aelwazir): Implement Queue Query
bool rocmtool::FindQueue(rocprofiler_queue_id_t queue_id) { return true; }
size_t rocmtool::GetQueueInfoSize(rocprofiler_queue_info_kind_t kind, rocprofiler_queue_id_t queue_id) {
bool ROCProfiler_Singleton::FindQueue(rocprofiler_queue_id_t queue_id) { return true; }
size_t ROCProfiler_Singleton::GetQueueInfoSize(rocprofiler_queue_info_kind_t kind, rocprofiler_queue_id_t queue_id) {
return 0;
}
const char* rocmtool::GetQueueInfo(rocprofiler_queue_info_kind_t kind,
const char* ROCProfiler_Singleton::GetQueueInfo(rocprofiler_queue_info_kind_t kind,
rocprofiler_queue_id_t queue_id) {
return "";
}
bool rocmtool::FindSession(rocprofiler_session_id_t session_id) {
bool ROCProfiler_Singleton::FindSession(rocprofiler_session_id_t session_id) {
std::lock_guard<std::mutex> lock(session_map_lock_);
return sessions_.find(session_id.handle) != sessions_.end();
}
rocprofiler_session_id_t rocmtool::CreateSession(rocprofiler_replay_mode_t replay_mode) {
rocprofiler_session_id_t ROCProfiler_Singleton::CreateSession(rocprofiler_replay_mode_t replay_mode) {
rocprofiler_session_id_t session_id = rocprofiler_session_id_t{GenerateUniqueSessionId()};
{
std::lock_guard<std::mutex> lock(session_map_lock_);
@@ -102,7 +102,7 @@ rocprofiler_session_id_t rocmtool::CreateSession(rocprofiler_replay_mode_t repla
return session_id;
}
void rocmtool::DestroySession(rocprofiler_session_id_t session_id) {
void ROCProfiler_Singleton::DestroySession(rocprofiler_session_id_t session_id) {
while (GetCurrentActiveInterruptSignalsCount() != 0) {
}
@@ -125,12 +125,12 @@ void rocmtool::DestroySession(rocprofiler_session_id_t session_id) {
}
}
bool rocmtool::FindDeviceProfilingSession(rocprofiler_session_id_t session_id) {
bool ROCProfiler_Singleton::FindDeviceProfilingSession(rocprofiler_session_id_t session_id) {
std::lock_guard<std::mutex> lock(device_profiling_session_map_lock_);
return dev_profiling_sessions_.find(session_id.handle) != dev_profiling_sessions_.end();
}
rocprofiler_session_id_t rocmtool::CreateDeviceProfilingSession(std::vector<std::string> counters,
rocprofiler_session_id_t ROCProfiler_Singleton::CreateDeviceProfilingSession(std::vector<std::string> counters,
int cpu_agent_index,
int gpu_agent_index) {
rocprofiler_session_id_t session_id;
@@ -149,7 +149,7 @@ rocprofiler_session_id_t rocmtool::CreateDeviceProfilingSession(std::vector<std:
return session_id;
}
void rocmtool::DestroyDeviceProfilingSession(rocprofiler_session_id_t session_id) {
void ROCProfiler_Singleton::DestroyDeviceProfilingSession(rocprofiler_session_id_t session_id) {
{
std::lock_guard<std::mutex> lock(device_profiling_session_map_lock_);
ASSERTM(dev_profiling_sessions_.find(session_id.handle) != dev_profiling_sessions_.end(),
@@ -159,15 +159,15 @@ void rocmtool::DestroyDeviceProfilingSession(rocprofiler_session_id_t session_id
}
}
DeviceProfileSession* rocmtool::GetDeviceProfilingSession(rocprofiler_session_id_t session_id) {
DeviceProfileSession* ROCProfiler_Singleton::GetDeviceProfilingSession(rocprofiler_session_id_t session_id) {
std::lock_guard<std::mutex> lock(device_profiling_session_map_lock_);
assert(dev_profiling_sessions_.find(session_id.handle) != dev_profiling_sessions_.end() &&
"Error: Can't find the session!");
return dev_profiling_sessions_.at(session_id.handle);
}
bool rocmtool::HasActiveSession() { return GetCurrentSessionId().handle > 0; }
bool rocmtool::IsActiveSession(rocprofiler_session_id_t session_id) {
bool ROCProfiler_Singleton::HasActiveSession() { return GetCurrentSessionId().handle > 0; }
bool ROCProfiler_Singleton::IsActiveSession(rocprofiler_session_id_t session_id) {
return (GetCurrentSessionId().handle == session_id.handle);
}
@@ -176,26 +176,26 @@ bool rocmtool::IsActiveSession(rocprofiler_session_id_t session_id) {
// If a given session id doesn't exist, it throws an assertion.
// If a session object exists for the given session id, the session object is
// returned.
Session* rocmtool::GetSession(rocprofiler_session_id_t session_id) {
Session* ROCProfiler_Singleton::GetSession(rocprofiler_session_id_t session_id) {
std::lock_guard<std::mutex> lock(session_map_lock_);
assert(sessions_.find(session_id.handle) != sessions_.end() && "Error: Can't find the session!");
return sessions_.at(session_id.handle);
}
// Get Current Session ID
rocprofiler_session_id_t rocmtool::GetCurrentSessionId() { return current_session_id_; }
rocprofiler_session_id_t ROCProfiler_Singleton::GetCurrentSessionId() { return current_session_id_; }
void rocmtool::SetCurrentActiveSession(rocprofiler_session_id_t session_id) {
void ROCProfiler_Singleton::SetCurrentActiveSession(rocprofiler_session_id_t session_id) {
current_session_id_ = session_id;
}
uint64_t rocmtool::GetUniqueRecordId() { return records_counter_.fetch_add(1); }
uint64_t ROCProfiler_Singleton::GetUniqueRecordId() { return records_counter_.fetch_add(1); }
uint64_t rocmtool::GetUniqueKernelDispatchId() {
uint64_t ROCProfiler_Singleton::GetUniqueKernelDispatchId() {
return kernel_dispatch_counter_.fetch_add(1, std::memory_order_relaxed);
}
size_t rocmtool::GetKernelInfoSize(rocprofiler_kernel_info_kind_t kind,
size_t ROCProfiler_Singleton::GetKernelInfoSize(rocprofiler_kernel_info_kind_t kind,
rocprofiler_kernel_id_t kernel_id) {
switch (kind) {
case ROCPROFILER_KERNEL_NAME:
@@ -205,7 +205,7 @@ size_t rocmtool::GetKernelInfoSize(rocprofiler_kernel_info_kind_t kind,
return 0;
}
}
const char* rocmtool::GetKernelInfo(rocprofiler_kernel_info_kind_t kind,
const char* ROCProfiler_Singleton::GetKernelInfo(rocprofiler_kernel_info_kind_t kind,
rocprofiler_kernel_id_t kernel_id) {
switch (kind) {
case ROCPROFILER_KERNEL_NAME:
@@ -217,19 +217,20 @@ const char* rocmtool::GetKernelInfo(rocprofiler_kernel_info_kind_t kind,
}
// TODO(aelwazir): To be implemented
bool rocmtool::CheckFilterData(rocprofiler_filter_kind_t filter_kind,
bool ROCProfiler_Singleton::CheckFilterData(rocprofiler_filter_kind_t filter_kind,
rocprofiler_filter_data_t filter_data) {
return true;
}
// End of ROCMTool Class
// End of ROCProfiler_Singleton Class
rocmtool* GetROCMToolObj() { return rocmtool_obj; }
ROCProfiler_Singleton* GetROCProfilerSingleton() { return rocprofiler_singleton; }
void InitROCMToolObj() { rocmtool_obj = new rocmtool; }
void ResetROCMToolObj() {
delete rocmtool_obj;
// if (rocmtool_obj) rocmtool_obj.reset();
void InitROCProfilerSingleton() { rocprofiler_singleton = new ROCProfiler_Singleton; }
void ResetROCProfilerSingleton() {
delete rocprofiler_singleton;
// TODO(aelwazir): We need to use std::optional or std::unique_ptr
// if (rocprofiler_singleton) rocprofiler_singleton.reset();
}
rocprofiler_timestamp_t GetCurrentTimestamp() { return hsa_support::GetCurrentTimestampNS(); }
@@ -239,4 +240,4 @@ rocprofiler_status_t IterateCounters(rocprofiler_counters_info_callback_t counte
return ROCPROFILER_STATUS_ERROR;
}
} // namespace rocmtools
} // namespace rocprofiler
@@ -18,8 +18,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. */
#ifndef SRC_TOOLS_ROCMTOOL_H_
#define SRC_TOOLS_ROCMTOOL_H_
#ifndef SRC_TOOLS_ROCPROFILER_SINGLETON_H_
#define SRC_TOOLS_ROCPROFILER_SINGLETON_H_
#include <hsa/hsa_ven_amd_aqlprofile.h>
@@ -42,12 +42,12 @@
#include "src/core/session/session.h"
#include "src/core/session/device_profiling.h"
namespace rocmtools {
namespace rocprofiler {
class rocmtool {
class ROCProfiler_Singleton {
public:
rocmtool();
~rocmtool();
ROCProfiler_Singleton();
~ROCProfiler_Singleton();
bool FindAgent(rocprofiler_agent_id_t agent_id);
size_t GetAgentInfoSize(rocprofiler_agent_info_kind_t kind, rocprofiler_agent_id_t agent_id);
@@ -98,7 +98,7 @@ class rocmtool {
* identical if the same kernel is dispatched twice. Currently, this
* identifier is written to the `reserved2` field of the dispatch packet when
* its launch is intercepted, but this could change: a future version of
* ROCmtools may instead attempt to identify a kernel by a key with high
* ROCProfiler may instead attempt to identify a kernel by a key with high
* _probability_ of uniqueness: for example, a combination of the kernel's
* name, the queue ID to which it was dispatched, and the offset of the queue
* write pointer is likely sufficient to associate PC samples with a running
@@ -109,14 +109,14 @@ class rocmtool {
std::atomic<uint64_t> kernel_dispatch_counter_{1};
};
void InitROCMToolObj();
void ResetROCMToolObj();
rocmtool* GetROCMToolObj();
void InitROCProfilerSingleton();
void ResetROCProfilerSingleton();
ROCProfiler_Singleton* GetROCProfilerSingleton();
rocprofiler_timestamp_t GetCurrentTimestamp();
rocprofiler_status_t IterateCounters(rocprofiler_counters_info_callback_t counters_info_callback);
} // namespace rocmtools
} // namespace rocprofiler
#endif // SRC_TOOLS_ROCMTOOL_H_
#endif // SRC_TOOLS_ROCPROFILER_SINGLETON_H_
@@ -1,7 +1,7 @@
#include <atomic>
#include "src/core/hsa/hsa_support.h"
#include "src/api/rocmtool.h"
#include "src/api/rocprofiler_singleton.h"
#include "src/utils/helper.h"
#include "rocprofiler.h"
@@ -12,7 +12,7 @@
try {
#define API_METHOD_SUFFIX \
} \
catch (rocmtools::Exception & e) { \
catch (rocprofiler::Exception & e) { \
std::cout << __FUNCTION__ << "(), " << e.what(); \
} \
return err;
@@ -20,7 +20,7 @@
#define API_INIT_CHECKER \
API_METHOD_PREFIX \
if (!api_started.load(std::memory_order_relaxed)) \
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_NOT_INITIALIZED);
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_NOT_INITIALIZED);
std::atomic<bool> api_started{false};
@@ -32,9 +32,9 @@ ROCPROFILER_API uint32_t rocprofiler_version_minor() { return ROCPROFILER_VERSIO
ROCPROFILER_API const char* rocprofiler_error_str(rocprofiler_status_t status) {
switch (status) {
case ROCPROFILER_STATUS_ERROR_ALREADY_INITIALIZED:
return "ROCMTool is already initialized\n";
return "ROCProfiler is already initialized\n";
case ROCPROFILER_STATUS_ERROR_NOT_INITIALIZED:
return "ROCMTool is not initialized or already destroyed\n";
return "ROCProfiler is not initialized or already destroyed\n";
case ROCPROFILER_STATUS_ERROR_SESSION_MISSING_BUFFER:
return "Missing Buffer for a session\n";
case ROCPROFILER_STATUS_ERROR_TIMESTAMP_NOT_APPLICABLE:
@@ -111,8 +111,8 @@ ROCPROFILER_API const char* rocprofiler_error_str(rocprofiler_status_t status) {
ROCPROFILER_API rocprofiler_status_t rocprofiler_initialize() {
API_METHOD_PREFIX
if (api_started.load(std::memory_order_relaxed))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_ALREADY_INITIALIZED);
rocmtools::InitROCMToolObj();
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_ALREADY_INITIALIZED);
rocprofiler::InitROCProfilerSingleton();
api_started.exchange(true, std::memory_order_release);
API_METHOD_SUFFIX
}
@@ -120,23 +120,23 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_initialize() {
// Finalize the API
ROCPROFILER_API rocprofiler_status_t rocprofiler_finalize() {
API_INIT_CHECKER
rocmtools::ResetROCMToolObj();
rocprofiler::ResetROCProfilerSingleton();
api_started.exchange(false, std::memory_order_release);
API_METHOD_SUFFIX
}
ROCPROFILER_API rocprofiler_status_t rocprofiler_get_timestamp(rocprofiler_timestamp_t* timestamp) {
API_INIT_CHECKER
*timestamp = rocmtools::GetCurrentTimestamp();
*timestamp = rocprofiler::GetCurrentTimestamp();
if (timestamp->value <= 0)
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TIMESTAMP_NOT_APPLICABLE);
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TIMESTAMP_NOT_APPLICABLE);
API_METHOD_SUFFIX
}
ROCPROFILER_API rocprofiler_status_t
rocprofiler_iterate_counters(rocprofiler_counters_info_callback_t counters_info_callback) {
API_INIT_CHECKER
return rocmtools::IterateCounters(counters_info_callback);
return rocprofiler::IterateCounters(counters_info_callback);
API_METHOD_SUFFIX
}
@@ -144,10 +144,10 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_agent_info_size(rocprofil
rocprofiler_agent_id_t agent_id,
size_t* data_size) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindAgent(agent_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_AGENT_NOT_FOUND);
*data_size = rocmtools::GetROCMToolObj()->GetAgentInfoSize(kind, agent_id);
if (*data_size <= 0) throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_AGENT_INFORMATION_MISSING);
if (!rocprofiler::GetROCProfilerSingleton()->FindAgent(agent_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_AGENT_NOT_FOUND);
*data_size = rocprofiler::GetROCProfilerSingleton()->GetAgentInfoSize(kind, agent_id);
if (*data_size <= 0) throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_AGENT_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -155,10 +155,10 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_agent_info(rocprofiler_ag
rocprofiler_agent_id_t agent_id,
const char** data) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindAgent(agent_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_AGENT_NOT_FOUND);
if (!(*data = rocmtools::GetROCMToolObj()->GetAgentInfo(kind, agent_id)))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_AGENT_INFORMATION_MISSING);
if (!rocprofiler::GetROCProfilerSingleton()->FindAgent(agent_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_AGENT_NOT_FOUND);
if (!(*data = rocprofiler::GetROCProfilerSingleton()->GetAgentInfo(kind, agent_id)))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_AGENT_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -166,10 +166,10 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_queue_info_size(rocprofil
rocprofiler_queue_id_t queue_id,
size_t* data_size) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindQueue(queue_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_QUEUE_NOT_FOUND);
*data_size = rocmtools::GetROCMToolObj()->GetQueueInfoSize(kind, queue_id);
if (*data_size <= 0) throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_QUEUE_INFORMATION_MISSING);
if (!rocprofiler::GetROCProfilerSingleton()->FindQueue(queue_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_QUEUE_NOT_FOUND);
*data_size = rocprofiler::GetROCProfilerSingleton()->GetQueueInfoSize(kind, queue_id);
if (*data_size <= 0) throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_QUEUE_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -177,10 +177,10 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_queue_info(rocprofiler_qu
rocprofiler_queue_id_t queue_id,
const char** data) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindQueue(queue_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_QUEUE_NOT_FOUND);
if (!(*data = rocmtools::GetROCMToolObj()->GetQueueInfo(kind, queue_id)))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_QUEUE_INFORMATION_MISSING);
if (!rocprofiler::GetROCProfilerSingleton()->FindQueue(queue_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_QUEUE_NOT_FOUND);
if (!(*data = rocprofiler::GetROCProfilerSingleton()->GetQueueInfo(kind, queue_id)))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_QUEUE_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -188,11 +188,11 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_kernel_info_size(rocprofi
rocprofiler_kernel_id_t kernel_id,
size_t* data_size) {
API_INIT_CHECKER
// if (!rocmtools::GetROCMToolObj()->FindKernel(kernel_id))
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_KERNEL_NOT_FOUND);
*data_size = rocmtools::GetROCMToolObj()->GetKernelInfoSize(kind, kernel_id);
// if (!rocprofiler::GetROCProfilerSingleton()->FindKernel(kernel_id))
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_KERNEL_NOT_FOUND);
*data_size = rocprofiler::GetROCProfilerSingleton()->GetKernelInfoSize(kind, kernel_id);
if (*data_size <= 0)
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_KERNEL_INFORMATION_MISSING);
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_KERNEL_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -200,10 +200,10 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_kernel_info(rocprofiler_k
rocprofiler_kernel_id_t kernel_id,
const char** data) {
API_INIT_CHECKER
// if (!rocmtools::GetROCMToolObj()->FindKernel(kernel_id))
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_KERNEL_NOT_FOUND);
if (!(*data = rocmtools::GetROCMToolObj()->GetKernelInfo(kind, kernel_id)))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_KERNEL_INFORMATION_MISSING);
// if (!rocprofiler::GetROCProfilerSingleton()->FindKernel(kernel_id))
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_KERNEL_NOT_FOUND);
if (!(*data = rocprofiler::GetROCProfilerSingleton()->GetKernelInfo(kind, kernel_id)))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_KERNEL_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -211,14 +211,14 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_counter_info_size(
rocprofiler_session_id_t session_id, rocprofiler_counter_info_kind_t kind,
rocprofiler_counter_id_t counter_id, size_t* data_size) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->GetProfiler()->FindCounter(counter_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND);
*data_size = rocmtools::GetROCMToolObj()
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->GetProfiler()->FindCounter(counter_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND);
*data_size = rocprofiler::GetROCProfilerSingleton()
->GetSession(session_id)
->GetProfiler()
->GetCounterInfoSize(kind, counter_id);
if (*data_size <= 0)
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_COUNTER_INFORMATION_MISSING);
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_COUNTER_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -227,13 +227,13 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_counter_info(rocprofiler_
rocprofiler_counter_id_t counter_id,
const char** data) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->GetProfiler()->FindCounter(counter_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND);
if (!(*data = rocmtools::GetROCMToolObj()
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->GetProfiler()->FindCounter(counter_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_COUNTER_NOT_FOUND);
if (!(*data = rocprofiler::GetROCProfilerSingleton()
->GetSession(session_id)
->GetProfiler()
->GetCounterInfo(kind, counter_id)))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_COUNTER_INFORMATION_MISSING);
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_COUNTER_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -243,29 +243,29 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_roctx_tracer_api_data_inf
size_t* data_size) {
API_INIT_CHECKER
// TODO(aelwazir): To be implemented
// if (!rocmtools::GetROCMToolObj()
// if (!rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindROCTxApiData(api_data_id)) {
// if (rocmtools::GetROCMToolObj()
// if (rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindHSAApiData(api_data_id) ||
// rocmtools::GetROCMToolObj()
// rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindHIPApiData(api_data_id)) {
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_DOMAIN);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_DOMAIN);
// } else {
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_NOT_FOUND);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_NOT_FOUND);
// }
// }
*data_size = rocmtools::GetROCMToolObj()
*data_size = rocprofiler::GetROCProfilerSingleton()
->GetSession(session_id)
->GetTracer()
->GetROCTxApiDataInfoSize(kind, api_data_id, operation_id);
// if (*data_size <= 0)
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_INFORMATION_MISSING);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -275,28 +275,28 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_roctx_tracer_api_data_inf
char** data) {
API_INIT_CHECKER
// TODO(aelwazir): To be implemented
// if (!rocmtools::GetROCMToolObj()
// if (!rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindROCTxApiData(api_data_id)) {
// if (rocmtools::GetROCMToolObj()
// if (rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindHSAApiData(api_data_id) ||
// rocmtools::GetROCMToolObj()
// rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindHIPApiData(api_data_id)) {
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_DOMAIN);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_DOMAIN);
// } else {
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_NOT_FOUND);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_NOT_FOUND);
// }
// }
if (!(*data = rocmtools::GetROCMToolObj()
if (!(*data = rocprofiler::GetROCProfilerSingleton()
->GetSession(session_id)
->GetTracer()
->GetROCTxApiDataInfo(kind, api_data_id, operation_id)))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_INFORMATION_MISSING);
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -306,31 +306,31 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_hsa_tracer_api_data_info_
size_t* data_size) {
API_INIT_CHECKER
// TODO(aelwazir): To be implemented
// if (!rocmtools::GetROCMToolObj()
// if (!rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindHSAApiData(api_data_id)) {
// if (rocmtools::GetROCMToolObj()
// if (rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindROCTxApiData(api_data_id) ||
// rocmtools::GetROCMToolObj()
// rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindHIPApiData(api_data_id)) {
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_DOMAIN);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_DOMAIN);
// } else {
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_NOT_FOUND);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_NOT_FOUND);
// }
// }
*data_size = ((kind == ROCPROFILER_HSA_FUNCTION_NAME)
? rocmtools::tracer::GetApiCallFunctionNameSize(ACTIVITY_DOMAIN_HSA_API, operation_id)
: rocmtools::GetROCMToolObj()
? rocprofiler::tracer::GetApiCallFunctionNameSize(ACTIVITY_DOMAIN_HSA_API, operation_id)
: rocprofiler::GetROCProfilerSingleton()
->GetSession(session_id)
->GetTracer()
->GetHSAApiDataInfoSize(kind, api_data_id, operation_id));
if (*data_size <= 0)
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_INFORMATION_MISSING);
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -340,30 +340,30 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_hsa_tracer_api_data_info(
char** data) {
API_INIT_CHECKER
// TODO(aelwazir): To be implemented
// if (!rocmtools::GetROCMToolObj()
// if (!rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindHSAApiData(api_data_id)) {
// if (rocmtools::GetROCMToolObj()
// if (rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindROCTxApiData(api_data_id) ||
// rocmtools::GetROCMToolObj()
// rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindHIPApiData(api_data_id)) {
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_DOMAIN);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_DOMAIN);
// } else {
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_NOT_FOUND);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_NOT_FOUND);
// }
// }
if (!(*data = (kind == ROCPROFILER_HSA_FUNCTION_NAME)
? rocmtools::tracer::GetApiCallFunctionName(ACTIVITY_DOMAIN_HSA_API, operation_id)
: rocmtools::GetROCMToolObj()
? rocprofiler::tracer::GetApiCallFunctionName(ACTIVITY_DOMAIN_HSA_API, operation_id)
: rocprofiler::GetROCProfilerSingleton()
->GetSession(session_id)
->GetTracer()
->GetHSAApiDataInfo(kind, api_data_id, operation_id)))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_INFORMATION_MISSING);
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -373,31 +373,31 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_hip_tracer_api_data_info_
size_t* data_size) {
API_INIT_CHECKER
// TODO(aelwazir): To be implemented
// if (!rocmtools::GetROCMToolObj()
// if (!rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindHIPApiData(api_data_id)) {
// if (rocmtools::GetROCMToolObj()
// if (rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindHSAApiData(api_data_id) ||
// rocmtools::GetROCMToolObj()
// rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindROCTxApiData(api_data_id)) {
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_DOMAIN);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_DOMAIN);
// } else {
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_NOT_FOUND);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_NOT_FOUND);
// }
// }
*data_size = (kind == ROCPROFILER_HIP_FUNCTION_NAME)
? rocmtools::tracer::GetApiCallFunctionNameSize(ACTIVITY_DOMAIN_HIP_API, operation_id)
: rocmtools::GetROCMToolObj()
? rocprofiler::tracer::GetApiCallFunctionNameSize(ACTIVITY_DOMAIN_HIP_API, operation_id)
: rocprofiler::GetROCProfilerSingleton()
->GetSession(session_id)
->GetTracer()
->GetHIPApiDataInfoSize(kind, api_data_id, operation_id);
// if (*data_size <= 0)
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_INFORMATION_MISSING);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
@@ -407,45 +407,45 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_query_hip_tracer_api_data_info(
char** data) {
API_INIT_CHECKER
// TODO(aelwazir): To be implemented
// if (!rocmtools::GetROCMToolObj()
// if (!rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindHIPApiData(api_data_id)) {
// if (rocmtools::GetROCMToolObj()
// if (rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindHSAApiData(api_data_id) ||
// rocmtools::GetROCMToolObj()
// rocprofiler::GetROCProfilerSingleton()
// ->GetSession(session_id)
// ->GetTracer()
// ->FindROCTxApiData(api_data_id)) {
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_DOMAIN);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_DOMAIN);
// } else {
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_NOT_FOUND);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_NOT_FOUND);
// }
// }
// if (!(
*data = (kind == ROCPROFILER_HIP_FUNCTION_NAME)
? rocmtools::tracer::GetApiCallFunctionName(ACTIVITY_DOMAIN_HIP_API, operation_id)
: rocmtools::GetROCMToolObj()
? rocprofiler::tracer::GetApiCallFunctionName(ACTIVITY_DOMAIN_HIP_API, operation_id)
: rocprofiler::GetROCProfilerSingleton()
->GetSession(session_id)
->GetTracer()
->GetHIPApiDataInfo(kind, api_data_id, operation_id);
// ))
// throw
// rocmtools::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_INFORMATION_MISSING);
// rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_TRACER_API_DATA_INFORMATION_MISSING);
API_METHOD_SUFFIX
}
ROCPROFILER_API rocprofiler_status_t rocprofiler_flush_data(rocprofiler_session_id_t session_id,
rocprofiler_buffer_id_t buffer_id) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->FindBuffer(buffer_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND);
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->GetBuffer(buffer_id)->Flush())
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_CORRUPTED_SESSION_BUFFER);
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->FindBuffer(buffer_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->GetBuffer(buffer_id)->Flush())
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_CORRUPTED_SESSION_BUFFER);
API_METHOD_SUFFIX
}
@@ -456,12 +456,12 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_next_record(const rocprofiler_r
rocprofiler_session_id_t session_id,
rocprofiler_buffer_id_t buffer_id) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->FindBuffer(buffer_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->FindBuffer(buffer_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND);
if (!Memory::GetNextRecord(record, next))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_RECORD_CORRUPTED);
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_RECORD_CORRUPTED);
API_METHOD_SUFFIX
}
@@ -469,7 +469,7 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_next_record(const rocprofiler_r
ROCPROFILER_API rocprofiler_status_t rocprofiler_create_session(rocprofiler_replay_mode_t replay_mode,
rocprofiler_session_id_t* session_id) {
API_INIT_CHECKER
*session_id = rocmtools::GetROCMToolObj()->CreateSession(replay_mode);
*session_id = rocprofiler::GetROCProfilerSingleton()->CreateSession(replay_mode);
API_METHOD_SUFFIX
}
@@ -482,14 +482,14 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_create_filter(rocprofiler_sessi
API_INIT_CHECKER
// TODO(aelwazir): CheckFilterData to be implemented
// int error_code =
// rocmtools::GetROCMToolObj()->CheckFilterData(filter_kind,
// rocprofiler::GetROCProfilerSingleton()->CheckFilterData(filter_kind,
// filter_data);
// if (error_code == -1) throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_FILTER_DATA_CORRUPTED);
// if (error_code == -1) throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_FILTER_DATA_CORRUPTED);
// if (error_code == 0)
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_FILTER_DATA_MISMATCH);
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
*filter_id = rocmtools::GetROCMToolObj()
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_FILTER_DATA_MISMATCH);
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
*filter_id = rocprofiler::GetROCProfilerSingleton()
->GetSession(session_id)
->CreateFilter(filter_kind, filter_data, data_count, property);
API_METHOD_SUFFIX
@@ -498,11 +498,11 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_create_filter(rocprofiler_sessi
ROCPROFILER_API rocprofiler_status_t rocprofiler_destroy_filter(rocprofiler_session_id_t session_id,
rocprofiler_filter_id_t filter_id) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->FindFilter(filter_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_FILTER_NOT_FOUND);
rocmtools::GetROCMToolObj()->GetSession(session_id)->DestroyFilter(filter_id);
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->FindFilter(filter_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_FILTER_NOT_FOUND);
rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->DestroyFilter(filter_id);
API_METHOD_SUFFIX
}
@@ -510,9 +510,9 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_create_buffer(
rocprofiler_session_id_t session_id, rocprofiler_buffer_callback_t buffer_callback,
size_t buffer_size, rocprofiler_buffer_id_t* buffer_id) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
*buffer_id = rocmtools::GetROCMToolObj()
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
*buffer_id = rocprofiler::GetROCProfilerSingleton()
->GetSession(session_id)
->CreateBuffer(buffer_callback, buffer_size);
API_METHOD_SUFFIX
@@ -522,11 +522,11 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_set_buffer_properties(
rocprofiler_session_id_t session_id, rocprofiler_buffer_id_t buffer_id,
rocprofiler_buffer_property_t* buffer_properties, uint32_t buffer_properties_count) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->FindBuffer(buffer_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND);
rocmtools::GetROCMToolObj()
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->FindBuffer(buffer_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND);
rocprofiler::GetROCProfilerSingleton()
->GetSession(session_id)
->GetBuffer(buffer_id)
->SetProperties(buffer_properties, buffer_properties_count);
@@ -536,11 +536,11 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_set_buffer_properties(
ROCPROFILER_API rocprofiler_status_t rocprofiler_destroy_buffer(rocprofiler_session_id_t session_id,
rocprofiler_buffer_id_t buffer_id) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->FindBuffer(buffer_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND);
rocmtools::GetROCMToolObj()->GetSession(session_id)->DestroyBuffer(buffer_id);
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->FindBuffer(buffer_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND);
rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->DestroyBuffer(buffer_id);
API_METHOD_SUFFIX
}
@@ -548,17 +548,17 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_set_filter_buffer(rocprofiler_s
rocprofiler_filter_id_t filter_id,
rocprofiler_buffer_id_t buffer_id) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->FindBuffer(buffer_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND);
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->FindFilter(filter_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_FILTER_NOT_FOUND);
if (!rocmtools::GetROCMToolObj()
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->FindBuffer(buffer_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->FindFilter(filter_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_FILTER_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()
->GetSession(session_id)
->CheckFilterBufferSize(filter_id, buffer_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_SIZE);
rocmtools::GetROCMToolObj()->GetSession(session_id)->GetFilter(filter_id)->SetBufferId(buffer_id);
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_SIZE);
rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->GetFilter(filter_id)->SetBufferId(buffer_id);
API_METHOD_SUFFIX
}
@@ -566,14 +566,14 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_set_api_trace_sync_callback(
rocprofiler_session_id_t session_id, rocprofiler_filter_id_t filter_id,
rocprofiler_sync_callback_t callback) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->FindFilter(filter_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_FILTER_NOT_FOUND);
if (rocmtools::GetROCMToolObj()->GetSession(session_id)->GetFilter(filter_id)->GetKind() !=
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->FindFilter(filter_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_FILTER_NOT_FOUND);
if (rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->GetFilter(filter_id)->GetKind() !=
ROCPROFILER_API_TRACE)
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_FILTER_NOT_SUPPORTED);
rocmtools::GetROCMToolObj()->GetSession(session_id)->GetFilter(filter_id)->SetCallback(callback);
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_FILTER_NOT_SUPPORTED);
rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->GetFilter(filter_id)->SetCallback(callback);
API_METHOD_SUFFIX
}
@@ -585,29 +585,29 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_create_ready_session(
API_INIT_CHECKER
// TODO(aelwazir): CheckFilterData to be implemented
// int error_code =
// rocmtools::GetROCMToolObj()->CheckFilterData(filter_kind,
// rocprofiler::GetROCProfilerSingleton()->CheckFilterData(filter_kind,
// filter_data);
// if (error_code == -1) throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_FILTER_DATA_CORRUPTED);
// if (error_code == -1) throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_FILTER_DATA_CORRUPTED);
// if (error_code == 0)
// throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_FILTER_DATA_MISMATCH);
*session_id = rocmtools::GetROCMToolObj()->CreateSession(replay_mode);
// throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_FILTER_DATA_MISMATCH);
*session_id = rocprofiler::GetROCProfilerSingleton()->CreateSession(replay_mode);
rocprofiler_filter_id_t filter_id =
rocmtools::GetROCMToolObj()
rocprofiler::GetROCProfilerSingleton()
->GetSession(*session_id)
->CreateFilter(filter_kind, filter_data, data_count, property);
rocprofiler_buffer_id_t buffer_id = rocmtools::GetROCMToolObj()
rocprofiler_buffer_id_t buffer_id = rocprofiler::GetROCProfilerSingleton()
->GetSession(*session_id)
->CreateBuffer(buffer_callback, buffer_size);
if (filter_kind == ROCPROFILER_API_TRACE)
rocmtools::GetROCMToolObj()
rocprofiler::GetROCProfilerSingleton()
->GetSession(*session_id)
->GetFilter(filter_id)
->SetCallback(callback);
if (!rocmtools::GetROCMToolObj()
if (!rocprofiler::GetROCProfilerSingleton()
->GetSession(*session_id)
->CheckFilterBufferSize(filter_id, buffer_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_SIZE);
rocmtools::GetROCMToolObj()
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_INCORRECT_SIZE);
rocprofiler::GetROCProfilerSingleton()
->GetSession(*session_id)
->GetFilter(filter_id)
->SetBufferId(buffer_id);
@@ -617,37 +617,37 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_create_ready_session(
// API to destroy a session by id
ROCPROFILER_API rocprofiler_status_t rocprofiler_destroy_session(rocprofiler_session_id_t session_id) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
rocmtools::GetROCMToolObj()->DestroySession(session_id);
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
rocprofiler::GetROCProfilerSingleton()->DestroySession(session_id);
API_METHOD_SUFFIX
}
// API to activate a session by id
ROCPROFILER_API rocprofiler_status_t rocprofiler_start_session(rocprofiler_session_id_t session_id) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->HasFilter())
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_MISSING_FILTER);
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->HasBuffer())
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_MISSING_BUFFER);
if (rocmtools::GetROCMToolObj()->HasActiveSession())
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_HAS_ACTIVE_SESSION);
rocmtools::GetROCMToolObj()->GetSession(session_id)->Start();
rocmtools::GetROCMToolObj()->SetCurrentActiveSession(session_id);
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->HasFilter())
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_MISSING_FILTER);
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->HasBuffer())
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_MISSING_BUFFER);
if (rocprofiler::GetROCProfilerSingleton()->HasActiveSession())
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_HAS_ACTIVE_SESSION);
rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->Start();
rocprofiler::GetROCProfilerSingleton()->SetCurrentActiveSession(session_id);
API_METHOD_SUFFIX
}
// API to deactivate a session by id
ROCPROFILER_API rocprofiler_status_t rocprofiler_terminate_session(rocprofiler_session_id_t session_id) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocmtools::GetROCMToolObj()->IsActiveSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_ACTIVE);
rocmtools::GetROCMToolObj()->GetSession(session_id)->Terminate();
rocmtools::GetROCMToolObj()->SetCurrentActiveSession(rocprofiler_session_id_t{0});
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
if (!rocprofiler::GetROCProfilerSingleton()->IsActiveSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_ACTIVE);
rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->Terminate();
rocprofiler::GetROCProfilerSingleton()->SetCurrentActiveSession(rocprofiler_session_id_t{0});
API_METHOD_SUFFIX
}
@@ -656,32 +656,32 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_terminate_session(rocprofiler_s
ROCPROFILER_API rocprofiler_status_t rocprofiler_push_range(rocprofiler_session_id_t session_id,
const char* label) {
API_INIT_CHECKER
if (!label) throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_CORRUPTED_LABEL_DATA);
rocmtools::GetROCMToolObj()->GetSession(session_id)->PushRangeLabels(label);
if (!label) throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_CORRUPTED_LABEL_DATA);
rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->PushRangeLabels(label);
API_METHOD_SUFFIX
}
// API to pop a custom label defined for a code section
ROCPROFILER_API rocprofiler_status_t rocprofiler_pop_range(rocprofiler_session_id_t session_id) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->PopRangeLabels())
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_RANGE_STACK_IS_EMPTY);
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->PopRangeLabels())
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_RANGE_STACK_IS_EMPTY);
API_METHOD_SUFFIX
}
ROCPROFILER_API rocprofiler_status_t rocprofiler_start_replay_pass(rocprofiler_session_id_t session_id) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->FindSession(session_id))
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
rocmtools::GetROCMToolObj()->GetSession(session_id)->GetProfiler()->StartReplayPass(session_id);
if (!rocprofiler::GetROCProfilerSingleton()->FindSession(session_id))
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_SESSION_NOT_FOUND);
rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->GetProfiler()->StartReplayPass(session_id);
API_METHOD_SUFFIX
}
ROCPROFILER_API rocprofiler_status_t rocprofiler_end_replay_pass(rocprofiler_session_id_t session_id) {
API_INIT_CHECKER
if (!rocmtools::GetROCMToolObj()->GetSession(session_id)->GetProfiler()->HasActivePass())
throw rocmtools::Exception(ROCPROFILER_STATUS_ERROR_PASS_NOT_STARTED);
rocmtools::GetROCMToolObj()->GetSession(session_id)->GetProfiler()->EndReplayPass();
if (!rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->GetProfiler()->HasActivePass())
throw rocprofiler::Exception(ROCPROFILER_STATUS_ERROR_PASS_NOT_STARTED);
rocprofiler::GetROCProfilerSingleton()->GetSession(session_id)->GetProfiler()->EndReplayPass();
API_METHOD_SUFFIX
}
@@ -691,7 +691,7 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_device_profiling_session_create
API_METHOD_PREFIX
std::vector<std::string> counters(counter_names, counter_names + num_counters);
*session_id =
rocmtools::GetROCMToolObj()->CreateDeviceProfilingSession(counters, cpu_index, gpu_index);
rocprofiler::GetROCProfilerSingleton()->CreateDeviceProfilingSession(counters, cpu_index, gpu_index);
API_METHOD_SUFFIX
}
@@ -699,7 +699,7 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_device_profiling_session_create
ROCPROFILER_API rocprofiler_status_t
rocprofiler_device_profiling_session_start(rocprofiler_session_id_t session_id) {
API_METHOD_PREFIX
rocmtools::GetROCMToolObj()->GetDeviceProfilingSession(session_id)->StartSession();
rocprofiler::GetROCProfilerSingleton()->GetDeviceProfilingSession(session_id)->StartSession();
API_METHOD_SUFFIX
}
@@ -707,7 +707,7 @@ rocprofiler_device_profiling_session_start(rocprofiler_session_id_t session_id)
ROCPROFILER_API rocprofiler_status_t rocprofiler_device_profiling_session_poll(
rocprofiler_session_id_t session_id, rocprofiler_device_profile_metric_t* data) {
API_METHOD_PREFIX
rocmtools::GetROCMToolObj()->GetDeviceProfilingSession(session_id)->PollMetrics(data);
rocprofiler::GetROCProfilerSingleton()->GetDeviceProfilingSession(session_id)->PollMetrics(data);
API_METHOD_SUFFIX
}
@@ -715,7 +715,7 @@ ROCPROFILER_API rocprofiler_status_t rocprofiler_device_profiling_session_poll(
ROCPROFILER_API rocprofiler_status_t
rocprofiler_device_profiling_session_stop(rocprofiler_session_id_t session_id) {
API_METHOD_PREFIX
rocmtools::GetROCMToolObj()->GetDeviceProfilingSession(session_id)->StopSession();
rocprofiler::GetROCProfilerSingleton()->GetDeviceProfilingSession(session_id)->StopSession();
API_METHOD_SUFFIX
}
@@ -723,7 +723,7 @@ rocprofiler_device_profiling_session_stop(rocprofiler_session_id_t session_id) {
ROCPROFILER_API rocprofiler_status_t
rocprofiler_device_profiling_session_destroy(rocprofiler_session_id_t session_id) {
API_METHOD_PREFIX
rocmtools::GetROCMToolObj()->DestroyDeviceProfilingSession(session_id);
rocprofiler::GetROCProfilerSingleton()->DestroyDeviceProfilingSession(session_id);
API_METHOD_SUFFIX
}
@@ -746,9 +746,9 @@ ROCPROFILER_EXPORT extern const uint32_t HSA_AMD_TOOL_PRIORITY = 25;
*/
ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
uint64_t failed_tool_count, const char* const* failed_tool_names) {
if (started) rocmtools::fatal("HSA Tool started already!");
if (started) rocprofiler::fatal("HSA Tool started already!");
started = true;
rocmtools::hsa_support::Initialize(table);
rocprofiler::hsa_support::Initialize(table);
return true;
}
@@ -756,8 +756,8 @@ ROCPROFILER_EXPORT bool OnLoad(HsaApiTable* table, uint64_t runtime_version,
* @brief Callback function upon unloading the HSA.
*/
ROCPROFILER_EXPORT void OnUnload() {
if (!started) rocmtools::fatal("HSA Tool hasn't started yet!");
rocmtools::hsa_support::Finalize();
if (!started) rocprofiler::fatal("HSA Tool hasn't started yet!");
rocprofiler::hsa_support::Finalize();
started=false;
}