Adding platform info for FCL

Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:
Jaroslaw Chodor 2020-12-09 08:41:52 +01:00 committed by Compute-Runtime-Automation
parent 6e2d81a7da
commit 993ea27e25
6 changed files with 96 additions and 2 deletions

View File

@ -605,8 +605,15 @@ IGC::OclTranslationOutputBase *MockFclOclTranslationCtx::TranslateImpl(
return out;
}
MockFclOclDeviceCtx::MockFclOclDeviceCtx() = default;
MockFclOclDeviceCtx::~MockFclOclDeviceCtx() = default;
MockFclOclDeviceCtx::MockFclOclDeviceCtx() {
platform = new MockCIFPlatform;
}
MockFclOclDeviceCtx::~MockFclOclDeviceCtx() {
if (nullptr != platform) {
platform->Release();
}
}
CIF::ICIF *MockFclOclDeviceCtx::Create(CIF::InterfaceId_t intId, CIF::Version_t version) {
return new MockFclOclDeviceCtx;

View File

@ -33,6 +33,7 @@ struct MockCompilerDebugVars {
bool failCreatePlatformInterface = false;
bool failCreateGtSystemInfoInterface = false;
bool failCreateIgcFeWaInterface = false;
int64_t overrideFclDeviceCtxVersion = -1;
IGC::SystemRoutineType::SystemRoutineType_t typeOfSystemRoutine = IGC::SystemRoutineType::undefined;
std::string *receivedInternalOptionsOutput = nullptr;
std::string *receivedInput = nullptr;
@ -259,7 +260,22 @@ struct MockFclOclDeviceCtx : MockCIF<IGC::FclOclDeviceCtxTagOCL> {
IGC::CodeType::CodeType_t outType,
CIF::Builtins::BufferSimple *err) override;
IGC::PlatformBase *GetPlatformHandleImpl(CIF::Version_t ver) override {
if (getFclDebugVars().failCreatePlatformInterface) {
return nullptr;
}
return platform;
}
CIF::Version_t GetUnderlyingVersion() const override {
if (getFclDebugVars().overrideFclDeviceCtxVersion >= 0) {
return getFclDebugVars().overrideFclDeviceCtxVersion;
}
return CIF::ICIF::GetUnderlyingVersion();
}
uint32_t oclApiVersion = 120;
MockCIFPlatform *platform = nullptr;
};
} // namespace NEO

View File

@ -436,6 +436,13 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
fclDeviceCtx->SetOclApiVersion(hwInfo.capabilityTable.clVersionSupport * 10);
preferredIntermediateRepresentation = fclDeviceCtx->GetPreferredIntermediateRepresentation();
if (this->fclDeviceCtx->GetUnderlyingVersion() > 4U) {
auto igcPlatform = fclDeviceCtx->GetPlatformHandle();
if (nullptr == igcPlatform) {
return OUT_OF_HOST_MEMORY;
}
IGC::PlatformHelper::PopulateInterfaceWith(*igcPlatform, hwInfo.platform);
}
} else {
if (!isQuiet()) {
argHelper->printf("Compilation from IR - skipping loading of FCL\n");

View File

@ -363,6 +363,15 @@ IGC::FclOclDeviceCtxTagOCL *CompilerInterface::getFclDeviceCtx(const Device &dev
return nullptr;
}
newDeviceCtx->SetOclApiVersion(device.getHardwareInfo().capabilityTable.clVersionSupport * 10);
if (newDeviceCtx->GetUnderlyingVersion() > 4U) {
auto igcPlatform = newDeviceCtx->GetPlatformHandle();
if (nullptr == igcPlatform.get()) {
DEBUG_BREAK_IF(true); // could not acquire handles to platform descriptor
return nullptr;
}
const HardwareInfo *hwInfo = &device.getHardwareInfo();
IGC::PlatformHelper::PopulateInterfaceWith(*igcPlatform, hwInfo->platform);
}
fclDeviceContexts[&device] = std::move(newDeviceCtx);
return fclDeviceContexts[&device].get();

View File

@ -1067,6 +1067,60 @@ TEST_F(CompilerInterfaceTest, whenCompilerIsNotAvailableThenGetSpecializationCon
EXPECT_EQ(TranslationOutput::ErrorCode::CompilerNotAvailable, err);
}
TEST_F(CompilerInterfaceTest, GivenRequestForNewFclTranslationCtxWhenInterfaceVersionAbove4ThenPopulatePlatformInfo) {
auto device = this->pDevice;
auto prevDebugVars = getFclDebugVars();
auto debugVars = prevDebugVars;
debugVars.overrideFclDeviceCtxVersion = 5;
setFclDebugVars(debugVars);
auto ret = pCompilerInterface->createFclTranslationCtx(*device, IGC::CodeType::oclC, IGC::CodeType::spirV);
ASSERT_NE(nullptr, ret);
ASSERT_EQ(1U, pCompilerInterface->fclDeviceContexts.size());
auto platform = pCompilerInterface->fclDeviceContexts.begin()->second->GetPlatformHandle();
ASSERT_NE(nullptr, platform);
EXPECT_EQ(device->getHardwareInfo().platform.eProductFamily, platform->GetProductFamily());
setFclDebugVars(prevDebugVars);
}
TEST_F(CompilerInterfaceTest, GivenRequestForNewFclTranslationCtxWhenCouldNotPopulatePlatformInfoAndInterfaceVersionAbove4ThenReturnNullptr) {
auto device = this->pDevice;
auto prevDebugVars = getFclDebugVars();
auto debugVars = prevDebugVars;
debugVars.failCreatePlatformInterface = true;
debugVars.overrideFclDeviceCtxVersion = 5;
setFclDebugVars(debugVars);
auto ret = pCompilerInterface->createFclTranslationCtx(*device, IGC::CodeType::oclC, IGC::CodeType::spirV);
EXPECT_EQ(nullptr, ret);
setFclDebugVars(prevDebugVars);
}
TEST_F(CompilerInterfaceTest, GivenRequestForNewFclTranslationCtxWhenInterfaceVersion4ThenDontPopulatePlatformInfo) {
auto device = this->pDevice;
auto prevDebugVars = getFclDebugVars();
auto debugVars = prevDebugVars;
debugVars.failCreatePlatformInterface = true;
debugVars.overrideFclDeviceCtxVersion = 4;
setFclDebugVars(debugVars);
auto ret = pCompilerInterface->createFclTranslationCtx(*device, IGC::CodeType::oclC, IGC::CodeType::spirV);
EXPECT_NE(nullptr, ret);
setFclDebugVars(prevDebugVars);
}
struct SpecConstantsTranslationCtxMock {
bool returnFalse = false;

View File

@ -20,6 +20,7 @@ namespace NEO {
class MockCompilerInterface : public CompilerInterface {
public:
using CompilerInterface::fclDeviceContexts;
using CompilerInterface::initialize;
using CompilerInterface::isCompilerAvailable;
using CompilerInterface::isFclAvailable;