diff --git a/projects/clr/rocclr/runtime/device/device.cpp b/projects/clr/rocclr/runtime/device/device.cpp index ec060bcb63..a9b3a65f4a 100644 --- a/projects/clr/rocclr/runtime/device/device.cpp +++ b/projects/clr/rocclr/runtime/device/device.cpp @@ -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; } diff --git a/projects/clr/rocclr/runtime/device/device.hpp b/projects/clr/rocclr/runtime/device/device.hpp index 7451547bdc..8d58fc5a32 100644 --- a/projects/clr/rocclr/runtime/device/device.hpp +++ b/projects/clr/rocclr/runtime/device/device.hpp @@ -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; diff --git a/projects/clr/rocclr/runtime/platform/program.cpp b/projects/clr/rocclr/runtime/platform/program.cpp index e5e987fff5..087ffb5fb4 100644 --- a/projects/clr/rocclr/runtime/platform/program.cpp +++ b/projects/clr/rocclr/runtime/platform/program.cpp @@ -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& 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& 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& 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; diff --git a/projects/clr/rocclr/runtime/platform/program.hpp b/projects/clr/rocclr/runtime/platform/program.hpp index 01008731b0..b22f82d322 100644 --- a/projects/clr/rocclr/runtime/platform/program.hpp +++ b/projects/clr/rocclr/runtime/platform/program.hpp @@ -72,6 +72,12 @@ class Program : public RuntimeObject { typedef std::map deviceprograms_t; typedef std::map 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_; 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_(); }