2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-01-21 20:10:13 +08:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-20 11:54:29 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/mocks/mock_command_stream_receiver.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 22:20:22 +08:00
|
|
|
#include "opencl/test/unit_test/libult/ult_command_stream_receiver.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2018-03-14 18:07:51 +08:00
|
|
|
#include "gmock/gmock.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
class MockCsrBase : public UltCommandStreamReceiver<GfxFamily> {
|
|
|
|
public:
|
|
|
|
using BaseUltCsrClass = UltCommandStreamReceiver<GfxFamily>;
|
2019-02-27 17:06:14 +08:00
|
|
|
using BaseUltCsrClass::BaseUltCsrClass;
|
2021-02-06 22:38:55 +08:00
|
|
|
using BaseUltCsrClass::debugPauseStateLock;
|
2021-04-30 23:39:01 +08:00
|
|
|
using BaseUltCsrClass::preemptionAllocation;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
MockCsrBase() = delete;
|
|
|
|
|
2020-10-29 22:33:35 +08:00
|
|
|
MockCsrBase(int32_t &execStamp,
|
|
|
|
ExecutionEnvironment &executionEnvironment,
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
const DeviceBitfield deviceBitfield)
|
2020-10-28 23:08:37 +08:00
|
|
|
: BaseUltCsrClass(executionEnvironment, rootDeviceIndex, deviceBitfield), executionStamp(&execStamp), flushTaskStamp(-1) {
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void makeResident(GraphicsAllocation &gfxAllocation) override {
|
|
|
|
madeResidentGfxAllocations.push_back(&gfxAllocation);
|
|
|
|
if (this->getMemoryManager()) {
|
2018-09-12 15:47:01 +08:00
|
|
|
this->getResidencyAllocations().push_back(&gfxAllocation);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2018-12-03 17:05:36 +08:00
|
|
|
gfxAllocation.updateResidencyTaskCount(this->taskCount, this->osContext->getContextId());
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
void makeNonResident(GraphicsAllocation &gfxAllocation) override {
|
|
|
|
madeNonResidentGfxAllocations.push_back(&gfxAllocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t peekThreadArbitrationPolicy() { return this->requiredThreadArbitrationPolicy; }
|
|
|
|
|
|
|
|
bool isMadeResident(GraphicsAllocation *gfxAllocation) {
|
|
|
|
for (GraphicsAllocation *gfxAlloc : madeResidentGfxAllocations) {
|
|
|
|
if (gfxAlloc == gfxAllocation)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isMadeNonResident(GraphicsAllocation *gfxAllocation) {
|
|
|
|
for (GraphicsAllocation *gfxAlloc : madeNonResidentGfxAllocations) {
|
|
|
|
if (gfxAlloc == gfxAllocation)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool getGSBAFor32BitProgrammed() {
|
|
|
|
return this->GSBAFor32BitProgrammed;
|
|
|
|
}
|
|
|
|
|
2018-11-26 21:04:52 +08:00
|
|
|
void processEviction() override {
|
2017-12-21 07:45:38 +08:00
|
|
|
processEvictionCalled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResidencyContainer madeResidentGfxAllocations;
|
|
|
|
ResidencyContainer madeNonResidentGfxAllocations;
|
|
|
|
int32_t *executionStamp;
|
|
|
|
int32_t flushTaskStamp;
|
|
|
|
bool processEvictionCalled = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
using MockCsrHw = MockCsrBase<GfxFamily>;
|
|
|
|
|
2019-04-16 20:39:40 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
class MockCsrAub : public MockCsrBase<GfxFamily> {
|
|
|
|
public:
|
2020-10-29 22:33:35 +08:00
|
|
|
MockCsrAub(int32_t &execStamp,
|
|
|
|
ExecutionEnvironment &executionEnvironment,
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
const DeviceBitfield deviceBitfield)
|
2020-10-28 23:08:37 +08:00
|
|
|
: MockCsrBase<GfxFamily>(execStamp, executionEnvironment, rootDeviceIndex, deviceBitfield) {}
|
2019-04-16 20:39:40 +08:00
|
|
|
CommandStreamReceiverType getType() override {
|
|
|
|
return CommandStreamReceiverType::CSR_AUB;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
class MockCsr : public MockCsrBase<GfxFamily> {
|
|
|
|
public:
|
|
|
|
using BaseClass = MockCsrBase<GfxFamily>;
|
2017-12-20 20:24:19 +08:00
|
|
|
using CommandStreamReceiver::mediaVfeStateDirty;
|
2020-09-29 17:58:15 +08:00
|
|
|
using MockCsrBase<GfxFamily>::lastAdditionalKernelExecInfo;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
MockCsr() = delete;
|
|
|
|
MockCsr(const HardwareInfo &hwInfoIn) = delete;
|
2020-10-29 22:33:35 +08:00
|
|
|
MockCsr(int32_t &execStamp,
|
|
|
|
ExecutionEnvironment &executionEnvironment,
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
const DeviceBitfield deviceBitfield)
|
2020-10-28 23:08:37 +08:00
|
|
|
: BaseClass(execStamp, executionEnvironment, rootDeviceIndex, deviceBitfield) {
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2019-11-24 21:50:41 +08:00
|
|
|
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
|
|
|
|
return true;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CompletionStamp flushTask(
|
|
|
|
LinearStream &commandStream,
|
|
|
|
size_t commandStreamStart,
|
2018-04-17 19:50:50 +08:00
|
|
|
const IndirectHeap &dsh,
|
|
|
|
const IndirectHeap &ioh,
|
|
|
|
const IndirectHeap &ssh,
|
2017-12-21 07:45:38 +08:00
|
|
|
uint32_t taskLevel,
|
2018-08-01 16:01:41 +08:00
|
|
|
DispatchFlags &dispatchFlags,
|
|
|
|
Device &device) override {
|
2017-12-21 07:45:38 +08:00
|
|
|
this->flushTaskStamp = *this->executionStamp;
|
|
|
|
(*this->executionStamp)++;
|
|
|
|
slmUsedInLastFlushTask = dispatchFlags.useSLM;
|
|
|
|
this->latestSentTaskCount = ++this->taskCount;
|
|
|
|
lastTaskLevelToFlushTask = taskLevel;
|
|
|
|
|
|
|
|
return CommandStreamReceiverHw<GfxFamily>::flushTask(
|
|
|
|
commandStream,
|
|
|
|
commandStreamStart,
|
|
|
|
dsh,
|
|
|
|
ioh,
|
|
|
|
ssh,
|
|
|
|
taskLevel,
|
2018-08-01 16:01:41 +08:00
|
|
|
dispatchFlags,
|
|
|
|
device);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2017-12-20 20:24:19 +08:00
|
|
|
bool peekMediaVfeStateDirty() const { return mediaVfeStateDirty; }
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
bool slmUsedInLastFlushTask = false;
|
|
|
|
uint32_t lastTaskLevelToFlushTask = 0;
|
|
|
|
};
|
|
|
|
|
2018-04-04 17:34:46 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
class MockFlatBatchBufferHelper : public FlatBatchBufferHelperHw<GfxFamily> {
|
|
|
|
public:
|
2018-10-11 17:19:49 +08:00
|
|
|
using FlatBatchBufferHelperHw<GfxFamily>::FlatBatchBufferHelperHw;
|
2020-05-18 18:05:00 +08:00
|
|
|
MOCK_METHOD(bool, setPatchInfoData, (const PatchInfoData &), (override));
|
|
|
|
MOCK_METHOD(bool, removePatchInfoData, (uint64_t), (override));
|
|
|
|
MOCK_METHOD(bool, registerCommandChunk, (CommandChunk &), (override));
|
|
|
|
MOCK_METHOD(bool, registerBatchBufferStartAddress, (uint64_t, uint64_t), (override));
|
|
|
|
MOCK_METHOD(GraphicsAllocation *,
|
|
|
|
flattenBatchBuffer,
|
2020-07-08 16:47:28 +08:00
|
|
|
(uint32_t rootDeviceIndex, BatchBuffer &batchBuffer, size_t &sizeBatchBuffer, DispatchMode dispatchMode, DeviceBitfield deviceBitfield),
|
2020-05-18 18:05:00 +08:00
|
|
|
(override));
|
2018-04-04 17:34:46 +08:00
|
|
|
};
|