Skip to content

Commit ab2134a

Browse files
Change subDeviceIndex to subDevicesBitfield in allocation properties
Related-To: NEO-3691 Change-Id: I11d235107bf9b4cee75b910c114795b5df76d9c7 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent ecc54ed commit ab2134a

File tree

7 files changed

+24
-16
lines changed

7 files changed

+24
-16
lines changed

core/command_container/cmdcontainer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ bool CommandContainer::initialize(Device *device) {
4747
heapHelper = std::unique_ptr<HeapHelper>(new HeapHelper(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumAvailableDevices() > 1u));
4848

4949
size_t alignedSize = alignUp<size_t>(totalCmdBufferSize, MemoryConstants::pageSize64k);
50-
NEO::AllocationProperties properties{0u, true /* allocateMemory*/, alignedSize,
50+
NEO::AllocationProperties properties{0u,
51+
true /* allocateMemory*/,
52+
alignedSize,
5153
GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
5254
(device->getNumAvailableDevices() > 1u) /* multiOsContextCapable */,
5355
false,
54-
NEO::SubDevice::unspecifiedSubDeviceIndex};
56+
{}};
5557

5658
cmdBufferAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
5759

core/helpers/heap_helper.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ GraphicsAllocation *HeapHelper::getHeapAllocation(size_t heapSize, size_t alignm
1717
if (allocation) {
1818
return allocation.release();
1919
}
20-
NEO::AllocationProperties properties{rootDeviceIndex, true /* allocateMemory*/, alignment,
20+
NEO::AllocationProperties properties{rootDeviceIndex,
21+
true /* allocateMemory*/,
22+
alignment,
2123
GraphicsAllocation::AllocationType::INTERNAL_HEAP,
22-
isMultiOsContextCapable /* multiOsContextCapable */,
23-
false,
24-
NEO::SubDevice::unspecifiedSubDeviceIndex};
24+
isMultiOsContextCapable,
25+
false /* isMultiStorageAllocation */,
26+
{}};
2527

2628
return this->memManager->allocateGraphicsMemoryWithProperties(properties);
2729
}
2830
void HeapHelper::storeHeapAllocation(GraphicsAllocation *heapAllocation) {
2931
this->storageForReuse->storeAllocation(std::unique_ptr<NEO::GraphicsAllocation>(heapAllocation), NEO::AllocationUsage::REUSABLE_ALLOCATION);
3032
}
31-
} // namespace NEO
33+
} // namespace NEO

core/program/sync_buffer_handler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void SyncBufferHandler::prepareForEnqueue(size_t workGroupsCount, Kernel &kernel
4343
void SyncBufferHandler::allocateNewBuffer() {
4444
AllocationProperties allocationProperties{device.getRootDeviceIndex(), true, bufferSize,
4545
GraphicsAllocation::AllocationType::LINEAR_STREAM,
46-
false, false, static_cast<uint32_t>(device.getDeviceBitfield().to_ulong())};
46+
false, false, device.getDeviceBitfield()};
4747
graphicsAllocation = memoryManager.allocateGraphicsMemoryWithProperties(allocationProperties);
4848
UNRECOVERABLE_IF(graphicsAllocation == nullptr);
4949

runtime/command_stream/command_stream_receiver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void CommandStreamReceiver::ensureCommandBufferAllocation(LinearStream &commandS
126126
auto allocation = this->getInternalAllocationStorage()->obtainReusableAllocation(allocationSize, allocationType).release();
127127
if (allocation == nullptr) {
128128
const AllocationProperties commandStreamAllocationProperties{rootDeviceIndex, true, allocationSize, allocationType,
129-
isMultiOsContextCapable(), false, getDeviceIndex()};
129+
isMultiOsContextCapable(), false, osContext->getDeviceBitfield()};
130130
allocation = this->getMemoryManager()->allocateGraphicsMemoryWithProperties(commandStreamAllocationProperties);
131131
}
132132
DEBUG_BREAK_IF(allocation == nullptr);
@@ -327,7 +327,7 @@ void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType,
327327

328328
if (!heapMemory) {
329329
heapMemory = getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex, true, finalHeapSize, allocationType,
330-
isMultiOsContextCapable(), false, getDeviceIndex()});
330+
isMultiOsContextCapable(), false, osContext->getDeviceBitfield()});
331331
} else {
332332
finalHeapSize = std::max(heapMemory->getUnderlyingBufferSize(), finalHeapSize);
333333
}

