SWDEV-545952 - API definitions for hipStreamSet/GetAttribute (#831)

Co-authored-by: Rahul Manocha <rmanocha@amd.com>
This commit is contained in:
Manocha, Rahul
2025-08-15 12:51:35 -07:00
committed by GitHub
parent a5be0f5346
commit 0f49c4a97f
16 changed files with 200 additions and 20 deletions
+11 -3
View File
@@ -1383,6 +1383,14 @@ class VirtualDevice : public amd::HeapObject {
namespace amd {
/*! IHIP IPC MEMORY Structure */
#define AMD_IPC_MEM_HANDLE_SIZE 32
typedef enum SyncPolicy {
Auto = 1,
Spin = 2,
Yield = 3,
Blocking = 4
} SyncPolicy;
//! MemoryObject map lookup class
class MemObjMap : public AllStatic {
public:
@@ -2050,9 +2058,9 @@ class Device : public RuntimeObject {
// Returns the status of HW event, associated with amd::Event
virtual bool IsHwEventReady(
const amd::Event& event, //!< AMD event for HW status validation
bool wait = false, //!< If true then forces the event completion
uint32_t hip_event_flags = 0 //!< flags associated with the event. 0 = hipEventDefault
const amd::Event& event, //!< AMD event for HW status validation
bool wait = false, //!< If true then forces the event completion
amd::SyncPolicy policy = amd::SyncPolicy::Auto
) const {
return false;
};
+5 -3
View File
@@ -2840,7 +2840,7 @@ bool Device::SetClockMode(const cl_set_device_clock_mode_input_amd setClockModeI
}
// ================================================================================================
bool Device::IsHwEventReady(const amd::Event& event, bool wait, uint32_t hip_event_flags) const {
bool Device::IsHwEventReady(const amd::Event& event, bool wait, amd::SyncPolicy policy) const {
void* hw_event =
(event.NotifyEvent() != nullptr) ? event.NotifyEvent()->HwEvent() : event.HwEvent();
if (hw_event == nullptr) {
@@ -2851,8 +2851,10 @@ bool Device::IsHwEventReady(const amd::Event& event, bool wait, uint32_t hip_eve
// when set the CPU gives up host thread for other work
// when not set the CPU enters a busy-wait on the event to occur
constexpr int kHipEventBlockingSync = 0x1;
bool active_wait = !(hip_event_flags & kHipEventBlockingSync) && ActiveWait();
return WaitForSignal(reinterpret_cast<ProfilingSignal*>(hw_event)->signal_, active_wait);
bool active_wait = !((policy == amd::SyncPolicy::Blocking) & kHipEventBlockingSync) &&
ActiveWait();
bool yield = (policy == amd::SyncPolicy::Yield);
return WaitForSignal(reinterpret_cast<ProfilingSignal*>(hw_event)->signal_, active_wait, yield);
}
auto signal = reinterpret_cast<ProfilingSignal*>(hw_event)->signal_;
+4 -2
View File
@@ -291,7 +291,8 @@ class NullDevice : public amd::Device {
}
bool IsHwEventReady(const amd::Event& event, bool wait = false,
uint32_t hip_event_flags = 0) const override {
amd::SyncPolicy policy = amd::SyncPolicy::Auto)
const override {
return false;
}
@@ -447,7 +448,8 @@ class Device : public NullDevice {
cl_set_device_clock_mode_output_amd* pSetClockModeOutput);
virtual bool IsHwEventReady(const amd::Event& event, bool wait = false,
uint32_t hip_event_flags = 0) const;
amd::SyncPolicy policy = amd::SyncPolicy::Auto)
const;
virtual void getHwEventTime(const amd::Event& event, uint64_t* start, uint64_t* end) const;
virtual void ReleaseGlobalSignal(void* signal) const;
virtual bool CreateUserEvent(amd::UserEvent* event) const;
+5 -1
View File
@@ -32,6 +32,7 @@
#include "hsa/hsa_ven_amd_aqlprofile.h"
#include "rocsched.hpp"
#include "device/device.hpp"
#include "os/os.hpp"
#include <stack>
namespace amd::roc {
@@ -49,7 +50,7 @@ constexpr static uint64_t kUnlimitedWait = std::numeric_limits<uint64_t>::max();
constexpr static uint64_t kTimeout4Secs = 4 * M;
inline bool WaitForSignal(hsa_signal_t signal, bool active_wait = false) {
inline bool WaitForSignal(hsa_signal_t signal, bool active_wait = false, bool yield = false) {
hsa_wait_state_t wait_state = HSA_WAIT_STATE_BLOCKED;
if (active_wait) {
@@ -81,6 +82,9 @@ inline bool WaitForSignal(hsa_signal_t signal, bool active_wait = false) {
"(0x%lx) for %d ns", signal.handle, kTimeout4Secs);
return true;
}
if (yield && wait_state == HSA_WAIT_STATE_ACTIVE) {
amd::Os::yield();
}
}
}