Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Allow multiple build options for opencl-aot #2828

Merged
merged 3 commits into from
Dec 1, 2020
Merged

Conversation

vmaksimo
Copy link
Contributor

This patch adds handling of multiple build options if they were set separately.
Covered by test https://github.com/intel/llvm-test-suite/pull/58/files

Signed-off-by: Viktoria Maksimova [email protected]

std::string BuildOptions = OptBuildOptions;
std::string BuildOptsStr;
if (!OptBuildOptions.empty()) {
BuildOptsStr = *OptBuildOptions.begin();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this can't be handled within a loop below?

Copy link
Contributor Author

@vmaksimo vmaksimo Nov 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's done to avoid trailing space delimiter. If we start for_each from the first element, there will be a space at the beginning of the string.
Possibly, it's not a big problem, but I was not sure.

Copy link
Contributor

@dm-vodopyanov dm-vodopyanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this patch make the following use case available (multiple usage of --bo option)?
opencl-aot input.spv --device=cpu --bo="-some-option1" --bo="-some-option2 -someoption3"

std::string BuildOptions = OptBuildOptions;
std::string BuildOptsStr;
if (!OptBuildOptions.empty()) {
BuildOptsStr = *OptBuildOptions.begin();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can range-based loop be used here? Smth like that:

if (!OptBuildOptions.empty()) {
    for (const auto& BuildOption: OptBuildOptions) {
      BuildOptions += BuildOption + ' ';
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care about the extra space delimiter at the end of the string? If not, then that's an option

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, missed this thread. Yeah, it doesn't matter if extra space is at the beginning or at the end of the string.

@@ -414,7 +414,14 @@ int main(int Argc, char *Argv[]) {
CLProgramUPtr ProgramUPtr(std::move(Progs[0]));

// step 7: set OpenCL build options
std::string BuildOptions = OptBuildOptions;
std::string BuildOptsStr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use BuildOptions variable here, the number of variables reduced.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so too, but on 433 line we use the initial build options string, not the BuildOptions with the parent directory path attached (on line 427). And we, unfortunately, can't reuse OptBuildOptions for this purpose as it was done previously

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it looks like a bug on my side - BuildOptions should have been passed to clBuildProgram, not OptBuildOptions. That's because on line 427 a mandatory option -I"/path/to/dir" is adding to BuildOptions, and after that it prints to cout, and it doesn't use in any way after that - just another variable - OptBuildOptions - is used in algorithm below. This mandatory option is required for FPGA Emu, and dpcpp don't use opencl-aot for AOT FPGA Emu, but definitely is should be fixed.
Can you please try to use the single variable BuildOptions here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that makes more sense.
Sure, I've uploaded the change you asked for, you're welcome to review it.

std::string BuildOptsStr;
if (!OptBuildOptions.empty()) {
BuildOptsStr = *OptBuildOptions.begin();
for_each(OptBuildOptions.begin() + 1, OptBuildOptions.end(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::for_each

@vmaksimo
Copy link
Contributor Author

Does this patch make the following use case available (multiple usage of --bo option)?
opencl-aot input.spv --device=cpu --bo="-some-option1" --bo="-some-option2 -someoption3"

Exactly, here is the test for this case intel/llvm-test-suite#58

This patch adds handling of multiple build options if they were set separately.

Signed-off-by: Viktoria Maksimova <[email protected]>
@vmaksimo vmaksimo marked this pull request as ready for review November 27, 2020 17:19
Copy link
Contributor

@dm-vodopyanov dm-vodopyanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bader bader requested a review from AlexeySachkov December 1, 2020 11:50
@bader bader merged commit 5e5703f into intel:sycl Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants