SWDEV-254185 - Added support to pass include headers to hipRTC

Change-Id: Ic7f2957b04e518c57e2fd3fc9d839de07232405e


[ROCm/clr commit: ac72e50adc]
This commit is contained in:
agodavar
2020-10-05 04:25:18 -04:00
committed by Anusha Godavarthy Surya
parent 4c8d5a2d97
commit 6dddb8ffac
2 changed files with 24 additions and 4 deletions
+10 -3
View File
@@ -1580,7 +1580,7 @@ int32_t Program::link(const std::vector<Program*>& 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<const std::string*> headers;
std::vector<const char*> headerIncludeNames;
const std::vector<std::string>& tmpHeaderNames = owner()->headerNames();
const std::vector<std::string>& 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.";
+14 -1
View File
@@ -104,6 +104,8 @@ class Program : public RuntimeObject {
//! The context this program is part of.
SharedReference<Context> context_;
std::vector<std::string> headerNames_;
std::vector<std::string> 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<std::string>& headers() const { return headers_; }
//! Return the program header include names.
const std::vector<std::string>& headerNames() const { return headerNames_; }
//! Return the program language.
const Language language() const { return language_; }