runtime/memory_manager/allocation_properties.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct AllocationProperties {
3232
GraphicsAllocation::AllocationType allocationType = GraphicsAllocation::AllocationType::UNKNOWN;
3333
ImageInfo *imgInfo = nullptr;
3434
bool multiStorageResource = false;
35-
uint32_t subDeviceIndex = SubDevice::unspecifiedSubDeviceIndex;
35+
DeviceBitfield subDevicesBitfield{};
3636

3737
AllocationProperties(uint32_t rootDeviceIndex, size_t size,
3838
GraphicsAllocation::AllocationType allocationType)
@@ -50,16 +50,20 @@ struct AllocationProperties {
5050
size_t size,
5151
GraphicsAllocation::AllocationType allocationType,
5252
bool isMultiStorageAllocation)
53-
: AllocationProperties(rootDeviceIndex, allocateMemory, size, allocationType, false, isMultiStorageAllocation, SubDevice::unspecifiedSubDeviceIndex) {}
53+
: AllocationProperties(rootDeviceIndex, allocateMemory, size, allocationType, false, isMultiStorageAllocation, {}) {}
5454

5555
AllocationProperties(uint32_t rootDeviceIndexParam,
5656
bool allocateMemoryParam,
5757
size_t sizeParam,
5858
GraphicsAllocation::AllocationType allocationTypeParam,
5959
bool multiOsContextCapableParam,
6060
bool isMultiStorageAllocationParam,
61-
uint32_t subDeviceIndexParam)
62-
: rootDeviceIndex(rootDeviceIndexParam), size(sizeParam), allocationType(allocationTypeParam), multiStorageResource(isMultiStorageAllocationParam), subDeviceIndex(subDeviceIndexParam) {
61+
DeviceBitfield subDevicesBitfieldParam)
62+
: rootDeviceIndex(rootDeviceIndexParam),
63+
size(sizeParam),
64+
allocationType(allocationTypeParam),
65+
multiStorageResource(isMultiStorageAllocationParam),
66+
subDevicesBitfield(subDevicesBitfieldParam) {
6367
allFlags = 0;
6468
flags.flushL3RequiredForRead = 1;
6569
flags.flushL3RequiredForWrite = 1;

unit_tests/memory_manager/memory_manager_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenCreateGraphicsAllocat
878878
osHandle handle = 1;
879879
auto size = 4096u;
880880
AllocationProperties properties(0u, false, size, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, false, 0u);
881-
EXPECT_EQ(properties.subDeviceIndex, 0u);
881+
EXPECT_TRUE(properties.subDevicesBitfield.none());
882882
EXPECT_EQ(properties.rootDeviceIndex, 0u);
883883

884884
auto sharedAllocation = memoryManager.createGraphicsAllocationFromSharedHandle(handle, properties, false);

unit_tests/os_interface/linux/drm_memory_manager_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenCreateIsCalledA
15571557
this->mock->outputHandle = 2u;
15581558
size_t size = 4096u;
15591559
AllocationProperties properties(0u, false, size, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, false, 0u);
1560-
ASSERT_EQ(properties.subDeviceIndex, 0u);
1560+
ASSERT_TRUE(properties.subDevicesBitfield.none());
15611561
ASSERT_EQ(properties.rootDeviceIndex, 0u);
15621562

15631563
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false);

0 commit comments

Comments
 (0)