Use StackVec in Buffer::create instead of std::map
Related-To: NEO-4589 Change-Id: I9aa3a5de7e4e86b85c4589901a81a5b9633fc23f Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
parent
1d74871f85
commit
0f31b5cc8b
|
@ -173,12 +173,14 @@ Buffer *Buffer::create(Context *context,
|
||||||
auto maxRootDeviceIndex = context->getMaxRootDeviceIndex();
|
auto maxRootDeviceIndex = context->getMaxRootDeviceIndex();
|
||||||
auto multiGraphicsAllocation = MultiGraphicsAllocation(maxRootDeviceIndex);
|
auto multiGraphicsAllocation = MultiGraphicsAllocation(maxRootDeviceIndex);
|
||||||
|
|
||||||
std::map<uint32_t, CreateBuffer::AllocationInfo> allocationInfo;
|
AllocationInfoType allocationInfo;
|
||||||
|
allocationInfo.resize(maxRootDeviceIndex + 1u);
|
||||||
|
|
||||||
void *ptr = nullptr;
|
void *ptr = nullptr;
|
||||||
bool forceCopyHostPtr = false;
|
bool forceCopyHostPtr = false;
|
||||||
|
|
||||||
for (auto &rootDeviceIndex : context->getRootDeviceIndices()) {
|
for (auto &rootDeviceIndex : context->getRootDeviceIndices()) {
|
||||||
allocationInfo.insert({rootDeviceIndex, {}});
|
allocationInfo[rootDeviceIndex] = {};
|
||||||
|
|
||||||
auto hwInfo = (&memoryManager->peekExecutionEnvironment())->rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
auto hwInfo = (&memoryManager->peekExecutionEnvironment())->rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
||||||
|
|
||||||
|
@ -732,7 +734,7 @@ bool Buffer::isCompressed(uint32_t rootDeviceIndex) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::cleanAllGraphicsAllocations(Context &context, MemoryManager &memoryManager, std::map<uint32_t, NEO::CreateBuffer::AllocationInfo> &allocationInfo) {
|
void Buffer::cleanAllGraphicsAllocations(Context &context, MemoryManager &memoryManager, AllocationInfoType &allocationInfo) {
|
||||||
for (auto &index : context.getRootDeviceIndices()) {
|
for (auto &index : context.getRootDeviceIndices()) {
|
||||||
if (allocationInfo[index].memory) {
|
if (allocationInfo[index].memory) {
|
||||||
memoryManager.removeAllocationFromHostPtrManager(allocationInfo[index].memory);
|
memoryManager.removeAllocationFromHostPtrManager(allocationInfo[index].memory);
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "memory_properties_flags.h"
|
#include "memory_properties_flags.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
class Device;
|
class Device;
|
||||||
|
@ -69,6 +68,8 @@ struct AllocationInfo {
|
||||||
};
|
};
|
||||||
} // namespace CreateBuffer
|
} // namespace CreateBuffer
|
||||||
|
|
||||||
|
using AllocationInfoType = StackVec<CreateBuffer::AllocationInfo, 1>;
|
||||||
|
|
||||||
class Buffer : public MemObj {
|
class Buffer : public MemObj {
|
||||||
public:
|
public:
|
||||||
constexpr static size_t maxBufferSizeForReadWriteOnCpu = 10 * MB;
|
constexpr static size_t maxBufferSizeForReadWriteOnCpu = 10 * MB;
|
||||||
|
@ -173,7 +174,7 @@ class Buffer : public MemObj {
|
||||||
|
|
||||||
bool isCompressed(uint32_t rootDeviceIndex) const;
|
bool isCompressed(uint32_t rootDeviceIndex) const;
|
||||||
|
|
||||||
static void cleanAllGraphicsAllocations(Context &context, MemoryManager &memoryManager, std::map<uint32_t, NEO::CreateBuffer::AllocationInfo> &allocationInfo);
|
static void cleanAllGraphicsAllocations(Context &context, MemoryManager &memoryManager, AllocationInfoType &allocationInfo);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Buffer(Context *context,
|
Buffer(Context *context,
|
||||||
|
|
|
@ -1810,9 +1810,10 @@ TEST_F(BufferTransferTests, givenBufferWhenTransferFromHostPtrCalledThenCopyRequ
|
||||||
using MultiRootDeviceBufferTest = MultiRootDeviceFixture;
|
using MultiRootDeviceBufferTest = MultiRootDeviceFixture;
|
||||||
|
|
||||||
TEST_F(MultiRootDeviceBufferTest, WhenCleanAllGraphicsAllocationsCalledThenGraphicsAllocationsAreProperlyRemoved) {
|
TEST_F(MultiRootDeviceBufferTest, WhenCleanAllGraphicsAllocationsCalledThenGraphicsAllocationsAreProperlyRemoved) {
|
||||||
std::map<uint32_t, NEO::CreateBuffer::AllocationInfo> allocationInfo;
|
AllocationInfoType allocationInfo;
|
||||||
|
allocationInfo.resize(3u);
|
||||||
|
|
||||||
allocationInfo.insert({1u, {}});
|
allocationInfo[1u] = {};
|
||||||
allocationInfo[1u].memory = mockMemoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{1u, MemoryConstants::pageSize});
|
allocationInfo[1u].memory = mockMemoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{1u, MemoryConstants::pageSize});
|
||||||
|
|
||||||
Buffer::cleanAllGraphicsAllocations(*context, *context->getMemoryManager(), allocationInfo);
|
Buffer::cleanAllGraphicsAllocations(*context, *context->getMemoryManager(), allocationInfo);
|
||||||
|
|
Loading…
Reference in New Issue