Skip to content

Commit d49c5d6

Browse files
OCL: Set target device product family
In OCL product family of target device is not set which leads to a fail on validating target device in ZEBin path. This change adds function that sets all necessary fields based on provided hardware info. Signed-off-by: Krystian Chmielewski <[email protected]>
1 parent b61d213 commit d49c5d6

File tree

6 files changed

+24
-29
lines changed

6 files changed

+24
-29
lines changed

level_zero/core/source/module/module_imp.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,7 @@ bool ModuleTranslationUnit::createFromNativeBinary(const char *input, size_t inp
240240
UNRECOVERABLE_IF((nullptr == device) || (nullptr == device->getNEODevice()));
241241
auto productAbbreviation = NEO::hardwarePrefix[device->getNEODevice()->getHardwareInfo().platform.eProductFamily];
242242

243-
NEO::TargetDevice targetDevice = {};
244-
targetDevice.coreFamily = device->getNEODevice()->getHardwareInfo().platform.eRenderCoreFamily;
245-
targetDevice.productFamily = device->getNEODevice()->getHardwareInfo().platform.eProductFamily;
246-
targetDevice.stepping = device->getNEODevice()->getHardwareInfo().platform.usRevId;
247-
targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t);
243+
NEO::TargetDevice targetDevice = NEO::targetDeviceFromHwInfo(device->getNEODevice()->getHardwareInfo());
248244
std::string decodeErrors;
249245
std::string decodeWarnings;
250246
ArrayRef<const uint8_t> archive(reinterpret_cast<const uint8_t *>(input), inputSize);
@@ -294,7 +290,7 @@ bool ModuleTranslationUnit::processUnpackedBinary() {
294290
auto blob = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->unpackedDeviceBinary.get()), this->unpackedDeviceBinarySize);
295291
NEO::SingleDeviceBinary binary = {};
296292
binary.deviceBinary = blob;
297-
binary.targetDevice.grfSize = device->getHwInfo().capabilityTable.grfSize;
293+
binary.targetDevice = NEO::targetDeviceFromHwInfo(device->getHwInfo());
298294
std::string decodeErrors;
299295
std::string decodeWarnings;
300296

@@ -354,17 +350,13 @@ bool ModuleTranslationUnit::processUnpackedBinary() {
354350
kernelInfo->apply(deviceInfoConstants);
355351
}
356352

357-
auto gfxCore = device->getNEODevice()->getHardwareInfo().platform.eRenderCoreFamily;
358-
auto stepping = device->getNEODevice()->getHardwareInfo().platform.usRevId;
359-
360353
if (this->packedDeviceBinary != nullptr) {
361354
return true;
362355
}
363356

364-
NEO::SingleDeviceBinary singleDeviceBinary;
357+
NEO::SingleDeviceBinary singleDeviceBinary = {};
358+
singleDeviceBinary.targetDevice = NEO::targetDeviceFromHwInfo(device->getNEODevice()->getHardwareInfo());
365359
singleDeviceBinary.buildOptions = this->options;
366-
singleDeviceBinary.targetDevice.coreFamily = gfxCore;
367-
singleDeviceBinary.targetDevice.stepping = stepping;
368360
singleDeviceBinary.deviceBinary = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->unpackedDeviceBinary.get()), this->unpackedDeviceBinarySize);
369361
singleDeviceBinary.intermediateRepresentation = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->irBinary.get()), this->irBinarySize);
370362
singleDeviceBinary.debugData = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->debugData.get()), this->debugDataSize);

opencl/source/program/process_device_binary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ cl_int Program::processGenBinary(const ClDevice &clDevice) {
156156
auto blob = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(buildInfo.unpackedDeviceBinary.get()), buildInfo.unpackedDeviceBinarySize);
157157
SingleDeviceBinary binary = {};
158158
binary.deviceBinary = blob;
159-
binary.targetDevice.grfSize = clDevice.getDevice().getHardwareInfo().capabilityTable.grfSize;
159+
binary.targetDevice = NEO::targetDeviceFromHwInfo(clDevice.getDevice().getHardwareInfo());
160160
std::string decodeErrors;
161161
std::string decodeWarnings;
162162

