@@ -230,6 +230,17 @@ TEST(clUnifiedSharedMemoryTests, whenHostMemAllocWithInvalidPropertiesTokenThenE
230230 EXPECT_EQ (CL_INVALID_VALUE, retVal);
231231}
232232
233+ TEST (clUnifiedSharedMemoryTests, whenHostMemAllocWithInvalidWriteCombinedTokenThenErrorIsReturned) {
234+ MockContext mockContext;
235+ cl_int retVal = CL_SUCCESS;
236+ cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL, 0 };
237+
238+ auto unifiedMemoryHostAllocation = clHostMemAllocINTEL (&mockContext, properties, 4 , 0 , &retVal);
239+
240+ EXPECT_EQ (nullptr , unifiedMemoryHostAllocation);
241+ EXPECT_EQ (CL_INVALID_VALUE, retVal);
242+ }
243+
233244TEST (clUnifiedSharedMemoryTests, whenDeviceMemAllocWithInvalidPropertiesTokenThenErrorIsReturned) {
234245 MockContext mockContext;
235246 cl_int retVal = CL_SUCCESS;
@@ -253,6 +264,17 @@ TEST(clUnifiedSharedMemoryTests, whenSharedMemAllocWithInvalidPropertiesTokenThe
253264 EXPECT_EQ (CL_INVALID_VALUE, retVal);
254265}
255266
267+ TEST (clUnifiedSharedMemoryTests, whenSharedMemAllocWithInvalidWriteCombinedTokenThenErrorIsReturned) {
268+ MockContext mockContext;
269+ cl_int retVal = CL_SUCCESS;
270+ cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL, 0 };
271+
272+ auto unifiedMemorySharedAllocation = clSharedMemAllocINTEL (&mockContext, mockContext.getDevice (0u ), properties, 4 , 0 , &retVal);
273+
274+ EXPECT_EQ (nullptr , unifiedMemorySharedAllocation);
275+ EXPECT_EQ (CL_INVALID_VALUE, retVal);
276+ }
277+
256278TEST (clUnifiedSharedMemoryTests, givenUnifiedMemoryAllocWithoutPropertiesWhenGetMemAllocFlagsThenDefaultValueIsReturned) {
257279 uint64_t defaultValue = CL_MEM_ALLOC_DEFAULT_INTEL;
258280 MockContext mockContext;
@@ -277,7 +299,7 @@ TEST(clUnifiedSharedMemoryTests, whenClGetMemAllocTypeIsCalledWithValidUnifiedMe
277299 size_t paramValueSize = sizeof (cl_mem_properties_intel);
278300 cl_mem_properties_intel paramValue = 0 ;
279301 size_t paramValueSizeRet = 0 ;
280- cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL , 0 };
302+ cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_DEFAULT_INTEL , 0 };
281303
282304 auto unifiedMemoryHostAllocation = clHostMemAllocINTEL (&mockContext, properties, 4 , 0 , &retVal);
283305
@@ -313,7 +335,7 @@ TEST(clUnifiedSharedMemoryTests, whenClGetMemAllocTypeIsCalledWithValidUnifiedMe
313335 size_t paramValueSize = sizeof (cl_mem_properties_intel);
314336 cl_mem_properties_intel paramValue = 0 ;
315337 size_t paramValueSizeRet = 0 ;
316- cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL , 0 };
338+ cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_DEFAULT_INTEL , 0 };
317339
318340 auto unifiedMemorySharedAllocation = clSharedMemAllocINTEL (&mockContext, mockContext.getDevice (0u ), properties, 4 , 0 , &retVal);
319341
@@ -760,3 +782,56 @@ TEST_F(clUnifiedSharedMemoryEventTests, whenClEnqueueMemFillINTELIsCalledWithEve
760782 EXPECT_EQ (expectedCmd, actualCmd);
761783 clMemFreeINTEL (this ->context , unfiedMemorySharedAllocation);
762784}
785+
786+ TEST (clUnifiedSharedMemoryTests, givenDefaulMemPropertiesWhenClDeviceMemAllocIntelIsCalledThenItAllocatesDeviceUnifiedMemoryAllocationWithProperAllocationTypeAndSize) {
787+ MockContext mockContext;
788+ cl_int retVal = CL_SUCCESS;
789+ cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_DEFAULT_INTEL, 0 };
790+ auto allocationSize = 4000u ;
791+ auto unfiedMemoryDeviceAllocation = clDeviceMemAllocINTEL (&mockContext, mockContext.getDevice (0u ), properties, allocationSize, 0 , &retVal);
792+ EXPECT_EQ (CL_SUCCESS, retVal);
793+ ASSERT_NE (nullptr , unfiedMemoryDeviceAllocation);
794+
795+ auto allocationsManager = mockContext.getSVMAllocsManager ();
796+ EXPECT_EQ (1u , allocationsManager->getNumAllocs ());
797+ auto graphicsAllocation = allocationsManager->getSVMAlloc (unfiedMemoryDeviceAllocation);
798+ EXPECT_EQ (graphicsAllocation->size , allocationSize);
799+ EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::DEVICE_UNIFIED_MEMORY);
800+ EXPECT_EQ (GraphicsAllocation::AllocationType::BUFFER, graphicsAllocation->gpuAllocation ->getAllocationType ());
801+ EXPECT_EQ (graphicsAllocation->gpuAllocation ->getGpuAddress (), castToUint64 (unfiedMemoryDeviceAllocation));
802+ EXPECT_EQ (alignUp (allocationSize, MemoryConstants::pageSize64k), graphicsAllocation->gpuAllocation ->getUnderlyingBufferSize ());
803+
804+ retVal = clMemFreeINTEL (&mockContext, unfiedMemoryDeviceAllocation);
805+ EXPECT_EQ (CL_SUCCESS, retVal);
806+ }
807+
808+ TEST (clUnifiedSharedMemoryTests, givenValidMemPropertiesWhenClDeviceMemAllocIntelIsCalledThenItAllocatesDeviceUnifiedMemoryAllocationWithProperAllocationTypeAndSize) {
809+ MockContext mockContext;
810+ cl_int retVal = CL_SUCCESS;
811+ auto allocationSize = 4000u ;
812+ cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_FLAGS_INTEL, CL_MEM_ALLOC_WRITE_COMBINED_INTEL, 0 };
813+ auto unfiedMemoryDeviceAllocation = clDeviceMemAllocINTEL (&mockContext, mockContext.getDevice (0u ), properties, allocationSize, 0 , &retVal);
814+ EXPECT_EQ (CL_SUCCESS, retVal);
815+ ASSERT_NE (nullptr , unfiedMemoryDeviceAllocation);
816+
817+ auto allocationsManager = mockContext.getSVMAllocsManager ();
818+ EXPECT_EQ (1u , allocationsManager->getNumAllocs ());
819+ auto graphicsAllocation = allocationsManager->getSVMAlloc (unfiedMemoryDeviceAllocation);
820+ EXPECT_EQ (graphicsAllocation->size , allocationSize);
821+ EXPECT_EQ (graphicsAllocation->memoryType , InternalMemoryType::DEVICE_UNIFIED_MEMORY);
822+ EXPECT_EQ (graphicsAllocation->gpuAllocation ->getAllocationType (), GraphicsAllocation::AllocationType::WRITE_COMBINED);
823+ EXPECT_EQ (graphicsAllocation->gpuAllocation ->getGpuAddress (), castToUint64 (unfiedMemoryDeviceAllocation));
824+ EXPECT_EQ (alignUp (allocationSize, MemoryConstants::pageSize64k), graphicsAllocation->gpuAllocation ->getUnderlyingBufferSize ());
825+
826+ retVal = clMemFreeINTEL (&mockContext, unfiedMemoryDeviceAllocation);
827+ EXPECT_EQ (CL_SUCCESS, retVal);
828+ }
829+
830+ TEST (clUnifiedSharedMemoryTests, givenInvalidMemPropertiesWhenClSharedMemAllocIntelIsCalledThenInvalidValueIsReturned) {
831+ MockContext mockContext;
832+ cl_int retVal = CL_SUCCESS;
833+ cl_mem_properties_intel properties[] = {CL_MEM_ALLOC_WRITE_COMBINED_INTEL, 0 };
834+ auto unfiedMemorySharedAllocation = clSharedMemAllocINTEL (&mockContext, mockContext.getDevice (0u ), properties, 4 , 0 , &retVal);
835+ EXPECT_EQ (CL_INVALID_VALUE, retVal);
836+ EXPECT_EQ (nullptr , unfiedMemorySharedAllocation);
837+ }
0 commit comments