Skip to content

Commit 496f785

Browse files
Refactor copy and fill tests with events
Related-To: NEO-7434 Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent d965869 commit 496f785

File tree

7 files changed

+1882
-1652
lines changed

7 files changed

+1882
-1652
lines changed

level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,36 @@ void ImmediateCmdListSharedHeapsFixture::setUp() {
137137
ModuleMutableCommandListFixture::setUp();
138138
}
139139

140+
bool AppendFillFixture::MockDriverFillHandle::findAllocationDataForRange(const void *buffer,
141+
size_t size,
142+
NEO::SvmAllocationData **allocData) {
143+
mockAllocation.reset(new NEO::MockGraphicsAllocation(const_cast<void *>(buffer), size));
144+
data.gpuAllocations.addAllocation(mockAllocation.get());
145+
if (allocData) {
146+
*allocData = &data;
147+
}
148+
return true;
149+
}
150+
151+
void AppendFillFixture::setUp() {
152+
dstPtr = new uint8_t[allocSize];
153+
immediateDstPtr = new uint8_t[allocSize];
154+
155+
neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get());
156+
auto mockBuiltIns = new MockBuiltins();
157+
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns);
158+
NEO::DeviceVector devices;
159+
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
160+
driverHandle = std::make_unique<Mock<MockDriverFillHandle>>();
161+
driverHandle->initialize(std::move(devices));
162+
device = driverHandle->devices[0];
163+
neoDevice->deviceInfo.maxWorkGroupSize = 256;
164+
}
165+
166+
void AppendFillFixture::tearDown() {
167+
delete[] immediateDstPtr;
168+
delete[] dstPtr;
169+
}
170+
140171
} // namespace ult
141172
} // namespace L0

level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.h

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,72 @@ struct ImmediateCmdListSharedHeapsFixture : public ModuleMutableCommandListFixtu
124124
DebugManagerStateRestore restorer;
125125
};
126126

127+
class AppendFillFixture : public DeviceFixture {
128+
public:
129+
class MockDriverFillHandle : public L0::DriverHandleImp {
130+
public:
131+
bool findAllocationDataForRange(const void *buffer,
132+
size_t size,
133+
NEO::SvmAllocationData **allocData) override;
134+
135+
const uint32_t rootDeviceIndex = 0u;
136+
std::unique_ptr<NEO::GraphicsAllocation> mockAllocation;
137+
NEO::SvmAllocationData data{rootDeviceIndex};
138+
};
139+
140+
template <GFXCORE_FAMILY gfxCoreFamily>
141+
class MockCommandList : public WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>> {
142+
public:
143+
MockCommandList() : WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>() {}
144+
145+
ze_result_t appendLaunchKernelWithParams(Kernel *kernel,
146+
const ze_group_count_t *pThreadGroupDimensions,
147+
Event *event,
148+
const CmdListKernelLaunchParams &launchParams) override {
149+
if (numberOfCallsToAppendLaunchKernelWithParams == thresholdOfCallsToAppendLaunchKernelWithParamsToFail) {
150+
return ZE_RESULT_ERROR_UNKNOWN;
151+
}
152+
if (numberOfCallsToAppendLaunchKernelWithParams < 3) {
153+
threadGroupDimensions[numberOfCallsToAppendLaunchKernelWithParams] = *pThreadGroupDimensions;
154+
xGroupSizes[numberOfCallsToAppendLaunchKernelWithParams] = kernel->getGroupSize()[0];
155+
}
156+
numberOfCallsToAppendLaunchKernelWithParams++;
157+
return CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelWithParams(kernel,
158+
pThreadGroupDimensions,
159+
event,
160+
launchParams);
161+
}
162+
ze_group_count_t threadGroupDimensions[3];
163+
uint32_t xGroupSizes[3];
164+
uint32_t thresholdOfCallsToAppendLaunchKernelWithParamsToFail = std::numeric_limits<uint32_t>::max();
165+
uint32_t numberOfCallsToAppendLaunchKernelWithParams = 0;
166+
};
167+
168+
void setUp();
169+
void tearDown();
170+
171+
DebugManagerStateRestore restorer;
172+
173+
std::unique_ptr<Mock<MockDriverFillHandle>> driverHandle;
174+
NEO::MockDevice *neoDevice = nullptr;
175+
L0::Device *device = nullptr;
176+
static constexpr size_t allocSize = 70;
177+
static constexpr size_t patternSize = 8;
178+
uint8_t *dstPtr = nullptr;
179+
uint8_t pattern[patternSize] = {1, 2, 3, 4};
180+
181+
static constexpr size_t immediateAllocSize = 106;
182+
uint8_t immediatePattern = 4;
183+
uint8_t *immediateDstPtr = nullptr;
184+
};
185+
186+
struct TestExpectedValues {
187+
uint32_t expectedPacketsInUse = 0;
188+
uint32_t expectedKernelCount = 0;
189+
uint32_t expectedWalkerPostSyncOp = 0;
190+
uint32_t expectedPostSyncPipeControls = 0;
191+
bool postSyncAddressZero = false;
192+
};
193+
127194
} // namespace ult
128195
} // namespace L0

level_zero/core/test/unit_tests/sources/cmdlist/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@ target_sources(${TARGET_NAME} PRIVATE
2020
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_launch_kernel_2.cpp
2121
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_launch_kernel_3.cpp
2222
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_memory.cpp
23+
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_multipartition_prologue.cpp
2324
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_signal_event.cpp
2425
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_wait_on_events.cpp
2526
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_blit.cpp
2627
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_fill.cpp
27-
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_append_multipartition_prologue.cpp
2828
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_memory_extension.cpp
2929
)
3030

3131
if(TESTS_XEHP_AND_LATER)
3232
target_sources(${TARGET_NAME} PRIVATE
33+
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_copy_event_xehp_and_later.cpp
34+
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_fill_event_xehp_and_later.cpp
3335
${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_xehp_and_later.cpp
3436
)
3537
endif()

0 commit comments

Comments
 (0)