Skip to content

Commit

Permalink
Remove the ROCprofiler loader
Browse files Browse the repository at this point in the history
Was used for the HSA_EVT activities, so no longer needed.

Change-Id: I7729fb4519f2e3cee73776264647381cb5826067
  • Loading branch information
lmoriche committed Sep 7, 2022
1 parent c2b87b1 commit 9c57b15
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 65 deletions.
14 changes: 14 additions & 0 deletions inc/roctracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
*
* The API provides functionality for registering the runtimes API callbacks
* and asynchronous activity records pool support.
*
* \section known_limitations Known Limitations and Restrictions
*
* The ROCtracer API library implementation currently has the following
* restrictions. Future releases aim to address these restrictions.
*
* 1. The ACTIVITY_DOMAIN_HSA_OPS operations HSA_OP_ID_DISPATCH,
* HSA_OP_ID_BARRIER, and HSA_OP_ID_RESERVED1 are not currently implemented.
*/

/**
Expand Down Expand Up @@ -191,6 +199,12 @@ typedef enum {
* External correlation ID pop mismatch.
*/
ROCTRACER_STATUS_ERROR_MISMATCHED_EXTERNAL_CORRELATION_ID = -7,
/**
* The operation is not currently implemented. This error may be reported by
* any function. Check the \ref known_limitations section to determine the
* status of the library implementation of the interface.
*/
ROCTRACER_STATUS_ERROR_NOT_IMPLEMENTED = -8,
/**
* Deprecated error code.
*/
Expand Down
43 changes: 22 additions & 21 deletions src/roctracer/hsa_support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "correlation_id.h"
#include "exception.h"
#include "loader.h"
#include "memory_pool.h"
#include "roctracer.h"
#include "roctracer_hsa.h"
Expand Down Expand Up @@ -355,13 +354,6 @@ hsa_status_t MemoryASyncCopyRectIntercept(const hsa_pitched_ptr_t* dst,
return status;
}

void AsyncActivityCallback(uint32_t op_id, void* record, void* arg) {
MemoryPool* pool = reinterpret_cast<MemoryPool*>(arg);
roctracer_record_t* record_ptr = reinterpret_cast<roctracer_record_t*>(record);
record_ptr->domain = ACTIVITY_DOMAIN_HSA_OPS;
pool->Write(*record_ptr);
}

} // namespace

roctracer_timestamp_t timestamp_ns() {
Expand Down Expand Up @@ -481,11 +473,23 @@ const char* GetEvtName(uint32_t id) {
return "CODEOBJ";
case HSA_EVT_ID_NUMBER:
break;
};
}
throw ApiError(ROCTRACER_STATUS_ERROR_INVALID_ARGUMENT, "invalid HSA EVT callback id");
}

const char* GetOpsName(uint32_t id) { return RocpLoader::Instance().GetOpName(id); }
const char* GetOpsName(uint32_t id) {
switch (id) {
case HSA_OP_ID_DISPATCH:
return "DISPATCH";
case HSA_OP_ID_COPY:
return "COPY";
case HSA_OP_ID_BARRIER:
return "BARRIER";
case HSA_OP_ID_RESERVED1:
return "PCSAMPLE";
}
throw ApiError(ROCTRACER_STATUS_ERROR_INVALID_ARGUMENT, "invalid HSA OPS callback id");
}

uint32_t GetApiCode(const char* str) { return detail::GetApiCode(str); }

Expand All @@ -502,15 +506,11 @@ void EnableActivity(roctracer_domain_t domain, uint32_t op, roctracer_pool_t* po
}
async_copy_callback_enabled = true;
async_copy_callback_memory_pool = reinterpret_cast<MemoryPool*>(pool);
} else if (op == HSA_OP_ID_RESERVED1) {
/* Place holder for PC sampling. */
} else {
const bool init_phase = (RocpLoader::GetRef() == nullptr);
if (RocpLoader::GetRef() == nullptr) break;
if (init_phase) {
RocpLoader::Instance().InitActivityCallback(
reinterpret_cast<void*>(AsyncActivityCallback), pool);
}
if (!RocpLoader::Instance().EnableActivityCallback(op, true))
FATAL_LOGGING("HSA::EnableActivityCallback error");
EXC_RAISING(ROCTRACER_STATUS_ERROR_NOT_IMPLEMENTED,
"HSA OPS operation ID(" << op << ") is not currently implemented");
}
break;
case ACTIVITY_DOMAIN_HSA_API:
Expand Down Expand Up @@ -562,10 +562,11 @@ void DisableActivity(roctracer_domain_t domain, uint32_t op) {
assert(status == HSA_STATUS_SUCCESS || status == HSA_STATUS_ERROR_NOT_INITIALIZED ||
!"hsa_amd_profiling_async_copy_enable failed");
}
} else if (op == HSA_OP_ID_RESERVED1) {
/* Place holder for PC sampling. */
} else {
if (RocpLoader::GetRef() != nullptr &&
!RocpLoader::Instance().EnableActivityCallback(op, false))
FATAL_LOGGING("HSA::EnableActivityCallback(false) error, op(" << op << ")");
EXC_RAISING(ROCTRACER_STATUS_ERROR_NOT_IMPLEMENTED,
"HSA OPS operation ID(" << op << ") is not currently implemented");
}
break;
case ACTIVITY_DOMAIN_HSA_API:
Expand Down
38 changes: 0 additions & 38 deletions src/roctracer/loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,41 +99,6 @@ template <class T> class BaseLoader : public T {
void* handle_;
};

