remove stream locks where it is safe to do so
这个提交包含在:
+1
-3
@@ -191,10 +191,8 @@ hipError_t hipEventSynchronize(hipEvent_t event) {
|
|||||||
ctx->locked_syncDefaultStream(true, true);
|
ctx->locked_syncDefaultStream(true, true);
|
||||||
return ihipLogStatus(hipSuccess);
|
return ihipLogStatus(hipSuccess);
|
||||||
} else {
|
} else {
|
||||||
ecd._stream->locked_eventWaitComplete(
|
ecd.marker().wait((event->_flags & hipEventBlockingSync) ? hc::hcWaitModeBlocked
|
||||||
ecd.marker(), (event->_flags & hipEventBlockingSync) ? hc::hcWaitModeBlocked
|
|
||||||
: hc::hcWaitModeActive);
|
: hc::hcWaitModeActive);
|
||||||
|
|
||||||
return ihipLogStatus(hipSuccess);
|
return ihipLogStatus(hipSuccess);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+10
-20
@@ -316,16 +316,20 @@ void ihipStream_t::wait(LockedAccessor_StreamCrit_t& crit) {
|
|||||||
tprintf(DB_SYNC, "%s wait for queue-empty..\n", ToString(this).c_str());
|
tprintf(DB_SYNC, "%s wait for queue-empty..\n", ToString(this).c_str());
|
||||||
|
|
||||||
crit->_av.wait(waitMode());
|
crit->_av.wait(waitMode());
|
||||||
|
|
||||||
crit->_kernelCnt = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---
|
//---
|
||||||
// Wait for all kernel and data copy commands in this stream to complete.
|
// Wait for all kernel and data copy commands in this stream to complete.
|
||||||
void ihipStream_t::locked_wait() {
|
void ihipStream_t::locked_wait() {
|
||||||
LockedAccessor_StreamCrit_t crit(_criticalData);
|
// create a marker while holding stream lock,
|
||||||
|
// but release lock prior to waiting on the marker
|
||||||
|
hc::completion_future marker;
|
||||||
|
{
|
||||||
|
LockedAccessor_StreamCrit_t crit(_criticalData);
|
||||||
|
marker = crit->_av.create_marker(hc::no_scope);
|
||||||
|
}
|
||||||
|
|
||||||
wait(crit);
|
marker.wait(waitMode());
|
||||||
};
|
};
|
||||||
|
|
||||||
// Causes current stream to wait for specified event to complete:
|
// Causes current stream to wait for specified event to complete:
|
||||||
@@ -340,30 +344,14 @@ void ihipStream_t::locked_streamWaitEvent(ihipEventData_t& ecd) {
|
|||||||
// Causes current stream to wait for specified event to complete:
|
// Causes current stream to wait for specified event to complete:
|
||||||
// Note this does not provide any kind of host serialization.
|
// Note this does not provide any kind of host serialization.
|
||||||
bool ihipStream_t::locked_eventIsReady(hipEvent_t event) {
|
bool ihipStream_t::locked_eventIsReady(hipEvent_t event) {
|
||||||
// Event query that returns "Complete" may cause HCC to manipulate
|
|
||||||
// internal queue state so lock the stream's queue here.
|
|
||||||
LockedAccessor_StreamCrit_t scrit(_criticalData);
|
|
||||||
|
|
||||||
LockedAccessor_EventCrit_t ecrit(event->criticalData());
|
LockedAccessor_EventCrit_t ecrit(event->criticalData());
|
||||||
|
|
||||||
return (ecrit->_eventData.marker().is_ready());
|
return (ecrit->_eventData.marker().is_ready());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Waiting on event can cause HCC to reclaim stream resources - so need to lock the stream.
|
|
||||||
void ihipStream_t::locked_eventWaitComplete(hc::completion_future& marker,
|
|
||||||
hc::hcWaitMode waitMode) {
|
|
||||||
LockedAccessor_StreamCrit_t crit(_criticalData);
|
|
||||||
|
|
||||||
marker.wait(waitMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Create a marker in this stream.
|
// Create a marker in this stream.
|
||||||
// Save state in the event so it can track the status of the event.
|
// Save state in the event so it can track the status of the event.
|
||||||
hc::completion_future ihipStream_t::locked_recordEvent(hipEvent_t event) {
|
hc::completion_future ihipStream_t::locked_recordEvent(hipEvent_t event) {
|
||||||
// Lock the stream to prevent simultaneous access
|
|
||||||
LockedAccessor_StreamCrit_t crit(_criticalData);
|
|
||||||
|
|
||||||
auto scopeFlag = hc::accelerator_scope;
|
auto scopeFlag = hc::accelerator_scope;
|
||||||
// The env var HIP_EVENT_SYS_RELEASE sets the default,
|
// The env var HIP_EVENT_SYS_RELEASE sets the default,
|
||||||
// The explicit flags override the env var (if specified)
|
// The explicit flags override the env var (if specified)
|
||||||
@@ -375,6 +363,8 @@ hc::completion_future ihipStream_t::locked_recordEvent(hipEvent_t event) {
|
|||||||
scopeFlag = HIP_EVENT_SYS_RELEASE ? hc::system_scope : hc::accelerator_scope;
|
scopeFlag = HIP_EVENT_SYS_RELEASE ? hc::system_scope : hc::accelerator_scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lock the stream to prevent simultaneous access
|
||||||
|
LockedAccessor_StreamCrit_t crit(_criticalData);
|
||||||
return crit->_av.create_marker(scopeFlag);
|
return crit->_av.create_marker(scopeFlag);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -476,7 +476,7 @@ template <typename MUTEX_TYPE>
|
|||||||
class ihipStreamCriticalBase_t : public LockedBase<MUTEX_TYPE> {
|
class ihipStreamCriticalBase_t : public LockedBase<MUTEX_TYPE> {
|
||||||
public:
|
public:
|
||||||
ihipStreamCriticalBase_t(ihipStream_t* parentStream, hc::accelerator_view av)
|
ihipStreamCriticalBase_t(ihipStream_t* parentStream, hc::accelerator_view av)
|
||||||
: _kernelCnt(0), _av(av), _parent(parentStream){};
|
: _av(av), _parent(parentStream){};
|
||||||
|
|
||||||
~ihipStreamCriticalBase_t() {}
|
~ihipStreamCriticalBase_t() {}
|
||||||
|
|
||||||
@@ -500,7 +500,6 @@ class ihipStreamCriticalBase_t : public LockedBase<MUTEX_TYPE> {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ihipStream_t* _parent;
|
ihipStream_t* _parent;
|
||||||
uint32_t _kernelCnt; // Count of inflight kernels in this stream. Reset at ::wait().
|
|
||||||
|
|
||||||
hc::accelerator_view _av;
|
hc::accelerator_view _av;
|
||||||
|
|
||||||
@@ -564,7 +563,6 @@ class ihipStream_t {
|
|||||||
hc::completion_future locked_recordEvent(hipEvent_t event);
|
hc::completion_future locked_recordEvent(hipEvent_t event);
|
||||||
|
|
||||||
bool locked_eventIsReady(hipEvent_t event);
|
bool locked_eventIsReady(hipEvent_t event);
|
||||||
void locked_eventWaitComplete(hc::completion_future& marker, hc::hcWaitMode waitMode);
|
|
||||||
|
|
||||||
ihipStreamCritical_t& criticalData() { return _criticalData; };
|
ihipStreamCritical_t& criticalData() { return _criticalData; };
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -142,9 +142,8 @@ hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int
|
|||||||
// conservative wait on host for the specified event to complete:
|
// conservative wait on host for the specified event to complete:
|
||||||
// return _stream->locked_eventWaitComplete(this, waitMode);
|
// return _stream->locked_eventWaitComplete(this, waitMode);
|
||||||
//
|
//
|
||||||
ecd._stream->locked_eventWaitComplete(
|
ecd.marker().wait((event->_flags & hipEventBlockingSync) ? hc::hcWaitModeBlocked
|
||||||
ecd.marker(), (event->_flags & hipEventBlockingSync) ? hc::hcWaitModeBlocked
|
: hc::hcWaitModeActive);
|
||||||
: hc::hcWaitModeActive);
|
|
||||||
} else {
|
} else {
|
||||||
stream = ihipSyncAndResolveStream(stream);
|
stream = ihipSyncAndResolveStream(stream);
|
||||||
// This will use create_blocking_marker to wait on the specified queue.
|
// This will use create_blocking_marker to wait on the specified queue.
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户