opencl/source/program/program.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ cl_int Program::createProgramFromBinary(
162162
auto hwInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
163163
auto productAbbreviation = hardwarePrefix[hwInfo->platform.eProductFamily];
164164

165-
TargetDevice targetDevice = {};
166-
targetDevice.coreFamily = hwInfo->platform.eRenderCoreFamily;
167-
targetDevice.stepping = hwInfo->platform.usRevId;
168-
targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t);
165+
TargetDevice targetDevice = targetDeviceFromHwInfo(*hwInfo);
169166
std::string decodeErrors;
170167
std::string decodeWarnings;
171168
auto singleDeviceBinary = unpackSingleDeviceBinary(archive, ConstStringRef(productAbbreviation, strlen(productAbbreviation)), targetDevice,
@@ -370,14 +367,11 @@ cl_int Program::packDeviceBinary(ClDevice &clDevice) {
370367
}
371368

372369
auto hwInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
373-
auto gfxCore = hwInfo->platform.eRenderCoreFamily;
374-
auto stepping = hwInfo->platform.usRevId;
375370

376371
if (nullptr != this->buildInfos[rootDeviceIndex].unpackedDeviceBinary.get()) {
377-
SingleDeviceBinary singleDeviceBinary;
372+
SingleDeviceBinary singleDeviceBinary = {};
373+
singleDeviceBinary.targetDevice = NEO::targetDeviceFromHwInfo(*hwInfo);
378374
singleDeviceBinary.buildOptions = this->options;
379-
singleDeviceBinary.targetDevice.coreFamily = gfxCore;
380-
singleDeviceBinary.targetDevice.stepping = stepping;
381375
singleDeviceBinary.deviceBinary = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->buildInfos[rootDeviceIndex].unpackedDeviceBinary.get()), this->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize);
382376
singleDeviceBinary.intermediateRepresentation = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->irBinary.get()), this->irBinarySize);
383377
singleDeviceBinary.debugData = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->buildInfos[rootDeviceIndex].debugData.get()), this->buildInfos[rootDeviceIndex].debugDataSize);

opencl/test/unit_test/program/program_tests.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,11 +1625,7 @@ TEST_F(ProgramWithDebugSymbolsTests, GivenProgramCreatedWithDashGOptionWhenGetti
16251625
ArrayRef<const uint8_t> archive(reinterpret_cast<const uint8_t *>(testBinary.get()), size);
16261626
auto productAbbreviation = hardwarePrefix[pDevice->getHardwareInfo().platform.eProductFamily];
16271627

1628-
TargetDevice targetDevice = {};
1629-
1630-
targetDevice.coreFamily = pDevice->getHardwareInfo().platform.eRenderCoreFamily;
1631-
targetDevice.stepping = pDevice->getHardwareInfo().platform.usRevId;
1632-
targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t);
1628+
TargetDevice targetDevice = NEO::targetDeviceFromHwInfo(pDevice->getHardwareInfo());
16331629

16341630
std::string decodeErrors;
16351631
std::string decodeWarnings;

shared/source/device_binary_format/device_binary_formats.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/*
2-
* Copyright (C) 2020 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#include "shared/source/device_binary_format/device_binary_formats.h"
99

10+
#include "shared/source/helpers/hw_info.h"
11+
1012
namespace NEO {
1113

1214
std::vector<uint8_t> packDeviceBinary(const SingleDeviceBinary binary, std::string &outErrReason, std::string &outWarning) {
@@ -16,4 +18,13 @@ std::vector<uint8_t> packDeviceBinary(const SingleDeviceBinary binary, std::stri
1618
return packDeviceBinary<DeviceBinaryFormat::OclElf>(binary, outErrReason, outWarning);
1719
}
1820

21+
TargetDevice targetDeviceFromHwInfo(const HardwareInfo &hwInfo) {
22+
TargetDevice targetDevice = {};
23+
targetDevice.coreFamily = hwInfo.platform.eRenderCoreFamily;
24+
targetDevice.productFamily = hwInfo.platform.eProductFamily;
25+
targetDevice.stepping = hwInfo.platform.usRevId;
26+
targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t);
27+
targetDevice.grfSize = hwInfo.capabilityTable.grfSize;
28+
return targetDevice;
29+
}
1930
} // namespace NEO

shared/source/device_binary_format/device_binary_formats.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -18,6 +18,7 @@
1818

1919
namespace NEO {
2020
struct ProgramInfo;
21+
struct HardwareInfo;
2122

2223
enum class DeviceBinaryFormat : uint8_t {
2324
Unknown,
@@ -60,6 +61,7 @@ struct TargetDevice {
6061
uint32_t maxPointerSizeInBytes = 4U;
6162
uint32_t grfSize = 32U;
6263
};
64+
TargetDevice targetDeviceFromHwInfo(const NEO::HardwareInfo &hwInfo);
6365

6466
struct SingleDeviceBinary {
6567
DeviceBinaryFormat format = DeviceBinaryFormat::Unknown;

0 commit comments

Comments
 (0)