From 6dddb8ffaceac4cbd086b07b894bfdaad4156828 Mon Sep 17 00:00:00 2001 From: agodavar Date: Mon, 5 Oct 2020 04:25:18 -0400 Subject: [PATCH] SWDEV-254185 - Added support to pass include headers to hipRTC Change-Id: Ic7f2957b04e518c57e2fd3fc9d839de07232405e [ROCm/clr commit: ac72e50adc98f47e1190d8ef8c58350b757a8a48] --- projects/clr/rocclr/device/devprogram.cpp | 13 ++++++++++--- projects/clr/rocclr/platform/program.hpp | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/projects/clr/rocclr/device/devprogram.cpp b/projects/clr/rocclr/device/devprogram.cpp index 1e0da1f653..bbc6fc279a 100755 --- a/projects/clr/rocclr/device/devprogram.cpp +++ b/projects/clr/rocclr/device/devprogram.cpp @@ -1580,7 +1580,7 @@ int32_t Program::link(const std::vector& inputPrograms, const char* or // ================================================================================================ int32_t Program::build(const std::string& sourceCode, const char* origOptions, - amd::option::Options* options) { + amd::option::Options* options) { uint64_t start_time = 0; if (options->oVariables->EnableBuildTiming) { buildLog_ = "\nStart timing major build components.....\n\n"; @@ -1608,10 +1608,17 @@ int32_t Program::build(const std::string& sourceCode, const char* origOptions, "specified without device support"; } - // Compile the source code if any std::vector headers; + std::vector headerIncludeNames; + const std::vector& tmpHeaderNames = owner()->headerNames(); + const std::vector& tmpHeaders = owner()->headers(); + for (size_t i = 0; i < tmpHeaders.size(); ++i){ + headers.push_back(&tmpHeaders[i]); + headerIncludeNames.push_back(tmpHeaderNames[i].c_str()); + } + // Compile the source code if any if ((buildStatus_ == CL_BUILD_IN_PROGRESS) && !sourceCode.empty() && - !compileImpl(sourceCode, headers, nullptr, options)) { + !compileImpl(sourceCode, headers, &headerIncludeNames[0], options)) { buildStatus_ = CL_BUILD_ERROR; if (buildLog_.empty()) { buildLog_ = "Internal error: Compilation failed."; diff --git a/projects/clr/rocclr/platform/program.hpp b/projects/clr/rocclr/platform/program.hpp index 0d3c0e5990..cb802d9938 100755 --- a/projects/clr/rocclr/platform/program.hpp +++ b/projects/clr/rocclr/platform/program.hpp @@ -104,6 +104,8 @@ class Program : public RuntimeObject { //! The context this program is part of. SharedReference context_; + std::vector headerNames_; + std::vector headers_; std::string sourceCode_; //!< Strings that make up the source code Language language_; //!< Input source language devicebinary_t binary_; //!< The binary image, provided by the app @@ -128,12 +130,17 @@ class Program : public RuntimeObject { public: //! Construct a new program to be compiled from the given source code. - Program(Context& context, const std::string& sourceCode, Language language) + Program(Context& context, const std::string& sourceCode, Language language, + int numHeaders = 0, const char** headers = nullptr, const char** headerNames= nullptr) : context_(context), sourceCode_(sourceCode), language_(language), symbolTable_(NULL), programLog_() { + for (auto i = 0; i != numHeaders; ++i) { + headers_.emplace_back(headers[i]); + headerNames_.emplace_back(headerNames[i]); + } } //! Construct a new program associated with a context. @@ -159,6 +166,12 @@ class Program : public RuntimeObject { //! Return the program source code. const std::string& sourceCode() const { return sourceCode_; } + //! Return the program headers. + const std::vector& headers() const { return headers_; } + + //! Return the program header include names. + const std::vector& headerNames() const { return headerNames_; } + //! Return the program language. const Language language() const { return language_; }