@@ -461,6 +461,150 @@ TEST_F(KernelArgBufferTest, whenSettingAuxTranslationRequiredThenIsAuxTranslatio
461
461
}
462
462
}
463
463
464
+ TEST_F (KernelArgBufferTest, givenSetArgBufferOnKernelWithDirectStatelessAccessToHostMemoryWhenUpdateAuxTranslationRequiredIsCalledThenIsAuxTranslationRequiredShouldReturnTrue) {
465
+ DebugManagerStateRestore debugRestorer;
466
+ DebugManager.flags .EnableStatelessCompression .set (1 );
467
+
468
+ MockBuffer buffer;
469
+ buffer.getGraphicsAllocation (mockRootDeviceIndex)->setAllocationType (GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
470
+
471
+ auto val = (cl_mem)&buffer;
472
+ auto pVal = &val;
473
+
474
+ auto retVal = pKernel->setArg (0 , sizeof (cl_mem *), pVal);
475
+ EXPECT_EQ (CL_SUCCESS, retVal);
476
+
477
+ EXPECT_TRUE (pKernel->hasDirectStatelessAccessToHostMemory ());
478
+
479
+ EXPECT_FALSE (pKernel->isAuxTranslationRequired ());
480
+
481
+ pKernel->updateAuxTranslationRequired ();
482
+
483
+ EXPECT_TRUE (pKernel->isAuxTranslationRequired ());
484
+ }
485
+
486
+ TEST_F (KernelArgBufferTest, givenSetArgBufferOnKernelWithNoDirectStatelessAccessToHostMemoryWhenUpdateAuxTranslationRequiredIsCalledThenIsAuxTranslationRequiredShouldReturnFalse) {
487
+ DebugManagerStateRestore debugRestorer;
488
+ DebugManager.flags .EnableStatelessCompression .set (1 );
489
+
490
+ MockBuffer buffer;
491
+ buffer.getGraphicsAllocation (mockRootDeviceIndex)->setAllocationType (GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
492
+
493
+ auto val = (cl_mem)&buffer;
494
+ auto pVal = &val;
495
+
496
+ auto retVal = pKernel->setArg (0 , sizeof (cl_mem *), pVal);
497
+ EXPECT_EQ (CL_SUCCESS, retVal);
498
+
499
+ EXPECT_FALSE (pKernel->hasDirectStatelessAccessToHostMemory ());
500
+
501
+ EXPECT_FALSE (pKernel->isAuxTranslationRequired ());
502
+
503
+ pKernel->updateAuxTranslationRequired ();
504
+
505
+ EXPECT_FALSE (pKernel->isAuxTranslationRequired ());
506
+ }
507
+
508
+ TEST_F (KernelArgBufferTest, givenSetArgSvmAllocOnKernelWithDirectStatelessAccessToHostMemoryWhenUpdateAuxTranslationRequiredIsCalledThenIsAuxTranslationRequiredShouldReturnTrue) {
509
+ DebugManagerStateRestore debugRestorer;
510
+ DebugManager.flags .EnableStatelessCompression .set (1 );
511
+
512
+ char data[128 ];
513
+ void *ptr = &data;
514
+ MockGraphicsAllocation gfxAllocation (ptr, 128 );
515
+ gfxAllocation.setAllocationType (GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
516
+
517
+ auto retVal = pKernel->setArgSvmAlloc (0 , ptr, &gfxAllocation);
518
+ EXPECT_EQ (CL_SUCCESS, retVal);
519
+
520
+ EXPECT_TRUE (pKernel->hasDirectStatelessAccessToHostMemory ());
521
+
522
+ EXPECT_FALSE (pKernel->isAuxTranslationRequired ());
523
+
524
+ pKernel->updateAuxTranslationRequired ();
525
+
526
+ EXPECT_TRUE (pKernel->isAuxTranslationRequired ());
527
+ }
528
+
529
+ TEST_F (KernelArgBufferTest, givenSetArgSvmAllocOnKernelWithNoDirectStatelessAccessToHostMemoryWhenUpdateAuxTranslationRequiredIsCalledThenIsAuxTranslationRequiredShouldReturnFalse) {
530
+ DebugManagerStateRestore debugRestorer;
531
+ DebugManager.flags .EnableStatelessCompression .set (1 );
532
+
533
+ char data[128 ];
534
+ void *ptr = &data;
535
+ MockGraphicsAllocation gfxAllocation (ptr, 128 );
536
+ gfxAllocation.setAllocationType (GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
537
+
538
+ auto retVal = pKernel->setArgSvmAlloc (0 , ptr, &gfxAllocation);
539
+ EXPECT_EQ (CL_SUCCESS, retVal);
540
+
541
+ EXPECT_FALSE (pKernel->hasDirectStatelessAccessToHostMemory ());
542
+
543
+ EXPECT_FALSE (pKernel->isAuxTranslationRequired ());
544
+
545
+ pKernel->updateAuxTranslationRequired ();
546
+
547
+ EXPECT_FALSE (pKernel->isAuxTranslationRequired ());
548
+ }
549
+
550
+ TEST_F (KernelArgBufferTest, givenSetUnifiedMemoryExecInfoOnKernelWithNoIndirectStatelessAccessWhenUpdateAuxTranslationRequiredIsCalledThenIsAuxTranslationRequiredShouldReturnFalse) {
551
+ DebugManagerStateRestore debugRestorer;
552
+ DebugManager.flags .EnableStatelessCompression .set (1 );
553
+
554
+ pKernelInfo->hasIndirectStatelessAccess = false ;
555
+
556
+ MockGraphicsAllocation gfxAllocation;
557
+ gfxAllocation.setAllocationType (GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
558
+
559
+ pKernel->setUnifiedMemoryExecInfo (&gfxAllocation);
560
+
561
+ EXPECT_FALSE (pKernel->hasIndirectStatelessAccessToHostMemory ());
562
+
563
+ EXPECT_FALSE (pKernel->isAuxTranslationRequired ());
564
+
565
+ pKernel->updateAuxTranslationRequired ();
566
+
567
+ EXPECT_FALSE (pKernel->isAuxTranslationRequired ());
568
+ }
569
+
570
+ TEST_F (KernelArgBufferTest, givenSetUnifiedMemoryExecInfoOnKernelWithIndirectStatelessAccessWhenUpdateAuxTranslationRequiredIsCalledThenIsAuxTranslationRequiredShouldReturnTrueForHostMemoryAllocation) {
571
+ DebugManagerStateRestore debugRestorer;
572
+ DebugManager.flags .EnableStatelessCompression .set (1 );
573
+
574
+ pKernelInfo->hasIndirectStatelessAccess = true ;
575
+
576
+ const auto allocationTypes = {GraphicsAllocation::AllocationType::BUFFER,
577
+ GraphicsAllocation::AllocationType::BUFFER_COMPRESSED,
578
+ GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY};
579
+
580
+ MockGraphicsAllocation gfxAllocation;
581
+
582
+ for (const auto type : allocationTypes) {
583
+ gfxAllocation.setAllocationType (type);
584
+
585
+ pKernel->setUnifiedMemoryExecInfo (&gfxAllocation);
586
+
587
+ if (type == GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY) {
588
+ EXPECT_TRUE (pKernel->hasIndirectStatelessAccessToHostMemory ());
589
+ } else {
590
+ EXPECT_FALSE (pKernel->hasIndirectStatelessAccessToHostMemory ());
591
+ }
592
+
593
+ EXPECT_FALSE (pKernel->isAuxTranslationRequired ());
594
+
595
+ pKernel->updateAuxTranslationRequired ();
596
+
597
+ if (type == GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY) {
598
+ EXPECT_TRUE (pKernel->isAuxTranslationRequired ());
599
+ } else {
600
+ EXPECT_FALSE (pKernel->isAuxTranslationRequired ());
601
+ }
602
+
603
+ pKernel->clearUnifiedMemoryExecInfo ();
604
+ pKernel->setAuxTranslationRequired (false );
605
+ }
606
+ }
607
+
464
608
class KernelArgBufferFixtureBindless : public KernelArgBufferFixture {
465
609
public:
466
610
void SetUp () {
0 commit comments