Improve hip_prof_api.h's readability
- Don't pass uint32_t arguments by reference.
- Use nullptr instead of NULL.
- Don't add frivolous typedefs.
- Use correct types when available instead of generic integral types.
- Make all roctracer callbacks extern "C" to prepare for a future change
that will be removing their declaration from hip_runtime_api.h.
- Rename cb/sem sync and release functions -> reader_lock/writer_lock
acquire and release.
Change-Id: If203fee077d421a9782fcd34607a413b8c3dcfc8
[ROCm/clr commit: 9f09ca929e]
This commit is contained in:
@@ -29,6 +29,8 @@ api_callbacks_table_t callbacks_table;
|
||||
|
||||
extern const std::string& FunctionName(const hipFunction_t f);
|
||||
|
||||
extern "C" {
|
||||
|
||||
const char* hipKernelNameRef(const hipFunction_t f) { return FunctionName(f).c_str(); }
|
||||
|
||||
int hipGetStreamDeviceId(hipStream_t stream) {
|
||||
@@ -40,28 +42,28 @@ int hipGetStreamDeviceId(hipStream_t stream) {
|
||||
}
|
||||
|
||||
const char* hipKernelNameRefByPtr(const void* hostFunction, hipStream_t) {
|
||||
if (hostFunction == NULL) {
|
||||
return NULL;
|
||||
if (hostFunction == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return PlatformState::instance().getStatFuncName(hostFunction);
|
||||
}
|
||||
|
||||
hipError_t hipRegisterApiCallback(uint32_t id, void* fun, void* arg) {
|
||||
return callbacks_table.set_callback(id, reinterpret_cast<api_callbacks_table_t::fun_t>(fun), arg) ?
|
||||
return callbacks_table.set_callback(static_cast<hip_api_id_t>(id), reinterpret_cast<activity_rtapi_callback_t>(fun), arg) ?
|
||||
hipSuccess : hipErrorInvalidValue;
|
||||
}
|
||||
|
||||
hipError_t hipRemoveApiCallback(uint32_t id) {
|
||||
return callbacks_table.set_callback(id, NULL, NULL) ? hipSuccess : hipErrorInvalidValue;
|
||||
return callbacks_table.set_callback(static_cast<hip_api_id_t>(id), nullptr, nullptr) ? hipSuccess : hipErrorInvalidValue;
|
||||
}
|
||||
|
||||
hipError_t hipRegisterActivityCallback(uint32_t id, void* fun, void* arg) {
|
||||
return callbacks_table.set_activity(id, reinterpret_cast<api_callbacks_table_t::act_t>(fun), arg) ?
|
||||
return callbacks_table.set_activity(static_cast<hip_api_id_t>(id), reinterpret_cast<activity_sync_callback_t>(fun), arg) ?
|
||||
hipSuccess : hipErrorInvalidValue;
|
||||
}
|
||||
|
||||
hipError_t hipRemoveActivityCallback(uint32_t id) {
|
||||
return callbacks_table.set_activity(id, NULL, NULL) ? hipSuccess : hipErrorInvalidValue;
|
||||
return callbacks_table.set_activity(static_cast<hip_api_id_t>(id), nullptr, nullptr) ? hipSuccess : hipErrorInvalidValue;
|
||||
}
|
||||
|
||||
hipError_t hipEnableTracing(bool enabled) {
|
||||
@@ -72,3 +74,5 @@ hipError_t hipEnableTracing(bool enabled) {
|
||||
const char* hipApiName(uint32_t id) {
|
||||
return hip_api_name(id);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user