Add preemption WA to make CSR surface uncacheable

Change-Id: Ia468c6f5df16522c3bc9aae22802895f2badc431
This commit is contained in:
Zdanowicz, Zbigniew
2018-01-04 17:48:46 +01:00
committed by sys_ocldev
parent e9fd40db13
commit 21f92d8258
24 changed files with 149 additions and 64 deletions

View File

@@ -155,7 +155,8 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo,
if (pDevice->preemptionMode == PreemptionMode::MidThread) {
size_t requiredSize = pHwInfo->pSysInfo->CsrSizeInMb * MemoryConstants::megaByte;
size_t alignment = 256 * MemoryConstants::kiloByte;
auto preemptionAllocation = outDevice.memoryManager->allocateGraphicsMemory(requiredSize, alignment);
bool uncacheable = pDevice->getWaTable()->waCSRUncachable;
auto preemptionAllocation = outDevice.memoryManager->allocateGraphicsMemory(requiredSize, alignment, false, uncacheable);
if (!preemptionAllocation) {
return false;
}

View File

@@ -89,6 +89,9 @@ int HwInfoConfigHw<IGFX_SKYLAKE>::configureHardwareCustom(HardwareInfo *hwInfo,
pWaTable->waDisablePerCtxtPreemptionGranularityControl = 1;
pWaTable->waModifyVFEStateAfterGPGPUPreemption = 1;
}
if ((1 << hwInfo->pPlatform->usRevId) & 0x3f) {
pWaTable->waCSRUncachable = 1;
}
if (hwInfo->pPlatform->usDeviceID == ISKL_GT3e_ULT_DEVICE_F0_ID_540 ||
hwInfo->pPlatform->usDeviceID == ISKL_GT3e_ULT_DEVICE_F0_ID_550 ||

View File

@@ -100,8 +100,7 @@ uint32_t Gmm::getMOCS(uint32_t type) {
return static_cast<uint32_t>(mocs.DwordValue);
}
Gmm *Gmm::create(const void *alignedPtr, size_t alignedSize) {
Gmm *Gmm::create(const void *alignedPtr, size_t alignedSize, bool uncacheable) {
auto gmm = new Gmm();
gmm->resourceParams.Type = RESOURCE_BUFFER;
@@ -109,7 +108,11 @@ Gmm *Gmm::create(const void *alignedPtr, size_t alignedSize) {
gmm->resourceParams.BaseWidth = (uint32_t)alignedSize;
gmm->resourceParams.BaseHeight = 1;
gmm->resourceParams.Depth = 1;
gmm->resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER;
if (!uncacheable) {
gmm->resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER;
} else {
gmm->resourceParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC;
}
gmm->resourceParams.Flags.Info.Linear = 1;
gmm->resourceParams.Flags.Info.Cacheable = 1;
gmm->resourceParams.Flags.Gpu.Texture = 1;

View File

@@ -55,7 +55,7 @@ class Gmm {
virtual ~Gmm() = default;
void create();
static Gmm *create(const void *alignedPtr, size_t alignedSize);
static Gmm *create(const void *alignedPtr, size_t alignedSize, bool uncacheable);
static Gmm *create(GMM_RESOURCE_INFO *inputGmm);
static bool initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo);

View File

@@ -156,6 +156,7 @@ struct WorkaroundTable {
bool waLLCCachingUnsupported = false;
bool waUseVAlign16OnTileXYBpp816 = false;
bool waModifyVFEStateAfterGPGPUPreemption = false;
bool waCSRUncachable = false;
};
struct HardwareInfo {

View File

@@ -81,10 +81,10 @@ class MemoryManager {
}
virtual GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment) {
return allocateGraphicsMemory(size, alignment, false);
return allocateGraphicsMemory(size, alignment, false, false);
}
virtual GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) = 0;
virtual GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) = 0;
virtual GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) = 0;
@@ -172,7 +172,7 @@ class MemoryManager {
if (enable64kbpages) {
return allocateGraphicsMemory64kb(size, MemoryConstants::pageSize64k, forcePin);
} else {
return allocateGraphicsMemory(size, MemoryConstants::pageSize, forcePin);
return allocateGraphicsMemory(size, MemoryConstants::pageSize, forcePin, false);
}
}
}

View File

@@ -40,7 +40,7 @@ OsAgnosticMemoryManager::~OsAgnosticMemoryManager() {
struct OsHandle {
};
GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) {
GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) {
auto sizeAligned = alignUp(size, MemoryConstants::pageSize);
MemoryAllocation *memoryAllocation = nullptr;
@@ -49,6 +49,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory(size_t size,
memoryAllocation = new MemoryAllocation(true, 1, (void *)dummyAddress, static_cast<uint64_t>(dummyAddress), size, counter);
counter++;
memoryAllocation->dummyAllocation = true;
memoryAllocation->uncacheable = uncacheable;
return memoryAllocation;
}
auto ptr = allocateSystemMemory(sizeAligned, alignment ? alignUp(alignment, MemoryConstants::pageSize) : MemoryConstants::pageSize);
@@ -59,6 +60,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory(size_t size,
alignedFree(ptr);
return nullptr;
}
memoryAllocation->uncacheable = uncacheable;
allocationMap.insert(std::pair<void *, MemoryAllocation>(ptr, *memoryAllocation));
}
counter++;
@@ -66,7 +68,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory(size_t size,
}
GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) {
return allocateGraphicsMemory(alignUp(size, MemoryConstants::pageSize64k), MemoryConstants::pageSize64k, forcePin);
return allocateGraphicsMemory(alignUp(size, MemoryConstants::pageSize64k), MemoryConstants::pageSize64k, forcePin, false);
}
GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemory(size_t size, void *ptr) {

View File

@@ -38,6 +38,7 @@ class MemoryAllocation : public GraphicsAllocation {
bool allowAubFileWrite = true;
size_t sizeToFree = 0;
bool dummyAllocation = false;
bool uncacheable = false;
void setSharedHandle(osHandle handle) { this->sharedHandle = handle; }
@@ -62,7 +63,7 @@ class OsAgnosticMemoryManager : public MemoryManager {
allocator32Bit = std::unique_ptr<Allocator32bit>(new Allocator32bit(heap32Base, GB - 2 * 4096));
};
~OsAgnosticMemoryManager() override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override;
GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override;
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, void *ptr) override;
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness, bool reuseBO) override;

