From 96fe08583267005f8aef97c308600396dd417ba5 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 27 Jul 2016 13:48:49 -0500 Subject: [PATCH] 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: 1b2a24d0b8268211ca7d0faa0693669753de54ac] --- projects/clr/hipamd/include/hcc_detail/hip_hcc.h | 6 ++++-- projects/clr/hipamd/src/hip_hcc.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) 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; }