Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit 20ce3b4

Browse files
agodavarAnusha Godavarthy Surya
authored andcommitted
SWDEV-254185 - Added support to pass include headers to hipRTC
Change-Id: Ic7f2957b04e518c57e2fd3fc9d839de07232405e
1 parent bf04cff commit 20ce3b4

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

device/devprogram.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,7 @@ int32_t Program::link(const std::vector<Program*>& inputPrograms, const char* or
15801580

15811581
// ================================================================================================
15821582
int32_t Program::build(const std::string& sourceCode, const char* origOptions,
1583-
amd::option::Options* options) {
1583+
amd::option::Options* options) {
15841584
uint64_t start_time = 0;
15851585
if (options->oVariables->EnableBuildTiming) {
15861586
buildLog_ = "\nStart timing major build components.....\n\n";
@@ -1608,10 +1608,17 @@ int32_t Program::build(const std::string& sourceCode, const char* origOptions,
16081608
"specified without device support";
16091609
}
16101610

1611-
// Compile the source code if any
16121611
std::vector<const std::string*> headers;
1612+
std::vector<const char*> headerIncludeNames;
1613+
const std::vector<std::string>& tmpHeaderNames = owner()->headerNames();
1614+
const std::vector<std::string>& tmpHeaders = owner()->headers();
1615+
for (size_t i = 0; i < tmpHeaders.size(); ++i){
1616+
headers.push_back(&tmpHeaders[i]);
1617+
headerIncludeNames.push_back(tmpHeaderNames[i].c_str());
1618+
}
1619+
// Compile the source code if any
16131620
if ((buildStatus_ == CL_BUILD_IN_PROGRESS) && !sourceCode.empty() &&
1614-
!compileImpl(sourceCode, headers, nullptr, options)) {
1621+
!compileImpl(sourceCode, headers, &headerIncludeNames[0], options)) {
16151622
buildStatus_ = CL_BUILD_ERROR;
16161623
if (buildLog_.empty()) {
16171624
buildLog_ = "Internal error: Compilation failed.";

platform/program.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ class Program : public RuntimeObject {
104104
//! The context this program is part of.
105105
SharedReference<Context> context_;
106106

107+
std::vector<std::string> headerNames_;
108+
std::vector<std::string> headers_;
107109
std::string sourceCode_; //!< Strings that make up the source code
108110
Language language_; //!< Input source language
109111
devicebinary_t binary_; //!< The binary image, provided by the app
@@ -128,12 +130,17 @@ class Program : public RuntimeObject {
128130

129131
public:
130132
//! Construct a new program to be compiled from the given source code.
131-
Program(Context& context, const std::string& sourceCode, Language language)
133+
Program(Context& context, const std::string& sourceCode, Language language,
134+
int numHeaders = 0, const char** headers = nullptr, const char** headerNames= nullptr)
132135
: context_(context),
133136
sourceCode_(sourceCode),
134137
language_(language),
135138
symbolTable_(NULL),
136139
programLog_() {
140+
for (auto i = 0; i != numHeaders; ++i) {
141+
headers_.emplace_back(headers[i]);
142+
headerNames_.emplace_back(headerNames[i]);
143+
}
137144
}
138145

139146
//! Construct a new program associated with a context.
@@ -159,6 +166,12 @@ class Program : public RuntimeObject {
159166
//! Return the program source code.
160167
const std::string& sourceCode() const { return sourceCode_; }
161168

169+
//! Return the program headers.
170+
const std::vector<std::string>& headers() const { return headers_; }
171+
172+
//! Return the program header include names.
173+
const std::vector<std::string>& headerNames() const { return headerNames_; }
174+
162175
//! Return the program language.
163176
const Language language() const { return language_; }
164177

0 commit comments

Comments
 (0)