diff --git a/opencl/extensions/public/cl_ext_private.h b/opencl/extensions/public/cl_ext_private.h index ae52c0a8ab..cbc1784186 100644 --- a/opencl/extensions/public/cl_ext_private.h +++ b/opencl/extensions/public/cl_ext_private.h @@ -192,3 +192,21 @@ typedef struct _cl_queue_family_properties_intel { cl_uint count; char name[CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL]; } cl_queue_family_properties_intel; + +/****************************** +* DEVICE ATTRIBUTE QUERY * +*******************************/ + +/* For GPU devices, version 1.0.0: */ +#define CL_DEVICE_IP_VERSION_INTEL 0x4250 +#define CL_DEVICE_ID_INTEL 0x4251 +#define CL_DEVICE_NUM_SLICES_INTEL 0x4252 +#define CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL 0x4253 +#define CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL 0x4254 +#define CL_DEVICE_NUM_THREADS_PER_EU_INTEL 0x4255 +#define CL_DEVICE_FEATURE_CAPABILITIES_INTEL 0x4256 + +typedef cl_bitfield cl_device_feature_capabilities_intel; + +/* For GPU devices, version 1.0.0: */ +#define CL_DEVICE_FEATURE_FLAG_DP4A_INTEL (1 << 0) diff --git a/opencl/source/cl_device/cl_device_info.cpp b/opencl/source/cl_device/cl_device_info.cpp index b9cd7a27c1..3322067fc4 100644 --- a/opencl/source/cl_device/cl_device_info.cpp +++ b/opencl/source/cl_device/cl_device_info.cpp @@ -10,6 +10,7 @@ #include "shared/source/device/device.h" #include "shared/source/device/device_info.h" #include "shared/source/helpers/get_info.h" +#include "shared/source/helpers/hw_helper.h" #include "shared/source/os_interface/os_time.h" #include "opencl/source/cl_device/cl_device.h" @@ -65,7 +66,7 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName, size_t srcSize = GetInfo::invalidSourceSize; size_t retSize = 0; size_t value = 0u; - cl_uint param; + ClDeviceInfoParam param{}; const void *src = nullptr; // clang-format off @@ -176,8 +177,8 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName, case CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES: if (paramValueSize == sizeof(cl_bool)) { srcSize = retSize = sizeof(cl_bool); - param = (deviceInfo.deviceEnqueueSupport > 0u) ? CL_TRUE : CL_FALSE; - src = ¶m; + param.boolean = (deviceInfo.deviceEnqueueSupport > 0u) ? CL_TRUE : CL_FALSE; + src = ¶m.boolean; } else { getCap(src, srcSize, retSize); } @@ -185,8 +186,8 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName, case CL_DEVICE_NUM_SIMULTANEOUS_INTEROPS_INTEL: if (simultaneousInterops.size() > 1u) { srcSize = retSize = sizeof(cl_uint); - param = 1u; - src = ¶m; + param.uint = 1u; + src = ¶m.uint; } break; case CL_DEVICE_SIMULTANEOUS_INTEROPS_INTEL: @@ -202,9 +203,9 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName, case CL_DEVICE_REFERENCE_COUNT: { cl_int ref = this->getReference(); DEBUG_BREAK_IF(ref != 1 && !deviceInfo.parentDevice); - param = static_cast(ref); - src = ¶m; - retSize = srcSize = sizeof(param); + param.uint = static_cast(ref); + src = ¶m.uint; + retSize = srcSize = sizeof(param.uint); break; } case CL_DEVICE_PARTITION_PROPERTIES: @@ -242,6 +243,49 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName, src = deviceInfo.supportedThreadArbitrationPolicies.data(); retSize = srcSize = deviceInfo.supportedThreadArbitrationPolicies.size() * sizeof(cl_uint); break; + case CL_DEVICE_IP_VERSION_INTEL: { + auto &clHwHelper = ClHwHelper::get(getHardwareInfo().platform.eRenderCoreFamily); + param.uint = clHwHelper.getDeviceIpVersion(getHardwareInfo()); + src = ¶m.uint; + retSize = srcSize = sizeof(cl_version); + break; + } + case CL_DEVICE_ID_INTEL: + param.uint = getHardwareInfo().platform.usDeviceID; + src = ¶m.uint; + 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)); + src = ¶m.uint; + retSize = srcSize = sizeof(cl_uint); + break; + case CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL: { + const auto >SysInfo = getHardwareInfo().gtSystemInfo; + param.uint = gtSysInfo.SubSliceCount / gtSysInfo.SliceCount; + src = ¶m.uint; + retSize = srcSize = sizeof(cl_uint); + break; + } + case CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL: + param.uint = getHardwareInfo().gtSystemInfo.MaxEuPerSubSlice; + src = ¶m.uint; + retSize = srcSize = sizeof(cl_uint); + break; + case CL_DEVICE_NUM_THREADS_PER_EU_INTEL: { + const auto >SysInfo = getHardwareInfo().gtSystemInfo; + param.uint = gtSysInfo.ThreadCount / gtSysInfo.EUCount; + src = ¶m.uint; + retSize = srcSize = sizeof(cl_uint); + break; + } + case CL_DEVICE_FEATURE_CAPABILITIES_INTEL: { + auto &clHwHelper = ClHwHelper::get(getHardwareInfo().platform.eRenderCoreFamily); + param.bitfield = clHwHelper.getSupportedDeviceFeatureCapabilities(); + src = ¶m.bitfield; + retSize = srcSize = sizeof(cl_device_feature_capabilities_intel); + break; + } default: if (getDeviceInfoForImage(paramName, src, srcSize, retSize) && !getSharedDeviceInfo().imageSupport) { src = &value; diff --git a/opencl/source/cl_device/cl_device_info.h b/opencl/source/cl_device/cl_device_info.h index 6e1ba20545..855125a493 100644 --- a/opencl/source/cl_device/cl_device_info.h +++ b/opencl/source/cl_device/cl_device_info.h @@ -19,6 +19,14 @@ namespace NEO { using OpenClCFeaturesContainer = StackVec; +struct ClDeviceInfoParam { + union { + cl_bool boolean; + cl_uint uint; + cl_bitfield bitfield; + }; +}; + // clang-format off struct ClDeviceInfo { cl_name_version ilsWithVersion[1]; diff --git a/opencl/source/gen11/cl_hw_helper_gen11.cpp b/opencl/source/gen11/cl_hw_helper_gen11.cpp index 8ce73ee4b4..e0c574cf40 100644 --- a/opencl/source/gen11/cl_hw_helper_gen11.cpp +++ b/opencl/source/gen11/cl_hw_helper_gen11.cpp @@ -23,6 +23,11 @@ void populateFactoryTable>() { clHwHelperFactory[gfxCore] = &ClHwHelperHw::get(); } +template <> +cl_version ClHwHelperHw::getDeviceIpVersion(const HardwareInfo &hwInfo) const { + return makeDeviceIpVersion(11, 0, 0); +} + template class ClHwHelperHw; } // namespace NEO diff --git a/opencl/source/gen12lp/cl_hw_helper_gen12lp.cpp b/opencl/source/gen12lp/cl_hw_helper_gen12lp.cpp index 1263d3a09c..dc6dcf5285 100644 --- a/opencl/source/gen12lp/cl_hw_helper_gen12lp.cpp +++ b/opencl/source/gen12lp/cl_hw_helper_gen12lp.cpp @@ -23,6 +23,16 @@ void populateFactoryTable>() { clHwHelperFactory[gfxCore] = &ClHwHelperHw::get(); } +template <> +cl_device_feature_capabilities_intel ClHwHelperHw::getSupportedDeviceFeatureCapabilities() const { + return CL_DEVICE_FEATURE_FLAG_DP4A_INTEL; +} + +template <> +cl_version ClHwHelperHw::getDeviceIpVersion(const HardwareInfo &hwInfo) const { + return makeDeviceIpVersion(12, 0, makeDeviceRevision(hwInfo)); +} + template class ClHwHelperHw; } // namespace NEO diff --git a/opencl/source/gen8/cl_hw_helper_gen8.cpp b/opencl/source/gen8/cl_hw_helper_gen8.cpp index 3c75aaa232..bf0e18d344 100644 --- a/opencl/source/gen8/cl_hw_helper_gen8.cpp +++ b/opencl/source/gen8/cl_hw_helper_gen8.cpp @@ -23,6 +23,11 @@ void populateFactoryTable>() { clHwHelperFactory[gfxCore] = &ClHwHelperHw::get(); } +template <> +cl_version ClHwHelperHw::getDeviceIpVersion(const HardwareInfo &hwInfo) const { + return makeDeviceIpVersion(8, 0, 0); +} + template class ClHwHelperHw; } // namespace NEO diff --git a/opencl/source/gen9/cl_hw_helper_gen9.cpp b/opencl/source/gen9/cl_hw_helper_gen9.cpp index 396024a0ab..64d8f03ce7 100644 --- a/opencl/source/gen9/cl_hw_helper_gen9.cpp +++ b/opencl/source/gen9/cl_hw_helper_gen9.cpp @@ -23,6 +23,11 @@ void populateFactoryTable>() { clHwHelperFactory[gfxCore] = &ClHwHelperHw::get(); } +template <> +cl_version ClHwHelperHw::getDeviceIpVersion(const HardwareInfo &hwInfo) const { + return makeDeviceIpVersion(9, 0, 0); +} + template class ClHwHelperHw; } // namespace NEO diff --git a/opencl/source/helpers/cl_device_helpers.cpp b/opencl/source/helpers/cl_device_helpers.cpp index e7855ecfc5..a29bfac072 100644 --- a/opencl/source/helpers/cl_device_helpers.cpp +++ b/opencl/source/helpers/cl_device_helpers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2020 Intel Corporation + * Copyright (C) 2018-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -8,5 +8,5 @@ #include "opencl/source/helpers/cl_device_helpers.h" namespace NEO { -void ClDeviceHelper::getExtraDeviceInfo(const ClDevice &clDevice, cl_device_info paramName, cl_uint ¶m, const void *&src, size_t &size, size_t &retSize) {} +void ClDeviceHelper::getExtraDeviceInfo(const ClDevice &clDevice, cl_device_info paramName, ClDeviceInfoParam ¶m, const void *&src, size_t &size, size_t &retSize) {} } // namespace NEO diff --git a/opencl/source/helpers/cl_device_helpers.h b/opencl/source/helpers/cl_device_helpers.h index fa54e4c764..0b007c01d7 100644 --- a/opencl/source/helpers/cl_device_helpers.h +++ b/opencl/source/helpers/cl_device_helpers.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2020 Intel Corporation + * Copyright (C) 2018-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -11,8 +11,9 @@ #include namespace NEO { class ClDevice; +struct ClDeviceInfoParam; namespace ClDeviceHelper { -void getExtraDeviceInfo(const ClDevice &clDevice, cl_device_info paramName, cl_uint ¶m, const void *&src, size_t &size, size_t &retSize); +void getExtraDeviceInfo(const ClDevice &clDevice, cl_device_info paramName, ClDeviceInfoParam ¶m, const void *&src, size_t &size, size_t &retSize); }; // namespace ClDeviceHelper } // namespace NEO diff --git a/opencl/source/helpers/cl_hw_helper.cpp b/opencl/source/helpers/cl_hw_helper.cpp index 31e0a893dc..ec1c681b29 100644 --- a/opencl/source/helpers/cl_hw_helper.cpp +++ b/opencl/source/helpers/cl_hw_helper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -7,6 +7,8 @@ #include "opencl/source/helpers/cl_hw_helper.h" +#include "shared/source/helpers/hw_info.h" + namespace NEO { ClHwHelper *clHwHelperFactory[IGFX_MAX_CORE] = {}; @@ -15,4 +17,12 @@ ClHwHelper &ClHwHelper::get(GFXCORE_FAMILY gfxCore) { return *clHwHelperFactory[gfxCore]; } +uint8_t ClHwHelper::makeDeviceRevision(const HardwareInfo &hwInfo) { + return static_cast(!hwInfo.capabilityTable.isIntegratedDevice); +} + +cl_version ClHwHelper::makeDeviceIpVersion(uint16_t major, uint8_t minor, uint8_t revision) { + return (major << 16) | (minor << 8) | revision; +} + } // namespace NEO diff --git a/opencl/source/helpers/cl_hw_helper.h b/opencl/source/helpers/cl_hw_helper.h index 603fa66acd..bce1dc4aba 100644 --- a/opencl/source/helpers/cl_hw_helper.h +++ b/opencl/source/helpers/cl_hw_helper.h @@ -19,6 +19,7 @@ namespace NEO { class Context; class ClDevice; +struct HardwareInfo; struct KernelInfo; struct MultiDispatchInfo; @@ -34,10 +35,15 @@ class ClHwHelper { virtual bool preferBlitterForLocalToLocalTransfers() const = 0; virtual bool isSupportedKernelThreadArbitrationPolicy() const = 0; virtual std::vector getSupportedThreadArbitrationPolicies() const = 0; + virtual cl_version getDeviceIpVersion(const HardwareInfo &hwInfo) const = 0; + virtual cl_device_feature_capabilities_intel getSupportedDeviceFeatureCapabilities() const = 0; protected: virtual bool hasStatelessAccessToBuffer(const KernelInfo &kernelInfo) const = 0; + static uint8_t makeDeviceRevision(const HardwareInfo &hwInfo); + static cl_version makeDeviceIpVersion(uint16_t major, uint8_t minor, uint8_t revision); + ClHwHelper() = default; }; @@ -57,6 +63,8 @@ class ClHwHelperHw : public ClHwHelper { bool preferBlitterForLocalToLocalTransfers() const override; bool isSupportedKernelThreadArbitrationPolicy() const override; std::vector getSupportedThreadArbitrationPolicies() const override; + cl_version getDeviceIpVersion(const HardwareInfo &hwInfo) const override; + cl_device_feature_capabilities_intel getSupportedDeviceFeatureCapabilities() const override; protected: bool hasStatelessAccessToBuffer(const KernelInfo &kernelInfo) const override; diff --git a/opencl/source/helpers/cl_hw_helper_bdw_plus.inl b/opencl/source/helpers/cl_hw_helper_bdw_plus.inl index 519c141e4b..76253186f1 100644 --- a/opencl/source/helpers/cl_hw_helper_bdw_plus.inl +++ b/opencl/source/helpers/cl_hw_helper_bdw_plus.inl @@ -22,4 +22,9 @@ cl_ulong ClHwHelperHw::getKernelPrivateMemSize(const KernelInfo &kern return kernelInfo.kernelDescriptor.kernelAttributes.perHwThreadPrivateMemorySize; } +template +cl_device_feature_capabilities_intel ClHwHelperHw::getSupportedDeviceFeatureCapabilities() const { + return 0; +} + } // namespace NEO diff --git a/opencl/source/platform/extensions.cpp b/opencl/source/platform/extensions.cpp index 17b6a5ce82..6c984bcbc2 100644 --- a/opencl/source/platform/extensions.cpp +++ b/opencl/source/platform/extensions.cpp @@ -41,7 +41,8 @@ const char *deviceExtensionsList = "cl_khr_byte_addressable_store " "cl_khr_subgroup_non_uniform_arithmetic " "cl_khr_subgroup_shuffle " "cl_khr_subgroup_shuffle_relative " - "cl_khr_subgroup_clustered_reduce "; + "cl_khr_subgroup_clustered_reduce " + "cl_intel_device_attribute_query "; std::string getExtensionsList(const HardwareInfo &hwInfo) { std::string allExtensionsList; diff --git a/opencl/test/unit_test/api/cl_get_device_info_tests.inl b/opencl/test/unit_test/api/cl_get_device_info_tests.inl index 95c414ae99..630cdd5d38 100644 --- a/opencl/test/unit_test/api/cl_get_device_info_tests.inl +++ b/opencl/test/unit_test/api/cl_get_device_info_tests.inl @@ -243,7 +243,8 @@ TEST_F(clGetDeviceInfoTests, GivenClDeviceExtensionsParamWhenGettingDeviceInfoTh "cl_khr_subgroup_non_uniform_arithmetic ", "cl_khr_subgroup_shuffle ", "cl_khr_subgroup_shuffle_relative ", - "cl_khr_subgroup_clustered_reduce "}; + "cl_khr_subgroup_clustered_reduce " + "cl_intel_device_attribute_query "}; for (auto extension : supportedExtensions) { auto foundOffset = extensionString.find(extension); 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 e531c696f8..e47a08a63a 100644 --- a/opencl/test/unit_test/device/get_device_info_tests.cpp +++ b/opencl/test/unit_test/device/get_device_info_tests.cpp @@ -9,6 +9,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "opencl/source/cl_device/cl_device_info_map.h" +#include "opencl/source/helpers/cl_hw_helper.h" #include "opencl/test/unit_test/fixtures/cl_device_fixture.h" #include "opencl/test/unit_test/fixtures/device_info_fixture.h" #include "opencl/test/unit_test/helpers/raii_hw_helper.h" @@ -992,3 +993,124 @@ TEST(GetDeviceInfoTest, givenDeviceWithSubDevicesWhenGettingNumberOfComputeUnits EXPECT_EQ(expectedComputeUnitsForRootDevice, numComputeUnits); EXPECT_EQ(sizeof(numComputeUnits), retSize); } + +struct DeviceAttributeQueryTest : public ::testing::TestWithParam { + void SetUp() override { + param = GetParam(); + } + + void verifyDeviceAttribute(ClDevice &device) { + size_t sizeReturned = GetInfo::invalidSourceSize; + auto retVal = device.getDeviceInfo( + param, + 0, + nullptr, + &sizeReturned); + if (CL_SUCCESS != retVal) { + ASSERT_EQ(CL_SUCCESS, retVal) << " param = " << param; + } + ASSERT_NE(GetInfo::invalidSourceSize, sizeReturned); + + auto object = std::make_unique(sizeReturned); + retVal = device.getDeviceInfo( + param, + sizeReturned, + object.get(), + nullptr); + EXPECT_EQ(CL_SUCCESS, retVal); + + switch (param) { + case CL_DEVICE_IP_VERSION_INTEL: { + auto pDeviceIpVersion = reinterpret_cast(object.get()); + auto &hwInfo = device.getHardwareInfo(); + auto &clHwHelper = NEO::ClHwHelper::get(hwInfo.platform.eRenderCoreFamily); + EXPECT_EQ(clHwHelper.getDeviceIpVersion(hwInfo), *pDeviceIpVersion); + EXPECT_EQ(sizeof(cl_version), sizeReturned); + break; + } + case CL_DEVICE_ID_INTEL: { + auto pDeviceId = reinterpret_cast(object.get()); + EXPECT_EQ(device.getHardwareInfo().platform.usDeviceID, *pDeviceId); + EXPECT_EQ(sizeof(cl_uint), sizeReturned); + break; + } + case CL_DEVICE_NUM_SLICES_INTEL: { + auto pNumSlices = reinterpret_cast(object.get()); + const auto >SysInfo = device.getHardwareInfo().gtSystemInfo; + EXPECT_EQ(gtSysInfo.SliceCount * device.getNumAvailableDevices(), *pNumSlices); + EXPECT_EQ(sizeof(cl_uint), sizeReturned); + break; + } + case CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL: { + auto pNumSubslicesPerSlice = reinterpret_cast(object.get()); + const auto >SysInfo = device.getHardwareInfo().gtSystemInfo; + EXPECT_EQ(gtSysInfo.SubSliceCount / gtSysInfo.SliceCount, *pNumSubslicesPerSlice); + EXPECT_EQ(sizeof(cl_uint), sizeReturned); + break; + } + case CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL: { + auto pNumEusPerSubslice = reinterpret_cast(object.get()); + const auto >SysInfo = device.getHardwareInfo().gtSystemInfo; + EXPECT_EQ(gtSysInfo.MaxEuPerSubSlice, *pNumEusPerSubslice); + EXPECT_EQ(sizeof(cl_uint), sizeReturned); + break; + } + case CL_DEVICE_NUM_THREADS_PER_EU_INTEL: { + auto pNumThreadsPerEu = reinterpret_cast(object.get()); + const auto >SysInfo = device.getHardwareInfo().gtSystemInfo; + EXPECT_EQ(gtSysInfo.ThreadCount / gtSysInfo.EUCount, *pNumThreadsPerEu); + EXPECT_EQ(sizeof(cl_uint), sizeReturned); + break; + } + case CL_DEVICE_FEATURE_CAPABILITIES_INTEL: { + auto pCapabilities = reinterpret_cast(object.get()); + auto &hwInfo = device.getHardwareInfo(); + auto &clHwHelper = ClHwHelper::get(hwInfo.platform.eRenderCoreFamily); + EXPECT_EQ(clHwHelper.getSupportedDeviceFeatureCapabilities(), *pCapabilities); + EXPECT_EQ(sizeof(cl_device_feature_capabilities_intel), sizeReturned); + break; + } + default: + EXPECT_TRUE(false); + break; + } + } + + cl_device_info param; +}; + +TEST_P(DeviceAttributeQueryTest, givenGetDeviceInfoWhenDeviceAttributeIsQueriedOnClDeviceThenReturnCorrectAttributeValue) { + auto pClDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); + ASSERT_EQ(0u, pClDevice->subDevices.size()); + + verifyDeviceAttribute(*pClDevice); +} + +TEST_P(DeviceAttributeQueryTest, givenGetDeviceInfoWhenDeviceAttributeIsQueriedOnRootDeviceAndSubDevicesThenReturnCorrectAttributeValues) { + DebugManagerStateRestore restorer; + DebugManager.flags.CreateMultipleSubDevices.set(2); + VariableBackup mockDeviceFlagBackup(&MockDevice::createSingleDevice, false); + + auto pRootClDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); + ASSERT_EQ(2u, pRootClDevice->subDevices.size()); + + verifyDeviceAttribute(*pRootClDevice); + + for (const auto &pClSubDevice : pRootClDevice->subDevices) { + verifyDeviceAttribute(*pClSubDevice); + } +} + +cl_device_info deviceAttributeQueryParams[] = { + CL_DEVICE_IP_VERSION_INTEL, + CL_DEVICE_ID_INTEL, + CL_DEVICE_NUM_SLICES_INTEL, + CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL, + CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL, + CL_DEVICE_NUM_THREADS_PER_EU_INTEL, + CL_DEVICE_FEATURE_CAPABILITIES_INTEL}; + +INSTANTIATE_TEST_CASE_P( + Device_, + DeviceAttributeQueryTest, + testing::ValuesIn(deviceAttributeQueryParams)); diff --git a/opencl/test/unit_test/gen11/hw_helper_tests_gen11.cpp b/opencl/test/unit_test/gen11/hw_helper_tests_gen11.cpp index e25223a874..e8cf61eee2 100644 --- a/opencl/test/unit_test/gen11/hw_helper_tests_gen11.cpp +++ b/opencl/test/unit_test/gen11/hw_helper_tests_gen11.cpp @@ -7,8 +7,10 @@ #include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "opencl/source/helpers/cl_hw_helper.h" #include "opencl/test/unit_test/helpers/get_gpgpu_engines_tests.inl" #include "opencl/test/unit_test/helpers/hw_helper_tests.h" +#include "opencl/test/unit_test/mocks/mock_cl_hw_helper.h" using HwHelperTestGen11 = HwHelperTest; @@ -49,6 +51,14 @@ GEN11TEST_F(HwHelperTestGen11, whenGetGpgpuEnginesThenReturnThreeRcsEngines) { EXPECT_EQ(3u, pDevice->engines.size()); } +GEN11TEST_F(HwHelperTestGen11, WhenGettingDeviceIpVersionThenMakeCorrectDeviceIpVersion) { + EXPECT_EQ(ClHwHelperMock::makeDeviceIpVersion(11, 0, 0), ClHwHelper::get(renderCoreFamily).getDeviceIpVersion(*defaultHwInfo)); +} + +GEN11TEST_F(HwHelperTestGen11, WhenGettingSupportedDeviceFeatureCapabilitiesThenReturnCorrectValue) { + EXPECT_EQ(0u, ClHwHelper::get(renderCoreFamily).getSupportedDeviceFeatureCapabilities()); +} + using MemorySynchronizatiopCommandsTestsGen11 = ::testing::Test; GEN11TEST_F(MemorySynchronizatiopCommandsTestsGen11, WhenProgrammingCacheFlushThenExpectConstantCacheFieldSet) { using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; diff --git a/opencl/test/unit_test/gen12lp/dg1/hw_helper_tests_dg1.cpp b/opencl/test/unit_test/gen12lp/dg1/hw_helper_tests_dg1.cpp index df0ebdc745..65a18a4c59 100644 --- a/opencl/test/unit_test/gen12lp/dg1/hw_helper_tests_dg1.cpp +++ b/opencl/test/unit_test/gen12lp/dg1/hw_helper_tests_dg1.cpp @@ -8,6 +8,7 @@ #include "shared/source/utilities/compiler_support.h" #include "shared/test/common/mocks/mock_graphics_allocation.h" +#include "opencl/source/helpers/cl_hw_helper.h" #include "opencl/test/unit_test/helpers/hw_helper_tests.h" using HwHelperTestDg1 = HwHelperTest; diff --git a/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl b/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl index 7c3bbdc0a2..2c9c430bfa 100644 --- a/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl +++ b/opencl/test/unit_test/gen12lp/hw_helper_tests_gen12lp.inl @@ -11,6 +11,7 @@ #include "opencl/source/helpers/cl_hw_helper.h" #include "opencl/test/unit_test/gen12lp/special_ult_helper_gen12lp.h" #include "opencl/test/unit_test/helpers/hw_helper_tests.h" +#include "opencl/test/unit_test/mocks/mock_cl_hw_helper.h" #include "opencl/test/unit_test/mocks/mock_context.h" #include "opencl/test/unit_test/mocks/mock_memory_manager.h" #include "opencl/test/unit_test/mocks/mock_platform.h" @@ -478,3 +479,20 @@ HWTEST2_F(HwHelperTestGen12Lp, givenRevisionEnumThenProperValueForIsWorkaroundRe } } } + +HWTEST2_F(HwHelperTestGen12Lp, WhenGettingDeviceIpVersionThenMakeCorrectDeviceIpVersion, IsTGLLP) { + EXPECT_EQ(ClHwHelperMock::makeDeviceIpVersion(12, 0, 0), ClHwHelper::get(renderCoreFamily).getDeviceIpVersion(*defaultHwInfo)); +} + +HWTEST2_F(HwHelperTestGen12Lp, WhenGettingDeviceIpVersionThenMakeCorrectDeviceIpVersion, IsRKL) { + EXPECT_EQ(ClHwHelperMock::makeDeviceIpVersion(12, 0, 0), ClHwHelper::get(renderCoreFamily).getDeviceIpVersion(*defaultHwInfo)); +} + +HWTEST2_F(HwHelperTestGen12Lp, WhenGettingDeviceIpVersionThenMakeCorrectDeviceIpVersion, IsADLS) { + EXPECT_EQ(ClHwHelperMock::makeDeviceIpVersion(12, 0, 0), ClHwHelper::get(renderCoreFamily).getDeviceIpVersion(*defaultHwInfo)); +} + +GEN12LPTEST_F(HwHelperTestGen12Lp, WhenGettingSupportedDeviceFeatureCapabilitiesThenReturnCorrectValue) { + cl_device_feature_capabilities_intel expectedCapabilities = CL_DEVICE_FEATURE_FLAG_DP4A_INTEL; + EXPECT_EQ(expectedCapabilities, ClHwHelper::get(renderCoreFamily).getSupportedDeviceFeatureCapabilities()); +} diff --git a/opencl/test/unit_test/gen8/hw_helper_tests_gen8.cpp b/opencl/test/unit_test/gen8/hw_helper_tests_gen8.cpp index 18b8d01cf6..96e63e1333 100644 --- a/opencl/test/unit_test/gen8/hw_helper_tests_gen8.cpp +++ b/opencl/test/unit_test/gen8/hw_helper_tests_gen8.cpp @@ -8,9 +8,11 @@ #include "shared/source/helpers/constants.h" #include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "opencl/source/helpers/cl_hw_helper.h" #include "opencl/source/helpers/hardware_commands_helper.h" #include "opencl/test/unit_test/helpers/get_gpgpu_engines_tests.inl" #include "opencl/test/unit_test/helpers/hw_helper_tests.h" +#include "opencl/test/unit_test/mocks/mock_cl_hw_helper.h" using HwHelperTestGen8 = HwHelperTest; @@ -56,6 +58,14 @@ GEN8TEST_F(HwHelperTestGen8, whenGetGpgpuEnginesThenReturnThreeEngines) { EXPECT_EQ(3u, pDevice->engines.size()); } +GEN8TEST_F(HwHelperTestGen8, WhenGettingDeviceIpVersionThenMakeCorrectDeviceIpVersion) { + EXPECT_EQ(ClHwHelperMock::makeDeviceIpVersion(8, 0, 0), ClHwHelper::get(renderCoreFamily).getDeviceIpVersion(*defaultHwInfo)); +} + +GEN8TEST_F(HwHelperTestGen8, WhenGettingSupportedDeviceFeatureCapabilitiesThenReturnCorrectValue) { + EXPECT_EQ(0u, ClHwHelper::get(renderCoreFamily).getSupportedDeviceFeatureCapabilities()); +} + using MemorySynchronizatiopCommandsTestsGen8 = ::testing::Test; GEN8TEST_F(MemorySynchronizatiopCommandsTestsGen8, WhenProgrammingCacheFlushThenExpectConstantCacheFieldSet) { using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; diff --git a/opencl/test/unit_test/gen9/hw_helper_tests_gen9.cpp b/opencl/test/unit_test/gen9/hw_helper_tests_gen9.cpp index 561974c472..49fbfcfa04 100644 --- a/opencl/test/unit_test/gen9/hw_helper_tests_gen9.cpp +++ b/opencl/test/unit_test/gen9/hw_helper_tests_gen9.cpp @@ -7,8 +7,10 @@ #include "shared/test/common/cmd_parse/gen_cmd_parse.h" +#include "opencl/source/helpers/cl_hw_helper.h" #include "opencl/test/unit_test/helpers/get_gpgpu_engines_tests.inl" #include "opencl/test/unit_test/helpers/hw_helper_tests.h" +#include "opencl/test/unit_test/mocks/mock_cl_hw_helper.h" using HwHelperTestGen9 = HwHelperTest; @@ -61,6 +63,14 @@ GEN9TEST_F(HwHelperTestGen9, whenGetGpgpuEnginesThenReturnThreeRcsEngines) { EXPECT_EQ(3u, pDevice->engines.size()); } +GEN9TEST_F(HwHelperTestGen9, WhenGettingDeviceIpVersionThenMakeCorrectDeviceIpVersion) { + EXPECT_EQ(ClHwHelperMock::makeDeviceIpVersion(9, 0, 0), ClHwHelper::get(renderCoreFamily).getDeviceIpVersion(*defaultHwInfo)); +} + +GEN9TEST_F(HwHelperTestGen9, WhenGettingSupportedDeviceFeatureCapabilitiesThenReturnCorrectValue) { + EXPECT_EQ(0u, ClHwHelper::get(renderCoreFamily).getSupportedDeviceFeatureCapabilities()); +} + using MemorySynchronizatiopCommandsTestsGen9 = ::testing::Test; GEN9TEST_F(MemorySynchronizatiopCommandsTestsGen9, WhenProgrammingCacheFlushThenExpectConstantCacheFieldSet) { using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; diff --git a/opencl/test/unit_test/mocks/mock_cl_hw_helper.h b/opencl/test/unit_test/mocks/mock_cl_hw_helper.h new file mode 100644 index 0000000000..5d310c8726 --- /dev/null +++ b/opencl/test/unit_test/mocks/mock_cl_hw_helper.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "opencl/source/helpers/cl_hw_helper.h" + +namespace NEO { + +struct ClHwHelperMock : public ClHwHelper { + using ClHwHelper::makeDeviceIpVersion; + using ClHwHelper::makeDeviceRevision; +}; + +} // namespace NEO