SpirV improvements
* Use preferredIR form compiler * Allow .spv test files instead of .bc Change-Id: Ia1a693be52b7391896378fbe159be85f4e7a00c1
This commit is contained in:
parent
d382402957
commit
c2454d5aa2
|
@ -360,7 +360,7 @@ int OfflineCompiler::initialize(uint32_t numArgs, const char **argv) {
|
|||
}
|
||||
|
||||
fclDeviceCtx->SetOclApiVersion(hwInfo->capabilityTable.clVersionSupport * 10);
|
||||
preferredIntermediateRepresentation = IGC::CodeType::llvmBc;
|
||||
preferredIntermediateRepresentation = fclDeviceCtx->GetPreferredIntermediateRepresentation();
|
||||
|
||||
this->igcLib.reset(OsLibrary::load(Os::igcDllName));
|
||||
if (this->igcLib == nullptr) {
|
||||
|
|
|
@ -395,7 +395,7 @@ IGC::FclOclDeviceCtxTagOCL *CompilerInterface::getFclDeviceCtx(const Device &dev
|
|||
}
|
||||
|
||||
IGC::CodeType::CodeType_t CompilerInterface::getPreferredIntermediateRepresentation(const Device &device) {
|
||||
return IGC::CodeType::llvmBc;
|
||||
return getFclDeviceCtx(device)->GetPreferredIntermediateRepresentation();
|
||||
}
|
||||
|
||||
CIF::RAII::UPtr_t<IGC::FclOclTranslationCtxTagOCL> CompilerInterface::createFclTranslationCtx(const Device &device, IGC::CodeType::CodeType_t inType, IGC::CodeType::CodeType_t outType) {
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "runtime/program/program.h"
|
||||
#include "unit_tests/helpers/kernel_binary_helper.h"
|
||||
#include "unit_tests/helpers/test_files.h"
|
||||
#include "unit_tests/mocks/mock_compilers.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
|
@ -185,37 +186,34 @@ TEST_F(clBuildProgramTests, GivenProgramCreatedFromBinaryWhenBuildProgramWithOpt
|
|||
CompilerInterface::shutdown();
|
||||
}
|
||||
|
||||
TEST_F(clBuildProgramTests, FromBinarySpir) {
|
||||
TEST_F(clBuildProgramTests, GivenSpirAsInputWhenCreatingProgramFromBinaryThenProgramBuildSucceeds) {
|
||||
cl_program pProgram = nullptr;
|
||||
cl_int binaryStatus = CL_SUCCESS;
|
||||
void *pBinary = nullptr;
|
||||
size_t binarySize = 0;
|
||||
|
||||
KernelBinaryHelper kbHeler("CopyBuffer_simd8", false);
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bc");
|
||||
|
||||
binarySize = loadDataFromFile(
|
||||
testFile.c_str(),
|
||||
pBinary);
|
||||
|
||||
ASSERT_NE(0u, binarySize);
|
||||
ASSERT_NE(nullptr, pBinary);
|
||||
char llvm[16] = "BC\xc0\xde";
|
||||
void *binary = llvm;
|
||||
size_t binarySize = sizeof(llvm);
|
||||
|
||||
pProgram = clCreateProgramWithBinary(
|
||||
pContext,
|
||||
num_devices,
|
||||
devices,
|
||||
&binarySize,
|
||||
(const unsigned char **)&pBinary,
|
||||
(const unsigned char **)&binary,
|
||||
&binaryStatus,
|
||||
&retVal);
|
||||
|
||||
deleteDataReadFromFile(pBinary);
|
||||
|
||||
EXPECT_NE(nullptr, pProgram);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
MockCompilerDebugVars igcDebugVars;
|
||||
SProgramBinaryHeader progBin = {};
|
||||
progBin.Magic = iOpenCL::MAGIC_CL;
|
||||
progBin.Version = iOpenCL::CURRENT_ICBE_VERSION;
|
||||
progBin.Device = pContext->getDevice(0)->getHardwareInfo().pPlatform->eRenderCoreFamily;
|
||||
igcDebugVars.binaryToReturn = &progBin;
|
||||
igcDebugVars.binaryToReturnSize = sizeof(progBin);
|
||||
auto prevDebugVars = getIgcDebugVars();
|
||||
setIgcDebugVars(igcDebugVars);
|
||||
retVal = clBuildProgram(
|
||||
pProgram,
|
||||
num_devices,
|
||||
|
@ -223,8 +221,9 @@ TEST_F(clBuildProgramTests, FromBinarySpir) {
|
|||
"-x spir -spir-std=1.2",
|
||||
nullptr,
|
||||
nullptr);
|
||||
setIgcDebugVars(prevDebugVars);
|
||||
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = clReleaseProgram(pProgram);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/helpers/file_io.h"
|
||||
#include "test_files.h"
|
||||
#include "config.h"
|
||||
|
||||
|
@ -37,4 +38,8 @@ void retrieveBinaryKernelFilename(std::string &outputFilename, const std::string
|
|||
outputFilename.append(binaryNameSuffix);
|
||||
outputFilename.append(extension);
|
||||
outputFilename.append(options);
|
||||
}
|
||||
|
||||
if (!fileExists(outputFilename) && (extension == ".bc")) {
|
||||
retrieveBinaryKernelFilename(outputFilename, kernelName, ".spv", options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -406,12 +406,16 @@ void translate(bool usingIgc, CIF::Builtins::BufferSimple *src, CIF::Builtins::B
|
|||
}
|
||||
}
|
||||
|
||||
size_t fileSize = 0;
|
||||
auto fileData = loadBinaryFile(inputFile, fileSize);
|
||||
if ((debugVars.binaryToReturn != nullptr) || (debugVars.binaryToReturnSize != 0)) {
|
||||
out->setOutput(debugVars.binaryToReturn, debugVars.binaryToReturnSize);
|
||||
} else {
|
||||
size_t fileSize = 0;
|
||||
auto fileData = loadBinaryFile(inputFile, fileSize);
|
||||
|
||||
out->setOutput(fileData.get(), fileSize);
|
||||
if (fileSize == 0) {
|
||||
out->setError("error: Mock compiler could not find cached input file: " + inputFile);
|
||||
out->setOutput(fileData.get(), fileSize);
|
||||
if (fileSize == 0) {
|
||||
out->setError("error: Mock compiler could not find cached input file: " + inputFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (debugVars.debugDataToReturn != nullptr) {
|
||||
|
|
|
@ -42,6 +42,8 @@ struct MockCompilerDebugVars {
|
|||
bool appendOptionsToFileName = true;
|
||||
void *debugDataToReturn = nullptr;
|
||||
size_t debugDataToReturnSize = 0;
|
||||
void *binaryToReturn = nullptr;
|
||||
size_t binaryToReturnSize = 0;
|
||||
bool failCreatePlatformInterface = false;
|
||||
bool failCreateGtSystemInfoInterface = false;
|
||||
bool failCreateIgcFeWaInterface = false;
|
||||
|
|
Loading…
Reference in New Issue