Skip to content

Commit 22725e5

Browse files
Pass device bit field to create bindless heaps allocations
Signed-off-by: Maciej Plewka <[email protected]>
1 parent 684b9e5 commit 22725e5

File tree

13 files changed

+69
-47
lines changed

13 files changed

+69
-47
lines changed

level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ HWTEST2_F(CommandQueueProgramSBATest,
446446
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
447447
DebugManagerStateRestore dbgRestorer;
448448
DebugManager.flags.UseBindlessMode.set(1);
449-
auto bindlessHeapsHelper = std::make_unique<MockBindlesHeapsHelper>(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex());
449+
auto bindlessHeapsHelper = std::make_unique<MockBindlesHeapsHelper>(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield());
450450
MockBindlesHeapsHelper *bindlessHeapsHelperPtr = bindlessHeapsHelper.get();
451451
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapsHelper.release());
452452
NEO::MockGraphicsAllocation baseAllocation;
@@ -485,7 +485,7 @@ HWTEST2_F(CommandQueueProgramSBATest,
485485
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
486486
DebugManagerStateRestore dbgRestorer;
487487
DebugManager.flags.UseBindlessMode.set(0);
488-
auto bindlessHeapsHelper = std::make_unique<MockBindlesHeapsHelper>(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex());
488+
auto bindlessHeapsHelper = std::make_unique<MockBindlesHeapsHelper>(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield());
489489
MockBindlesHeapsHelper *bindlessHeapsHelperPtr = bindlessHeapsHelper.get();
490490
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapsHelper.release());
491491
NEO::MockGraphicsAllocation baseAllocation;
@@ -1010,7 +1010,7 @@ HWTEST2_F(CommandQueueDestroy, givenCommandQueueAndCommandListWithSshAndScratchW
10101010
HWTEST2_F(CommandQueueDestroy, givenCommandQueueAndCommandListWithWhenBindlessEnabledThenHeapContainerIsEmpty, CommandQueueExecuteTestSupport) {
10111011
DebugManagerStateRestore dbgRestorer;
10121012
DebugManager.flags.UseBindlessMode.set(1);
1013-
auto bindlessHeapsHelper = std::make_unique<MockBindlesHeapsHelper>(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex());
1013+
auto bindlessHeapsHelper = std::make_unique<MockBindlesHeapsHelper>(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield());
10141014
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapsHelper.release());
10151015
ze_command_queue_desc_t desc = {};
10161016
NEO::CommandStreamReceiver *csr;

level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,8 @@ TEST_F(KernelImpPatchBindlessTest, GivenKernelImpWhenPatchBindlessOffsetCalledTh
14081408
neoDevice->incRefInternal();
14091409
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(),
14101410
neoDevice->getNumGenericSubDevices() > 1,
1411-
neoDevice->getRootDeviceIndex());
1411+
neoDevice->getRootDeviceIndex(),
1412+
neoDevice->getDeviceBitfield());
14121413
Mock<Module> mockModule(&mockDevice, nullptr);
14131414
kernel.module = &mockModule;
14141415
NEO::MockGraphicsAllocation alloc;
@@ -1441,7 +1442,8 @@ HWTEST2_F(KernelImpPatchBindlessTest, GivenKernelImpWhenSetSurfaceStateBindlessT
14411442

14421443
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(),
14431444
neoDevice->getNumGenericSubDevices() > 1,
1444-
neoDevice->getRootDeviceIndex());
1445+
neoDevice->getRootDeviceIndex(),
1446+
neoDevice->getDeviceBitfield());
14451447

14461448
auto &hwHelper = NEO::HwHelper::get(device->getHwInfo().platform.eRenderCoreFamily);
14471449
size_t size = hwHelper.getRenderSurfaceStateSize();
@@ -1475,7 +1477,8 @@ HWTEST2_F(KernelImpPatchBindlessTest, GivenKernelImpWhenSetSurfaceStateBindfulTh
14751477

14761478
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(),
14771479
neoDevice->getNumGenericSubDevices() > 1,
1478-
neoDevice->getRootDeviceIndex());
1480+
neoDevice->getRootDeviceIndex(),
1481+
neoDevice->getDeviceBitfield());
14791482

14801483
auto &hwHelper = NEO::HwHelper::get(device->getHwInfo().platform.eRenderCoreFamily);
14811484
size_t size = hwHelper.getRenderSurfaceStateSize();
@@ -1750,7 +1753,8 @@ HWTEST2_F(SetKernelArg, givenImageAndBindlessKernelWhenSetArgImageThenCopySurfac
17501753

17511754
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(),
17521755
neoDevice->getNumGenericSubDevices() > 1,
1753-
neoDevice->getRootDeviceIndex());
1756+
neoDevice->getRootDeviceIndex(),
1757+
neoDevice->getDeviceBitfield());
17541758
auto &imageArg = const_cast<NEO::ArgDescImage &>(kernel->kernelImmData->getDescriptor().payloadMappings.explicitArgs[3].template as<NEO::ArgDescImage>());
17551759
auto &addressingMode = kernel->kernelImmData->getDescriptor().kernelAttributes.imageAddressingMode;
17561760
const_cast<NEO::KernelDescriptor::AddressingMode &>(addressingMode) = NEO::KernelDescriptor::Bindless;

