Calculate a maxOsContextCount variable

Change-Id: I7b2f7733be74abf4ae299396d616b249b67de58e
Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
Jobczyk, Lukasz 2019-12-17 08:11:16 +01:00 committed by sys_ocldev
parent 1021d8c6d2
commit eac48002ab
30 changed files with 110 additions and 64 deletions

View File

@ -9,9 +9,9 @@
#include <cstdint>
namespace NEO {
namespace EngineLimits {
constexpr uint32_t numGpgpuEngineInstances = 3u;
constexpr uint32_t maxOsContextCount = numGpgpuEngineInstances;
constexpr uint32_t maxHandleCount = 1u;
}; // namespace EngineLimits
} // namespace NEO

View File

@ -8,10 +8,10 @@
#include "graphics_allocation.h"
#include "core/helpers/aligned_memory.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/utilities/logger.h"
namespace NEO {
void GraphicsAllocation::setAllocationType(AllocationType allocationType) {
this->allocationType = allocationType;
FileLoggerInstance().logAllocation(this);
@ -25,7 +25,8 @@ GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, AllocationType
size(sizeIn),
cpuPtr(cpuPtrIn),
memoryPool(pool),
allocationType(allocationType) {
allocationType(allocationType),
usageInfos(MemoryManager::maxOsContextCount) {
}
GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn,
@ -35,7 +36,8 @@ GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, AllocationType
size(sizeIn),
cpuPtr(cpuPtrIn),
memoryPool(pool),
allocationType(allocationType) {
allocationType(allocationType),
usageInfos(MemoryManager::maxOsContextCount) {
sharingInfo.sharedHandle = sharedHandleIn;
}

View File

@ -23,6 +23,7 @@
#include <cstdint>
#include <limits>
#include <mutex>
#include <vector>
namespace NEO {
@ -285,8 +286,8 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
MemoryPool::Type memoryPool = MemoryPool::MemoryNull;
AllocationType allocationType = AllocationType::UNKNOWN;
std::array<UsageInfo, maxOsContextCount> usageInfos;
std::vector<UsageInfo> usageInfos;
std::atomic<uint32_t> registeredContextsNum{0};
std::array<Gmm *, maxHandleCount> gmms{};
std::array<Gmm *, EngineLimits::maxHandleCount> gmms{};
};
} // namespace NEO

View File

@ -6,7 +6,6 @@
*/
#pragma once
#include "core/memory_manager/residency.h"
#include <cinttypes>
#include <cstdlib>
@ -14,6 +13,7 @@
namespace NEO {
struct OsHandle;
struct ResidencyData;
using OsGraphicsHandle = OsHandle;

View File

@ -6,20 +6,19 @@
*/
#pragma once
#include "engine_limits.h"
#include "runtime/memory_manager/memory_manager.h"
#include <array>
#include <cstdint>
#include <vector>
namespace NEO {
struct ResidencyData {
bool resident[maxOsContextCount] = {};
std::vector<bool> resident = std::vector<bool>(MemoryManager::maxOsContextCount, 0);
void updateCompletionData(uint64_t newFenceValue, uint32_t contextId);
uint64_t getFenceValueForContextId(uint32_t contextId);
protected:
std::array<uint64_t, maxOsContextCount> lastFenceValues = {};
std::vector<uint64_t> lastFenceValues = std::vector<uint64_t>(MemoryManager::maxOsContextCount, 0);
};
} // namespace NEO

View File

@ -15,6 +15,7 @@
#include "runtime/built_ins/built_ins.h"
#include "runtime/command_stream/tbx_command_stream_receiver_hw.h"
#include "runtime/compiler_interface/default_cl_cache_config.h"
#include "runtime/helpers/device_helpers.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/os_interface/os_interface.h"
#include "runtime/source_level_debugger/source_level_debugger.h"
@ -36,9 +37,11 @@ void ExecutionEnvironment::initGmm() {
gmmHelper.reset(new GmmHelper(osInterface.get(), hwInfo.get()));
}
}
void ExecutionEnvironment::setHwInfo(const HardwareInfo *hwInfo) {
*this->hwInfo = *hwInfo;
}
void ExecutionEnvironment::initializeMemoryManager() {
if (this->memoryManager) {
return;
@ -65,6 +68,7 @@ void ExecutionEnvironment::initializeMemoryManager() {
}
DEBUG_BREAK_IF(!this->memoryManager);
}
void ExecutionEnvironment::initSourceLevelDebugger() {
if (hwInfo->capabilityTable.sourceLevelDebuggerSupported) {
sourceLevelDebugger.reset(SourceLevelDebugger::create());
@ -74,9 +78,20 @@ void ExecutionEnvironment::initSourceLevelDebugger() {
sourceLevelDebugger->initialize(localMemorySipAvailable);
}
}
void ExecutionEnvironment::calculateMaxOsContextCount() {
auto &hwHelper = HwHelper::get(this->hwInfo->platform.eRenderCoreFamily);
auto osContextCount = hwHelper.getGpgpuEngineInstances().size();
auto subDevicesCount = DeviceHelper::getSubDevicesCount(this->getHardwareInfo());
bool hasRootCsr = subDevicesCount > 1;
MemoryManager::maxOsContextCount = static_cast<uint32_t>(osContextCount * subDevicesCount * this->rootDeviceEnvironments.size() + hasRootCsr);
}
GmmHelper *ExecutionEnvironment::getGmmHelper() const {
return gmmHelper.get();
}
CompilerInterface *ExecutionEnvironment::getCompilerInterface() {
if (this->compilerInterface.get() == nullptr) {
std::lock_guard<std::mutex> autolock(this->mtx);
@ -87,6 +102,7 @@ CompilerInterface *ExecutionEnvironment::getCompilerInterface() {
}
return this->compilerInterface.get();
}
BuiltIns *ExecutionEnvironment::getBuiltIns() {
if (this->builtins.get() == nullptr) {
std::lock_guard<std::mutex> autolock(this->mtx);
@ -110,5 +126,6 @@ void ExecutionEnvironment::prepareRootDeviceEnvironments(uint32_t numRootDevices
rootDeviceEnvironments[rootDeviceIndex] = std::make_unique<RootDeviceEnvironment>(*this);
}
}
calculateMaxOsContextCount();
}
} // namespace NEO

View File

@ -39,6 +39,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
void initGmm();
void initializeMemoryManager();
void initSourceLevelDebugger();
void calculateMaxOsContextCount();
void setHwInfo(const HardwareInfo *hwInfo);
const HardwareInfo *getHardwareInfo() const { return hwInfo.get(); }
HardwareInfo *getMutableHardwareInfo() const { return hwInfo.get(); }

View File

@ -30,6 +30,8 @@
#include <algorithm>
namespace NEO {
uint32_t MemoryManager::maxOsContextCount = 0u;
MemoryManager::MemoryManager(ExecutionEnvironment &executionEnvironment) : executionEnvironment(executionEnvironment), hostPtrManager(std::make_unique<HostPtrManager>()),
multiContextResourceDestructor(std::make_unique<DeferredDeleter>()) {
auto hwInfo = executionEnvironment.getHardwareInfo();

View File

@ -158,6 +158,8 @@ class MemoryManager {
void *getReservedMemory(size_t size, size_t alignment);
GfxPartition *getGfxPartition(uint32_t rootDeviceIndex) { return gfxPartitions.at(rootDeviceIndex).get(); }
static uint32_t maxOsContextCount;
protected:
struct AllocationData {
union {

View File

@ -15,6 +15,7 @@
#include "core/helpers/options.h"
#include "core/helpers/ptr_math.h"
#include "core/memory_manager/host_ptr_manager.h"
#include "core/memory_manager/residency.h"
#include "core/os_interface/os_memory.h"
#include "runtime/aub/aub_center.h"
#include "runtime/execution_environment/execution_environment.h"
@ -188,7 +189,7 @@ void OsAgnosticMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocat
}
void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
for (auto handleId = 0u; handleId < maxHandleCount; handleId++) {
for (auto handleId = 0u; handleId < EngineLimits::maxHandleCount; handleId++) {
delete gfxAllocation->getGmm(handleId);
}

View File

@ -15,7 +15,7 @@ struct OsHandle {
BufferObject *bo = nullptr;
};
using BufferObjects = std::array<BufferObject *, maxHandleCount>;
using BufferObjects = std::array<BufferObject *, EngineLimits::maxHandleCount>;
class DrmAllocation : public GraphicsAllocation {
public:

View File

@ -9,6 +9,7 @@
#include "core/gmm_helper/gmm_helper.h"
#include "core/helpers/aligned_memory.h"
#include "core/helpers/preamble.h"
#include "core/memory_manager/residency.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/gmm_helper/page_table_mngr.h"
#include "runtime/helpers/flush_stamp.h"

View File

@ -12,6 +12,7 @@
#include "core/helpers/options.h"
#include "core/helpers/ptr_math.h"
#include "core/memory_manager/host_ptr_manager.h"
#include "core/memory_manager/residency.h"
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/device/device.h"
#include "runtime/execution_environment/execution_environment.h"
@ -538,7 +539,7 @@ void DrmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *gf
}
void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
for (auto handleId = 0u; handleId < maxHandleCount; handleId++) {
for (auto handleId = 0u; handleId < EngineLimits::maxHandleCount; handleId++) {
if (gfxAllocation->getGmm(handleId)) {
delete gfxAllocation->getGmm(handleId);
}

View File

@ -9,6 +9,7 @@
#define UMDF_USING_NTSTATUS
#include "core/helpers/aligned_memory.h"
#include "core/memory_manager/graphics_allocation.h"
#include "core/memory_manager/residency.h"
#include "core/os_interface/windows/windows_wrapper.h"
#include <d3dkmthk.h>
@ -26,23 +27,19 @@ constexpr size_t trimListUnusedPosition = std::numeric_limits<size_t>::max();
class WddmAllocation : public GraphicsAllocation {
public:
WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, void *reservedAddr, MemoryPool::Type pool)
: GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool) {
trimCandidateListPositions.fill(trimListUnusedPosition);
: GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool), trimCandidateListPositions(MemoryManager::maxOsContextCount, trimListUnusedPosition) {
reservedAddressRangeInfo.addressPtr = reservedAddr;
reservedAddressRangeInfo.rangeSize = sizeIn;
}
WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, void *reservedAddr, MemoryPool::Type pool, uint32_t shareable)
: GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool), shareable(shareable) {
trimCandidateListPositions.fill(trimListUnusedPosition);
: GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool), shareable(shareable), trimCandidateListPositions(MemoryManager::maxOsContextCount, trimListUnusedPosition) {
reservedAddressRangeInfo.addressPtr = reservedAddr;
reservedAddressRangeInfo.rangeSize = sizeIn;
}
WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool)
: GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool) {
trimCandidateListPositions.fill(trimListUnusedPosition);
}
: GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool), trimCandidateListPositions(MemoryManager::maxOsContextCount, trimListUnusedPosition) {}
void *getAlignedCpuPtr() const {
return alignDown(this->cpuPtr, MemoryConstants::pageSize);
@ -55,7 +52,7 @@ class WddmAllocation : public GraphicsAllocation {
ResidencyData &getResidencyData() {
return residency;
}
const std::array<D3DKMT_HANDLE, maxHandleCount> &getHandles() const { return handles; }
const std::array<D3DKMT_HANDLE, EngineLimits::maxHandleCount> &getHandles() const { return handles; }
D3DKMT_HANDLE &getHandleToModify(uint32_t handleIndex) { return handles[handleIndex]; }
D3DKMT_HANDLE getDefaultHandle() const { return handles[0]; }
void setDefaultHandle(D3DKMT_HANDLE handle) {
@ -94,8 +91,8 @@ class WddmAllocation : public GraphicsAllocation {
}
return ss.str();
}
std::array<D3DKMT_HANDLE, maxHandleCount> handles{};
std::array<D3DKMT_HANDLE, EngineLimits::maxHandleCount> handles{};
ResidencyData residency;
std::array<size_t, maxOsContextCount> trimCandidateListPositions;
std::vector<size_t> trimCandidateListPositions;
};
} // namespace NEO

View File

@ -341,7 +341,7 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
DEBUG_BREAK_IF(!status);
}
}
for (auto handleId = 0u; handleId < maxHandleCount; handleId++) {
for (auto handleId = 0u; handleId < EngineLimits::maxHandleCount; handleId++) {
delete gfxAllocation->getGmm(handleId);
}
@ -450,7 +450,7 @@ void WddmMemoryManager::cleanOsHandles(OsHandleStorage &handleStorage, uint32_t
for (unsigned int i = 0; i < maxFragmentsCount; i++) {
if (handleStorage.fragmentStorageData[i].freeTheFragment) {
handles[allocationCount++] = handleStorage.fragmentStorageData[i].osHandleStorage->handle;
std::fill_n(handleStorage.fragmentStorageData[i].residency->resident, maxOsContextCount, false);
std::fill(handleStorage.fragmentStorageData[i].residency->resident.begin(), handleStorage.fragmentStorageData[i].residency->resident.end(), false);
}
}

View File

@ -7,12 +7,9 @@
#include "runtime/os_interface/windows/wddm_memory_operations_handler.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/wddm_allocation.h"
#include "runtime/os_interface/windows/wddm_residency_allocations_container.h"
#include "engine_limits.h"
namespace NEO {
WddmMemoryOperationsHandler::WddmMemoryOperationsHandler(Wddm *wddm) : wddm(wddm) {

View File

@ -300,7 +300,7 @@ bool WddmResidencyController::trimResidencyToBudget(uint64_t bytes) {
bool WddmResidencyController::makeResidentResidencyAllocations(const ResidencyContainer &allocationsForResidency) {
const size_t residencyCount = allocationsForResidency.size();
std::unique_ptr<D3DKMT_HANDLE[]> handlesForResidency(new D3DKMT_HANDLE[residencyCount * maxFragmentsCount * maxHandleCount]);
std::unique_ptr<D3DKMT_HANDLE[]> handlesForResidency(new D3DKMT_HANDLE[residencyCount * maxFragmentsCount * EngineLimits::maxHandleCount]);
uint32_t totalHandlesCount = 0;
auto lock = this->acquireLock();

View File

@ -16,6 +16,7 @@
#include "runtime/built_ins/built_ins.h"
#include "runtime/device/device.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/helpers/device_helpers.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/os_interface/os_interface.h"
#include "runtime/platform/platform.h"
@ -218,3 +219,18 @@ TEST(ExecutionEnvironment, givenUnproperSetCsrFlagValueWhenInitializingMemoryMan
executionEnvironment->initializeMemoryManager();
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
}
TEST(ExecutionEnvironment, whenCalculateMaxOsContexCountThenGlobalVariableHasProperValue) {
VariableBackup<uint32_t> osContextCountBackup(&MemoryManager::maxOsContextCount);
ExecutionEnvironment executionEnvironment;
uint32_t numRootDevices = 17u;
auto &hwHelper = HwHelper::get(executionEnvironment.getHardwareInfo()->platform.eRenderCoreFamily);
auto osContextCount = hwHelper.getGpgpuEngineInstances().size();
auto subDevicesCount = DeviceHelper::getSubDevicesCount(executionEnvironment.getHardwareInfo());
bool hasRootCsr = subDevicesCount > 1;
executionEnvironment.prepareRootDeviceEnvironments(numRootDevices);
auto expectedOsContextCount = numRootDevices * osContextCount * subDevicesCount + hasRootCsr;
EXPECT_EQ(expectedOsContextCount, MemoryManager::maxOsContextCount);
}

View File

@ -17,16 +17,16 @@
namespace NEO {
namespace MockSipData {
static MockSipKernel mockSipKernel;
std::unique_ptr<MockSipKernel> mockSipKernel;
SipKernelType calledType = SipKernelType::COUNT;
bool called = false;
} // namespace MockSipData
const SipKernel &initSipKernel(SipKernelType type, Device &device) {
MockSipData::calledType = type;
MockSipData::mockSipKernel.type = type;
MockSipData::mockSipKernel->type = type;
MockSipData::called = true;
return MockSipData::mockSipKernel;
return *MockSipData::mockSipKernel;
}
Program *createProgramForSip(ExecutionEnvironment &executionEnvironment,
Context *context,

View File

@ -49,6 +49,10 @@ extern TestMode testMode;
extern const char *executionDirectorySuffix;
std::thread::id tempThreadID;
namespace MockSipData {
extern std::unique_ptr<MockSipKernel> mockSipKernel;
}
} // namespace NEO
namespace Os {
extern const char *gmmDllName;
@ -140,6 +144,7 @@ LONG WINAPI UltExceptionFilter(
void initializeTestHelpers() {
GlobalMockSipProgram::initSipProgram();
MockSipData::mockSipKernel.reset(new MockSipKernel());
}
void cleanTestHelpers() {

View File

@ -27,7 +27,7 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenSetAdditionalDataThenAdd
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenIsCreatedThenAllInspectionIdsAreSetToZero) {
MockGraphicsAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 0, MemoryPool::MemoryNull);
for (auto i = 0u; i < maxOsContextCount; i++) {
for (auto i = 0u; i < MemoryManager::maxOsContextCount; i++) {
EXPECT_EQ(0u, graphicsAllocation.getInspectionId(i));
}
}
@ -35,7 +35,7 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenIsCreatedThenAllInspecti
TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenIsCreatedThenTaskCountsAreInitializedProperly) {
GraphicsAllocation graphicsAllocation1(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 0, MemoryPool::MemoryNull);
GraphicsAllocation graphicsAllocation2(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 0, MemoryPool::MemoryNull);
for (auto i = 0u; i < maxOsContextCount; i++) {
for (auto i = 0u; i < MemoryManager::maxOsContextCount; i++) {
EXPECT_EQ(MockGraphicsAllocation::objectNotUsed, graphicsAllocation1.getTaskCount(i));
EXPECT_EQ(MockGraphicsAllocation::objectNotUsed, graphicsAllocation2.getTaskCount(i));
EXPECT_EQ(MockGraphicsAllocation::objectNotResident, graphicsAllocation1.getResidencyTaskCount(i));
@ -53,13 +53,13 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenUpdatedTaskCountThenOnly
MockGraphicsAllocation graphicsAllocation;
graphicsAllocation.updateTaskCount(1u, 0u);
EXPECT_EQ(1u, graphicsAllocation.getTaskCount(0u));
for (auto i = 1u; i < maxOsContextCount; i++) {
for (auto i = 1u; i < MemoryManager::maxOsContextCount; i++) {
EXPECT_EQ(MockGraphicsAllocation::objectNotUsed, graphicsAllocation.getTaskCount(i));
}
graphicsAllocation.updateTaskCount(2u, 1u);
EXPECT_EQ(1u, graphicsAllocation.getTaskCount(0u));
EXPECT_EQ(2u, graphicsAllocation.getTaskCount(1u));
for (auto i = 2u; i < maxOsContextCount; i++) {
for (auto i = 2u; i < MemoryManager::maxOsContextCount; i++) {
EXPECT_EQ(MockGraphicsAllocation::objectNotUsed, graphicsAllocation.getTaskCount(i));
}
}

View File

@ -9,6 +9,7 @@
#include "core/helpers/cache_policy.h"
#include "core/memory_manager/graphics_allocation.h"
#include "core/memory_manager/memory_constants.h"
#include "core/memory_manager/residency.h"
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
#include "runtime/event/event.h"
#include "runtime/gmm_helper/page_table_mngr.h"
@ -1690,9 +1691,9 @@ TEST(ResidencyDataTest, givenTwoOsContextsWhenTheyAreRegisteredFromHigherToLower
EXPECT_EQ(1, memoryManager.registeredEngines[1].osContext->getRefInternalCount());
}
TEST(ResidencyDataTest, givenGpgpuEnginesWhenAskedForMaxOscontextCountThenValueIsGreaterOrEqual) {
TEST(ResidencyDataTest, givenGpgpuEnginesWhenAskedForMaxOsContextCountThenValueIsGreaterOrEqual) {
auto &engines = HwHelper::get(platformDevices[0]->platform.eRenderCoreFamily).getGpgpuEngineInstances();
EXPECT_TRUE(maxOsContextCount >= engines.size());
EXPECT_TRUE(MemoryManager::maxOsContextCount >= engines.size());
}
TEST(ResidencyDataTest, givenResidencyDataWhenUpdateCompletionDataIsCalledThenItIsProperlyUpdated) {
@ -1709,16 +1710,16 @@ TEST(ResidencyDataTest, givenResidencyDataWhenUpdateCompletionDataIsCalledThenIt
auto lastFenceValue2 = 23llu;
auto lastFenceValue3 = 373llu;
EXPECT_EQ(maxOsContextCount, residency.lastFenceValues.size());
EXPECT_EQ(MemoryManager::maxOsContextCount, residency.lastFenceValues.size());
residency.updateCompletionData(lastFenceValue, osContext.getContextId());
EXPECT_EQ(maxOsContextCount, residency.lastFenceValues.size());
EXPECT_EQ(MemoryManager::maxOsContextCount, residency.lastFenceValues.size());
EXPECT_EQ(lastFenceValue, residency.lastFenceValues[0]);
EXPECT_EQ(lastFenceValue, residency.getFenceValueForContextId(osContext.getContextId()));
residency.updateCompletionData(lastFenceValue2, osContext2.getContextId());
EXPECT_EQ(maxOsContextCount, residency.lastFenceValues.size());
EXPECT_EQ(MemoryManager::maxOsContextCount, residency.lastFenceValues.size());
EXPECT_EQ(lastFenceValue2, residency.lastFenceValues[1]);
EXPECT_EQ(lastFenceValue2, residency.getFenceValueForContextId(osContext2.getContextId()));

View File

@ -36,14 +36,17 @@ cl_int GlobalMockSipProgram::processGenBinaryOnce() {
return ret;
}
void GlobalMockSipProgram::resetAllocationState() {
for (uint32_t index = 0u; index < maxOsContextCount; index++) {
auto allocation = static_cast<MockGraphicsAllocation *>(this->kernelInfoArray[0]->kernelAllocation);
for (uint32_t index = 0u; index < allocation->usageInfos.size(); index++) {
this->kernelInfoArray[0]->kernelAllocation->releaseResidencyInOsContext(index);
}
static_cast<MockGraphicsAllocation *>(this->kernelInfoArray[0]->kernelAllocation)->resetInspectionIds();
allocation->resetInspectionIds();
}
void GlobalMockSipProgram::initSipProgram() {
cl_int retVal = 0;
std::vector<char> binary = MockCompilerInterface::getDummyGenBinary();
executionEnvironment.setHwInfo(*platformDevices);
executionEnvironment.prepareRootDeviceEnvironments(1u);
sipProgram = Program::createFromGenBinary<GlobalMockSipProgram>(executionEnvironment,
nullptr,
binary.data(),

View File

@ -14,7 +14,6 @@
#include "runtime/os_interface/os_inc_base.h"
#include "unit_tests/helpers/test_files.h"
#include "unit_tests/mocks/mock_compilers.h"
#include "unit_tests/mocks/mock_execution_environment.h"
#include "unit_tests/mocks/mock_program.h"
#include "cif/macros/enable.h"
@ -24,9 +23,6 @@
#include <map>
namespace NEO {
static MockExecutionEnvironment mockExecEnv;
MockSipKernel::MockSipKernel(SipKernelType type, Program *sipProgram) : SipKernel(type, sipProgram) {
this->mockSipMemoryAllocation =
std::make_unique<MemoryAllocation>(0u,
@ -47,7 +43,7 @@ MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, nullptr) {
0u,
MemoryConstants::pageSize,
MemoryPool::System4KBPages);
this->program = new MockProgram(mockExecEnv, nullptr, false);
this->program = new MockProgram(this->executionEnvironment, nullptr, false);
}
MockSipKernel::~MockSipKernel() = default;
@ -81,4 +77,4 @@ void MockSipKernel::shutDown() {
GraphicsAllocation *MockSipKernel::getSipAllocation() const {
return mockSipMemoryAllocation.get();
}
} // namespace NEO
} // namespace NEO

View File

@ -8,6 +8,7 @@
#pragma once
#include "runtime/built_ins/sip.h"
#include "unit_tests/mocks/mock_execution_environment.h"
#include <memory>
#include <vector>
@ -33,5 +34,6 @@ class MockSipKernel : public SipKernel {
GraphicsAllocation *getSipAllocation() const override;
std::unique_ptr<MemoryAllocation> mockSipMemoryAllocation;
MockExecutionEnvironment executionEnvironment;
};
} // namespace NEO
} // namespace NEO

View File

@ -8,6 +8,7 @@
#include "core/command_stream/preemption.h"
#include "core/gmm_helper/gmm_helper.h"
#include "core/memory_manager/graphics_allocation.h"
#include "core/memory_manager/residency.h"
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
#include "runtime/gmm_helper/page_table_mngr.h"
#include "runtime/gmm_helper/resource_info.h"
@ -818,15 +819,15 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenDrmAllocationWhenGetBuffer
auto allocation = new DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, size, (osHandle)0u, MemoryPool::MemoryNull);
auto &bos = allocation->getBOs();
for (auto handleId = 0u; handleId < maxHandleCount; handleId++) {
for (auto handleId = 0u; handleId < EngineLimits::maxHandleCount; handleId++) {
EXPECT_EQ(nullptr, bos[handleId]);
}
for (auto handleId = 0u; handleId < maxHandleCount; handleId++) {
for (auto handleId = 0u; handleId < EngineLimits::maxHandleCount; handleId++) {
allocation->getBufferObjectToModify(handleId) = this->createBO(size);
}
for (auto handleId = 0u; handleId < maxHandleCount; handleId++) {
for (auto handleId = 0u; handleId < EngineLimits::maxHandleCount; handleId++) {
EXPECT_NE(nullptr, bos[handleId]);
}

View File

@ -14,6 +14,7 @@
#include "core/helpers/ptr_math.h"
#include "core/memory_manager/host_ptr_manager.h"
#include "core/memory_manager/memory_constants.h"
#include "core/memory_manager/residency.h"
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
#include "runtime/command_stream/device_command_stream.h"
#include "runtime/event/event.h"
@ -3266,7 +3267,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryCallSequenceTest, givenDrmMemoryManagerAn
{
::testing::InSequence inSequence;
EXPECT_CALL(gmockDrmMemoryManager, unreference(::testing::_, true)).Times(maxHandleCount);
EXPECT_CALL(gmockDrmMemoryManager, unreference(::testing::_, true)).Times(EngineLimits::maxHandleCount);
EXPECT_CALL(gmockDrmMemoryManager, releaseGpuRange(::testing::_, ::testing::_, ::testing::_)).Times(1);
EXPECT_CALL(gmockDrmMemoryManager, alignedFreeWrapper(::testing::_)).Times(1);
}
@ -3286,7 +3287,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest, givenDrmMemoryManagerAnd
ASSERT_NE(nullptr, allocation);
EXPECT_CALL(gmockDrmMemoryManager, unreference(::testing::_, false)).Times(1);
EXPECT_CALL(gmockDrmMemoryManager, unreference(::testing::_, true)).Times(maxHandleCount - 1);
EXPECT_CALL(gmockDrmMemoryManager, unreference(::testing::_, true)).Times(EngineLimits::maxHandleCount - 1);
gmockDrmMemoryManager.freeGraphicsMemory(allocation);
}

View File

@ -56,7 +56,7 @@ void WddmMemoryManagerFixture::SetUp() {
TEST(ResidencyData, givenNewlyConstructedResidencyDataThenItIsNotResidentOnAnyOsContext) {
ResidencyData residencyData;
for (auto contextId = 0u; contextId < maxOsContextCount; contextId++) {
for (auto contextId = 0u; contextId < MemoryManager::maxOsContextCount; contextId++) {
EXPECT_EQ(false, residencyData.resident[contextId]);
}
}

View File

@ -9,6 +9,7 @@
#include "core/helpers/options.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/platform/platform.h"
void NEO::UltConfigListener::OnTestStart(const ::testing::TestInfo &testInfo) {
@ -20,4 +21,5 @@ void NEO::UltConfigListener::OnTestStart(const ::testing::TestInfo &testInfo) {
void NEO::UltConfigListener::OnTestEnd(const ::testing::TestInfo &testInfo) {
// Clear global platform that it shouldn't be reused between tests
platformImpl.reset();
MemoryManager::maxOsContextCount = 0u;
}

View File

@ -26,11 +26,9 @@ HWTEST_F(GetDevicesTests, WhenGetDevicesIsCalledThenSuccessIsReturned) {
HWTEST_F(GetDevicesTests, whenGetDevicesIsCalledThenGmmIsBeingInitializedAfterFillingHwInfo) {
platformImpl.reset(new Platform());
size_t numDevicesReturned = 0;
HardwareInfo hwInfo;
hwInfo.platform.eProductFamily = PRODUCT_FAMILY::IGFX_UNKNOWN;
hwInfo.platform.eRenderCoreFamily = GFXCORE_FAMILY::IGFX_UNKNOWN_CORE;
hwInfo.platform.ePCHProductFamily = PCH_PRODUCT_FAMILY::PCH_UNKNOWN;
platform()->peekExecutionEnvironment()->setHwInfo(&hwInfo);
auto hwInfo = platform()->peekExecutionEnvironment()->getMutableHardwareInfo();
hwInfo->platform.eProductFamily = PRODUCT_FAMILY::IGFX_UNKNOWN;
hwInfo->platform.ePCHProductFamily = PCH_PRODUCT_FAMILY::PCH_UNKNOWN;
auto returnValue = DeviceFactory::getDevices(numDevicesReturned, *platform()->peekExecutionEnvironment());
EXPECT_TRUE(returnValue);