Switch to new compiler interface to get system routine

Related-To: NEO-4773
This commit is contained in:
Mateusz Hoppe
2021-01-04 11:44:28 +00:00
committed by Compute-Runtime-Automation
parent 3ca77a6cbe
commit 0eb10d7505
12 changed files with 111 additions and 237 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -34,6 +34,7 @@
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
#include "opencl/test/unit_test/mocks/mock_compilers.h"
#include "opencl/test/unit_test/mocks/mock_kernel.h"
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
#include "opencl/test/unit_test/test_macros/test_checks_ocl.h"
#include "test.h"
@ -2009,24 +2010,12 @@ TEST_F(BuiltInTests, WhenGettingSipKernelThenReturnProgramCreatedFromIsaAcquired
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[rootDeviceIndex]->builtins.reset(builtins);
mockCompilerInterface->sipKernelBinaryOverride = mockCompilerInterface->getDummyGenBinary();
cl_int errCode = CL_BUILD_PROGRAM_FAILURE;
auto p = Program::createBuiltInFromGenBinary(pContext, pContext->getDevices(), mockCompilerInterface->sipKernelBinaryOverride.data(), mockCompilerInterface->sipKernelBinaryOverride.size(), &errCode);
ASSERT_EQ(CL_SUCCESS, errCode);
errCode = p->processGenBinary(*pClDevice);
ASSERT_EQ(CL_SUCCESS, errCode);
const auto &sipKernelInfo = p->getKernelInfo(static_cast<size_t>(0), rootDeviceIndex);
auto compbinedKernelHeapSize = sipKernelInfo->heapInfo.KernelHeapSize;
auto sipOffset = sipKernelInfo->systemKernelOffset;
ASSERT_GT(compbinedKernelHeapSize, sipOffset);
const SipKernel &sipKernel = builtins->getSipKernel(SipKernelType::Csr, *pDevice);
auto expectedMem = reinterpret_cast<const char *>(sipKernelInfo->heapInfo.pKernelHeap) + sipOffset;
EXPECT_EQ(0, memcmp(expectedMem, sipKernel.getSipAllocation()->getUnderlyingBuffer(), compbinedKernelHeapSize - sipOffset));
auto expectedMem = mockCompilerInterface->sipKernelBinaryOverride.data();
EXPECT_EQ(0, memcmp(expectedMem, sipKernel.getSipAllocation()->getUnderlyingBuffer(), mockCompilerInterface->sipKernelBinaryOverride.size()));
EXPECT_EQ(SipKernelType::Csr, mockCompilerInterface->requestedSipKernel);
p->release();
mockCompilerInterface->releaseDummyGenBinary();
}
@ -2036,6 +2025,22 @@ TEST_F(BuiltInTests, givenSipKernelWhenItIsCreatedThenItHasGraphicsAllocationFor
EXPECT_NE(nullptr, sipAllocation);
}
TEST_F(BuiltInTests, givenSipKernelWhenAllocationFailsThenItHasNullptrGraphicsAllocation) {
auto executionEnvironment = new MockExecutionEnvironment;
executionEnvironment->prepareRootDeviceEnvironments(1);
auto memoryManager = new MockMemoryManager(*executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager);
auto device = std::unique_ptr<RootDevice>(Device::create<RootDevice>(executionEnvironment, 0u));
EXPECT_NE(nullptr, device);
memoryManager->failAllocate32Bit = true;
auto builtins = std::make_unique<BuiltIns>();
const SipKernel &sipKern = builtins->getSipKernel(SipKernelType::Csr, *device);
auto sipAllocation = sipKern.getSipAllocation();
EXPECT_EQ(nullptr, sipAllocation);
}
TEST_F(BuiltInTests, givenSameDeviceIsUsedWhenUsingStaticGetterThenExpectRetrieveSameAllocation) {
const SipKernel &sipKern = pDevice->getBuiltIns()->getSipKernel(SipKernelType::Csr, pContext->getDevice(0)->getDevice());
auto sipAllocation = sipKern.getSipAllocation();

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -19,67 +19,6 @@
using namespace NEO;
namespace SipKernelTests {
std::string getDebugSipKernelNameWithBitnessAndProductSuffix(std::string &base, const char *product) {
std::string fullName = base + std::string("_");
if (sizeof(uintptr_t) == 8) {
fullName.append("64_");
} else {
fullName.append("32_");
}
fullName.append(product);
return fullName;
}
TEST(Sip, WhenSipKernelIsInvalidThenEmptyCompilerInternalOptionsAreReturned) {
const char *opt = getSipKernelCompilerInternalOptions(SipKernelType::COUNT);
ASSERT_NE(nullptr, opt);
EXPECT_EQ(0U, strlen(opt));
}
TEST(Sip, WhenRequestingCsrSipKernelThenProperCompilerInternalOptionsAreReturned) {
const char *opt = getSipKernelCompilerInternalOptions(SipKernelType::Csr);
ASSERT_NE(nullptr, opt);
EXPECT_STREQ("-cl-include-sip-csr", opt);
}
TEST(Sip, When32BitAddressesAreNotBeingForcedThenSipLlHasSameBitnessAsHostApplication) {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_NE(nullptr, mockDevice);
mockDevice->deviceInfo.force32BitAddressess = false;
const char *src = getSipLlSrc(*mockDevice);
ASSERT_NE(nullptr, src);
if (sizeof(void *) == 8) {
EXPECT_NE(nullptr, strstr(src, "target datalayout = \"e-p:64:64:64\""));
EXPECT_NE(nullptr, strstr(src, "target triple = \"spir64\""));
} else {
EXPECT_NE(nullptr, strstr(src, "target datalayout = \"e-p:32:32:32\""));
EXPECT_NE(nullptr, strstr(src, "target triple = \"spir\""));
EXPECT_EQ(nullptr, strstr(src, "target triple = \"spir64\""));
}
}
TEST(Sip, When32BitAddressesAreBeingForcedThenSipLlHas32BitAddresses) {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_NE(nullptr, mockDevice);
mockDevice->deviceInfo.force32BitAddressess = true;
const char *src = getSipLlSrc(*mockDevice);
ASSERT_NE(nullptr, src);
EXPECT_NE(nullptr, strstr(src, "target datalayout = \"e-p:32:32:32\""));
EXPECT_NE(nullptr, strstr(src, "target triple = \"spir\""));
EXPECT_EQ(nullptr, strstr(src, "target triple = \"spir64\""));
}
TEST(Sip, GivenSipLlWhenGettingMetadataThenMetadataRequiredByCompilerIsReturned) {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_NE(nullptr, mockDevice);
const char *src = getSipLlSrc(*mockDevice);
ASSERT_NE(nullptr, src);
EXPECT_NE(nullptr, strstr(src, "!opencl.compiler.options"));
EXPECT_NE(nullptr, strstr(src, "!opencl.kernels"));
}
TEST(Sip, WhenGettingTypeThenCorrectTypeIsReturned) {
SipKernel csr{SipKernelType::Csr, nullptr};
@ -109,18 +48,6 @@ TEST(DebugSip, givenDebuggingActiveWhenSipTypeIsQueriedThenDbgCsrSipTypeIsReturn
EXPECT_LE(SipKernelType::DbgCsr, sipType);
}
TEST(DebugSip, WhenRequestingDbgCsrSipKernelThenProperCompilerInternalOptionsAreReturned) {
const char *opt = getSipKernelCompilerInternalOptions(SipKernelType::DbgCsr);
ASSERT_NE(nullptr, opt);
EXPECT_STREQ("-cl-include-sip-kernel-debug -cl-include-sip-csr -cl-set-bti:0", opt);
}
TEST(DebugSip, WhenRequestingDbgCsrWithLocalMemorySipKernelThenProperCompilerInternalOptionsAreReturned) {
const char *opt = getSipKernelCompilerInternalOptions(SipKernelType::DbgCsrLocal);
ASSERT_NE(nullptr, opt);
EXPECT_STREQ("-cl-include-sip-kernel-local-debug -cl-include-sip-csr -cl-set-bti:0", opt);
}
TEST(DebugSip, givenBuiltInsWhenDbgCsrSipIsRequestedThanCorrectSipKernelIsReturned) {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_NE(nullptr, mockDevice);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -18,8 +18,6 @@
using namespace NEO;
namespace SipKernelTests {
extern std::string getDebugSipKernelNameWithBitnessAndProductSuffix(std::string &base, const char *product);
typedef ::testing::Test gen9SipTests;
GEN9TEST_F(gen9SipTests, givenDebugCsrSipKernelWithLocalMemoryWhenAskedForDebugSurfaceBtiAndSizeThenBtiIsZeroAndSizeGreaterThanZero) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -490,6 +490,15 @@ bool MockIgcOclDeviceCtx::GetSystemRoutine(IGC::SystemRoutineType::SystemRoutine
bool bindless,
CIF::Builtins::BufferSimple *outSystemRoutineBuffer,
CIF::Builtins::BufferSimple *stateSaveAreaHeaderInit) {
MockCompilerDebugVars &debugVars = *NEO::igcDebugVars;
debugVars.typeOfSystemRoutine = typeOfSystemRoutine;
const char mockData[64] = {'C', 'T', 'N', 'I'};
if (debugVars.forceBuildFailure || typeOfSystemRoutine == IGC::SystemRoutineType::undefined) {
return false;
}
outSystemRoutineBuffer->PushBackRawBytes(mockData, 64);
return true;
}
@ -636,7 +645,6 @@ std::vector<char> MockCompilerInterface::getDummyGenBinary() {
return MockSipKernel::getDummyGenBinary();
}
void MockCompilerInterface::releaseDummyGenBinary() {
MockSipKernel::shutDown();
}
} // namespace NEO

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -26,7 +26,7 @@ namespace NEO {
MockSipKernel::MockSipKernel(SipKernelType type, GraphicsAllocation *sipAlloc) : SipKernel(type, sipAlloc) {
this->mockSipMemoryAllocation =
std::make_unique<MemoryAllocation>(0u,
GraphicsAllocation::AllocationType::KERNEL_ISA,
GraphicsAllocation::AllocationType::KERNEL_ISA_INTERNAL,
nullptr,
MemoryConstants::pageSize * 10u,
0u,
@ -37,7 +37,7 @@ MockSipKernel::MockSipKernel(SipKernelType type, GraphicsAllocation *sipAlloc) :
MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, nullptr) {
this->mockSipMemoryAllocation =
std::make_unique<MemoryAllocation>(0u,
GraphicsAllocation::AllocationType::KERNEL_ISA,
GraphicsAllocation::AllocationType::KERNEL_ISA_INTERNAL,
nullptr,
MemoryConstants::pageSize * 10u,
0u,
@ -47,31 +47,10 @@ MockSipKernel::MockSipKernel() : SipKernel(SipKernelType::Csr, nullptr) {
MockSipKernel::~MockSipKernel() = default;
std::vector<char> MockSipKernel::dummyBinaryForSip;
const char *MockSipKernel::dummyBinaryForSip = "12345678";
std::vector<char> MockSipKernel::getDummyGenBinary() {
if (dummyBinaryForSip.empty()) {
dummyBinaryForSip = getBinary();
}
return dummyBinaryForSip;
}
std::vector<char> MockSipKernel::getBinary() {
std::string testFile;
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd16_", ".gen");
size_t binarySize = 0;
auto binary = loadDataFromFile(testFile.c_str(), binarySize);
UNRECOVERABLE_IF(binary == nullptr);
std::vector<char> ret{binary.get(), binary.get() + binarySize};
return ret;
}
void MockSipKernel::initDummyBinary() {
dummyBinaryForSip = getBinary();
}
void MockSipKernel::shutDown() {
MockSipKernel::dummyBinaryForSip.clear();
std::vector<char>().swap(MockSipKernel::dummyBinaryForSip);
return std::vector<char>(dummyBinaryForSip, dummyBinaryForSip + sizeof(MockSipKernel::dummyBinaryForSip));
}
GraphicsAllocation *MockSipKernel::getSipAllocation() const {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -25,11 +25,8 @@ class MockSipKernel : public SipKernel {
MockSipKernel();
~MockSipKernel() override;
static std::vector<char> dummyBinaryForSip;
static const char *dummyBinaryForSip;
static std::vector<char> getDummyGenBinary();
static std::vector<char> getBinary();
static void initDummyBinary();
static void shutDown();
GraphicsAllocation *getSipAllocation() const override;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -13,18 +13,8 @@ static std::vector<char> dummyBinaryForSip;
using namespace NEO;
std::vector<char> MockSipKernel::dummyBinaryForSip;
const char *MockSipKernel::dummyBinaryForSip = "12345678";
std::vector<char> MockSipKernel::getDummyGenBinary() {
return MockSipKernel::dummyBinaryForSip;
}
std::vector<char> MockSipKernel::getBinary() {
return MockSipKernel::dummyBinaryForSip;
}
void MockSipKernel::initDummyBinary() {
}
void MockSipKernel::shutDown() {
return std::vector<char>(dummyBinaryForSip, dummyBinaryForSip + sizeof(MockSipKernel::dummyBinaryForSip));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -46,23 +46,22 @@ const SipKernel &BuiltIns::getSipKernel(SipKernelType type, Device &device) {
UNRECOVERABLE_IF(ret != TranslationOutput::ErrorCode::Success);
UNRECOVERABLE_IF(sipBinary.size() == 0);
ProgramInfo programInfo;
auto blob = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(sipBinary.data()), sipBinary.size());
SingleDeviceBinary deviceBinary = {};
deviceBinary.deviceBinary = blob;
std::string decodeErrors;
std::string decodeWarnings;
const auto allocType = GraphicsAllocation::AllocationType::KERNEL_ISA_INTERNAL;
DecodeError decodeError;
DeviceBinaryFormat singleDeviceBinaryFormat;
std::tie(decodeError, singleDeviceBinaryFormat) = NEO::decodeSingleDeviceBinary(programInfo, deviceBinary, decodeErrors, decodeWarnings);
UNRECOVERABLE_IF(DecodeError::Success != decodeError);
AllocationProperties properties = {device.getRootDeviceIndex(), sipBinary.size(), allocType, device.getDeviceBitfield()};
properties.flags.use32BitFrontWindow = false;
auto success = programInfo.kernelInfos[0]->createKernelAllocation(device, true);
UNRECOVERABLE_IF(!success);
auto sipAllocation = device.getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
sipBuiltIn.first.reset(new SipKernel(type, programInfo.kernelInfos[0]->kernelAllocation));
programInfo.kernelInfos[0]->kernelAllocation = nullptr;
auto &hwInfo = device.getHardwareInfo();
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
if (sipAllocation) {
MemoryTransferHelper::transferMemoryToAllocation(hwHelper.isBlitCopyRequiredForLocalMemory(hwInfo, *sipAllocation),
device, sipAllocation, 0, sipBinary.data(),
sipBinary.size());
}
sipBuiltIn.first.reset(new SipKernel(type, sipAllocation));
};
std::call_once(sipBuiltIn.second, initializer);
UNRECOVERABLE_IF(sipBuiltIn.first == nullptr);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -22,51 +22,6 @@ namespace NEO {
const size_t SipKernel::maxDbgSurfaceSize = 0x1800000; // proper value should be taken from compiler when it's ready
const char *getSipKernelCompilerInternalOptions(SipKernelType kernel) {
switch (kernel) {
default:
DEBUG_BREAK_IF(true);
return "";
case SipKernelType::Csr:
return "-cl-include-sip-csr";
case SipKernelType::DbgCsr:
return "-cl-include-sip-kernel-debug -cl-include-sip-csr -cl-set-bti:0";
case SipKernelType::DbgCsrLocal:
return "-cl-include-sip-kernel-local-debug -cl-include-sip-csr -cl-set-bti:0";
}
}
const char *getSipLlSrc(const Device &device) {
#define M_DUMMY_LL_SRC \
"define void @f() { \n" \
" ret void \n" \
"} \n" \
"!opencl.compiler.options = !{!0} \n" \
"!opencl.kernels = !{!1} \n" \
"!0 = !{} \n" \
"!1 = !{void()* @f, !2, !3, !4, !5, !6, !7} \n" \
"!2 = !{!\"kernel_arg_addr_space\"} \n" \
"!3 = !{!\"kernel_arg_access_qual\"} \n" \
"!4 = !{!\"kernel_arg_type\"} \n" \
"!5 = !{!\"kernel_arg_type_qual\"} \n" \
"!6 = !{!\"kernel_arg_base_type\"} \n" \
"!7 = !{!\"kernel_arg_name\"} \n"
constexpr const char *llDummySrc32 =
"target datalayout = \"e-p:32:32:32\" \n"
"target triple = \"spir\" \n" M_DUMMY_LL_SRC;
constexpr const char *llDummySrc64 =
"target datalayout = \"e-p:64:64:64\" \n"
"target triple = \"spir64\" \n" M_DUMMY_LL_SRC;
#undef M_DUMMY_LL_SRC
const uint32_t ptrSize = device.getDeviceInfo().force32BitAddressess ? 4 : sizeof(void *);
return (ptrSize == 8) ? llDummySrc64 : llDummySrc32;
}
SipKernel::~SipKernel() = default;
SipKernel::SipKernel(SipKernelType type, GraphicsAllocation *sipAlloc) : type(type), sipAllocation(sipAlloc) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -17,10 +17,6 @@ namespace NEO {
class Device;
class GraphicsAllocation;
const char *getSipKernelCompilerInternalOptions(SipKernelType kernel);
const char *getSipLlSrc(const Device &device);
class SipKernel {
public:
SipKernel(SipKernelType type, GraphicsAllocation *sipAlloc);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -308,23 +308,37 @@ TranslationOutput::ErrorCode CompilerInterface::getSipKernelBinary(NEO::Device &
return TranslationOutput::ErrorCode::CompilerNotAvailable;
}
const char *sipSrc = getSipLlSrc(device);
std::string sipInternalOptions = getSipKernelCompilerInternalOptions(type);
IGC::SystemRoutineType::SystemRoutineType_t typeOfSystemRoutine = IGC::SystemRoutineType::undefined;
switch (type) {
case SipKernelType::Csr:
typeOfSystemRoutine = IGC::SystemRoutineType::contextSaveRestore;
break;
case SipKernelType::DbgCsr:
typeOfSystemRoutine = IGC::SystemRoutineType::debug;
break;
case SipKernelType::DbgCsrLocal:
typeOfSystemRoutine = IGC::SystemRoutineType::debugSlm;
break;
default:
break;
}
auto igcSrc = CIF::Builtins::CreateConstBuffer(igcMain.get(), sipSrc, strlen(sipSrc) + 1);
auto igcOptions = CIF::Builtins::CreateConstBuffer(igcMain.get(), nullptr, 0);
auto igcInternalOptions = CIF::Builtins::CreateConstBuffer(igcMain.get(), sipInternalOptions.c_str(), sipInternalOptions.size() + 1);
auto deviceCtx = getIgcDeviceCtx(device);
const bool bindlessSip = false;
auto igcTranslationCtx = createIgcTranslationCtx(device, IGC::CodeType::llvmLl, IGC::CodeType::oclGenBin);
auto systemRoutineBuffer = igcMain.get()->CreateBuiltin<CIF::Builtins::BufferLatest>();
auto stateSaveAreaBuffer = igcMain.get()->CreateBuiltin<CIF::Builtins::BufferLatest>();
auto igcOutput = translate(igcTranslationCtx.get(), igcSrc.get(),
igcOptions.get(), igcInternalOptions.get());
auto result = deviceCtx->GetSystemRoutine(typeOfSystemRoutine,
bindlessSip,
systemRoutineBuffer.get(),
stateSaveAreaBuffer.get());
if ((igcOutput == nullptr) || (igcOutput->Successful() == false)) {
if (!result) {
return TranslationOutput::ErrorCode::UnknownError;
}
retBinary.assign(igcOutput->GetOutput()->GetMemory<char>(), igcOutput->GetOutput()->GetMemory<char>() + igcOutput->GetOutput()->GetSizeRaw());
retBinary.assign(systemRoutineBuffer->GetMemory<char>(), systemRoutineBuffer->GetMemory<char>() + systemRoutineBuffer->GetSizeRaw());
return TranslationOutput::ErrorCode::Success;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -1007,15 +1007,7 @@ TEST_F(CompilerInterfaceTest, whenCompilerIsNotAvailableThenGetSipKernelBinaryFa
EXPECT_EQ(0U, sipBinary.size());
}
TEST_F(CompilerInterfaceTest, whenIgcTranslatorReturnsNullptrThenGetSipKernelBinaryFailsGracefully) {
pCompilerInterface->failCreateIgcTranslationCtx = true;
std::vector<char> sipBinary;
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary);
EXPECT_EQ(TranslationOutput::ErrorCode::UnknownError, err);
EXPECT_EQ(0U, sipBinary.size());
}
TEST_F(CompilerInterfaceTest, whenIgcTranslatorReturnsBuildErrorThenGetSipKernelBinaryFailsGracefully) {
TEST_F(CompilerInterfaceTest, whenIgcReturnsErrorThenGetSipKernelBinaryFailsGracefully) {
MockCompilerDebugVars igcDebugVars;
igcDebugVars.forceBuildFailure = true;
gEnvironment->igcPushDebugVars(igcDebugVars);
@ -1040,22 +1032,36 @@ TEST_F(CompilerInterfaceTest, whenEverythingIsOkThenGetSipKernelReturnsIgcsOutpu
gEnvironment->igcPopDebugVars();
}
TEST_F(CompilerInterfaceTest, whenRequestingSipKernelBinaryThenProperInternalOptionsAndSrcAreUsed) {
std::string receivedInternalOptions;
std::string receivedInput;
TEST_F(CompilerInterfaceTest, whenRequestingSipKernelBinaryThenProperSystemRoutineIsSelectedFromCompiler) {
MockCompilerDebugVars igcDebugVars;
retrieveBinaryKernelFilename(igcDebugVars.fileName, "CopyBuffer_simd16_", ".bc");
igcDebugVars.receivedInternalOptionsOutput = &receivedInternalOptions;
igcDebugVars.receivedInput = &receivedInput;
gEnvironment->igcPushDebugVars(igcDebugVars);
std::vector<char> sipBinary;
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::Csr, sipBinary);
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
EXPECT_NE(0U, sipBinary.size());
EXPECT_EQ(0, strcmp(getSipKernelCompilerInternalOptions(SipKernelType::Csr), receivedInternalOptions.c_str()));
std::string expectedInut = getSipLlSrc(*this->pDevice);
EXPECT_EQ(0, strcmp(expectedInut.c_str(), receivedInput.c_str()));
EXPECT_EQ(IGC::SystemRoutineType::contextSaveRestore, getIgcDebugVars().typeOfSystemRoutine);
err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsr, sipBinary);
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
EXPECT_NE(0U, sipBinary.size());
EXPECT_EQ(IGC::SystemRoutineType::debug, getIgcDebugVars().typeOfSystemRoutine);
err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::DbgCsrLocal, sipBinary);
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
EXPECT_NE(0U, sipBinary.size());
EXPECT_EQ(IGC::SystemRoutineType::debugSlm, getIgcDebugVars().typeOfSystemRoutine);
gEnvironment->igcPopDebugVars();
}
TEST_F(CompilerInterfaceTest, whenRequestingIvalidSipKernelBinaryThenErrorIsReturned) {
MockCompilerDebugVars igcDebugVars;
gEnvironment->igcPushDebugVars(igcDebugVars);
std::vector<char> sipBinary;
auto err = pCompilerInterface->getSipKernelBinary(*this->pDevice, SipKernelType::COUNT, sipBinary);
EXPECT_EQ(TranslationOutput::ErrorCode::UnknownError, err);
EXPECT_EQ(0U, sipBinary.size());
EXPECT_EQ(IGC::SystemRoutineType::undefined, getIgcDebugVars().typeOfSystemRoutine);
gEnvironment->igcPopDebugVars();
}