Add adjustPlatformCoreFamilyForIgc helper

Change-Id: Ic372e76c1024ca9e585bef15fab29827d33122f3
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
Related-To: NEO-4865
This commit is contained in:
Kamil Kopryk
2020-08-13 14:09:05 +02:00
parent 5b50575c23
commit 8fffdcc111
11 changed files with 47 additions and 14 deletions

View File

@@ -115,8 +115,13 @@ bool ModuleTranslationUnit::createFromNativeBinary(const char *input, size_t inp
auto productAbbreviation = NEO::hardwarePrefix[device->getNEODevice()->getHardwareInfo().platform.eProductFamily]; auto productAbbreviation = NEO::hardwarePrefix[device->getNEODevice()->getHardwareInfo().platform.eProductFamily];
NEO::TargetDevice targetDevice = {}; NEO::TargetDevice targetDevice = {};
targetDevice.coreFamily = device->getNEODevice()->getHardwareInfo().platform.eRenderCoreFamily;
targetDevice.stepping = device->getNEODevice()->getHardwareInfo().platform.usRevId; auto copyHwInfo = device->getNEODevice()->getHardwareInfo();
auto &hwHelper = NEO::HwHelper::get(copyHwInfo.platform.eRenderCoreFamily);
hwHelper.adjustPlatformCoreFamilyForIgc(copyHwInfo);
targetDevice.coreFamily = copyHwInfo.platform.eRenderCoreFamily;
targetDevice.stepping = copyHwInfo.platform.usRevId;
targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t); targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t);
std::string decodeErrors; std::string decodeErrors;
std::string decodeWarnings; std::string decodeWarnings;

View File

@@ -168,8 +168,13 @@ cl_int Program::createProgramFromBinary(
auto productAbbreviation = hardwarePrefix[pDevice->getHardwareInfo().platform.eProductFamily]; auto productAbbreviation = hardwarePrefix[pDevice->getHardwareInfo().platform.eProductFamily];
TargetDevice targetDevice = {}; TargetDevice targetDevice = {};
targetDevice.coreFamily = pDevice->getHardwareInfo().platform.eRenderCoreFamily;
targetDevice.stepping = pDevice->getHardwareInfo().platform.usRevId; auto copyHwInfo = pDevice->getHardwareInfo();
auto &hwHelper = HwHelper::get(copyHwInfo.platform.eRenderCoreFamily);
hwHelper.adjustPlatformCoreFamilyForIgc(copyHwInfo);
targetDevice.coreFamily = copyHwInfo.platform.eRenderCoreFamily;
targetDevice.stepping = copyHwInfo.platform.usRevId;
targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t); targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t);
std::string decodeErrors; std::string decodeErrors;
std::string decodeWarnings; std::string decodeWarnings;

View File

