Skip to content

[Driver][SYCL] Provide ability to use an external host compiler #3530

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

Merged
merged 12 commits into from
Apr 20, 2021

Conversation

mdtoguchi
Copy link
Contributor

The default toolchain when performing -fsycl compilations is to use the
clang compiler for the device and host compilations. Enable the ability
to use an external host compiler (e.g. gcc/g++) to be used when creating
the host objects. This introduces 2 options:

-fsycl-host-compiler=
When specified, this option informs the compiler driver that the host
compilation step that is performed as part of the greater compilation
flow will be performed by the compiler . It is expected that
is the compiler to be called, either by name (in which the PATH
will be used to discover it) or a fully qualified directory with
compiler to invoke. This option is only useful when used with when
'-fsycl' is provided on the command line.

-fsycl-host-compiler-options="opts"
Passes along the space separated quoted "opts" string as option
arguments to the compiler specified with the -fsycl-host-compiler=
option. It is expected that the options used here are compatible with
the compiler specified via -fsycl-host-compiler=. This option
does not have any affect without -fsycl-host-compiler=.

The default toolchain when performing -fsycl compilations is to use the
clang compiler for the device and host compilations.  Enable the ability
to use an external host compiler (e.g. gcc/g++) to be used when creating
the host objects.  This introduces 2 options:

-fsycl-host-compiler=<arg>
  When specified, this option informs the compiler driver that the host
  compilation step that is performed as part of the greater compilation
  flow will be performed by the compiler <arg>.  It is expected that
  <arg> is the compiler to be called, either by name (in which the PATH
  will be used to discover it) or a fully qualified directory with
  compiler to invoke.  This option is only useful when used with when
  '-fsycl' is provided on the command line.

-fsycl-host-compiler-options="opts"
  Passes along the space separated quoted "opts" string as option
  arguments to the compiler specified with the -fsycl-host-compiler=<arg>
  option.  It is expected that the options used here are compatible with
  the compiler specified via -fsycl-host-compiler=<arg>.  This option
  does not have any affect without -fsycl-host-compiler=<arg>.
pvchupin
pvchupin previously approved these changes Apr 11, 2021
Copy link
Contributor

@pvchupin pvchupin left a comment

Choose a reason for hiding this comment

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

doc ok

Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

Mostly just small nits from me.

AaronBallman
AaronBallman previously approved these changes Apr 13, 2021
Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM!

kbobrovs
kbobrovs previously approved these changes Apr 13, 2021
Copy link
Contributor

@kbobrovs kbobrovs left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@mdtoguchi
Copy link
Contributor Author

@AGindinson , can you take a look?

Copy link
Contributor

@AGindinson AGindinson left a comment

Choose a reason for hiding this comment

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

Is it possible to add E2E tests of some sort into llvm-test-suite or sycl tests?

@mdtoguchi mdtoguchi dismissed stale reviews from kbobrovs and AaronBallman via bc068dd April 15, 2021 00:23
@mdtoguchi
Copy link
Contributor Author

While working on an E2E test, I found issues at runtime. When using the external compiler and using -I

/include/sycl there would be a runtime fault. Poking around I found that if I used the clang++ as an external host compiler and tried it would still fail in the same manner. Forcing the usage of -internal-isystem <dir>/include/sycl allows for the runtime to succeed. I've reached out to @premanandrao for help, but maybe @AaronBallman has any ideas what is going on?

@AGindinson AGindinson requested a review from AaronBallman April 16, 2021 08:56
Copy link
Contributor

@AGindinson AGindinson left a comment

Choose a reason for hiding this comment

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

The changes LGTM on the whole. I'm joining to the help request for @premanandrao or @AaronBallman on the matter of E2E testing.

@AaronBallman
Copy link
Contributor

While working on an E2E test, I found issues at runtime. When using the external compiler and using -I

/include/sycl there would be a runtime fault. Poking around I found that if I used the clang++ as an external host compiler and tried it would still fail in the same manner. Forcing the usage of -internal-isystem <dir>/include/sycl allows for the runtime to succeed. I've reached out to @premanandrao for help, but maybe @AaronBallman has any ideas what is going on?

I'm not clear on how we position /include/sycl (whether we believe it's a system header because it's part of the implementation of the compiler or whether we treat it like any other third-party library like openssl, etc), but I suspect we treat it as a system header. Based on that, I think you want to use -cxx-isystem rather than -I so that it is very clear that 1) it's a system header and all the usual system header hacks apply to it, 2) it's a C++-only system header, and 3) it's only available through angle bracket inclusion and not quoted inclusion. That said, this is a bit out of my wheelhouse and I may be repeating information you've already considered.

