diff --git a/projects/rocr-runtime/tests/kfdtest/src/BaseQueue.cpp b/projects/rocr-runtime/tests/kfdtest/src/BaseQueue.cpp index 5001813f72..46e543ab9b 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/BaseQueue.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/BaseQueue.cpp @@ -119,9 +119,9 @@ void BaseQueue::PlaceAndSubmitPacket(const BasePacket &packet) { SubmitPacket(); } -void BaseQueue::Wait4PacketConsumption(HsaEvent *event) { +void BaseQueue::Wait4PacketConsumption(HsaEvent *event, unsigned int timeOut) { ASSERT_TRUE(!event) << "Not supported!" << std::endl; - ASSERT_TRUE(WaitOnValue(m_Resources.Queue_read_ptr, RptrWhenConsumed())); + ASSERT_TRUE(WaitOnValue(m_Resources.Queue_read_ptr, RptrWhenConsumed(), timeOut)); } bool BaseQueue::AllPacketsSubmitted() { diff --git a/projects/rocr-runtime/tests/kfdtest/src/BaseQueue.hpp b/projects/rocr-runtime/tests/kfdtest/src/BaseQueue.hpp index 23df1d1ad6..c0dd1eb840 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/BaseQueue.hpp +++ b/projects/rocr-runtime/tests/kfdtest/src/BaseQueue.hpp @@ -64,7 +64,7 @@ class BaseQueue { /** Wait for all the packets submitted to the queue to be consumed. (i.e. wait until RPTR=WPTR). * Note that all packets being consumed is not the same as all packets being processed. */ - virtual void Wait4PacketConsumption(HsaEvent *event = NULL); + virtual void Wait4PacketConsumption(HsaEvent *event = NULL, unsigned int timeOut = g_TestTimeOut); /** @brief Place packet and submit it in one function */ virtual void PlaceAndSubmitPacket(const BasePacket &packet); diff --git a/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.cpp b/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.cpp index b316909139..af9b3b3056 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.cpp @@ -44,9 +44,7 @@ uint64_t RoundToPowerOf2(uint64_t val) { return val; } -bool WaitOnValue(const volatile unsigned int *buf, unsigned int value) { - unsigned int timeOut = g_TestTimeOut; - +bool WaitOnValue(const volatile unsigned int *buf, unsigned int value, unsigned int timeOut) { while (timeOut > 0 && *buf != value) { Delay(1); diff --git a/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.hpp b/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.hpp index fb4937e7dc..b65dd96531 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.hpp +++ b/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtil.hpp @@ -38,7 +38,7 @@ class BaseQueue; uint64_t RoundToPowerOf2(uint64_t val); // @brief: waits until the value is written to the buffer or until time out if received through args -bool WaitOnValue(const volatile unsigned int *buf, unsigned int value); +bool WaitOnValue(const volatile unsigned int *buf, unsigned int value, unsigned int timeOut = g_TestTimeOut); void SplitU64(const HSAuint64 value, unsigned int& rLoPart, unsigned int& rHiPart); diff --git a/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtilQueue.cpp b/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtilQueue.cpp index 46c88cf702..8369e5a9f8 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtilQueue.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/KFDTestUtilQueue.cpp @@ -61,7 +61,10 @@ class AsyncMPSQ { /* Return only when all packets are consumed. * If there is any packet issues some IO operations, wait these IO to complete too. */ - void Wait(void) { ASSERT_NE((HSAuint64)m_queue, NULL); m_queue->Wait4PacketConsumption(m_event); } + void Wait(void) { + ASSERT_NE((HSAuint64)m_queue, NULL); + m_queue->Wait4PacketConsumption(m_event, std::max((unsigned int)6000, g_TestTimeOut)); + } /* Report the time used between packet [begin, end) in Global Counter on success. * Return 0 on failure. diff --git a/projects/rocr-runtime/tests/kfdtest/src/PM4Queue.cpp b/projects/rocr-runtime/tests/kfdtest/src/PM4Queue.cpp index 99707fb9ad..74c1035d01 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/PM4Queue.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/PM4Queue.cpp @@ -71,14 +71,14 @@ void PM4Queue::SubmitPacket() { } } -void PM4Queue::Wait4PacketConsumption(HsaEvent *event) { +void PM4Queue::Wait4PacketConsumption(HsaEvent *event, unsigned int timeOut) { if (event) { PlaceAndSubmitPacket(PM4ReleaseMemoryPacket(0, event->EventData.HWData2, event->EventId, true)); - EXPECT_SUCCESS(hsaKmtWaitOnEvent(event, g_TestTimeOut)); + EXPECT_SUCCESS(hsaKmtWaitOnEvent(event, timeOut)); } else { BaseQueue::Wait4PacketConsumption(); } diff --git a/projects/rocr-runtime/tests/kfdtest/src/PM4Queue.hpp b/projects/rocr-runtime/tests/kfdtest/src/PM4Queue.hpp index 64e8f4ec96..340356ee47 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/PM4Queue.hpp +++ b/projects/rocr-runtime/tests/kfdtest/src/PM4Queue.hpp @@ -48,7 +48,7 @@ class PM4Queue : public BaseQueue { * 1) Less CPU usage (process can sleep, waiting for interrupt). * 2) Lower latency (GPU only updates RPTR in memory periodically). */ - virtual void Wait4PacketConsumption(HsaEvent *event = NULL); + virtual void Wait4PacketConsumption(HsaEvent *event = NULL, unsigned int timeOut = g_TestTimeOut); protected: virtual PACKETTYPE PacketTypeSupported() { return PACKETTYPE_PM4; } diff --git a/projects/rocr-runtime/tests/kfdtest/src/SDMAQueue.cpp b/projects/rocr-runtime/tests/kfdtest/src/SDMAQueue.cpp index 047b9eae74..facbeee60d 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/SDMAQueue.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/SDMAQueue.cpp @@ -80,13 +80,13 @@ void SDMAQueue::SubmitPacket() { } } -void SDMAQueue::Wait4PacketConsumption(HsaEvent *event) { +void SDMAQueue::Wait4PacketConsumption(HsaEvent *event, unsigned int timeOut) { if (event) { PlacePacket(SDMAFencePacket((void*)event->EventData.HWData2, event->EventId)); PlaceAndSubmitPacket(SDMATrapPacket(event->EventId)); - EXPECT_SUCCESS(hsaKmtWaitOnEvent(event, g_TestTimeOut)); + EXPECT_SUCCESS(hsaKmtWaitOnEvent(event, timeOut)); } else { BaseQueue::Wait4PacketConsumption(); } diff --git a/projects/rocr-runtime/tests/kfdtest/src/SDMAQueue.hpp b/projects/rocr-runtime/tests/kfdtest/src/SDMAQueue.hpp index 75a0f2a250..0a34fd56f4 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/SDMAQueue.hpp +++ b/projects/rocr-runtime/tests/kfdtest/src/SDMAQueue.hpp @@ -41,7 +41,7 @@ class SDMAQueue : public BaseQueue { * 1) Less CPU usage (process can sleep, waiting for interrupt). * 2) Lower latency (GPU only updates RPTR in memory periodically). */ - virtual void Wait4PacketConsumption(HsaEvent *event = NULL); + virtual void Wait4PacketConsumption(HsaEvent *event = NULL, unsigned int timeOut = g_TestTimeOut); protected: // @ return Write pointer modulo queue size in dwords