@@ -17,6 +17,7 @@
#include "opencl/test/unit_test/mocks/mock_cl_device.h" #include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "opencl/test/unit_test/mocks/mock_program.h" #include "opencl/test/unit_test/mocks/mock_program.h"
#include "test.h"
#include "compiler_options.h" #include "compiler_options.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
@@ -235,7 +236,7 @@ TEST_F(ProcessElfBinaryTests, GivenNonEmptyBuildOptionsWhenCreatingProgramFromBi
EXPECT_STREQ(buildOptionsNotEmpty.c_str(), options.c_str()); EXPECT_STREQ(buildOptionsNotEmpty.c_str(), options.c_str());
} }
TEST_F(ProcessElfBinaryTests, GivenBinaryWhenIncompatiblePatchtokenVerionThenProramCreationFails) { HWTEST_F(ProcessElfBinaryTests, GivenBinaryWhenIncompatiblePatchtokenVerionThenProramCreationFails) {
PatchTokensTestData::ValidEmptyProgram programTokens; PatchTokensTestData::ValidEmptyProgram programTokens;
{ {
NEO::Elf::ElfEncoder<> elfEncoder; NEO::Elf::ElfEncoder<> elfEncoder;

View File

@@ -2721,8 +2721,9 @@ TEST_F(ProgramTests, WhenProgramIsCreatedThenItsDeviceIsProperlySet) {
MockProgram programWithDeviceWithValidSpecializedDevice{executionEnvironment, nullptr, false, &validClDevice.getDevice()}; MockProgram programWithDeviceWithValidSpecializedDevice{executionEnvironment, nullptr, false, &validClDevice.getDevice()};
EXPECT_TRUE(wasValidClDeviceUsed(programWithDeviceWithValidSpecializedDevice)); EXPECT_TRUE(wasValidClDeviceUsed(programWithDeviceWithValidSpecializedDevice));
} }
using CreateProgramFromBinaryTests2 = ::testing::Test;
TEST(CreateProgramFromBinaryTests, givenBinaryProgramWhenKernelRebulildIsForcedThenDeviceBinaryIsNotUsed) { HWTEST_F(CreateProgramFromBinaryTests2, givenBinaryProgramWhenKernelRebulildIsForcedThenDeviceBinaryIsNotUsed) {
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.RebuildPrecompiledKernels.set(true); DebugManager.flags.RebuildPrecompiledKernels.set(true);
cl_int retVal = CL_INVALID_BINARY; cl_int retVal = CL_INVALID_BINARY;
@@ -2743,7 +2744,7 @@ TEST(CreateProgramFromBinaryTests, givenBinaryProgramWhenKernelRebulildIsForcedT
EXPECT_EQ(0U, pProgram->packedDeviceBinarySize); EXPECT_EQ(0U, pProgram->packedDeviceBinarySize);
} }
TEST(CreateProgramFromBinaryTests, givenBinaryProgramWhenKernelRebulildIsNotForcedThenDeviceBinaryIsUsed) { HWTEST_F(CreateProgramFromBinaryTests2, givenBinaryProgramWhenKernelRebulildIsNotForcedThenDeviceBinaryIsUsed) {
cl_int retVal = CL_INVALID_BINARY; cl_int retVal = CL_INVALID_BINARY;
PatchTokensTestData::ValidEmptyProgram programTokens; PatchTokensTestData::ValidEmptyProgram programTokens;
@@ -3058,4 +3059,4 @@ TEST(ProgramReplaceDeviceBinary, GivenBinaryZebinThenUseAsBothPackedAndUnpackedB
ASSERT_NE(nullptr, program.unpackedDeviceBinary); ASSERT_NE(nullptr, program.unpackedDeviceBinary);
EXPECT_EQ(0, memcmp(program.packedDeviceBinary.get(), zebin.storage.data(), program.packedDeviceBinarySize)); EXPECT_EQ(0, memcmp(program.packedDeviceBinary.get(), zebin.storage.data(), program.packedDeviceBinarySize));
EXPECT_EQ(0, memcmp(program.unpackedDeviceBinary.get(), zebin.storage.data(), program.unpackedDeviceBinarySize)); EXPECT_EQ(0, memcmp(program.unpackedDeviceBinary.get(), zebin.storage.data(), program.unpackedDeviceBinarySize));
} }

View File

@@ -16,4 +16,7 @@ void OfflineCompiler::resolveExtraSettings() {
CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::forceEmuInt32DivRemSP); CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::forceEmuInt32DivRemSP);
} }
} }
void OfflineCompiler::adjustExtraSettings(HardwareInfo &hwInfo) {
}
} // namespace NEO } // namespace NEO

View File

