From 773ffef7d255644804a67df3e4865a4cfaff01d5 Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 19 Aug 2015 07:28:56 -0400
Subject: [PATCH] P4 to Git Change 1182078 by yaxunl@yaxunl_stg_win50 on
2015/08/19 07:12:32
ECR #354633 - SPIR-V: Add consumption of SPIR-V to HSAIL path.
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/build/Makefile.api#120 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_program.cpp#36 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/OpenCL.def.in#11 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/icd/icd_exports.map.in#7 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/Makefile#35 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/acl.cpp#34 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/aclValidation.cpp#6 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/v0_8/if_acl.cpp#73 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/build/Makefile.complib#90 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/include/v0_8/acl.h#10 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/include/v0_8/aclEnums.h#21 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/include/v0_8/aclTypes.h#7 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/bif/bifinternal.hpp#11 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/spirv/Makefile#1 add
... //depot/stg/opencl/drivers/opencl/compiler/lib/spirv/build/Makefile#1 add
... //depot/stg/opencl/drivers/opencl/compiler/lib/spirv/build/Makefile.spirv#1 add
... //depot/stg/opencl/drivers/opencl/compiler/lib/spirv/spirvUtils.cpp#1 add
... //depot/stg/opencl/drivers/opencl/compiler/lib/spirv/spirvUtils.h#1 add
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/options.hpp#16 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/v0_8/libUtils.h#22 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#182 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#250 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#200 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.cpp#64 edit
... //depot/stg/opencl/drivers/opencl/tests/conformance/devel/2.0/test_conformance/spirv/select.zip#1 add
... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/complib/CLEnumCheck.cpp#46 edit
... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/complib/CLEnumCheck.h#4 edit
... //depot/stg/opencl/drivers/opencl/tests/ocltst/module/complib/aclAPI.cpp#20 edit
---
.../lib/backends/common/v0_8/if_acl.cpp | 83 ++++++++++++++++++-
rocclr/compiler/lib/include/v0_8/acl.h | 7 +-
rocclr/compiler/lib/include/v0_8/aclEnums.h | 19 ++++-
rocclr/compiler/lib/include/v0_8/aclTypes.h | 1 +
rocclr/compiler/lib/spirv/spirvUtils.cpp | 18 ++++
rocclr/compiler/lib/spirv/spirvUtils.h | 9 ++
rocclr/compiler/lib/utils/options.hpp | 4 +-
rocclr/compiler/lib/utils/v0_8/libUtils.h | 15 ++++
rocclr/runtime/device/device.cpp | 44 ++--------
rocclr/runtime/device/device.hpp | 3 -
rocclr/runtime/device/gpu/gpuprogram.cpp | 14 +++-
rocclr/runtime/platform/program.cpp | 5 +-
12 files changed, 170 insertions(+), 52 deletions(-)
create mode 100644 rocclr/compiler/lib/spirv/spirvUtils.cpp
create mode 100644 rocclr/compiler/lib/spirv/spirvUtils.h
diff --git a/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp b/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp
index f3e8d7196b..d7da9353bd 100644
--- a/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp
+++ b/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp
@@ -45,6 +45,7 @@
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/IRReader.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ExecutionEngine/ObjectImage.h"
#include "llvm/ExecutionEngine/ObjectBuffer.h"
@@ -52,9 +53,11 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/SPIRV.h"
#endif
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PrettyStackTrace.h"
@@ -378,6 +381,59 @@ OCLFEToModule(
}
return module;
}
+
+aclModule* ACL_API_ENTRY
+SPIRVToModule(
+ aclLoaderData *ald,
+ const char *image,
+ size_t length,
+ aclContext *ctx,
+ acl_error *error)
+{
+ auto compiler = reinterpret_cast(ald);
+#ifdef LEGACY_COMPLIB
+ llvm::report_fatal_error("SPIR-V not supported on legacy compiler lib");
+ appendLogToCL(compiler->CL(), "SPIR-V not supported on legacy compiler lib");
+ if (error != nullptr) (*error) = ACL_SPIRV_LOAD_FAIL;
+ return nullptr;
+#else
+ std::string spvImg(image, length);
+ auto opt = compiler->Options();
+ if (opt->isDumpFlagSet(amd::option::DUMP_SPIRV)) {
+ std::ofstream ofs(opt->getDumpFileName(".spv"), std::ios::binary);
+ ofs << spvImg;
+ ofs.close();
+ }
+
+ std::stringstream ss(spvImg);
+ std::string errMsg;
+ auto llCtx = reinterpret_cast(ctx);
+ llvm::Module *llMod = nullptr;
+ bool success = llvm::ReadSPRV(*llCtx, ss, llMod, errMsg);
+
+ if (success && llMod && opt->isDumpFlagSet(amd::option::DUMP_BC_SPIRV)) {
+ auto bcDump = opt->getDumpFileName("_spirv.bc");
+ std::error_code ec;
+ llvm::raw_fd_ostream outS(bcDump.c_str(), ec, llvm::sys::fs::F_None);
+ if (!ec)
+ WriteBitcodeToFile(llMod, outS);
+ else
+ errMsg = ec.message();
+ }
+
+ if (!errMsg.empty()) {
+ appendLogToCL(compiler->CL(), errMsg);
+ }
+ if (!success || llMod == nullptr) {
+ if (error != nullptr) (*error) = ACL_SPIRV_LOAD_FAIL;
+ return nullptr;
+ }
+
+ if (error != nullptr) (*error) = ACL_SUCCESS;
+ return reinterpret_cast(llMod);
+#endif // LEGACY_COMPLIB
+}
+
acl_error ACL_API_ENTRY
AMDILFEToISA(
aclLoaderData *ald,
@@ -1369,8 +1425,10 @@ if_aclCompile(aclCompiler *cl,
(from == ACL_TYPE_HSAIL_BINARY && to != ACL_TYPE_ISA && to != ACL_TYPE_CG)) {
return ACL_INVALID_ARG;
}
- uint8_t sectable[ACL_TYPE_LAST] = {0, 0, 1, 1, 1, 1, 0, 6, 0, 3, 4, 4, 4, 0, 5, 0, 1};
- aclSections d_section[7] = {aclSOURCE, aclLLVMIR, aclSPIR, aclSOURCE, aclCODEGEN, aclTEXT, aclINTERNAL};
+ uint8_t sectable[ACL_TYPE_LAST] = {0, 0, 1, 1, 1, 1, 0, 6, 0, 3, 4, 4, 4, 0,
+ 5, 0, 1, 1};
+ aclSections d_section[7] = {aclSOURCE, aclLLVMIR, aclSPIR, aclSOURCE,
+ aclCODEGEN, aclTEXT, aclINTERNAL};
uint8_t start = sectable[from];
uint8_t stop = sectable[to];
const void* data = NULL;
@@ -1393,6 +1451,9 @@ if_aclCompile(aclCompiler *cl,
}
break;
}
+ case ACL_TYPE_SPIRV_BINARY:
+ data = cl->clAPI.extSec(cl, bin, &data_size, aclSPIRV, &error_code);
+ break;
case ACL_TYPE_SPIR_BINARY:
case ACL_TYPE_SPIR_TEXT:
data = cl->clAPI.extSec(cl, bin, &data_size, aclSPIR, &error_code);
@@ -1486,15 +1547,19 @@ if_aclCompile(aclCompiler *cl,
CONDITIONAL_CMP_ASSIGN(cl->feAPI.toModule, &OCLFEToModule, &SPIRToModule);
} else if (from == ACL_TYPE_LLVMIR_BINARY || from == ACL_TYPE_LLVMIR_TEXT ||
from == ACL_TYPE_SPIR_BINARY || from == ACL_TYPE_SPIR_TEXT ||
- from == ACL_TYPE_RSLLVMIR_BINARY) {
+ from == ACL_TYPE_RSLLVMIR_BINARY || from == ACL_TYPE_SPIRV_BINARY) {
CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &SPIRInit, &OCLInit);
CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &AMDILInit, &OCLInit);
CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &HSAILFEInit, &OCLInit);
CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &SPIRFini, &OCLFini);
CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &AMDILFini, &OCLFini);
CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &HSAILFEFini, &OCLFini);
- if (from == ACL_TYPE_RSLLVMIR_BINARY) {
+ if (from == ACL_TYPE_SPIRV_BINARY) {
+ cl->feAPI.toModule = &SPIRVToModule;
+ } else if (from == ACL_TYPE_RSLLVMIR_BINARY) {
cl->feAPI.toModule = &RSLLVMIRToModule;
+ } else {
+ cl->feAPI.toModule = &OCLFEToModule;
}
}
}
@@ -2284,6 +2349,16 @@ if_aclQueryInfo(aclCompiler *cl,
return ACL_SUCCESS;
}
return ACL_ERROR;
+ case RT_CONTAINS_SPIRV:
+ if (!ptr) {
+ *size = sizeof(bool);
+ return ACL_SUCCESS;
+ } else if (*size >= sizeof(bool)) {
+ bool contains = elfBin->isSection(aclSPIRV);
+ memcpy(ptr, &contains, sizeof(bool));
+ return ACL_SUCCESS;
+ }
+ return ACL_ERROR;
case RT_CONTAINS_OPTIONS:
if (!ptr) {
*size = sizeof(bool);
diff --git a/rocclr/compiler/lib/include/v0_8/acl.h b/rocclr/compiler/lib/include/v0_8/acl.h
index 35fafd5435..ba2669196c 100644
--- a/rocclr/compiler/lib/include/v0_8/acl.h
+++ b/rocclr/compiler/lib/include/v0_8/acl.h
@@ -229,7 +229,12 @@ const void* ACL_API_ENTRY
const char *kernel,
size_t *size,
acl_error *error_code) ACL_API_0_8;
-
+//!--------------------------------------------------------------------------!//
+// Functions that deal with binary image.
+//!--------------------------------------------------------------------------!//
+bool ACL_API_ENTRY
+ aclValidateBinaryImage(const void* binary,
+ size_t length, unsigned) ACL_API_0_8;
//!--------------------------------------------------------------------------!//
// Functions that deal with aclJITObjectImage objects.
//!--------------------------------------------------------------------------!//
diff --git a/rocclr/compiler/lib/include/v0_8/aclEnums.h b/rocclr/compiler/lib/include/v0_8/aclEnums.h
index 82e3703fd1..eec2bcef34 100644
--- a/rocclr/compiler/lib/include/v0_8/aclEnums.h
+++ b/rocclr/compiler/lib/include/v0_8/aclEnums.h
@@ -32,7 +32,8 @@ typedef enum _acl_error_enum_0_8 {
ACL_INVALID_SPIR = 24,
ACL_LWVERIFY_FAIL = 25,
ACL_HWVERIFY_FAIL = 26,
- ACL_LAST_ERROR = 27
+ ACL_SPIRV_LOAD_FAIL = 27,
+ ACL_LAST_ERROR = 28
} acl_error_0_8;
typedef enum _comp_device_caps_enum_0_8 {
@@ -111,7 +112,8 @@ typedef enum _acl_type_enum_0_8 {
ACL_TYPE_ISA = 14,
ACL_TYPE_HEADER = 15,
ACL_TYPE_RSLLVMIR_BINARY = 16,
- ACL_TYPE_LAST = 17
+ ACL_TYPE_SPIRV_BINARY = 17,
+ ACL_TYPE_LAST = 18
} aclType_0_8;
//! Enum of the various loader types that are supported.
@@ -184,7 +186,8 @@ typedef enum _bif_sections_enum_0_8 {
aclBRIGxxx3 = 33,
aclHSADEBUG = 34,
aclKSTATS = 35, // For storing kernel statistics
- aclLAST = 36
+ aclSPIRV = 36,
+ aclLAST = 37
} aclSections_0_8;
//! An enumeration that defines what are valid queries for aclQueryInfo.
@@ -212,7 +215,8 @@ typedef enum _rt_query_types_enum_0_8 {
RT_CONTAINS_LOADER_MAP = 20,
RT_CONTAINS_SPIR = 21,
RT_NUM_KERNEL_HIDDEN_ARGS = 22,
- RT_LAST_TYPE = 23
+ RT_CONTAINS_SPIRV = 23,
+ RT_LAST_TYPE = 24
} aclQueryType_0_8;
//! An enumeration for the various GPU capabilities
@@ -328,4 +332,11 @@ typedef enum _acl_access_type_enum_0_8 {
ACCESS_TYPE_LAST = 4
} aclAccessType_0_8;
+// Enumeration that specifies the binary types.
+typedef enum _acl_binary_image_type_enum_0_8 {
+ BINARY_TYPE_ELF = 1,
+ BINARY_TYPE_LLVM = 2,
+ BINARY_TYPE_SPIRV = 4,
+} aclBinaryImageType_0_8;
+
#endif // _ACL_ENUMS_0_8_H_
diff --git a/rocclr/compiler/lib/include/v0_8/aclTypes.h b/rocclr/compiler/lib/include/v0_8/aclTypes.h
index e500a1d46e..f6cb0f9598 100644
--- a/rocclr/compiler/lib/include/v0_8/aclTypes.h
+++ b/rocclr/compiler/lib/include/v0_8/aclTypes.h
@@ -51,6 +51,7 @@ typedef enum _bif_version_enum_0_8 aclBIFVersion;
typedef enum _bif_platform_enum_0_8 aclPlatform;
typedef enum _bif_sections_enum_0_8 aclSections;
typedef enum _acl_loader_type_enum_0_8 aclLoaderType;
+typedef enum _acl_binary_image_type_enum_0_8 aclBinaryImageType;
#include "aclFunctors.h"
// Typedefs for function pointers
diff --git a/rocclr/compiler/lib/spirv/spirvUtils.cpp b/rocclr/compiler/lib/spirv/spirvUtils.cpp
new file mode 100644
index 0000000000..1244714578
--- /dev/null
+++ b/rocclr/compiler/lib/spirv/spirvUtils.cpp
@@ -0,0 +1,18 @@
+#include "spirvUtils.h"
+
+const unsigned SPRVMagicNumber = 0x07230203;
+
+bool isSPIRVMagic(const void* Image, size_t Length) {
+ if (Image == nullptr || Length < sizeof(unsigned))
+ return false;
+ auto Magic = static_cast(Image);
+ return *Magic == SPRVMagicNumber;
+}
+
+// ToDo: replace this with SPIR-V validator when it is available.
+bool
+validateSPIRV(const void *Image, size_t Length) {
+ return isSPIRVMagic(Image, Length);
+}
+
+
diff --git a/rocclr/compiler/lib/spirv/spirvUtils.h b/rocclr/compiler/lib/spirv/spirvUtils.h
new file mode 100644
index 0000000000..0efd13c010
--- /dev/null
+++ b/rocclr/compiler/lib/spirv/spirvUtils.h
@@ -0,0 +1,9 @@
+#ifndef _COMPLIB_SPIRV_UTILS_H
+#define _COMPLIB_SPIRV_UTILS_H
+
+#include
+
+bool validateSPIRV(const void *image, size_t length);
+bool isSPIRVMagic(const void* image, size_t length);
+
+#endif
diff --git a/rocclr/compiler/lib/utils/options.hpp b/rocclr/compiler/lib/utils/options.hpp
index 6897762f58..ef10ff28ff 100644
--- a/rocclr/compiler/lib/utils/options.hpp
+++ b/rocclr/compiler/lib/utils/options.hpp
@@ -165,6 +165,8 @@ enum DumpFlags {
DUMP_BC_OPTIMIZED = 0x00000400, // bitcode after optimization (llvm opt's output)
DUMP_CGIL = 0x00000800, // output il generated by Codegen (llvm llc's output)
DUMP_DEBUGIL = 0x00001000, // debug il (from MDParser, dwarf refers to)
+ DUMP_SPIRV = 0x00002000, // SPIR-V binary
+ DUMP_BC_SPIRV = 0x00004000, // bitcode translated from SPIR-V
// For a binary is encrypted, can only dump the following
DUMP_ENCRYPT = (DUMP_DLL | DUMP_BIF),
@@ -174,7 +176,7 @@ enum DumpFlags {
DUMP_IL |DUMP_CGIL | DUMP_DEBUGIL |
DUMP_ISA | DUMP_BIF),
- DUMP_ALL = 0x00001FFF // Everything
+ DUMP_ALL = 0x00007FFF // Everything
};
enum OptLevelFlags {
diff --git a/rocclr/compiler/lib/utils/v0_8/libUtils.h b/rocclr/compiler/lib/utils/v0_8/libUtils.h
index 2f9775f3ae..620e5c3724 100644
--- a/rocclr/compiler/lib/utils/v0_8/libUtils.h
+++ b/rocclr/compiler/lib/utils/v0_8/libUtils.h
@@ -376,4 +376,19 @@ inline bool writeFile(std::string source_filename, const char *source, size_t si
return EXIT_SUCCESS;
}
+#if !defined(BCMAG)
+#define BCMAG "BC"
+#define SBCMAG 2
+#endif
+// Helper predicate returns true if p starts with bit code signature.
+// TODO: Move it into Compiler Lib back in new 1_0 API
+inline static bool
+isBcMagic(const char* p)
+{
+ if (p==NULL || strncmp(p, BCMAG, SBCMAG) != 0) {
+ return false;
+ }
+ return true;
+}
+
#endif // _CL_LIB_UTILS_0_8_H_
diff --git a/rocclr/runtime/device/device.cpp b/rocclr/runtime/device/device.cpp
index 496c7ad755..8829f6c170 100644
--- a/rocclr/runtime/device/device.cpp
+++ b/rocclr/runtime/device/device.cpp
@@ -32,6 +32,8 @@ extern void DeviceUnload();
#endif
#include "utils/bif_section_labels.hpp"
+#include "utils/libUtils.h"
+#include "spirv/spirvUtils.h"
#include
#include
@@ -41,20 +43,7 @@ extern void DeviceUnload();
#include
#include
-#if !defined(BCMAG)
-#define BCMAG "BC"
-#define SBCMAG 2
-#endif
-// Helper predicate returns true if p starts with bit code signature.
-// TODO: Move it into Compiler Lib back in new 1_0 API
-inline static bool
-isBcMagic(const char* p)
-{
- if (p==NULL || strncmp(p, BCMAG, SBCMAG) != 0) {
- return false;
- }
- return true;
-}
+
namespace device {
extern const char* BlitSourceCode;
@@ -252,27 +241,6 @@ Device::~Device()
}
}
-// TODO: Move it into Compiler Lib in new 1_0 API
-bool
-Device::verifyBinaryImage( const void* image, size_t size) const
-{
- const char* p = static_cast(image);
-#if defined(HAVE_BLOWFISH_H)
- int outBufSize;
- if (amd::isEncryptedBIF(p, (int)size, &outBufSize)) {
- // For encrypted image, check it later and simply return true here.
- return true;
- }
-#endif
- if (amd::isElfMagic(p)) {
- return true;
- }
- if (isBcMagic(p)) {
- return true;
- }
- return false;
-}
-
bool
Device::isAncestor(const Device* sub) const
{
@@ -1069,7 +1037,8 @@ Program::initClBinary(char* binaryIn, size_t size)
int encryptCode = 0;
char* decryptedBin = NULL;
- if (isBcMagic(binaryIn))
+ bool isSPIRV = isSPIRVMagic(binaryIn, size);
+ if (isSPIRV || isBcMagic(binaryIn))
{
acl_error err = ACL_SUCCESS;
aclBinaryOptions binOpts = {0};
@@ -1087,7 +1056,8 @@ Program::initClBinary(char* binaryIn, size_t size)
aclBinaryFini(aclbin_v30);
return false;
}
- err = aclInsertSection(device().compiler(), aclbin_v30, binaryIn, size, aclSPIR);
+ err = aclInsertSection(device().compiler(), aclbin_v30, binaryIn, size,
+ isSPIRV?aclSPIRV:aclSPIR);
if (ACL_SUCCESS != err) {
LogWarning("aclInsertSection failed");
aclBinaryFini(aclbin_v30);
diff --git a/rocclr/runtime/device/device.hpp b/rocclr/runtime/device/device.hpp
index 4adce37016..aea5d8dd44 100644
--- a/rocclr/runtime/device/device.hpp
+++ b/rocclr/runtime/device/device.hpp
@@ -1648,9 +1648,6 @@ public:
const amd::Kernel& kernel,
const device::VirtualDevice* vdev) { return true; };
- //! Returns true if the given binary image is valid for this device.
- bool verifyBinaryImage( const void* image, size_t size) const;
-
//! Returns TRUE if the device is available for computations
bool isOnline() const { return online_; }
//! Returns TRUE if the device is a root device (as opposed to sub-device)
diff --git a/rocclr/runtime/device/gpu/gpuprogram.cpp b/rocclr/runtime/device/gpu/gpuprogram.cpp
index 6f7996508e..c8a737ae70 100644
--- a/rocclr/runtime/device/gpu/gpuprogram.cpp
+++ b/rocclr/runtime/device/gpu/gpuprogram.cpp
@@ -1840,6 +1840,16 @@ HSAILProgram::getCompilationStagesFromBinary(std::vector& completeStage
size_t boolSize = sizeof(bool);
//! @todo Should we also check for ACL_TYPE_OPENCL & ACL_TYPE_LLVMIR_TEXT?
// Checking llvmir in .llvmir section
+ bool containsSpirv = true;
+ errorCode = aclQueryInfo(dev().hsaCompiler(), binaryElf_,
+ RT_CONTAINS_SPIRV, NULL, &containsSpirv, &boolSize);
+ if (errorCode != ACL_SUCCESS) {
+ containsSpirv = false;
+ }
+ if (containsSpirv) {
+ completeStages.push_back(from);
+ from = ACL_TYPE_SPIRV_BINARY;
+ }
bool containsSpirText = true;
errorCode = aclQueryInfo(dev().hsaCompiler(), binaryElf_, RT_CONTAINS_SPIR, NULL, &containsSpirText, &boolSize);
if (errorCode != ACL_SUCCESS) {
@@ -1998,7 +2008,8 @@ HSAILProgram::getNextCompilationStageFromBinary(amd::option::Options* options) {
if (recompile) {
while (!completeStages.empty()) {
continueCompileFrom = completeStages.back();
- if (continueCompileFrom == ACL_TYPE_LLVMIR_BINARY ||
+ if (continueCompileFrom == ACL_TYPE_SPIRV_BINARY ||
+ continueCompileFrom == ACL_TYPE_LLVMIR_BINARY ||
continueCompileFrom == ACL_TYPE_SPIR_BINARY ||
continueCompileFrom == ACL_TYPE_DEFAULT) {
break;
@@ -2032,6 +2043,7 @@ HSAILProgram::linkImpl(amd::option::Options* options)
continueCompileFrom = getNextCompilationStageFromBinary(options);
}
switch (continueCompileFrom) {
+ case ACL_TYPE_SPIRV_BINARY:
case ACL_TYPE_SPIR_BINARY:
// Compilation from ACL_TYPE_LLVMIR_BINARY to ACL_TYPE_CG in cases:
// 1. if the program is not created with binary;
diff --git a/rocclr/runtime/platform/program.cpp b/rocclr/runtime/platform/program.cpp
index fdd969bee6..5789d0f7b5 100644
--- a/rocclr/runtime/platform/program.cpp
+++ b/rocclr/runtime/platform/program.cpp
@@ -6,6 +6,7 @@
#include "platform/program.hpp"
#include "platform/context.hpp"
#include "utils/options.hpp"
+#include "acl.h"
#include // for malloc
#include // for strcmp
@@ -48,7 +49,9 @@ Program::findSymbol(const char* kernelName) const
cl_int
Program::addDeviceProgram(Device& device, const void* image, size_t length, int oclVer)
{
- if (image != NULL && !device.verifyBinaryImage(image, length)) {
+ if (image != NULL &&
+ !aclValidateBinaryImage(image, length,
+ isIL_?BINARY_TYPE_SPIRV:BINARY_TYPE_ELF|BINARY_TYPE_LLVM)) {
return CL_INVALID_BINARY;
}