diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_base.inl b/level_zero/core/source/cmdlist/cmdlist_hw_base.inl index a37956315a..e696e9f524 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_base.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_base.inl @@ -176,7 +176,7 @@ ze_result_t CommandListCoreFamily::appendLaunchKernelWithParams(z auto surfaceState = GfxFamily::cmdInitRenderSurfaceState; NEO::EncodeSurfaceState::encodeBuffer(&surfaceState, debugSurface->getGpuAddress(), debugSurface->getUnderlyingBufferSize(), mocs, - false, false, false, neoDevice->getNumAvailableDevices(), + false, false, false, neoDevice->getNumGenericSubDevices(), debugSurface, neoDevice->getGmmHelper(), kernelImp->getKernelDescriptor().kernelAttributes.flags.useGlobalAtomics, 1u); *reinterpret_cast(surfaceStateSpace) = surfaceState; } diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl index bf08804752..828aad84a3 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl @@ -26,34 +26,34 @@ template ze_result_t CommandListCoreFamilyImmediate::executeCommandListImmediateWithFlushTask(bool performMigration) { NEO::DispatchFlags dispatchFlags( - {}, //csrDependencies - nullptr, //barrierTimestampPacketNodes - {}, //pipelineSelectArgs - nullptr, //flushStampReference - NEO::QueueThrottle::MEDIUM, //throttle - this->getCommandListPreemptionMode(), //preemptionMode - this->commandContainer.lastSentNumGrfRequired, //numGrfRequired - NEO::L3CachingSettings::l3CacheOn, //l3CacheSettings - this->getThreadArbitrationPolicy(), //threadArbitrationPolicy - NEO::AdditionalKernelExecInfo::NotApplicable, //additionalKernelExecInfo - NEO::KernelExecutionType::NotApplicable, //kernelExecutionType - NEO::MemoryCompressionState::NotApplicable, //memoryCompressionState - NEO::QueueSliceCount::defaultSliceCount, //sliceCount - this->isSyncModeQueue, //blocking - this->isSyncModeQueue, //dcFlush - this->getCommandListSLMEnable(), //useSLM - this->isSyncModeQueue, //guardCommandBufferWithPipeControl - false, //GSBA32BitRequired - false, //requiresCoherency - false, //lowPriority - true, //implicitFlush - this->csr->isNTo1SubmissionModelEnabled(), //outOfOrderExecutionAllowed - false, //epilogueRequired - false, //usePerDssBackedBuffer - false, //useSingleSubdevice - false, //useGlobalAtomics - this->device->getNEODevice()->getNumAvailableDevices() > 1, //areMultipleSubDevicesInContext - false //memoryMigrationRequired + {}, //csrDependencies + nullptr, //barrierTimestampPacketNodes + {}, //pipelineSelectArgs + nullptr, //flushStampReference + NEO::QueueThrottle::MEDIUM, //throttle + this->getCommandListPreemptionMode(), //preemptionMode + this->commandContainer.lastSentNumGrfRequired, //numGrfRequired + NEO::L3CachingSettings::l3CacheOn, //l3CacheSettings + this->getThreadArbitrationPolicy(), //threadArbitrationPolicy + NEO::AdditionalKernelExecInfo::NotApplicable, //additionalKernelExecInfo + NEO::KernelExecutionType::NotApplicable, //kernelExecutionType + NEO::MemoryCompressionState::NotApplicable, //memoryCompressionState + NEO::QueueSliceCount::defaultSliceCount, //sliceCount + this->isSyncModeQueue, //blocking + this->isSyncModeQueue, //dcFlush + this->getCommandListSLMEnable(), //useSLM + this->isSyncModeQueue, //guardCommandBufferWithPipeControl + false, //GSBA32BitRequired + false, //requiresCoherency + false, //lowPriority + true, //implicitFlush + this->csr->isNTo1SubmissionModelEnabled(), //outOfOrderExecutionAllowed + false, //epilogueRequired + false, //usePerDssBackedBuffer + false, //useSingleSubdevice + false, //useGlobalAtomics + this->device->getNEODevice()->getNumGenericSubDevices() > 1, //areMultipleSubDevicesInContext + false //memoryMigrationRequired ); this->commandContainer.removeDuplicatesFromResidencyContainer(); diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl b/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl index a4bc57aac9..f02d60d90b 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_xehp_and_later.inl @@ -242,7 +242,7 @@ ze_result_t CommandListCoreFamily::appendLaunchKernelWithParams(z auto surfaceState = GfxFamily::cmdInitRenderSurfaceState; NEO::EncodeSurfaceState::encodeBuffer(&surfaceState, debugSurface->getGpuAddress(), debugSurface->getUnderlyingBufferSize(), mocs, - false, false, false, neoDevice->getNumAvailableDevices(), + false, false, false, neoDevice->getNumGenericSubDevices(), debugSurface, neoDevice->getGmmHelper(), kernelDescriptor.kernelAttributes.flags.useGlobalAtomics, 1u); *reinterpret_cast(surfaceStateSpace) = surfaceState; diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index 714e1856e1..832baebb90 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -686,28 +686,23 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, uint3 device->setDebugSurface(debugSurface); } - if (device->neoDevice->getNumAvailableDevices() == 1) { - device->numSubDevices = 0; - } else { - for (uint32_t i = 0; i < device->neoDevice->getNumAvailableDevices(); i++) { - - if (!((1UL << i) & currentDeviceMask)) { - continue; - } - - ze_device_handle_t subDevice = Device::create(driverHandle, - device->neoDevice->getSubDevice(i), - 0, - true, returnValue); - if (subDevice == nullptr) { - return nullptr; - } - static_cast(subDevice)->isSubdevice = true; - static_cast(subDevice)->setDebugSurface(debugSurface); - device->subDevices.push_back(static_cast(subDevice)); + for (uint32_t i = 0; i < device->neoDevice->getNumSubDevices(); i++) { + if (!((1UL << i) & currentDeviceMask)) { + continue; } - device->numSubDevices = static_cast(device->subDevices.size()); + + ze_device_handle_t subDevice = Device::create(driverHandle, + device->neoDevice->getSubDevice(i), + 0, + true, returnValue); + if (subDevice == nullptr) { + return nullptr; + } + static_cast(subDevice)->isSubdevice = true; + static_cast(subDevice)->setDebugSurface(debugSurface); + device->subDevices.push_back(static_cast(subDevice)); } + device->numSubDevices = static_cast(device->subDevices.size()); if (neoDevice->getCompilerInterface()) { auto &hwInfo = neoDevice->getHardwareInfo(); diff --git a/level_zero/core/source/device/device_imp_helper.cpp b/level_zero/core/source/device/device_imp_helper.cpp index 23aef4007e..d37b6c5246 100644 --- a/level_zero/core/source/device/device_imp_helper.cpp +++ b/level_zero/core/source/device/device_imp_helper.cpp @@ -19,7 +19,7 @@ NEO::Device *DeviceImp::getActiveDevice() const { } bool DeviceImp::isMultiDeviceCapable() const { - return neoDevice->getNumAvailableDevices() > 1u; + return neoDevice->getNumGenericSubDevices() > 1u; } void DeviceImp::processAdditionalKernelProperties(NEO::HwHelper &hwHelper, ze_device_module_properties_t *pKernelProperties) { diff --git a/level_zero/core/source/kernel/kernel_hw.h b/level_zero/core/source/kernel/kernel_hw.h index ee2ffa280e..780c0529d9 100644 --- a/level_zero/core/source/kernel/kernel_hw.h +++ b/level_zero/core/source/kernel/kernel_hw.h @@ -69,7 +69,7 @@ struct KernelHw : public KernelImp { NEO::Device *neoDevice = module->getDevice()->getNEODevice(); NEO::EncodeSurfaceState::encodeBuffer(&surfaceState, bufferAddressForSsh, bufferSizeForSsh, mocs, - false, false, false, neoDevice->getNumAvailableDevices(), + false, false, false, neoDevice->getNumGenericSubDevices(), alloc, neoDevice->getGmmHelper(), kernelImmData->getDescriptor().kernelAttributes.flags.useGlobalAtomics, 1u); *reinterpret_cast(surfaceStateAddress) = surfaceState; diff --git a/level_zero/core/source/kernel/kernel_imp.cpp b/level_zero/core/source/kernel/kernel_imp.cpp index c91d079986..a12d6b450e 100644 --- a/level_zero/core/source/kernel/kernel_imp.cpp +++ b/level_zero/core/source/kernel/kernel_imp.cpp @@ -93,7 +93,7 @@ inline void patchWithImplicitSurface(ArrayRef crossThreadData, ArrayRef void *addressToPatch = reinterpret_cast(allocation.getUnderlyingBuffer()); size_t sizeToPatch = allocation.getUnderlyingBufferSize(); NEO::Buffer::setSurfaceState(&device, surfaceState, false, false, sizeToPatch, addressToPatch, 0, - &allocation, 0, 0, useGlobalAtomics, device.getNumAvailableDevices() > 1); + &allocation, 0, 0, useGlobalAtomics, device.getNumGenericSubDevices() > 1); } } diff --git a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp index 939481d9aa..cacaf5c59a 100644 --- a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp @@ -446,7 +446,7 @@ HWTEST2_F(CommandQueueProgramSBATest, using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); - auto bindlessHeapsHelper = std::make_unique(neoDevice->getMemoryManager(), neoDevice->getNumAvailableDevices() > 1, neoDevice->getRootDeviceIndex()); + auto bindlessHeapsHelper = std::make_unique(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex()); MockBindlesHeapsHelper *bindlessHeapsHelperPtr = bindlessHeapsHelper.get(); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapsHelper.release()); NEO::MockGraphicsAllocation baseAllocation; @@ -485,7 +485,7 @@ HWTEST2_F(CommandQueueProgramSBATest, using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(0); - auto bindlessHeapsHelper = std::make_unique(neoDevice->getMemoryManager(), neoDevice->getNumAvailableDevices() > 1, neoDevice->getRootDeviceIndex()); + auto bindlessHeapsHelper = std::make_unique(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex()); MockBindlesHeapsHelper *bindlessHeapsHelperPtr = bindlessHeapsHelper.get(); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapsHelper.release()); NEO::MockGraphicsAllocation baseAllocation; @@ -1010,7 +1010,7 @@ HWTEST2_F(CommandQueueDestroy, givenCommandQueueAndCommandListWithSshAndScratchW HWTEST2_F(CommandQueueDestroy, givenCommandQueueAndCommandListWithWhenBindlessEnabledThenHeapContainerIsEmpty, CommandQueueExecuteTestSupport) { DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); - auto bindlessHeapsHelper = std::make_unique(neoDevice->getMemoryManager(), neoDevice->getNumAvailableDevices() > 1, neoDevice->getRootDeviceIndex()); + auto bindlessHeapsHelper = std::make_unique(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex()); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapsHelper.release()); ze_command_queue_desc_t desc = {}; NEO::CommandStreamReceiver *csr; diff --git a/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp b/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp index 8b14fcd669..c34a783796 100644 --- a/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp +++ b/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp @@ -1401,7 +1401,9 @@ TEST_F(KernelImpPatchBindlessTest, GivenKernelImpWhenPatchBindlessOffsetCalledTh WhiteBox<::L0::DeviceImp> mockDevice; mockDevice.neoDevice = neoDevice; neoDevice->incRefInternal(); - neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), neoDevice->getNumAvailableDevices() > 1, neoDevice->getRootDeviceIndex()); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), + neoDevice->getNumGenericSubDevices() > 1, + neoDevice->getRootDeviceIndex()); Mock mockModule(&mockDevice, nullptr); kernel.module = &mockModule; NEO::MockGraphicsAllocation alloc; @@ -1432,7 +1434,9 @@ HWTEST2_F(KernelImpPatchBindlessTest, GivenKernelImpWhenSetSurfaceStateBindlessT arg.bindless = 0x40; arg.bindful = undefined; - neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), neoDevice->getNumAvailableDevices() > 1, neoDevice->getRootDeviceIndex()); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), + neoDevice->getNumGenericSubDevices() > 1, + neoDevice->getRootDeviceIndex()); auto &hwHelper = NEO::HwHelper::get(device->getHwInfo().platform.eRenderCoreFamily); size_t size = hwHelper.getRenderSurfaceStateSize(); @@ -1464,7 +1468,9 @@ HWTEST2_F(KernelImpPatchBindlessTest, GivenKernelImpWhenSetSurfaceStateBindfulTh arg.bindless = undefined; arg.bindful = 0x40; - neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), neoDevice->getNumAvailableDevices() > 1, neoDevice->getRootDeviceIndex()); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), + neoDevice->getNumGenericSubDevices() > 1, + neoDevice->getRootDeviceIndex()); auto &hwHelper = NEO::HwHelper::get(device->getHwInfo().platform.eRenderCoreFamily); size_t size = hwHelper.getRenderSurfaceStateSize(); @@ -1737,7 +1743,9 @@ struct MyMockImage : public WhiteBox<::L0::ImageCoreFamily> { HWTEST2_F(SetKernelArg, givenImageAndBindlessKernelWhenSetArgImageThenCopySurfaceStateToSSHCalledWithCorrectArgs, ImageSupport) { createKernel(); - neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), neoDevice->getNumAvailableDevices() > 1, neoDevice->getRootDeviceIndex()); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), + neoDevice->getNumGenericSubDevices() > 1, + neoDevice->getRootDeviceIndex()); auto &imageArg = const_cast(kernel->kernelImmData->getDescriptor().payloadMappings.explicitArgs[3].template as()); auto &addressingMode = kernel->kernelImmData->getDescriptor().kernelAttributes.imageAddressingMode; const_cast(addressingMode) = NEO::KernelDescriptor::Bindless; diff --git a/level_zero/tools/source/metrics/metric_query_imp.cpp b/level_zero/tools/source/metrics/metric_query_imp.cpp index b1cee5455c..afedddc37b 100644 --- a/level_zero/tools/source/metrics/metric_query_imp.cpp +++ b/level_zero/tools/source/metrics/metric_query_imp.cpp @@ -213,7 +213,7 @@ void MetricsLibrary::getSubDeviceClientOptions( subDeviceIndex.SubDeviceIndex.Index = 0; subDeviceCount.Type = ClientOptionsType::SubDeviceCount; - subDeviceCount.SubDeviceCount.Count = neoDevice.getNumAvailableDevices(); + subDeviceCount.SubDeviceCount.Count = neoDevice.getNumSubDevices(); } else { @@ -225,7 +225,7 @@ void MetricsLibrary::getSubDeviceClientOptions( subDeviceIndex.SubDeviceIndex.Index = static_cast(&neoDevice)->getSubDeviceIndex(); subDeviceCount.Type = ClientOptionsType::SubDeviceCount; - subDeviceCount.SubDeviceCount.Count = neoDevice.getRootDevice()->getNumAvailableDevices(); + subDeviceCount.SubDeviceCount.Count = neoDevice.getRootDevice()->getNumSubDevices(); } } diff --git a/level_zero/tools/test/unit_tests/sources/metrics/test_metric_query_pool_2.cpp b/level_zero/tools/test/unit_tests/sources/metrics/test_metric_query_pool_2.cpp index f5ce4fe3d4..17e1d35199 100644 --- a/level_zero/tools/test/unit_tests/sources/metrics/test_metric_query_pool_2.cpp +++ b/level_zero/tools/test/unit_tests/sources/metrics/test_metric_query_pool_2.cpp @@ -899,7 +899,7 @@ TEST_F(MetricQueryPoolTest, givenRootDeviceWhenGetSubDeviceClientOptionsIsCalled EXPECT_EQ(subDeviceIndex.SubDeviceIndex.Index, 0u); EXPECT_EQ(subDeviceCount.Type, MetricsLibraryApi::ClientOptionsType::SubDeviceCount); - EXPECT_EQ(subDeviceCount.SubDeviceCount.Count, device->getNEODevice()->getNumAvailableDevices()); + EXPECT_EQ(subDeviceCount.SubDeviceCount.Count, device->getNEODevice()->getNumSubDevices()); } TEST_F(MetricQueryPoolTest, givenSubDeviceWhenGetSubDeviceClientOptionsIsCalledThenReturnSubDeviceProperties) { @@ -914,7 +914,7 @@ TEST_F(MetricQueryPoolTest, givenSubDeviceWhenGetSubDeviceClientOptionsIsCalledT auto subDeviceCount = ClientOptionsData_1_0{}; // Sub devices - for (uint32_t i = 0, count = rootDevice->getNumAvailableDevices(); i < count; ++i) { + for (uint32_t i = 0, count = rootDevice->getNumSubDevices(); i < count; ++i) { metricsLibrary.getSubDeviceClientOptions(*rootDevice->subdevices[i], subDevice, subDeviceIndex, subDeviceCount); @@ -925,7 +925,7 @@ TEST_F(MetricQueryPoolTest, givenSubDeviceWhenGetSubDeviceClientOptionsIsCalledT EXPECT_EQ(subDeviceIndex.SubDeviceIndex.Index, i); EXPECT_EQ(subDeviceCount.Type, MetricsLibraryApi::ClientOptionsType::SubDeviceCount); - EXPECT_EQ(subDeviceCount.SubDeviceCount.Count, rootDevice->getNumAvailableDevices()); + EXPECT_EQ(subDeviceCount.SubDeviceCount.Count, rootDevice->getNumSubDevices()); } } } // namespace ult diff --git a/opencl/source/api/api.cpp b/opencl/source/api/api.cpp index ef9808af2d..e13d9db6aa 100644 --- a/opencl/source/api/api.cpp +++ b/opencl/source/api/api.cpp @@ -289,7 +289,7 @@ cl_int CL_API_CALL clCreateSubDevices(cl_device_id inDevice, if (pInDevice == nullptr) { return CL_INVALID_DEVICE; } - auto subDevicesCount = pInDevice->getNumAvailableDevices(); + auto subDevicesCount = pInDevice->getNumSubDevices(); if (subDevicesCount <= 1) { return CL_DEVICE_PARTITION_FAILED; } diff --git a/opencl/source/cl_device/cl_device.cpp b/opencl/source/cl_device/cl_device.cpp index b1a33999aa..e973abbe46 100644 --- a/opencl/source/cl_device/cl_device.cpp +++ b/opencl/source/cl_device/cl_device.cpp @@ -35,7 +35,7 @@ ClDevice::ClDevice(Device &device, ClDevice &rootClDevice, Platform *platform) : compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(deviceInfo.deviceExtensions, emptyOpenClCFeatures); compilerExtensionsWithFeatures = convertEnabledExtensionsToCompilerInternalOptions(deviceInfo.deviceExtensions, deviceInfo.openclCFeatures); - auto numAvailableDevices = device.getNumAvailableDevices(); + auto numAvailableDevices = device.getNumSubDevices(); if (numAvailableDevices > 1) { for (uint32_t i = 0; i < numAvailableDevices; i++) { auto &coreSubDevice = static_cast(*device.getSubDevice(i)); @@ -169,7 +169,8 @@ const HardwareCapabilities &ClDevice::getHardwareCapabilities() const { return d bool ClDevice::isFullRangeSvm() const { return device.isFullRangeSvm(); } bool ClDevice::areSharedSystemAllocationsAllowed() const { return device.areSharedSystemAllocationsAllowed(); } uint32_t ClDevice::getRootDeviceIndex() const { return device.getRootDeviceIndex(); } -uint32_t ClDevice::getNumAvailableDevices() const { return device.getNumAvailableDevices(); } +uint32_t ClDevice::getNumGenericSubDevices() const { return device.getNumGenericSubDevices(); } +uint32_t ClDevice::getNumSubDevices() const { return static_cast(subDevices.size()); } ClDeviceVector::ClDeviceVector(const cl_device_id *devices, cl_uint numDevices) { diff --git a/opencl/source/cl_device/cl_device.h b/opencl/source/cl_device/cl_device.h index c06953301f..946b4a1166 100644 --- a/opencl/source/cl_device/cl_device.h +++ b/opencl/source/cl_device/cl_device.h @@ -89,7 +89,8 @@ class ClDevice : public BaseObject<_cl_device_id> { bool isFullRangeSvm() const; bool areSharedSystemAllocationsAllowed() const; uint32_t getRootDeviceIndex() const; - uint32_t getNumAvailableDevices() const; + uint32_t getNumGenericSubDevices() const; + uint32_t getNumSubDevices() const; // API entry points cl_int getDeviceInfo(cl_device_info paramName, diff --git a/opencl/source/cl_device/cl_device_caps.cpp b/opencl/source/cl_device/cl_device_caps.cpp index 0d32d422b5..c51f39a0dd 100644 --- a/opencl/source/cl_device/cl_device_caps.cpp +++ b/opencl/source/cl_device/cl_device_caps.cpp @@ -197,7 +197,7 @@ void ClDevice::initializeCaps() { deviceExtensions += "cl_intel_media_block_io "; } - auto sharingAllowed = (getNumAvailableDevices() == 1u); + auto sharingAllowed = (getNumGenericSubDevices() <= 1u); if (sharingAllowed) { deviceExtensions += sharingFactory.getExtensions(driverInfo.get()); } @@ -245,8 +245,8 @@ void ClDevice::initializeCaps() { deviceInfo.deviceAvailable = CL_TRUE; deviceInfo.compilerAvailable = CL_TRUE; deviceInfo.parentDevice = nullptr; - deviceInfo.partitionMaxSubDevices = device.getNumAvailableDevices(); - if (deviceInfo.partitionMaxSubDevices > 1) { + deviceInfo.partitionMaxSubDevices = device.getNumSubDevices(); + if (deviceInfo.partitionMaxSubDevices > 0) { deviceInfo.partitionProperties[0] = CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN; deviceInfo.partitionProperties[1] = 0; deviceInfo.partitionAffinityDomain = CL_DEVICE_AFFINITY_DOMAIN_NUMA | CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE; @@ -308,7 +308,11 @@ void ClDevice::initializeCaps() { deviceInfo.maxWorkItemDimensions = 3; - deviceInfo.maxComputUnits = systemInfo.EUCount * getNumAvailableDevices(); + deviceInfo.maxComputUnits = systemInfo.EUCount * std::max(getNumGenericSubDevices(), 1u); + if (device.isEngineInstanced()) { + deviceInfo.maxComputUnits /= systemInfo.CCSInfo.NumberOfCCSEnabled; + } + deviceInfo.maxConstantArgs = 8; deviceInfo.maxSliceCount = systemInfo.SliceCount; diff --git a/opencl/source/cl_device/cl_device_info.cpp b/opencl/source/cl_device/cl_device_info.cpp index d93e8cca56..dc126afd98 100644 --- a/opencl/source/cl_device/cl_device_info.cpp +++ b/opencl/source/cl_device/cl_device_info.cpp @@ -256,7 +256,7 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName, retSize = srcSize = sizeof(cl_uint); break; case CL_DEVICE_NUM_SLICES_INTEL: - param.uint = static_cast(getHardwareInfo().gtSystemInfo.SliceCount * ((subDevices.size() > 0) ? subDevices.size() : 1)); + param.uint = static_cast(getHardwareInfo().gtSystemInfo.SliceCount * std::max(device.getNumGenericSubDevices(), 1u)); src = ¶m.uint; retSize = srcSize = sizeof(cl_uint); break; diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index be374668a2..5fe3f7ae8a 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -842,7 +842,7 @@ void CommandQueue::processProperties(const cl_queue_properties *properties) { if (specificEngineSelected) { this->queueFamilySelected = true; - if (getDevice().getNumAvailableDevices() == 1) { + if (!getDevice().hasRootCsr()) { auto queueFamily = getDevice().getNonEmptyEngineGroup(selectedQueueFamilyIndex); const auto &engine = queueFamily->at(selectedQueueIndex); auto engineType = engine.getEngineType(); diff --git a/opencl/source/context/context.cpp b/opencl/source/context/context.cpp index a1c7c23248..486f6650b5 100644 --- a/opencl/source/context/context.cpp +++ b/opencl/source/context/context.cpp @@ -181,7 +181,7 @@ bool Context::createImpl(const cl_context_properties *properties, bool containsDeviceWithSubdevices = false; for (const auto &device : inputDevices) { rootDeviceIndices.insert(device->getRootDeviceIndex()); - containsDeviceWithSubdevices |= device->getNumAvailableDevices() > 1; + containsDeviceWithSubdevices |= device->getNumGenericSubDevices() > 1; } this->driverDiagnostics = driverDiagnostics.release(); @@ -472,6 +472,6 @@ Platform *Context::getPlatformFromProperties(const cl_context_properties *proper } bool Context::isSingleDeviceContext() { - return devices[0]->getNumAvailableDevices() == 1 && getNumDevices() == 1; + return devices[0]->getNumGenericSubDevices() == 0 && getNumDevices() == 1; } } // namespace NEO diff --git a/opencl/source/mem_obj/buffer_base.inl b/opencl/source/mem_obj/buffer_base.inl index 7177f2b716..c5edeafc59 100644 --- a/opencl/source/mem_obj/buffer_base.inl +++ b/opencl/source/mem_obj/buffer_base.inl @@ -42,7 +42,7 @@ void BufferHw::setArgStateful(void *memory, bool forceNonAuxMode, boo EncodeSurfaceState::encodeBuffer(memory, getBufferAddress(rootDeviceIndex), getSurfaceSize(alignSizeForAuxTranslation, rootDeviceIndex), getMocsValue(disableL3, isReadOnly, rootDeviceIndex), - true, forceNonAuxMode, isReadOnly, device.getNumAvailableDevices(), + true, forceNonAuxMode, isReadOnly, device.getNumGenericSubDevices(), graphicsAllocation, device.getGmmHelper(), useGlobalAtomics, areMultipleSubDevicesInContext); appendSurfaceStateExt(memory); } diff --git a/opencl/source/os_interface/linux/performance_counters_linux.cpp b/opencl/source/os_interface/linux/performance_counters_linux.cpp index b3afd894e7..7e56fc6ad3 100644 --- a/opencl/source/os_interface/linux/performance_counters_linux.cpp +++ b/opencl/source/os_interface/linux/performance_counters_linux.cpp @@ -29,13 +29,13 @@ std::unique_ptr PerformanceCounters::create(Device *device) // Root device. counter->subDevice.Enabled = false; counter->subDeviceIndex.Index = 0; - counter->subDeviceCount.Count = device->getNumAvailableDevices(); + counter->subDeviceCount.Count = device->getNumSubDevices(); } else { // Sub device. counter->subDevice.Enabled = true; counter->subDeviceIndex.Index = static_cast(device)->getSubDeviceIndex(); - counter->subDeviceCount.Count = device->getRootDevice()->getNumAvailableDevices(); + counter->subDeviceCount.Count = device->getRootDevice()->getNumSubDevices(); } // Adapter data. diff --git a/opencl/source/program/program.cpp b/opencl/source/program/program.cpp index a0068254c4..d02653960f 100644 --- a/opencl/source/program/program.cpp +++ b/opencl/source/program/program.cpp @@ -53,8 +53,8 @@ Program::Program(Context *context, bool isBuiltIn, const ClDeviceVector &clDevic maxRootDeviceIndex = device->getRootDeviceIndex(); } deviceBuildInfos[device] = {}; - if (device->getNumAvailableDevices() > 1) { - for (auto i = 0u; i < device->getNumAvailableDevices(); i++) { + if (device->getNumGenericSubDevices() > 1) { + for (auto i = 0u; i < device->getNumGenericSubDevices(); i++) { auto subDevice = device->getNearestGenericSubDevice(i); if (isDeviceAssociated(*subDevice)) { deviceBuildInfos[device].associatedSubDevices.push_back(subDevice); diff --git a/opencl/test/unit_test/api/cl_create_command_queue_with_properties_tests.cpp b/opencl/test/unit_test/api/cl_create_command_queue_with_properties_tests.cpp index 6911494d98..66187d77c5 100644 --- a/opencl/test/unit_test/api/cl_create_command_queue_with_properties_tests.cpp +++ b/opencl/test/unit_test/api/cl_create_command_queue_with_properties_tests.cpp @@ -556,7 +556,7 @@ HWTEST_F(LowPriorityCommandQueueTest, GivenDeviceWithSubdevicesWhenCreatingLowPr DebugManager.flags.CreateMultipleSubDevices.set(2); MockContext context; cl_queue_properties properties[] = {CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_LOW_KHR, 0}; - EXPECT_EQ(2u, context.getDevice(0)->getNumAvailableDevices()); + EXPECT_EQ(2u, context.getDevice(0)->getNumGenericSubDevices()); auto cmdQ = clCreateCommandQueueWithProperties(&context, context.getDevice(0), properties, nullptr); auto commandQueueObj = castToObject(cmdQ); diff --git a/opencl/test/unit_test/command_queue/command_queue_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_tests.cpp index c9235dbdb1..105625502c 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -296,7 +296,7 @@ HWTEST_P(CommandQueueWithBlitOperationsTests, givenDeviceWithSubDevicesSupportin REQUIRE_BLITTER_OR_SKIP(&hwInfo); auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); - EXPECT_EQ(2u, device->getNumAvailableDevices()); + EXPECT_EQ(2u, device->getNumGenericSubDevices()); std::unique_ptr bcsOsContext; auto subDevice = device->getSubDevice(0); diff --git a/opencl/test/unit_test/command_queue/get_command_queue_info_tests.cpp b/opencl/test/unit_test/command_queue/get_command_queue_info_tests.cpp index 57c4f8a8de..c6c18af1c9 100644 --- a/opencl/test/unit_test/command_queue/get_command_queue_info_tests.cpp +++ b/opencl/test/unit_test/command_queue/get_command_queue_info_tests.cpp @@ -193,7 +193,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, GetCommandQueueFamilyInfoTests, givenFamilyIdWhenGe auto context = clCreateContext(nullptr, 1, &deviceId, nullptr, nullptr, nullptr); auto ccsFamily = mockClDevice.getDevice().getIndexOfNonEmptyEngineGroup(EngineGroupType::Compute); cl_command_queue_properties properties[] = {CL_QUEUE_FAMILY_INTEL, ccsFamily, CL_QUEUE_INDEX_INTEL, 0, 0}; - EXPECT_EQ(1u, mockClDevice.getNumAvailableDevices()); + EXPECT_EQ(0u, mockClDevice.getNumGenericSubDevices()); auto commandQueue = clCreateCommandQueueWithProperties(context, deviceId, properties, nullptr); auto neoQueue = castToObject(commandQueue); @@ -229,7 +229,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, GetCommandQueueFamilyInfoTests, givenFamilyIdWhenCr auto context = clCreateContext(nullptr, 1, &deviceId, nullptr, nullptr, nullptr); cl_command_queue_properties properties[] = {CL_QUEUE_FAMILY_INTEL, static_cast(EngineGroupType::Compute), CL_QUEUE_INDEX_INTEL, 0, 0}; - EXPECT_EQ(2u, rootDevice->getNumAvailableDevices()); + EXPECT_EQ(2u, rootDevice->getNumGenericSubDevices()); cl_int retVal; auto commandQueue = clCreateCommandQueueWithProperties(context, rootDevice, properties, &retVal); diff --git a/opencl/test/unit_test/device/device_tests.cpp b/opencl/test/unit_test/device/device_tests.cpp index b7de46c3c5..a28ba5ba47 100644 --- a/opencl/test/unit_test/device/device_tests.cpp +++ b/opencl/test/unit_test/device/device_tests.cpp @@ -325,8 +325,8 @@ TEST(DeviceCreation, givenDeviceWhenItIsCreatedThenOsContextIsRegistredInMemoryM auto memoryManager = device->getMemoryManager(); auto &hwInfo = device->getHardwareInfo(); auto numEnginesForDevice = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo).size(); - if (device->getNumAvailableDevices() > 1) { - numEnginesForDevice *= device->getNumAvailableDevices(); + if (device->getNumGenericSubDevices() > 1) { + numEnginesForDevice *= device->getNumGenericSubDevices(); numEnginesForDevice += device->engines.size(); } EXPECT_EQ(numEnginesForDevice, memoryManager->getRegisteredEnginesCount()); diff --git a/opencl/test/unit_test/device/get_device_info_tests.cpp b/opencl/test/unit_test/device/get_device_info_tests.cpp index 6bae195dfb..3b9dcf6668 100644 --- a/opencl/test/unit_test/device/get_device_info_tests.cpp +++ b/opencl/test/unit_test/device/get_device_info_tests.cpp @@ -1080,7 +1080,7 @@ struct DeviceAttributeQueryTest : public ::testing::TestWithParam(object.get()); const auto >SysInfo = device.getHardwareInfo().gtSystemInfo; - EXPECT_EQ(gtSysInfo.SliceCount * device.getNumAvailableDevices(), *pNumSlices); + EXPECT_EQ(gtSysInfo.SliceCount * std::max(device.getNumGenericSubDevices(), 1u), *pNumSlices); EXPECT_EQ(sizeof(cl_uint), sizeReturned); break; } diff --git a/opencl/test/unit_test/device/sub_device_tests.cpp b/opencl/test/unit_test/device/sub_device_tests.cpp index 49ce2742cb..3e9b88ed21 100644 --- a/opencl/test/unit_test/device/sub_device_tests.cpp +++ b/opencl/test/unit_test/device/sub_device_tests.cpp @@ -28,7 +28,7 @@ TEST(SubDevicesTest, givenDefaultConfigWhenCreateRootDeviceThenItDoesntContainSu auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); EXPECT_EQ(0u, device->getNumSubDevices()); - EXPECT_EQ(1u, device->getNumAvailableDevices()); + EXPECT_EQ(0u, device->getNumGenericSubDevices()); } TEST(SubDevicesTest, givenCreateMultipleSubDevicesFlagSetWhenCreateRootDeviceThenItsSubdevicesHaveProperRootIdSet) { @@ -55,9 +55,9 @@ TEST(SubDevicesTest, givenCreateMultipleSubDevicesFlagSetWhenCreateRootDeviceThe EXPECT_EQ(2u, device->getNumSubDevices()); - EXPECT_EQ(2u, device->getNumAvailableDevices()); - EXPECT_EQ(1u, device->subdevices.at(0)->getNumAvailableDevices()); - EXPECT_EQ(1u, device->subdevices.at(1)->getNumAvailableDevices()); + EXPECT_EQ(2u, device->getNumGenericSubDevices()); + EXPECT_EQ(0u, device->subdevices.at(0)->getNumGenericSubDevices()); + EXPECT_EQ(0u, device->subdevices.at(1)->getNumGenericSubDevices()); } TEST(SubDevicesTest, givenDeviceWithSubDevicesWhenSubDeviceApiRefCountsAreChangedThenChangeIsPropagatedToRootDevice) { @@ -204,7 +204,7 @@ TEST(SubDevicesTest, givenSubDeviceWhenOsContextIsCreatedThenItsBitfieldBasesOnS TEST(SubDevicesTest, givenDeviceWithoutSubDevicesWhenGettingDeviceByIdZeroThenGetThisDevice) { auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); - EXPECT_EQ(1u, device->getNumAvailableDevices()); + EXPECT_EQ(0u, device->getNumGenericSubDevices()); EXPECT_ANY_THROW(device->getSubDevice(0u)); } @@ -248,10 +248,10 @@ TEST(RootDevicesTest, givenRootDeviceWithSubdevicesWhenCreateEnginesThenDeviceCr auto executionEnvironment = new MockExecutionEnvironment; MockDevice device(executionEnvironment, 0); - device.createSubDevices(); - EXPECT_EQ(2u, device.getNumAvailableDevices()); EXPECT_EQ(0u, device.engines.size()); + device.createSubDevices(); device.createEngines(); + EXPECT_EQ(2u, device.getNumGenericSubDevices()); EXPECT_EQ(1u, device.engines.size()); } @@ -328,7 +328,8 @@ struct EngineInstancedDeviceTests : public ::testing::Test { bool isEngineInstanced(MockSubDevice *subDevice, aub_stream::EngineType engineType, uint32_t subDeviceIndex, DeviceBitfield deviceBitfield) { bool isEngineInstanced = !subDevice->engines[0].osContext->isRootDevice(); isEngineInstanced &= subDevice->engineInstanced; - isEngineInstanced &= (subDevice->getNumAvailableDevices() == 1); + isEngineInstanced &= (subDevice->getNumGenericSubDevices() == 0); + isEngineInstanced &= (subDevice->getNumSubDevices() == 0); isEngineInstanced &= (engineType == subDevice->engineInstancedType); isEngineInstanced &= (subDeviceIndex == subDevice->getSubDeviceIndex()); isEngineInstanced &= (deviceBitfield == subDevice->getDeviceBitfield()); @@ -400,7 +401,8 @@ TEST_F(EngineInstancedDeviceTests, givenDebugFlagSetAndMoreThanOneCcsWhenCreatin auto &hwInfo = rootDevice->getHardwareInfo(); EXPECT_EQ(ccsCount, hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled); - EXPECT_EQ(ccsCount, rootDevice->getNumAvailableDevices()); + EXPECT_EQ(ccsCount, rootDevice->getNumSubDevices()); + EXPECT_EQ(0u, rootDevice->getNumGenericSubDevices()); EXPECT_FALSE(hasRootCsrOnly(rootDevice)); EXPECT_TRUE(hasAllEngines(rootDevice)); @@ -424,7 +426,8 @@ TEST_F(EngineInstancedDeviceTests, givenDebugFlagSetAndZeroCcsesWhenCreatingRoot EXPECT_FALSE(hasRootCsrOnly(rootDevice)); EXPECT_TRUE(hasAllEngines(rootDevice)); - EXPECT_EQ(1u, rootDevice->getNumAvailableDevices()); + EXPECT_EQ(0u, rootDevice->getNumGenericSubDevices()); + EXPECT_EQ(0u, rootDevice->getNumSubDevices()); EXPECT_FALSE(rootDevice->getNearestGenericSubDevice(0)->isSubDevice()); } @@ -439,7 +442,8 @@ TEST_F(EngineInstancedDeviceTests, givenDebugFlagSetAndSingleCcsWhenCreatingRoot EXPECT_FALSE(hasRootCsrOnly(rootDevice)); EXPECT_TRUE(hasAllEngines(rootDevice)); - EXPECT_EQ(1u, rootDevice->getNumAvailableDevices()); + EXPECT_EQ(0u, rootDevice->getNumGenericSubDevices()); + EXPECT_EQ(0u, rootDevice->getNumSubDevices()); EXPECT_FALSE(rootDevice->getNearestGenericSubDevice(0)->isSubDevice()); } @@ -457,7 +461,8 @@ TEST_F(EngineInstancedDeviceTests, givenDebugFlagSetWhenCreatingRootDeviceWithGe EXPECT_FALSE(subDevice->engines[0].osContext->isRootDevice()); EXPECT_FALSE(subDevice->engineInstanced); - EXPECT_EQ(1u, subDevice->getNumAvailableDevices()); + EXPECT_EQ(0u, subDevice->getNumGenericSubDevices()); + EXPECT_EQ(0u, subDevice->getNumSubDevices()); EXPECT_EQ(aub_stream::EngineType::NUM_ENGINES, subDevice->engineInstancedType); EXPECT_TRUE(hasAllEngines(subDevice)); @@ -480,7 +485,8 @@ TEST_F(EngineInstancedDeviceTests, givenDebugFlagSetWhenCreatingRootDeviceWithGe EXPECT_FALSE(subDevice->engines[0].osContext->isRootDevice()); EXPECT_FALSE(subDevice->engineInstanced); - EXPECT_EQ(1u, subDevice->getNumAvailableDevices()); + EXPECT_EQ(0u, subDevice->getNumGenericSubDevices()); + EXPECT_EQ(0u, subDevice->getNumSubDevices()); EXPECT_EQ(aub_stream::EngineType::NUM_ENGINES, subDevice->engineInstancedType); EXPECT_TRUE(hasAllEngines(subDevice)); @@ -503,7 +509,8 @@ TEST_F(EngineInstancedDeviceTests, givenDebugFlagSetWhenCreatingRootDeviceWithGe EXPECT_FALSE(subDevice->engines[0].osContext->isRootDevice()); EXPECT_FALSE(subDevice->engineInstanced); - EXPECT_EQ(ccsCount, subDevice->getNumAvailableDevices()); + EXPECT_EQ(0u, subDevice->getNumGenericSubDevices()); + EXPECT_EQ(ccsCount, subDevice->getNumSubDevices()); EXPECT_EQ(aub_stream::EngineType::NUM_ENGINES, subDevice->engineInstancedType); EXPECT_TRUE(hasAllEngines(subDevice)); @@ -639,7 +646,8 @@ TEST_F(EngineInstancedDeviceTests, givenAffinityMaskSetWhenCreatingDevicesThenFi EXPECT_FALSE(subDevice->engines[0].osContext->isRootDevice()); EXPECT_FALSE(subDevice->engineInstanced); - EXPECT_EQ(engineInstancedPerGeneric[i], subDevice->getNumAvailableDevices()); + EXPECT_EQ(engineInstancedPerGeneric[i], subDevice->getNumSubDevices()); + EXPECT_EQ(0u, subDevice->getNumGenericSubDevices()); EXPECT_EQ(aub_stream::EngineType::NUM_ENGINES, subDevice->engineInstancedType); EXPECT_TRUE(hasAllEngines(subDevice)); @@ -687,7 +695,8 @@ TEST_F(EngineInstancedDeviceTests, givenAffinityMaskForSingle3rdLevelDeviceWhenC EXPECT_TRUE(isEngineInstanced(subDevice, engineType, i, deviceBitfield)); EXPECT_TRUE(hasEngineInstancedEngines(subDevice, engineType)); - EXPECT_EQ(1u, subDevice->getNumAvailableDevices()); + EXPECT_EQ(0u, subDevice->getNumGenericSubDevices()); + EXPECT_EQ(0u, subDevice->getNumSubDevices()); continue; } @@ -697,7 +706,8 @@ TEST_F(EngineInstancedDeviceTests, givenAffinityMaskForSingle3rdLevelDeviceWhenC EXPECT_FALSE(subDevice->engineInstanced); EXPECT_EQ(aub_stream::EngineType::NUM_ENGINES, subDevice->engineInstancedType); - EXPECT_EQ(ccsCount, subDevice->getNumAvailableDevices()); + EXPECT_EQ(0u, subDevice->getNumGenericSubDevices()); + EXPECT_EQ(ccsCount, subDevice->getNumSubDevices()); for (uint32_t j = 0; j < ccsCount; j++) { auto engineType = static_cast(aub_stream::EngineType::ENGINE_CCS + j); @@ -730,7 +740,8 @@ TEST_F(EngineInstancedDeviceTests, givenAffinityMaskForSingle3rdLevelDeviceOnlyW EXPECT_FALSE(rootDevice->engines[0].osContext->isRootDevice()); EXPECT_TRUE(rootDevice->engineInstanced); - EXPECT_TRUE(rootDevice->getNumAvailableDevices() == 1); + EXPECT_TRUE(rootDevice->getNumGenericSubDevices() == 0); + EXPECT_TRUE(rootDevice->getNumSubDevices() == 0); EXPECT_TRUE(engineType == rootDevice->engineInstancedType); EXPECT_TRUE(deviceBitfield == rootDevice->getDeviceBitfield()); EXPECT_EQ(1u, rootDevice->getDeviceBitfield().count()); @@ -758,7 +769,8 @@ TEST_F(EngineInstancedDeviceTests, givenAffinityMaskForSingle2rdLevelDeviceOnlyW EXPECT_FALSE(rootDevice->engines[0].osContext->isRootDevice()); EXPECT_TRUE(rootDevice->engineInstanced); - EXPECT_TRUE(rootDevice->getNumAvailableDevices() == 1); + EXPECT_TRUE(rootDevice->getNumGenericSubDevices() == 0); + EXPECT_TRUE(rootDevice->getNumSubDevices() == 0); EXPECT_TRUE(engineType == rootDevice->engineInstancedType); EXPECT_TRUE(deviceBitfield == rootDevice->getDeviceBitfield()); EXPECT_EQ(1u, rootDevice->getDeviceBitfield().count()); @@ -807,6 +819,6 @@ TEST(SubDevicesTest, givenCreateMultipleSubDevicesFlagSetWhenBindlessHeapHelperC VariableBackup mockDeviceFlagBackup(&MockDevice::createSingleDevice, false); auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); - device->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->createBindlessHeapsHelper(device->getMemoryManager(), device->getNumAvailableDevices() > 1, device->getRootDeviceIndex()); + device->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->createBindlessHeapsHelper(device->getMemoryManager(), device->getNumGenericSubDevices() > 1, device->getRootDeviceIndex()); EXPECT_EQ(device->getBindlessHeapsHelper(), device->subdevices.at(0)->getBindlessHeapsHelper()); } diff --git a/opencl/test/unit_test/execution_environment/execution_environment_tests.cpp b/opencl/test/unit_test/execution_environment/execution_environment_tests.cpp index da035b54b2..abbc7ced6a 100644 --- a/opencl/test/unit_test/execution_environment/execution_environment_tests.cpp +++ b/opencl/test/unit_test/execution_environment/execution_environment_tests.cpp @@ -63,11 +63,11 @@ TEST(ExecutionEnvironment, WhenCreatingDevicesThenThoseDevicesAddRefcountsToExec auto expectedRefCounts = executionEnvironment->getRefInternalCount(); auto devices = DeviceFactory::createDevices(*executionEnvironment); - EXPECT_LT(0u, devices[0]->getNumAvailableDevices()); - if (devices[0]->getNumAvailableDevices() > 1) { + EXPECT_LE(0u, devices[0]->getNumSubDevices()); + if (devices[0]->getNumSubDevices() > 1) { expectedRefCounts++; } - expectedRefCounts += devices[0]->getNumAvailableDevices(); + expectedRefCounts += std::max(devices[0]->getNumSubDevices(), 1u); EXPECT_EQ(expectedRefCounts, executionEnvironment->getRefInternalCount()); } diff --git a/opencl/test/unit_test/helpers/test_preamble_xehp_and_later.cpp b/opencl/test/unit_test/helpers/test_preamble_xehp_and_later.cpp index e717a3f68d..1a18412fa4 100644 --- a/opencl/test/unit_test/helpers/test_preamble_xehp_and_later.cpp +++ b/opencl/test/unit_test/helpers/test_preamble_xehp_and_later.cpp @@ -575,7 +575,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, RenderSurfaceStateXeHPAndLaterTests, givenSpecificP EncodeSurfaceState::encodeBuffer(&rssCmd, allocation->getGpuAddress(), allocation->getUnderlyingBufferSize(), buffer->getMocsValue(false, false, pClDevice->getRootDeviceIndex()), false, false, false, - pClDevice->getNumAvailableDevices(), allocation, pClDevice->getGmmHelper(), false, 1u); + pClDevice->getNumGenericSubDevices(), allocation, pClDevice->getGmmHelper(), false, 1u); EXPECT_EQ(FamilyType::RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT, rssCmd.getCoherencyType()); } diff --git a/opencl/test/unit_test/mem_obj/buffer_tests_xehp_and_later.cpp b/opencl/test/unit_test/mem_obj/buffer_tests_xehp_and_later.cpp index 3b9f2fb72b..b0b28d4847 100644 --- a/opencl/test/unit_test/mem_obj/buffer_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_tests_xehp_and_later.cpp @@ -35,7 +35,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterBufferTests, givenContextTypeDefaultWhe DebugManagerStateRestore restorer; DebugManager.flags.CreateMultipleSubDevices.set(1); initPlatform(); - EXPECT_EQ(1u, platform()->getClDevice(0)->getNumAvailableDevices()); + EXPECT_EQ(0u, platform()->getClDevice(0)->getNumGenericSubDevices()); using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; MockContext context(platform()->getClDevice(0)); context.contextType = ContextType::CONTEXT_TYPE_DEFAULT; @@ -280,7 +280,12 @@ HWCMDTEST_P(IGFX_XE_HP_CORE, MultiGpuGlobalAtomicsBufferTest, givenSetArgStatefu DebugManager.flags.CreateMultipleSubDevices.set(numAvailableDevices); DebugManager.flags.EnableMultiGpuAtomicsOptimization.set(enableMultiGpuAtomicsOptimization); initPlatform(); - EXPECT_EQ(numAvailableDevices, platform()->getClDevice(0)->getNumAvailableDevices()); + + if (numAvailableDevices == 1) { + EXPECT_EQ(0u, platform()->getClDevice(0)->getNumGenericSubDevices()); + } else { + EXPECT_EQ(numAvailableDevices, platform()->getClDevice(0)->getNumGenericSubDevices()); + } using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; MockContext context(platform()->getClDevice(0)); context.contextType = ContextType::CONTEXT_TYPE_DEFAULT; @@ -322,7 +327,11 @@ HWCMDTEST_P(IGFX_XE_HP_CORE, MultiGpuGlobalAtomicsBufferTest, givenSetSurfaceSta DebugManager.flags.CreateMultipleSubDevices.set(numAvailableDevices); DebugManager.flags.EnableMultiGpuAtomicsOptimization.set(enableMultiGpuAtomicsOptimization); initPlatform(); - EXPECT_EQ(numAvailableDevices, platform()->getClDevice(0)->getNumAvailableDevices()); + if (numAvailableDevices == 1) { + EXPECT_EQ(0u, platform()->getClDevice(0)->getNumGenericSubDevices()); + } else { + EXPECT_EQ(numAvailableDevices, platform()->getClDevice(0)->getNumGenericSubDevices()); + } auto size = MemoryConstants::pageSize; auto ptr = alignedMalloc(size, MemoryConstants::pageSize); diff --git a/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp b/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp index 1520d7940c..76d523f79b 100644 --- a/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp @@ -33,7 +33,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterImageTests, givenContextTypeDefaultWhen DebugManagerStateRestore restorer; DebugManager.flags.CreateMultipleSubDevices.set(1); initPlatform(); - EXPECT_EQ(1u, platform()->getClDevice(0)->getNumAvailableDevices()); + EXPECT_EQ(0u, platform()->getClDevice(0)->getNumGenericSubDevices()); using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; MockContext context(platform()->getClDevice(0)); context.contextType = ContextType::CONTEXT_TYPE_DEFAULT; @@ -269,7 +269,11 @@ HWCMDTEST_P(IGFX_XE_HP_CORE, MultiGpuGlobalAtomicsImageTest, givenAppendSurfaceS DebugManager.flags.EnableMultiGpuAtomicsOptimization.set(enableMultiGpuAtomicsOptimization); DebugManager.flags.CreateMultipleSubDevices.set(numAvailableDevices); initPlatform(); - EXPECT_EQ(numAvailableDevices, platform()->getClDevice(0)->getNumAvailableDevices()); + if (numAvailableDevices == 1) { + EXPECT_EQ(0u, platform()->getClDevice(0)->getNumGenericSubDevices()); + } else { + EXPECT_EQ(numAvailableDevices, platform()->getClDevice(0)->getNumGenericSubDevices()); + } using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; MockContext context(platform()->getClDevice(0)); context.contextType = contextType; diff --git a/opencl/test/unit_test/os_interface/device_factory_tests.cpp b/opencl/test/unit_test/os_interface/device_factory_tests.cpp index 4285b31a5a..065a4a758e 100644 --- a/opencl/test/unit_test/os_interface/device_factory_tests.cpp +++ b/opencl/test/unit_test/os_interface/device_factory_tests.cpp @@ -107,10 +107,10 @@ TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetWhenCreateDevicesThenProperNumbe auto devices = DeviceFactory::createDevices(*executionEnvironment); EXPECT_EQ(devices.size(), 4u); - EXPECT_EQ(devices[0]->getNumAvailableDevices(), 4u); - EXPECT_EQ(devices[1]->getNumAvailableDevices(), 2u); - EXPECT_EQ(devices[2]->getNumAvailableDevices(), 3u); - EXPECT_EQ(devices[3]->getNumAvailableDevices(), 4u); + EXPECT_EQ(devices[0]->getNumSubDevices(), 4u); + EXPECT_EQ(devices[1]->getNumSubDevices(), 2u); + EXPECT_EQ(devices[2]->getNumSubDevices(), 3u); + EXPECT_EQ(devices[3]->getNumSubDevices(), 4u); } TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToGreaterRootDeviceThanAvailableWhenCreateDevicesThenProperNumberOfDevicesIsReturned) { @@ -124,8 +124,9 @@ TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToGreaterRootDeviceThanAvailable auto devices = DeviceFactory::createDevices(*executionEnvironment); EXPECT_EQ(devices.size(), 2u); - EXPECT_EQ(devices[0]->getNumAvailableDevices(), 4u); - EXPECT_EQ(devices[1]->getNumAvailableDevices(), 1u); + EXPECT_EQ(devices[0]->getNumSubDevices(), 4u); + EXPECT_EQ(devices[1]->getNumGenericSubDevices(), 0u); + EXPECT_EQ(devices[1]->getNumSubDevices(), 0u); } TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToGreaterSubDeviceThanAvailableWhenCreateDevicesThenProperNumberOfDevicesIsReturned) { @@ -139,7 +140,7 @@ TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToGreaterSubDeviceThanAvailableW auto devices = DeviceFactory::createDevices(*executionEnvironment); EXPECT_EQ(devices.size(), 1u); - EXPECT_EQ(devices[0]->getNumAvailableDevices(), 4u); + EXPECT_EQ(devices[0]->getNumSubDevices(), 4u); } TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToRootDevicesOnlyWhenCreateDevicesThenProperNumberOfDevicesIsReturned) { @@ -153,8 +154,8 @@ TEST_F(DeviceFactoryTest, givenZeAffinityMaskSetToRootDevicesOnlyWhenCreateDevic auto devices = DeviceFactory::createDevices(*executionEnvironment); EXPECT_EQ(devices.size(), 2u); - EXPECT_EQ(devices[0]->getNumAvailableDevices(), 4u); - EXPECT_EQ(devices[1]->getNumAvailableDevices(), 4u); + EXPECT_EQ(devices[0]->getNumSubDevices(), 4u); + EXPECT_EQ(devices[1]->getNumSubDevices(), 4u); } TEST_F(DeviceFactoryTest, WhenOverridingEngineTypeThenDebugEngineIsReported) { diff --git a/opencl/test/unit_test/xe_hp_core/xehp/test_sub_devices_xehp.inl b/opencl/test/unit_test/xe_hp_core/xehp/test_sub_devices_xehp.inl index dcb614f62d..0f97aba50a 100644 --- a/opencl/test/unit_test/xe_hp_core/xehp/test_sub_devices_xehp.inl +++ b/opencl/test/unit_test/xe_hp_core/xehp/test_sub_devices_xehp.inl @@ -27,7 +27,8 @@ XEHPTEST_F(XeHPUsDeviceIdTest, givenRevisionAWhenCreatingEngineWithSubdevicesThe MockDevice device(executionEnvironment, 0); EXPECT_EQ(0u, device.engines.size()); device.createSubDevices(); - EXPECT_EQ(2u, device.getNumAvailableDevices()); + device.createEngines(); + EXPECT_EQ(2u, device.getNumGenericSubDevices()); auto hwInfo = device.getRootDeviceEnvironment().getMutableHardwareInfo(); const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo->platform.eProductFamily); @@ -47,7 +48,8 @@ XEHPTEST_F(XeHPUsDeviceIdTest, givenRevisionBWhenCreatingEngineWithSubdevicesThe MockDevice device(executionEnvironment, 0); EXPECT_EQ(0u, device.engines.size()); device.createSubDevices(); - EXPECT_EQ(2u, device.getNumAvailableDevices()); + device.createEngines(); + EXPECT_EQ(2u, device.getNumGenericSubDevices()); auto hwInfo = device.getRootDeviceEnvironment().getMutableHardwareInfo(); const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo->platform.eProductFamily); diff --git a/shared/source/command_container/cmdcontainer.cpp b/shared/source/command_container/cmdcontainer.cpp index 35478b9a63..34180862a7 100644 --- a/shared/source/command_container/cmdcontainer.cpp +++ b/shared/source/command_container/cmdcontainer.cpp @@ -52,7 +52,7 @@ ErrorCode CommandContainer::initialize(Device *device) { true /* allocateMemory*/, alignedSize, GraphicsAllocation::AllocationType::COMMAND_BUFFER, - (device->getNumAvailableDevices() > 1u) /* multiOsContextCapable */, + (device->getNumGenericSubDevices() > 1u) /* multiOsContextCapable */, false, device->getDeviceBitfield()}; @@ -72,7 +72,7 @@ ErrorCode CommandContainer::initialize(Device *device) { } constexpr size_t heapSize = 65536u; - heapHelper = std::unique_ptr(new HeapHelper(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumAvailableDevices() > 1u)); + heapHelper = std::unique_ptr(new HeapHelper(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumGenericSubDevices() > 1u)); for (uint32_t i = 0; i < IndirectHeap::Type::NUM_TYPES; i++) { if (NEO::ApiSpecificConfig::getBindlessConfiguration() && i != IndirectHeap::INDIRECT_OBJECT) { @@ -226,7 +226,7 @@ void CommandContainer::allocateNextCommandBuffer() { true /* allocateMemory*/, alignedSize, GraphicsAllocation::AllocationType::COMMAND_BUFFER, - (device->getNumAvailableDevices() > 1u) /* multiOsContextCapable */, + (device->getNumGenericSubDevices() > 1u) /* multiOsContextCapable */, false, device->getDeviceBitfield()}; diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index 32da32375d..ab9cc2ca75 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -535,7 +535,7 @@ bool CommandStreamReceiver::createWorkPartitionAllocation(const Device &device) if (!staticWorkPartitioningEnabled) { return false; } - UNRECOVERABLE_IF(device.getNumAvailableDevices() < 2); + UNRECOVERABLE_IF(device.getNumGenericSubDevices() < 2); AllocationProperties properties{this->rootDeviceIndex, true, 4096u, GraphicsAllocation::AllocationType::WORK_PARTITION_SURFACE, true, false, deviceBitfield}; this->workPartitionAllocation = getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index 83c2e941e4..49a8b9abfe 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -479,11 +479,8 @@ bool Device::getHostTimer(uint64_t *hostTimestamp) const { return getOSTime()->getCpuTime(hostTimestamp); } -uint32_t Device::getNumAvailableDevices() const { - if (subdevices.empty()) { - return 1u; - } - return getNumSubDevices(); +uint32_t Device::getNumGenericSubDevices() const { + return (hasRootCsr() ? getNumSubDevices() : 0); } Device *Device::getSubDevice(uint32_t deviceId) const { diff --git a/shared/source/device/device.h b/shared/source/device/device.h index 36e3edc339..848b35a838 100644 --- a/shared/source/device/device.h +++ b/shared/source/device/device.h @@ -108,7 +108,7 @@ class Device : public ReferenceTrackedObject { void allocateSyncBufferHandler(); virtual uint32_t getRootDeviceIndex() const = 0; - uint32_t getNumAvailableDevices() const; + uint32_t getNumGenericSubDevices() const; Device *getSubDevice(uint32_t deviceId) const; Device *getNearestGenericSubDevice(uint32_t deviceId); virtual Device *getRootDevice() const = 0; diff --git a/shared/source/device/root_device.cpp b/shared/source/device/root_device.cpp index c36bc84bf4..46e0f7fa3a 100644 --- a/shared/source/device/root_device.cpp +++ b/shared/source/device/root_device.cpp @@ -39,7 +39,7 @@ Device *RootDevice::getRootDevice() const { void RootDevice::createBindlessHeapsHelper() { if (ApiSpecificConfig::getBindlessConfiguration()) { - this->executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->createBindlessHeapsHelper(getMemoryManager(), getNumAvailableDevices() > 1, rootDeviceIndex); + this->executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->createBindlessHeapsHelper(getMemoryManager(), getNumGenericSubDevices() > 1, rootDeviceIndex); } } diff --git a/shared/source/device/sub_device.cpp b/shared/source/device/sub_device.cpp index cf5ee449b5..ad1ba6fd2e 100644 --- a/shared/source/device/sub_device.cpp +++ b/shared/source/device/sub_device.cpp @@ -47,7 +47,7 @@ Device *SubDevice::getRootDevice() const { uint64_t SubDevice::getGlobalMemorySize(uint32_t deviceBitfield) const { auto globalMemorySize = Device::getGlobalMemorySize(static_cast(maxNBitValue(rootDevice.getNumSubDevices()))); - return globalMemorySize / rootDevice.getNumAvailableDevices(); + return globalMemorySize / std::max(rootDevice.getNumGenericSubDevices(), 1u); } } // namespace NEO diff --git a/shared/test/common/helpers/bindless_heaps_helper_tests.cpp b/shared/test/common/helpers/bindless_heaps_helper_tests.cpp index a3db1629e1..9714f5d27f 100644 --- a/shared/test/common/helpers/bindless_heaps_helper_tests.cpp +++ b/shared/test/common/helpers/bindless_heaps_helper_tests.cpp @@ -34,13 +34,13 @@ TEST(BindlessHeapsHelper, givenBindlessModeFlagDisabledWhenCreatingRootDevicesTh using BindlessHeapsHelperTests = Test; TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenItsCreatedThenSpecialSshAllocatedAtHeapBegining) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); auto specialSshAllocation = bindlessHeapHelper->specialSsh->getGraphicsAllocation(); EXPECT_EQ(specialSshAllocation->getGpuAddress(), specialSshAllocation->getGpuBaseAddress()); } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapThenHeapUsedSpaceGrow) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); auto usedBefore = bindlessHeapHelper->globalSsh->getUsed(); MockGraphicsAllocation alloc; @@ -51,7 +51,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapThen } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapThenMemoryAtReturnedOffsetIsCorrect) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); MockGraphicsAllocation alloc; size_t size = 0x40; @@ -62,7 +62,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapThen } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapTwiceForTheSameAllocationThenTheSameOffsetReturned) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); MockGraphicsAllocation alloc; size_t size = 0x40; @@ -73,7 +73,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapTwic } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapTwiceForDifferentAllocationThenDifferentOffsetsReturned) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); MockGraphicsAllocation alloc1; MockGraphicsAllocation alloc2; @@ -87,7 +87,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapTwic } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocatingMoreSsThenNewHeapAllocationCreated) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); size_t ssSize = 0x40; auto ssCount = bindlessHeapHelper->globalSsh->getAvailableSpace() / ssSize; auto graphicsAllocations = std::make_unique(ssCount); @@ -104,27 +104,27 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocatingMoreSsThen } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenCreatedThenAllocationsHaveTheSameBaseAddress) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); for (auto allocation : bindlessHeapHelper->ssHeapsAllocations) { EXPECT_EQ(allocation->getGpuBaseAddress(), bindlessHeapHelper->getGlobalHeapsBase()); } } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenGetDefaultBorderColorOffsetCalledThenCorrectOffsetReturned) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); auto expectedOffset = bindlessHeapHelper->borderColorStates->getGpuAddress() - bindlessHeapHelper->borderColorStates->getGpuBaseAddress(); EXPECT_EQ(bindlessHeapHelper->getDefaultBorderColorOffset(), expectedOffset); } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenGetAlphaBorderColorOffsetCalledThenCorrectOffsetReturned) { auto borderColorSize = 0x40; - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); auto expectedOffset = bindlessHeapHelper->borderColorStates->getGpuAddress() - bindlessHeapHelper->borderColorStates->getGpuBaseAddress() + borderColorSize; EXPECT_EQ(bindlessHeapHelper->getAlphaBorderColorOffset(), expectedOffset); } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInSpecialHeapThenOffsetLessThanFrontWindowSize) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); MockGraphicsAllocation alloc; size_t size = 0x40; auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::SPECIAL_SSH); @@ -132,7 +132,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInSpecialH EXPECT_LT(ssInHeapInfo.surfaceStateOffset, frontWindowSize); } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInGlobalHeapThenOffsetLessThanFrontWindowSize) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); MockGraphicsAllocation alloc; size_t size = 0x40; auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH); @@ -141,7 +141,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInGlobalHe } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInScratchHeapThenOffsetLessThanFrontWindowSize) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); MockGraphicsAllocation alloc; size_t size = 0x40; auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::SCRATCH_SSH); @@ -150,7 +150,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInScratchH } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInGlobalDshThenOffsetGreaterOrEqualFrontWindowSize) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); MockGraphicsAllocation alloc; size_t size = 0x40; auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH); @@ -161,7 +161,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInGlobalDs TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenFreeGraphicsMemoryIsCalledThenSSinHeapInfoShouldBePlacedInReuseVector) { DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); MockBindlesHeapsHelper *bindlessHeapHelperPtr = bindlessHeapHelper.get(); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapHelper.release()); MockGraphicsAllocation *alloc = new MockGraphicsAllocation; @@ -177,7 +177,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenFreeGraphicsMemoryIs TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperPreviousAllocationThenItShouldBeReused) { DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); MockBindlesHeapsHelper *bindlessHeapHelperPtr = bindlessHeapHelper.get(); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapHelper.release()); MockGraphicsAllocation *alloc = new MockGraphicsAllocation; diff --git a/shared/test/common/mocks/ult_device_factory.cpp b/shared/test/common/mocks/ult_device_factory.cpp index 540df332c9..8b679f665f 100644 --- a/shared/test/common/mocks/ult_device_factory.cpp +++ b/shared/test/common/mocks/ult_device_factory.cpp @@ -37,8 +37,8 @@ UltDeviceFactory::UltDeviceFactory(uint32_t rootDevicesCount, uint32_t subDevice for (auto &pCreatedDevice : createdDevices) { pCreatedDevice->incRefInternal(); - if (pCreatedDevice->getNumAvailableDevices() > 1) { - for (uint32_t i = 0; i < pCreatedDevice->getNumAvailableDevices(); i++) { + if (pCreatedDevice->getNumSubDevices() > 1) { + for (uint32_t i = 0; i < pCreatedDevice->getNumSubDevices(); i++) { this->subDevices.push_back(static_cast(pCreatedDevice->getSubDevice(i))); } } diff --git a/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp b/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp index 775d7d7755..a3f11f134d 100644 --- a/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp +++ b/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp @@ -1156,7 +1156,9 @@ HWTEST_F(BindlessCommandEncodeStatesTesttt, givenBindlessKernelWhenBindlessModeE auto commandContainer = std::make_unique(); commandContainer->initialize(pDevice); commandContainer->setDirtyStateForAllHeaps(false); - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), + pDevice->getNumGenericSubDevices() > 1, + pDevice->getRootDeviceIndex()); uint32_t numBindingTable = 1; BINDING_TABLE_STATE bindingTableState = FamilyType::cmdInitBindingTableState; @@ -1191,7 +1193,9 @@ HWTEST_F(BindlessCommandEncodeStatesTesttt, givenBindfulKernelWhenBindlessModeEn auto commandContainer = std::make_unique(); commandContainer->initialize(pDevice); commandContainer->setDirtyStateForAllHeaps(false); - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), + pDevice->getNumGenericSubDevices() > 1, + pDevice->getRootDeviceIndex()); uint32_t numBindingTable = 1; BINDING_TABLE_STATE bindingTableState = FamilyType::cmdInitBindingTableState; @@ -1226,7 +1230,9 @@ HWTEST_F(BindlessCommandEncodeStatesTesttt, givenBindlessModeEnabledWhenDispatch auto commandContainer = std::make_unique(); commandContainer->initialize(pDevice); commandContainer->setDirtyStateForAllHeaps(false); - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), + pDevice->getNumGenericSubDevices() > 1, + pDevice->getRootDeviceIndex()); uint32_t numBindingTable = 1; BINDING_TABLE_STATE bindingTableState = FamilyType::cmdInitBindingTableState; @@ -1274,7 +1280,9 @@ HWTEST_F(BindlessCommandEncodeStatesTest, givenGlobalBindlessHeapsWhenDispatchin uint32_t numSamplers = 1; SAMPLER_BORDER_COLOR_STATE samplerState; samplerState.init(); - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), + pDevice->getNumGenericSubDevices() > 1, + pDevice->getRootDeviceIndex()); uint32_t dims[] = {2, 1, 1}; std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); @@ -1305,7 +1313,9 @@ HWTEST_F(BindlessCommandEncodeStatesTest, givenBindlessModeDisabledelWithSampler uint32_t numSamplers = 1; SAMPLER_STATE samplerState; memset(&samplerState, 2, sizeof(SAMPLER_STATE)); - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), + pDevice->getNumGenericSubDevices() > 1, + pDevice->getRootDeviceIndex()); uint32_t dims[] = {2, 1, 1}; std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); diff --git a/shared/test/unit_test/encoders/test_encode_states.cpp b/shared/test/unit_test/encoders/test_encode_states.cpp index 43ac7310d8..508228f7f9 100644 --- a/shared/test/unit_test/encoders/test_encode_states.cpp +++ b/shared/test/unit_test/encoders/test_encode_states.cpp @@ -59,7 +59,9 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorWit DebugManager.flags.UseBindlessMode.set(1); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; uint32_t numSamplers = 1; - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), + pDevice->getNumGenericSubDevices() > 1, + pDevice->getRootDeviceIndex()); uint32_t borderColorSize = 0x40; SAMPLER_BORDER_COLOR_STATE samplerState; @@ -78,7 +80,9 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorWit DebugManager.flags.UseBindlessMode.set(1); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; uint32_t numSamplers = 1; - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), + pDevice->getNumGenericSubDevices() > 1, + pDevice->getRootDeviceIndex()); uint32_t borderColorSize = 0x40; SAMPLER_BORDER_COLOR_STATE samplerState; @@ -98,7 +102,9 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsRe DebugManager.flags.UseBindlessMode.set(1); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; uint32_t numSamplers = 1; - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), + pDevice->getNumGenericSubDevices() > 1, + pDevice->getRootDeviceIndex()); uint32_t borderColorSize = 0x40; SAMPLER_BORDER_COLOR_STATE samplerState; @@ -114,7 +120,9 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsGr DebugManager.flags.UseBindlessMode.set(1); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; uint32_t numSamplers = 1; - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), + pDevice->getNumGenericSubDevices() > 1, + pDevice->getRootDeviceIndex()); uint32_t borderColorSize = 0x40; SAMPLER_BORDER_COLOR_STATE samplerState; @@ -130,7 +138,9 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsBl DebugManager.flags.UseBindlessMode.set(1); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; uint32_t numSamplers = 1; - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), + pDevice->getNumGenericSubDevices() > 1, + pDevice->getRootDeviceIndex()); uint32_t borderColorSize = 0x40; SAMPLER_BORDER_COLOR_STATE samplerState; @@ -146,7 +156,9 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsAl DebugManager.flags.UseBindlessMode.set(1); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; uint32_t numSamplers = 1; - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), + pDevice->getNumGenericSubDevices() > 1, + pDevice->getRootDeviceIndex()); uint32_t borderColorSize = 0x40; SAMPLER_BORDER_COLOR_STATE samplerState; diff --git a/shared/test/unit_test/scratch_space_controler/scratch_space_controler_xehp_and_later_tests.cpp b/shared/test/unit_test/scratch_space_controler/scratch_space_controler_xehp_and_later_tests.cpp index 35ab638c30..b1c632e22a 100644 --- a/shared/test/unit_test/scratch_space_controler/scratch_space_controler_xehp_and_later_tests.cpp +++ b/shared/test/unit_test/scratch_space_controler/scratch_space_controler_xehp_and_later_tests.cpp @@ -77,7 +77,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenDirtyScratchAllocationO std::unique_ptr scratchController = std::make_unique(pDevice->getRootDeviceIndex(), *execEnv, *csr.getInternalAllocationStorage()); - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); bool gsbaStateDirty = false; bool frontEndStateDirty = false; scratchController->scratchDirty = true; @@ -97,7 +97,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenNotDirtyScratchAllocati std::unique_ptr scratchController = std::make_unique(pDevice->getRootDeviceIndex(), *execEnv, *csr.getInternalAllocationStorage()); - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); bool gsbaStateDirty = false; bool frontEndStateDirty = false; scratchController->scratchDirty = false; @@ -119,7 +119,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenPrivateScratchEnabledWh std::unique_ptr scratchController = std::make_unique(pDevice->getRootDeviceIndex(), *execEnv, *csr.getInternalAllocationStorage()); - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); bool gsbaStateDirty = false; bool frontEndStateDirty = false; scratchController->scratchDirty = true; @@ -141,7 +141,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenPrivateScratchDisabledW std::unique_ptr scratchController = std::make_unique(pDevice->getRootDeviceIndex(), *execEnv, *csr.getInternalAllocationStorage()); - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); bool gsbaStateDirty = false; bool frontEndStateDirty = false; scratchController->scratchDirty = true;