@mdtoguchi
Copy link
Contributor Author

While working on an E2E test, I found issues at runtime. When using the external compiler and using -I
/include/sycl there would be a runtime fault. Poking around I found that if I used the clang++ as an external host compiler and tried it would still fail in the same manner. Forcing the usage of -internal-isystem <dir>/include/sycl allows for the runtime to succeed. I've reached out to @premanandrao for help, but maybe @AaronBallman has any ideas what is going on?

I'm not clear on how we position /include/sycl (whether we believe it's a system header because it's part of the implementation of the compiler or whether we treat it like any other third-party library like openssl, etc), but I suspect we treat it as a system header. Based on that, I think you want to use -cxx-isystem rather than -I so that it is very clear that 1) it's a system header and all the usual system header hacks apply to it, 2) it's a C++-only system header, and 3) it's only available through angle bracket inclusion and not quoted inclusion. That said, this is a bit out of my wheelhouse and I may be repeating information you've already considered.

I've tried various things including -cxx-isystem. Unfortunately, only using -internal-isystem allowed for this to work, which doesn't seem to be very friendly when dealing with an external compiler invocation.

@AaronBallman
Copy link
Contributor

I've tried various things including -cxx-isystem. Unfortunately, only using -internal-isystem allowed for this to work, which doesn't seem to be very friendly when dealing with an external compiler invocation.

That seems pretty strange to me and may be worth opening an issue to try to track down the root cause of. It seems odd that we need to use the undocumented flag (https://clang.llvm.org/docs/ClangCommandLineReference.html#include-path-management) to get things to work.

@mdtoguchi mdtoguchi requested a review from a team as a code owner April 16, 2021 19:13
@mdtoguchi mdtoguchi requested a review from dm-vodopyanov April 16, 2021 19:13
@mdtoguchi
Copy link
Contributor Author

Looks like my environment is somewhat tainted. I had a CPLUS_INCLUDE_PATH setting to an internal (archived) set of the headers. The combination of this and the -internal-isystem allowed things to work but not clear if it is just happenstance. I went ahead and uploaded my small E2E test to see what happens with a clean environment with our testing.

@premanandrao
Copy link
Contributor

Looks like my environment is somewhat tainted. I had a CPLUS_INCLUDE_PATH setting to an internal (archived) set of the headers. The combination of this and the -internal-isystem allowed things to work but not clear if it is just happenstance. I went ahead and uploaded my small E2E test to see what happens with a clean environment with our testing.

This may explain why I am not able to reproduce this failure. :-)

AGindinson
AGindinson previously approved these changes Apr 19, 2021
Copy link
Contributor

@AGindinson AGindinson left a comment

Choose a reason for hiding this comment

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

LGTM. A similar E2E Windows test could be "intuitively nice", but I personally believe the Linux one provides sufficient coverage for the Driver part.

dm-vodopyanov
dm-vodopyanov previously approved these changes Apr 19, 2021
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.

Thanks, sycl/test/regression part LGTM

@dm-vodopyanov
Copy link
Contributor

A similar E2E Windows test could be "intuitively nice

Missed this. Agree, E2E test on Windows with msvc will be nice to have test, but only Linux one looks ok.

@mdtoguchi mdtoguchi dismissed stale reviews from dm-vodopyanov and AGindinson via 2d66de2 April 19, 2021 15:24
AGindinson
AGindinson previously approved these changes Apr 19, 2021
dm-vodopyanov
dm-vodopyanov previously approved these changes Apr 19, 2021
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.

sycl/test/regression part LGTM

@mdtoguchi mdtoguchi dismissed stale reviews from dm-vodopyanov and AGindinson via b39f7ab April 19, 2021 17:28
@mdtoguchi
Copy link
Contributor Author

Everything should be accounted for, could I get a final look? @kbobrovs, @pvchupin , @AaronBallman, @dm-vodopyanov

Copy link
Contributor

@pvchupin pvchupin left a comment

Choose a reason for hiding this comment

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

doc ok

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.

sycl/test/regression part LGTM

Copy link
Contributor

@premanandrao premanandrao left a comment

Choose a reason for hiding this comment

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

FE changes continue to look good to me.

@bader bader merged commit 6f0ad1a into intel:sycl Apr 20, 2021
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.

8 participants