mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Move non-ult shared files to single directory
Add SKIP_SHARED_UNIT_TESTS flag Related-To: NEO-5201 Signed-off-by: Pawel Cieslak <pawel.cieslak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
1a0b7dc393
commit
8a700c5187
@@ -1,41 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2020-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(NEO_CORE_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_bindless_heaps_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_stream_receiver.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_stream_receiver.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_compiler_interface_spirv.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_compiler_interface_spirv.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_direct_submission_hw.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_direct_submission_diagnostic_collector.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_dispatch_kernel_encoder_interface.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_dispatch_kernel_encoder_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_debugger.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_device.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_device.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_elf.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_graphics_allocation.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_os_library.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sip.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sip.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ult_device_factory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ult_device_factory.h
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND NEO_CORE_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_wddm_direct_submission.h
|
||||
)
|
||||
else()
|
||||
list(APPEND NEO_CORE_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/mock_drm_memory_manager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/mock_drm_memory_manager.h
|
||||
)
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_tests_mocks ${NEO_CORE_tests_mocks})
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/unit_test/mocks/linux/mock_drm_memory_manager.h"
|
||||
|
||||
#include "shared/source/os_interface/linux/allocator_helper.h"
|
||||
#include "shared/source/os_interface/linux/drm_memory_manager.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_host_ptr_manager.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace NEO {
|
||||
off_t lseekReturn = 4096u;
|
||||
std::atomic<int> lseekCalledCount(0);
|
||||
int closeInputFd = 0;
|
||||
std::atomic<int> closeCalledCount(0);
|
||||
StackVec<void *, 10> mmapVector;
|
||||
|
||||
TestedDrmMemoryManager::TestedDrmMemoryManager(ExecutionEnvironment &executionEnvironment) : MemoryManagerCreate(gemCloseWorkerMode::gemCloseWorkerInactive,
|
||||
false,
|
||||
false,
|
||||
executionEnvironment) {
|
||||
this->mmapFunction = &mmapMock;
|
||||
this->munmapFunction = &munmapMock;
|
||||
this->lseekFunction = &lseekMock;
|
||||
this->closeFunction = &closeMock;
|
||||
lseekReturn = 4096;
|
||||
lseekCalledCount = 0;
|
||||
closeInputFd = 0;
|
||||
closeCalledCount = 0;
|
||||
hostPtrManager.reset(new MockHostPtrManager);
|
||||
};
|
||||
|
||||
TestedDrmMemoryManager::TestedDrmMemoryManager(bool enableLocalMemory,
|
||||
bool allowForcePin,
|
||||
bool validateHostPtrMemory,
|
||||
ExecutionEnvironment &executionEnvironment) : MemoryManagerCreate(false, enableLocalMemory,
|
||||
gemCloseWorkerMode::gemCloseWorkerInactive,
|
||||
allowForcePin,
|
||||
validateHostPtrMemory,
|
||||
executionEnvironment) {
|
||||
this->mmapFunction = &mmapMock;
|
||||
this->munmapFunction = &munmapMock;
|
||||
this->lseekFunction = &lseekMock;
|
||||
this->closeFunction = &closeMock;
|
||||
lseekReturn = 4096;
|
||||
lseekCalledCount = 0;
|
||||
closeInputFd = 0;
|
||||
closeCalledCount = 0;
|
||||
}
|
||||
|
||||
void TestedDrmMemoryManager::injectPinBB(BufferObject *newPinBB, uint32_t rootDeviceIndex) {
|
||||
BufferObject *currentPinBB = pinBBs[rootDeviceIndex];
|
||||
pinBBs[rootDeviceIndex] = nullptr;
|
||||
DrmMemoryManager::unreference(currentPinBB, true);
|
||||
pinBBs[rootDeviceIndex] = newPinBB;
|
||||
}
|
||||
|
||||
DrmGemCloseWorker *TestedDrmMemoryManager::getgemCloseWorker() { return this->gemCloseWorker.get(); }
|
||||
void TestedDrmMemoryManager::forceLimitedRangeAllocator(uint64_t range) {
|
||||
for (auto &gfxPartition : gfxPartitions) {
|
||||
gfxPartition->init(range, getSizeToReserve(), 0, 1);
|
||||
}
|
||||
}
|
||||
void TestedDrmMemoryManager::overrideGfxPartition(GfxPartition *newGfxPartition) { gfxPartitions[0].reset(newGfxPartition); }
|
||||
|
||||
DrmAllocation *TestedDrmMemoryManager::allocate32BitGraphicsMemory(uint32_t rootDeviceIndex, size_t size, const void *ptr, GraphicsAllocation::AllocationType allocationType) {
|
||||
bool allocateMemory = ptr == nullptr;
|
||||
AllocationData allocationData;
|
||||
MockAllocationProperties properties(rootDeviceIndex, allocateMemory, size, allocationType);
|
||||
getAllocationData(allocationData, properties, ptr, createStorageInfoFromProperties(properties));
|
||||
bool useLocalMemory = !allocationData.flags.useSystemMemory && this->localMemorySupported[rootDeviceIndex];
|
||||
return allocate32BitGraphicsMemoryImpl(allocationData, useLocalMemory);
|
||||
}
|
||||
TestedDrmMemoryManager::~TestedDrmMemoryManager() {
|
||||
DrmMemoryManager::commonCleanup();
|
||||
}
|
||||
}; // namespace NEO
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/os_interface/linux/drm_memory_manager.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace NEO {
|
||||
extern off_t lseekReturn;
|
||||
extern std::atomic<int> lseekCalledCount;
|
||||
extern int closeInputFd;
|
||||
extern std::atomic<int> closeCalledCount;
|
||||
extern StackVec<void *, 10> mmapVector;
|
||||
|
||||
inline void *mmapMock(void *addr, size_t length, int prot, int flags, int fd, off_t offset) noexcept {
|
||||
if (addr) {
|
||||
return addr;
|
||||
}
|
||||
void *ptr = nullptr;
|
||||
if (length > 0) {
|
||||
ptr = alignedMalloc(length, MemoryConstants::pageSize64k);
|
||||
mmapVector.push_back(ptr);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
inline int munmapMock(void *addr, size_t length) noexcept {
|
||||
if (length > 0) {
|
||||
auto ptrIt = std::find(mmapVector.begin(), mmapVector.end(), addr);
|
||||
if (ptrIt != mmapVector.end()) {
|
||||
alignedFree(addr);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline off_t lseekMock(int fd, off_t offset, int whence) noexcept {
|
||||
lseekCalledCount++;
|
||||
if ((fd == closeInputFd) && (closeCalledCount > 0)) {
|
||||
return 0;
|
||||
}
|
||||
return lseekReturn;
|
||||
}
|
||||
inline int closeMock(int fd) {
|
||||
closeInputFd = fd;
|
||||
closeCalledCount++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
class ExecutionEnvironment;
|
||||
class BufferObject;
|
||||
class DrmGemCloseWorker;
|
||||
|
||||
class TestedDrmMemoryManager : public MemoryManagerCreate<DrmMemoryManager> {
|
||||
public:
|
||||
using DrmMemoryManager::acquireGpuRange;
|
||||
using DrmMemoryManager::allocateGraphicsMemory;
|
||||
using DrmMemoryManager::allocateGraphicsMemory64kb;
|
||||
using DrmMemoryManager::allocateGraphicsMemoryForImage;
|
||||
using DrmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr;
|
||||
using DrmMemoryManager::allocateGraphicsMemoryWithAlignment;
|
||||
using DrmMemoryManager::allocateGraphicsMemoryWithHostPtr;
|
||||
using DrmMemoryManager::allocateShareableMemory;
|
||||
using DrmMemoryManager::allocUserptr;
|
||||
using DrmMemoryManager::createAllocWithAlignment;
|
||||
using DrmMemoryManager::createGraphicsAllocation;
|
||||
using DrmMemoryManager::createSharedBufferObject;
|
||||
using DrmMemoryManager::eraseSharedBufferObject;
|
||||
using DrmMemoryManager::getDefaultDrmContextId;
|
||||
using DrmMemoryManager::getDrm;
|
||||
using DrmMemoryManager::getRootDeviceIndex;
|
||||
using DrmMemoryManager::getUserptrAlignment;
|
||||
using DrmMemoryManager::gfxPartitions;
|
||||
using DrmMemoryManager::lockResourceInLocalMemoryImpl;
|
||||
using DrmMemoryManager::memoryForPinBBs;
|
||||
using DrmMemoryManager::mmapFunction;
|
||||
using DrmMemoryManager::munmapFunction;
|
||||
using DrmMemoryManager::pinBBs;
|
||||
using DrmMemoryManager::pinThreshold;
|
||||
using DrmMemoryManager::pushSharedBufferObject;
|
||||
using DrmMemoryManager::registerAllocationInOs;
|
||||
using DrmMemoryManager::releaseGpuRange;
|
||||
using DrmMemoryManager::setDomainCpu;
|
||||
using DrmMemoryManager::sharingBufferObjects;
|
||||
using DrmMemoryManager::supportsMultiStorageResources;
|
||||
using DrmMemoryManager::unlockResourceInLocalMemoryImpl;
|
||||
using MemoryManager::allocateGraphicsMemoryInDevicePool;
|
||||
using MemoryManager::heapAssigner;
|
||||
using MemoryManager::registeredEngines;
|
||||
|
||||
TestedDrmMemoryManager(ExecutionEnvironment &executionEnvironment);
|
||||
TestedDrmMemoryManager(bool enableLocalMemory,
|
||||
bool allowForcePin,
|
||||
bool validateHostPtrMemory,
|
||||
ExecutionEnvironment &executionEnvironment);
|
||||
void injectPinBB(BufferObject *newPinBB, uint32_t rootDeviceIndex);
|
||||
|
||||
DrmGemCloseWorker *getgemCloseWorker();
|
||||
void forceLimitedRangeAllocator(uint64_t range);
|
||||
void overrideGfxPartition(GfxPartition *newGfxPartition);
|
||||
|
||||
DrmAllocation *allocate32BitGraphicsMemory(uint32_t rootDeviceIndex, size_t size, const void *ptr, GraphicsAllocation::AllocationType allocationType);
|
||||
~TestedDrmMemoryManager() override;
|
||||
size_t peekSharedBosSize() {
|
||||
size_t size = 0;
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
size = sharingBufferObjects.size();
|
||||
return size;
|
||||
}
|
||||
};
|
||||
} // namespace NEO
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/bindless_heaps_helper.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
class MockBindlesHeapsHelper : public BindlessHeapsHelper {
|
||||
public:
|
||||
using BaseClass = BindlessHeapsHelper;
|
||||
MockBindlesHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex) : BaseClass(memManager, isMultiOsContextCapable, rootDeviceIndex) {
|
||||
globalSsh = surfaceStateHeaps[BindlesHeapType::GLOBAL_SSH].get();
|
||||
specialSsh = surfaceStateHeaps[BindlesHeapType::SPECIAL_SSH].get();
|
||||
scratchSsh = surfaceStateHeaps[BindlesHeapType::SPECIAL_SSH].get();
|
||||
globalDsh = surfaceStateHeaps[BindlesHeapType::SPECIAL_SSH].get();
|
||||
}
|
||||
using BindlesHeapType = BindlessHeapsHelper::BindlesHeapType;
|
||||
using BaseClass::borderColorStates;
|
||||
using BaseClass::growHeap;
|
||||
using BaseClass::isMultiOsContextCapable;
|
||||
using BaseClass::memManager;
|
||||
using BaseClass::rootDeviceIndex;
|
||||
using BaseClass::ssHeapsAllocations;
|
||||
using BaseClass::surfaceStateHeaps;
|
||||
using BaseClass::surfaceStateInHeapAllocationMap;
|
||||
using BaseClass::surfaceStateInHeapVectorReuse;
|
||||
|
||||
IndirectHeap *specialSsh;
|
||||
IndirectHeap *globalSsh;
|
||||
IndirectHeap *scratchSsh;
|
||||
IndirectHeap *globalDsh;
|
||||
};
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/unit_test/mocks/mock_command_stream_receiver.h"
|
||||
|
||||
bool MockCommandStreamReceiver::flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CompletionStamp MockCommandStreamReceiver::flushTask(
|
||||
LinearStream &commandStream,
|
||||
size_t commandStreamStart,
|
||||
const IndirectHeap &dsh,
|
||||
const IndirectHeap &ioh,
|
||||
const IndirectHeap &ssh,
|
||||
uint32_t taskLevel,
|
||||
DispatchFlags &dispatchFlags,
|
||||
Device &device) {
|
||||
++taskCount;
|
||||
CompletionStamp stamp = {taskCount, taskLevel, flushStamp->peekStamp()};
|
||||
return stamp;
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/command_stream/command_stream_receiver_hw.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/helpers/flat_batch_buffer_helper_hw.h"
|
||||
#include "shared/source/helpers/flush_stamp.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
#include "shared/test/unit_test/helpers/dispatch_flags_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
class MockCommandStreamReceiver : public CommandStreamReceiver {
|
||||
public:
|
||||
using CommandStreamReceiver::checkForNewResources;
|
||||
using CommandStreamReceiver::checkImplicitFlushForGpuIdle;
|
||||
using CommandStreamReceiver::CommandStreamReceiver;
|
||||
using CommandStreamReceiver::globalFenceAllocation;
|
||||
using CommandStreamReceiver::internalAllocationStorage;
|
||||
using CommandStreamReceiver::latestFlushedTaskCount;
|
||||
using CommandStreamReceiver::latestSentTaskCount;
|
||||
using CommandStreamReceiver::newResources;
|
||||
using CommandStreamReceiver::requiredThreadArbitrationPolicy;
|
||||
using CommandStreamReceiver::tagAddress;
|
||||
using CommandStreamReceiver::taskCount;
|
||||
using CommandStreamReceiver::useGpuIdleImplicitFlush;
|
||||
using CommandStreamReceiver::useNewResourceImplicitFlush;
|
||||
|
||||
bool waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait) override {
|
||||
waitForCompletionWithTimeoutCalled++;
|
||||
return true;
|
||||
}
|
||||
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
|
||||
|
||||
bool isMultiOsContextCapable() const override { return multiOsContextCapable; }
|
||||
|
||||
MemoryCompressionState getMemoryCompressionState(bool auxTranslationRequired) const override {
|
||||
return MemoryCompressionState::NotApplicable;
|
||||
};
|
||||
|
||||
CompletionStamp flushTask(
|
||||
LinearStream &commandStream,
|
||||
size_t commandStreamStart,
|
||||
const IndirectHeap &dsh,
|
||||
const IndirectHeap &ioh,
|
||||
const IndirectHeap &ssh,
|
||||
uint32_t taskLevel,
|
||||
DispatchFlags &dispatchFlags,
|
||||
Device &device) override;
|
||||
|
||||
bool flushBatchedSubmissions() override {
|
||||
if (flushBatchedSubmissionsCallCounter) {
|
||||
(*flushBatchedSubmissionsCallCounter)++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, bool forcePowerSavingMode) override {
|
||||
}
|
||||
|
||||
uint32_t blitBuffer(const BlitPropertiesContainer &blitPropertiesContainer, bool blocking, bool profilingEnabled) override { return taskCount; };
|
||||
|
||||
CommandStreamReceiverType getType() override {
|
||||
return CommandStreamReceiverType::CSR_HW;
|
||||
}
|
||||
|
||||
void downloadAllocations() override {
|
||||
downloadAllocationsCalled = true;
|
||||
}
|
||||
|
||||
void programHardwareContext(LinearStream &cmdStream) override {
|
||||
programHardwareContextCalled = true;
|
||||
}
|
||||
size_t getCmdsSizeForHardwareContext() const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
volatile uint32_t *getTagAddress() const override {
|
||||
if (callParentGetTagAddress) {
|
||||
return CommandStreamReceiver::getTagAddress();
|
||||
}
|
||||
return const_cast<volatile uint32_t *>(&mockTagAddress);
|
||||
}
|
||||
|
||||
GraphicsAllocation *getClearColorAllocation() override { return nullptr; }
|
||||
|
||||
std::vector<char> instructionHeapReserveredData;
|
||||
int *flushBatchedSubmissionsCallCounter = nullptr;
|
||||
uint32_t waitForCompletionWithTimeoutCalled = 0;
|
||||
uint32_t mockTagAddress = 0;
|
||||
bool multiOsContextCapable = false;
|
||||
bool memoryCompressionEnabled = false;
|
||||
bool downloadAllocationsCalled = false;
|
||||
bool programHardwareContextCalled = false;
|
||||
bool callParentGetTagAddress = true;
|
||||
};
|
||||
|
||||
template <typename GfxFamily>
|
||||
class MockCsrHw2 : public CommandStreamReceiverHw<GfxFamily> {
|
||||
public:
|
||||
using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiverHw;
|
||||
using CommandStreamReceiverHw<GfxFamily>::csrSizeRequestFlags;
|
||||
using CommandStreamReceiverHw<GfxFamily>::flushStamp;
|
||||
using CommandStreamReceiverHw<GfxFamily>::programL3;
|
||||
using CommandStreamReceiverHw<GfxFamily>::programVFEState;
|
||||
using CommandStreamReceiver::clearColorAllocation;
|
||||
using CommandStreamReceiver::commandStream;
|
||||
using CommandStreamReceiver::dispatchMode;
|
||||
using CommandStreamReceiver::globalFenceAllocation;
|
||||
using CommandStreamReceiver::isPreambleSent;
|
||||
using CommandStreamReceiver::lastSentCoherencyRequest;
|
||||
using CommandStreamReceiver::mediaVfeStateDirty;
|
||||
using CommandStreamReceiver::nTo1SubmissionModelEnabled;
|
||||
using CommandStreamReceiver::pageTableManagerInitialized;
|
||||
using CommandStreamReceiver::requiredScratchSize;
|
||||
using CommandStreamReceiver::requiredThreadArbitrationPolicy;
|
||||
using CommandStreamReceiver::taskCount;
|
||||
using CommandStreamReceiver::taskLevel;
|
||||
using CommandStreamReceiver::timestampPacketWriteEnabled;
|
||||
using CommandStreamReceiver::useGpuIdleImplicitFlush;
|
||||
using CommandStreamReceiver::useNewResourceImplicitFlush;
|
||||
|
||||
MockCsrHw2(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex, const DeviceBitfield deviceBitfield)
|
||||
: CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiverHw(executionEnvironment, rootDeviceIndex, deviceBitfield) {}
|
||||
|
||||
SubmissionAggregator *peekSubmissionAggregator() {
|
||||
return this->submissionAggregator.get();
|
||||
}
|
||||
|
||||
void overrideSubmissionAggregator(SubmissionAggregator *newSubmissionsAggregator) {
|
||||
this->submissionAggregator.reset(newSubmissionsAggregator);
|
||||
}
|
||||
|
||||
uint64_t peekTotalMemoryUsed() {
|
||||
return this->totalMemoryUsed;
|
||||
}
|
||||
|
||||
bool peekMediaVfeStateDirty() const { return mediaVfeStateDirty; }
|
||||
|
||||
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override {
|
||||
flushCalledCount++;
|
||||
if (recordedCommandBuffer) {
|
||||
recordedCommandBuffer->batchBuffer = batchBuffer;
|
||||
}
|
||||
copyOfAllocations = allocationsForResidency;
|
||||
flushStamp->setStamp(flushStamp->peekStamp() + 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
|
||||
const IndirectHeap &dsh, const IndirectHeap &ioh,
|
||||
const IndirectHeap &ssh, uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) override {
|
||||
passedDispatchFlags = dispatchFlags;
|
||||
|
||||
recordedCommandBuffer = std::unique_ptr<CommandBuffer>(new CommandBuffer(device));
|
||||
auto completionStamp = CommandStreamReceiverHw<GfxFamily>::flushTask(commandStream, commandStreamStart,
|
||||
dsh, ioh, ssh, taskLevel, dispatchFlags, device);
|
||||
|
||||
if (storeFlushedTaskStream && commandStream.getUsed() > commandStreamStart) {
|
||||
storedTaskStreamSize = commandStream.getUsed() - commandStreamStart;
|
||||
// Overfetch to allow command parser verify if "big" command is programmed at the end of allocation
|
||||
auto overfetchedSize = storedTaskStreamSize + MemoryConstants::cacheLineSize;
|
||||
storedTaskStream.reset(new uint8_t[overfetchedSize]);
|
||||
memset(storedTaskStream.get(), 0, overfetchedSize);
|
||||
memcpy_s(storedTaskStream.get(), storedTaskStreamSize,
|
||||
ptrOffset(commandStream.getCpuBase(), commandStreamStart), storedTaskStreamSize);
|
||||
}
|
||||
|
||||
return completionStamp;
|
||||
}
|
||||
|
||||
uint32_t blitBuffer(const BlitPropertiesContainer &blitPropertiesContainer, bool blocking, bool profilingEnabled) override {
|
||||
if (!skipBlitCalls) {
|
||||
return CommandStreamReceiverHw<GfxFamily>::blitBuffer(blitPropertiesContainer, blocking, profilingEnabled);
|
||||
}
|
||||
return taskCount;
|
||||
}
|
||||
|
||||
void programHardwareContext(LinearStream &cmdStream) override {
|
||||
programHardwareContextCalled = true;
|
||||
}
|
||||
|
||||
bool skipBlitCalls = false;
|
||||
bool storeFlushedTaskStream = false;
|
||||
std::unique_ptr<uint8_t> storedTaskStream;
|
||||
size_t storedTaskStreamSize = 0;
|
||||
|
||||
int flushCalledCount = 0;
|
||||
std::unique_ptr<CommandBuffer> recordedCommandBuffer = nullptr;
|
||||
ResidencyContainer copyOfAllocations;
|
||||
DispatchFlags passedDispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
|
||||
bool programHardwareContextCalled = false;
|
||||
};
|
||||
@@ -1,182 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/compiler_interface/compiler_interface.h"
|
||||
|
||||
#include "ocl_igc_interface/fcl_ocl_device_ctx.h"
|
||||
#include "ocl_igc_interface/igc_ocl_device_ctx.h"
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class MockCompilerInterface : public CompilerInterface {
|
||||
public:
|
||||
using CompilerInterface::fclDeviceContexts;
|
||||
using CompilerInterface::initialize;
|
||||
using CompilerInterface::isCompilerAvailable;
|
||||
using CompilerInterface::isFclAvailable;
|
||||
using CompilerInterface::isIgcAvailable;
|
||||
|
||||
using CompilerInterface::fclMain;
|
||||
using CompilerInterface::igcMain;
|
||||
|
||||
bool loadFcl() override {
|
||||
if (failLoadFcl) {
|
||||
return false;
|
||||
}
|
||||
return CompilerInterface::loadFcl();
|
||||
}
|
||||
|
||||
bool loadIgc() override {
|
||||
if (failLoadIgc) {
|
||||
return false;
|
||||
}
|
||||
return CompilerInterface::loadIgc();
|
||||
}
|
||||
|
||||
void setFclDeviceCtx(const Device &d, IGC::FclOclDeviceCtxTagOCL *ctx) {
|
||||
this->fclDeviceContexts[&d] = CIF::RAII::RetainAndPack<IGC::FclOclDeviceCtxTagOCL>(ctx);
|
||||
}
|
||||
|
||||
std::map<const Device *, fclDevCtxUptr> &getFclDeviceContexts() {
|
||||
return this->fclDeviceContexts;
|
||||
}
|
||||
|
||||
void setIgcDeviceCtx(const Device &d, IGC::IgcOclDeviceCtxTagOCL *ctx) {
|
||||
this->igcDeviceContexts[&d] = CIF::RAII::RetainAndPack<IGC::IgcOclDeviceCtxTagOCL>(ctx);
|
||||
}
|
||||
|
||||
std::map<const Device *, igcDevCtxUptr> &getIgcDeviceContexts() {
|
||||
return this->igcDeviceContexts;
|
||||
}
|
||||
|
||||
void setDeviceCtx(const Device &d, IGC::IgcOclDeviceCtxTagOCL *ctx) {
|
||||
setIgcDeviceCtx(d, ctx);
|
||||
}
|
||||
|
||||
void setDeviceCtx(const Device &d, IGC::FclOclDeviceCtxTagOCL *ctx) {
|
||||
setFclDeviceCtx(d, ctx);
|
||||
}
|
||||
|
||||
template <typename DeviceCtx>
|
||||
std::map<const Device *, CIF::RAII::UPtr_t<DeviceCtx>> &getDeviceContexts();
|
||||
|
||||
std::unique_lock<SpinLock> lock() override {
|
||||
if (lockListener != nullptr) {
|
||||
lockListener(*this);
|
||||
}
|
||||
|
||||
return std::unique_lock<SpinLock>(spinlock);
|
||||
}
|
||||
|
||||
void setIgcMain(CIF::CIFMain *main) {
|
||||
this->igcMain.release();
|
||||
this->igcMain.reset(main);
|
||||
}
|
||||
|
||||
void setFclMain(CIF::CIFMain *main) {
|
||||
this->fclMain.release();
|
||||
this->fclMain.reset(main);
|
||||
}
|
||||
|
||||
CIF::RAII::UPtr_t<IGC::FclOclTranslationCtxTagOCL> createFclTranslationCtx(const Device &device,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType) override {
|
||||
requestedTranslationCtxs.emplace_back(inType, outType);
|
||||
if (failCreateFclTranslationCtx) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return CompilerInterface::createFclTranslationCtx(device, inType, outType);
|
||||
}
|
||||
|
||||
CIF::RAII::UPtr_t<IGC::IgcOclTranslationCtxTagOCL> createIgcTranslationCtx(const Device &device,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType) override {
|
||||
requestedTranslationCtxs.emplace_back(inType, outType);
|
||||
if (failCreateIgcTranslationCtx) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return CompilerInterface::createIgcTranslationCtx(device, inType, outType);
|
||||
}
|
||||
|
||||
IGC::FclOclTranslationCtxTagOCL *getFclBaseTranslationCtx() {
|
||||
return this->fclBaseTranslationCtx.get();
|
||||
}
|
||||
|
||||
TranslationOutput::ErrorCode getSipKernelBinary(NEO::Device &device, SipKernelType type, std::vector<char> &retBinary) override {
|
||||
if (this->sipKernelBinaryOverride.size() > 0) {
|
||||
retBinary = this->sipKernelBinaryOverride;
|
||||
this->requestedSipKernel = type;
|
||||
return TranslationOutput::ErrorCode::Success;
|
||||
} else {
|
||||
return CompilerInterface::getSipKernelBinary(device, type, retBinary);
|
||||
}
|
||||
}
|
||||
|
||||
static std::vector<char> getDummyGenBinary();
|
||||
static void releaseDummyGenBinary();
|
||||
|
||||
void (*lockListener)(MockCompilerInterface &compInt) = nullptr;
|
||||
void *lockListenerData = nullptr;
|
||||
bool failCreateFclTranslationCtx = false;
|
||||
bool failCreateIgcTranslationCtx = false;
|
||||
bool failLoadFcl = false;
|
||||
bool failLoadIgc = false;
|
||||
|
||||
using TranslationOpT = std::pair<IGC::CodeType::CodeType_t, IGC::CodeType::CodeType_t>;
|
||||
std::vector<TranslationOpT> requestedTranslationCtxs;
|
||||
|
||||
std::vector<char> sipKernelBinaryOverride;
|
||||
SipKernelType requestedSipKernel = SipKernelType::COUNT;
|
||||
|
||||
IGC::IgcOclDeviceCtxTagOCL *peekIgcDeviceCtx(Device *device) { return igcDeviceContexts[device].get(); }
|
||||
};
|
||||
|
||||
template <>
|
||||
inline std::map<const Device *, MockCompilerInterface::igcDevCtxUptr> &MockCompilerInterface::getDeviceContexts<IGC::IgcOclDeviceCtxTagOCL>() {
|
||||
return getIgcDeviceContexts();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::map<const Device *, MockCompilerInterface::fclDevCtxUptr> &MockCompilerInterface::getDeviceContexts<IGC::FclOclDeviceCtxTagOCL>() {
|
||||
return getFclDeviceContexts();
|
||||
}
|
||||
|
||||
struct MockCompilerInterfaceCaptureBuildOptions : CompilerInterface {
|
||||
TranslationOutput::ErrorCode compile(const NEO::Device &device, const TranslationInput &input, TranslationOutput &) override {
|
||||
buildOptions.clear();
|
||||
if ((input.apiOptions.size() > 0) && (input.apiOptions.begin() != nullptr)) {
|
||||
buildOptions.assign(input.apiOptions.begin(), input.apiOptions.end());
|
||||
}
|
||||
buildInternalOptions.clear();
|
||||
if ((input.internalOptions.size() > 0) && (input.internalOptions.begin() != nullptr)) {
|
||||
buildInternalOptions.assign(input.internalOptions.begin(), input.internalOptions.end());
|
||||
}
|
||||
return TranslationOutput::ErrorCode::Success;
|
||||
}
|
||||
|
||||
TranslationOutput::ErrorCode build(const NEO::Device &device, const TranslationInput &input, TranslationOutput &out) override {
|
||||
return this->MockCompilerInterfaceCaptureBuildOptions::compile(device, input, out);
|
||||
}
|
||||
|
||||
TranslationOutput::ErrorCode link(const NEO::Device &device,
|
||||
const TranslationInput &input,
|
||||
TranslationOutput &output) override {
|
||||
return this->MockCompilerInterfaceCaptureBuildOptions::compile(device, input, output);
|
||||
}
|
||||
|
||||
std::string buildOptions;
|
||||
std::string buildInternalOptions;
|
||||
};
|
||||
} // namespace NEO
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/unit_test/mocks/mock_compiler_interface_spirv.h"
|
||||
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/test/unit_test/helpers/test_files.h"
|
||||
|
||||
#include "opencl/test/unit_test/global_environment.h"
|
||||
#include "opencl/test/unit_test/helpers/kernel_binary_helper.h"
|
||||
|
||||
namespace NEO {
|
||||
TranslationOutput::ErrorCode MockCompilerInterfaceSpirv::compile(const NEO::Device &device, const TranslationInput &input, TranslationOutput &output) {
|
||||
std::string kernelName;
|
||||
retrieveBinaryKernelFilename(kernelName, KernelBinaryHelper::BUILT_INS + "_", ".gen");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(
|
||||
kernelName.c_str(),
|
||||
size);
|
||||
output.deviceBinary.mem = std::move(src);
|
||||
output.deviceBinary.size = size;
|
||||
output.intermediateCodeType = IGC::CodeType::spirV;
|
||||
|
||||
return TranslationOutput::ErrorCode::Success;
|
||||
}
|
||||
TranslationOutput::ErrorCode MockCompilerInterfaceSpirv::build(const NEO::Device &device, const TranslationInput &input, TranslationOutput &out) {
|
||||
return this->compile(device, input, out);
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/test/unit_test/mocks/mock_compiler_interface.h"
|
||||
|
||||
#include "cif/common/cif_main.h"
|
||||
|
||||
namespace NEO {
|
||||
class MockCompilerInterfaceSpirv : public MockCompilerInterface {
|
||||
TranslationOutput::ErrorCode compile(const NEO::Device &device, const TranslationInput &input, TranslationOutput &output) override;
|
||||
TranslationOutput::ErrorCode build(const NEO::Device &device, const TranslationInput &input, TranslationOutput &out) override;
|
||||
};
|
||||
} // namespace NEO
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/debugger/debugger.h"
|
||||
|
||||
namespace NEO {
|
||||
class CommandContainer;
|
||||
|
||||
class MockDebugger : public Debugger {
|
||||
public:
|
||||
MockDebugger() = default;
|
||||
~MockDebugger() = default;
|
||||
void captureStateBaseAddress(CommandContainer &container, SbaAddresses sba){};
|
||||
};
|
||||
} // namespace NEO
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/unit_test/mocks/mock_device.h"
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
#include "shared/test/unit_test/mocks/ult_device_factory.h"
|
||||
#include "shared/test/unit_test/tests_configuration.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_execution_environment.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_ostime.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
bool MockDevice::createSingleDevice = true;
|
||||
|
||||
decltype(&createCommandStream) MockSubDevice::createCommandStreamReceiverFunc = createCommandStream;
|
||||
decltype(&createCommandStream) MockDevice::createCommandStreamReceiverFunc = createCommandStream;
|
||||
|
||||
MockDevice::MockDevice()
|
||||
: MockDevice(new MockExecutionEnvironment(), 0u) {
|
||||
UltDeviceFactory::initializeMemoryManager(*executionEnvironment);
|
||||
CommandStreamReceiver *commandStreamReceiver = createCommandStream(*executionEnvironment, this->getRootDeviceIndex(), this->getDeviceBitfield());
|
||||
commandStreamReceivers.resize(1);
|
||||
commandStreamReceivers[0].reset(commandStreamReceiver);
|
||||
this->engines.resize(1);
|
||||
this->engines[0] = {commandStreamReceiver, nullptr};
|
||||
this->engineGroups.resize(static_cast<uint32_t>(EngineGroupType::MaxEngineGroups));
|
||||
initializeCaps();
|
||||
}
|
||||
|
||||
const char *MockDevice::getProductAbbrev() const {
|
||||
return hardwarePrefix[getHardwareInfo().platform.eProductFamily];
|
||||
}
|
||||
|
||||
MockDevice::MockDevice(ExecutionEnvironment *executionEnvironment, uint32_t rootDeviceIndex)
|
||||
: RootDevice(executionEnvironment, rootDeviceIndex) {
|
||||
UltDeviceFactory::initializeMemoryManager(*executionEnvironment);
|
||||
this->osTime = MockOSTime::create();
|
||||
this->engineGroups.resize(static_cast<uint32_t>(EngineGroupType::MaxEngineGroups));
|
||||
auto &hwInfo = getHardwareInfo();
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(&hwInfo);
|
||||
initializeCaps();
|
||||
preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfo);
|
||||
}
|
||||
|
||||
bool MockDevice::createDeviceImpl() {
|
||||
if (MockDevice::createSingleDevice) {
|
||||
return Device::createDeviceImpl();
|
||||
}
|
||||
return RootDevice::createDeviceImpl();
|
||||
}
|
||||
|
||||
void MockDevice::setOSTime(OSTime *osTime) {
|
||||
this->osTime.reset(osTime);
|
||||
};
|
||||
|
||||
void MockDevice::injectMemoryManager(MemoryManager *memoryManager) {
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
}
|
||||
|
||||
void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr) {
|
||||
resetCommandStreamReceiver(newCsr, defaultEngineIndex);
|
||||
}
|
||||
|
||||
void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr, uint32_t engineIndex) {
|
||||
|
||||
auto osContext = this->engines[engineIndex].osContext;
|
||||
auto memoryManager = executionEnvironment->memoryManager.get();
|
||||
auto registeredEngine = *memoryManager->getRegisteredEngineForCsr(engines[engineIndex].commandStreamReceiver);
|
||||
|
||||
registeredEngine.commandStreamReceiver = newCsr;
|
||||
engines[engineIndex].commandStreamReceiver = newCsr;
|
||||
memoryManager->getRegisteredEngines().emplace_back(registeredEngine);
|
||||
osContext->incRefInternal();
|
||||
newCsr->setupContext(*osContext);
|
||||
commandStreamReceivers[engineIndex].reset(newCsr);
|
||||
commandStreamReceivers[engineIndex]->initializeTagAllocation();
|
||||
commandStreamReceivers[engineIndex]->createGlobalFenceAllocation();
|
||||
|
||||
if (preemptionMode == PreemptionMode::MidThread || isDebuggerActive()) {
|
||||
commandStreamReceivers[engineIndex]->createPreemptionAllocation();
|
||||
}
|
||||
}
|
||||
|
||||
MockAlignedMallocManagerDevice::MockAlignedMallocManagerDevice(ExecutionEnvironment *executionEnvironment, uint32_t internalDeviceIndex) : MockDevice(executionEnvironment, internalDeviceIndex) {
|
||||
executionEnvironment->memoryManager.reset(new MockAllocSysMemAgnosticMemoryManager(*executionEnvironment));
|
||||
}
|
||||
FailDevice::FailDevice(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
|
||||
: MockDevice(executionEnvironment, deviceIndex) {
|
||||
executionEnvironment->memoryManager.reset(new FailMemoryManager(*executionEnvironment));
|
||||
}
|
||||
FailDeviceAfterOne::FailDeviceAfterOne(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
|
||||
: MockDevice(executionEnvironment, deviceIndex) {
|
||||
executionEnvironment->memoryManager.reset(new FailMemoryManager(1, *executionEnvironment));
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/device/root_device.h"
|
||||
#include "shared/source/device/sub_device.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/test/unit_test/helpers/variable_backup.h"
|
||||
|
||||
#include "opencl/test/unit_test/fixtures/mock_aub_center_fixture.h"
|
||||
|
||||
namespace NEO {
|
||||
class CommandStreamReceiver;
|
||||
class DriverInfo;
|
||||
class OSTime;
|
||||
|
||||
template <typename GfxFamily>
|
||||
class UltCommandStreamReceiver;
|
||||
|
||||
extern CommandStreamReceiver *createCommandStream(ExecutionEnvironment &executionEnvironment,
|
||||
uint32_t rootDeviceIndex,
|
||||
const DeviceBitfield deviceBitfield);
|
||||
|
||||
struct MockSubDevice : public SubDevice {
|
||||
using SubDevice::getDeviceBitfield;
|
||||
using SubDevice::getGlobalMemorySize;
|
||||
using SubDevice::SubDevice;
|
||||
|
||||
std::unique_ptr<CommandStreamReceiver> createCommandStreamReceiver() const override {
|
||||
return std::unique_ptr<CommandStreamReceiver>(createCommandStreamReceiverFunc(*executionEnvironment, getRootDeviceIndex(), getDeviceBitfield()));
|
||||
}
|
||||
static decltype(&createCommandStream) createCommandStreamReceiverFunc;
|
||||
};
|
||||
|
||||
class MockDevice : public RootDevice {
|
||||
public:
|
||||
using Device::commandStreamReceivers;
|
||||
using Device::createDeviceInternals;
|
||||
using Device::createEngine;
|
||||
using Device::deviceInfo;
|
||||
using Device::engineGroups;
|
||||
using Device::engines;
|
||||
using Device::executionEnvironment;
|
||||
using Device::getGlobalMemorySize;
|
||||
using Device::initializeCaps;
|
||||
using RootDevice::createEngines;
|
||||
using RootDevice::defaultEngineIndex;
|
||||
using RootDevice::getDeviceBitfield;
|
||||
using RootDevice::initializeRootCommandStreamReceiver;
|
||||
using RootDevice::numSubDevices;
|
||||
using RootDevice::subdevices;
|
||||
|
||||
void setOSTime(OSTime *osTime);
|
||||
void setDriverInfo(DriverInfo *driverInfo);
|
||||
|
||||
static bool createSingleDevice;
|
||||
bool createDeviceImpl() override;
|
||||
|
||||
bool getCpuTime(uint64_t *timeStamp) { return true; };
|
||||
MockDevice();
|
||||
MockDevice(ExecutionEnvironment *executionEnvironment, uint32_t rootDeviceIndex);
|
||||
|
||||
void setPreemptionMode(PreemptionMode mode) {
|
||||
preemptionMode = mode;
|
||||
}
|
||||
|
||||
void injectMemoryManager(MemoryManager *);
|
||||
|
||||
void setPerfCounters(PerformanceCounters *perfCounters) {
|
||||
if (perfCounters) {
|
||||
performanceCounters = std::unique_ptr<PerformanceCounters>(perfCounters);
|
||||
} else {
|
||||
performanceCounters.release();
|
||||
}
|
||||
}
|
||||
|
||||
const char *getProductAbbrev() const;
|
||||
|
||||
template <typename T>
|
||||
UltCommandStreamReceiver<T> &getUltCommandStreamReceiver() {
|
||||
return reinterpret_cast<UltCommandStreamReceiver<T> &>(*engines[defaultEngineIndex].commandStreamReceiver);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
UltCommandStreamReceiver<T> &getUltCommandStreamReceiverFromIndex(uint32_t index) {
|
||||
return reinterpret_cast<UltCommandStreamReceiver<T> &>(*engines[index].commandStreamReceiver);
|
||||
}
|
||||
CommandStreamReceiver &getGpgpuCommandStreamReceiver() const { return *engines[defaultEngineIndex].commandStreamReceiver; }
|
||||
void resetCommandStreamReceiver(CommandStreamReceiver *newCsr);
|
||||
void resetCommandStreamReceiver(CommandStreamReceiver *newCsr, uint32_t engineIndex);
|
||||
|
||||
void setDebuggerActive(bool active) {
|
||||
this->deviceInfo.debuggerActive = active;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T *createWithExecutionEnvironment(const HardwareInfo *pHwInfo, ExecutionEnvironment *executionEnvironment, uint32_t rootDeviceIndex) {
|
||||
pHwInfo = pHwInfo ? pHwInfo : defaultHwInfo.get();
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(pHwInfo);
|
||||
T *device = new T(executionEnvironment, rootDeviceIndex);
|
||||
return createDeviceInternals(device);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T *createWithNewExecutionEnvironment(const HardwareInfo *pHwInfo, uint32_t rootDeviceIndex = 0) {
|
||||
ExecutionEnvironment *executionEnvironment = new ExecutionEnvironment();
|
||||
auto numRootDevices = DebugManager.flags.CreateMultipleRootDevices.get() ? DebugManager.flags.CreateMultipleRootDevices.get() : rootDeviceIndex + 1;
|
||||
executionEnvironment->prepareRootDeviceEnvironments(numRootDevices);
|
||||
pHwInfo = pHwInfo ? pHwInfo : defaultHwInfo.get();
|
||||
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {
|
||||
executionEnvironment->rootDeviceEnvironments[i]->setHwInfo(pHwInfo);
|
||||
}
|
||||
return createWithExecutionEnvironment<T>(pHwInfo, executionEnvironment, rootDeviceIndex);
|
||||
}
|
||||
|
||||
SubDevice *createSubDevice(uint32_t subDeviceIndex) override {
|
||||
return Device::create<MockSubDevice>(executionEnvironment, subDeviceIndex, *this);
|
||||
}
|
||||
|
||||
std::unique_ptr<CommandStreamReceiver> createCommandStreamReceiver() const override {
|
||||
return std::unique_ptr<CommandStreamReceiver>(createCommandStreamReceiverFunc(*executionEnvironment, getRootDeviceIndex(), getDeviceBitfield()));
|
||||
}
|
||||
|
||||
static decltype(&createCommandStream) createCommandStreamReceiverFunc;
|
||||
};
|
||||
|
||||
template <>
|
||||
inline Device *MockDevice::createWithNewExecutionEnvironment<Device>(const HardwareInfo *pHwInfo, uint32_t rootDeviceIndex) {
|
||||
auto executionEnvironment = new ExecutionEnvironment();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
MockAubCenterFixture::setMockAubCenter(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto hwInfo = pHwInfo ? pHwInfo : defaultHwInfo.get();
|
||||
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(hwInfo);
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
return Device::create<RootDevice>(executionEnvironment, 0u);
|
||||
}
|
||||
|
||||
class FailDevice : public MockDevice {
|
||||
public:
|
||||
FailDevice(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
|
||||
};
|
||||
|
||||
class FailDeviceAfterOne : public MockDevice {
|
||||
public:
|
||||
FailDeviceAfterOne(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
|
||||
};
|
||||
|
||||
class MockAlignedMallocManagerDevice : public MockDevice {
|
||||
public:
|
||||
MockAlignedMallocManagerDevice(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
|
||||
};
|
||||
|
||||
struct EnvironmentWithCsrWrapper {
|
||||
template <typename CsrType>
|
||||
void setCsrType() {
|
||||
createSubDeviceCsrFuncBackup = EnvironmentWithCsrWrapper::createCommandStreamReceiver<CsrType>;
|
||||
createRootDeviceCsrFuncBackup = EnvironmentWithCsrWrapper::createCommandStreamReceiver<CsrType>;
|
||||
}
|
||||
|
||||
template <typename CsrType>
|
||||
static CommandStreamReceiver *createCommandStreamReceiver(ExecutionEnvironment &executionEnvironment,
|
||||
uint32_t rootDeviceIndex,
|
||||
const DeviceBitfield deviceBitfield) {
|
||||
return new CsrType(executionEnvironment, rootDeviceIndex, deviceBitfield);
|
||||
}
|
||||
|
||||
VariableBackup<decltype(MockSubDevice::createCommandStreamReceiverFunc)> createSubDeviceCsrFuncBackup{&MockSubDevice::createCommandStreamReceiverFunc};
|
||||
VariableBackup<decltype(MockDevice::createCommandStreamReceiverFunc)> createRootDeviceCsrFuncBackup{&MockDevice::createCommandStreamReceiverFunc};
|
||||
};
|
||||
} // namespace NEO
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/direct_submission/direct_submission_hw_diagnostic_mode.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
struct MockDirectSubmissionDiagnosticsCollector : public DirectSubmissionDiagnosticsCollector {
|
||||
using BaseClass = DirectSubmissionDiagnosticsCollector;
|
||||
using BaseClass::DirectSubmissionDiagnosticsCollector;
|
||||
using BaseClass::executionList;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/direct_submission/direct_submission_hw.h"
|
||||
#include "shared/source/direct_submission/direct_submission_hw_diagnostic_mode.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
struct MockDirectSubmissionHw : public DirectSubmissionHw<GfxFamily, Dispatcher> {
|
||||
using BaseClass = DirectSubmissionHw<GfxFamily, Dispatcher>;
|
||||
using BaseClass::allocateResources;
|
||||
using BaseClass::completionRingBuffers;
|
||||
using BaseClass::cpuCachelineFlush;
|
||||
using BaseClass::currentQueueWorkCount;
|
||||
using BaseClass::currentRingBuffer;
|
||||
using BaseClass::deallocateResources;
|
||||
using BaseClass::device;
|
||||
using BaseClass::diagnostic;
|
||||
using BaseClass::DirectSubmissionHw;
|
||||
using BaseClass::disableCacheFlush;
|
||||
using BaseClass::disableCpuCacheFlush;
|
||||
using BaseClass::disableMonitorFence;
|
||||
using BaseClass::dispatchDisablePrefetcher;
|
||||
using BaseClass::dispatchPrefetchMitigation;
|
||||
using BaseClass::dispatchSemaphoreSection;
|
||||
using BaseClass::dispatchStartSection;
|
||||
using BaseClass::dispatchSwitchRingBufferSection;
|
||||
using BaseClass::dispatchWorkloadSection;
|
||||
using BaseClass::getCommandBufferPositionGpuAddress;
|
||||
using BaseClass::getDiagnosticModeSection;
|
||||
using BaseClass::getSizeDisablePrefetcher;
|
||||
using BaseClass::getSizeDispatch;
|
||||
using BaseClass::getSizeEnd;
|
||||
using BaseClass::getSizePrefetchMitigation;
|
||||
using BaseClass::getSizeSemaphoreSection;
|
||||
using BaseClass::getSizeStartSection;
|
||||
using BaseClass::getSizeSwitchRingBufferSection;
|
||||
using BaseClass::hwInfo;
|
||||
using BaseClass::osContext;
|
||||
using BaseClass::performDiagnosticMode;
|
||||
using BaseClass::ringBuffer;
|
||||
using BaseClass::ringBuffer2;
|
||||
using BaseClass::ringCommandStream;
|
||||
using BaseClass::ringStart;
|
||||
using BaseClass::semaphoreData;
|
||||
using BaseClass::semaphoreGpuVa;
|
||||
using BaseClass::semaphorePtr;
|
||||
using BaseClass::semaphores;
|
||||
using BaseClass::setReturnAddress;
|
||||
using BaseClass::stopRingBuffer;
|
||||
using BaseClass::switchRingBuffersAllocations;
|
||||
using BaseClass::workloadMode;
|
||||
using BaseClass::workloadModeOneExpectedValue;
|
||||
using BaseClass::workloadModeOneStoreAddress;
|
||||
using typename BaseClass::RingBufferUse;
|
||||
|
||||
~MockDirectSubmissionHw() override {
|
||||
if (ringStart) {
|
||||
stopRingBuffer();
|
||||
}
|
||||
deallocateResources();
|
||||
}
|
||||
|
||||
bool allocateOsResources() override {
|
||||
return allocateOsResourcesReturn;
|
||||
}
|
||||
|
||||
bool makeResourcesResident(DirectSubmissionAllocations &allocations) override {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool submit(uint64_t gpuAddress, size_t size) override {
|
||||
submitGpuAddress = gpuAddress;
|
||||
submitSize = size;
|
||||
submitCount++;
|
||||
return submitReturn;
|
||||
}
|
||||
|
||||
bool handleResidency() override {
|
||||
handleResidencyCount++;
|
||||
return handleResidencyReturn;
|
||||
}
|
||||
|
||||
void handleSwitchRingBuffers() override {}
|
||||
|
||||
uint64_t updateTagValue() override {
|
||||
return updateTagValueReturn;
|
||||
}
|
||||
|
||||
void getTagAddressValue(TagData &tagData) override {
|
||||
tagData.tagAddress = tagAddressSetValue;
|
||||
tagData.tagValue = tagValueSetValue;
|
||||
}
|
||||
|
||||
void performDiagnosticMode() override {
|
||||
if (!NEO::directSubmissionDiagnosticAvailable) {
|
||||
disabledDiagnosticCalled++;
|
||||
}
|
||||
uint32_t add = 1;
|
||||
if (diagnostic.get()) {
|
||||
add += diagnostic->getExecutionsCount();
|
||||
}
|
||||
*static_cast<volatile uint32_t *>(workloadModeOneStoreAddress) = workloadModeOneExpectedValue + add;
|
||||
BaseClass::performDiagnosticMode();
|
||||
}
|
||||
|
||||
uint64_t updateTagValueReturn = 1ull;
|
||||
uint64_t tagAddressSetValue = MemoryConstants::pageSize;
|
||||
uint64_t tagValueSetValue = 1ull;
|
||||
uint64_t submitGpuAddress = 0ull;
|
||||
size_t submitSize = 0u;
|
||||
uint32_t submitCount = 0u;
|
||||
uint32_t handleResidencyCount = 0u;
|
||||
uint32_t disabledDiagnosticCalled = 0u;
|
||||
bool allocateOsResourcesReturn = true;
|
||||
bool submitReturn = true;
|
||||
bool handleResidencyReturn = true;
|
||||
};
|
||||
} // namespace NEO
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/unit_test/mocks/mock_dispatch_kernel_encoder_interface.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using ::testing::Return;
|
||||
|
||||
MockDispatchKernelEncoder::MockDispatchKernelEncoder() {
|
||||
EXPECT_CALL(*this, getKernelDescriptor).WillRepeatedly(::testing::ReturnRef(kernelDescriptor));
|
||||
|
||||
EXPECT_CALL(*this, getIsaAllocation).WillRepeatedly(Return(&mockAllocation));
|
||||
EXPECT_CALL(*this, getCrossThreadDataSize).WillRepeatedly(Return(crossThreadSize));
|
||||
EXPECT_CALL(*this, getPerThreadDataSize).WillRepeatedly(Return(perThreadSize));
|
||||
|
||||
EXPECT_CALL(*this, getCrossThreadData).WillRepeatedly(Return(dataCrossThread));
|
||||
EXPECT_CALL(*this, getPerThreadData).WillRepeatedly(Return(dataPerThread));
|
||||
EXPECT_CALL(*this, getSlmPolicy()).WillRepeatedly(::testing::Return(SlmPolicy::SlmPolicyNone));
|
||||
|
||||
groupSizes[0] = 32u;
|
||||
groupSizes[1] = groupSizes[2] = 1;
|
||||
EXPECT_CALL(*this, getGroupSize()).WillRepeatedly(Return(groupSizes));
|
||||
|
||||
EXPECT_CALL(*this, requiresGenerationOfLocalIdsByRuntime).WillRepeatedly(Return(localIdGenerationByRuntime));
|
||||
|
||||
expectAnyMockFunctionCall();
|
||||
}
|
||||
|
||||
void MockDispatchKernelEncoder::expectAnyMockFunctionCall() {
|
||||
EXPECT_CALL(*this, getSlmTotalSize()).Times(::testing::AnyNumber());
|
||||
|
||||
EXPECT_CALL(*this, getThreadExecutionMask()).Times(::testing::AnyNumber());
|
||||
EXPECT_CALL(*this, getPerThreadDataSizeForWholeThreadGroup()).Times(::testing::AnyNumber());
|
||||
|
||||
EXPECT_CALL(*this, getSurfaceStateHeapData()).Times(::testing::AnyNumber());
|
||||
EXPECT_CALL(*this, getSurfaceStateHeapDataSize()).Times(::testing::AnyNumber());
|
||||
|
||||
EXPECT_CALL(*this, getDynamicStateHeapData()).Times(::testing::AnyNumber());
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/kernel/dispatch_kernel_encoder_interface.h"
|
||||
#include "shared/source/kernel/kernel_descriptor.h"
|
||||
#include "shared/test/unit_test/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace NEO {
|
||||
class GraphicsAllocation;
|
||||
|
||||
struct MockDispatchKernelEncoder : public DispatchKernelEncoderI {
|
||||
public:
|
||||
MockDispatchKernelEncoder();
|
||||
|
||||
MOCK_METHOD(const KernelDescriptor &, getKernelDescriptor, (), (const, override));
|
||||
|
||||
MOCK_METHOD(const uint32_t *, getGroupSize, (), (const, override));
|
||||
MOCK_METHOD(uint32_t, getSlmTotalSize, (), (const, override));
|
||||
|
||||
MOCK_METHOD(const uint8_t *, getCrossThreadData, (), (const, override));
|
||||
MOCK_METHOD(uint32_t, getCrossThreadDataSize, (), (const, override));
|
||||
|
||||
MOCK_METHOD(uint32_t, getThreadExecutionMask, (), (const, override));
|
||||
|
||||
MOCK_METHOD(const uint8_t *, getPerThreadData, (), (const, override));
|
||||
MOCK_METHOD(uint32_t, getPerThreadDataSize, (), (const, override));
|
||||
|
||||
MOCK_METHOD(uint32_t, getPerThreadDataSizeForWholeThreadGroup, (), (const, override));
|
||||
|
||||
MOCK_METHOD(const uint8_t *, getSurfaceStateHeapData, (), (const, override));
|
||||
MOCK_METHOD(uint32_t, getSurfaceStateHeapDataSize, (), (const, override));
|
||||
|
||||
MOCK_METHOD(GraphicsAllocation *, getIsaAllocation, (), (const, override));
|
||||
MOCK_METHOD(const uint8_t *, getDynamicStateHeapData, (), (const, override));
|
||||
|
||||
MOCK_METHOD(bool, requiresGenerationOfLocalIdsByRuntime, (), (const, override));
|
||||
|
||||
MOCK_METHOD(SlmPolicy, getSlmPolicy, (), (const, override));
|
||||
|
||||
uint32_t getRequiredWorkgroupOrder() const override {
|
||||
return requiredWalkGroupOrder;
|
||||
}
|
||||
uint32_t getNumThreadsPerThreadGroup() const override {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void expectAnyMockFunctionCall();
|
||||
|
||||
::testing::NiceMock<MockGraphicsAllocation> mockAllocation;
|
||||
static constexpr uint32_t crossThreadSize = 0x40;
|
||||
static constexpr uint32_t perThreadSize = 0x20;
|
||||
uint8_t dataCrossThread[crossThreadSize];
|
||||
uint8_t dataPerThread[perThreadSize];
|
||||
KernelDescriptor kernelDescriptor;
|
||||
|
||||
uint32_t groupSizes[3];
|
||||
bool localIdGenerationByRuntime = true;
|
||||
uint32_t requiredWalkGroupOrder = 0x0u;
|
||||
};
|
||||
} // namespace NEO
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/device_binary_format/elf/elf_decoder.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_encoder.h"
|
||||
|
||||
template <NEO::Elf::ELF_IDENTIFIER_CLASS NumBits = NEO::Elf::EI_CLASS_64>
|
||||
struct MockElf : public NEO::Elf::Elf<NumBits> {
|
||||
using BaseClass = NEO::Elf::Elf<NumBits>;
|
||||
|
||||
using BaseClass::relocations;
|
||||
using BaseClass::symbolTable;
|
||||
|
||||
std::string getSectionName(uint32_t id) const override {
|
||||
if (overrideSectionNames) {
|
||||
return sectionNames.find(id)->second;
|
||||
}
|
||||
return NEO::Elf::Elf<NumBits>::getSectionName(id);
|
||||
}
|
||||
|
||||
std::string getSymbolName(uint32_t nameOffset) const override {
|
||||
if (overrideSymbolName) {
|
||||
return std::to_string(nameOffset);
|
||||
}
|
||||
return NEO::Elf::Elf<NumBits>::getSymbolName(nameOffset);
|
||||
}
|
||||
|
||||
void setupSecionNames(std::unordered_map<uint32_t, std::string> map) {
|
||||
sectionNames = map;
|
||||
overrideSectionNames = true;
|
||||
}
|
||||
|
||||
bool overrideSectionNames = false;
|
||||
std::unordered_map<uint32_t, std::string> sectionNames;
|
||||
bool overrideSymbolName = false;
|
||||
};
|
||||
|
||||
template <NEO::Elf::ELF_IDENTIFIER_CLASS NumBits = NEO::Elf::EI_CLASS_64>
|
||||
struct MockElfEncoder : public NEO::Elf::ElfEncoder<NumBits> {
|
||||
using NEO::Elf::ElfEncoder<NumBits>::sectionHeaders;
|
||||
|
||||
uint32_t getLastSectionHeaderIndex() {
|
||||
return uint32_t(sectionHeaders.size()) - 1;
|
||||
}
|
||||
|
||||
NEO::Elf::ElfSectionHeader<NumBits> *getSectionHeader(uint32_t idx) {
|
||||
return sectionHeaders.data() + idx;
|
||||
}
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/source/memory_manager/multi_graphics_allocation.h"
|
||||
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
constexpr uint32_t mockRootDeviceIndex = 0u;
|
||||
constexpr DeviceBitfield mockDeviceBitfield(0b1);
|
||||
constexpr size_t mockMaxOsContextCount = 3u;
|
||||
|
||||
class MockGraphicsAllocation : public MemoryAllocation {
|
||||
public:
|
||||
using MemoryAllocation::aubInfo;
|
||||
using MemoryAllocation::MemoryAllocation;
|
||||
using MemoryAllocation::objectNotResident;
|
||||
using MemoryAllocation::objectNotUsed;
|
||||
using MemoryAllocation::usageInfos;
|
||||
|
||||
MockGraphicsAllocation()
|
||||
: MemoryAllocation(0, AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull, mockMaxOsContextCount) {}
|
||||
|
||||
MockGraphicsAllocation(void *buffer, size_t sizeIn)
|
||||
: MemoryAllocation(0, AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull, mockMaxOsContextCount) {}
|
||||
|
||||
MockGraphicsAllocation(void *buffer, uint64_t gpuAddr, size_t sizeIn)
|
||||
: MemoryAllocation(0, AllocationType::UNKNOWN, buffer, gpuAddr, 0llu, sizeIn, MemoryPool::MemoryNull, mockMaxOsContextCount) {}
|
||||
|
||||
MockGraphicsAllocation(uint32_t rootDeviceIndex, void *buffer, size_t sizeIn)
|
||||
: MemoryAllocation(rootDeviceIndex, AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull, mockMaxOsContextCount) {}
|
||||
|
||||
void resetInspectionIds() {
|
||||
for (auto &usageInfo : usageInfos) {
|
||||
usageInfo.inspectionId = 0u;
|
||||
}
|
||||
}
|
||||
|
||||
void overrideMemoryPool(MemoryPool::Type pool) {
|
||||
this->memoryPool = pool;
|
||||
}
|
||||
};
|
||||
|
||||
namespace GraphicsAllocationHelper {
|
||||
|
||||
static inline MultiGraphicsAllocation toMultiGraphicsAllocation(GraphicsAllocation *graphicsAllocation) {
|
||||
MultiGraphicsAllocation multiGraphicsAllocation(graphicsAllocation->getRootDeviceIndex());
|
||||
multiGraphicsAllocation.addAllocation(graphicsAllocation);
|
||||
return multiGraphicsAllocation;
|
||||
}
|
||||
|
||||
} // namespace GraphicsAllocationHelper
|
||||
|
||||
} // namespace NEO
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
class MockOsLibrary : public NEO::OsLibrary {
|
||||
public:
|
||||
void *getProcAddress(const std::string &procName) override {
|
||||
return nullptr;
|
||||
}
|
||||
bool isLoaded() override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/unit_test/mocks/mock_sip.h"
|
||||
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "shared/test/unit_test/helpers/test_files.h"
|
||||
|
||||
#include "cif/macros/enable.h"
|
||||
#include "ocl_igc_interface/igc_ocl_device_ctx.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
|
||||
namespace NEO {
|
||||
MockSipKernel::MockSipKernel(SipKernelType type, GraphicsAllocation *sipAlloc) : SipKernel(type, sipAlloc) {
|
||||
this->mockSipMemoryAllocation =
|
||||
std::make_unique<MemoryAllocation>(0u,
|
||||
GraphicsAllocation::AllocationType::KERNEL_ISA_INTERNAL,
|
||||
nullptr,
|
||||
MemoryConstants::pageSize * 10u,
|
||||
0u,
|
||||
MemoryConstants::pageSize,
|
||||
MemoryPool::System4KBPages, 3u);
|
||||
}
|
||||
|
||||
MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, nullptr) {
|
||||
this->mockSipMemoryAllocation =
|
||||
std::make_unique<MemoryAllocation>(0u,
|
||||
GraphicsAllocation::AllocationType::KERNEL_ISA_INTERNAL,
|
||||
nullptr,
|
||||
MemoryConstants::pageSize * 10u,
|
||||
0u,
|
||||
MemoryConstants::pageSize,
|
||||
MemoryPool::System4KBPages, 3u);
|
||||
}
|
||||
|
||||
MockSipKernel::~MockSipKernel() = default;
|
||||
|
||||
const char *MockSipKernel::dummyBinaryForSip = "12345678";
|
||||
|
||||
std::vector<char> MockSipKernel::getDummyGenBinary() {
|
||||
return std::vector<char>(dummyBinaryForSip, dummyBinaryForSip + sizeof(MockSipKernel::dummyBinaryForSip));
|
||||
}
|
||||
|
||||
GraphicsAllocation *MockSipKernel::getSipAllocation() const {
|
||||
return mockSipMemoryAllocation.get();
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/built_ins/sip.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_execution_environment.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
class MemoryAllocation;
|
||||
|
||||
class MockSipKernel : public SipKernel {
|
||||
public:
|
||||
using SipKernel::type;
|
||||
|
||||
MockSipKernel(SipKernelType type, GraphicsAllocation *sipAlloc);
|
||||
MockSipKernel();
|
||||
~MockSipKernel() override;
|
||||
|
||||
static const char *dummyBinaryForSip;
|
||||
static std::vector<char> getDummyGenBinary();
|
||||
|
||||
GraphicsAllocation *getSipAllocation() const override;
|
||||
|
||||
std::unique_ptr<MemoryAllocation> mockSipMemoryAllocation;
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
};
|
||||
|
||||
namespace MockSipData {
|
||||
extern std::unique_ptr<MockSipKernel> mockSipKernel;
|
||||
extern SipKernelType calledType;
|
||||
extern bool called;
|
||||
} // namespace MockSipData
|
||||
} // namespace NEO
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/unit_test/mocks/ult_device_factory.h"
|
||||
|
||||
#include "shared/source/os_interface/device_factory.h"
|
||||
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/unit_test/helpers/variable_backup.h"
|
||||
#include "shared/test/unit_test/mocks/mock_device.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
UltDeviceFactory::UltDeviceFactory(uint32_t rootDevicesCount, uint32_t subDevicesCount)
|
||||
: UltDeviceFactory(rootDevicesCount, subDevicesCount, *(new ExecutionEnvironment)) {
|
||||
}
|
||||
|
||||
UltDeviceFactory::UltDeviceFactory(uint32_t rootDevicesCount, uint32_t subDevicesCount, ExecutionEnvironment &executionEnvironment) {
|
||||
DebugManagerStateRestore restorer;
|
||||
VariableBackup<bool> createSingleDeviceBackup{&MockDevice::createSingleDevice, false};
|
||||
VariableBackup<decltype(DeviceFactory::createRootDeviceFunc)> createRootDeviceFuncBackup{&DeviceFactory::createRootDeviceFunc};
|
||||
VariableBackup<decltype(DeviceFactory::createMemoryManagerFunc)> createMemoryManagerFuncBackup{&DeviceFactory::createMemoryManagerFunc};
|
||||
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(rootDevicesCount);
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(subDevicesCount);
|
||||
createRootDeviceFuncBackup = [](ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex) -> std::unique_ptr<Device> {
|
||||
return std::unique_ptr<Device>(MockDevice::create<MockDevice>(&executionEnvironment, rootDeviceIndex));
|
||||
};
|
||||
createMemoryManagerFuncBackup = UltDeviceFactory::initializeMemoryManager;
|
||||
|
||||
auto createdDevices = DeviceFactory::createDevices(executionEnvironment);
|
||||
|
||||
for (auto &pCreatedDevice : createdDevices) {
|
||||
pCreatedDevice->incRefInternal();
|
||||
for (uint32_t i = 0; i < pCreatedDevice->getNumAvailableDevices(); i++) {
|
||||
this->subDevices.push_back(static_cast<SubDevice *>(pCreatedDevice->getDeviceById(i)));
|
||||
}
|
||||
this->rootDevices.push_back(static_cast<MockDevice *>(pCreatedDevice.release()));
|
||||
}
|
||||
}
|
||||
|
||||
UltDeviceFactory::~UltDeviceFactory() {
|
||||
for (auto &pDevice : rootDevices) {
|
||||
pDevice->decRefInternal();
|
||||
}
|
||||
}
|
||||
|
||||
void UltDeviceFactory::prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment, uint32_t rootDevicesCount) {
|
||||
uint32_t numRootDevices = rootDevicesCount;
|
||||
executionEnvironment.prepareRootDeviceEnvironments(numRootDevices);
|
||||
for (auto i = 0u; i < numRootDevices; i++) {
|
||||
if (executionEnvironment.rootDeviceEnvironments[i]->getHardwareInfo() == nullptr ||
|
||||
(executionEnvironment.rootDeviceEnvironments[i]->getHardwareInfo()->platform.eProductFamily == IGFX_UNKNOWN &&
|
||||
executionEnvironment.rootDeviceEnvironments[i]->getHardwareInfo()->platform.eRenderCoreFamily == IGFX_UNKNOWN_CORE)) {
|
||||
executionEnvironment.rootDeviceEnvironments[i]->setHwInfo(defaultHwInfo.get());
|
||||
}
|
||||
}
|
||||
executionEnvironment.calculateMaxOsContextCount();
|
||||
DeviceFactory::createMemoryManagerFunc(executionEnvironment);
|
||||
}
|
||||
bool UltDeviceFactory::initializeMemoryManager(ExecutionEnvironment &executionEnvironment) {
|
||||
if (executionEnvironment.memoryManager == nullptr) {
|
||||
bool enableLocalMemory = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getEnableLocalMemory(*defaultHwInfo);
|
||||
bool aubUsage = (testMode == TestMode::AubTests) || (testMode == TestMode::AubTestsWithTbx);
|
||||
executionEnvironment.memoryManager.reset(new MockMemoryManager(false, enableLocalMemory, aubUsage, executionEnvironment));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
class ExecutionEnvironment;
|
||||
class MockDevice;
|
||||
class SubDevice;
|
||||
|
||||
struct UltDeviceFactory {
|
||||
UltDeviceFactory(uint32_t rootDevicesCount, uint32_t subDevicesCount);
|
||||
UltDeviceFactory(uint32_t rootDevicesCount, uint32_t subDevicesCount, ExecutionEnvironment &executionEnvironment);
|
||||
~UltDeviceFactory();
|
||||
|
||||
static void prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment, uint32_t rootDevicesCount);
|
||||
static bool initializeMemoryManager(ExecutionEnvironment &executionEnvironment);
|
||||
|
||||
std::vector<MockDevice *> rootDevices;
|
||||
std::vector<SubDevice *> subDevices;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/direct_submission/windows/wddm_direct_submission.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename GfxFamily, typename Dispatcher>
|
||||
struct MockWddmDirectSubmission : public WddmDirectSubmission<GfxFamily, Dispatcher> {
|
||||
using BaseClass = WddmDirectSubmission<GfxFamily, Dispatcher>;
|
||||
using BaseClass::allocateOsResources;
|
||||
using BaseClass::allocateResources;
|
||||
using BaseClass::commandBufferHeader;
|
||||
using BaseClass::completionRingBuffers;
|
||||
using BaseClass::currentRingBuffer;
|
||||
using BaseClass::getSizeDispatch;
|
||||
using BaseClass::getSizeSemaphoreSection;
|
||||
using BaseClass::getSizeSwitchRingBufferSection;
|
||||
using BaseClass::getTagAddressValue;
|
||||
using BaseClass::handleCompletionRingBuffer;
|
||||
using BaseClass::handleResidency;
|
||||
using BaseClass::osContextWin;
|
||||
using BaseClass::ringBuffer;
|
||||
using BaseClass::ringBuffer2;
|
||||
using BaseClass::ringCommandStream;
|
||||
using BaseClass::ringFence;
|
||||
using BaseClass::ringStart;
|
||||
using BaseClass::semaphores;
|
||||
using BaseClass::submit;
|
||||
using BaseClass::switchRingBuffers;
|
||||
using BaseClass::updateTagValue;
|
||||
using BaseClass::wddm;
|
||||
using BaseClass::WddmDirectSubmission;
|
||||
using typename BaseClass::RingBufferUse;
|
||||
};
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user