@@ -1912,10 +1912,13 @@ void ProgramManager::addImage(sycl_device_binary RawImg,
1912
1912
if (EntriesB == EntriesE && shouldSkipEmptyImage (RawImg))
1913
1913
return ;
1914
1914
1915
- std::unique_ptr<RTDeviceBinaryImage> Img;
1916
- bool IsBfloat16DeviceLib = false ;
1917
1915
uint32_t Bfloat16DeviceLibVersion = 0 ;
1918
- if (isDeviceImageCompressed (RawImg))
1916
+ const bool IsBfloat16DeviceLib =
1917
+ isBfloat16DeviceLibImage (RawImg, &Bfloat16DeviceLibVersion);
1918
+ const bool IsDeviceImageCompressed = isDeviceImageCompressed (RawImg);
1919
+
1920
+ std::unique_ptr<RTDeviceBinaryImage> Img;
1921
+ if (IsDeviceImageCompressed) {
1919
1922
#ifndef SYCL_RT_ZSTD_NOT_AVAIABLE
1920
1923
Img = std::make_unique<CompressedRTDeviceBinaryImage>(RawImg);
1921
1924
#else
@@ -1924,11 +1927,8 @@ void ProgramManager::addImage(sycl_device_binary RawImg,
1924
1927
" SYCL RT was built without ZSTD support."
1925
1928
" Aborting. " );
1926
1929
#endif
1927
- else {
1928
- IsBfloat16DeviceLib =
1929
- isBfloat16DeviceLibImage (RawImg, &Bfloat16DeviceLibVersion);
1930
- if (!IsBfloat16DeviceLib)
1931
- Img = std::make_unique<RTDeviceBinaryImage>(RawImg);
1930
+ } else if (!IsBfloat16DeviceLib) {
1931
+ Img = std::make_unique<RTDeviceBinaryImage>(RawImg);
1932
1932
}
1933
1933
1934
1934
// If an output image is requested, set it to the newly allocated image.
@@ -1966,21 +1966,29 @@ void ProgramManager::addImage(sycl_device_binary RawImg,
1966
1966
" Invalid Bfloat16 Device Library Index." );
1967
1967
if (m_Bfloat16DeviceLibImages[Bfloat16DeviceLibVersion].get ())
1968
1968
return ;
1969
- size_t ImgSize =
1970
- static_cast <size_t >(RawImg->BinaryEnd - RawImg->BinaryStart );
1971
- std::unique_ptr<char []> Data (new char [ImgSize]);
1972
- std::memcpy (Data.get (), RawImg->BinaryStart , ImgSize);
1973
- auto DynBfloat16DeviceLibImg =
1974
- std::make_unique<DynRTDeviceBinaryImage>(std::move (Data), ImgSize);
1969
+
1970
+ std::unique_ptr<RTDeviceBinaryImage> DevImg;
1971
+ if (IsDeviceImageCompressed) {
1972
+ // Decompress the image.
1973
+ CheckAndDecompressImage (Img.get ());
1974
+ DevImg = std::move (Img);
1975
+ } else {
1976
+ size_t ImgSize =
1977
+ static_cast <size_t >(RawImg->BinaryEnd - RawImg->BinaryStart );
1978
+ std::unique_ptr<char []> Data (new char [ImgSize]);
1979
+ std::memcpy (Data.get (), RawImg->BinaryStart , ImgSize);
1980
+ DevImg =
1981
+ std::make_unique<DynRTDeviceBinaryImage>(std::move (Data), ImgSize);
1982
+ }
1983
+
1984
+ // Register export symbols for bfloat16 device library image.
1975
1985
auto ESPropSet = getExportedSymbolPS (RawImg);
1976
- sycl_device_binary_property ESProp;
1977
- for (ESProp = ESPropSet->PropertiesBegin ;
1986
+ for (auto ESProp = ESPropSet->PropertiesBegin ;
1978
1987
ESProp != ESPropSet->PropertiesEnd ; ++ESProp) {
1979
- m_ExportedSymbolImages.insert (
1980
- {ESProp->Name , DynBfloat16DeviceLibImg.get ()});
1988
+ m_ExportedSymbolImages.insert ({ESProp->Name , DevImg.get ()});
1981
1989
}
1982
- m_Bfloat16DeviceLibImages[Bfloat16DeviceLibVersion] =
1983
- std::move (DynBfloat16DeviceLibImg);
1990
+ m_Bfloat16DeviceLibImages[Bfloat16DeviceLibVersion] = std::move (DevImg);
1991
+
1984
1992
return ;
1985
1993
}
1986
1994
}
0 commit comments