|
20 | 20 | #include "shared/test/common/mocks/mock_command_stream_receiver.h" |
21 | 21 | #include "shared/test/common/mocks/mock_graphics_allocation.h" |
22 | 22 | #include "shared/test/common/mocks/mock_memory_manager.h" |
| 23 | +#include "shared/test/common/mocks/mock_memory_operations_handler.h" |
23 | 24 | #include "shared/test/common/mocks/ult_device_factory.h" |
24 | 25 |
|
25 | 26 | #include "test.h" |
@@ -2030,5 +2031,82 @@ TEST_F(CommandQueueCreate, givenOverrideCmdQueueSyncModeToSynchronousWhenCommand |
2030 | 2031 |
|
2031 | 2032 | commandQueue->destroy(); |
2032 | 2033 | } |
| 2034 | + |
| 2035 | +struct DeviceWithDualStorage : Test<DeviceFixture> { |
| 2036 | + void SetUp() override { |
| 2037 | + NEO::MockCompilerEnableGuard mock(true); |
| 2038 | + DebugManager.flags.EnableLocalMemory.set(1); |
| 2039 | + DebugManager.flags.AllocateSharedAllocationsWithCpuAndGpuStorage.set(1); |
| 2040 | + DeviceFixture::SetUp(); |
| 2041 | + } |
| 2042 | + void TearDown() override { |
| 2043 | + DeviceFixture::TearDown(); |
| 2044 | + } |
| 2045 | + DebugManagerStateRestore restorer; |
| 2046 | +}; |
| 2047 | + |
| 2048 | +HWTEST2_F(DeviceWithDualStorage, givenCmdListWithAppendedKernelAndUsmTransferAndBlitterDisabledWhenExecuteCmdListThenCfeStateOnceProgrammed, IsAtLeastXeHpCore) { |
| 2049 | + using CFE_STATE = typename FamilyType::CFE_STATE; |
| 2050 | + neoDevice->executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<MockMemoryOperationsHandler>(); |
| 2051 | + ze_result_t res = ZE_RESULT_SUCCESS; |
| 2052 | + |
| 2053 | + const ze_command_queue_desc_t desc = {}; |
| 2054 | + auto commandQueue = whitebox_cast(CommandQueue::create(productFamily, |
| 2055 | + device, |
| 2056 | + neoDevice->getInternalEngine().commandStreamReceiver, |
| 2057 | + &desc, |
| 2058 | + false, |
| 2059 | + false, |
| 2060 | + res)); |
| 2061 | + EXPECT_EQ(ZE_RESULT_SUCCESS, res); |
| 2062 | + ASSERT_NE(nullptr, commandQueue); |
| 2063 | + |
| 2064 | + auto commandList = std::unique_ptr<CommandList>(whitebox_cast(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, res))); |
| 2065 | + EXPECT_EQ(ZE_RESULT_SUCCESS, res); |
| 2066 | + ASSERT_NE(nullptr, commandList); |
| 2067 | + Mock<Kernel> kernel; |
| 2068 | + kernel.immutableData.device = device; |
| 2069 | + size_t size = 10; |
| 2070 | + size_t alignment = 1u; |
| 2071 | + void *ptr = nullptr; |
| 2072 | + ze_device_mem_alloc_desc_t deviceDesc = {}; |
| 2073 | + ze_host_mem_alloc_desc_t hostDesc = {}; |
| 2074 | + res = context->allocSharedMem(device->toHandle(), |
| 2075 | + &deviceDesc, |
| 2076 | + &hostDesc, |
| 2077 | + size, alignment, &ptr); |
| 2078 | + EXPECT_EQ(ZE_RESULT_SUCCESS, res); |
| 2079 | + auto gpuAlloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(ptr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex()); |
| 2080 | + kernel.residencyContainer.push_back(gpuAlloc); |
| 2081 | + |
| 2082 | + ze_group_count_t dispatchFunctionArguments{1, 1, 1}; |
| 2083 | + commandList->appendLaunchKernel(kernel.toHandle(), &dispatchFunctionArguments, nullptr, 0, nullptr); |
| 2084 | + auto deviceImp = static_cast<DeviceImp *>(device); |
| 2085 | + auto pageFaultCmdQueue = whitebox_cast(deviceImp->pageFaultCommandList->cmdQImmediate); |
| 2086 | + |
| 2087 | + auto sizeBefore = commandQueue->commandStream->getUsed(); |
| 2088 | + auto pageFaultSizeBefore = pageFaultCmdQueue->commandStream->getUsed(); |
| 2089 | + auto handle = commandList->toHandle(); |
| 2090 | + commandQueue->executeCommandLists(1, &handle, nullptr, true); |
| 2091 | + auto sizeAfter = commandQueue->commandStream->getUsed(); |
| 2092 | + auto pageFaultSizeAfter = pageFaultCmdQueue->commandStream->getUsed(); |
| 2093 | + EXPECT_LT(sizeBefore, sizeAfter); |
| 2094 | + EXPECT_LT(pageFaultSizeBefore, pageFaultSizeAfter); |
| 2095 | + |
| 2096 | + GenCmdList commands; |
| 2097 | + CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(commandQueue->commandStream->getCpuBase(), 0), |
| 2098 | + sizeAfter); |
| 2099 | + auto count = findAll<CFE_STATE *>(commands.begin(), commands.end()).size(); |
| 2100 | + EXPECT_EQ(0u, count); |
| 2101 | + |
| 2102 | + CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(pageFaultCmdQueue->commandStream->getCpuBase(), 0), |
| 2103 | + pageFaultSizeAfter); |
| 2104 | + count = findAll<CFE_STATE *>(commands.begin(), commands.end()).size(); |
| 2105 | + EXPECT_EQ(1u, count); |
| 2106 | + |
| 2107 | + res = context->freeMem(ptr); |
| 2108 | + ASSERT_EQ(ZE_RESULT_SUCCESS, res); |
| 2109 | + commandQueue->destroy(); |
| 2110 | +} |
2033 | 2111 | } // namespace ult |
2034 | 2112 | } // namespace L0 |
0 commit comments