@@ -494,35 +494,42 @@ TEST_F(CloneKernelTest, GivenArgSvmWhenCloningKernelThenKernelInfoIsCorrect) {
494494}
495495
496496TEST_F (CloneKernelTest, GivenArgSvmAllocWhenCloningKernelThenKernelInfoIsCorrect) {
497- char *svmPtr = new char [256 ];
498- MockGraphicsAllocation svmAlloc (svmPtr, 256 );
497+ char memory[100 ] = {};
498+ MultiGraphicsAllocation multiGraphicsAllocation (3 );
499+ for (auto &rootDeviceIndex : this ->context ->getRootDeviceIndices ()) {
500+ auto svmAlloc = new MockGraphicsAllocation (rootDeviceIndex, memory, 100 );
501+ multiGraphicsAllocation.addAllocation (svmAlloc);
502+ }
499503
500- auto rootDeviceIndex = *context->getRootDeviceIndices ().begin ();
501- retVal = pSourceMultiDeviceKernel->setArgSvmAlloc (0 , svmPtr, &svmAlloc);
504+ retVal = pSourceMultiDeviceKernel->setArgSvmAlloc (0 , memory, &multiGraphicsAllocation);
502505 ASSERT_EQ (CL_SUCCESS, retVal);
503506
504- EXPECT_EQ (1u , pSourceKernel[rootDeviceIndex]->getKernelArguments ().size ());
505- EXPECT_EQ (Kernel::SVM_ALLOC_OBJ, pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).type );
506- EXPECT_NE (0u , pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).size );
507- EXPECT_EQ (1u , pSourceKernel[rootDeviceIndex]->getPatchedArgumentsNum ());
508- EXPECT_TRUE (pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).isPatched );
507+ for (auto &rootDeviceIndex : this ->context ->getRootDeviceIndices ()) {
508+ EXPECT_EQ (1u , pSourceKernel[rootDeviceIndex]->getKernelArguments ().size ());
509+ EXPECT_EQ (multiGraphicsAllocation.getGraphicsAllocation (rootDeviceIndex), pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).object );
510+ EXPECT_EQ (Kernel::SVM_ALLOC_OBJ, pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).type );
511+ EXPECT_NE (0u , pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).size );
512+ EXPECT_EQ (1u , pSourceKernel[rootDeviceIndex]->getPatchedArgumentsNum ());
513+ EXPECT_TRUE (pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).isPatched );
514+ }
509515
510516 retVal = pClonedMultiDeviceKernel->cloneKernel (pSourceMultiDeviceKernel.get ());
511517 EXPECT_EQ (CL_SUCCESS, retVal);
512518
513- EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getKernelArguments ().size (), pClonedKernel[rootDeviceIndex]->getKernelArguments ().size ());
514- EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).type , pClonedKernel[rootDeviceIndex]->getKernelArgInfo (0 ).type );
515- EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).object , pClonedKernel[rootDeviceIndex]->getKernelArgInfo (0 ).object );
516- EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).value , pClonedKernel[rootDeviceIndex]->getKernelArgInfo (0 ).value );
517- EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).size , pClonedKernel[rootDeviceIndex]->getKernelArgInfo (0 ).size );
518- EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getPatchedArgumentsNum (), pClonedKernel[rootDeviceIndex]->getPatchedArgumentsNum ());
519- EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).isPatched , pClonedKernel[rootDeviceIndex]->getKernelArgInfo (0 ).isPatched );
520-
521- auto pKernelArg = (void **)(pClonedKernel[rootDeviceIndex]->getCrossThreadData () +
522- pClonedKernel[rootDeviceIndex]->getKernelInfo ().kernelArgInfo [0 ].kernelArgPatchInfoVector [0 ].crossthreadOffset );
523- EXPECT_EQ (svmPtr, *pKernelArg);
519+ for (auto &rootDeviceIndex : this ->context ->getRootDeviceIndices ()) {
520+ EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getKernelArguments ().size (), pClonedKernel[rootDeviceIndex]->getKernelArguments ().size ());
521+ EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).type , pClonedKernel[rootDeviceIndex]->getKernelArgInfo (0 ).type );
522+ EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).object , pClonedKernel[rootDeviceIndex]->getKernelArgInfo (0 ).object );
523+ EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).value , pClonedKernel[rootDeviceIndex]->getKernelArgInfo (0 ).value );
524+ EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).size , pClonedKernel[rootDeviceIndex]->getKernelArgInfo (0 ).size );
525+ EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getPatchedArgumentsNum (), pClonedKernel[rootDeviceIndex]->getPatchedArgumentsNum ());
526+ EXPECT_EQ (pSourceKernel[rootDeviceIndex]->getKernelArgInfo (0 ).isPatched , pClonedKernel[rootDeviceIndex]->getKernelArgInfo (0 ).isPatched );
524527
525- delete[] svmPtr;
528+ auto pKernelArg = (void **)(pClonedKernel[rootDeviceIndex]->getCrossThreadData () +
529+ pClonedKernel[rootDeviceIndex]->getKernelInfo ().kernelArgInfo [0 ].kernelArgPatchInfoVector [0 ].crossthreadOffset );
530+ EXPECT_EQ (memory, *pKernelArg);
531+ delete multiGraphicsAllocation.getGraphicsAllocation (rootDeviceIndex);
532+ }
526533}
527534
528535TEST_F (CloneKernelTest, GivenArgImmediateWhenCloningKernelThenKernelInfoIsCorrect) {
@@ -565,13 +572,14 @@ TEST_F(CloneKernelTest, GivenExecInfoWhenCloningKernelThenSvmAllocationIsCorrect
565572
566573 auto svmData = context->getSVMAllocsManager ()->getSVMAlloc (ptrSVM);
567574 ASSERT_NE (nullptr , svmData);
568- GraphicsAllocation *pSvmAlloc = svmData->gpuAllocations .getGraphicsAllocation (device1->getRootDeviceIndex ());
569- ASSERT_NE (nullptr , pSvmAlloc);
575+ auto &pSvmAllocs = svmData->gpuAllocations ;
570576
571- pSourceMultiDeviceKernel->setSvmKernelExecInfo (pSvmAlloc );
577+ pSourceMultiDeviceKernel->setSvmKernelExecInfo (pSvmAllocs );
572578
573579 for (auto &rootDeviceIndex : this ->context ->getRootDeviceIndices ()) {
574580 EXPECT_EQ (1u , pSourceKernel[rootDeviceIndex]->kernelSvmGfxAllocations .size ());
581+ EXPECT_NE (nullptr , pSourceKernel[rootDeviceIndex]->kernelSvmGfxAllocations .at (0 ));
582+ EXPECT_EQ (pSvmAllocs.getGraphicsAllocation (rootDeviceIndex), pSourceKernel[rootDeviceIndex]->kernelSvmGfxAllocations .at (0 ));
575583 }
576584
577585 retVal = pClonedMultiDeviceKernel->cloneKernel (pSourceMultiDeviceKernel.get ());
@@ -585,6 +593,34 @@ TEST_F(CloneKernelTest, GivenExecInfoWhenCloningKernelThenSvmAllocationIsCorrect
585593 context->getSVMAllocsManager ()->freeSVMAlloc (ptrSVM);
586594}
587595
596+ TEST_F (CloneKernelTest, GivenUnifiedMemoryExecInfoWhenCloningKernelThenUnifiedMemoryAllocationIsCorrect) {
597+ REQUIRE_SVM_OR_SKIP (device1);
598+ void *ptrSVM = context->getSVMAllocsManager ()->createSVMAlloc (256 , {}, context->getRootDeviceIndices (), context->getDeviceBitfields ());
599+ ASSERT_NE (nullptr , ptrSVM);
600+
601+ auto svmData = context->getSVMAllocsManager ()->getSVMAlloc (ptrSVM);
602+ ASSERT_NE (nullptr , svmData);
603+ auto &pSvmAllocs = svmData->gpuAllocations ;
604+
605+ pSourceMultiDeviceKernel->setUnifiedMemoryExecInfo (pSvmAllocs);
606+
607+ for (auto &rootDeviceIndex : this ->context ->getRootDeviceIndices ()) {
608+ EXPECT_EQ (1u , pSourceKernel[rootDeviceIndex]->kernelUnifiedMemoryGfxAllocations .size ());
609+ EXPECT_NE (nullptr , pSourceKernel[rootDeviceIndex]->kernelUnifiedMemoryGfxAllocations .at (0 ));
610+ EXPECT_EQ (pSvmAllocs.getGraphicsAllocation (rootDeviceIndex), pSourceKernel[rootDeviceIndex]->kernelUnifiedMemoryGfxAllocations .at (0 ));
611+ }
612+
613+ retVal = pClonedMultiDeviceKernel->cloneKernel (pSourceMultiDeviceKernel.get ());
614+ EXPECT_EQ (CL_SUCCESS, retVal);
615+
616+ for (auto &rootDeviceIndex : this ->context ->getRootDeviceIndices ()) {
617+ EXPECT_EQ (pSourceKernel[rootDeviceIndex]->kernelUnifiedMemoryGfxAllocations .size (), pClonedKernel[rootDeviceIndex]->kernelUnifiedMemoryGfxAllocations .size ());
618+ EXPECT_EQ (pSourceKernel[rootDeviceIndex]->kernelUnifiedMemoryGfxAllocations .at (0 ), pClonedKernel[rootDeviceIndex]->kernelUnifiedMemoryGfxAllocations .at (0 ));
619+ }
620+
621+ context->getSVMAllocsManager ()->freeSVMAlloc (ptrSVM);
622+ }
623+
588624TEST_F (CloneKernelTest, givenBuiltinSourceKernelWhenCloningThenSetBuiltinFlagToClonedKernel) {
589625 for (auto &rootDeviceIndex : this ->context ->getRootDeviceIndices ()) {
590626 pSourceKernel[rootDeviceIndex]->isBuiltIn = true ;
0 commit comments