Initial support for compressed L0 Images

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski 2021-12-14 15:03:37 +00:00 committed by Compute-Runtime-Automation
parent 6e7515a12b
commit 8288fa76cb
5 changed files with 124 additions and 0 deletions

View File

@ -32,6 +32,7 @@ class L0HwHelper {
virtual L0::Event *createEvent(L0::EventPool *eventPool, const ze_event_desc_t *desc, L0::Device *device) const = 0; virtual L0::Event *createEvent(L0::EventPool *eventPool, const ze_event_desc_t *desc, L0::Device *device) const = 0;
virtual bool isResumeWARequired() = 0; virtual bool isResumeWARequired() = 0;
virtual bool imageCompressionSupported(const NEO::HardwareInfo &hwInfo) const = 0;
virtual void getAttentionBitmaskForSingleThreads(std::vector<ze_device_thread_t> &threads, const NEO::HardwareInfo &hwInfo, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) const = 0; virtual void getAttentionBitmaskForSingleThreads(std::vector<ze_device_thread_t> &threads, const NEO::HardwareInfo &hwInfo, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) const = 0;
virtual std::vector<ze_device_thread_t> getThreadsFromAttentionBitmask(const NEO::HardwareInfo &hwInfo, const uint8_t *bitmask, const size_t bitmaskSize) const = 0; virtual std::vector<ze_device_thread_t> getThreadsFromAttentionBitmask(const NEO::HardwareInfo &hwInfo, const uint8_t *bitmask, const size_t bitmaskSize) const = 0;
@ -52,6 +53,7 @@ class L0HwHelperHw : public L0HwHelper {
L0HwHelperHw() = default; L0HwHelperHw() = default;
bool isResumeWARequired() override; bool isResumeWARequired() override;
bool imageCompressionSupported(const NEO::HardwareInfo &hwInfo) const override;
void getAttentionBitmaskForSingleThreads(std::vector<ze_device_thread_t> &threads, const NEO::HardwareInfo &hwInfo, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) const override; void getAttentionBitmaskForSingleThreads(std::vector<ze_device_thread_t> &threads, const NEO::HardwareInfo &hwInfo, std::unique_ptr<uint8_t[]> &bitmask, size_t &bitmaskSize) const override;
std::vector<ze_device_thread_t> getThreadsFromAttentionBitmask(const NEO::HardwareInfo &hwInfo, const uint8_t *bitmask, const size_t bitmaskSize) const override; std::vector<ze_device_thread_t> getThreadsFromAttentionBitmask(const NEO::HardwareInfo &hwInfo, const uint8_t *bitmask, const size_t bitmaskSize) const override;
}; };

View File

@ -88,4 +88,13 @@ std::vector<ze_device_thread_t> L0HwHelperHw<GfxFamily>::getThreadsFromAttention
return threads; return threads;
} }
template <typename GfxFamily>
bool L0HwHelperHw<GfxFamily>::imageCompressionSupported(const NEO::HardwareInfo &hwInfo) const {
if (NEO::DebugManager.flags.RenderCompressedImagesEnabled.get() != -1) {
return !!NEO::DebugManager.flags.RenderCompressedImagesEnabled.get();
}
return false;
}
} // namespace L0 } // namespace L0

View File

