-
Notifications
You must be signed in to change notification settings - Fork 789
[SYCL][RTC] Clarify and test handling of include paths #17307
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
Conversation
Signed-off-by: Julian Oppermann <[email protected]>
Signed-off-by: Julian Oppermann <[email protected]>
Signed-off-by: Julian Oppermann <[email protected]>
Signed-off-by: Julian Oppermann <[email protected]>
Signed-off-by: Julian Oppermann <[email protected]>
Signed-off-by: Julian Oppermann <[email protected]>
Signed-off-by: Julian Oppermann <[email protected]>
Signed-off-by: Julian Oppermann <[email protected]>
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
is useful, for example, to compile kernels using external libraries. The | ||
following spellings are supported (note that the path is a separate element in | ||
the `build_options` list for the second and fourth form): | ||
|
||
[source,c++] | ||
---- | ||
build_options{{ | ||
{"-Ipath"}, | ||
{"-I"}, {"path"}, | ||
{"--include-directory=path"}, | ||
{"--include-directory"}, {"path"} | ||
}} | ||
---- |
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.
Nit: I'd prefer it if we actually documented each of these flags separately, but I'm not sure we have precedent for how to do that. I don't want this comment to block this PR, but I'm leaving a note for @gmlueck to review upon his return.
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.
FWIW, these are standard compiler flags for Clang and GCC, not specific to RTC, so users are potentially already familiar with 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.
That's a good point. I agree that most people reading the specification will be able to figure this out, and that's another reason not to let my comment completely block this PR.
But, the specification for build_options
currently says:
The
source_language::sycl
language does not define any standard build options, but an implementation may support implementation-defined options.
Because the current description of these include options is so vague, it's not clear to me whether there are intended to be supported by all implementations of this extension (in which case, the description of build_options
is wrong), or whether they are intended to be specific to DPC++.
The only situation I'd feel comfortable leaving things with a vague description would be if the specification said something like "In DPC++, any additional build_options
behave as if passed to DPC++", in which case we'd inherit the definitions of -I
etc from there. But I don't know if that's the current behavior.
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 agree, the documentation of the build_options
still needs some attention in this document.
"In DPC++, any additional
build_options
behave as if passed to DPC++"
This is true for many options, but there are definitely some we cannot support right now (e.g. everything related to AoT compilation).
I plan to add a list of supported options before the release, in form of a DPC++-specific, non-normative section* towards the end of the document. This would of course include the -I
option, so we could move the examples for using it to that section, and/or reference the DPC++ docs. Makes sense to me that the specification part would then only state that implementation-specific options can be added to build_options
to include additional paths, and point the reader to the non-normative section.
*) Greg suggested (or at least approved of) having such a section.
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.
Okay, thanks for explaining that. I think if the intent is that -I
is not guaranteed to be supported by all compilers, we should create the DPC++-specific non-normative section now, and just put the -I
flags in it.
It's much easier to take something that's DPC++-specific and make it available to all implementations than to do the opposite. And you can still add the documentation for the other flags later.
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.
[...] we should create the DPC++-specific non-normative section now, and just put the
-I
flags in it.
Makes sense, done! @Pennycook can you have another look, please?
sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Outdated
Show resolved
Hide resolved
is useful, for example, to compile kernels using external libraries. The | ||
following spellings are supported (note that the path is a separate element in | ||
the `build_options` list for the second and fourth form): | ||
|
||
[source,c++] | ||
---- | ||
build_options{{ | ||
{"-Ipath"}, | ||
{"-I"}, {"path"}, | ||
{"--include-directory=path"}, | ||
{"--include-directory"}, {"path"} | ||
}} | ||
---- |
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.
FWIW, these are standard compiler flags for Clang and GCC, not specific to RTC, so users are potentially already familiar with them.
sycl/include/sycl/kernel_bundle.hpp
Outdated
if (std::find_if(record.begin(), record.end(), [&name](auto &p) { | ||
return p.first == name; | ||
}) != record.end()) { | ||
throw sycl::exception(make_error_code(errc::invalid), | ||
"Include file '" + name + | ||
"' is already registered"); | ||
} |
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.
Does the specification promise this exception to be thrown?
It seems like potential overhead to go through the existing list over and over again.
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.
Yes:
llvm/sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Lines 381 to 382 in b02a2c1
* An `exception` with the `errc::invalid` error code if there is already an | |
entry with `name` in this property. |
Not sure if we are expecting apps to register many virtual header files. For registered_kernel_names
, the semantics are more relaxed:
llvm/sycl/doc/extensions/experimental/sycl_ext_oneapi_kernel_compiler.asciidoc
Lines 522 to 523 in b02a2c1
[_Note:_ It is not an error to have duplicate names in a `registered_names` | |
property, but the duplicates have no effect. |
Maybe we should adopt that. WDYT?
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.
Could we potentially use a different data structure, e.g., map, to make the lookup more efficient and avoid the quadratic complexity?
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.
Yes, the order of the virtual include files should be insignificant. In 0ad484d I switched the container to an unordered_map
. Unfortunately this causes the rather large change to the sycl_classes_abi_neutral_test.cpp
test.
…er.asciidoc Co-authored-by: John Pennycook <[email protected]>
…er.asciidoc Co-authored-by: John Pennycook <[email protected]>
Signed-off-by: Julian Oppermann <[email protected]>
AFAICT this is not an ABI break. The entrypoint into llvm/sycl/include/sycl/kernel_bundle.hpp Lines 1027 to 1032 in a412c12
which is unaffected by the changes to include_files .
|
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.
sycl/test/abi/sycl_classes_abi_neutral_test.cpp
ensures that SYCL classes do not containstd::basic_string
andstd::list
members.include_files
was already listed as an exclusion in the test, however, a map's internal layout is more complicated than a vector, requiring moreCHECK
lines to match all occurences ofstd::basic_string
.
Thanks for explanation, that makes sense.
Implementation LGTM.
Signed-off-by: Julian Oppermann <[email protected]>
Signed-off-by: Julian Oppermann <[email protected]>
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.
Latest extension specification LGTM.
Signed-off-by: Julian Oppermann <[email protected]>
@intel/llvm-gatekeepers Can you merge this, please? I'd argue we don't need to wait for the AMD runner. The AMD workflow was successful for 5fbd5b0, and I just bumped the counter in a SYCL lit test for the pending commit. |
Partially revert #17307: change the container in the `include_files` property back to vector of pairs, as the more complex internal structure of a map made it very fragile to test in `sycl_classes_abi_neutral_test.cpp`. --------- Signed-off-by: Julian Oppermann <[email protected]>
Multiple changes related to the handling of
#include
's in RTC:-I
inbuild_options
" to the locations that extension will look for header files, and clarifiy search order, in the specification. This change is meant to establish clang's usual include behavior.include_files::add
to match specificationadd
method toinclude_files
andbuild_properties
to match specification