Add memory banks to Simulated CSR

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-06-29 16:23:56 +00:00
committed by Compute-Runtime-Automation
parent 2ce3a223f0
commit c7a936d1f4
24 changed files with 913 additions and 75 deletions

View File

@@ -11,8 +11,9 @@
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
#include "shared/source/memory_manager/page_table.h"
#include "opencl/source/command_stream/definitions/command_stream_receiver_simulated_hw.h"
#include "aub_mapper.h"
#include "command_stream_receiver_simulated_hw.h"
#include <set>

View File

@@ -18,7 +18,7 @@ set(NEO_CORE_MEMORY_MANAGER
${CMAKE_CURRENT_SOURCE_DIR}/deferrable_deletion.h
${CMAKE_CURRENT_SOURCE_DIR}/deferred_deleter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/deferred_deleter.h
${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/engine_limits.h
${CMAKE_CURRENT_SOURCE_DIR}/definitions/engine_limits.h
${CMAKE_CURRENT_SOURCE_DIR}/definitions/storage_info.cpp
${CMAKE_CURRENT_SOURCE_DIR}/definitions/storage_info.h
${CMAKE_CURRENT_SOURCE_DIR}/eviction_status.h
@@ -27,7 +27,6 @@ set(NEO_CORE_MEMORY_MANAGER
${CMAKE_CURRENT_SOURCE_DIR}/gfx_partition.h
${CMAKE_CURRENT_SOURCE_DIR}/graphics_allocation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/graphics_allocation.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/graphics_allocation_extra.cpp
${CMAKE_CURRENT_SOURCE_DIR}/host_ptr_defines.h
${CMAKE_CURRENT_SOURCE_DIR}/host_ptr_manager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/host_ptr_manager.h
@@ -53,7 +52,6 @@ set(NEO_CORE_MEMORY_MANAGER
${CMAKE_CURRENT_SOURCE_DIR}/surface.h
${CMAKE_CURRENT_SOURCE_DIR}/unified_memory_manager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/unified_memory_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/${BRANCH_DIR_SUFFIX}/unified_memory_manager_extra.cpp
${CMAKE_CURRENT_SOURCE_DIR}/page_table.cpp
${CMAKE_CURRENT_SOURCE_DIR}/page_table.h
${CMAKE_CURRENT_SOURCE_DIR}/page_table.inl

View File

@@ -11,7 +11,7 @@
namespace NEO {
namespace EngineLimits {
constexpr uint32_t maxHandleCount = 1u;
constexpr uint32_t maxHandleCount = 4u;
}; // namespace EngineLimits
} // namespace NEO

View File

@@ -80,6 +80,24 @@ bool GraphicsAllocation::isAllocationLockable() const {
return 0 == gmm->resourceParams.Flags.Info.NotLockable;
}
void GraphicsAllocation::setAubWritable(bool writable, uint32_t banks) {
UNRECOVERABLE_IF(banks == 0);
aubInfo.aubWritable = static_cast<uint32_t>(setBits(aubInfo.aubWritable, writable, banks));
}
bool GraphicsAllocation::isAubWritable(uint32_t banks) const {
return isAnyBitSet(aubInfo.aubWritable, banks);
}
void GraphicsAllocation::setTbxWritable(bool writable, uint32_t banks) {
UNRECOVERABLE_IF(banks == 0);
aubInfo.tbxWritable = static_cast<uint32_t>(setBits(aubInfo.tbxWritable, writable, banks));
}
bool GraphicsAllocation::isTbxWritable(uint32_t banks) const {
return isAnyBitSet(aubInfo.tbxWritable, banks);
}
constexpr uint32_t GraphicsAllocation::objectNotUsed;
constexpr uint32_t GraphicsAllocation::objectNotResident;
constexpr uint32_t GraphicsAllocation::objectAlwaysResident;

View File

@@ -10,14 +10,13 @@
#include "shared/source/helpers/constants.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/ptr_math.h"
#include "shared/source/memory_manager/definitions/engine_limits.h"
#include "shared/source/memory_manager/definitions/storage_info.h"
#include "shared/source/memory_manager/host_ptr_defines.h"
#include "shared/source/memory_manager/memory_pool.h"
#include "shared/source/utilities/idlist.h"
#include "shared/source/utilities/stackvec.h"
#include "engine_limits.h"
#include <array>
#include <atomic>
#include <cstddef>

View File

@@ -1,17 +0,0 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/memory_manager/graphics_allocation.h"
namespace NEO {
void GraphicsAllocation::setAubWritable(bool writable, uint32_t banks) { aubInfo.aubWritable = writable; }
bool GraphicsAllocation::isAubWritable(uint32_t banks) const { return (aubInfo.aubWritable != 0); }
void GraphicsAllocation::setTbxWritable(bool writable, uint32_t banks) { aubInfo.tbxWritable = writable; }
bool GraphicsAllocation::isTbxWritable(uint32_t banks) const { return (aubInfo.tbxWritable != 0); }
} // namespace NEO

View File

@@ -496,4 +496,20 @@ void SVMAllocsManager::removeSvmMapOperation(const void *regionSvmPtr) {
svmMapOperations.remove(regionSvmPtr);
}
GraphicsAllocation::AllocationType SVMAllocsManager::getGraphicsAllocationType(const UnifiedMemoryProperties &unifiedMemoryProperties) const {
GraphicsAllocation::AllocationType allocationType = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
if (unifiedMemoryProperties.memoryType == InternalMemoryType::DEVICE_UNIFIED_MEMORY) {
if (unifiedMemoryProperties.allocationFlags.allocFlags.allocWriteCombined) {
allocationType = GraphicsAllocation::AllocationType::WRITE_COMBINED;
} else {
if (DebugManager.flags.EnableStatelessCompression.get()) {
allocationType = GraphicsAllocation::AllocationType::BUFFER_COMPRESSED;
} else {
allocationType = GraphicsAllocation::AllocationType::BUFFER;
}
}
}
return allocationType;
}
} // namespace NEO

View File

@@ -1,24 +0,0 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/memory_manager/unified_memory_manager.h"
namespace NEO {
GraphicsAllocation::AllocationType SVMAllocsManager::getGraphicsAllocationType(const UnifiedMemoryProperties &unifiedMemoryProperties) const {
GraphicsAllocation::AllocationType allocationType = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
if (unifiedMemoryProperties.memoryType == InternalMemoryType::DEVICE_UNIFIED_MEMORY) {
if (unifiedMemoryProperties.allocationFlags.allocFlags.allocWriteCombined) {
allocationType = GraphicsAllocation::AllocationType::WRITE_COMBINED;
} else {
allocationType = GraphicsAllocation::AllocationType::BUFFER;
}
}
return allocationType;
}
} // namespace NEO

View File

@@ -7,11 +7,11 @@
#pragma once
#include "shared/source/memory_manager/definitions/engine_limits.h"
#include "shared/source/os_interface/linux/cache_info.h"
#include "shared/source/utilities/stackvec.h"
#include "drm/i915_drm.h"
#include "engine_limits.h"
#include <array>
#include <atomic>

View File

@@ -8,6 +8,7 @@
#pragma once
#include "shared/source/gmm_helper/gmm_lib.h"
#include "shared/source/helpers/basic_math.h"
#include "shared/source/memory_manager/definitions/engine_limits.h"
#include "shared/source/os_interface/driver_info.h"
#include "shared/source/os_interface/linux/cache_info.h"
#include "shared/source/os_interface/linux/engine_info.h"
@@ -18,7 +19,6 @@
#include "shared/source/utilities/stackvec.h"
#include "drm/i915_drm.h"
#include "engine_limits.h"
#include "engine_node.h"
#include "igfxfmid.h"

View File

@@ -7,7 +7,9 @@
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "gtest/gtest.h"
#include "opencl/test/unit_test/mocks/mock_aub_csr.h"
#include "opencl/test/unit_test/mocks/mock_execution_environment.h"
#include "test.h"
using namespace NEO;
@@ -237,3 +239,164 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenQueryingUsedPageSizeThen
EXPECT_EQ(MemoryConstants::pageSize64k, graphicsAllocation.getUsedPageSize());
}
}
struct GraphicsAllocationTests : public ::testing::Test {
template <typename GfxFamily>
void initializeCsr() {
executionEnvironment.initializeMemoryManager();
DeviceBitfield deviceBitfield(3);
auto csr = new MockAubCsr<GfxFamily>("", true, executionEnvironment, 0, deviceBitfield);
csr->multiOsContextCapable = true;
aubCsr.reset(csr);
}
template <typename GfxFamily>
MockAubCsr<GfxFamily> &getAubCsr() {
return *(static_cast<MockAubCsr<GfxFamily> *>(aubCsr.get()));
}
void gfxAllocationSetToDefault() {
graphicsAllocation.storageInfo.readOnlyMultiStorage = false;
graphicsAllocation.storageInfo.memoryBanks = 0;
graphicsAllocation.overrideMemoryPool(MemoryPool::MemoryNull);
}
void gfxAllocationEnableReadOnlyMultiStorage(uint32_t banks) {
graphicsAllocation.storageInfo.cloningOfPageTables = false;
graphicsAllocation.storageInfo.readOnlyMultiStorage = true;
graphicsAllocation.storageInfo.memoryBanks = banks;
graphicsAllocation.overrideMemoryPool(MemoryPool::LocalMemory);
}
MockExecutionEnvironment executionEnvironment;
std::unique_ptr<CommandStreamReceiver> aubCsr;
MockGraphicsAllocation graphicsAllocation;
};
HWTEST_F(GraphicsAllocationTests, givenGraphicsAllocationWhenIsAubWritableIsCalledThenTrueIsReturned) {
initializeCsr<FamilyType>();
auto &aubCsr = getAubCsr<FamilyType>();
gfxAllocationSetToDefault();
EXPECT_TRUE(aubCsr.isAubWritable(graphicsAllocation));
gfxAllocationEnableReadOnlyMultiStorage(0b1111);
EXPECT_TRUE(aubCsr.isAubWritable(graphicsAllocation));
}
HWTEST_F(GraphicsAllocationTests, givenGraphicsAllocationThatHasPageTablesCloningWhenWriteableFlagsAreUsedThenDefaultBankIsUsed) {
initializeCsr<FamilyType>();
auto &aubCsr = getAubCsr<FamilyType>();
gfxAllocationSetToDefault();
graphicsAllocation.storageInfo.memoryBanks = 0x2;
graphicsAllocation.overrideMemoryPool(MemoryPool::LocalMemory);
graphicsAllocation.storageInfo.cloningOfPageTables = true;
EXPECT_TRUE(aubCsr.isAubWritable(graphicsAllocation));
//modify non default bank
graphicsAllocation.setAubWritable(false, 0x2);
EXPECT_TRUE(aubCsr.isAubWritable(graphicsAllocation));
aubCsr.setAubWritable(false, graphicsAllocation);
EXPECT_FALSE(aubCsr.isAubWritable(graphicsAllocation));
EXPECT_TRUE(aubCsr.isTbxWritable(graphicsAllocation));
graphicsAllocation.setTbxWritable(false, 0x2);
EXPECT_TRUE(aubCsr.isTbxWritable(graphicsAllocation));
aubCsr.setTbxWritable(false, graphicsAllocation);
EXPECT_FALSE(aubCsr.isTbxWritable(graphicsAllocation));
}
HWTEST_F(GraphicsAllocationTests, givenGraphicsAllocationWhenAubWritableIsSetToFalseThenAubWritableIsFalse) {
initializeCsr<FamilyType>();
auto &aubCsr = getAubCsr<FamilyType>();
gfxAllocationSetToDefault();
aubCsr.setAubWritable(false, graphicsAllocation);
EXPECT_FALSE(aubCsr.isAubWritable(graphicsAllocation));
gfxAllocationEnableReadOnlyMultiStorage(0b1111);
aubCsr.setAubWritable(false, graphicsAllocation);
EXPECT_FALSE(aubCsr.isAubWritable(graphicsAllocation));
}
HWTEST_F(GraphicsAllocationTests, givenMultiStorageGraphicsAllocationWhenAubWritableIsSetOnSpecificBanksThenCorrectValuesAreSet) {
initializeCsr<FamilyType>();
auto &aubCsr = getAubCsr<FamilyType>();
gfxAllocationEnableReadOnlyMultiStorage(0b1010);
aubCsr.setAubWritable(false, graphicsAllocation);
EXPECT_EQ(graphicsAllocation.aubInfo.aubWritable, maxNBitValue(32) & ~(0b1010));
EXPECT_FALSE(graphicsAllocation.isAubWritable(0b10));
EXPECT_FALSE(graphicsAllocation.isAubWritable(0b1000));
EXPECT_FALSE(graphicsAllocation.isAubWritable(0b1010));
EXPECT_TRUE(graphicsAllocation.isAubWritable(0b1));
EXPECT_TRUE(graphicsAllocation.isAubWritable(0b100));
EXPECT_TRUE(graphicsAllocation.isAubWritable(0b101));
aubCsr.setAubWritable(true, graphicsAllocation);
EXPECT_EQ(graphicsAllocation.aubInfo.aubWritable, maxNBitValue(32));
EXPECT_TRUE(graphicsAllocation.isAubWritable(0b1));
EXPECT_TRUE(graphicsAllocation.isAubWritable(0b10));
EXPECT_TRUE(graphicsAllocation.isAubWritable(0b100));
EXPECT_TRUE(graphicsAllocation.isAubWritable(0b1000));
EXPECT_TRUE(graphicsAllocation.isAubWritable(0b101));
EXPECT_TRUE(graphicsAllocation.isAubWritable(0b1010));
}
HWTEST_F(GraphicsAllocationTests, givenGraphicsAllocationWhenIsTbxWritableIsCalledThenTrueIsReturned) {
initializeCsr<FamilyType>();
auto &aubCsr = getAubCsr<FamilyType>();
gfxAllocationSetToDefault();
EXPECT_TRUE(aubCsr.isTbxWritable(graphicsAllocation));
gfxAllocationEnableReadOnlyMultiStorage(0b1111);
EXPECT_TRUE(aubCsr.isTbxWritable(graphicsAllocation));
};
HWTEST_F(GraphicsAllocationTests, givenGraphicsAllocationWhenTbxWritableIsSetToFalseThenTbxWritableIsFalse) {
initializeCsr<FamilyType>();
auto &aubCsr = getAubCsr<FamilyType>();
gfxAllocationSetToDefault();
aubCsr.setTbxWritable(false, graphicsAllocation);
EXPECT_FALSE(aubCsr.isTbxWritable(graphicsAllocation));
gfxAllocationEnableReadOnlyMultiStorage(0b1111);
aubCsr.setTbxWritable(false, graphicsAllocation);
EXPECT_FALSE(aubCsr.isTbxWritable(graphicsAllocation));
}
HWTEST_F(GraphicsAllocationTests, givenMultiStorageGraphicsAllocationWhenTbxWritableIsSetOnSpecificBanksThenCorrectValuesAreSet) {
initializeCsr<FamilyType>();
auto &aubCsr = getAubCsr<FamilyType>();
gfxAllocationEnableReadOnlyMultiStorage(0b1010);
aubCsr.setTbxWritable(false, graphicsAllocation);
EXPECT_EQ(graphicsAllocation.aubInfo.tbxWritable, maxNBitValue(32) & ~(0b1010));
EXPECT_FALSE(graphicsAllocation.isTbxWritable(0b10));
EXPECT_FALSE(graphicsAllocation.isTbxWritable(0b1000));
EXPECT_FALSE(graphicsAllocation.isTbxWritable(0b1010));
EXPECT_TRUE(graphicsAllocation.isTbxWritable(0b1));
EXPECT_TRUE(graphicsAllocation.isTbxWritable(0b100));
EXPECT_TRUE(graphicsAllocation.isTbxWritable(0b101));
aubCsr.setTbxWritable(true, graphicsAllocation);
EXPECT_EQ(graphicsAllocation.aubInfo.tbxWritable, maxNBitValue(32));
EXPECT_TRUE(graphicsAllocation.isTbxWritable(0b1));
EXPECT_TRUE(graphicsAllocation.isTbxWritable(0b10));
EXPECT_TRUE(graphicsAllocation.isTbxWritable(0b100));
EXPECT_TRUE(graphicsAllocation.isTbxWritable(0b1000));
EXPECT_TRUE(graphicsAllocation.isTbxWritable(0b101));
EXPECT_TRUE(graphicsAllocation.isTbxWritable(0b1010));
}