Add function to create devices bitfield based on allocation properties
Change-Id: Ic70443b1fb6106186efcff318690e434dc1db625 Signed-off-by: Jablonski, Mateusz <mateusz.jablonski@intel.com>
This commit is contained in:
parent
ce77425428
commit
798137e4bb
|
@ -215,7 +215,7 @@ LinearStream &CommandQueue::getCS(size_t minRequiredSize) {
|
|||
GraphicsAllocation *allocation = storageForAllocation->obtainReusableAllocation(minRequiredSize, allocationType).release();
|
||||
|
||||
if (!allocation) {
|
||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties({minRequiredSize, allocationType});
|
||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties({true, minRequiredSize, allocationType, getCommandStreamReceiver().isMultiOsContextCapable()});
|
||||
}
|
||||
|
||||
// Deallocate the old block, if not null
|
||||
|
|
|
@ -121,6 +121,10 @@ MemoryManager *CommandStreamReceiver::getMemoryManager() const {
|
|||
return executionEnvironment.memoryManager.get();
|
||||
}
|
||||
|
||||
bool CommandStreamReceiver::isMultiOsContextCapable() const {
|
||||
return executionEnvironment.specialCommandStreamReceiver.get() == this;
|
||||
}
|
||||
|
||||
LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) {
|
||||
if (commandStream.getAvailableSpace() < minRequiredSize) {
|
||||
// Make sure we have enough room for a MI_BATCH_BUFFER_END and any padding.
|
||||
|
@ -133,7 +137,7 @@ LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) {
|
|||
auto allocationType = GraphicsAllocation::AllocationType::COMMAND_BUFFER;
|
||||
auto allocation = internalAllocationStorage->obtainReusableAllocation(minRequiredSize, allocationType).release();
|
||||
if (!allocation) {
|
||||
allocation = getMemoryManager()->allocateGraphicsMemoryWithProperties({minRequiredSize, allocationType});
|
||||
allocation = getMemoryManager()->allocateGraphicsMemoryWithProperties({true, minRequiredSize, allocationType, isMultiOsContextCapable()});
|
||||
}
|
||||
|
||||
//pass current allocation to reusable list
|
||||
|
|
|
@ -173,6 +173,7 @@ class CommandStreamReceiver {
|
|||
void setDisableL3Cache(bool val) {
|
||||
disableL3Cache = val;
|
||||
}
|
||||
bool isMultiOsContextCapable() const;
|
||||
|
||||
protected:
|
||||
void cleanupResources();
|
||||
|
|
|
@ -62,7 +62,7 @@ void ExperimentalCommandBuffer::getCS(size_t minRequiredSize) {
|
|||
auto allocationType = GraphicsAllocation::AllocationType::COMMAND_BUFFER;
|
||||
GraphicsAllocation *allocation = storageWithAllocations->obtainReusableAllocation(requiredSize, allocationType).release();
|
||||
if (!allocation) {
|
||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties({requiredSize, allocationType});
|
||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties({true, minRequiredSize, allocationType, commandStreamReceiver->isMultiOsContextCapable()});
|
||||
}
|
||||
// Deallocate the old block, if not null
|
||||
auto oldAllocation = currentStream->getGraphicsAllocation();
|
||||
|
|
|
@ -14,6 +14,7 @@ set(RUNTIME_SRCS_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}/devices_bitfield.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/definitions${BRANCH_DIR_SUFFIX}/devices_bitfield.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/graphics_allocation.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/graphics_allocation.h
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/memory_manager/graphics_allocation.h"
|
||||
|
||||
namespace OCLRT {
|
||||
DevicesBitfield GraphicsAllocation::createBitfieldFromProperties(const AllocationProperties &properties) {
|
||||
return {};
|
||||
}
|
||||
} // namespace OCLRT
|
|
@ -44,6 +44,7 @@ constexpr auto nonSharedResource = 0u;
|
|||
}
|
||||
|
||||
class Gmm;
|
||||
struct AllocationProperties;
|
||||
|
||||
class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
||||
public:
|
||||
|
@ -165,6 +166,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
|||
allocationType == AllocationType::TIMESTAMP_PACKET_TAG_BUFFER ||
|
||||
allocationType == AllocationType::COMMAND_BUFFER;
|
||||
}
|
||||
static DevicesBitfield createBitfieldFromProperties(const AllocationProperties &properties);
|
||||
|
||||
protected:
|
||||
constexpr static uint32_t objectNotResident = (uint32_t)-1;
|
||||
|
|
|
@ -60,11 +60,14 @@ struct AllocationProperties {
|
|||
AllocationProperties(size_t size, GraphicsAllocation::AllocationType allocationType)
|
||||
: AllocationProperties(true, size, allocationType) {}
|
||||
AllocationProperties(bool allocateMemory, size_t size, GraphicsAllocation::AllocationType allocationType)
|
||||
: AllocationProperties(allocateMemory, size, allocationType, false) {}
|
||||
AllocationProperties(bool allocateMemory, size_t size, GraphicsAllocation::AllocationType allocationType, bool multiOsContextCapable)
|
||||
: size(size), allocationType(allocationType) {
|
||||
allFlags = 0;
|
||||
flags.flushL3RequiredForRead = 1;
|
||||
flags.flushL3RequiredForWrite = 1;
|
||||
flags.allocateMemory = allocateMemory;
|
||||
flags.multiOsContextCapable = multiOsContextCapable;
|
||||
}
|
||||
AllocationProperties(ImageInfo *imgInfo, bool allocateMemory) : AllocationProperties(allocateMemory, 0, GraphicsAllocation::AllocationType::IMAGE) {
|
||||
this->imgInfo = imgInfo;
|
||||
|
@ -95,11 +98,11 @@ class MemoryManager {
|
|||
virtual void removeAllocationFromHostPtrManager(GraphicsAllocation *memory) = 0;
|
||||
|
||||
MOCKABLE_VIRTUAL GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties) {
|
||||
return allocateGraphicsMemoryInPreferredPool(properties, {}, nullptr);
|
||||
return allocateGraphicsMemoryInPreferredPool(properties, GraphicsAllocation::createBitfieldFromProperties(properties), nullptr);
|
||||
}
|
||||
|
||||
virtual GraphicsAllocation *allocateGraphicsMemory(const AllocationProperties &properties, const void *ptr) {
|
||||
return allocateGraphicsMemoryInPreferredPool(properties, {}, ptr);
|
||||
return allocateGraphicsMemoryInPreferredPool(properties, GraphicsAllocation::createBitfieldFromProperties(properties), ptr);
|
||||
}
|
||||
|
||||
GraphicsAllocation *allocateGraphicsMemoryForHostPtr(size_t size, void *ptr, bool fullRangeSvm, bool requiresL3Flush) {
|
||||
|
|
|
@ -49,6 +49,15 @@ struct CommandStreamReceiverTest : public DeviceFixture,
|
|||
CommandStreamReceiver *commandStreamReceiver;
|
||||
};
|
||||
|
||||
TEST_F(CommandStreamReceiverTest, whenCommandStreamReceiverIsSetAsSpecialCommandStreamReceiverInExecutionEnvironmentThenItIsMulitOsContextCapable) {
|
||||
EXPECT_FALSE(commandStreamReceiver->isMultiOsContextCapable());
|
||||
|
||||
auto executionEnvironment = pDevice->getExecutionEnvironment();
|
||||
executionEnvironment->specialCommandStreamReceiver.reset(commandStreamReceiver);
|
||||
EXPECT_TRUE(commandStreamReceiver->isMultiOsContextCapable());
|
||||
executionEnvironment->specialCommandStreamReceiver.release();
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverTest, testCtor) {
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
EXPECT_EQ(0u, csr.peekTaskLevel());
|
||||
|
|
|
@ -80,6 +80,20 @@ TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesCommandStrea
|
|||
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0].get());
|
||||
}
|
||||
|
||||
TEST(ExecutionEnvironment, whenPlatformIsInitializedThenOnlySpecialCommandStreamReceiverIsMultiOsContextCapable) {
|
||||
Platform platform;
|
||||
auto executionEnvironment = platform.peekExecutionEnvironment();
|
||||
platform.initialize();
|
||||
for (auto &csrContainer : executionEnvironment->commandStreamReceivers) {
|
||||
for (auto &csr : csrContainer) {
|
||||
EXPECT_FALSE(csr->isMultiOsContextCapable());
|
||||
}
|
||||
}
|
||||
if (executionEnvironment->specialCommandStreamReceiver) {
|
||||
EXPECT_TRUE(executionEnvironment->specialCommandStreamReceiver->isMultiOsContextCapable());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesMemoryManagerInExecutionEnvironment) {
|
||||
Platform platform;
|
||||
auto executionEnvironment = platform.peekExecutionEnvironment();
|
||||
|
|
Loading…
Reference in New Issue