Change Buffer to MemObj in BufferForAuxTranslation collection

Change-Id: Icbdb8fecaa3fd8e19e993502f59c76156fe4ad2c
This commit is contained in:
Kamil Diedrich
2018-12-19 07:13:57 +01:00
parent 2f88abfa2a
commit b2e0195663
10 changed files with 48 additions and 48 deletions

View File

@@ -28,22 +28,22 @@ BuiltInOp<HWFamily, EBuiltInOps::AuxTranslation>::BuiltInOp(BuiltIns &kernelsLib
template <typename HWFamily>
bool BuiltInOp<HWFamily, EBuiltInOps::AuxTranslation>::buildDispatchInfos(MultiDispatchInfo &multiDispatchInfo, const BuiltinOpParams &operationParams) const {
size_t kernelInstanceNumber = 0;
resizeKernelInstances(operationParams.buffersForAuxTranslation->size());
resizeKernelInstances(operationParams.memObjsForAuxTranslation->size());
for (auto &buffer : *operationParams.buffersForAuxTranslation) {
for (auto &memObj : *operationParams.memObjsForAuxTranslation) {
DispatchInfoBuilder<SplitDispatch::Dim::d1D, SplitDispatch::SplitMode::NoSplit> builder;
auto graphicsAllocation = buffer->getGraphicsAllocation();
auto graphicsAllocation = memObj->getGraphicsAllocation();
size_t allocationSize = graphicsAllocation->getUnderlyingBufferSize();
if (AuxTranslationDirection::AuxToNonAux == operationParams.auxTranslationDirection) {
builder.setKernel(convertToNonAuxKernel.at(kernelInstanceNumber++).get());
builder.setArg(0, buffer);
builder.setArg(0, memObj);
builder.setArgSvm(1, allocationSize, reinterpret_cast<void *>(graphicsAllocation->getGpuAddress()));
} else {
UNRECOVERABLE_IF(AuxTranslationDirection::NonAuxToAux != operationParams.auxTranslationDirection);
builder.setKernel(convertToAuxKernel.at(kernelInstanceNumber++).get());
builder.setArgSvm(0, allocationSize, reinterpret_cast<void *>(graphicsAllocation->getGpuAddress()));
builder.setArg(1, buffer);
builder.setArg(1, memObj);
}
size_t elementSize = sizeof(uint32_t) * 4;

View File

@@ -38,7 +38,7 @@ class BuiltinDispatchInfoBuilder {
MemObj *dstMemObj = nullptr;
GraphicsAllocation *srcSvmAlloc = nullptr;
GraphicsAllocation *dstSvmAlloc = nullptr;
const BuffersForAuxTranslation *buffersForAuxTranslation = nullptr;
const MemObjsForAuxTranslation *memObjsForAuxTranslation = nullptr;
AuxTranslationDirection auxTranslationDirection = AuxTranslationDirection::None;
Vec3<size_t> srcOffset = {0, 0, 0};
Vec3<size_t> dstOffset = {0, 0, 0};

View File

@@ -555,12 +555,12 @@ void CommandQueue::releaseIndirectHeap(IndirectHeap::Type heapType) {
getCommandStreamReceiver().releaseIndirectHeap(heapType);
}
void CommandQueue::dispatchAuxTranslation(MultiDispatchInfo &multiDispatchInfo, BuffersForAuxTranslation &buffersForAuxTranslation,
void CommandQueue::dispatchAuxTranslation(MultiDispatchInfo &multiDispatchInfo, MemObjsForAuxTranslation &memObjsForAuxTranslation,
AuxTranslationDirection auxTranslationDirection) {
auto &builder = getDevice().getExecutionEnvironment()->getBuiltIns()->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, getContext(), getDevice());
BuiltinDispatchInfoBuilder::BuiltinOpParams dispatchParams;
dispatchParams.buffersForAuxTranslation = &buffersForAuxTranslation;
dispatchParams.memObjsForAuxTranslation = &memObjsForAuxTranslation;
dispatchParams.auxTranslationDirection = auxTranslationDirection;
builder.buildDispatchInfos(multiDispatchInfo, dispatchParams);

View File

@@ -414,7 +414,7 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
virtual void obtainTaskLevelAndBlockedStatus(unsigned int &taskLevel, cl_uint &numEventsInWaitList, const cl_event *&eventWaitList, bool &blockQueue, unsigned int commandType){};
MOCKABLE_VIRTUAL void dispatchAuxTranslation(MultiDispatchInfo &multiDispatchInfo, BuffersForAuxTranslation &buffersForAuxTranslation,
MOCKABLE_VIRTUAL void dispatchAuxTranslation(MultiDispatchInfo &multiDispatchInfo, MemObjsForAuxTranslation &memObjsForAuxTranslation,
AuxTranslationDirection auxTranslationDirection);
void obtainNewTimestampPacketNodes(size_t numberOfNodes, TimestampPacketContainer &previousNodes);

View File

@@ -58,12 +58,12 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface *(&surfaces)[surfaceCount
if (DebugManager.flags.ForceDispatchScheduler.get()) {
forceDispatchScheduler(multiDispatchInfo);
} else {
BuffersForAuxTranslation buffersForAuxTranslation;
MemObjsForAuxTranslation memObjsForAuxTranslation;
if (kernel->isAuxTranslationRequired()) {
auto &builder = getDevice().getExecutionEnvironment()->getBuiltIns()->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, getContext(), getDevice());
builtInLock.takeOwnership(builder, this->context);
kernel->fillWithBuffersForAuxTranslation(buffersForAuxTranslation);
dispatchAuxTranslation(multiDispatchInfo, buffersForAuxTranslation, AuxTranslationDirection::AuxToNonAux);
kernel->fillWithBuffersForAuxTranslation(memObjsForAuxTranslation);
dispatchAuxTranslation(multiDispatchInfo, memObjsForAuxTranslation, AuxTranslationDirection::AuxToNonAux);
}
if (kernel->getKernelInfo().builtinDispatchBuilder == nullptr) {
@@ -81,11 +81,11 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface *(&surfaces)[surfaceCount
}
if (kernel->isAuxTranslationRequired()) {
if (kernel->isParentKernel) {
for (auto &buffer : buffersForAuxTranslation) {
for (auto &buffer : memObjsForAuxTranslation) {
buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
}
} else {
dispatchAuxTranslation(multiDispatchInfo, buffersForAuxTranslation, AuxTranslationDirection::NonAuxToAux);
dispatchAuxTranslation(multiDispatchInfo, memObjsForAuxTranslation, AuxTranslationDirection::NonAuxToAux);
}
}
}

View File

@@ -34,7 +34,7 @@ struct EventsRequest {
using MemObjSizeArray = std::array<size_t, 3>;
using MemObjOffsetArray = std::array<size_t, 3>;
using BuffersForAuxTranslation = std::unordered_set<Buffer *>;
using MemObjsForAuxTranslation = std::unordered_set<MemObj *>;
enum class AuxTranslationDirection {
None,

View File

@@ -2111,13 +2111,13 @@ bool Kernel::canTransformImages() const {
return device.getHardwareInfo().pPlatform->eRenderCoreFamily >= IGFX_GEN9_CORE;
}
void Kernel::fillWithBuffersForAuxTranslation(BuffersForAuxTranslation &buffersForAuxTranslation) {
buffersForAuxTranslation.reserve(getKernelArgsNumber());
void Kernel::fillWithBuffersForAuxTranslation(MemObjsForAuxTranslation &memObjsForAuxTranslation) {
memObjsForAuxTranslation.reserve(getKernelArgsNumber());
for (uint32_t i = 0; i < getKernelArgsNumber(); i++) {
if (BUFFER_OBJ == kernelArguments.at(i).type && !kernelInfo.kernelArgInfo.at(i).pureStatefulBufferAccess) {
auto buffer = castToObject<Buffer>(getKernelArg(i));
if (buffer && buffer->getGraphicsAllocation()->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED) {
buffersForAuxTranslation.insert(buffer);
memObjsForAuxTranslation.insert(buffer);
}
}
}

View File

@@ -372,7 +372,7 @@ class Kernel : public BaseObject<_cl_kernel> {
return usingImagesOnly;
}
void fillWithBuffersForAuxTranslation(BuffersForAuxTranslation &buffersForAuxTranslation);
void fillWithBuffersForAuxTranslation(MemObjsForAuxTranslation &buffersForAuxTranslation);
protected:
struct ObjectCounts {

View File

@@ -238,7 +238,7 @@ TEST_F(BuiltInTests, BuiltinDispatchInfoBuilderCopyBufferToBuffer) {
TEST_F(BuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxTranslationThenPickAndSetupCorrectKernels) {
BuiltinDispatchInfoBuilder &builder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
BuffersForAuxTranslation buffersForAuxTranslation;
MemObjsForAuxTranslation memObjsForAuxTranslation;
MultiDispatchInfo multiDispatchInfo;
std::vector<Kernel *> builtinKernels;
MockBuffer mockBuffer[3];
@@ -247,11 +247,11 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxTransla
mockBuffer[2].getGraphicsAllocation()->setSize(0x30000);
BuiltinDispatchInfoBuilder::BuiltinOpParams builtinOpsParams;
builtinOpsParams.buffersForAuxTranslation = &buffersForAuxTranslation;
builtinOpsParams.memObjsForAuxTranslation = &memObjsForAuxTranslation;
builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux;
for (auto &buffer : mockBuffer) {
buffersForAuxTranslation.insert(&buffer);
memObjsForAuxTranslation.insert(&buffer);
}
EXPECT_TRUE(builder.buildDispatchInfos(multiDispatchInfo, builtinOpsParams));
@@ -260,9 +260,9 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxTransla
for (auto &dispatchInfo : multiDispatchInfo) {
auto kernel = dispatchInfo.getKernel();
builtinKernels.push_back(kernel);
Buffer *buffer = *buffersForAuxTranslation.find(castToObject<Buffer>(kernel->getKernelArguments().at(0).object));
MemObj *buffer = *memObjsForAuxTranslation.find(castToObject<Buffer>(kernel->getKernelArguments().at(0).object));
EXPECT_NE(nullptr, buffer);
buffersForAuxTranslation.erase(buffer);
memObjsForAuxTranslation.erase(buffer);
cl_mem clMem = buffer;
void *gpuAddress = reinterpret_cast<void *>(buffer->getGraphicsAllocation()->getGpuAddress());
@@ -286,7 +286,7 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxTransla
TEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTranslationThenPickAndSetupCorrectKernels) {
BuiltinDispatchInfoBuilder &builder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
BuffersForAuxTranslation buffersForAuxTranslation;
MemObjsForAuxTranslation memObjsForAuxTranslation;
MultiDispatchInfo multiDispatchInfo;
std::vector<Kernel *> builtinKernels;
MockBuffer mockBuffer[3];
@@ -295,11 +295,11 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTranslatio
mockBuffer[2].getGraphicsAllocation()->setSize(0x30000);
BuiltinDispatchInfoBuilder::BuiltinOpParams builtinOpsParams;
builtinOpsParams.buffersForAuxTranslation = &buffersForAuxTranslation;
builtinOpsParams.memObjsForAuxTranslation = &memObjsForAuxTranslation;
builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::NonAuxToAux;
for (auto &buffer : mockBuffer) {
buffersForAuxTranslation.insert(&buffer);
memObjsForAuxTranslation.insert(&buffer);
}
EXPECT_TRUE(builder.buildDispatchInfos(multiDispatchInfo, builtinOpsParams));
@@ -308,9 +308,9 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTranslatio
for (auto &dispatchInfo : multiDispatchInfo) {
auto kernel = dispatchInfo.getKernel();
builtinKernels.push_back(kernel);
Buffer *buffer = *buffersForAuxTranslation.find(castToObject<Buffer>(kernel->getKernelArguments().at(1).object));
MemObj *buffer = *memObjsForAuxTranslation.find(castToObject<Buffer>(kernel->getKernelArguments().at(1).object));
EXPECT_NE(nullptr, buffer);
buffersForAuxTranslation.erase(buffer);
memObjsForAuxTranslation.erase(buffer);
cl_mem clMem = buffer;
void *gpuAddress = reinterpret_cast<void *>(buffer->getGraphicsAllocation()->getGpuAddress());
@@ -334,16 +334,16 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTranslatio
TEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxTranslationDispatchThenPickDifferentKernelsDependingOnRequest) {
BuiltinDispatchInfoBuilder &builder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
BuffersForAuxTranslation buffersForAuxTranslation;
MemObjsForAuxTranslation memObjsForAuxTranslation;
MockBuffer mockBuffer[3];
std::vector<Kernel *> builtinKernels;
MultiDispatchInfo multiDispatchInfo;
BuiltinDispatchInfoBuilder::BuiltinOpParams builtinOpsParams;
builtinOpsParams.buffersForAuxTranslation = &buffersForAuxTranslation;
builtinOpsParams.memObjsForAuxTranslation = &memObjsForAuxTranslation;
for (auto &buffer : mockBuffer) {
buffersForAuxTranslation.insert(&buffer);
memObjsForAuxTranslation.insert(&buffer);
}
builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux;
@@ -368,14 +368,14 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxTranslationDispatchThenPickD
TEST_F(BuiltInTests, givenInvalidAuxTranslationDirectionWhenBuildingDispatchInfosThenAbort) {
BuiltinDispatchInfoBuilder &builder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
BuffersForAuxTranslation buffersForAuxTranslation;
MemObjsForAuxTranslation memObjsForAuxTranslation;
MockBuffer mockBuffer;
MultiDispatchInfo multiDispatchInfo;
BuiltinDispatchInfoBuilder::BuiltinOpParams builtinOpsParams;
builtinOpsParams.buffersForAuxTranslation = &buffersForAuxTranslation;
builtinOpsParams.memObjsForAuxTranslation = &memObjsForAuxTranslation;
buffersForAuxTranslation.insert(&mockBuffer);
memObjsForAuxTranslation.insert(&mockBuffer);
builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::None;
EXPECT_THROW(builder.buildDispatchInfos(multiDispatchInfo, builtinOpsParams), std::exception);
@@ -406,16 +406,16 @@ HWTEST_F(BuiltInTests, givenMoreBuffersForAuxTranslationThanKernelInstancesWhenD
EXPECT_EQ(5u, mockAuxBuiltInOp.convertToAuxKernel.size());
EXPECT_EQ(5u, mockAuxBuiltInOp.convertToNonAuxKernel.size());
BuffersForAuxTranslation buffersForAuxTranslation;
MemObjsForAuxTranslation memObjsForAuxTranslation;
BuiltinDispatchInfoBuilder::BuiltinOpParams builtinOpsParams;
MultiDispatchInfo multiDispatchInfo;
MockBuffer mockBuffer[7];
builtinOpsParams.buffersForAuxTranslation = &buffersForAuxTranslation;
builtinOpsParams.memObjsForAuxTranslation = &memObjsForAuxTranslation;
builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux;
for (auto &buffer : mockBuffer) {
buffersForAuxTranslation.insert(&buffer);
memObjsForAuxTranslation.insert(&buffer);
}
EXPECT_TRUE(mockAuxBuiltInOp.buildDispatchInfos(multiDispatchInfo, builtinOpsParams));

View File

@@ -657,14 +657,14 @@ struct EnqueueAuxKernelTests : public EnqueueKernelTest {
class MyCmdQ : public CommandQueueHw<FamilyType> {
public:
MyCmdQ(Context *context, Device *device) : CommandQueueHw<FamilyType>(context, device, nullptr) {}
void dispatchAuxTranslation(MultiDispatchInfo &multiDispatchInfo, BuffersForAuxTranslation &buffersForAuxTranslation,
void dispatchAuxTranslation(MultiDispatchInfo &multiDispatchInfo, MemObjsForAuxTranslation &memObjsForAuxTranslation,
AuxTranslationDirection auxTranslationDirection) override {
CommandQueueHw<FamilyType>::dispatchAuxTranslation(multiDispatchInfo, buffersForAuxTranslation, auxTranslationDirection);
CommandQueueHw<FamilyType>::dispatchAuxTranslation(multiDispatchInfo, memObjsForAuxTranslation, auxTranslationDirection);
Kernel *lastKernel = nullptr;
for (const auto &dispatchInfo : multiDispatchInfo) {
lastKernel = dispatchInfo.getKernel();
}
dispatchAuxTranslationInputs.emplace_back(lastKernel, multiDispatchInfo.size(), buffersForAuxTranslation, auxTranslationDirection);
dispatchAuxTranslationInputs.emplace_back(lastKernel, multiDispatchInfo.size(), memObjsForAuxTranslation, auxTranslationDirection);
}
void waitUntilComplete(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep) override {
@@ -672,7 +672,7 @@ struct EnqueueAuxKernelTests : public EnqueueKernelTest {
CommandQueueHw<FamilyType>::waitUntilComplete(taskCountToWait, flushStampToWait, useQuickKmdSleep);
}
std::vector<std::tuple<Kernel *, size_t, BuffersForAuxTranslation, AuxTranslationDirection>> dispatchAuxTranslationInputs;
std::vector<std::tuple<Kernel *, size_t, MemObjsForAuxTranslation, AuxTranslationDirection>> dispatchAuxTranslationInputs;
uint32_t waitCalled = 0;
};
};
@@ -736,11 +736,11 @@ HWTEST_F(EnqueueAuxKernelTests, givenMultipleArgsWhenAuxTranslationIsRequiredThe
cmdQ.enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(2u, cmdQ.dispatchAuxTranslationInputs.size());
EXPECT_EQ(1u, std::get<BuffersForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(0)).size()); // before kernel
EXPECT_EQ(1u, std::get<BuffersForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(1)).size()); // after kernel
EXPECT_EQ(1u, std::get<MemObjsForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(0)).size()); // before kernel
EXPECT_EQ(1u, std::get<MemObjsForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(1)).size()); // after kernel
EXPECT_EQ(&buffer2, *std::get<BuffersForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(0)).begin());
EXPECT_EQ(&buffer2, *std::get<BuffersForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(1)).begin());
EXPECT_EQ(&buffer2, *std::get<MemObjsForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(0)).begin());
EXPECT_EQ(&buffer2, *std::get<MemObjsForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(1)).begin());
}
HWTEST_F(EnqueueAuxKernelTests, givenKernelWithRequiredAuxTranslationWhenEnqueuedThenDispatchAuxTranslationBuiltin) {
@@ -808,9 +808,9 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueAuxKernelTests, givenParentKernelWhenAuxTrans
cmdQ.enqueueKernel(parentKernel.get(), 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
EXPECT_EQ(1u, cmdQ.dispatchAuxTranslationInputs.size());
EXPECT_EQ(2u, std::get<BuffersForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(0)).size()); // before kernel
EXPECT_EQ(2u, std::get<MemObjsForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(0)).size()); // before kernel
auto &dispatchedBuffers = std::get<BuffersForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(0));
auto &dispatchedBuffers = std::get<MemObjsForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(0));
EXPECT_NE(dispatchedBuffers.end(), dispatchedBuffers.find(&buffer0));
EXPECT_EQ(dispatchedBuffers.end(), dispatchedBuffers.find(&buffer1));