mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 16:24:18 +08:00
Use stateful args programming for aux translation kernels.
Set valid mocs values Change-Id: I8de2bbdd72b102a1623b9e397485ef52ecca8306 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
d35c20f430
commit
1518774fe6
@@ -27,7 +27,6 @@ class BuiltInOp<EBuiltInOps::AuxTranslation> : public BuiltinDispatchInfoBuilder
|
||||
|
||||
for (auto &memObj : *operationParams.memObjsForAuxTranslation) {
|
||||
DispatchInfoBuilder<SplitDispatch::Dim::d1D, SplitDispatch::SplitMode::NoSplit> builder;
|
||||
auto graphicsAllocation = memObj->getGraphicsAllocation();
|
||||
size_t allocationSize = alignUp(memObj->getSize(), 512);
|
||||
|
||||
UNRECOVERABLE_IF(builder.getMaxNumDispatches() != 1);
|
||||
@@ -43,15 +42,14 @@ class BuiltInOp<EBuiltInOps::AuxTranslation> : public BuiltinDispatchInfoBuilder
|
||||
|
||||
if (AuxTranslationDirection::AuxToNonAux == operationParams.auxTranslationDirection) {
|
||||
builder.setKernel(convertToNonAuxKernel[kernelInstanceNumber++].get());
|
||||
builder.setArg(0, memObj);
|
||||
builder.setArgSvm(1, allocationSize, reinterpret_cast<void *>(graphicsAllocation->getGpuAddress()), nullptr, 0u);
|
||||
} else {
|
||||
UNRECOVERABLE_IF(AuxTranslationDirection::NonAuxToAux != operationParams.auxTranslationDirection);
|
||||
builder.setKernel(convertToAuxKernel[kernelInstanceNumber++].get());
|
||||
builder.setArgSvm(0, allocationSize, reinterpret_cast<void *>(graphicsAllocation->getGpuAddress()), nullptr, 0u);
|
||||
builder.setArg(1, memObj);
|
||||
}
|
||||
|
||||
builder.setArg(0, memObj);
|
||||
builder.setArg(1, memObj);
|
||||
|
||||
size_t xGws = allocationSize / 16;
|
||||
|
||||
builder.setDispatchGeometry(Vec3<size_t>{xGws, 0, 0}, Vec3<size_t>{0, 0, 0}, Vec3<size_t>{0, 0, 0});
|
||||
|
||||
@@ -20,6 +20,7 @@ void BuiltinDispatchInfoBuilder::populate(Context &context, Device &device, EBui
|
||||
|
||||
BuiltInOp<EBuiltInOps::AuxTranslation>::BuiltInOp(BuiltIns &kernelsLib, Context &context, Device &device) : BuiltinDispatchInfoBuilder(kernelsLib) {
|
||||
BuiltinDispatchInfoBuilder::populate(context, device, EBuiltInOps::AuxTranslation, "", "fullCopy", baseKernel);
|
||||
|
||||
resizeKernelInstances(5);
|
||||
}
|
||||
|
||||
@@ -28,15 +29,17 @@ void BuiltInOp<EBuiltInOps::AuxTranslation>::resizeKernelInstances(size_t size)
|
||||
convertToAuxKernel.reserve(size);
|
||||
|
||||
for (size_t i = convertToNonAuxKernel.size(); i < size; i++) {
|
||||
auto clonedKernel1 = Kernel::create(baseKernel->getProgram(), baseKernel->getKernelInfo(), nullptr);
|
||||
clonedKernel1->setAuxTranslationFlag(true);
|
||||
auto clonedKernel2 = Kernel::create(baseKernel->getProgram(), baseKernel->getKernelInfo(), nullptr);
|
||||
clonedKernel2->setAuxTranslationFlag(true);
|
||||
clonedKernel1->cloneKernel(baseKernel);
|
||||
clonedKernel2->cloneKernel(baseKernel);
|
||||
auto clonedNonAuxToAuxKernel = Kernel::create(baseKernel->getProgram(), baseKernel->getKernelInfo(), nullptr);
|
||||
clonedNonAuxToAuxKernel->setAuxTranslationDirection(AuxTranslationDirection::NonAuxToAux);
|
||||
|
||||
convertToNonAuxKernel.emplace_back(clonedKernel1);
|
||||
convertToAuxKernel.emplace_back(clonedKernel2);
|
||||
auto clonedAuxToNonAuxKernel = Kernel::create(baseKernel->getProgram(), baseKernel->getKernelInfo(), nullptr);
|
||||
clonedAuxToNonAuxKernel->setAuxTranslationDirection(AuxTranslationDirection::AuxToNonAux);
|
||||
|
||||
clonedNonAuxToAuxKernel->cloneKernel(baseKernel);
|
||||
clonedAuxToNonAuxKernel->cloneKernel(baseKernel);
|
||||
|
||||
convertToAuxKernel.emplace_back(clonedNonAuxToAuxKernel);
|
||||
convertToNonAuxKernel.emplace_back(clonedAuxToNonAuxKernel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ void gtpinNotifyKernelSubmit(cl_kernel kernel, void *pCmdQueue) {
|
||||
void *pSurfaceState = gtpinHelper.getSurfaceState(pKernel, gtpinBTI);
|
||||
cl_mem buffer = (cl_mem)resource;
|
||||
auto pBuffer = castToObjectOrAbort<Buffer>(buffer);
|
||||
pBuffer->setArgStateful(pSurfaceState, false, false, false);
|
||||
pBuffer->setArgStateful(pSurfaceState, false, false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1186,12 +1186,24 @@ cl_int Kernel::setArgBuffer(uint32_t argIndex,
|
||||
this->patchInfoDataList.push_back(patchInfoData);
|
||||
}
|
||||
|
||||
bool forceNonAuxMode = buffer->getGraphicsAllocation()->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED &&
|
||||
!kernelArgInfo.pureStatefulBufferAccess;
|
||||
bool disableL3 = false;
|
||||
bool forceNonAuxMode = false;
|
||||
bool isAuxTranslationKernel = (AuxTranslationDirection::None != auxTranslationDirection);
|
||||
|
||||
if (isAuxTranslationKernel) {
|
||||
if (((AuxTranslationDirection::AuxToNonAux == auxTranslationDirection) && argIndex == 1) ||
|
||||
((AuxTranslationDirection::NonAuxToAux == auxTranslationDirection) && argIndex == 0)) {
|
||||
forceNonAuxMode = true;
|
||||
}
|
||||
disableL3 = (argIndex == 0);
|
||||
} else if (buffer->getGraphicsAllocation()->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED &&
|
||||
!kernelArgInfo.pureStatefulBufferAccess) {
|
||||
forceNonAuxMode = true;
|
||||
}
|
||||
|
||||
if (requiresSshForBuffers()) {
|
||||
auto surfaceState = ptrOffset(getSurfaceStateHeap(), kernelArgInfo.offsetHeap);
|
||||
buffer->setArgStateful(surfaceState, forceNonAuxMode, auxTranslationKernel, kernelArgInfo.isReadOnly);
|
||||
buffer->setArgStateful(surfaceState, forceNonAuxMode, disableL3, isAuxTranslationKernel, kernelArgInfo.isReadOnly);
|
||||
kernelArguments[argIndex].isUncacheable = buffer->isMemObjUncacheable();
|
||||
}
|
||||
addAllocationToCacheFlushVector(argIndex, buffer->getGraphicsAllocation());
|
||||
|
||||
@@ -386,8 +386,8 @@ class Kernel : public BaseObject<_cl_kernel> {
|
||||
using CacheFlushAllocationsVec = StackVec<GraphicsAllocation *, 32>;
|
||||
void getAllocationsForCacheFlush(CacheFlushAllocationsVec &out) const;
|
||||
|
||||
void setAuxTranslationFlag(bool auxTranslationFlag) {
|
||||
this->auxTranslationKernel = auxTranslationFlag;
|
||||
void setAuxTranslationDirection(AuxTranslationDirection auxTranslationDirection) {
|
||||
this->auxTranslationDirection = auxTranslationDirection;
|
||||
}
|
||||
void setUnifiedMemoryProperty(cl_kernel_exec_info infoType, bool infoValue);
|
||||
void setUnifiedMemoryExecInfo(GraphicsAllocation *argValue);
|
||||
@@ -492,7 +492,7 @@ class Kernel : public BaseObject<_cl_kernel> {
|
||||
std::vector<GraphicsAllocation *> kernelSvmGfxAllocations;
|
||||
std::vector<GraphicsAllocation *> kernelUnifiedMemoryGfxAllocations;
|
||||
|
||||
bool auxTranslationKernel = false;
|
||||
AuxTranslationDirection auxTranslationDirection = AuxTranslationDirection::None;
|
||||
|
||||
size_t numberOfBindingTableStates;
|
||||
size_t localBindingTableOffset;
|
||||
|
||||
@@ -563,7 +563,7 @@ void Buffer::setSurfaceState(const Device *device,
|
||||
GraphicsAllocation *gfxAlloc,
|
||||
cl_mem_flags flags) {
|
||||
auto buffer = Buffer::createBufferHwFromDevice(device, flags, svmSize, svmPtr, svmPtr, gfxAlloc, true, false, false);
|
||||
buffer->setArgStateful(surfaceState, false, false, false);
|
||||
buffer->setArgStateful(surfaceState, false, false, false, false);
|
||||
buffer->graphicsAllocation = nullptr;
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ class Buffer : public MemObj {
|
||||
bool isValidSubBufferOffset(size_t offset);
|
||||
uint64_t setArgStateless(void *memory, uint32_t patchSize) { return setArgStateless(memory, patchSize, false); }
|
||||
uint64_t setArgStateless(void *memory, uint32_t patchSize, bool set32BitAddressing);
|
||||
virtual void setArgStateful(void *memory, bool forceNonAuxMode, bool programForAuxTranslation, bool isReadOnly) = 0;
|
||||
virtual void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) = 0;
|
||||
bool bufferRectPitchSet(const size_t *bufferOrigin,
|
||||
const size_t *region,
|
||||
size_t &bufferRowPitch,
|
||||
@@ -170,7 +170,7 @@ class BufferHw : public Buffer {
|
||||
: Buffer(context, properties, size, memoryStorage, hostPtr, gfxAllocation,
|
||||
zeroCopy, isHostPtrSVM, isObjectRedescribed) {}
|
||||
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool programForAuxTranslation, bool isReadOnlyArgument) override;
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument) override;
|
||||
void appendBufferState(void *memory, Context *context, GraphicsAllocation *gfxAllocation, bool isReadOnlyArgument);
|
||||
|
||||
static Buffer *create(Context *context,
|
||||
|
||||
@@ -28,7 +28,7 @@ union SURFACE_STATE_BUFFER_LENGTH {
|
||||
};
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, bool programForAuxTranslation, bool isReadOnlyArgument) {
|
||||
void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument) {
|
||||
using RENDER_SURFACE_STATE = typename GfxFamily::RENDER_SURFACE_STATE;
|
||||
using SURFACE_FORMAT = typename RENDER_SURFACE_STATE::SURFACE_FORMAT;
|
||||
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
|
||||
@@ -41,7 +41,7 @@ void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, boo
|
||||
auto bufferAddressAligned = alignDown(bufferAddress, 4);
|
||||
auto bufferOffset = ptrDiff(bufferAddress, bufferAddressAligned);
|
||||
|
||||
auto surfaceSize = alignUp(getSize() + bufferOffset, programForAuxTranslation ? 512 : 4);
|
||||
auto surfaceSize = alignUp(getSize() + bufferOffset, alignSizeForAuxTranslation ? 512 : 4);
|
||||
|
||||
SURFACE_STATE_BUFFER_LENGTH Length = {0};
|
||||
Length.Length = static_cast<uint32_t>(surfaceSize - 1);
|
||||
@@ -62,7 +62,8 @@ void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, boo
|
||||
surfaceState->setTileMode(RENDER_SURFACE_STATE::TILE_MODE_LINEAR);
|
||||
surfaceState->setVerticalLineStride(0);
|
||||
surfaceState->setVerticalLineStrideOffset(0);
|
||||
surfaceState->setMemoryObjectControlState(getMocsValue(programForAuxTranslation, isReadOnlyArgument));
|
||||
|
||||
surfaceState->setMemoryObjectControlState(getMocsValue(disableL3, isReadOnlyArgument));
|
||||
surfaceState->setSurfaceBaseAddress(bufferAddressAligned);
|
||||
|
||||
Gmm *gmm = graphicsAllocation ? graphicsAllocation->getDefaultGmm() : nullptr;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/built_ins/builtins_dispatch_builder.h"
|
||||
#include "runtime/built_ins/vme_dispatch_builder.h"
|
||||
#include "runtime/gmm_helper/gmm.h"
|
||||
#include "runtime/helpers/dispatch_info_builder.h"
|
||||
#include "runtime/helpers/file_io.h"
|
||||
#include "runtime/helpers/hash.h"
|
||||
@@ -286,10 +287,8 @@ HWTEST_F(BuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxTrans
|
||||
memObjsForAuxTranslation.erase(buffer);
|
||||
|
||||
cl_mem clMem = buffer;
|
||||
void *gpuAddress = reinterpret_cast<void *>(buffer->getGraphicsAllocation()->getGpuAddress());
|
||||
EXPECT_EQ(clMem, kernel->getKernelArguments().at(0).object);
|
||||
EXPECT_EQ(gpuAddress, kernel->getKernelArguments().at(1).value);
|
||||
EXPECT_EQ(nullptr, kernel->getKernelArguments().at(1).object);
|
||||
EXPECT_EQ(clMem, kernel->getKernelArguments().at(1).object);
|
||||
|
||||
EXPECT_EQ(1u, dispatchInfo.getDim());
|
||||
size_t xGws = alignUp(buffer->getSize(), 512) / 16;
|
||||
@@ -335,9 +334,7 @@ HWTEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTranslat
|
||||
memObjsForAuxTranslation.erase(buffer);
|
||||
|
||||
cl_mem clMem = buffer;
|
||||
void *gpuAddress = reinterpret_cast<void *>(buffer->getGraphicsAllocation()->getGpuAddress());
|
||||
EXPECT_EQ(gpuAddress, kernel->getKernelArguments().at(0).value);
|
||||
EXPECT_EQ(nullptr, kernel->getKernelArguments().at(0).object);
|
||||
EXPECT_EQ(clMem, kernel->getKernelArguments().at(0).object);
|
||||
EXPECT_EQ(clMem, kernel->getKernelArguments().at(1).object);
|
||||
|
||||
EXPECT_EQ(1u, dispatchInfo.getDim());
|
||||
@@ -495,6 +492,142 @@ HWTEST_F(BuiltInTests, givenKernelWithAuxTranslationRequiredWhenEnqueueCalledThe
|
||||
EXPECT_EQ(1u, mockBuiltinKernel->releaseOwnershipCalls);
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInTests, givenAuxTranslationKernelWhenSettingKernelArgsThenSetValidMocs) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
|
||||
MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pContext, *pDevice);
|
||||
MultiDispatchInfo multiDispatchInfo;
|
||||
MemObjsForAuxTranslation memObjsForAuxTranslation;
|
||||
|
||||
BuiltinOpParams builtinOpParamsToAux;
|
||||
builtinOpParamsToAux.memObjsForAuxTranslation = &memObjsForAuxTranslation;
|
||||
builtinOpParamsToAux.auxTranslationDirection = AuxTranslationDirection::NonAuxToAux;
|
||||
|
||||
BuiltinOpParams builtinOpParamsToNonAux;
|
||||
builtinOpParamsToNonAux.memObjsForAuxTranslation = &memObjsForAuxTranslation;
|
||||
builtinOpParamsToNonAux.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux;
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
auto buffer = std::unique_ptr<Buffer>(Buffer::create(pContext, 0, MemoryConstants::pageSize, nullptr, retVal));
|
||||
memObjsForAuxTranslation.insert(buffer.get());
|
||||
|
||||
mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpParamsToAux);
|
||||
mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpParamsToNonAux);
|
||||
|
||||
{
|
||||
// read args
|
||||
auto argNum = 0;
|
||||
auto expectedMocs = pDevice->getExecutionEnvironment()->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED);
|
||||
auto sshBase = mockAuxBuiltInOp.convertToAuxKernel[0]->getSurfaceStateHeap();
|
||||
auto sshOffset = mockAuxBuiltInOp.convertToAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
|
||||
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
|
||||
EXPECT_EQ(expectedMocs, surfaceState->getMemoryObjectControlState());
|
||||
|
||||
sshBase = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getSurfaceStateHeap();
|
||||
sshOffset = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
|
||||
surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
|
||||
EXPECT_EQ(expectedMocs, surfaceState->getMemoryObjectControlState());
|
||||
}
|
||||
|
||||
{
|
||||
// write args
|
||||
auto argNum = 1;
|
||||
auto expectedMocs = pDevice->getExecutionEnvironment()->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER);
|
||||
auto sshBase = mockAuxBuiltInOp.convertToAuxKernel[0]->getSurfaceStateHeap();
|
||||
auto sshOffset = mockAuxBuiltInOp.convertToAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
|
||||
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
|
||||
EXPECT_EQ(expectedMocs, surfaceState->getMemoryObjectControlState());
|
||||
|
||||
sshBase = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getSurfaceStateHeap();
|
||||
sshOffset = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
|
||||
surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
|
||||
EXPECT_EQ(expectedMocs, surfaceState->getMemoryObjectControlState());
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInTests, givenAuxToNonAuxTranslationWhenSettingSurfaceStateThenSetValidAuxMode) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
|
||||
|
||||
MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pContext, *pDevice);
|
||||
MultiDispatchInfo multiDispatchInfo;
|
||||
MemObjsForAuxTranslation memObjsForAuxTranslation;
|
||||
|
||||
BuiltinOpParams builtinOpParams;
|
||||
builtinOpParams.memObjsForAuxTranslation = &memObjsForAuxTranslation;
|
||||
builtinOpParams.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux;
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
auto buffer = std::unique_ptr<Buffer>(Buffer::create(pContext, 0, MemoryConstants::pageSize, nullptr, retVal));
|
||||
buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||
auto gmm = new Gmm(nullptr, 1, false);
|
||||
gmm->isRenderCompressed = true;
|
||||
buffer->getGraphicsAllocation()->setDefaultGmm(gmm);
|
||||
|
||||
memObjsForAuxTranslation.insert(buffer.get());
|
||||
|
||||
mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpParams);
|
||||
|
||||
{
|
||||
// read arg
|
||||
auto argNum = 0;
|
||||
auto sshBase = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getSurfaceStateHeap();
|
||||
auto sshOffset = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
|
||||
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
|
||||
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E, surfaceState->getAuxiliarySurfaceMode());
|
||||
}
|
||||
|
||||
{
|
||||
// write arg
|
||||
auto argNum = 1;
|
||||
auto sshBase = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getSurfaceStateHeap();
|
||||
auto sshOffset = mockAuxBuiltInOp.convertToNonAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
|
||||
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
|
||||
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, surfaceState->getAuxiliarySurfaceMode());
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInTests, givenNonAuxToAuxTranslationWhenSettingSurfaceStateThenSetValidAuxMode) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
|
||||
|
||||
MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pContext, *pDevice);
|
||||
MultiDispatchInfo multiDispatchInfo;
|
||||
MemObjsForAuxTranslation memObjsForAuxTranslation;
|
||||
|
||||
BuiltinOpParams builtinOpParams;
|
||||
builtinOpParams.memObjsForAuxTranslation = &memObjsForAuxTranslation;
|
||||
builtinOpParams.auxTranslationDirection = AuxTranslationDirection::NonAuxToAux;
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
auto buffer = std::unique_ptr<Buffer>(Buffer::create(pContext, 0, MemoryConstants::pageSize, nullptr, retVal));
|
||||
buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||
auto gmm = new Gmm(nullptr, 1, false);
|
||||
gmm->isRenderCompressed = true;
|
||||
buffer->getGraphicsAllocation()->setDefaultGmm(gmm);
|
||||
memObjsForAuxTranslation.insert(buffer.get());
|
||||
|
||||
mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpParams);
|
||||
|
||||
{
|
||||
// read arg
|
||||
auto argNum = 0;
|
||||
auto sshBase = mockAuxBuiltInOp.convertToAuxKernel[0]->getSurfaceStateHeap();
|
||||
auto sshOffset = mockAuxBuiltInOp.convertToAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
|
||||
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
|
||||
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, surfaceState->getAuxiliarySurfaceMode());
|
||||
}
|
||||
|
||||
{
|
||||
// write arg
|
||||
auto argNum = 1;
|
||||
auto sshBase = mockAuxBuiltInOp.convertToAuxKernel[0]->getSurfaceStateHeap();
|
||||
auto sshOffset = mockAuxBuiltInOp.convertToAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap;
|
||||
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(sshBase, sshOffset));
|
||||
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E, surfaceState->getAuxiliarySurfaceMode());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(BuiltInTests, BuiltinDispatchInfoBuilderCopyBufferToBufferAligned) {
|
||||
BuiltinDispatchInfoBuilder &builder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToBuffer, *pContext, *pDevice);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ GEN9TEST_F(Gen9HardwareCommandsTest, givenBufferThatIsNotZeroCopyWhenSurfaceStat
|
||||
auto gmmHelper = context.getDevice(0)->getExecutionEnvironment()->getGmmHelper();
|
||||
gmmHelper->setSimplifiedMocsTableUsage(true);
|
||||
|
||||
buffer->setArgStateful(&surfaceState, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
//make sure proper mocs is selected
|
||||
constexpr uint32_t expectedMocs = GmmHelper::cacheEnabledIndex;
|
||||
EXPECT_EQ(expectedMocs, surfaceState.getMemoryObjectControlStateIndexToMocsTables());
|
||||
|
||||
@@ -74,7 +74,7 @@ class MockObject : public MockObjectBase<BaseType> {};
|
||||
template <>
|
||||
class MockObject<Buffer> : public MockObjectBase<Buffer> {
|
||||
public:
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3Cache, bool isReadOnly) override {}
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {}
|
||||
};
|
||||
|
||||
template <>
|
||||
@@ -278,7 +278,7 @@ class MockBuffer : public MockBufferStorage, public Buffer {
|
||||
MockBuffer() : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data), &data, &data, &mockGfxAllocation, true, false, false) {
|
||||
}
|
||||
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3Cache, bool isReadOnly) override {
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1690,7 +1690,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatAddressIsForcedTo32bitW
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
RENDER_SURFACE_STATE surfaceState = {};
|
||||
|
||||
buffer->setArgStateful(&surfaceState, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
|
||||
auto surfBaseAddress = surfaceState.getSurfaceBaseAddress();
|
||||
auto bufferAddress = buffer->getGraphicsAllocation()->getGpuAddress();
|
||||
@@ -1725,7 +1725,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferWithOffsetWhenSetArgStatefulIsCalledT
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
RENDER_SURFACE_STATE surfaceState = {};
|
||||
|
||||
subBuffer->setArgStateful(&surfaceState, false, false, false);
|
||||
subBuffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
|
||||
auto surfBaseAddress = surfaceState.getSurfaceBaseAddress();
|
||||
auto bufferAddress = buffer->getGraphicsAllocation()->getGpuAddress();
|
||||
@@ -1754,7 +1754,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferWhenSetArgStatefulWithL3ChacheDisable
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
RENDER_SURFACE_STATE surfaceState = {};
|
||||
|
||||
buffer->setArgStateful(&surfaceState, false, true, false);
|
||||
buffer->setArgStateful(&surfaceState, false, true, true, false);
|
||||
|
||||
auto mocs = surfaceState.getMemoryObjectControlState();
|
||||
auto gmmHelper = device->getGmmHelper();
|
||||
@@ -1781,7 +1781,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferThatIsMisalignedButIsAReadOnlyArgumen
|
||||
|
||||
buffer->getGraphicsAllocation()->setSize(127);
|
||||
|
||||
buffer->setArgStateful(&surfaceState, false, false, true);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, true);
|
||||
|
||||
auto mocs = surfaceState.getMemoryObjectControlState();
|
||||
auto gmmHelper = device->getGmmHelper();
|
||||
@@ -1806,7 +1806,7 @@ HWTEST_F(BufferSetSurfaceTests, givenAlignedCacheableReadOnlyBufferThenChoseOclB
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
typename FamilyType::RENDER_SURFACE_STATE surfaceState = {};
|
||||
buffer->setArgStateful(&surfaceState, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
|
||||
const auto expectedMocs = device->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER);
|
||||
const auto actualMocs = surfaceState.getMemoryObjectControlState();
|
||||
@@ -1831,7 +1831,7 @@ HWTEST_F(BufferSetSurfaceTests, givenAlignedCacheableNonReadOnlyBufferThenChoose
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
typename FamilyType::RENDER_SURFACE_STATE surfaceState = {};
|
||||
buffer->setArgStateful(&surfaceState, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
|
||||
const auto expectedMocs = device->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER);
|
||||
const auto actualMocs = surfaceState.getMemoryObjectControlState();
|
||||
@@ -1854,14 +1854,14 @@ HWTEST_F(BufferSetSurfaceTests, givenRenderCompressedGmmResourceWhenSurfaceState
|
||||
buffer->getGraphicsAllocation()->setDefaultGmm(gmm);
|
||||
gmm->isRenderCompressed = true;
|
||||
|
||||
buffer->setArgStateful(&surfaceState, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
|
||||
EXPECT_EQ(0u, surfaceState.getAuxiliarySurfaceBaseAddress());
|
||||
EXPECT_TRUE(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E == surfaceState.getAuxiliarySurfaceMode());
|
||||
EXPECT_TRUE(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT == surfaceState.getCoherencyType());
|
||||
|
||||
buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
EXPECT_TRUE(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE == surfaceState.getAuxiliarySurfaceMode());
|
||||
}
|
||||
|
||||
@@ -1878,7 +1878,7 @@ HWTEST_F(BufferSetSurfaceTests, givenNonRenderCompressedGmmResourceWhenSurfaceSt
|
||||
buffer->getGraphicsAllocation()->setDefaultGmm(gmm);
|
||||
gmm->isRenderCompressed = false;
|
||||
|
||||
buffer->setArgStateful(&surfaceState, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
|
||||
EXPECT_EQ(0u, surfaceState.getAuxiliarySurfaceBaseAddress());
|
||||
EXPECT_TRUE(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE == surfaceState.getAuxiliarySurfaceMode());
|
||||
|
||||
@@ -45,7 +45,7 @@ class MockBuffer : public MockBufferStorage, public Buffer {
|
||||
this->graphicsAllocation = &this->mockGfxAllocation;
|
||||
}
|
||||
}
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3Cache, bool isReadOnly) override {
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
|
||||
Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), (externalAlloc != nullptr) ? externalAlloc : &mockGfxAllocation);
|
||||
}
|
||||
GraphicsAllocation *externalAlloc = nullptr;
|
||||
@@ -58,7 +58,7 @@ class AlignedBuffer : public MockBufferStorage, public Buffer {
|
||||
}
|
||||
AlignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), gfxAllocation, true, false, false) {
|
||||
}
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3Cache, bool isReadOnly) override {
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
|
||||
Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation);
|
||||
}
|
||||
};
|
||||
@@ -70,7 +70,7 @@ class UnalignedBuffer : public MockBufferStorage, public Buffer {
|
||||
}
|
||||
UnalignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(true), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), gfxAllocation, false, false, false) {
|
||||
}
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3Cache, bool isReadOnly) override {
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
|
||||
Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1498,7 +1498,7 @@ class DrmMockBuffer : public Buffer {
|
||||
gfxAllocation(alloc) {
|
||||
}
|
||||
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3Cache, bool isReadOnly) override {
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user