// ROCprofiler library loader class
class RocpApi {
public:
typedef BaseLoader<RocpApi> Loader;

typedef bool(RegisterCallback_t)(uint32_t op, void* callback, void* arg);
typedef bool(OperateCallback_t)(uint32_t op);
typedef bool(InitCallback_t)(void* callback, void* arg);
typedef bool(EnableCallback_t)(uint32_t op, bool enable);
typedef const char*(NameCallback_t)(uint32_t op);

RegisterCallback_t* RegisterApiCallback;
OperateCallback_t* RemoveApiCallback;
InitCallback_t* InitActivityCallback;
EnableCallback_t* EnableActivityCallback;
NameCallback_t* GetOpName;

RegisterCallback_t* RegisterEvtCallback;
OperateCallback_t* RemoveEvtCallback;
NameCallback_t* GetEvtName;

protected:
void init(Loader* loader) {
RegisterApiCallback = loader->GetFun<RegisterCallback_t>("RegisterApiCallback");
RemoveApiCallback = loader->GetFun<OperateCallback_t>("RemoveApiCallback");
InitActivityCallback = loader->GetFun<InitCallback_t>("InitActivityCallback");
EnableActivityCallback = loader->GetFun<EnableCallback_t>("EnableActivityCallback");
GetOpName = loader->GetFun<NameCallback_t>("GetOpName");

RegisterEvtCallback = loader->GetFun<RegisterCallback_t>("RegisterEvtCallback");
RemoveEvtCallback = loader->GetFun<OperateCallback_t>("RemoveEvtCallback");
GetEvtName = loader->GetFun<NameCallback_t>("GetEvtName");
}
};

} // namespace roctracer

// HIP runtime library loader class
Expand Down Expand Up @@ -308,7 +273,6 @@ class RocTxApi {
}
};

typedef BaseLoader<RocpApi> RocpLoader;
typedef BaseLoader<RocTxApi> RocTxLoader;

#if STATIC_BUILD
Expand All @@ -326,8 +290,6 @@ typedef HipLoaderShared HipLoader;
template <class T> bool roctracer::BaseLoader<T>::to_load_ = false; \
template <class T> bool roctracer::BaseLoader<T>::to_check_open_ = true; \
template <class T> bool roctracer::BaseLoader<T>::to_check_symb_ = true; \
template <> const char* roctracer::RocpLoader::lib_name_ = "librocprofiler64.so"; \
template <> bool roctracer::RocpLoader::to_load_ = true; \
template <> const char* roctracer::RocTxLoader::lib_name_ = "libroctx64.so"; \
template <> bool roctracer::RocTxLoader::to_load_ = true;

Expand Down
21 changes: 15 additions & 6 deletions src/roctracer/roctracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ static void roctracer_enable_activity_fun(roctracer_domain_t domain, uint32_t op
assert(pool != nullptr);
switch (domain) {
case ACTIVITY_DOMAIN_HSA_OPS:
RocpLoader::Instance();
case ACTIVITY_DOMAIN_HSA_API:
case ACTIVITY_DOMAIN_HSA_EVT:
hsa_support::EnableActivity(domain, op, pool);
Expand Down Expand Up @@ -572,8 +571,11 @@ ROCTRACER_API roctracer_status_t roctracer_enable_op_activity(activity_domain_t
static void roctracer_enable_domain_activity_impl(roctracer_domain_t domain,
roctracer_pool_t* pool) {
const uint32_t op_end = get_op_end(domain);
for (uint32_t op = get_op_begin(domain); op < op_end; ++op)
roctracer_enable_activity_impl(domain, op, pool);
for (uint32_t op = get_op_begin(domain); op < op_end; ++op) try {
roctracer_enable_activity_impl(domain, op, pool);
} catch (const ApiError& err) {
if (err.status() != ROCTRACER_STATUS_ERROR_NOT_IMPLEMENTED) throw;
}
}

ROCTRACER_API roctracer_status_t roctracer_enable_domain_activity_expl(roctracer_domain_t domain,
Expand Down Expand Up @@ -637,11 +639,18 @@ ROCTRACER_API roctracer_status_t roctracer_disable_op_activity(roctracer_domain_
API_METHOD_SUFFIX
}

static void roctracer_disable_domain_activity_impl(roctracer_domain_t domain) {
const uint32_t op_end = get_op_end(domain);
for (uint32_t op = get_op_begin(domain); op < op_end; ++op) try {
roctracer_disable_activity_impl(domain, op);
} catch (const ApiError& err) {
if (err.status() != ROCTRACER_STATUS_ERROR_NOT_IMPLEMENTED) throw;
}
}

ROCTRACER_API roctracer_status_t roctracer_disable_domain_activity(roctracer_domain_t domain) {
API_METHOD_PREFIX
const uint32_t op_end = get_op_end(domain);
for (uint32_t op = get_op_begin(domain); op < op_end; ++op)
roctracer_disable_activity_impl(domain, op);
roctracer_disable_domain_activity_impl(domain);
API_METHOD_SUFFIX
}

Expand Down

0 comments on commit 9c57b15

Please sign in to comment.