-
Notifications
You must be signed in to change notification settings - Fork 733
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] Add option -fsycl-use-integration-headers #14759
base: sycl
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments; I don't understand why the option is considered related to code gen.
I still don't love the option name. The option controls two major behaviors:
- Disabling the generation of integration headers and associated options used in generated compiler actions.
- Setting the macro the SYCL run-time library will check to determine how to access kernel information.
Perhaps we shouldn't use a single option to influence both of these behaviors. How about this approach?
- Rename the option to
-f[no-]sycl-integration-headers
to enable/disable generation and use of SYCL integration headers in the generated compiler actions. This option won't be upstreamed. - Have the SYCL run-time library check to see if the builtin functions are available (via
has_builtin
orhas_feature
or similar) and, if so, default to using the builtins unless the__INTEL_SYCL_USE_INTEGRATION_HEADERS
macro is defined. - Modify the dpcpp/icx drivers to predefine
__INTEL_SYCL_USE_INTEGRATION_HEADERS
until we are ready to change the default behavior for SYCL aware host compilers. Continue to predefine the macro for SYCL unaware third party host compilers indefinitely. For testing, we can undefine the macro on the command line. - Allow the user to manually define the macro on the command line as a workaround for any backward compatibility issues that arise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some minor comments and suggestions. The new updates look good to me.
I might have more comments to add depending on whether we can figure out how to get the BoolFOption
approach to work with the new option definition.
LANGOPT(SYCLUseIntegrationHeaders, 1, 1, "Use integration headers for " | ||
"communication between device and host compilation phases") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine. Here is another suggestion; use which ever one you prefer.
LANGOPT(SYCLUseIntegrationHeaders, 1, 1, "Use integration headers for " | |
"communication between device and host compilation phases") | |
LANGOPT(SYCLUseIntegrationHeaders, 1, 1, "Use integration headers for " | |
"coordination of device and host compilation phases") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to leave the old wording in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to use BoolFOption
for the option definition looks great. Requesting changes to deal with the default use-integration-header behavior being specified in multiple locations. I added a couple of other minor comments as well.
" that integration headers be used for " | ||
"communication between the host and the device compilations. SYCL Only">>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For pedantic consistency, I suggest:
" that integration headers be used for " | |
"communication between the host and the device compilations. SYCL Only">>; | |
" that integration headers be used for" | |
" communication between the host and the device compilations. SYCL Only">>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
clang/lib/Driver/Driver.cpp
Outdated
// -fno-sycl-use-integration-headers cannot be used with | ||
// -fsycl-host-compiler. | ||
if (SYCLHostCompiler && SYCLUIHArg->getOption().matches( | ||
options::OPT_fno_sycl_use_integration_headers)) | ||
Diag(clang::diag::err_drv_option_conflict) | ||
<< SYCLHostCompiler->getSpelling().split('=').first | ||
<< "-fno-sycl-use-integration-headers"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of getLastArg()
above is good since it ensures that the err_drv_sycl_opt_requires_opt
diagnostic is only issued when one of the options is explicitly used. I think we can simplify the check for conflict with the host compiler option a bit though and, while we're add it, perhaps future proof the code a bit against a change of default behavior. I suggest colocating the following with the declarations of HasSYCL
and HasValidSYCLRuntime
:
bool UseSYCLIntegrationHeaders =
Args.hasFlag(options::OPT_fsycl_use_integration_headers,
options::OPT_fno_sycl_use_integration_headers,
true);
Then, break this diagnostic out of the enclosing if
statement:
// -fno-sycl-use-integration-headers cannot be used with | |
// -fsycl-host-compiler. | |
if (SYCLHostCompiler && SYCLUIHArg->getOption().matches( | |
options::OPT_fno_sycl_use_integration_headers)) | |
Diag(clang::diag::err_drv_option_conflict) | |
<< SYCLHostCompiler->getSpelling().split('=').first | |
<< "-fno-sycl-use-integration-headers"; | |
} | |
} | |
// -fno-sycl-use-integration-headers cannot be used with | |
// -fsycl-host-compiler. | |
if (SYCLHostCompiler && !UseSYCLIntegrationHeaders) { | |
Diag(clang::diag::err_drv_option_conflict) | |
<< SYCLHostCompiler->getSpelling().split('=').first | |
<< "-fno-sycl-use-integration-headers"; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
if (!Args.hasFlag(options::OPT_fsycl_use_integration_headers, | ||
options::OPT_fno_sycl_use_integration_headers, | ||
true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value of true
is passed in multiple places (here, in Driver::BuildActions()
, in Clang::ConstructHostCompilerJob()
, in Clang::ConstructJob()
, and in the suggested change I offered in a previous comment). Perhaps we should define the default in one place somewhere. There are a few different approaches. I don't have a strong opinion on any of these, but I think we should do something.
- We could introduce a constant that is passed in each of the calls to
hasFlag()
. - We could introduce a function to be called at each of these locations to ascertain whether integration headers are being used; that function would query the options and supply the default.
- We could check the options in one place and store that result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with option 2. Thanks @tahonermann
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! It looks like this particular location didn't get updated to use it though.
Add option -fsycl-use-builtins-for-integration to enable integration between device and host compilation phases without using integration headers and footers. The option is passed through to the cc1 phase along with a macro __INTEL_SYCL_USE_BUILTINS_FOR_INTEGRATION.
5e652c4
to
fa6ae5d
Compare
And apologies; there were merge conflicts and I had to do a force push after resolving them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good. I think I spotted a couple of minor issues.
defm sycl_use_integration_headers : BoolFOption<"sycl-use-integration-headers", | ||
LangOpts<"SYCLUseIntegrationHeaders">, DefaultTrue, | ||
PosFlag<SetTrue, [], [ClangOption, CLOption], "Specify">, | ||
NegFlag<SetFalse, [], [ClangOption, CLOption], "Do not specify">, | ||
BothFlags<[HelpHidden], [ClangOption, CLOption, CC1Option], | ||
" that integration headers be used for communication" | ||
" between the host and the device compilations. SYCL Only">>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation with respect to surrounding code.
defm sycl_use_integration_headers : BoolFOption<"sycl-use-integration-headers", | |
LangOpts<"SYCLUseIntegrationHeaders">, DefaultTrue, | |
PosFlag<SetTrue, [], [ClangOption, CLOption], "Specify">, | |
NegFlag<SetFalse, [], [ClangOption, CLOption], "Do not specify">, | |
BothFlags<[HelpHidden], [ClangOption, CLOption, CC1Option], | |
" that integration headers be used for communication" | |
" between the host and the device compilations. SYCL Only">>; | |
defm sycl_use_integration_headers : BoolFOption<"sycl-use-integration-headers", | |
LangOpts<"SYCLUseIntegrationHeaders">, DefaultTrue, | |
PosFlag<SetTrue, [], [ClangOption, CLOption], "Specify">, | |
NegFlag<SetFalse, [], [ClangOption, CLOption], "Do not specify">, | |
BothFlags<[HelpHidden], [ClangOption, CLOption, CC1Option], | |
" that integration headers be used for communication" | |
" between the host and the device compilations. SYCL Only">>; |
if (SYCLUIHArg) { | ||
// -f[no-]sycl-use-integration-headers cannot be used without | ||
// -fsycl. (-fintelfpga implies -fsycl). | ||
if (!HasSYCL && !SYCLfpga) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason not to include the test of SYCLfpga
in the initialization of HasSYCL
above? As is, it looks like HasValidSYCLRuntime
will be initialized to false
if -fintelfpga
is passed (but -fsycl
is not).
if (!Args.hasFlag(options::OPT_fsycl_use_integration_headers, | ||
options::OPT_fno_sycl_use_integration_headers, | ||
true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! It looks like this particular location didn't get updated to use it though.
// If -fno-sycl-use-integration-headers is speficified, don't generate | ||
// integration headers and footers. | ||
if (!Args.hasFlag(options::OPT_fsycl_use_integration_headers, | ||
options::OPT_fno_sycl_use_integration_headers, true)) | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// If -fno-sycl-use-integration-headers is speficified, don't generate | |
// integration headers and footers. | |
if (!Args.hasFlag(options::OPT_fsycl_use_integration_headers, | |
options::OPT_fno_sycl_use_integration_headers, true)) | |
continue; | |
// If -fno-sycl-use-integration-headers is speficified, don't generate | |
// integration headers and footers. | |
if (!getSYCLUseIntegrationHeaders(Args)) | |
continue; |
@tahonermann, when you have time, could you please review this again? |
@premanandrao, it looks like the latest changes are still what I reviewed 5 days ago :) |
Add option -fsycl-use-integration-headers to enable integration between device and host compilation phases using integration headers and footers. This is currently the default behavior.
The option is passed through to the cc1 phase along with a macro __INTEL_SYCL_USE_INTEGRATION_HEADERS.