@ -16,6 +16,7 @@
#include "shared/source/memory_manager/memory_manager.h" #include "shared/source/memory_manager/memory_manager.h"
#include "level_zero/core/source/helpers/properties_parser.h" #include "level_zero/core/source/helpers/properties_parser.h"
#include "level_zero/core/source/hw_helpers/l0_hw_helper.h"
#include "level_zero/core/source/image/image_formats.h" #include "level_zero/core/source/image/image_formats.h"
#include "level_zero/core/source/image/image_hw.h" #include "level_zero/core/source/image/image_hw.h"
@ -90,6 +91,12 @@ ze_result_t ImageCoreFamily<gfxCoreFamily>::initialize(Device *device, const ze_
} else { } else {
NEO::AllocationProperties properties(device->getRootDeviceIndex(), true, imgInfo, NEO::GraphicsAllocation::AllocationType::IMAGE, device->getNEODevice()->getDeviceBitfield()); NEO::AllocationProperties properties(device->getRootDeviceIndex(), true, imgInfo, NEO::GraphicsAllocation::AllocationType::IMAGE, device->getNEODevice()->getDeviceBitfield());
auto &hwInfo = device->getHwInfo();
auto &l0HwHelper = L0HwHelper::get(hwInfo.platform.eRenderCoreFamily);
properties.flags.preferCompressed = l0HwHelper.imageCompressionSupported(hwInfo);
properties.flags.preferCompressed &= !imgInfo.linearStorage;
allocation = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); allocation = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
} }
if (allocation == nullptr) { if (allocation == nullptr) {

View File

@ -6,6 +6,7 @@
*/ */
#include "shared/source/helpers/ptr_math.h" #include "shared/source/helpers/ptr_math.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/test_macros/matchers.h" #include "shared/test/common/test_macros/matchers.h"
@ -65,6 +66,21 @@ static void printAttentionBitmask(uint8_t *expected, uint8_t *actual, uint32_t m
std::cout << "\n\n"; std::cout << "\n\n";
} }
} }
HWTEST_F(L0HwHelperTest, givenL0HwHelperWhenAskingForImageCompressionSupportThenReturnFalse) {
DebugManagerStateRestore restore;
auto &l0HwHelper = L0::L0HwHelper::get(NEO::defaultHwInfo->platform.eRenderCoreFamily);
EXPECT_FALSE(l0HwHelper.imageCompressionSupported(*NEO::defaultHwInfo));
NEO::DebugManager.flags.RenderCompressedImagesEnabled.set(1);
EXPECT_TRUE(l0HwHelper.imageCompressionSupported(*NEO::defaultHwInfo));
NEO::DebugManager.flags.RenderCompressedImagesEnabled.set(0);
EXPECT_FALSE(l0HwHelper.imageCompressionSupported(*NEO::defaultHwInfo));
}
HWTEST_F(L0HwHelperTest, givenSliceSubsliceEuAndThreadIdsWhenGettingBitmaskThenCorrectBitmaskIsReturned) { HWTEST_F(L0HwHelperTest, givenSliceSubsliceEuAndThreadIdsWhenGettingBitmaskThenCorrectBitmaskIsReturned) {
auto hwInfo = *NEO::defaultHwInfo.get(); auto hwInfo = *NEO::defaultHwInfo.get();
auto &l0HwHelper = L0::L0HwHelper::get(hwInfo.platform.eRenderCoreFamily); auto &l0HwHelper = L0::L0HwHelper::get(hwInfo.platform.eRenderCoreFamily);

View File

@ -8,6 +8,7 @@
#include "shared/source/gmm_helper/gmm.h" #include "shared/source/gmm_helper/gmm.h"
#include "shared/source/gmm_helper/resource_info.h" #include "shared/source/gmm_helper/resource_info.h"
#include "shared/source/helpers/surface_format_info.h" #include "shared/source/helpers/surface_format_info.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/mocks/mock_device.h" #include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_gmm_client_context.h" #include "shared/test/common/mocks/mock_gmm_client_context.h"
@ -15,6 +16,7 @@
#include "test.h" #include "test.h"
#include "level_zero/core/source/hw_helpers/l0_hw_helper.h"
#include "level_zero/core/source/image/image_format_desc_helper.h" #include "level_zero/core/source/image/image_format_desc_helper.h"
#include "level_zero/core/source/image/image_formats.h" #include "level_zero/core/source/image/image_formats.h"
#include "level_zero/core/source/image/image_hw.h" #include "level_zero/core/source/image/image_hw.h"
@ -828,5 +830,93 @@ HWTEST2_F(ImageGetMemoryProperties, givenImageMemoryPropertiesExpStructureWhenGe
EXPECT_EQ(imageInfo.rowPitch, imageMemoryPropertiesExp.rowPitch); EXPECT_EQ(imageInfo.rowPitch, imageMemoryPropertiesExp.rowPitch);
} }
HWTEST2_F(ImageGetMemoryProperties, givenDebugFlagSetWhenCreatingImageThenEnableCompression, ImageSupport) {
DebugManagerStateRestore restore;
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.ftrRenderCompressedImages = true;
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
zeDesc.arraylevels = 1u;
zeDesc.depth = 1u;
zeDesc.height = 1u;
zeDesc.width = 1u;
zeDesc.miplevels = 1u;
zeDesc.type = ZE_IMAGE_TYPE_2DARRAY;
zeDesc.flags = ZE_IMAGE_FLAG_BIAS_UNCACHED;
zeDesc.format = {ZE_IMAGE_FORMAT_LAYOUT_32,
ZE_IMAGE_FORMAT_TYPE_UINT,
ZE_IMAGE_FORMAT_SWIZZLE_R,
ZE_IMAGE_FORMAT_SWIZZLE_G,
ZE_IMAGE_FORMAT_SWIZZLE_B,
ZE_IMAGE_FORMAT_SWIZZLE_A};
{
Image *image_ptr = nullptr;
auto result = Image::create(productFamily, device, &zeDesc, &image_ptr);
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
EXPECT_NE(nullptr, image_ptr);
std::unique_ptr<L0::Image> image(image_ptr);
EXPECT_EQ(L0HwHelperHw<FamilyType>::get().imageCompressionSupported(device->getHwInfo()), image->getAllocation()->isCompressionEnabled());
}
{
NEO::DebugManager.flags.RenderCompressedImagesEnabled.set(1);
Image *image_ptr = nullptr;
auto result = Image::create(productFamily, device, &zeDesc, &image_ptr);
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
EXPECT_NE(nullptr, image_ptr);
std::unique_ptr<L0::Image> image(image_ptr);
EXPECT_TRUE(image->getAllocation()->isCompressionEnabled());
}
{
NEO::DebugManager.flags.RenderCompressedImagesEnabled.set(0);
Image *image_ptr = nullptr;
auto result = Image::create(productFamily, device, &zeDesc, &image_ptr);
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
EXPECT_NE(nullptr, image_ptr);
std::unique_ptr<L0::Image> image(image_ptr);
EXPECT_FALSE(image->getAllocation()->isCompressionEnabled());
}
}
HWTEST2_F(ImageGetMemoryProperties, givenDebugFlagSetWhenCreatingLinearImageThenDontEnableCompression, ImageSupport) {
DebugManagerStateRestore restore;
device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.ftrRenderCompressedImages = true;
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
zeDesc.arraylevels = 1u;
zeDesc.depth = 1u;
zeDesc.height = 1u;
zeDesc.width = 1u;
zeDesc.miplevels = 1u;
zeDesc.type = ZE_IMAGE_TYPE_1D;
zeDesc.flags = ZE_IMAGE_FLAG_BIAS_UNCACHED;
zeDesc.format = {ZE_IMAGE_FORMAT_LAYOUT_32,
ZE_IMAGE_FORMAT_TYPE_UINT,
ZE_IMAGE_FORMAT_SWIZZLE_R,
ZE_IMAGE_FORMAT_SWIZZLE_G,
ZE_IMAGE_FORMAT_SWIZZLE_B,
ZE_IMAGE_FORMAT_SWIZZLE_A};
Image *image_ptr = nullptr;
auto result = Image::create(productFamily, device, &zeDesc, &image_ptr);
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
EXPECT_NE(nullptr, image_ptr);
std::unique_ptr<L0::Image> image(image_ptr);
EXPECT_FALSE(image->getAllocation()->isCompressionEnabled());
}
} // namespace ult } // namespace ult
} // namespace L0 } // namespace L0