TBX csr downloads allocations on queryStatus calls

Change-Id: I57fd98f4227b6d03430db6b96cfd21dd726919a3
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2020-05-13 11:25:29 +02:00
committed by sys_ocldev
parent f3cb94c491
commit ac426b5108
17 changed files with 200 additions and 134 deletions

View File

@@ -16,43 +16,6 @@
namespace L0 {
struct FenceImp : public Fence {
FenceImp(CommandQueueImp *cmdQueueImp) : cmdQueue(cmdQueueImp) {}
~FenceImp() override {
cmdQueue->getDevice()->getDriverHandle()->getMemoryManager()->freeGraphicsMemory(allocation);
allocation = nullptr;
}
ze_result_t destroy() override {
delete this;
return ZE_RESULT_SUCCESS;
}
ze_result_t hostSynchronize(uint32_t timeout) override;
ze_result_t queryStatus() override {
auto csr = cmdQueue->getCsr();
if (csr) {
csr->downloadAllocation(*allocation);
}
auto hostAddr = static_cast<uint64_t *>(allocation->getUnderlyingBuffer());
return *hostAddr == Fence::STATE_CLEARED ? ZE_RESULT_NOT_READY : ZE_RESULT_SUCCESS;
}
ze_result_t reset() override;
static Fence *fromHandle(ze_fence_handle_t handle) { return static_cast<Fence *>(handle); }
inline ze_fence_handle_t toHandle() { return this; }
bool initialize();
protected:
CommandQueueImp *cmdQueue;
};
Fence *Fence::create(CommandQueueImp *cmdQueue, const ze_fence_desc_t *desc) {
auto fence = new FenceImp(cmdQueue);
UNRECOVERABLE_IF(fence == nullptr);
@@ -62,6 +25,21 @@ Fence *Fence::create(CommandQueueImp *cmdQueue, const ze_fence_desc_t *desc) {
return fence;
}
FenceImp::~FenceImp() {
cmdQueue->getDevice()->getDriverHandle()->getMemoryManager()->freeGraphicsMemory(allocation);
allocation = nullptr;
}
ze_result_t FenceImp::queryStatus() {
auto csr = cmdQueue->getCsr();
if (csr) {
csr->downloadAllocations();
}
auto hostAddr = static_cast<uint64_t *>(allocation->getUnderlyingBuffer());
return *hostAddr == Fence::STATE_CLEARED ? ZE_RESULT_NOT_READY : ZE_RESULT_SUCCESS;
}
bool FenceImp::initialize() {
NEO::AllocationProperties properties(
cmdQueue->getDevice()->getRootDeviceIndex(), MemoryConstants::cacheLineSize, NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);