mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Collect patch info for scratch/global/constant/private
Related-To: NEO-3342 Change-Id: I0b594219cedf5d13d1eb70514816e8048938772e Signed-off-by: Pawel Wilma <pawel.wilma@intel.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/command_stream/linear_stream.h"
|
||||
#include "runtime/command_stream/preemption.h"
|
||||
#include "runtime/command_stream/scratch_space_controller.h"
|
||||
#include "runtime/event/user_event.h"
|
||||
#include "runtime/helpers/cache_policy.h"
|
||||
#include "runtime/helpers/preamble.h"
|
||||
@@ -253,3 +254,60 @@ HWTEST_F(CommandStreamReceiverFlushTaskGmockTests, givenMockCsrWhenCollectStateB
|
||||
EXPECT_EQ(gshPatch.sourceAllocation, generalStateBase);
|
||||
EXPECT_EQ(gshPatch.targetAllocationOffset, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::GENERALSTATEBASEADDRESS_BYTEOFFSET);
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskGmockTests, givenPatchInfoCollectionEnabledWhenScratchSpaceIsProgrammedThenPatchInfoIsCollected) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true);
|
||||
|
||||
CommandQueueHw<FamilyType> commandQueue(nullptr, pDevice, 0);
|
||||
auto &commandStream = commandQueue.getCS(4096u);
|
||||
|
||||
std::unique_ptr<MockCsrHw2<FamilyType>> mockCsr(new MockCsrHw2<FamilyType>(*pDevice->executionEnvironment));
|
||||
mockCsr->overwriteFlatBatchBufferHelper(new MockFlatBatchBufferHelper<FamilyType>(*pDevice->executionEnvironment));
|
||||
|
||||
bool stateBaseAddressDirty;
|
||||
bool vfeStateDirty;
|
||||
mockCsr->getScratchSpaceController()->setRequiredScratchSpace(nullptr, 10u, 0u, 1u, 0u, stateBaseAddressDirty, vfeStateDirty);
|
||||
|
||||
DispatchFlags flags;
|
||||
mockCsr->requiredScratchSize = 0x200000;
|
||||
|
||||
mockCsr->programVFEState(commandStream, flags, 10);
|
||||
ASSERT_EQ(1u, mockCsr->getFlatBatchBufferHelper().getPatchInfoCollection().size());
|
||||
EXPECT_EQ(mockCsr->getScratchSpaceController()->getScratchPatchAddress(), mockCsr->getFlatBatchBufferHelper().getPatchInfoCollection().at(0).sourceAllocation);
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskGmockTests, givenPatchInfoCollectionDisabledWhenScratchSpaceIsProgrammedThenPatchInfoIsNotCollected) {
|
||||
CommandQueueHw<FamilyType> commandQueue(nullptr, pDevice, 0);
|
||||
auto &commandStream = commandQueue.getCS(4096u);
|
||||
|
||||
std::unique_ptr<MockCsrHw2<FamilyType>> mockCsr(new MockCsrHw2<FamilyType>(*pDevice->executionEnvironment));
|
||||
mockCsr->overwriteFlatBatchBufferHelper(new MockFlatBatchBufferHelper<FamilyType>(*pDevice->executionEnvironment));
|
||||
|
||||
bool stateBaseAddressDirty;
|
||||
bool vfeStateDirty;
|
||||
mockCsr->getScratchSpaceController()->setRequiredScratchSpace(nullptr, 10u, 0u, 1u, 0u, stateBaseAddressDirty, vfeStateDirty);
|
||||
|
||||
DispatchFlags flags;
|
||||
mockCsr->requiredScratchSize = 0x200000;
|
||||
|
||||
mockCsr->programVFEState(commandStream, flags, 10);
|
||||
EXPECT_EQ(0u, mockCsr->getFlatBatchBufferHelper().getPatchInfoCollection().size());
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskGmockTests, givenPatchInfoCollectionEnabledWhenMediaVfeStateIsProgrammedWithEmptyScratchThenPatchInfoIsNotCollected) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true);
|
||||
|
||||
CommandQueueHw<FamilyType> commandQueue(nullptr, pDevice, 0);
|
||||
auto &commandStream = commandQueue.getCS(4096u);
|
||||
|
||||
std::unique_ptr<MockCsrHw2<FamilyType>> mockCsr(new MockCsrHw2<FamilyType>(*pDevice->executionEnvironment));
|
||||
mockCsr->overwriteFlatBatchBufferHelper(new MockFlatBatchBufferHelper<FamilyType>(*pDevice->executionEnvironment));
|
||||
|
||||
DispatchFlags flags;
|
||||
mockCsr->requiredScratchSize = 0x200000;
|
||||
|
||||
mockCsr->programVFEState(commandStream, flags, 10);
|
||||
EXPECT_EQ(0u, mockCsr->getFlatBatchBufferHelper().getPatchInfoCollection().size());
|
||||
}
|
||||
|
||||
@@ -2697,6 +2697,31 @@ TEST(KernelTest, givenKernelWithoutMediaVfeStateSlot1WhenGettingSizeForPrivateSc
|
||||
EXPECT_EQ(0u, mockKernel.mockKernel->getPrivateScratchSize());
|
||||
}
|
||||
|
||||
TEST(KernelTest, givenKernelWithPatchInfoCollectionEnabledWhenPatchWithImplicitSurfaceCalledThenPatchInfoDataIsCollected) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true);
|
||||
|
||||
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
|
||||
MockKernelWithInternals kernel(*device);
|
||||
MockGraphicsAllocation mockAllocation;
|
||||
SPatchAllocateStatelessGlobalMemorySurfaceWithInitialization patchToken{};
|
||||
uint64_t crossThreadData = 0;
|
||||
EXPECT_EQ(0u, kernel.mockKernel->getPatchInfoDataList().size());
|
||||
kernel.mockKernel->patchWithImplicitSurface(&crossThreadData, mockAllocation, patchToken);
|
||||
EXPECT_EQ(1u, kernel.mockKernel->getPatchInfoDataList().size());
|
||||
}
|
||||
|
||||
TEST(KernelTest, givenKernelWithPatchInfoCollectionDisabledWhenPatchWithImplicitSurfaceCalledThenPatchInfoDataIsNotCollected) {
|
||||
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
|
||||
MockKernelWithInternals kernel(*device);
|
||||
MockGraphicsAllocation mockAllocation;
|
||||
SPatchAllocateStatelessGlobalMemorySurfaceWithInitialization patchToken{};
|
||||
uint64_t crossThreadData = 0;
|
||||
EXPECT_EQ(0u, kernel.mockKernel->getPatchInfoDataList().size());
|
||||
kernel.mockKernel->patchWithImplicitSurface(&crossThreadData, mockAllocation, patchToken);
|
||||
EXPECT_EQ(0u, kernel.mockKernel->getPatchInfoDataList().size());
|
||||
}
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename GfxFamily>
|
||||
|
||||
@@ -157,12 +157,14 @@ class MockCsrHw2 : public CommandStreamReceiverHw<GfxFamily> {
|
||||
using CommandStreamReceiverHw<GfxFamily>::flushStamp;
|
||||
using CommandStreamReceiverHw<GfxFamily>::programL3;
|
||||
using CommandStreamReceiverHw<GfxFamily>::csrSizeRequestFlags;
|
||||
using CommandStreamReceiverHw<GfxFamily>::programVFEState;
|
||||
using CommandStreamReceiver::commandStream;
|
||||
using CommandStreamReceiver::dispatchMode;
|
||||
using CommandStreamReceiver::isPreambleSent;
|
||||
using CommandStreamReceiver::lastSentCoherencyRequest;
|
||||
using CommandStreamReceiver::mediaVfeStateDirty;
|
||||
using CommandStreamReceiver::nTo1SubmissionModelEnabled;
|
||||
using CommandStreamReceiver::requiredScratchSize;
|
||||
using CommandStreamReceiver::taskCount;
|
||||
using CommandStreamReceiver::taskLevel;
|
||||
using CommandStreamReceiver::timestampPacketWriteEnabled;
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "runtime/command_stream/preemption.h"
|
||||
#include "runtime/helpers/flat_batch_buffer_helper_hw.h"
|
||||
#include "runtime/helpers/preamble.h"
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
#include "test.h"
|
||||
@@ -187,3 +189,15 @@ HWTEST_F(PreambleTest, givenDefaultPreambleWhenGetThreadsMaxNumberIsCalledThenMa
|
||||
uint32_t expected = hwInfo.gtSystemInfo.EUCount * threadsPerEU;
|
||||
EXPECT_EQ(expected, value);
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_GEN8_CORE, PreambleTest, givenPreambleHelperWhenMediaVfeStateIsProgrammedThenOffsetToCommandIsReturned) {
|
||||
char buffer[64];
|
||||
MockGraphicsAllocation graphicsAllocation(buffer, sizeof(buffer));
|
||||
LinearStream preambleStream(&graphicsAllocation, graphicsAllocation.getUnderlyingBuffer(), graphicsAllocation.getUnderlyingBufferSize());
|
||||
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
FlatBatchBufferHelperHw<FamilyType> helper(*mockDevice->getExecutionEnvironment());
|
||||
uint64_t addressToPatch = 0xC0DEC0DE;
|
||||
|
||||
auto offset = PreambleHelper<FamilyType>::programVFEState(&preambleStream, mockDevice->getHardwareInfo(), 1024u, addressToPatch, 10u);
|
||||
EXPECT_NE(0u, offset);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user