mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Introduce RegisteredMethodDispatcher.
- Inject dispatch methods per DispatchInfo - Each DispatchInfo in MultiDispatchInfo can have different behaviour - Implement AuxTranslation programming with new approach Change-Id: Ie28de0c72a77b8e91509a5b9b8740d72fedf4ad6 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
a72109d209
commit
ddb0d82e83
@@ -246,8 +246,9 @@ TEST_F(BuiltInTests, BuiltinDispatchInfoBuilderCopyBufferToBuffer) {
|
||||
delete dstPtr;
|
||||
}
|
||||
|
||||
TEST_F(BuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxTranslationThenPickAndSetupCorrectKernels) {
|
||||
BuiltinDispatchInfoBuilder &builder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
|
||||
HWTEST_F(BuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxTranslationThenPickAndSetupCorrectKernels) {
|
||||
BuiltinDispatchInfoBuilder &baseBuilder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
|
||||
auto &builder = static_cast<BuiltInOp<EBuiltInOps::AuxTranslation> &>(baseBuilder);
|
||||
|
||||
MemObjsForAuxTranslation memObjsForAuxTranslation;
|
||||
MultiDispatchInfo multiDispatchInfo;
|
||||
@@ -265,7 +266,7 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxTransla
|
||||
memObjsForAuxTranslation.insert(&buffer);
|
||||
}
|
||||
|
||||
EXPECT_TRUE(builder.buildDispatchInfos(multiDispatchInfo, builtinOpsParams));
|
||||
EXPECT_TRUE(builder.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpsParams));
|
||||
EXPECT_EQ(3u, multiDispatchInfo.size());
|
||||
|
||||
for (auto &dispatchInfo : multiDispatchInfo) {
|
||||
@@ -294,8 +295,9 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingNonAuxDispatchInfoForAuxTransla
|
||||
EXPECT_NE(builtinKernels[1], builtinKernels[2]);
|
||||
}
|
||||
|
||||
TEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTranslationThenPickAndSetupCorrectKernels) {
|
||||
BuiltinDispatchInfoBuilder &builder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
|
||||
HWTEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTranslationThenPickAndSetupCorrectKernels) {
|
||||
BuiltinDispatchInfoBuilder &baseBuilder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
|
||||
auto &builder = static_cast<BuiltInOp<EBuiltInOps::AuxTranslation> &>(baseBuilder);
|
||||
|
||||
MemObjsForAuxTranslation memObjsForAuxTranslation;
|
||||
MultiDispatchInfo multiDispatchInfo;
|
||||
@@ -313,7 +315,7 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTranslatio
|
||||
memObjsForAuxTranslation.insert(&buffer);
|
||||
}
|
||||
|
||||
EXPECT_TRUE(builder.buildDispatchInfos(multiDispatchInfo, builtinOpsParams));
|
||||
EXPECT_TRUE(builder.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpsParams));
|
||||
EXPECT_EQ(3u, multiDispatchInfo.size());
|
||||
|
||||
for (auto &dispatchInfo : multiDispatchInfo) {
|
||||
@@ -342,8 +344,9 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxDispatchInfoForAuxTranslatio
|
||||
EXPECT_NE(builtinKernels[1], builtinKernels[2]);
|
||||
}
|
||||
|
||||
TEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxTranslationDispatchThenPickDifferentKernelsDependingOnRequest) {
|
||||
BuiltinDispatchInfoBuilder &builder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
|
||||
HWTEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxTranslationDispatchThenPickDifferentKernelsDependingOnRequest) {
|
||||
BuiltinDispatchInfoBuilder &baseBuilder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
|
||||
auto &builder = static_cast<BuiltInOp<EBuiltInOps::AuxTranslation> &>(baseBuilder);
|
||||
|
||||
MemObjsForAuxTranslation memObjsForAuxTranslation;
|
||||
MockBuffer mockBuffer[3];
|
||||
@@ -358,10 +361,10 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxTranslationDispatchThenPickD
|
||||
}
|
||||
|
||||
builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux;
|
||||
EXPECT_TRUE(builder.buildDispatchInfos(multiDispatchInfo, builtinOpsParams));
|
||||
EXPECT_TRUE(builder.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpsParams));
|
||||
|
||||
builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::NonAuxToAux;
|
||||
EXPECT_TRUE(builder.buildDispatchInfos(multiDispatchInfo, builtinOpsParams));
|
||||
EXPECT_TRUE(builder.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpsParams));
|
||||
|
||||
EXPECT_EQ(6u, multiDispatchInfo.size());
|
||||
|
||||
@@ -376,8 +379,9 @@ TEST_F(BuiltInTests, givenInputBufferWhenBuildingAuxTranslationDispatchThenPickD
|
||||
EXPECT_NE(builtinKernels[2], builtinKernels[5]);
|
||||
}
|
||||
|
||||
TEST_F(BuiltInTests, givenInvalidAuxTranslationDirectionWhenBuildingDispatchInfosThenAbort) {
|
||||
BuiltinDispatchInfoBuilder &builder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
|
||||
HWTEST_F(BuiltInTests, givenInvalidAuxTranslationDirectionWhenBuildingDispatchInfosThenAbort) {
|
||||
BuiltinDispatchInfoBuilder &baseBuilder = pBuiltIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, *pContext, *pDevice);
|
||||
auto &builder = static_cast<BuiltInOp<EBuiltInOps::AuxTranslation> &>(baseBuilder);
|
||||
|
||||
MemObjsForAuxTranslation memObjsForAuxTranslation;
|
||||
MockBuffer mockBuffer;
|
||||
@@ -389,7 +393,7 @@ TEST_F(BuiltInTests, givenInvalidAuxTranslationDirectionWhenBuildingDispatchInfo
|
||||
memObjsForAuxTranslation.insert(&mockBuffer);
|
||||
|
||||
builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::None;
|
||||
EXPECT_THROW(builder.buildDispatchInfos(multiDispatchInfo, builtinOpsParams), std::exception);
|
||||
EXPECT_THROW(builder.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpsParams), std::exception);
|
||||
}
|
||||
|
||||
class MockAuxBuilInOp : public BuiltInOp<EBuiltInOps::AuxTranslation> {
|
||||
@@ -411,7 +415,7 @@ TEST_F(BuiltInTests, whenAuxBuiltInIsConstructedThenResizeKernelInstancedTo5) {
|
||||
EXPECT_EQ(5u, mockAuxBuiltInOp.convertToNonAuxKernel.size());
|
||||
}
|
||||
|
||||
TEST_F(BuiltInTests, givenMoreBuffersForAuxTranslationThanKernelInstancesWhenDispatchingThenResize) {
|
||||
HWTEST_F(BuiltInTests, givenMoreBuffersForAuxTranslationThanKernelInstancesWhenDispatchingThenResize) {
|
||||
MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pContext, *pDevice);
|
||||
EXPECT_EQ(5u, mockAuxBuiltInOp.convertToAuxKernel.size());
|
||||
EXPECT_EQ(5u, mockAuxBuiltInOp.convertToNonAuxKernel.size());
|
||||
@@ -428,7 +432,7 @@ TEST_F(BuiltInTests, givenMoreBuffersForAuxTranslationThanKernelInstancesWhenDis
|
||||
memObjsForAuxTranslation.insert(&buffer);
|
||||
}
|
||||
|
||||
EXPECT_TRUE(mockAuxBuiltInOp.buildDispatchInfos(multiDispatchInfo, builtinOpsParams));
|
||||
EXPECT_TRUE(mockAuxBuiltInOp.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpsParams));
|
||||
EXPECT_EQ(7u, mockAuxBuiltInOp.convertToAuxKernel.size());
|
||||
EXPECT_EQ(7u, mockAuxBuiltInOp.convertToNonAuxKernel.size());
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/built_ins/aux_translation_builtin.h"
|
||||
#include "runtime/command_queue/gpgpu_walker.h"
|
||||
#include "runtime/command_queue/hardware_interface.h"
|
||||
#include "runtime/event/perf_counter.h"
|
||||
@@ -18,6 +19,7 @@
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/helpers/hw_parse.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_command_queue.h"
|
||||
#include "unit_tests/mocks/mock_graphics_allocation.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
@@ -1266,7 +1268,13 @@ TEST(DispatchWalker, calculateDispatchDim) {
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(DispatchWalkerTest, givenKernelWhenAuxTranslationRequiredThenPipeControlWithStallAndDCFlushAdded) {
|
||||
HWTEST_F(DispatchWalkerTest, givenKernelWhenAuxToNonAuxWhenTranslationRequiredThenPipeControlWithStallAndDCFlushAdded) {
|
||||
MockContext context;
|
||||
auto executionEnvironment = pDevice->getExecutionEnvironment();
|
||||
auto builtIns = executionEnvironment->getBuiltIns();
|
||||
BuiltinDispatchInfoBuilder &baseBuilder = builtIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, context, *pDevice);
|
||||
auto &builder = static_cast<BuiltInOp<EBuiltInOps::AuxTranslation> &>(baseBuilder);
|
||||
|
||||
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
||||
kernelInfo.workloadInfo.workDimOffset = 0;
|
||||
ASSERT_EQ(CL_SUCCESS, kernel.initialize());
|
||||
@@ -1274,11 +1282,18 @@ HWTEST_F(DispatchWalkerTest, givenKernelWhenAuxTranslationRequiredThenPipeContro
|
||||
auto &cmdStream = pCmdQ->getCS(0);
|
||||
void *buffer = cmdStream.getCpuBase();
|
||||
kernel.auxTranslationRequired = true;
|
||||
MockBuffer mockBuffer[2];
|
||||
|
||||
MockMultiDispatchInfo multiDispatchInfo(&kernel);
|
||||
DispatchInfo di1(&kernel, 1, Vec3<size_t>(1, 1, 1), Vec3<size_t>(1, 1, 1), Vec3<size_t>(0, 0, 0));
|
||||
di1.setPipeControlRequired(true);
|
||||
multiDispatchInfo.push(di1);
|
||||
MultiDispatchInfo multiDispatchInfo;
|
||||
MemObjsForAuxTranslation memObjsForAuxTranslation;
|
||||
memObjsForAuxTranslation.insert(&mockBuffer[0]);
|
||||
memObjsForAuxTranslation.insert(&mockBuffer[1]);
|
||||
|
||||
BuiltinOpParams builtinOpsParams;
|
||||
builtinOpsParams.memObjsForAuxTranslation = &memObjsForAuxTranslation;
|
||||
builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::AuxToNonAux;
|
||||
|
||||
builder.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpsParams);
|
||||
|
||||
HardwareInterface<FamilyType>::dispatchWalker(
|
||||
*pCmdQ,
|
||||
@@ -1305,7 +1320,66 @@ HWTEST_F(DispatchWalkerTest, givenKernelWhenAuxTranslationRequiredThenPipeContro
|
||||
EXPECT_TRUE(beginPipeControl->getCommandStreamerStallEnable());
|
||||
|
||||
auto endPipeControl = genCmdCast<typename FamilyType::PIPE_CONTROL *>(*(pipeControls[1]));
|
||||
EXPECT_FALSE(endPipeControl->getDcFlushEnable());
|
||||
bool dcFlushRequired = (executionEnvironment->getHardwareInfo()->platform.eRenderCoreFamily == IGFX_GEN8_CORE);
|
||||
EXPECT_EQ(dcFlushRequired, endPipeControl->getDcFlushEnable());
|
||||
EXPECT_TRUE(endPipeControl->getCommandStreamerStallEnable());
|
||||
}
|
||||
|
||||
HWTEST_F(DispatchWalkerTest, givenKernelWhenNonAuxToAuxWhenTranslationRequiredThenPipeControlWithStallAdded) {
|
||||
MockContext context;
|
||||
auto executionEnvironment = pDevice->getExecutionEnvironment();
|
||||
auto builtIns = executionEnvironment->getBuiltIns();
|
||||
BuiltinDispatchInfoBuilder &baseBuilder = builtIns->getBuiltinDispatchInfoBuilder(EBuiltInOps::AuxTranslation, context, *pDevice);
|
||||
auto &builder = static_cast<BuiltInOp<EBuiltInOps::AuxTranslation> &>(baseBuilder);
|
||||
|
||||
MockKernel kernel(program.get(), kernelInfo, *pDevice);
|
||||
kernelInfo.workloadInfo.workDimOffset = 0;
|
||||
ASSERT_EQ(CL_SUCCESS, kernel.initialize());
|
||||
|
||||
auto &cmdStream = pCmdQ->getCS(0);
|
||||
void *buffer = cmdStream.getCpuBase();
|
||||
kernel.auxTranslationRequired = true;
|
||||
MockBuffer mockBuffer[2];
|
||||
|
||||
MultiDispatchInfo multiDispatchInfo;
|
||||
MemObjsForAuxTranslation memObjsForAuxTranslation;
|
||||
memObjsForAuxTranslation.insert(&mockBuffer[0]);
|
||||
memObjsForAuxTranslation.insert(&mockBuffer[1]);
|
||||
|
||||
BuiltinOpParams builtinOpsParams;
|
||||
builtinOpsParams.memObjsForAuxTranslation = &memObjsForAuxTranslation;
|
||||
builtinOpsParams.auxTranslationDirection = AuxTranslationDirection::NonAuxToAux;
|
||||
|
||||
builder.buildDispatchInfosForAuxTranslation<FamilyType>(multiDispatchInfo, builtinOpsParams);
|
||||
|
||||
HardwareInterface<FamilyType>::dispatchWalker(
|
||||
*pCmdQ,
|
||||
multiDispatchInfo,
|
||||
CsrDependencies(),
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
pDevice->getPreemptionMode(),
|
||||
false);
|
||||
|
||||
auto sizeUsed = cmdStream.getUsed();
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(cmdList, buffer, sizeUsed));
|
||||
|
||||
auto pipeControls = findAll<typename FamilyType::PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
|
||||
ASSERT_EQ(2u, pipeControls.size());
|
||||
|
||||
bool dcFlushRequired = (executionEnvironment->getHardwareInfo()->platform.eRenderCoreFamily == IGFX_GEN8_CORE);
|
||||
|
||||
auto beginPipeControl = genCmdCast<typename FamilyType::PIPE_CONTROL *>(*(pipeControls[0]));
|
||||
EXPECT_EQ(dcFlushRequired, beginPipeControl->getDcFlushEnable());
|
||||
EXPECT_TRUE(beginPipeControl->getCommandStreamerStallEnable());
|
||||
|
||||
auto endPipeControl = genCmdCast<typename FamilyType::PIPE_CONTROL *>(*(pipeControls[1]));
|
||||
EXPECT_EQ(dcFlushRequired, endPipeControl->getDcFlushEnable());
|
||||
EXPECT_TRUE(endPipeControl->getCommandStreamerStallEnable());
|
||||
}
|
||||
|
||||
|
||||
@@ -655,6 +655,7 @@ struct EnqueueAuxKernelTests : public EnqueueKernelTest {
|
||||
template <typename FamilyType>
|
||||
class MyCmdQ : public CommandQueueHw<FamilyType> {
|
||||
public:
|
||||
using CommandQueueHw<FamilyType>::commandStream;
|
||||
MyCmdQ(Context *context, Device *device) : CommandQueueHw<FamilyType>(context, device, nullptr) {}
|
||||
void dispatchAuxTranslation(MultiDispatchInfo &multiDispatchInfo, MemObjsForAuxTranslation &memObjsForAuxTranslation,
|
||||
AuxTranslationDirection auxTranslationDirection) override {
|
||||
@@ -733,14 +734,19 @@ HWTEST_F(EnqueueAuxKernelTests, givenMultipleArgsWhenAuxTranslationIsRequiredThe
|
||||
|
||||
EXPECT_EQ(&buffer2, *std::get<MemObjsForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(0)).begin());
|
||||
EXPECT_EQ(&buffer2, *std::get<MemObjsForAuxTranslation>(cmdQ.dispatchAuxTranslationInputs.at(1)).begin());
|
||||
uint32_t pipeControlCount = 0;
|
||||
for (auto dispatchInfo : cmdQ.dispatchInfos) {
|
||||
if (dispatchInfo.isPipeControlRequired()) {
|
||||
++pipeControlCount;
|
||||
}
|
||||
}
|
||||
|
||||
EXPECT_EQ(4u, pipeControlCount);
|
||||
auto cmdStream = cmdQ.commandStream;
|
||||
auto sizeUsed = cmdStream->getUsed();
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(cmdList, cmdStream->getCpuBase(), sizeUsed));
|
||||
|
||||
auto pipeControls = findAll<typename FamilyType::PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
|
||||
|
||||
auto additionalPcCount = PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation() / sizeof(typename FamilyType::PIPE_CONTROL);
|
||||
|
||||
// |AuxToNonAux|NDR|NonAuxToAux|
|
||||
ASSERT_EQ(4u + additionalPcCount, pipeControls.size());
|
||||
|
||||
ASSERT_EQ(2u, cmdQ.auxTranslationDirections.size());
|
||||
EXPECT_EQ(AuxTranslationDirection::AuxToNonAux, cmdQ.auxTranslationDirections[0]);
|
||||
EXPECT_EQ(AuxTranslationDirection::NonAuxToAux, cmdQ.auxTranslationDirections[1]);
|
||||
|
||||
Reference in New Issue
Block a user