@@ -425,8 +425,12 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
if ((igcPlatform == nullptr) || (igcGtSystemInfo == nullptr) || (igcFeWa == nullptr)) { if ((igcPlatform == nullptr) || (igcGtSystemInfo == nullptr) || (igcFeWa == nullptr)) {
return OUT_OF_HOST_MEMORY; return OUT_OF_HOST_MEMORY;
} }
IGC::PlatformHelper::PopulateInterfaceWith(*igcPlatform.get(), hwInfo.platform);
IGC::GtSysInfoHelper::PopulateInterfaceWith(*igcGtSystemInfo.get(), hwInfo.gtSystemInfo); auto copyHwInfo = hwInfo;
adjustExtraSettings(copyHwInfo);
IGC::PlatformHelper::PopulateInterfaceWith(*igcPlatform.get(), copyHwInfo.platform);
IGC::GtSysInfoHelper::PopulateInterfaceWith(*igcGtSystemInfo.get(), copyHwInfo.gtSystemInfo);
// populate with features // populate with features
igcFeWa.get()->SetFtrDesktop(hwInfo.featureTable.ftrDesktop); igcFeWa.get()->SetFtrDesktop(hwInfo.featureTable.ftrDesktop);
igcFeWa.get()->SetFtrChannelSwizzlingXOREnabled(hwInfo.featureTable.ftrChannelSwizzlingXOREnabled); igcFeWa.get()->SetFtrChannelSwizzlingXOREnabled(hwInfo.featureTable.ftrChannelSwizzlingXOREnabled);

View File

