Improve support for L0 uncached device allocations
Make sure UNCACHED flags are translated into setting the MOCS index for uncaching L3. Related-To: NEO-5500 Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
parent
ff31d6abd6
commit
ddca333045
|
@ -190,7 +190,7 @@ ze_result_t ContextImp::openIpcMemHandle(ze_device_handle_t hDevice,
|
|||
DEBUG_BREAK_IF(nullptr == this->driverHandle);
|
||||
return this->driverHandle->openIpcMemHandle(hDevice,
|
||||
handle,
|
||||
ZE_IPC_MEMORY_FLAG_TBD,
|
||||
flags,
|
||||
ptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ struct DriverHandle : _ze_driver_handle_t {
|
|||
virtual ze_result_t closeIpcMemHandle(const void *ptr) = 0;
|
||||
virtual ze_result_t getIpcMemHandle(const void *ptr, ze_ipc_mem_handle_t *pIpcHandle) = 0;
|
||||
virtual ze_result_t openIpcMemHandle(ze_device_handle_t hDevice, ze_ipc_mem_handle_t handle,
|
||||
ze_ipc_memory_flag_t flags, void **ptr) = 0;
|
||||
ze_ipc_memory_flags_t flags, void **ptr) = 0;
|
||||
virtual ze_result_t createEventPool(const ze_event_pool_desc_t *desc,
|
||||
uint32_t numDevices,
|
||||
ze_device_handle_t *phDevices,
|
||||
|
|
|
@ -49,11 +49,11 @@ struct DriverHandleImp : public DriverHandle {
|
|||
ze_result_t freeMem(const void *ptr) override;
|
||||
NEO::MemoryManager *getMemoryManager() override;
|
||||
void setMemoryManager(NEO::MemoryManager *memoryManager) override;
|
||||
MOCKABLE_VIRTUAL void *importFdHandle(ze_device_handle_t hDevice, uint64_t handle);
|
||||
MOCKABLE_VIRTUAL void *importFdHandle(ze_device_handle_t hDevice, ze_ipc_memory_flags_t flags, uint64_t handle);
|
||||
ze_result_t closeIpcMemHandle(const void *ptr) override;
|
||||
ze_result_t getIpcMemHandle(const void *ptr, ze_ipc_mem_handle_t *pIpcHandle) override;
|
||||
ze_result_t openIpcMemHandle(ze_device_handle_t hDevice, ze_ipc_mem_handle_t handle,
|
||||
ze_ipc_memory_flag_t flags, void **ptr) override;
|
||||
ze_ipc_memory_flags_t flags, void **ptr) override;
|
||||
ze_result_t createEventPool(const ze_event_pool_desc_t *desc,
|
||||
uint32_t numDevices,
|
||||
ze_device_handle_t *phDevices,
|
||||
|
|
|
@ -498,8 +498,15 @@ ze_result_t KernelImp::setArgBufferWithAlloc(uint32_t argIndex, uintptr_t argVal
|
|||
setBufferSurfaceState(argIndex, reinterpret_cast<void *>(val), allocation);
|
||||
} else {
|
||||
auto allocData = this->module->getDevice()->getDriverHandle()->getSvmAllocsManager()->getSVMAlloc(reinterpret_cast<void *>(allocation->getGpuAddress()));
|
||||
if (allocData && allocData->allocationFlagsProperty.flags.locallyUncachedResource) {
|
||||
kernelRequiresUncachedMocs = true;
|
||||
if (allocData) {
|
||||
bool argWasUncacheable = isArgUncached[argIndex];
|
||||
bool argIsUncacheable = allocData->allocationFlagsProperty.flags.locallyUncachedResource;
|
||||
if (argWasUncacheable == false && argIsUncacheable) {
|
||||
kernelRequiresUncachedMocsCount++;
|
||||
} else if (argWasUncacheable && argIsUncacheable == false) {
|
||||
kernelRequiresUncachedMocsCount--;
|
||||
}
|
||||
this->setKernelArgUncached(argIndex, argIsUncacheable);
|
||||
}
|
||||
}
|
||||
residencyContainer[argIndex] = allocation;
|
||||
|
@ -682,6 +689,8 @@ ze_result_t KernelImp::initialize(const ze_kernel_desc_t *desc) {
|
|||
|
||||
slmArgSizes.resize(this->kernelArgHandlers.size(), 0);
|
||||
|
||||
isArgUncached.resize(this->kernelArgHandlers.size(), 0);
|
||||
|
||||
if (kernelImmData->getSurfaceStateHeapSize() > 0) {
|
||||
this->surfaceStateHeapData.reset(new uint8_t[kernelImmData->getSurfaceStateHeapSize()]);
|
||||
memcpy_s(this->surfaceStateHeapData.get(),
|
||||
|
|
|
@ -115,7 +115,8 @@ struct KernelImp : Kernel {
|
|||
|
||||
uint32_t getRequiredWorkgroupOrder() const override { return requiredWorkgroupOrder; }
|
||||
bool requiresGenerationOfLocalIdsByRuntime() const override { return kernelRequiresGenerationOfLocalIdsByRuntime; }
|
||||
bool getKernelRequiresUncachedMocs() { return kernelRequiresUncachedMocs; }
|
||||
bool getKernelRequiresUncachedMocs() { return (kernelRequiresUncachedMocsCount > 0); }
|
||||
void setKernelArgUncached(uint32_t index, bool val) { isArgUncached[index] = val; }
|
||||
|
||||
uint32_t *getGlobalOffsets() override {
|
||||
return this->globalOffsets;
|
||||
|
@ -180,7 +181,8 @@ struct KernelImp : Kernel {
|
|||
uint32_t requiredWorkgroupOrder = 0u;
|
||||
|
||||
bool kernelRequiresGenerationOfLocalIdsByRuntime = true;
|
||||
bool kernelRequiresUncachedMocs = false;
|
||||
uint32_t kernelRequiresUncachedMocsCount = false;
|
||||
std::vector<bool> isArgUncached;
|
||||
|
||||
uint32_t globalOffsets[3] = {};
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ ze_result_t DriverHandleImp::getIpcMemHandle(const void *ptr, ze_ipc_mem_handle_
|
|||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
void *DriverHandleImp::importFdHandle(ze_device_handle_t hDevice, uint64_t handle) {
|
||||
void *DriverHandleImp::importFdHandle(ze_device_handle_t hDevice, ze_ipc_memory_flags_t flags, uint64_t handle) {
|
||||
auto neoDevice = Device::fromHandle(hDevice)->getNEODevice();
|
||||
NEO::osHandle osHandle = static_cast<NEO::osHandle>(handle);
|
||||
NEO::AllocationProperties unifiedMemoryProperties{neoDevice->getRootDeviceIndex(),
|
||||
|
@ -49,6 +49,9 @@ void *DriverHandleImp::importFdHandle(ze_device_handle_t hDevice, uint64_t handl
|
|||
allocData.size = alloc->getUnderlyingBufferSize();
|
||||
allocData.memoryType = InternalMemoryType::DEVICE_UNIFIED_MEMORY;
|
||||
allocData.device = neoDevice;
|
||||
if (flags & ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED) {
|
||||
allocData.allocationFlagsProperty.flags.locallyUncachedResource = 1;
|
||||
}
|
||||
|
||||
this->getSvmAllocsManager()->insertSVMAlloc(allocData);
|
||||
|
||||
|
@ -56,14 +59,14 @@ void *DriverHandleImp::importFdHandle(ze_device_handle_t hDevice, uint64_t handl
|
|||
}
|
||||
|
||||
ze_result_t DriverHandleImp::openIpcMemHandle(ze_device_handle_t hDevice, ze_ipc_mem_handle_t pIpcHandle,
|
||||
ze_ipc_memory_flag_t flags, void **ptr) {
|
||||
ze_ipc_memory_flags_t flags, void **ptr) {
|
||||
uint64_t handle = 0u;
|
||||
memcpy_s(&handle,
|
||||
sizeof(handle),
|
||||
reinterpret_cast<void *>(pIpcHandle.data),
|
||||
sizeof(handle));
|
||||
|
||||
*ptr = this->importFdHandle(hDevice, handle);
|
||||
*ptr = this->importFdHandle(hDevice, flags, handle);
|
||||
if (nullptr == *ptr) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
@ -133,7 +136,8 @@ ze_result_t DriverHandleImp::allocDeviceMem(ze_device_handle_t hDevice, const ze
|
|||
if (externalMemoryImportDesc->flags & ZE_EXTERNAL_MEMORY_TYPE_FLAG_OPAQUE_FD) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
|
||||
}
|
||||
*ptr = this->importFdHandle(hDevice, externalMemoryImportDesc->fd);
|
||||
ze_ipc_memory_flags_t flags = {};
|
||||
*ptr = this->importFdHandle(hDevice, flags, externalMemoryImportDesc->fd);
|
||||
if (nullptr == *ptr) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
|
|
@ -1325,7 +1325,8 @@ TEST_F(KernelBindlessUncachedMemoryTests, givenBindlessKernelAndAllocDataNoTfoun
|
|||
EXPECT_FALSE(mockKernel.getKernelRequiresUncachedMocs());
|
||||
}
|
||||
|
||||
TEST_F(KernelBindlessUncachedMemoryTests, givenDeviceAllocationWithUncachedFlagThenKernelRequiresUncachedMocsIsSet) {
|
||||
TEST_F(KernelBindlessUncachedMemoryTests,
|
||||
givenNonUncachedAllocationSetAsArgumentFollowedByNonUncachedAllocationThenRequiresUncachedMocsIsCorrectlySet) {
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
MyMockKernel mockKernel;
|
||||
|
@ -1337,23 +1338,144 @@ TEST_F(KernelBindlessUncachedMemoryTests, givenDeviceAllocationWithUncachedFlagT
|
|||
arg.bindless = undefined<CrossThreadDataOffset>;
|
||||
arg.bindful = undefined<SurfaceStateHeapOffset>;
|
||||
|
||||
void *devicePtr = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
deviceDesc.flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED;
|
||||
ze_result_t res = device->getDriverHandle()->allocDeviceMem(device->toHandle(),
|
||||
&deviceDesc,
|
||||
16384u,
|
||||
0u,
|
||||
&devicePtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
{
|
||||
void *devicePtr = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
ze_result_t res = device->getDriverHandle()->allocDeviceMem(device->toHandle(),
|
||||
&deviceDesc,
|
||||
16384u,
|
||||
0u,
|
||||
&devicePtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto alloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(devicePtr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
|
||||
EXPECT_NE(nullptr, alloc);
|
||||
auto alloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(devicePtr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
|
||||
EXPECT_NE(nullptr, alloc);
|
||||
|
||||
mockKernel.setArgBufferWithAlloc(0, 0x1234, alloc);
|
||||
EXPECT_TRUE(mockKernel.getKernelRequiresUncachedMocs());
|
||||
mockKernel.setArgBufferWithAlloc(0, 0x1234, alloc);
|
||||
EXPECT_FALSE(mockKernel.getKernelRequiresUncachedMocs());
|
||||
device->getDriverHandle()->freeMem(devicePtr);
|
||||
}
|
||||
|
||||
device->getDriverHandle()->freeMem(devicePtr);
|
||||
{
|
||||
void *devicePtr = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
ze_result_t res = device->getDriverHandle()->allocDeviceMem(device->toHandle(),
|
||||
&deviceDesc,
|
||||
16384u,
|
||||
0u,
|
||||
&devicePtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto alloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(devicePtr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
|
||||
EXPECT_NE(nullptr, alloc);
|
||||
|
||||
mockKernel.setArgBufferWithAlloc(0, 0x1234, alloc);
|
||||
EXPECT_FALSE(mockKernel.getKernelRequiresUncachedMocs());
|
||||
device->getDriverHandle()->freeMem(devicePtr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(KernelBindlessUncachedMemoryTests,
|
||||
givenUncachedAllocationSetAsArgumentFollowedByUncachedAllocationThenRequiresUncachedMocsIsCorrectlySet) {
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
MyMockKernel mockKernel;
|
||||
|
||||
mockKernel.module = module.get();
|
||||
mockKernel.initialize(&desc);
|
||||
|
||||
auto &arg = const_cast<NEO::ArgDescPointer &>(mockKernel.kernelImmData->getDescriptor().payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>());
|
||||
arg.bindless = undefined<CrossThreadDataOffset>;
|
||||
arg.bindful = undefined<SurfaceStateHeapOffset>;
|
||||
|
||||
{
|
||||
void *devicePtr = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
deviceDesc.flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED;
|
||||
ze_result_t res = device->getDriverHandle()->allocDeviceMem(device->toHandle(),
|
||||
&deviceDesc,
|
||||
16384u,
|
||||
0u,
|
||||
&devicePtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto alloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(devicePtr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
|
||||
EXPECT_NE(nullptr, alloc);
|
||||
|
||||
mockKernel.setArgBufferWithAlloc(0, 0x1234, alloc);
|
||||
EXPECT_TRUE(mockKernel.getKernelRequiresUncachedMocs());
|
||||
device->getDriverHandle()->freeMem(devicePtr);
|
||||
}
|
||||
|
||||
{
|
||||
void *devicePtr = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
deviceDesc.flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED;
|
||||
ze_result_t res = device->getDriverHandle()->allocDeviceMem(device->toHandle(),
|
||||
&deviceDesc,
|
||||
16384u,
|
||||
0u,
|
||||
&devicePtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto alloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(devicePtr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
|
||||
EXPECT_NE(nullptr, alloc);
|
||||
|
||||
mockKernel.setArgBufferWithAlloc(0, 0x1234, alloc);
|
||||
EXPECT_TRUE(mockKernel.getKernelRequiresUncachedMocs());
|
||||
device->getDriverHandle()->freeMem(devicePtr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(KernelBindlessUncachedMemoryTests,
|
||||
givenUncachedAllocationSetAsArgumentFollowedByNonUncachedAllocationThenRequiresUncachedMocsIsCorrectlySet) {
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = kernelName.c_str();
|
||||
MyMockKernel mockKernel;
|
||||
|
||||
mockKernel.module = module.get();
|
||||
mockKernel.initialize(&desc);
|
||||
|
||||
auto &arg = const_cast<NEO::ArgDescPointer &>(mockKernel.kernelImmData->getDescriptor().payloadMappings.explicitArgs[0].as<NEO::ArgDescPointer>());
|
||||
arg.bindless = undefined<CrossThreadDataOffset>;
|
||||
arg.bindful = undefined<SurfaceStateHeapOffset>;
|
||||
|
||||
{
|
||||
void *devicePtr = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
deviceDesc.flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED;
|
||||
ze_result_t res = device->getDriverHandle()->allocDeviceMem(device->toHandle(),
|
||||
&deviceDesc,
|
||||
16384u,
|
||||
0u,
|
||||
&devicePtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto alloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(devicePtr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
|
||||
EXPECT_NE(nullptr, alloc);
|
||||
|
||||
mockKernel.setArgBufferWithAlloc(0, 0x1234, alloc);
|
||||
EXPECT_TRUE(mockKernel.getKernelRequiresUncachedMocs());
|
||||
device->getDriverHandle()->freeMem(devicePtr);
|
||||
}
|
||||
|
||||
{
|
||||
void *devicePtr = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
ze_result_t res = device->getDriverHandle()->allocDeviceMem(device->toHandle(),
|
||||
&deviceDesc,
|
||||
16384u,
|
||||
0u,
|
||||
&devicePtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto alloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(devicePtr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
|
||||
EXPECT_NE(nullptr, alloc);
|
||||
|
||||
mockKernel.setArgBufferWithAlloc(0, 0x1234, alloc);
|
||||
EXPECT_FALSE(mockKernel.getKernelRequiresUncachedMocs());
|
||||
device->getDriverHandle()->freeMem(devicePtr);
|
||||
}
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
|
|
|
@ -294,7 +294,7 @@ TEST_F(MemoryRelaxedSizeTests,
|
|||
}
|
||||
|
||||
struct DriverHandleGetFdMock : public DriverHandleImp {
|
||||
void *importFdHandle(ze_device_handle_t hDevice, uint64_t handle) override {
|
||||
void *importFdHandle(ze_device_handle_t hDevice, ze_ipc_memory_flags_t flags, uint64_t handle) override {
|
||||
if (mockFd == allocationMap.second) {
|
||||
return allocationMap.first;
|
||||
}
|
||||
|
@ -635,7 +635,7 @@ TEST_F(MemoryIPCTests,
|
|||
result = driverHandle->getIpcMemHandle(ptr, &ipcHandle);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
ze_ipc_memory_flag_t flags = {};
|
||||
ze_ipc_memory_flags_t flags = {};
|
||||
void *ipcPtr;
|
||||
result = driverHandle->openIpcMemHandle(device->toHandle(), ipcHandle, flags, &ipcPtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
@ -673,7 +673,7 @@ TEST_F(MemoryIPCTests,
|
|||
result = contextImp->getIpcMemHandle(ptr, &ipcHandle);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
ze_ipc_memory_flag_t flags = {};
|
||||
ze_ipc_memory_flags_t flags = {};
|
||||
void *ipcPtr;
|
||||
result = contextImp->openIpcMemHandle(device->toHandle(), ipcHandle, flags, &ipcPtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
@ -724,14 +724,14 @@ TEST_F(MemoryIPCTests,
|
|||
TEST_F(MemoryIPCTests,
|
||||
whenCallingOpenIpcHandleWithIncorrectHandleThenInvalidArgumentIsReturned) {
|
||||
ze_ipc_mem_handle_t ipcHandle = {};
|
||||
ze_ipc_memory_flag_t flags = {};
|
||||
ze_ipc_memory_flags_t flags = {};
|
||||
void *ipcPtr;
|
||||
ze_result_t res = driverHandle->openIpcMemHandle(device->toHandle(), ipcHandle, flags, &ipcPtr);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, res);
|
||||
}
|
||||
|
||||
struct DriverHandleGetIpcHandleMock : public DriverHandleImp {
|
||||
void *importFdHandle(ze_device_handle_t hDevice, uint64_t handle) override {
|
||||
void *importFdHandle(ze_device_handle_t hDevice, ze_ipc_memory_flags_t flags, uint64_t handle) override {
|
||||
EXPECT_EQ(handle, static_cast<uint64_t>(mockFd));
|
||||
if (mockFd == allocationMap.second) {
|
||||
return allocationMap.first;
|
||||
|
@ -801,7 +801,7 @@ TEST_F(MemoryGetIpcHandleTest,
|
|||
result = driverHandle->getIpcMemHandle(ptr, &ipcHandle);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
ze_ipc_memory_flag_t flags = {};
|
||||
ze_ipc_memory_flags_t flags = {};
|
||||
void *ipcPtr;
|
||||
result = driverHandle->openIpcMemHandle(device->toHandle(), ipcHandle, flags, &ipcPtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
@ -918,7 +918,7 @@ TEST_F(MemoryOpenIpcHandleTest,
|
|||
result = driverHandle->getIpcMemHandle(ptr, &ipcHandle);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
ze_ipc_memory_flag_t flags = {};
|
||||
ze_ipc_memory_flags_t flags = {};
|
||||
void *ipcPtr;
|
||||
result = driverHandle->openIpcMemHandle(device->toHandle(), ipcHandle, flags, &ipcPtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
@ -976,7 +976,7 @@ TEST_F(MemoryFailedOpenIpcHandleTest,
|
|||
result = driverHandle->getIpcMemHandle(ptr, &ipcHandle);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
ze_ipc_memory_flag_t flags = {};
|
||||
ze_ipc_memory_flags_t flags = {};
|
||||
void *ipcPtr;
|
||||
result = driverHandle->openIpcMemHandle(device->toHandle(), ipcHandle, flags, &ipcPtr);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result);
|
||||
|
@ -1530,5 +1530,33 @@ TEST_F(ContextMemoryTest, givenCallTochangeMemoryOperationStatusToL0ResultTypeTh
|
|||
EXPECT_EQ(res, ZE_RESULT_ERROR_UNKNOWN);
|
||||
}
|
||||
|
||||
using ImportFdUncachedTests = MemoryOpenIpcHandleTest;
|
||||
|
||||
TEST_F(ImportFdUncachedTests,
|
||||
givenCallToImportFdHandleWithUncachedFlagsThenLocallyUncachedResourceIsSet) {
|
||||
ze_ipc_memory_flags_t flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED;
|
||||
uint64_t handle = 1;
|
||||
void *ptr = driverHandle->importFdHandle(device->toHandle(), flags, handle);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
|
||||
auto allocData = driverHandle->svmAllocsManager->getSVMAlloc(ptr);
|
||||
EXPECT_EQ(allocData->allocationFlagsProperty.flags.locallyUncachedResource, 1u);
|
||||
|
||||
driverHandle->freeMem(ptr);
|
||||
}
|
||||
|
||||
TEST_F(ImportFdUncachedTests,
|
||||
givenCallToImportFdHandleWithoutUncachedFlagsThenLocallyUncachedResourceIsNotSet) {
|
||||
ze_ipc_memory_flags_t flags = {};
|
||||
uint64_t handle = 1;
|
||||
void *ptr = driverHandle->importFdHandle(device->toHandle(), flags, handle);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
|
||||
auto allocData = driverHandle->svmAllocsManager->getSVMAlloc(ptr);
|
||||
EXPECT_EQ(allocData->allocationFlagsProperty.flags.locallyUncachedResource, 0u);
|
||||
|
||||
driverHandle->freeMem(ptr);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
|
|
@ -141,7 +141,8 @@ HWTEST2_F(ModuleTest, givenNonPatchedTokenThenSurfaceBaseAddressIsCorrectlySet,
|
|||
|
||||
using ModuleUncachedBufferTest = Test<ModuleFixture>;
|
||||
|
||||
HWTEST2_F(ModuleUncachedBufferTest, givenKernelWithNonUncachedArgumentThenUncachedMocsNotRequired, ModuleTestSupport) {
|
||||
HWTEST2_F(ModuleUncachedBufferTest,
|
||||
givenKernelWithNonUncachedArgumentAndPreviouslyNotSetUncachedThenUncachedMocsNotSet, ModuleTestSupport) {
|
||||
ze_kernel_handle_t kernelHandle;
|
||||
|
||||
ze_kernel_desc_t kernelDesc = {};
|
||||
|
@ -174,7 +175,78 @@ HWTEST2_F(ModuleUncachedBufferTest, givenKernelWithNonUncachedArgumentThenUncach
|
|||
device->getDriverHandle()->freeMem(devicePtr);
|
||||
}
|
||||
|
||||
HWTEST2_F(ModuleUncachedBufferTest, givenKernelWithUncachedArgumentThenCorrectMocsAreSet, ModuleTestSupport) {
|
||||
HWTEST2_F(ModuleUncachedBufferTest,
|
||||
givenKernelWithNonUncachedArgumentAndPreviouslySetUncachedArgumentThenUncachedMocsNotSet, ModuleTestSupport) {
|
||||
ze_kernel_handle_t kernelHandle;
|
||||
|
||||
ze_kernel_desc_t kernelDesc = {};
|
||||
kernelDesc.pKernelName = kernelName.c_str();
|
||||
|
||||
ze_result_t res = module->createKernel(&kernelDesc, &kernelHandle);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto kernelImp = reinterpret_cast<L0::KernelImp *>(L0::Kernel::fromHandle(kernelHandle));
|
||||
|
||||
void *devicePtr = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
res = device->getDriverHandle()->allocDeviceMem(device->toHandle(),
|
||||
&deviceDesc,
|
||||
16384u,
|
||||
0u,
|
||||
&devicePtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto gpuAlloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(devicePtr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
|
||||
EXPECT_NE(nullptr, gpuAlloc);
|
||||
|
||||
uint32_t argIndex = 0u;
|
||||
kernelImp->setKernelArgUncached(argIndex, true);
|
||||
kernelImp->setArgBufferWithAlloc(argIndex, reinterpret_cast<uintptr_t>(devicePtr), gpuAlloc);
|
||||
EXPECT_FALSE(kernelImp->getKernelRequiresUncachedMocs());
|
||||
|
||||
Kernel::fromHandle(kernelHandle)->destroy();
|
||||
|
||||
device->getDriverHandle()->freeMem(devicePtr);
|
||||
}
|
||||
|
||||
HWTEST2_F(ModuleUncachedBufferTest,
|
||||
givenKernelWithUncachedArgumentAndPreviouslyNotSetUncachedArgumentThenUncachedMocsIsSet, ModuleTestSupport) {
|
||||
ze_kernel_handle_t kernelHandle;
|
||||
|
||||
ze_kernel_desc_t kernelDesc = {};
|
||||
kernelDesc.pKernelName = kernelName.c_str();
|
||||
|
||||
ze_result_t res = module->createKernel(&kernelDesc, &kernelHandle);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto kernelImp = reinterpret_cast<L0::KernelImp *>(L0::Kernel::fromHandle(kernelHandle));
|
||||
|
||||
void *devicePtr = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
deviceDesc.flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED;
|
||||
res = device->getDriverHandle()->allocDeviceMem(device->toHandle(),
|
||||
&deviceDesc,
|
||||
16384u,
|
||||
0u,
|
||||
&devicePtr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto gpuAlloc = device->getDriverHandle()->getSvmAllocsManager()->getSVMAllocs()->get(devicePtr)->gpuAllocations.getGraphicsAllocation(device->getRootDeviceIndex());
|
||||
EXPECT_NE(nullptr, gpuAlloc);
|
||||
|
||||
uint32_t argIndex = 0u;
|
||||
kernelImp->setArgBufferWithAlloc(argIndex, reinterpret_cast<uintptr_t>(devicePtr), gpuAlloc);
|
||||
EXPECT_FALSE(kernelImp->getKernelRequiresUncachedMocs());
|
||||
|
||||
Kernel::fromHandle(kernelHandle)->destroy();
|
||||
|
||||
device->getDriverHandle()->freeMem(devicePtr);
|
||||
}
|
||||
|
||||
HWTEST2_F(ModuleUncachedBufferTest,
|
||||
givenKernelWithUncachedArgumentAndPreviouslySetUncachedArgumentThenUncachedMocsIsSet, ModuleTestSupport) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
ze_kernel_handle_t kernelHandle;
|
||||
|
||||
|
@ -201,6 +273,7 @@ HWTEST2_F(ModuleUncachedBufferTest, givenKernelWithUncachedArgumentThenCorrectMo
|
|||
EXPECT_NE(nullptr, gpuAlloc);
|
||||
|
||||
uint32_t argIndex = 0u;
|
||||
kernelImp->setKernelArgUncached(argIndex, true);
|
||||
kernelImp->setArgBufferWithAlloc(argIndex, reinterpret_cast<uintptr_t>(devicePtr), gpuAlloc);
|
||||
EXPECT_FALSE(kernelImp->getKernelRequiresUncachedMocs());
|
||||
|
||||
|
|
|
@ -164,6 +164,8 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
|||
bool peekEvictable() const { return allocationInfo.flags.evictable; }
|
||||
bool isFlushL3Required() const { return allocationInfo.flags.flushL3Required; }
|
||||
void setFlushL3Required(bool flushL3Required) { allocationInfo.flags.flushL3Required = flushL3Required; }
|
||||
|
||||
void setUncacheable(bool uncacheable) { allocationInfo.flags.uncacheable = uncacheable; }
|
||||
bool is32BitAllocation() const { return allocationInfo.flags.is32BitAllocation; }
|
||||
void set32BitAllocation(bool is32BitAllocation) { allocationInfo.flags.is32BitAllocation = is32BitAllocation; }
|
||||
|
||||
|
@ -294,8 +296,9 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
|||
uint32_t coherent : 1;
|
||||
uint32_t evictable : 1;
|
||||
uint32_t flushL3Required : 1;
|
||||
uint32_t uncacheable : 1;
|
||||
uint32_t is32BitAllocation : 1;
|
||||
uint32_t reserved : 28;
|
||||
uint32_t reserved : 27;
|
||||
} flags;
|
||||
uint32_t allFlags = 0u;
|
||||
};
|
||||
|
|
|
@ -187,6 +187,7 @@ void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size,
|
|||
unifiedMemoryProperties.flags.shareable = memoryProperties.allocationFlags.flags.shareable;
|
||||
unifiedMemoryProperties.flags.isUSMDeviceAllocation = true;
|
||||
unifiedMemoryProperties.cacheRegion = MemoryPropertiesHelper::getCacheRegion(memoryProperties.allocationFlags);
|
||||
unifiedMemoryProperties.flags.uncacheable = memoryProperties.allocationFlags.flags.locallyUncachedResource;
|
||||
|
||||
if (memoryProperties.memoryType == InternalMemoryType::HOST_UNIFIED_MEMORY) {
|
||||
unifiedMemoryProperties.flags.isUSMHostAllocation = true;
|
||||
|
|
Loading…
Reference in New Issue