SWDEV-509788 - Code cleanups in Event class

Change-Id: I4163ce6c1dabeaab92de13b51b6a46b7be83e2bd


[ROCm/clr commit: e9b33af45a]
This commit is contained in:
Ioannis Assiouras
2025-02-25 02:20:45 +00:00
parent 004fc8f4a7
commit efd1f3f012
4 ha cambiato i file con 19 aggiunte e 20 eliminazioni
+13 -11
Vedi File
@@ -166,7 +166,7 @@ int64_t EventDD::time(bool getStartTs) const {
return static_cast<int64_t>(end);
}
}
// ================================================================================================
hipError_t Event::streamWaitCommand(amd::Command*& command, hip::Stream* stream) {
amd::Command::EventWaitList eventWaitList;
if (event_ != nullptr) {
@@ -182,12 +182,7 @@ hipError_t Event::streamWaitCommand(amd::Command*& command, hip::Stream* stream)
}
return hipSuccess;
}
hipError_t Event::enqueueStreamWaitCommand(hipStream_t stream, amd::Command* command) {
command->enqueue();
return hipSuccess;
}
// ================================================================================================
hipError_t Event::streamWait(hipStream_t stream, uint flags) {
hip::Stream* hip_stream = hip::getStream(stream);
// Access to event_ object must be lock protected
@@ -203,10 +198,7 @@ hipError_t Event::streamWait(hipStream_t stream, uint flags) {
if (status != hipSuccess) {
return status;
}
status = enqueueStreamWaitCommand(stream, command);
if (status != hipSuccess) {
return status;
}
command->enqueue();
command->release();
return hipSuccess;
}
@@ -323,6 +315,7 @@ hipError_t ihipEventCreateWithFlags(hipEvent_t* event, unsigned flags) {
return hipSuccess;
}
// ================================================================================================
hipError_t hipEventCreateWithFlags(hipEvent_t* event, unsigned flags) {
HIP_INIT_API(hipEventCreateWithFlags, event, flags);
@@ -333,6 +326,7 @@ hipError_t hipEventCreateWithFlags(hipEvent_t* event, unsigned flags) {
HIP_RETURN(ihipEventCreateWithFlags(event, flags), *event);
}
// ================================================================================================
hipError_t hipEventCreate(hipEvent_t* event) {
HIP_INIT_API(hipEventCreate, event);
@@ -343,6 +337,7 @@ hipError_t hipEventCreate(hipEvent_t* event) {
HIP_RETURN(ihipEventCreateWithFlags(event, 0), *event);
}
// ================================================================================================
hipError_t hipEventDestroy(hipEvent_t event) {
HIP_INIT_API(hipEventDestroy, event);
@@ -367,6 +362,7 @@ hipError_t hipEventDestroy(hipEvent_t event) {
HIP_RETURN(hipSuccess);
}
// ================================================================================================
hipError_t hipEventElapsedTime(float* ms, hipEvent_t start, hipEvent_t stop) {
HIP_INIT_API(hipEventElapsedTime, ms, start, stop);
@@ -388,6 +384,7 @@ hipError_t hipEventElapsedTime(float* ms, hipEvent_t start, hipEvent_t stop) {
HIP_RETURN(eStart->elapsedTime(*eStop, *ms), "Elapsed Time = ", *ms);
}
// ================================================================================================
hipError_t hipEventRecord_common(hipEvent_t event, hipStream_t stream, unsigned int flags) {
if (!(flags == hipEventRecordDefault || flags == hipEventRecordExternal)){
return hipErrorInvalidValue;
@@ -433,22 +430,26 @@ hipError_t hipEventRecord_common(hipEvent_t event, hipStream_t stream, unsigned
return status;
}
// ================================================================================================
hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) {
HIP_INIT_API(hipEventRecord, event, stream);
HIP_RETURN(hipEventRecord_common(event, stream, hipEventRecordDefault));
}
// ================================================================================================
hipError_t hipEventRecord_spt(hipEvent_t event, hipStream_t stream) {
HIP_INIT_API(hipEventRecord, event, stream);
PER_THREAD_DEFAULT_STREAM(stream);
HIP_RETURN(hipEventRecord_common(event, stream, hipEventRecordDefault));
}
// ================================================================================================
hipError_t hipEventRecordWithFlags(hipEvent_t event, hipStream_t stream, unsigned int flags) {
HIP_INIT_API(hipEventRecordWithFlags, event, stream, flags);
HIP_RETURN(hipEventRecord_common(event, stream, flags));
}
// ================================================================================================
hipError_t hipEventSynchronize(hipEvent_t event) {
HIP_INIT_API(hipEventSynchronize, event);
@@ -473,6 +474,7 @@ hipError_t hipEventSynchronize(hipEvent_t event) {
HIP_RETURN(status);
}
// ================================================================================================
hipError_t ihipEventQuery(hipEvent_t event) {
if (event == nullptr) {
return hipErrorInvalidHandle;
-1
Vedi File
@@ -121,7 +121,6 @@ class Event {
hipError_t elapsedTime(Event& eStop, float& ms);
virtual hipError_t streamWaitCommand(amd::Command*& command, hip::Stream* stream);
virtual hipError_t enqueueStreamWaitCommand(hipStream_t stream, amd::Command* command);
virtual hipError_t streamWait(hipStream_t stream, uint flags);
virtual hipError_t recordCommand(amd::Command*& command, amd::HostQueue* stream,
+5 -1
Vedi File
@@ -75,6 +75,7 @@ bool IPCEvent::createIpcEventShmemIfNeeded() {
return true;
}
// ================================================================================================
hipError_t IPCEvent::query() {
if (ipc_evt_.ipc_shmem_) {
int prev_read_idx = ipc_evt_.ipc_shmem_->read_index;
@@ -87,6 +88,7 @@ hipError_t IPCEvent::query() {
return hipSuccess;
}
// ================================================================================================
hipError_t IPCEvent::synchronize() {
if (ipc_evt_.ipc_shmem_) {
int prev_read_idx = ipc_evt_.ipc_shmem_->read_index;
@@ -101,6 +103,7 @@ hipError_t IPCEvent::synchronize() {
return hipSuccess;
}
// ================================================================================================
hipError_t IPCEvent::streamWait(hipStream_t stream, uint flags) {
int offset = ipc_evt_.ipc_shmem_->read_index;
@@ -152,6 +155,7 @@ hipError_t IPCEvent::enqueueRecordCommand(hipStream_t stream, amd::Command* comm
return hipSuccess;
}
// ================================================================================================
hipError_t IPCEvent::GetHandle(ihipIpcEventHandle_t* handle) {
if (!createIpcEventShmemIfNeeded()) {
return hipErrorInvalidValue;
@@ -163,6 +167,7 @@ hipError_t IPCEvent::GetHandle(ihipIpcEventHandle_t* handle) {
return hipSuccess;
}
// ================================================================================================
hipError_t IPCEvent::OpenHandle(ihipIpcEventHandle_t* handle) {
ipc_evt_.ipc_name_ = handle->shmem_name;
if (!amd::Os::MemoryMapFileTruncated(ipc_evt_.ipc_name_.c_str(),
@@ -186,7 +191,6 @@ hipError_t IPCEvent::OpenHandle(ihipIpcEventHandle_t* handle) {
}
// ================================================================================================
hipError_t hipIpcGetEventHandle(hipIpcEventHandle_t* handle, hipEvent_t event) {
HIP_INIT_API(hipIpcGetEventHandle, handle, event);
@@ -2180,13 +2180,7 @@ class GraphEventWaitNode : public GraphNode {
void EnqueueCommands(hip::Stream* stream) override {
if (!commands_.empty()) {
hip::Event* e = reinterpret_cast<hip::Event*>(event_);
hipError_t status =
e->enqueueStreamWaitCommand(reinterpret_cast<hipStream_t>(stream), commands_[0]);
if (status != hipSuccess) {
ClPrint(amd::LOG_ERROR, amd::LOG_CODE,
"[hipGraph] Enqueue stream wait command failed for node %p - status %d", this,
status);
}
commands_[0]->enqueue();
commands_[0]->release();
}
}