Skip to content

Commit 83ed9d9

Browse files
Minor cleanup around L0 Fence
remove duplicated functions Change-Id: I815221835b87ab05317b2ac4436ea1321ccd7cab Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
1 parent 13b8929 commit 83ed9d9

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

level_zero/core/source/fence/fence.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,14 @@ ze_result_t FenceImp::queryStatus() {
4040
return *hostAddr == Fence::STATE_CLEARED ? ZE_RESULT_NOT_READY : ZE_RESULT_SUCCESS;
4141
}
4242

43-
bool FenceImp::initialize() {
43+
void FenceImp::initialize() {
4444
NEO::AllocationProperties properties(
4545
cmdQueue->getDevice()->getRootDeviceIndex(), MemoryConstants::cacheLineSize, NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, cmdQueue->getDevice()->getNEODevice()->getDeviceBitfield());
4646
properties.alignment = MemoryConstants::cacheLineSize;
4747
allocation = cmdQueue->getDevice()->getDriverHandle()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
4848
UNRECOVERABLE_IF(allocation == nullptr);
4949

5050
reset();
51-
52-
return true;
5351
}
5452

5553
ze_result_t FenceImp::reset() {

level_zero/core/source/fence/fence.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct Fence : _ze_fence_handle_t {
4040
enum EnqueueState : uint32_t { ENQUEUE_NOT_READY = 0u,
4141
ENQUEUE_READY };
4242

43-
NEO::GraphicsAllocation &getAllocation() { return *allocation; }
43+
NEO::GraphicsAllocation &getAllocation() const { return *allocation; }
4444

4545
uint64_t getGpuAddress() {
4646
UNRECOVERABLE_IF(allocation == nullptr);
@@ -67,11 +67,7 @@ struct FenceImp : public Fence {
6767

6868
ze_result_t reset() override;
6969

70-
static Fence *fromHandle(ze_fence_handle_t handle) { return static_cast<Fence *>(handle); }
71-
72-
inline ze_fence_handle_t toHandle() { return this; }
73-
74-
bool initialize();
70+
void initialize();
7571

7672
protected:
7773
CommandQueueImp *cmdQueue;

level_zero/core/test/unit_tests/sources/fence/test_fence.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,22 @@ TEST_F(FenceTest, whenQueryingStatusThenCsrAllocationsAreDownloaded) {
2121
auto csr = std::make_unique<MockCommandStreamReceiver>(*neoDevice->getExecutionEnvironment(), 0);
2222

2323
Mock<CommandQueue> cmdQueue(device, csr.get());
24-
std::unique_ptr<L0::FenceImp> fence = std::make_unique<L0::FenceImp>(&cmdQueue);
24+
auto fence = Fence::create(&cmdQueue, nullptr);
25+
26+
EXPECT_NE(nullptr, fence);
27+
28+
auto &graphicsAllocation = fence->getAllocation();
29+
30+
EXPECT_EQ(neoDevice->getRootDeviceIndex(), graphicsAllocation.getRootDeviceIndex());
2531

26-
bool result = fence->initialize();
27-
ASSERT_TRUE(result);
2832
EXPECT_FALSE(csr->downloadAllocationsCalled);
2933

30-
fence->queryStatus();
34+
auto status = fence->queryStatus();
35+
EXPECT_EQ(ZE_RESULT_NOT_READY, status);
3136
EXPECT_TRUE(csr->downloadAllocationsCalled);
37+
38+
status = fence->destroy();
39+
EXPECT_EQ(ZE_RESULT_SUCCESS, status);
3240
}
3341

3442
} // namespace ult

0 commit comments

Comments
 (0)