View File

@@ -167,7 +167,7 @@ DrmAllocation *DrmMemoryManager::createGraphicsAllocation(OsHandleStorage &handl
return allocation;
}
DrmAllocation *DrmMemoryManager::allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) {
DrmAllocation *DrmMemoryManager::allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) {
const size_t minAlignment = MemoryConstants::allocationAlignment;
size_t cAlignment = alignUp(std::max(alignment, minAlignment), minAlignment);
// When size == 0 allocate allocationAlignment

View File

@@ -43,9 +43,9 @@ class DrmMemoryManager : public MemoryManager {
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
DrmAllocation *allocateGraphicsMemory(size_t size, size_t alignment) override {
return allocateGraphicsMemory(size, alignment, false);
return allocateGraphicsMemory(size, alignment, false, false);
}
DrmAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) override;
DrmAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override;
DrmAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override;
DrmAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override {
return allocateGraphicsMemory(size, ptr, false);

View File

@@ -203,6 +203,7 @@ void Wddm::setupWorkaroundTableFromAdapterInfo(WorkaroundTable *table, ADAPTER_I
COPY_WA(waLLCCachingUnsupported, WaLLCCachingUnsupported);
COPY_WA(waUseVAlign16OnTileXYBpp816, WaUseVAlign16OnTileXYBpp816);
COPY_WA(waModifyVFEStateAfterGPGPUPreemption, WaModifyVFEStateAfterGPGPUPreemption);
COPY_WA(waCSRUncachable, WaCSRUncachable);
#undef COPY_WA
}

View File

@@ -83,7 +83,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(size_t size, s
WddmAllocation allocation(nullptr, sizeAligned, nullptr, sizeAligned);
gmm = Gmm::create(nullptr, sizeAligned);
gmm = Gmm::create(nullptr, sizeAligned, false);
while (success) {
allocation.gmm = gmm;
@@ -108,7 +108,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(size_t size, s
return nullptr;
}
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) {
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) {
size_t newAlignment = alignment ? alignUp(alignment, MemoryConstants::pageSize) : MemoryConstants::pageSize;
size_t sizeAligned = size ? alignUp(size, MemoryConstants::pageSize) : MemoryConstants::pageSize;
void *pSysMem = allocateSystemMemory(sizeAligned, newAlignment);
@@ -122,7 +122,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, size_
WddmAllocation allocation(pSysMem, sizeAligned, pSysMem, sizeAligned);
allocation.cpuPtrAllocated = true;
gmm = Gmm::create(pSysMem, sizeAligned);
gmm = Gmm::create(pSysMem, sizeAligned, uncacheable);
while (success) {
allocation.gmm = gmm;
@@ -178,7 +178,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemory(size_t size,
allocation.cpuPtrAllocated = cpuPtrAllocated;
allocation.is32BitAllocation = true;
gmm = Gmm::create(ptrAligned, sizeAligned);
gmm = Gmm::create(ptrAligned, sizeAligned, false);
while (success) {
allocation.gmm = gmm;
@@ -328,7 +328,7 @@ bool WddmMemoryManager::populateOsHandles(OsHandleStorage &handleStorage) {
handleStorage.fragmentStorageData[i].osHandleStorage = new OsHandle();
handleStorage.fragmentStorageData[i].residency = new ResidencyData();
handleStorage.fragmentStorageData[i].osHandleStorage->gmm = Gmm::create(handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize);
handleStorage.fragmentStorageData[i].osHandleStorage->gmm = Gmm::create(handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize, false);
hostPtrManager.storeFragment(handleStorage.fragmentStorageData[i]);
}
}

View File

@@ -44,7 +44,7 @@ class WddmMemoryManager : public MemoryManager {
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override;
GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override;
GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr) override;
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, void *ptr) override;
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, bool requireSpecificBitness, bool reuseBO) override;

View File

@@ -63,7 +63,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCre
HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentCalledMultipleTimesAffectsResidencyOnce) {
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0]));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false);
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
// First makeResident marks the allocation resident
aubCsr->makeResident(*gfxAllocation);

View File

@@ -186,6 +186,7 @@ SKLTEST_F(HwInfoConfigTestLinuxSkl, configureHwInfoWaFlags) {
EXPECT_EQ(1u, outHwInfo.pWaTable->waCompressedResourceRequiresConstVA21);
EXPECT_EQ(1u, outHwInfo.pWaTable->waModifyVFEStateAfterGPGPUPreemption);
EXPECT_EQ(1u, outHwInfo.pWaTable->waDisablePerCtxtPreemptionGranularityControl);
EXPECT_EQ(1u, outHwInfo.pWaTable->waCSRUncachable);
ReleaseOutHwInfoStructs();
@@ -195,6 +196,7 @@ SKLTEST_F(HwInfoConfigTestLinuxSkl, configureHwInfoWaFlags) {
EXPECT_EQ(0u, outHwInfo.pWaTable->waCompressedResourceRequiresConstVA21);
EXPECT_EQ(1u, outHwInfo.pWaTable->waModifyVFEStateAfterGPGPUPreemption);
EXPECT_EQ(1u, outHwInfo.pWaTable->waDisablePerCtxtPreemptionGranularityControl);
EXPECT_EQ(1u, outHwInfo.pWaTable->waCSRUncachable);
ReleaseOutHwInfoStructs();
@@ -204,6 +206,17 @@ SKLTEST_F(HwInfoConfigTestLinuxSkl, configureHwInfoWaFlags) {
EXPECT_EQ(0u, outHwInfo.pWaTable->waCompressedResourceRequiresConstVA21);
EXPECT_EQ(0u, outHwInfo.pWaTable->waModifyVFEStateAfterGPGPUPreemption);
EXPECT_EQ(0u, outHwInfo.pWaTable->waDisablePerCtxtPreemptionGranularityControl);
EXPECT_EQ(1u, outHwInfo.pWaTable->waCSRUncachable);
ReleaseOutHwInfoStructs();
drm->StoredDeviceRevID = 6;
ret = hwInfoConfig->configureHwInfo(pInHwInfo, &outHwInfo, osInterface);
EXPECT_EQ(0, ret);
EXPECT_EQ(0u, outHwInfo.pWaTable->waCompressedResourceRequiresConstVA21);
EXPECT_EQ(0u, outHwInfo.pWaTable->waModifyVFEStateAfterGPGPUPreemption);
EXPECT_EQ(0u, outHwInfo.pWaTable->waDisablePerCtxtPreemptionGranularityControl);
EXPECT_EQ(0u, outHwInfo.pWaTable->waCSRUncachable);
}
SKLTEST_F(HwInfoConfigTestLinuxSkl, configureHwInfoEdram) {

View File

@@ -35,13 +35,13 @@ using namespace OCLRT;
class TestedMemoryManager : public OsAgnosticMemoryManager {
public:
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) override {
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override {
EXPECT_NE(0u, expectedSize);
if (expectedSize == size) {
EXPECT_TRUE(forcePin);
allocCount++;
}
return OsAgnosticMemoryManager::allocateGraphicsMemory(size, alignment, forcePin);
return OsAgnosticMemoryManager::allocateGraphicsMemory(size, alignment, forcePin, uncacheable);
};
GraphicsAllocation *allocateGraphicsMemory64kb(size_t size, size_t alignment, bool forcePin) override {
return nullptr;

View File

@@ -43,10 +43,9 @@ class GmmTests : public ::testing::Test {
};
TEST_F(GmmTests, resourceCreation) {
MemoryManager *mm = new OsAgnosticMemoryManager;
std::unique_ptr<MemoryManager> mm(new OsAgnosticMemoryManager);
void *pSysMem = mm->allocateSystemMemory(4096, 4096);
auto gmm = Gmm::create(pSysMem, 4096);
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096, false));
ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr);
@@ -54,22 +53,34 @@ TEST_F(GmmTests, resourceCreation) {
EXPECT_EQ(gmm->resourceParams.Flags.Gpu.NoRestriction, 0u);
EXPECT_TRUE(pSysMem == pGmmSysMem);
delete gmm;
mm->freeSystemMemory(pSysMem);
delete mm;
}
TEST_F(GmmTests, resourceCleanupOnDelete) {
MemoryManager *mm = new OsAgnosticMemoryManager;
TEST_F(GmmTests, resourceCreationUncacheable) {
std::unique_ptr<MemoryManager> mm(new OsAgnosticMemoryManager);
void *pSysMem = mm->allocateSystemMemory(4096, 4096);
auto gmm = Gmm::create(pSysMem, 4096);
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096, true));
ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr);
void *pGmmSysMem = gmm->gmmResourceInfo->getSystemMemPointer(1);
EXPECT_EQ(gmm->resourceParams.Flags.Gpu.NoRestriction, 0u);
EXPECT_TRUE(pSysMem == pGmmSysMem);
EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC, gmm->resourceParams.Usage);
mm->freeSystemMemory(pSysMem);
}
TEST_F(GmmTests, resourceCleanupOnDelete) {
std::unique_ptr<MemoryManager> mm(new OsAgnosticMemoryManager);
void *pSysMem = mm->allocateSystemMemory(4096, 4096);
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096, false));
ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr);
delete gmm;
mm->freeSystemMemory(pSysMem);
delete mm;
}
TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGMMResourceIsCreatedWithNoRestrictionsFlag) {
@@ -78,7 +89,7 @@ TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGMM
MemoryManager *mm = new OsAgnosticMemoryManager;
void *pSysMem = mm->allocateSystemMemory(4096, 4096);
auto gmmRes = Gmm::create(pSysMem, maxSize);
auto gmmRes = Gmm::create(pSysMem, maxSize, false);
ASSERT_TRUE(gmmRes->gmmResourceInfo.get() != nullptr);
@@ -91,7 +102,7 @@ TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGMM
TEST_F(GmmTests, givenGmmCreatedFromExistingGmmThenHelperDoesNotReleaseParentGmm) {
auto size = 4096u;
void *incomingPtr = (void *)0x1000;
auto gmmRes = Gmm::create(incomingPtr, size);
auto gmmRes = Gmm::create(incomingPtr, size, false);
auto gmmRes2 = Gmm::create(gmmRes->gmmResourceInfo->peekHandle());
//copy is being made

View File

@@ -1089,7 +1089,7 @@ TEST(OsAgnosticMemoryManager, checkAllocationsForOverlappingWithNullCsrInMemoryM
}
TEST_F(MemoryAllocatorTest, GivenSizeWhenGmmIsCreatedThenSuccess) {
Gmm *gmm = Gmm::create(nullptr, 65536);
Gmm *gmm = Gmm::create(nullptr, 65536, false);
EXPECT_NE(nullptr, gmm);
delete gmm;
}

View File

@@ -114,12 +114,12 @@ class FailMemoryManager : public MemoryManager {
}
applyCommonCleanup();
};
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin) override {
GraphicsAllocation *allocateGraphicsMemory(size_t size, size_t alignment, bool forcePin, bool uncacheable) override {
if (fail <= 0) {
return nullptr;
}
fail--;
GraphicsAllocation *alloc = agnostic->allocateGraphicsMemory(size, alignment, forcePin);
GraphicsAllocation *alloc = agnostic->allocateGraphicsMemory(size, alignment, forcePin, uncacheable);
allocations.push_back(alloc);
return alloc;
};

View File

@@ -168,7 +168,7 @@ TEST_F(DrmMemoryManagerTest, pinAfterAllocateWhenAskedAndAllowedAndBigAllocation
auto mm = new (std::nothrow) TestedDrmMemoryManager(this->mock, true);
ASSERT_NE(nullptr, mm->getPinBB());
auto alloc = mm->allocateGraphicsMemory(10 * 1014 * 1024, 1024, true);
auto alloc = mm->allocateGraphicsMemory(10 * 1014 * 1024, 1024, true, false);
ASSERT_NE(nullptr, alloc);
EXPECT_NE(nullptr, alloc->getBO());
@@ -184,7 +184,7 @@ TEST_F(DrmMemoryManagerTest, doNotPinAfterAllocateWhenAskedAndAllowedButSmallAll
ASSERT_NE(nullptr, mm->getPinBB());
// one page is too small for early pinning
auto alloc = mm->allocateGraphicsMemory(4 * 1024, 1024, true);
auto alloc = mm->allocateGraphicsMemory(4 * 1024, 1024, true, false);
ASSERT_NE(nullptr, alloc);
EXPECT_NE(nullptr, alloc->getBO());
@@ -199,7 +199,7 @@ TEST_F(DrmMemoryManagerTest, doNotPinAfterAllocateWhenNotAskedButAllowed) {
auto mm = new (std::nothrow) TestedDrmMemoryManager(this->mock, true);
ASSERT_NE(nullptr, mm->getPinBB());
auto alloc = mm->allocateGraphicsMemory(1024, 1024, false);
auto alloc = mm->allocateGraphicsMemory(1024, 1024, false, false);
ASSERT_NE(nullptr, alloc);
EXPECT_NE(nullptr, alloc->getBO());
@@ -214,7 +214,7 @@ TEST_F(DrmMemoryManagerTest, doNotPinAfterAllocateWhenAskedButNotAllowed) {
auto mm = new (std::nothrow) TestedDrmMemoryManager(this->mock, false);
ASSERT_EQ(nullptr, mm->getPinBB());
auto alloc = mm->allocateGraphicsMemory(1024, 1024, true);
auto alloc = mm->allocateGraphicsMemory(1024, 1024, true, false);
ASSERT_NE(nullptr, alloc);
EXPECT_NE(nullptr, alloc->getBO());

View File

@@ -99,7 +99,7 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandle
auto size = 4096u;
void *pSysMem = (void *)0x1000;
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u));
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u, false));
auto status = setSizesFunction(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
auto *gpuAllocation = mm->createGraphicsAllocationFromSharedHandle(osHandle, false);
@@ -116,7 +116,7 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCa
auto size = 4096u;
void *pSysMem = (void *)0x1000;
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u));
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u, false));
auto status = setSizesFunction(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
auto *gpuAllocation = mm->createGraphicsAllocationFromNTHandle((void *)1);
@@ -150,7 +150,7 @@ HWTEST_F(WddmMemoryManagerTest, createAllocationFromSharedHandleReturns32BitAllo
auto size = 4096u;
void *pSysMem = (void *)0x1000;
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u));
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u, false));
auto status = setSizesFunction(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
mm->setForce32BitAllocations(true);
@@ -173,7 +173,7 @@ HWTEST_F(WddmMemoryManagerTest, createAllocationFromSharedHandleDoesNotReturn32B
auto size = 4096u;
void *pSysMem = (void *)0x1000;
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u));
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u, false));
auto status = setSizesFunction(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
mm->setForce32BitAllocations(true);
@@ -196,7 +196,7 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenFreeAllocFromSharedHan
auto size = 4096u;
void *pSysMem = (void *)0x1000;
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u));
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u, false));
auto status = setSizesFunction(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
auto gpuAllocation = (WddmAllocation *)mm->createGraphicsAllocationFromSharedHandle(osHandle, false);
@@ -218,7 +218,7 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerSizeZeroWhenCreateFromShar
auto size = 4096u;
void *pSysMem = (void *)0x1000;
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, size));
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, size, false));
auto status = setSizesFunction(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
auto *gpuAllocation = mm->createGraphicsAllocationFromSharedHandle(osHandle, false);
@@ -233,7 +233,7 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandle
auto size = 4096u;
void *pSysMem = (void *)0x1000;
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, size));
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, size, false));
auto status = setSizesFunction(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
mockWddm->failOpenSharedHandle = true;
@@ -504,7 +504,7 @@ HWTEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocation
storage.fragmentStorageData[0].osHandleStorage->handle = ALLOCATION_HANDLE;
storage.fragmentStorageData[0].freeTheFragment = true;
storage.fragmentStorageData[0].osHandleStorage->gmm = Gmm::create(pSysMem, 4096u);
storage.fragmentStorageData[0].osHandleStorage->gmm = Gmm::create(pSysMem, 4096u, false);
storage.fragmentStorageData[1].osHandleStorage = new OsHandle;
storage.fragmentStorageData[1].osHandleStorage->handle = ALLOCATION_HANDLE;
@@ -515,7 +515,7 @@ HWTEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocation
storage.fragmentStorageData[2].osHandleStorage = new OsHandle;
storage.fragmentStorageData[2].osHandleStorage->handle = ALLOCATION_HANDLE;
storage.fragmentStorageData[2].freeTheFragment = true;
storage.fragmentStorageData[2].osHandleStorage->gmm = Gmm::create(pSysMem, 4096u);
storage.fragmentStorageData[2].osHandleStorage->gmm = Gmm::create(pSysMem, 4096u, false);
storage.fragmentStorageData[2].residency = new ResidencyData;
mm->cleanOsHandles(storage);
@@ -1585,7 +1585,7 @@ TEST_F(MockWddmMemoryManagerTest, givenDisabledAsyncDeleterFlagWhenMemoryManager
}
HWTEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVaThenMapAuxVa) {
std::unique_ptr<Gmm> gmm(Gmm::create((void *)123, 4096u));
std::unique_ptr<Gmm> gmm(Gmm::create((void *)123, 4096u, false));
gmm->isRenderCompressed = true;
D3DGPU_VIRTUAL_ADDRESS gpuVa = 0;
WddmMock wddm;
@@ -1653,7 +1653,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenReleas
}
HWTEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenMappedGpuVaThenDontMapAuxVa) {
std::unique_ptr<Gmm> gmm(Gmm::create((void *)123, 4096u));
std::unique_ptr<Gmm> gmm(Gmm::create((void *)123, 4096u, false));
gmm->isRenderCompressed = false;
D3DGPU_VIRTUAL_ADDRESS gpuVa = 0;
WddmMock wddm;
@@ -1669,7 +1669,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenMapped
}
HWTEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenReturnFalse) {
std::unique_ptr<Gmm> gmm(Gmm::create((void *)123, 4096u));
std::unique_ptr<Gmm> gmm(Gmm::create((void *)123, 4096u, false));
gmm->isRenderCompressed = false;
D3DGPU_VIRTUAL_ADDRESS gpuVa = 0;
WddmMock wddm;
@@ -1688,7 +1688,7 @@ HWTEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsUn
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
wddm->resetPageTableManager(mockMngr);
auto myGmm = Gmm::create((void *)123, 4096u);
auto myGmm = Gmm::create((void *)123, 4096u, false);
myGmm->isRenderCompressed = false;
myGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = 1;

View File

@@ -316,7 +316,7 @@ TEST_F(WddmTest, GetCpuGpuTime) {
HWTEST_F(WddmTest, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledThenGraphicsAllocationWithSharedPropertiesIsCreated) {
void *pSysMem = (void *)0x1000;
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u));
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u, false));
auto status = setSizesFunction(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
EXPECT_EQ(0u, status);
@@ -355,7 +355,7 @@ HWTEST_F(WddmTest, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandle
HWTEST_F(WddmTest, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledThenMapGpuVaWithCpuPtrDepensOnBitness) {
void *pSysMem = (void *)0x1000;
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u));
std::unique_ptr<Gmm> gmm(Gmm::create(pSysMem, 4096u, false));
auto status = setSizesFunction(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
EXPECT_EQ(0u, status);

View File

@@ -21,11 +21,27 @@
*/
#include "unit_tests/preemption/preemption_tests.h"
#include "runtime/helpers/options.h"
using namespace OCLRT;
typedef DevicePreemptionTests ThreadGroupPreemptionTests;
typedef DevicePreemptionTests MidThreadPreemptionTests;
class ThreadGroupPreemptionTests : public DevicePreemptionTests {
void SetUp() override {
dbgRestore = new DebugManagerStateRestore();
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::ThreadGroup));
preemptionMode = PreemptionMode::ThreadGroup;
DevicePreemptionTests::SetUp();
}
};
class MidThreadPreemptionTests : public DevicePreemptionTests {
void SetUp() override {
dbgRestore = new DebugManagerStateRestore();
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
preemptionMode = PreemptionMode::MidThread;
DevicePreemptionTests::SetUp();
}
};
TEST_F(ThreadGroupPreemptionTests, disallowByKMD) {
waTable->waDisablePerCtxtPreemptionGranularityControl = 1;
@@ -269,3 +285,37 @@ TEST_F(DevicePreemptionTests, setDefaultDisabledPreemptionNoMidBatchSupport) {
TEST(PreemptionTest, defaultMode) {
EXPECT_EQ(0, DebugManager.flags.ForcePreemptionMode.get());
}
HWTEST_F(MidThreadPreemptionTests, createCsrSurfaceNoWa) {
const WorkaroundTable *waTable = platformDevices[0]->pWaTable;
WorkaroundTable tmpWaTable;
tmpWaTable.waCSRUncachable = false;
const_cast<HardwareInfo *>(platformDevices[0])->pWaTable = &tmpWaTable;
std::unique_ptr<MockDevice> mockDevice(Device::create<OCLRT::MockDevice>(platformDevices[0]));
ASSERT_NE(nullptr, mockDevice.get());
auto &csr = mockDevice->getUltCommandStreamReceiver<FamilyType>();
MemoryAllocation *csrSurface = static_cast<MemoryAllocation *>(csr.getPreemptionCsrAllocation());
ASSERT_NE(nullptr, csrSurface);
EXPECT_FALSE(csrSurface->uncacheable);
const_cast<HardwareInfo *>(platformDevices[0])->pWaTable = waTable;
}
HWTEST_F(MidThreadPreemptionTests, createCsrSurfaceWa) {
const WorkaroundTable *waTable = platformDevices[0]->pWaTable;
WorkaroundTable tmpWaTable;
tmpWaTable.waCSRUncachable = true;
const_cast<HardwareInfo *>(platformDevices[0])->pWaTable = &tmpWaTable;
std::unique_ptr<MockDevice> mockDevice(Device::create<OCLRT::MockDevice>(platformDevices[0]));
ASSERT_NE(nullptr, mockDevice.get());
auto &csr = mockDevice->getUltCommandStreamReceiver<FamilyType>();
MemoryAllocation *csrSurface = static_cast<MemoryAllocation *>(csr.getPreemptionCsrAllocation());
ASSERT_NE(nullptr, csrSurface);
EXPECT_TRUE(csrSurface->uncacheable);
const_cast<HardwareInfo *>(platformDevices[0])->pWaTable = waTable;
}

View File

@@ -44,8 +44,6 @@ namespace OCLRT {
class DevicePreemptionTests : public ::testing::Test {
public:
void SetUp() override {
dbgRestore = new DebugManagerStateRestore();
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::ThreadGroup));
const cl_queue_properties properties[3] = {CL_QUEUE_PROPERTIES, 0, 0};
kernelInfo = KernelInfo::create();
device = MockDevice::create<OCLRT::MockDevice>(nullptr, false);
@@ -60,11 +58,12 @@ class DevicePreemptionTests : public ::testing::Test {
ASSERT_NE(nullptr, context);
ASSERT_NE(nullptr, cmdQ);
forceWhitelistedRegs(true);
preemptionMode = PreemptionMode::ThreadGroup;
waTable = const_cast<WorkaroundTable *>(device->getWaTable());
}
void TearDown() override {
delete dbgRestore;
if (dbgRestore) {
delete dbgRestore;
}
delete kernel;
delete kernelInfo;
delete dispatchInfo;
@@ -83,7 +82,7 @@ class DevicePreemptionTests : public ::testing::Test {
MockCommandQueue *cmdQ;
MockDevice *device;
MockContext *context;
DebugManagerStateRestore *dbgRestore;
DebugManagerStateRestore *dbgRestore = nullptr;
WorkaroundTable *waTable = nullptr;
SPatchExecutionEnvironment executionEnvironment;
MockProgram program;