Skip to content

Commit

Permalink
[SYCL] Allow multiple build options for opencl-aot (#2828)
Browse files Browse the repository at this point in the history
This patch adds handling of multiple build options if they were set separately.
Covered by test from intel/llvm-test-suite#58.

Signed-off-by: Viktoria Maksimova <[email protected]>
  • Loading branch information
vmaksimo authored Dec 1, 2020
1 parent 56b9a1d commit 5e5703f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions opencl-aot/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ int main(int Argc, char *Argv[]) {
"o", cl::init("output.bin"),
cl::desc("Specify the output OpenCL program binary filename"),
cl::value_desc("filename"));
cl::opt<std::string> OptBuildOptions("bo",
cl::desc("Set OpenCL build options"),
cl::value_desc("build options"));
cl::list<std::string> OptBuildOptions("bo", cl::ZeroOrMore,
cl::desc("Set OpenCL build options"),
cl::value_desc("build options"));

cl::ParseCommandLineOptions(Argc, Argv,
"OpenCL ahead-of-time (AOT) compilation tool");
Expand Down Expand Up @@ -414,16 +414,21 @@ int main(int Argc, char *Argv[]) {
CLProgramUPtr ProgramUPtr(std::move(Progs[0]));

// step 7: set OpenCL build options
std::string BuildOptions = OptBuildOptions;
std::string BuildOptions;
if (!OptBuildOptions.empty()) {
for (const auto &BO : OptBuildOptions)
BuildOptions += BO + ' ';
}

auto ParentDir = sys::path::parent_path(OptInputBinary);
if (!ParentDir.empty()) {
BuildOptions += " -I \"" + std::string(ParentDir) + '\"';
}
std::cout << "Using build options: " << BuildOptions << '\n';

// step 8: build OpenCL program
CLErr = clBuildProgram(ProgramUPtr.get(), 1, &DeviceId,
OptBuildOptions.c_str(), nullptr, nullptr);
CLErr = clBuildProgram(ProgramUPtr.get(), 1, &DeviceId, BuildOptions.c_str(),
nullptr, nullptr);

std::string CompilerBuildLog;
std::tie(CompilerBuildLog, ErrorMessage, std::ignore) =
Expand Down

0 comments on commit 5e5703f

Please sign in to comment.