diff --git a/runtime/device/device_caps.cpp b/runtime/device/device_caps.cpp index ac5981f6e4..ff863a236a 100644 --- a/runtime/device/device_caps.cpp +++ b/runtime/device/device_caps.cpp @@ -211,9 +211,15 @@ void Device::initializeCaps() { deviceInfo.compilerAvailable = CL_TRUE; deviceInfo.parentDevice = nullptr; deviceInfo.partitionMaxSubDevices = HwHelper::getSubDevicesCount(&hwInfo); - 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; + if (deviceInfo.partitionMaxSubDevices > 1) { + 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; + } else { + deviceInfo.partitionMaxSubDevices = 0; + deviceInfo.partitionProperties[0] = 0; + deviceInfo.partitionAffinityDomain = 0; + } deviceInfo.partitionType[0] = 0; deviceInfo.preferredVectorWidthChar = 16; deviceInfo.preferredVectorWidthShort = 8; diff --git a/unit_tests/api/cl_create_sub_devices_tests.inl b/unit_tests/api/cl_create_sub_devices_tests.inl index 3dca908e45..005edef06c 100644 --- a/unit_tests/api/cl_create_sub_devices_tests.inl +++ b/unit_tests/api/cl_create_sub_devices_tests.inl @@ -124,6 +124,12 @@ struct clCreateSubDevicesDeviceInfoTests : clCreateSubDevicesTests { cl_device_partition_property expectedSubDevicePartitionType[3] = {CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_NUMA, 0}; + cl_device_id expectedRootDeviceWithoutSubDevicesParentDevice = nullptr; + cl_device_affinity_domain expectedRootDeviceWithoutSubDevicesPartitionAffinityDomain = 0; + cl_uint expectedRootDeviceWithoutSubDevicesPartitionMaxSubDevices = 0; + cl_device_partition_property expectedRootDeviceWithoutSubDevicesPartitionProperties[2] = {0}; + cl_device_partition_property expectedRootDeviceWithoutSubDevicesPartitionType[3] = {0}; + cl_device_id parentDevice; cl_device_affinity_domain partitionAffinityDomain; cl_uint partitionMaxSubDevices; @@ -157,6 +163,17 @@ TEST_F(clCreateSubDevicesDeviceInfoTests, WhenGettingSubDeviceRelatedDeviceInfoT } } +TEST_F(clCreateSubDevicesDeviceInfoTests, GivenRootDeviceWithoutSubDevicesWhenGettingSubDeviceRelatedDeviceInfoThenCorrectValuesAreSet) { + setup(1); + + auto &rootDeviceInfo = device->getDeviceInfo(); + EXPECT_EQ(expectedRootDeviceWithoutSubDevicesParentDevice, rootDeviceInfo.parentDevice); + EXPECT_EQ(expectedRootDeviceWithoutSubDevicesPartitionAffinityDomain, rootDeviceInfo.partitionAffinityDomain); + EXPECT_EQ(expectedRootDeviceWithoutSubDevicesPartitionMaxSubDevices, rootDeviceInfo.partitionMaxSubDevices); + EXPECT_EQ(expectedRootDeviceWithoutSubDevicesPartitionProperties[0], rootDeviceInfo.partitionProperties[0]); + EXPECT_EQ(expectedRootDeviceWithoutSubDevicesPartitionType[0], rootDeviceInfo.partitionType[0]); +} + TEST_F(clCreateSubDevicesDeviceInfoTests, WhenGettingSubDeviceRelatedDeviceInfoViaApiThenCorrectValuesAreSet) { setup(4); @@ -198,4 +215,23 @@ TEST_F(clCreateSubDevicesDeviceInfoTests, WhenGettingSubDeviceRelatedDeviceInfoV } } +TEST_F(clCreateSubDevicesDeviceInfoTests, GivenRootDeviceWithoutSubDevicesWhenGettingSubDeviceRelatedDeviceInfoViaApiThenCorrectValuesAreSet) { + setup(1); + + clGetDeviceInfo(device.get(), CL_DEVICE_PARENT_DEVICE, sizeof(parentDevice), &parentDevice, nullptr); + EXPECT_EQ(expectedRootDeviceWithoutSubDevicesParentDevice, parentDevice); + + clGetDeviceInfo(device.get(), CL_DEVICE_PARTITION_AFFINITY_DOMAIN, sizeof(partitionAffinityDomain), &partitionAffinityDomain, nullptr); + EXPECT_EQ(expectedRootDeviceWithoutSubDevicesPartitionAffinityDomain, partitionAffinityDomain); + + clGetDeviceInfo(device.get(), CL_DEVICE_PARTITION_MAX_SUB_DEVICES, sizeof(partitionMaxSubDevices), &partitionMaxSubDevices, nullptr); + EXPECT_EQ(expectedRootDeviceWithoutSubDevicesPartitionMaxSubDevices, partitionMaxSubDevices); + + clGetDeviceInfo(device.get(), CL_DEVICE_PARTITION_PROPERTIES, sizeof(partitionProperties), &partitionProperties, nullptr); + EXPECT_EQ(expectedRootDeviceWithoutSubDevicesPartitionProperties[0], partitionProperties[0]); + + clGetDeviceInfo(device.get(), CL_DEVICE_PARTITION_TYPE, sizeof(partitionType), &partitionType, nullptr); + EXPECT_EQ(expectedRootDeviceWithoutSubDevicesPartitionType[0], partitionType[0]); +} + } // namespace ULT