kfdtest: Add event-based synchronization mechanism to queues

Wait4PacketConsumption now can accept an event to wait all packets subbmitted
to be processed.

Change-Id: I1497b7704e892b04d05811b8d3e4742237c1be57
Signed-off-by: xinhui pan <xinhui.pan@amd.com>


[ROCm/ROCR-Runtime commit: 9c7cfc0df2]
Esse commit está contido em:
xinhui pan
2018-08-27 14:56:48 +08:00
commit de Xinhui Pan
commit 718af9febc
6 arquivos alterados com 44 adições e 2 exclusões
@@ -116,7 +116,8 @@ void BaseQueue::PlaceAndSubmitPacket(const BasePacket &packet) {
SubmitPacket();
}
void BaseQueue::Wait4PacketConsumption() {
void BaseQueue::Wait4PacketConsumption(HsaEvent *event) {
ASSERT_TRUE(!event) << "Not supported!" << std::endl;
ASSERT_TRUE(WaitOnValue(m_Resources.Queue_read_ptr, RptrWhenConsumed()));
}
@@ -63,7 +63,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();
virtual void Wait4PacketConsumption(HsaEvent *event = NULL);
/** @brief Place packet and submit it in one function
*/
virtual void PlaceAndSubmitPacket(const BasePacket &packet);
@@ -71,3 +71,15 @@ void PM4Queue::SubmitPacket() {
}
}
void PM4Queue::Wait4PacketConsumption(HsaEvent *event) {
if (event) {
PlaceAndSubmitPacket(PM4ReleaseMemoryPacket(0,
event->EventData.HWData2,
event->EventId,
true));
EXPECT_SUCCESS(hsaKmtWaitOnEvent(event, g_TestTimeOut));
} else {
BaseQueue::Wait4PacketConsumption();
}
}
@@ -41,6 +41,14 @@ class PM4Queue : public BaseQueue {
virtual unsigned int Wptr();
// @ return expected m_Resources.Queue_read_ptr when all packets consumed
virtual unsigned int RptrWhenConsumed();
/** 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.
* If event is set, wait all packets being processed.
* And we can benefit from that as it has
* 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);
protected:
virtual PACKETTYPE PacketTypeSupported() { return PACKETTYPE_PM4; }
@@ -22,6 +22,7 @@
*/
#include "SDMAQueue.hpp"
#include "SDMAPacket.hpp"
SDMAQueue::SDMAQueue(void) {
CMD_NOP = 0;
@@ -79,3 +80,14 @@ void SDMAQueue::SubmitPacket() {
}
}
void SDMAQueue::Wait4PacketConsumption(HsaEvent *event) {
if (event) {
PlacePacket(SDMAFencePacket((void*)event->EventData.HWData2, event->EventId));
PlaceAndSubmitPacket(SDMATrapPacket(event->EventId));
EXPECT_SUCCESS(hsaKmtWaitOnEvent(event, g_TestTimeOut));
} else {
BaseQueue::Wait4PacketConsumption();
}
}
@@ -34,6 +34,15 @@ class SDMAQueue : public BaseQueue {
// @brief Update queue write pointer and set the queue doorbell to the queue write pointer
virtual void SubmitPacket();
/** 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.
* If event is set, wait all packets being processed.
* And we can benefit from that as it has
* 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);
protected:
// @ return Write pointer modulo queue size in dwords
virtual unsigned int Wptr();