Fix for kernel synchronization
The completion future of a particular kernel is lost if there are
multiple kernels in the stream. This can cause a racing condition where
the signal associated with the unreferenced completion_future might get
released by hcc runtime.
[ROCm/clr commit: 6773a64b22]
This commit is contained in:
@@ -440,9 +440,13 @@ public:
|
|||||||
hc::accelerator_view _av;
|
hc::accelerator_view _av;
|
||||||
unsigned _flags;
|
unsigned _flags;
|
||||||
|
|
||||||
private: // Critical Data. THis MUST be accessed through LockedAccessor_StreamCrit_t
|
private:
|
||||||
|
// Critical Data. THis MUST be accessed through LockedAccessor_StreamCrit_t
|
||||||
ihipStreamCritical_t _criticalData;
|
ihipStreamCritical_t _criticalData;
|
||||||
|
|
||||||
|
// Array of dependency completion_future.
|
||||||
|
std::vector<hc::completion_future> _depFutures;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void enqueueBarrier(hsa_queue_t* queue, ihipSignal_t *depSignal);
|
void enqueueBarrier(hsa_queue_t* queue, ihipSignal_t *depSignal);
|
||||||
void waitCopy(LockedAccessor_StreamCrit_t &crit, ihipSignal_t *signal);
|
void waitCopy(LockedAccessor_StreamCrit_t &crit, ihipSignal_t *signal);
|
||||||
|
|||||||
@@ -181,6 +181,8 @@ void ihipStream_t::wait(LockedAccessor_StreamCrit_t &crit, bool assertQueueEmpty
|
|||||||
// Reset the stream to "empty" - next command will not set up an inpute dependency on any older signal.
|
// Reset the stream to "empty" - next command will not set up an inpute dependency on any older signal.
|
||||||
crit->_last_command_type = ihipCommandCopyH2D;
|
crit->_last_command_type = ihipCommandCopyH2D;
|
||||||
crit->_last_copy_signal = NULL;
|
crit->_last_copy_signal = NULL;
|
||||||
|
|
||||||
|
_depFutures.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -428,6 +430,9 @@ int ihipStream_t::preCopyCommand(LockedAccessor_StreamCrit_t &crit, ihipSignal_t
|
|||||||
needSync = 1;
|
needSync = 1;
|
||||||
hsa_signal_t *hsaSignal = (static_cast<hsa_signal_t*> (crit->_last_kernel_future.get_native_handle()));
|
hsa_signal_t *hsaSignal = (static_cast<hsa_signal_t*> (crit->_last_kernel_future.get_native_handle()));
|
||||||
if (hsaSignal) {
|
if (hsaSignal) {
|
||||||
|
// Keep reference to the kernel future in order to keep the
|
||||||
|
// dependent signal alive.
|
||||||
|
_depFutures.push_back(crit->_last_kernel_future);
|
||||||
*waitSignal = * hsaSignal;
|
*waitSignal = * hsaSignal;
|
||||||
} else {
|
} else {
|
||||||
assert(0); // if NULL signal, and we return 1, hsa_amd_memory_copy_async will fail. Confirm this never happens.
|
assert(0); // if NULL signal, and we return 1, hsa_amd_memory_copy_async will fail. Confirm this never happens.
|
||||||
|
|||||||
Reference in New Issue
Block a user