Signal Fix: Added signal limit to allocSignal

1. Did not change the logic in allocSignal
2. Added guard to wait on signal limit

Change-Id: I78f29097e6a584b3c3d78319dac19869067bd1fe


[ROCm/clr commit: 1b2a24d0b8]
This commit is contained in:
Aditya Atluri
2016-07-27 13:48:49 -05:00
parent b99410bd07
commit 96fe085832
2 changed files with 14 additions and 2 deletions
@@ -351,7 +351,9 @@ public:
_last_copy_signal(NULL),
_signalCursor(0),
_oldest_live_sig_id(1),
_stream_sig_id(0)
_stream_sig_id(0),
_kernelCnt(0),
_signalCnt(0)
{
_signalPool.resize(HIP_STREAM_SIGNALS > 0 ? HIP_STREAM_SIGNALS : 1);
};
@@ -378,7 +380,7 @@ public:
int _signalCursor;
SIGSEQNUM _oldest_live_sig_id; // oldest live seq_id, anything < this can be allocated.
std::deque<ihipSignal_t> _signalPool; // Pool of signals for use by this stream.
uint32_t _signalCnt;
uint32_t _kernelCnt;
SIGSEQNUM _stream_sig_id; // Monotonically increasing unique signal id.
};
+10
View File
@@ -293,6 +293,8 @@ ihipDevice_t * ihipStream_t::getDevice() const
return ::getDevice(_device_index);
};
#define HIP_NUM_SIGNALS_PER_STREAM 32
//---
// Allocate a new signal from the signal pool.
@@ -301,8 +303,16 @@ ihipDevice_t * ihipStream_t::getDevice() const
ihipSignal_t *ihipStream_t::allocSignal(LockedAccessor_StreamCrit_t &crit)
{
int numToScan = crit->_signalPool.size();
crit->_signalCnt++;
if(crit->_signalCnt == HIP_NUM_SIGNALS_PER_STREAM){
crit->_signalCnt = 0;
this->wait(crit);
}
do {
auto thisCursor = crit->_signalCursor;
if (++crit->_signalCursor == crit->_signalPool.size()) {
crit->_signalCursor = 0;
}