diff --git a/runtime/device/device_caps.cpp b/runtime/device/device_caps.cpp index 1ef4b3091f..dd9239cf05 100644 --- a/runtime/device/device_caps.cpp +++ b/runtime/device/device_caps.cpp @@ -24,6 +24,7 @@ #include #include "runtime/device/device.h" #include "runtime/helpers/basic_math.h" +#include "runtime/helpers/hw_helper.h" #include "runtime/helpers/options.h" #include "runtime/memory_manager/memory_manager.h" #include "runtime/sharings/sharing_factory.h" @@ -76,6 +77,10 @@ void Device::initializeCaps() { driverVersion.assign(driverInfo.get()->getVersion(driverVersion).c_str()); } + HardwareCapabilities hwCaps = {0}; + auto &hwHelper = HwHelper::get(hwInfo.pPlatform->eRenderCoreFamily); + hwHelper.setupHardwareCapabilities(&hwCaps); + deviceInfo.name = name.c_str(); deviceInfo.driverVersion = driverVersion.c_str(); @@ -301,8 +306,8 @@ void Device::initializeCaps() { deviceInfo.imageSupport = CL_TRUE; deviceInfo.image2DMaxWidth = 16384; deviceInfo.image2DMaxHeight = 16384; - deviceInfo.image3DMaxWidth = 16384; - deviceInfo.image3DMaxHeight = 16384; + deviceInfo.image3DMaxWidth = hwCaps.image3DMaxWidth; + deviceInfo.image3DMaxHeight = hwCaps.image3DMaxHeight; deviceInfo.image3DMaxDepth = 2048; deviceInfo.imageMaxArraySize = 2048; diff --git a/runtime/gen8/hw_helper.cpp b/runtime/gen8/hw_helper.cpp index 1a4f8cb122..307c7a0c7e 100644 --- a/runtime/gen8/hw_helper.cpp +++ b/runtime/gen8/hw_helper.cpp @@ -36,5 +36,11 @@ bool HwHelperHw::setupPreemptionRegisters(HardwareInfo *pHwInfo, bool en return false; } +template <> +void HwHelperHw::setupHardwareCapabilities(HardwareCapabilities *caps) { + caps->image3DMaxHeight = 2048; + caps->image3DMaxWidth = 2048; +} + template class HwHelperHw; } // namespace OCLRT diff --git a/runtime/helpers/hw_helper.cpp b/runtime/helpers/hw_helper.cpp index ef8d5bd0d6..93b7dd15b8 100644 --- a/runtime/helpers/hw_helper.cpp +++ b/runtime/helpers/hw_helper.cpp @@ -57,4 +57,7 @@ bool HwHelper::setupPreemptionRegisters(HardwareInfo *pHwInfo, bool enable) { void HwHelper::adjustDefaultEngineType(HardwareInfo *pHwInfo) { } +void HwHelper::setupHardwareCapabilities(HardwareCapabilities *caps) { +} + } // namespace OCLRT diff --git a/runtime/helpers/hw_helper.h b/runtime/helpers/hw_helper.h index 09c7edde10..6a6cdb12d1 100644 --- a/runtime/helpers/hw_helper.h +++ b/runtime/helpers/hw_helper.h @@ -28,6 +28,8 @@ #include namespace OCLRT { +struct HardwareCapabilities; + class HwHelper { public: static HwHelper &get(GFXCORE_FAMILY gfxCore); @@ -39,6 +41,7 @@ class HwHelper { virtual void setCapabilityCoherencyFlag(const HardwareInfo *pHwInfo, bool &coherencyFlag); virtual bool setupPreemptionRegisters(HardwareInfo *pHwInfo, bool enable); virtual void adjustDefaultEngineType(HardwareInfo *pHwInfo); + virtual void setupHardwareCapabilities(HardwareCapabilities *caps); protected: HwHelper(){}; @@ -82,6 +85,8 @@ class HwHelperHw : public HwHelper { void adjustDefaultEngineType(HardwareInfo *pHwInfo) override; + void setupHardwareCapabilities(HardwareCapabilities *caps) override; + private: HwHelperHw(){}; }; diff --git a/runtime/helpers/hw_helper.inl b/runtime/helpers/hw_helper.inl index 3f1af32e50..4bf281f34d 100644 --- a/runtime/helpers/hw_helper.inl +++ b/runtime/helpers/hw_helper.inl @@ -21,6 +21,7 @@ */ #include "runtime/helpers/hw_helper.h" +#include "runtime/helpers/hw_info.h" namespace OCLRT { template @@ -31,4 +32,11 @@ void HwHelperHw::setCapabilityCoherencyFlag(const HardwareInfo *pHwInfo, template void HwHelperHw::adjustDefaultEngineType(HardwareInfo *pHwInfo) { } + +template +void HwHelperHw::setupHardwareCapabilities(HardwareCapabilities *caps) { + caps->image3DMaxHeight = 16384; + caps->image3DMaxWidth = 16384; +} + } // namespace OCLRT diff --git a/runtime/helpers/hw_info.h b/runtime/helpers/hw_info.h index 9d8a115fa7..d931cd7325 100644 --- a/runtime/helpers/hw_info.h +++ b/runtime/helpers/hw_info.h @@ -26,6 +26,7 @@ #include "sku_info.h" #include "runtime/helpers/engine_node.h" +#include namespace OCLRT { @@ -70,6 +71,11 @@ struct RuntimeCapabilityTable { EngineType defaultEngineType; }; +struct HardwareCapabilities { + size_t image3DMaxWidth; + size_t image3DMaxHeight; +}; + struct HardwareInfo { const PLATFORM *pPlatform; const FeatureTable *pSkuTable; diff --git a/unit_tests/device/device_caps_tests.cpp b/unit_tests/device/device_caps_tests.cpp index 51da1d53e0..9320c077b4 100644 --- a/unit_tests/device/device_caps_tests.cpp +++ b/unit_tests/device/device_caps_tests.cpp @@ -189,9 +189,6 @@ TEST(Device_GetCaps, validate) { EXPECT_EQ(1u, caps.imageSupport); EXPECT_EQ(16384u, caps.image2DMaxWidth); EXPECT_EQ(16384u, caps.image2DMaxHeight); - EXPECT_EQ(16384u, caps.image3DMaxWidth); - EXPECT_EQ(2048u, caps.image3DMaxDepth); - EXPECT_EQ(16384u, caps.image3DMaxHeight); EXPECT_EQ(2048u, caps.imageMaxArraySize); if (device->getHardwareInfo().capabilityTable.clVersionSupport == 12 && is32BitOsAllocatorAvailable) { EXPECT_TRUE(caps.force32BitAddressess); @@ -200,6 +197,21 @@ TEST(Device_GetCaps, validate) { } } +TEST(Device_GetCaps, validateImage3DDimensions) { + auto device = std::unique_ptr(DeviceHelper<>::create(platformDevices[0])); + const auto &caps = device->getDeviceInfo(); + + if (device->getHardwareInfo().pPlatform->eRenderCoreFamily > IGFX_GEN8_CORE) { + EXPECT_EQ(16384u, caps.image3DMaxWidth); + EXPECT_EQ(16384u, caps.image3DMaxHeight); + } else { + EXPECT_EQ(2048u, caps.image3DMaxWidth); + EXPECT_EQ(2048u, caps.image3DMaxHeight); + } + + EXPECT_EQ(2048u, caps.image3DMaxDepth); +} + TEST(DeviceGetCapsSimple, givenDeviceWhenEUCountIsZeroThenmaxWgsIsDefault) { auto hardwareInfo = hardwareInfoTable[productFamily]; GT_SYSTEM_INFO sysInfo = *hardwareInfo->pSysInfo; diff --git a/unit_tests/gen8/hw_helper_tests.cpp b/unit_tests/gen8/hw_helper_tests.cpp index 3a2eaf86e5..5b4f17a8f1 100644 --- a/unit_tests/gen8/hw_helper_tests.cpp +++ b/unit_tests/gen8/hw_helper_tests.cpp @@ -56,3 +56,12 @@ GEN8TEST_F(HwHelperTestBdw, adjustDefaultEngineType) { helper.adjustDefaultEngineType(&hwInfo); EXPECT_EQ(engineType, hwInfo.capabilityTable.defaultEngineType); } + +GEN8TEST_F(HwHelperTestBdw, givenGen8PlatformWhenSetupHardwareCapabilitiesIsCalledThenSpecificImplementationIsUsed) { + auto &helper = HwHelper::get(renderCoreFamily); + HardwareCapabilities hwCaps = {0}; + helper.setupHardwareCapabilities(&hwCaps); + + EXPECT_EQ(2048u, hwCaps.image3DMaxHeight); + EXPECT_EQ(2048u, hwCaps.image3DMaxWidth); +} diff --git a/unit_tests/gen8/test_device_caps.cpp b/unit_tests/gen8/test_device_caps.cpp index 7ddc7ef8ed..4bff6d9ff6 100644 --- a/unit_tests/gen8/test_device_caps.cpp +++ b/unit_tests/gen8/test_device_caps.cpp @@ -64,6 +64,13 @@ GEN8TEST_F(Gen8DeviceCaps, compression) { EXPECT_FALSE(pDevice->getHardwareInfo().capabilityTable.ftrCompression); } +GEN8TEST_F(Gen8DeviceCaps, image3DDimensions) { + const auto &caps = pDevice->getDeviceInfo(); + EXPECT_EQ(2048u, caps.image3DMaxWidth); + EXPECT_EQ(2048u, caps.image3DMaxDepth); + EXPECT_EQ(2048u, caps.image3DMaxHeight); +} + BDWTEST_F(Gen8DeviceCaps, BdwProfilingTimerResolution) { const auto &caps = pDevice->getDeviceInfo(); EXPECT_EQ(83u, caps.profilingTimerResolution); diff --git a/unit_tests/gen9/hw_helper_tests.cpp b/unit_tests/gen9/hw_helper_tests.cpp index 1cfc9c6119..6ffd1d65be 100644 --- a/unit_tests/gen9/hw_helper_tests.cpp +++ b/unit_tests/gen9/hw_helper_tests.cpp @@ -57,3 +57,10 @@ GEN9TEST_F(HwHelperTestSkl, adjustDefaultEngineType) { helper.adjustDefaultEngineType(&hwInfo); EXPECT_EQ(engineType, hwInfo.capabilityTable.defaultEngineType); } + +GEN9TEST_F(HwHelperTestSkl, givenGen9PlatformWhenSetupHardwareCapabilitiesIsCalledThenDefaultImplementationIsUsed) { + auto &helper = HwHelper::get(renderCoreFamily); + + // Test default method implementation + testDefaultImplementationOfSetupHardwareCapabilities(helper); +} diff --git a/unit_tests/helpers/CMakeLists.txt b/unit_tests/helpers/CMakeLists.txt index 02db1d0e73..7fd0cbe0e8 100644 --- a/unit_tests/helpers/CMakeLists.txt +++ b/unit_tests/helpers/CMakeLists.txt @@ -36,6 +36,7 @@ set(IGDRCL_SRCS_tests_helpers "${CMAKE_CURRENT_SOURCE_DIR}/flush_stamp_tests.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/get_info_tests.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/gtest_helpers.h" + "${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_default_tests.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests.h" "${CMAKE_CURRENT_SOURCE_DIR}/hw_parse.h" diff --git a/unit_tests/helpers/hw_helper_default_tests.cpp b/unit_tests/helpers/hw_helper_default_tests.cpp new file mode 100644 index 0000000000..eb8a908e12 --- /dev/null +++ b/unit_tests/helpers/hw_helper_default_tests.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 - 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "runtime/helpers/hw_info.h" +#include "unit_tests/helpers/hw_helper_tests.h" + +void testDefaultImplementationOfSetupHardwareCapabilities(HwHelper &hwHelper) { + HardwareCapabilities hwCaps = {0}; + + hwHelper.setupHardwareCapabilities(&hwCaps); + + EXPECT_EQ(16384u, hwCaps.image3DMaxHeight); + EXPECT_EQ(16384u, hwCaps.image3DMaxWidth); +} diff --git a/unit_tests/helpers/hw_helper_tests.cpp b/unit_tests/helpers/hw_helper_tests.cpp index 1577d7cec2..e27f30b262 100644 --- a/unit_tests/helpers/hw_helper_tests.cpp +++ b/unit_tests/helpers/hw_helper_tests.cpp @@ -123,6 +123,24 @@ HWTEST_F(HwHelperTest, adjustDefaultEngineTypeDummy) { helper.adjustDefaultEngineType(&hwInfo); } +HWTEST_F(HwHelperTest, setupHardwareCapabilitiesDummy) { + auto helper = HwHelper::get(renderCoreFamily); + HardwareCapabilities hwCaps; + hwCaps.image3DMaxHeight = 123u; + hwCaps.image3DMaxWidth = 456u; + helper.setupHardwareCapabilities(&hwCaps); + + EXPECT_EQ(123u, hwCaps.image3DMaxHeight); + EXPECT_EQ(456u, hwCaps.image3DMaxWidth); + + hwCaps.image3DMaxHeight = 789u; + hwCaps.image3DMaxWidth = 987u; + helper.setupHardwareCapabilities(&hwCaps); + + EXPECT_EQ(789u, hwCaps.image3DMaxHeight); + EXPECT_EQ(987u, hwCaps.image3DMaxWidth); +} + TEST(DwordBuilderTest, setNonMaskedBits) { uint32_t dword = 0; diff --git a/unit_tests/helpers/hw_helper_tests.h b/unit_tests/helpers/hw_helper_tests.h index 9ec0b03e63..66045586ea 100644 --- a/unit_tests/helpers/hw_helper_tests.h +++ b/unit_tests/helpers/hw_helper_tests.h @@ -39,3 +39,5 @@ class HwHelperTest : public testing::Test { GT_SYSTEM_INFO testSysInfo; HardwareInfo hwInfo; }; + +void testDefaultImplementationOfSetupHardwareCapabilities(HwHelper &hwHelper); diff --git a/unit_tests/mocks/mock_gfx_family.cpp b/unit_tests/mocks/mock_gfx_family.cpp index 44e44c7877..0c25de7770 100644 --- a/unit_tests/mocks/mock_gfx_family.cpp +++ b/unit_tests/mocks/mock_gfx_family.cpp @@ -21,13 +21,12 @@ */ #include "unit_tests/mocks/mock_gfx_family.h" +#include "runtime/helpers/hw_helper.inl" namespace OCLRT { bool (*GENX::isSimulationFcn)(unsigned short) = nullptr; -template class HwHelperHw; - template <> size_t HwHelperHw::getMaxBarrierRegisterPerSlice() const { return 32; @@ -49,15 +48,13 @@ bool HwHelperHw::setupPreemptionRegisters(HardwareInfo *pHwInfo, bool enab return enable; } -template <> -void HwHelperHw::adjustDefaultEngineType(HardwareInfo *pHwInfo) { -} - struct hw_helper_static_init { hw_helper_static_init() { hwHelperFactory[IGFX_UNKNOWN_CORE] = &HwHelperHw::get(); } }; +template class HwHelperHw; + hw_helper_static_init si; } // namespace OCLRT