diff --git a/opencl/source/cl_device/cl_device.cpp b/opencl/source/cl_device/cl_device.cpp index 94af59e87d..aa6a706076 100644 --- a/opencl/source/cl_device/cl_device.cpp +++ b/opencl/source/cl_device/cl_device.cpp @@ -88,6 +88,12 @@ unique_ptr_if_unused ClDevice::decRefInternal() { return pParentDevice->decRefInternal(); } +bool ClDevice::isOcl21Conformant() const { + auto &hwInfo = device.getHardwareInfo(); + return (hwInfo.capabilityTable.supportsOcl21Features && hwInfo.capabilityTable.supportsDeviceEnqueue && + hwInfo.capabilityTable.supportsPipes && hwInfo.capabilityTable.supportsIndependentForwardProgress); +} + void ClDevice::allocateSyncBufferHandler() { TakeOwnershipWrapper lock(*this); if (syncBufferHandler.get() == nullptr) { diff --git a/opencl/source/cl_device/cl_device.h b/opencl/source/cl_device/cl_device.h index 0938cff630..11340a4839 100644 --- a/opencl/source/cl_device/cl_device.h +++ b/opencl/source/cl_device/cl_device.h @@ -57,6 +57,7 @@ class ClDevice : public BaseObject<_cl_device_id> { unsigned int getEnabledClVersion() const { return enabledClVersion; }; bool areOcl21FeaturesEnabled() const { return ocl21FeaturesEnabled; }; + bool isOcl21Conformant() const; void retainApi(); unique_ptr_if_unused releaseApi(); diff --git a/opencl/source/cl_device/cl_device_caps.cpp b/opencl/source/cl_device/cl_device_caps.cpp index c814ab3064..8daea4a6bb 100644 --- a/opencl/source/cl_device/cl_device_caps.cpp +++ b/opencl/source/cl_device/cl_device_caps.cpp @@ -420,7 +420,7 @@ void ClDevice::initializeOpenclCAllVersions() { openClCVersion.version = CL_MAKE_VERSION(1, 2, 0); deviceInfo.openclCAllVersions.push_back(openClCVersion); - if (ocl21FeaturesEnabled) { + if (isOcl21Conformant()) { openClCVersion.version = CL_MAKE_VERSION(2, 0, 0); deviceInfo.openclCAllVersions.push_back(openClCVersion); } diff --git a/opencl/test/unit_test/device/device_caps_tests.cpp b/opencl/test/unit_test/device/device_caps_tests.cpp index 377f0d726a..7466701f12 100644 --- a/opencl/test/unit_test/device/device_caps_tests.cpp +++ b/opencl/test/unit_test/device/device_caps_tests.cpp @@ -55,7 +55,7 @@ struct DeviceGetCapsTest : public ::testing::Test { EXPECT_EQ(CL_MAKE_VERSION(1u, 1u, 0u), (++openclCWithVersionIterator)->version); EXPECT_EQ(CL_MAKE_VERSION(1u, 2u, 0u), (++openclCWithVersionIterator)->version); - if (clDevice.areOcl21FeaturesEnabled()) { + if (clDevice.isOcl21Conformant()) { EXPECT_EQ(CL_MAKE_VERSION(2u, 0u, 0u), (++openclCWithVersionIterator)->version); } if (clDevice.getEnabledClVersion() == 30) { @@ -251,6 +251,10 @@ TEST_F(DeviceGetCapsTest, WhenCreatingDeviceThenCapsArePopulatedCorrectly) { if (device->getHardwareInfo().capabilityTable.supportsOcl21Features == false && is64bit) { EXPECT_TRUE(sharedCaps.force32BitAddressess); } + + if (caps.numericClVersion == 21) { + EXPECT_TRUE(device->isOcl21Conformant()); + } } HWTEST_F(DeviceGetCapsTest, givenDeviceWhenAskingForSubGroupSizesThenReturnCorrectValues) { diff --git a/opencl/test/unit_test/device/device_tests.cpp b/opencl/test/unit_test/device/device_tests.cpp index 43aee21dda..cb89807ab2 100644 --- a/opencl/test/unit_test/device/device_tests.cpp +++ b/opencl/test/unit_test/device/device_tests.cpp @@ -47,6 +47,27 @@ TEST_F(DeviceTest, WhenDeviceIsCreatedThenEnabledClVersionMatchesHardwareInfo) { EXPECT_EQ(version, version2); } +TEST_F(DeviceTest, WhenDeviceIsCheckedForOcl21ConformanceThenCorrectValueIsReturned) { + auto hwInfo = pClDevice->getHardwareInfo(); + for (auto supportsOcl21Features : ::testing::Bool()) { + hwInfo.capabilityTable.supportsOcl21Features = supportsOcl21Features; + for (auto supportsIfp : ::testing::Bool()) { + hwInfo.capabilityTable.supportsIndependentForwardProgress = supportsIfp; + for (auto supportsDeviceEnqueue : ::testing::Bool()) { + hwInfo.capabilityTable.supportsDeviceEnqueue = supportsDeviceEnqueue; + for (auto supportsPipes : ::testing::Bool()) { + hwInfo.capabilityTable.supportsPipes = supportsPipes; + + auto pClDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); + + auto expectedOcl21Conformance = (supportsOcl21Features && supportsIfp && supportsDeviceEnqueue && supportsPipes); + EXPECT_EQ(expectedOcl21Conformance, pClDevice->isOcl21Conformant()); + } + } + } + } +} + TEST_F(DeviceTest, givenDeviceWhenEngineIsCreatedThenSetInitialValueForTag) { for (auto &engine : pDevice->engines) { auto tagAddress = engine.commandStreamReceiver->getTagAddress();