diff --git a/level_zero/core/source/module/module_imp.cpp b/level_zero/core/source/module/module_imp.cpp index 403108edef..e6626b313f 100644 --- a/level_zero/core/source/module/module_imp.cpp +++ b/level_zero/core/source/module/module_imp.cpp @@ -274,7 +274,7 @@ ze_result_t ModuleTranslationUnit::createFromNativeBinary(const char *input, siz UNRECOVERABLE_IF((nullptr == device) || (nullptr == device->getNEODevice())); auto productAbbreviation = NEO::hardwarePrefix[device->getNEODevice()->getHardwareInfo().platform.eProductFamily]; - NEO::TargetDevice targetDevice = NEO::targetDeviceFromHwInfo(device->getNEODevice()->getHardwareInfo()); + NEO::TargetDevice targetDevice = NEO::getTargetDevice(device->getNEODevice()->getRootDeviceEnvironment()); std::string decodeErrors; std::string decodeWarnings; ArrayRef archive(reinterpret_cast(input), inputSize); @@ -340,7 +340,7 @@ ze_result_t ModuleTranslationUnit::processUnpackedBinary() { auto blob = ArrayRef(reinterpret_cast(this->unpackedDeviceBinary.get()), this->unpackedDeviceBinarySize); NEO::SingleDeviceBinary binary = {}; binary.deviceBinary = blob; - binary.targetDevice = NEO::targetDeviceFromHwInfo(device->getHwInfo()); + binary.targetDevice = NEO::getTargetDevice(device->getNEODevice()->getRootDeviceEnvironment()); std::string decodeErrors; std::string decodeWarnings; @@ -393,7 +393,7 @@ ze_result_t ModuleTranslationUnit::processUnpackedBinary() { } NEO::SingleDeviceBinary singleDeviceBinary = {}; - singleDeviceBinary.targetDevice = NEO::targetDeviceFromHwInfo(device->getNEODevice()->getHardwareInfo()); + singleDeviceBinary.targetDevice = NEO::getTargetDevice(device->getNEODevice()->getRootDeviceEnvironment()); singleDeviceBinary.buildOptions = this->options; singleDeviceBinary.deviceBinary = ArrayRef(reinterpret_cast(this->unpackedDeviceBinary.get()), this->unpackedDeviceBinarySize); singleDeviceBinary.intermediateRepresentation = ArrayRef(reinterpret_cast(this->irBinary.get()), this->irBinarySize); diff --git a/opencl/source/program/process_device_binary.cpp b/opencl/source/program/process_device_binary.cpp index 308d70bd66..cb32631cad 100644 --- a/opencl/source/program/process_device_binary.cpp +++ b/opencl/source/program/process_device_binary.cpp @@ -180,7 +180,7 @@ cl_int Program::processGenBinary(const ClDevice &clDevice) { if (isAnyPackedDeviceBinaryFormat(archive)) { std::string outErrReason, outWarning; auto productAbbreviation = NEO::hardwarePrefix[clDevice.getHardwareInfo().platform.eProductFamily]; - NEO::TargetDevice targetDevice = NEO::targetDeviceFromHwInfo(clDevice.getHardwareInfo()); + NEO::TargetDevice targetDevice = NEO::getTargetDevice(clDevice.getRootDeviceEnvironment()); auto singleDeviceBinary = unpackSingleDeviceBinary(archive, ConstStringRef(productAbbreviation, strlen(productAbbreviation)), targetDevice, outErrReason, outWarning); auto singleDeviceBinarySize = singleDeviceBinary.deviceBinary.size(); @@ -206,7 +206,7 @@ cl_int Program::processGenBinary(const ClDevice &clDevice) { auto blob = ArrayRef(reinterpret_cast(buildInfo.unpackedDeviceBinary.get()), buildInfo.unpackedDeviceBinarySize); SingleDeviceBinary binary = {}; binary.deviceBinary = blob; - binary.targetDevice = NEO::targetDeviceFromHwInfo(clDevice.getDevice().getHardwareInfo()); + binary.targetDevice = NEO::getTargetDevice(clDevice.getRootDeviceEnvironment()); std::string decodeErrors; std::string decodeWarnings; diff --git a/opencl/source/program/program.cpp b/opencl/source/program/program.cpp index ad2278304f..1535968eb5 100644 --- a/opencl/source/program/program.cpp +++ b/opencl/source/program/program.cpp @@ -151,10 +151,11 @@ cl_int Program::createProgramFromBinary( deviceBuildInfos[&clDevice].programBinaryType = CL_PROGRAM_BINARY_TYPE_EXECUTABLE; this->isCreatedFromBinary = true; - auto hwInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo(); + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]; + auto hwInfo = rootDeviceEnvironment.getHardwareInfo(); auto productAbbreviation = hardwarePrefix[hwInfo->platform.eProductFamily]; - TargetDevice targetDevice = targetDeviceFromHwInfo(*hwInfo); + TargetDevice targetDevice = getTargetDevice(rootDeviceEnvironment); std::string decodeErrors; std::string decodeWarnings; auto singleDeviceBinary = unpackSingleDeviceBinary(archive, ConstStringRef(productAbbreviation, strlen(productAbbreviation)), targetDevice, @@ -372,11 +373,11 @@ cl_int Program::packDeviceBinary(ClDevice &clDevice) { return CL_SUCCESS; } - auto hwInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo(); + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]; if (nullptr != this->buildInfos[rootDeviceIndex].unpackedDeviceBinary.get()) { SingleDeviceBinary singleDeviceBinary = {}; - singleDeviceBinary.targetDevice = NEO::targetDeviceFromHwInfo(*hwInfo); + singleDeviceBinary.targetDevice = NEO::getTargetDevice(rootDeviceEnvironment); singleDeviceBinary.buildOptions = this->options; singleDeviceBinary.deviceBinary = ArrayRef(reinterpret_cast(this->buildInfos[rootDeviceIndex].unpackedDeviceBinary.get()), this->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize); singleDeviceBinary.intermediateRepresentation = ArrayRef(reinterpret_cast(this->irBinary.get()), this->irBinarySize); diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 81ee631a60..c6ddb66ab2 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -1491,7 +1491,6 @@ using ProgramWithDebugDataTests = Test; TEST_F(ProgramWithDebugDataTests, GivenPatchtokensProgramWithDebugSymbolsWhenPackDeviceBinaryThenDebugDataIsAddedToSingleDeviceBinary) { auto clDevice = pContext->getDevices()[0]; - auto &hwInfo = clDevice->getHardwareInfo(); auto rootDeviceIdx = clDevice->getRootDeviceIndex(); pProgram = new PatchtokensProgramWithDebugData(*clDevice); @@ -1501,7 +1500,7 @@ TEST_F(ProgramWithDebugDataTests, GivenPatchtokensProgramWithDebugSymbolsWhenPac EXPECT_NE(nullptr, buildInfo.packedDeviceBinary.get()); auto packedDeviceBinary = ArrayRef::fromAny(buildInfo.packedDeviceBinary.get(), buildInfo.packedDeviceBinarySize); - TargetDevice targetDevice = NEO::targetDeviceFromHwInfo(hwInfo); + TargetDevice targetDevice = NEO::getTargetDevice(pDevice->getRootDeviceEnvironment()); std::string decodeErrors; std::string decodeWarnings; auto singleDeviceBinary = unpackSingleDeviceBinary(packedDeviceBinary, {}, targetDevice, diff --git a/shared/source/device_binary_format/device_binary_formats.cpp b/shared/source/device_binary_format/device_binary_formats.cpp index 11153e96d4..816ad87a01 100644 --- a/shared/source/device_binary_format/device_binary_formats.cpp +++ b/shared/source/device_binary_format/device_binary_formats.cpp @@ -7,6 +7,7 @@ #include "shared/source/device_binary_format/device_binary_formats.h" +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/os_interface/hw_info_config.h" @@ -20,9 +21,11 @@ std::vector packDeviceBinary(const SingleDeviceBinary binary, std::stri return packDeviceBinary(binary, outErrReason, outWarning); } -TargetDevice targetDeviceFromHwInfo(const HardwareInfo &hwInfo) { +TargetDevice getTargetDevice(const RootDeviceEnvironment &rootDeviceEnvironment) { + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + auto &productHelper = rootDeviceEnvironment.getHelper(); + auto &gfxCoreHelper = rootDeviceEnvironment.getHelper(); TargetDevice targetDevice = {}; - const auto &productHelper = *ProductHelper::get(hwInfo.platform.eProductFamily); targetDevice.coreFamily = hwInfo.platform.eRenderCoreFamily; targetDevice.productFamily = hwInfo.platform.eProductFamily; @@ -30,7 +33,7 @@ TargetDevice targetDeviceFromHwInfo(const HardwareInfo &hwInfo) { targetDevice.stepping = hwInfo.platform.usRevId; targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t); targetDevice.grfSize = hwInfo.capabilityTable.grfSize; - targetDevice.minScratchSpaceSize = GfxCoreHelper::get(hwInfo.platform.eRenderCoreFamily).getMinimalScratchSpaceSize(); + targetDevice.minScratchSpaceSize = gfxCoreHelper.getMinimalScratchSpaceSize(); return targetDevice; } } // namespace NEO diff --git a/shared/source/device_binary_format/device_binary_formats.h b/shared/source/device_binary_format/device_binary_formats.h index 0ee4501b8a..5b54ace076 100644 --- a/shared/source/device_binary_format/device_binary_formats.h +++ b/shared/source/device_binary_format/device_binary_formats.h @@ -18,7 +18,7 @@ namespace NEO { struct ProgramInfo; -struct HardwareInfo; +struct RootDeviceEnvironment; enum class DeviceBinaryFormat : uint8_t { Unknown, @@ -63,7 +63,7 @@ struct TargetDevice { uint32_t grfSize = 32U; uint32_t minScratchSpaceSize = 0U; }; -TargetDevice targetDeviceFromHwInfo(const NEO::HardwareInfo &hwInfo); +TargetDevice getTargetDevice(const RootDeviceEnvironment &rootDeviceEnvironment); struct SingleDeviceBinary { DeviceBinaryFormat format = DeviceBinaryFormat::Unknown;