mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 17:20:26 +08:00
Add support for write combined in unified memory
Related-To: NEO-3374 Change-Id: I610ad2d71b056f2bc5b8f4bda72e7f08a45cf59d Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
2c84c143e6
commit
03252ee9fe
@@ -230,6 +230,17 @@ TEST(clUnifiedSharedMemoryTests, whenHostMemAllocWithInvalidPropertiesTokenThenE
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
}
|
||||
|
||||
TEST(clUnifiedSharedMemoryTests, whenHostMemAllocWithInvalidWriteCombinedTokenThenErrorIsReturned) {
|
||||
MockContext mockContext;
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL, 0};
|
||||
|
||||
auto unifiedMemoryHostAllocation = clHostMemAllocINTEL(&mockContext, properties, 4, 0, &retVal);
|
||||
|
||||
EXPECT_EQ(nullptr, unifiedMemoryHostAllocation);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
}
|
||||
|
||||
TEST(clUnifiedSharedMemoryTests, whenDeviceMemAllocWithInvalidPropertiesTokenThenErrorIsReturned) {
|
||||
MockContext mockContext;
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
@@ -253,6 +264,17 @@ TEST(clUnifiedSharedMemoryTests, whenSharedMemAllocWithInvalidPropertiesTokenThe
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
}
|
||||
|
||||
TEST(clUnifiedSharedMemoryTests, whenSharedMemAllocWithInvalidWriteCombinedTokenThenErrorIsReturned) {
|
||||
MockContext mockContext;
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL, 0};
|
||||
|
||||
auto unifiedMemorySharedAllocation = clSharedMemAllocINTEL(&mockContext, mockContext.getDevice(0u), properties, 4, 0, &retVal);
|
||||
|
||||
EXPECT_EQ(nullptr, unifiedMemorySharedAllocation);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
}
|
||||
|
||||
TEST(clUnifiedSharedMemoryTests, givenUnifiedMemoryAllocWithoutPropertiesWhenGetMemAllocFlagsThenDefaultValueIsReturned) {
|
||||
uint64_t defaultValue = CL_MEM_ALLOC_DEFAULT_INTEL;
|
||||
MockContext mockContext;
|
||||
@@ -277,7 +299,7 @@ TEST(clUnifiedSharedMemoryTests, whenClGetMemAllocTypeIsCalledWithValidUnifiedMe
|
||||
size_t paramValueSize = sizeof(cl_mem_properties_intel);
|
||||
cl_mem_properties_intel paramValue = 0;
|
||||
size_t paramValueSizeRet = 0;
|
||||
cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL, 0};
|
||||
cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_DEFAULT_INTEL, 0};
|
||||
|
||||
auto unifiedMemoryHostAllocation = clHostMemAllocINTEL(&mockContext, properties, 4, 0, &retVal);
|
||||
|
||||
@@ -313,7 +335,7 @@ TEST(clUnifiedSharedMemoryTests, whenClGetMemAllocTypeIsCalledWithValidUnifiedMe
|
||||
size_t paramValueSize = sizeof(cl_mem_properties_intel);
|
||||
cl_mem_properties_intel paramValue = 0;
|
||||
size_t paramValueSizeRet = 0;
|
||||
cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL, 0};
|
||||
cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_DEFAULT_INTEL, 0};
|
||||
|
||||
auto unifiedMemorySharedAllocation = clSharedMemAllocINTEL(&mockContext, mockContext.getDevice(0u), properties, 4, 0, &retVal);
|
||||
|
||||
@@ -760,3 +782,56 @@ TEST_F(clUnifiedSharedMemoryEventTests, whenClEnqueueMemFillINTELIsCalledWithEve
|
||||
EXPECT_EQ(expectedCmd, actualCmd);
|
||||
clMemFreeINTEL(this->context, unfiedMemorySharedAllocation);
|
||||
}
|
||||
|
||||
TEST(clUnifiedSharedMemoryTests, givenDefaulMemPropertiesWhenClDeviceMemAllocIntelIsCalledThenItAllocatesDeviceUnifiedMemoryAllocationWithProperAllocationTypeAndSize) {
|
||||
MockContext mockContext;
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_DEFAULT_INTEL, 0};
|
||||
auto allocationSize = 4000u;
|
||||
auto unfiedMemoryDeviceAllocation = clDeviceMemAllocINTEL(&mockContext, mockContext.getDevice(0u), properties, allocationSize, 0, &retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
ASSERT_NE(nullptr, unfiedMemoryDeviceAllocation);
|
||||
|
||||
auto allocationsManager = mockContext.getSVMAllocsManager();
|
||||
EXPECT_EQ(1u, allocationsManager->getNumAllocs());
|
||||
auto graphicsAllocation = allocationsManager->getSVMAlloc(unfiedMemoryDeviceAllocation);
|
||||
EXPECT_EQ(graphicsAllocation->size, allocationSize);
|
||||
EXPECT_EQ(graphicsAllocation->memoryType, InternalMemoryType::DEVICE_UNIFIED_MEMORY);
|
||||
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER, graphicsAllocation->gpuAllocation->getAllocationType());
|
||||
EXPECT_EQ(graphicsAllocation->gpuAllocation->getGpuAddress(), castToUint64(unfiedMemoryDeviceAllocation));
|
||||
EXPECT_EQ(alignUp(allocationSize, MemoryConstants::pageSize64k), graphicsAllocation->gpuAllocation->getUnderlyingBufferSize());
|
||||
|
||||
retVal = clMemFreeINTEL(&mockContext, unfiedMemoryDeviceAllocation);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST(clUnifiedSharedMemoryTests, givenValidMemPropertiesWhenClDeviceMemAllocIntelIsCalledThenItAllocatesDeviceUnifiedMemoryAllocationWithProperAllocationTypeAndSize) {
|
||||
MockContext mockContext;
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
auto allocationSize = 4000u;
|
||||
cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL, 0};
|
||||
auto unfiedMemoryDeviceAllocation = clDeviceMemAllocINTEL(&mockContext, mockContext.getDevice(0u), properties, allocationSize, 0, &retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
ASSERT_NE(nullptr, unfiedMemoryDeviceAllocation);
|
||||
|
||||
auto allocationsManager = mockContext.getSVMAllocsManager();
|
||||
EXPECT_EQ(1u, allocationsManager->getNumAllocs());
|
||||
auto graphicsAllocation = allocationsManager->getSVMAlloc(unfiedMemoryDeviceAllocation);
|
||||
EXPECT_EQ(graphicsAllocation->size, allocationSize);
|
||||
EXPECT_EQ(graphicsAllocation->memoryType, InternalMemoryType::DEVICE_UNIFIED_MEMORY);
|
||||
EXPECT_EQ(graphicsAllocation->gpuAllocation->getAllocationType(), GraphicsAllocation::AllocationType::WRITE_COMBINED);
|
||||
EXPECT_EQ(graphicsAllocation->gpuAllocation->getGpuAddress(), castToUint64(unfiedMemoryDeviceAllocation));
|
||||
EXPECT_EQ(alignUp(allocationSize, MemoryConstants::pageSize64k), graphicsAllocation->gpuAllocation->getUnderlyingBufferSize());
|
||||
|
||||
retVal = clMemFreeINTEL(&mockContext, unfiedMemoryDeviceAllocation);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST(clUnifiedSharedMemoryTests, givenInvalidMemPropertiesWhenClSharedMemAllocIntelIsCalledThenInvalidValueIsReturned) {
|
||||
MockContext mockContext;
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_WRITE_COMBINED_INTEL, 0};
|
||||
auto unfiedMemorySharedAllocation = clSharedMemAllocINTEL(&mockContext, mockContext.getDevice(0u), properties, 4, 0, &retVal);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
EXPECT_EQ(nullptr, unfiedMemorySharedAllocation);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user