Add function to check if kernel has indirect stateless access to host memory

Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
Slawomir Milczarek
2021-01-08 13:09:32 +00:00
committed by Compute-Runtime-Automation
parent d1d81c1f48
commit d605234843
4 changed files with 45 additions and 0 deletions

View File

@ -2615,6 +2615,19 @@ bool Kernel::hasDirectStatelessAccessToHostMemory() const {
return false;
}
bool Kernel::hasIndirectStatelessAccessToHostMemory() const {
if (!getDefaultKernelInfo().hasIndirectStatelessAccess) {
return false;
}
for (auto gfxAllocation : kernelUnifiedMemoryGfxAllocations) {
if (gfxAllocation->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY) {
return true;
}
}
return false;
}
void Kernel::getAllocationsForCacheFlush(CacheFlushAllocationsVec &out, uint32_t rootDeviceIndex) const {
if (false == HwHelper::cacheFlushAfterWalkerSupported(getHardwareInfo(rootDeviceIndex))) {
return;

View File

@ -501,6 +501,7 @@ class Kernel : public BaseObject<_cl_kernel> {
void reconfigureKernel(uint32_t rootDeviceIndex);
bool hasDirectStatelessAccessToHostMemory() const;
bool hasIndirectStatelessAccessToHostMemory() const;
void addAllocationToCacheFlushVector(uint32_t argIndex, GraphicsAllocation *argAllocation);
bool allocationForCacheFlush(GraphicsAllocation *argAllocation) const;

View File

@ -432,6 +432,36 @@ TEST_F(KernelArgBufferTest, givenInvalidKernelObjWhenHasDirectStatelessAccessToH
EXPECT_FALSE(pKernel->hasDirectStatelessAccessToHostMemory());
}
TEST_F(KernelArgBufferTest, givenKernelWithIndirectStatelessAccessWhenHasIndirectStatelessAccessToHostMemoryIsCalledThenReturnTrueForHostMemoryAllocations) {
KernelInfo kernelInfo;
EXPECT_FALSE(kernelInfo.hasIndirectStatelessAccess);
MockKernel kernelWithNoIndirectStatelessAccess(pProgram, MockKernel::toKernelInfoContainer(kernelInfo, 0));
EXPECT_FALSE(kernelWithNoIndirectStatelessAccess.hasIndirectStatelessAccessToHostMemory());
kernelInfo.hasIndirectStatelessAccess = true;
MockKernel kernelWithNoIndirectHostAllocations(pProgram, MockKernel::toKernelInfoContainer(kernelInfo, 0));
EXPECT_FALSE(kernelWithNoIndirectHostAllocations.hasIndirectStatelessAccessToHostMemory());
const auto allocationTypes = {GraphicsAllocation::AllocationType::BUFFER,
GraphicsAllocation::AllocationType::BUFFER_COMPRESSED,
GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY};
MockKernel kernelWithIndirectUnifiedMemoryAllocation(pProgram, MockKernel::toKernelInfoContainer(kernelInfo, 0));
MockGraphicsAllocation gfxAllocation;
for (const auto type : allocationTypes) {
gfxAllocation.setAllocationType(type);
kernelWithIndirectUnifiedMemoryAllocation.setUnifiedMemoryExecInfo(&gfxAllocation);
if (type == GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY) {
EXPECT_TRUE(kernelWithIndirectUnifiedMemoryAllocation.hasIndirectStatelessAccessToHostMemory());
} else {
EXPECT_FALSE(kernelWithIndirectUnifiedMemoryAllocation.hasIndirectStatelessAccessToHostMemory());
}
kernelWithIndirectUnifiedMemoryAllocation.clearUnifiedMemoryExecInfo();
}
}
TEST_F(KernelArgBufferTest, whenSettingAuxTranslationRequiredThenIsAuxTranslationRequiredReturnsCorrectValue) {
for (auto auxTranslationRequired : {false, true}) {
pKernel->setAuxTranslationRequired(auxTranslationRequired);

View File

@ -63,6 +63,7 @@ class MockKernel : public Kernel {
using Kernel::containsStatelessWrites;
using Kernel::executionType;
using Kernel::hasDirectStatelessAccessToHostMemory;
using Kernel::hasIndirectStatelessAccessToHostMemory;
using Kernel::isSchedulerKernel;
using Kernel::kernelArgHandlers;
using Kernel::kernelArgRequiresCacheFlush;