opencl/test/unit_test/device/sub_device_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,6 @@ TEST(SubDevicesTest, givenCreateMultipleSubDevicesFlagSetWhenBindlessHeapHelperC
890890
VariableBackup<bool> mockDeviceFlagBackup(&MockDevice::createSingleDevice, false);
891891
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
892892

893-
device->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->createBindlessHeapsHelper(device->getMemoryManager(), device->getNumGenericSubDevices() > 1, device->getRootDeviceIndex());
893+
device->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->createBindlessHeapsHelper(device->getMemoryManager(), device->getNumGenericSubDevices() > 1, device->getRootDeviceIndex(), device->getDeviceBitfield());
894894
EXPECT_EQ(device->getBindlessHeapsHelper(), device->subdevices.at(0)->getBindlessHeapsHelper());
895895
}

shared/source/device/root_device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Device *RootDevice::getRootDevice() const {
3939

4040
void RootDevice::createBindlessHeapsHelper() {
4141
if (ApiSpecificConfig::getBindlessConfiguration()) {
42-
this->executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->createBindlessHeapsHelper(getMemoryManager(), getNumGenericSubDevices() > 1, rootDeviceIndex);
42+
this->executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->createBindlessHeapsHelper(getMemoryManager(), getNumGenericSubDevices() > 1, rootDeviceIndex, getDeviceBitfield());
4343
}
4444
}
4545

shared/source/execution_environment/root_device_environment.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ BindlessHeapsHelper *RootDeviceEnvironment::getBindlessHeapsHelper() const {
102102
return bindlessHeapsHelper.get();
103103
}
104104

105-
void RootDeviceEnvironment::createBindlessHeapsHelper(MemoryManager *memoryManager, bool availableDevices, uint32_t rootDeviceIndex) {
106-
bindlessHeapsHelper = std::make_unique<BindlessHeapsHelper>(memoryManager, availableDevices, rootDeviceIndex);
105+
void RootDeviceEnvironment::createBindlessHeapsHelper(MemoryManager *memoryManager, bool availableDevices, uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield) {
106+
bindlessHeapsHelper = std::make_unique<BindlessHeapsHelper>(memoryManager, availableDevices, rootDeviceIndex, deviceBitfield);
107107
}
108108

109109
CompilerInterface *RootDeviceEnvironment::getCompilerInterface() {

shared/source/execution_environment/root_device_environment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct RootDeviceEnvironment {
6060
MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface();
6161
BuiltIns *getBuiltIns();
6262
BindlessHeapsHelper *getBindlessHeapsHelper() const;
63-
void createBindlessHeapsHelper(MemoryManager *memoryManager, bool availableDevices, uint32_t rootDeviceIndex);
63+
void createBindlessHeapsHelper(MemoryManager *memoryManager, bool availableDevices, uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield);
6464

6565
std::unique_ptr<SipKernel> sipKernels[static_cast<uint32_t>(SipKernelType::COUNT)];
6666
std::unique_ptr<GmmHelper> gmmHelper;

shared/source/helpers/bindless_heaps_helper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ constexpr size_t globalSshAllocationSize = 4 * MemoryConstants::pageSize64k;
1717
constexpr size_t borderColorAlphaOffset = alignUp(4 * sizeof(float), MemoryConstants::cacheLineSize);
1818
using BindlesHeapType = BindlessHeapsHelper::BindlesHeapType;
1919

20-
BindlessHeapsHelper::BindlessHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex) : memManager(memManager), isMultiOsContextCapable(isMultiOsContextCapable), rootDeviceIndex(rootDeviceIndex) {
20+
BindlessHeapsHelper::BindlessHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield) : memManager(memManager), isMultiOsContextCapable(isMultiOsContextCapable), rootDeviceIndex(rootDeviceIndex), deviceBitfield(deviceBitfield) {
2121
for (auto heapType = 0; heapType < BindlesHeapType::NUM_HEAP_TYPES; heapType++) {
2222
auto allocInFrontWindow = heapType != BindlesHeapType::GLOBAL_DSH;
2323
auto heapAllocation = getHeapAllocation(MemoryConstants::pageSize64k, MemoryConstants::pageSize64k, allocInFrontWindow);
@@ -44,7 +44,7 @@ BindlessHeapsHelper::~BindlessHeapsHelper() {
4444

4545
GraphicsAllocation *BindlessHeapsHelper::getHeapAllocation(size_t heapSize, size_t alignment, bool allocInFrontWindow) {
4646
auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM;
47-
NEO::AllocationProperties properties{rootDeviceIndex, true, heapSize, allocationType, isMultiOsContextCapable, false};
47+
NEO::AllocationProperties properties{rootDeviceIndex, true, heapSize, allocationType, isMultiOsContextCapable, deviceBitfield};
4848
properties.flags.use32BitFrontWindow = allocInFrontWindow;
4949
properties.alignment = alignment;
5050

shared/source/helpers/bindless_heaps_helper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class BindlessHeapsHelper {
3737
SCRATCH_SSH,
3838
NUM_HEAP_TYPES
3939
};
40-
BindlessHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex);
40+
BindlessHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield);
4141
~BindlessHeapsHelper();
4242
GraphicsAllocation *getHeapAllocation(size_t heapSize, size_t alignment, bool allocInFrontWindow);
4343

@@ -60,5 +60,6 @@ class BindlessHeapsHelper {
6060
std::vector<std::unique_ptr<SurfaceStateInHeapInfo>> surfaceStateInHeapVectorReuse;
6161
std::unordered_map<GraphicsAllocation *, std::unique_ptr<SurfaceStateInHeapInfo>> surfaceStateInHeapAllocationMap;
6262
std::mutex mtx;
63+
DeviceBitfield deviceBitfield;
6364
};
6465
} // namespace NEO

0 commit comments

Comments
 (0)