Minor cleanup around L0 Fence

remove duplicated functions

Change-Id: I815221835b87ab05317b2ac4436ea1321ccd7cab
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski 2020-09-18 14:18:23 +02:00 committed by sys_ocldev
parent 13b8929832
commit 83ed9d9ee4
3 changed files with 15 additions and 13 deletions

View File

@ -40,7 +40,7 @@ ze_result_t FenceImp::queryStatus() {
return *hostAddr == Fence::STATE_CLEARED ? ZE_RESULT_NOT_READY : ZE_RESULT_SUCCESS;
}
bool FenceImp::initialize() {
void FenceImp::initialize() {
NEO::AllocationProperties properties(
cmdQueue->getDevice()->getRootDeviceIndex(), MemoryConstants::cacheLineSize, NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, cmdQueue->getDevice()->getNEODevice()->getDeviceBitfield());
properties.alignment = MemoryConstants::cacheLineSize;
@ -48,8 +48,6 @@ bool FenceImp::initialize() {
UNRECOVERABLE_IF(allocation == nullptr);
reset();
return true;
}
ze_result_t FenceImp::reset() {

View File

@ -40,7 +40,7 @@ struct Fence : _ze_fence_handle_t {
enum EnqueueState : uint32_t { ENQUEUE_NOT_READY = 0u,
ENQUEUE_READY };
NEO::GraphicsAllocation &getAllocation() { return *allocation; }
NEO::GraphicsAllocation &getAllocation() const { return *allocation; }
uint64_t getGpuAddress() {
UNRECOVERABLE_IF(allocation == nullptr);
@ -67,11 +67,7 @@ struct FenceImp : public Fence {
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();
void initialize();
protected:
CommandQueueImp *cmdQueue;

View File

@ -21,14 +21,22 @@ TEST_F(FenceTest, whenQueryingStatusThenCsrAllocationsAreDownloaded) {
auto csr = std::make_unique<MockCommandStreamReceiver>(*neoDevice->getExecutionEnvironment(), 0);
Mock<CommandQueue> cmdQueue(device, csr.get());
std::unique_ptr<L0::FenceImp> fence = std::make_unique<L0::FenceImp>(&cmdQueue);
auto fence = Fence::create(&cmdQueue, nullptr);
EXPECT_NE(nullptr, fence);
auto &graphicsAllocation = fence->getAllocation();
EXPECT_EQ(neoDevice->getRootDeviceIndex(), graphicsAllocation.getRootDeviceIndex());
bool result = fence->initialize();
ASSERT_TRUE(result);
EXPECT_FALSE(csr->downloadAllocationsCalled);
fence->queryStatus();
auto status = fence->queryStatus();
EXPECT_EQ(ZE_RESULT_NOT_READY, status);
EXPECT_TRUE(csr->downloadAllocationsCalled);
status = fence->destroy();
EXPECT_EQ(ZE_RESULT_SUCCESS, status);
}
} // namespace ult