@@ -83,6 +83,7 @@ class OfflineCompiler {
int parseCommandLine(size_t numArgs, const std::vector<std::string> &allArgs); int parseCommandLine(size_t numArgs, const std::vector<std::string> &allArgs);
void setStatelessToStatefullBufferOffsetFlag(); void setStatelessToStatefullBufferOffsetFlag();
void resolveExtraSettings(); void resolveExtraSettings();
void adjustExtraSettings(HardwareInfo &hwInfo);
void parseDebugSettings(); void parseDebugSettings();
void storeBinary(char *&pDst, size_t &dstSize, const void *pSrc, const size_t srcSize); void storeBinary(char *&pDst, size_t &dstSize, const void *pSrc, const size_t srcSize);
MOCKABLE_VIRTUAL int buildSourceCode(); MOCKABLE_VIRTUAL int buildSourceCode();

View File

@@ -11,6 +11,7 @@
#include "shared/source/compiler_interface/compiler_interface.inl" #include "shared/source/compiler_interface/compiler_interface.inl"
#include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/device/device.h" #include "shared/source/device/device.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/hw_info.h"
#include "opencl/source/os_interface/os_inc_base.h" #include "opencl/source/os_interface/os_inc_base.h"
@@ -330,7 +331,6 @@ TranslationOutput::ErrorCode CompilerInterface::getSipKernelBinary(NEO::Device &
bool CompilerInterface::loadFcl() { bool CompilerInterface::loadFcl() {
return NEO::loadCompiler<IGC::FclOclDeviceCtx>(Os::frontEndDllName, fclLib, fclMain); return NEO::loadCompiler<IGC::FclOclDeviceCtx>(Os::frontEndDllName, fclLib, fclMain);
;
} }
bool CompilerInterface::loadIgc() { bool CompilerInterface::loadIgc() {
@@ -400,8 +400,13 @@ IGC::IgcOclDeviceCtxTagOCL *CompilerInterface::getIgcDeviceCtx(const Device &dev
if (productFamily != "unk") { if (productFamily != "unk") {
getHwInfoForPlatformString(productFamily, hwInfo); getHwInfoForPlatformString(productFamily, hwInfo);
} }
IGC::PlatformHelper::PopulateInterfaceWith(*igcPlatform, hwInfo->platform);
IGC::GtSysInfoHelper::PopulateInterfaceWith(*igcGtSystemInfo, hwInfo->gtSystemInfo); auto &hwHelper = NEO::HwHelper::get(hwInfo->platform.eRenderCoreFamily);
auto copyHwInfo = *hwInfo;
hwHelper.adjustPlatformCoreFamilyForIgc(copyHwInfo);
IGC::PlatformHelper::PopulateInterfaceWith(*igcPlatform, copyHwInfo.platform);
IGC::GtSysInfoHelper::PopulateInterfaceWith(*igcGtSystemInfo, copyHwInfo.gtSystemInfo);
igcFeWa.get()->SetFtrDesktop(device.getHardwareInfo().featureTable.ftrDesktop); igcFeWa.get()->SetFtrDesktop(device.getHardwareInfo().featureTable.ftrDesktop);
igcFeWa.get()->SetFtrChannelSwizzlingXOREnabled(device.getHardwareInfo().featureTable.ftrChannelSwizzlingXOREnabled); igcFeWa.get()->SetFtrChannelSwizzlingXOREnabled(device.getHardwareInfo().featureTable.ftrChannelSwizzlingXOREnabled);

View File

@@ -123,6 +123,7 @@ class HwHelper {
virtual bool isSpecialWorkgroupSizeRequired(const HardwareInfo &hwInfo, bool isSimulation) const = 0; virtual bool isSpecialWorkgroupSizeRequired(const HardwareInfo &hwInfo, bool isSimulation) const = 0;
virtual uint32_t getGlobalTimeStampBits() const = 0; virtual uint32_t getGlobalTimeStampBits() const = 0;
virtual uint32_t getDefaultThreadArbitrationPolicy() const = 0; virtual uint32_t getDefaultThreadArbitrationPolicy() const = 0;
virtual void adjustPlatformCoreFamilyForIgc(HardwareInfo &hwInfo) = 0;
static uint32_t getSubDevicesCount(const HardwareInfo *pHwInfo); static uint32_t getSubDevicesCount(const HardwareInfo *pHwInfo);
static uint32_t getEnginesCount(const HardwareInfo &hwInfo); static uint32_t getEnginesCount(const HardwareInfo &hwInfo);
@@ -311,6 +312,8 @@ class HwHelperHw : public HwHelper {
uint32_t getDefaultThreadArbitrationPolicy() const override; uint32_t getDefaultThreadArbitrationPolicy() const override;
void adjustPlatformCoreFamilyForIgc(HardwareInfo &hwInfo) override;
protected: protected:
LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override; LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override;

View File

@@ -179,6 +179,10 @@ bool HwHelperHw<Family>::getEnableLocalMemory(const HardwareInfo &hwInfo) const
return OSInterface::osEnableLocalMemory && isLocalMemoryEnabled(hwInfo); return OSInterface::osEnableLocalMemory && isLocalMemoryEnabled(hwInfo);
} }
template <typename Family>
void HwHelperHw<Family>::adjustPlatformCoreFamilyForIgc(HardwareInfo &hwInfo) {
}
template <typename Family> template <typename Family>
AuxTranslationMode HwHelperHw<Family>::getAuxTranslationMode() { AuxTranslationMode HwHelperHw<Family>::getAuxTranslationMode() {
if (DebugManager.flags.ForceAuxTranslationMode.get() != -1) { if (DebugManager.flags.ForceAuxTranslationMode.get() != -1) {

View File

@@ -17,6 +17,7 @@
#include "opencl/test/unit_test/global_environment.h" #include "opencl/test/unit_test/global_environment.h"
#include "opencl/test/unit_test/mocks/mock_cif.h" #include "opencl/test/unit_test/mocks/mock_cif.h"
#include "opencl/test/unit_test/mocks/mock_compilers.h" #include "opencl/test/unit_test/mocks/mock_compilers.h"
#include "test.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "hw_cmds.h" #include "hw_cmds.h"
@@ -902,7 +903,7 @@ TEST_F(CompilerInterfaceTest, GivenRequestForNewIgcTranslationCtxWhenCouldNotPop
setIgcDebugVars(prevDebugVars); setIgcDebugVars(prevDebugVars);
} }
TEST_F(CompilerInterfaceTest, givenNoDbgKeyForceUseDifferentPlatformWhenRequestForNewTranslationCtxThenUseDefaultPlatform) { HWTEST_F(CompilerInterfaceTest, givenNoDbgKeyForceUseDifferentPlatformWhenRequestForNewTranslationCtxThenUseDefaultPlatform) {
auto device = this->pDevice; auto device = this->pDevice;
auto retIgc = pCompilerInterface->createIgcTranslationCtx(*device, IGC::CodeType::spirV, IGC::CodeType::oclGenBin); auto retIgc = pCompilerInterface->createIgcTranslationCtx(*device, IGC::CodeType::spirV, IGC::CodeType::oclGenBin);
EXPECT_NE(nullptr, retIgc); EXPECT_NE(nullptr, retIgc);