diff --git a/projects/clr/hipamd/include/hcc_detail/hip_hcc.h b/projects/clr/hipamd/include/hcc_detail/hip_hcc.h index 07bbe95742..db51a497e9 100644 --- a/projects/clr/hipamd/include/hcc_detail/hip_hcc.h +++ b/projects/clr/hipamd/include/hcc_detail/hip_hcc.h @@ -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 _signalPool; // Pool of signals for use by this stream. - + uint32_t _signalCnt; uint32_t _kernelCnt; SIGSEQNUM _stream_sig_id; // Monotonically increasing unique signal id. }; diff --git a/projects/clr/hipamd/src/hip_hcc.cpp b/projects/clr/hipamd/src/hip_hcc.cpp index a319234538..54a16a56d8 100644 --- a/projects/clr/hipamd/src/hip_hcc.cpp +++ b/projects/clr/hipamd/src/hip_hcc.cpp @@ -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; }