P4 to Git Change 1487653 by wchau@wchau_OCL_boltzmann on 2017/11/28 11:28:09

SWDEV-119491 - Add support for cl_amd_assembly_program extension
	This is a sub-task of SWDEV-134396.  Part 1/4 of the required changes:
	  (1) OpenCL API / Runtime, (2) ROCm Runtime - compiler invocation, (3) ROCm Driver, (4) Enabling Extension

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_common.hpp#19 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_context.cpp#57 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_program.cpp#45 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl1.2/CL/cl_ext.h#19 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.0/CL/cl_ext.h#35 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.1/CL/cl_ext.h#12 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/khronos/headers/opencl2.2/CL/cl_ext.h#6 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#215 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#293 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.cpp#90 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/program.hpp#42 edit


[ROCm/clr commit: 1f86279494]
This commit is contained in:
foreman
2017-11-28 11:41:42 -05:00
parent 95d2f777a0
commit f898f91b38
4 changed files with 24 additions and 10 deletions
@@ -116,7 +116,7 @@ bool Device::BlitProgram::create(amd::Device* device, const char* extraKernels,
}
// Create a program with all blit kernels
program_ = new Program(*context_, kernels.c_str());
program_ = new Program(*context_, kernels.c_str(), Program::OpenCL_C);
if (program_ == NULL) {
return false;
}
@@ -119,6 +119,7 @@ enum OclExtensions {
ClKhrIlProgram,
ClAMDLiquidFlash,
ClAmdCopyBufferP2P,
ClAmdAssemblyProgram,
ClExtTotal
};
@@ -161,6 +162,7 @@ static const char* OclExtensionsString[] = {"cl_khr_fp64 ",
"",
"cl_amd_liquid_flash ",
"cl_amd_copy_buffer_p2p ",
"cl_amd_assembly_program ",
NULL};
static constexpr int AmdVendor = 0x1002;
@@ -52,7 +52,7 @@ cl_int Program::addDeviceProgram(Device& device, const void* image, size_t lengt
if (image != NULL && !amd::isElfMagic((const char*)image)
#if !defined(WITH_LIGHTNING_COMPILER)
&& !aclValidateBinaryImage(
image, length, isSPIRV_ ? BINARY_TYPE_SPIRV : BINARY_TYPE_ELF | BINARY_TYPE_LLVM)
image, length, language_ == SPIRV ? BINARY_TYPE_SPIRV : BINARY_TYPE_ELF | BINARY_TYPE_LLVM)
#endif // !defined(WITH_LIGHTNING_COMPILER)
) {
return CL_INVALID_BINARY;
@@ -104,7 +104,7 @@ cl_int Program::addDeviceProgram(Device& device, const void* image, size_t lengt
aclBinaryFini(binary);
}
#endif // defined(WITH_COMPILER_LIB)
options->oVariables->BinaryIsSpirv = isSPIRV_;
options->oVariables->BinaryIsSpirv = language_ == SPIRV;
device::Program* program = rootDev.createProgram(options);
if (program == NULL) {
return CL_OUT_OF_HOST_MEMORY;
@@ -210,7 +210,7 @@ cl_int Program::compile(const std::vector<Device*>& devices, size_t numHeaders,
devProgram = getDeviceProgram(**it);
}
if (devProgram->type() == device::Program::TYPE_INTERMEDIATE || isSPIRV_) {
if (devProgram->type() == device::Program::TYPE_INTERMEDIATE || language_ == SPIRV) {
continue;
}
// We only build a Device-Program once
@@ -284,8 +284,8 @@ cl_int Program::link(const std::vector<Device*>& devices, size_t numInputs,
bool found = false;
for (size_t i = 0; i < numInputs; ++i) {
Program& inputProgram = *inputPrograms[i];
if (inputProgram.isSPIRV_) {
parsedOptions.oVariables->BinaryIsSpirv = inputProgram.isSPIRV_;
if (inputProgram.language_ == SPIRV) {
parsedOptions.oVariables->BinaryIsSpirv = true;
}
deviceprograms_t inputDevProgs = inputProgram.devicePrograms();
deviceprograms_t::const_iterator findIt = inputDevProgs.find(*it);
@@ -492,6 +492,11 @@ cl_int Program::build(const std::vector<Device*>& devices, const char* options,
parsedOptions.oVariables->AssumeAlias = true;
if (language_ == Assembly) {
constexpr char asmLang[] = "asm";
parsedOptions.oVariables->XLang = asmLang;
}
// We only build a Device-Program once
if (devProgram->buildStatus() != CL_BUILD_NONE) {
continue;
@@ -72,6 +72,12 @@ class Program : public RuntimeObject {
typedef std::map<Device const*, device::Program*> deviceprograms_t;
typedef std::map<std::string, Symbol> symbols_t;
enum Language {
Binary = 0,
OpenCL_C,
SPIRV,
Assembly
};
private:
//! Replaces the compiled program with the new version from HD
void StubProgramSource(const std::string& app_name);
@@ -80,7 +86,7 @@ class Program : public RuntimeObject {
SharedReference<Context> context_;
std::string sourceCode_; //!< Strings that make up the source code
bool isSPIRV_; //!< The binary image is SPIRV
Language language_; //!< Input source language
devicebinary_t binary_; //!< The binary image, provided by the app
symbols_t* symbolTable_; //!< The program's kernels symbol table
std::string kernelNames_; //!< The program kernel names
@@ -103,15 +109,16 @@ class Program : public RuntimeObject {
public:
//! Construct a new program to be compiled from the given source code.
Program(Context& context, const std::string& sourceCode, bool isSPIRV = false)
Program(Context& context, const std::string& sourceCode, Language language)
: context_(context),
sourceCode_(sourceCode),
isSPIRV_(isSPIRV),
language_(language),
symbolTable_(NULL),
programLog_() {}
//! Construct a new program associated with a context.
Program(Context& context) : context_(context), isSPIRV_(false), symbolTable_(NULL) {}
Program(Context& context, Language language = Binary)
: context_(context), language_(language), symbolTable_(NULL) {}
//! Returns context, associated with the current program.
const Context& context() const { return context_(); }