-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL][NFCI] Use DeviceConfigFile instead of sycl_aspects metadata #13194
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
// expected-error@+1{{redefinition of aspect enum}} | ||
enum class [[__sycl_detail__::sycl_type(aspect)]] aspect_redef { | ||
imposter_value = 3 | ||
}; |
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.
What happens for this testcase after your changes?
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.
No error or note will be emitted, I removed the code that would do so otherwise
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 it not possible for the user to redefine the aspect enum anymore? I understand that you have removed the diagnostic for it, but is it safe to do so?
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.
From my understanding, yes, it is safe to remove this diagnostic, as it is not relevant anymore.
The only purpose that I found of the [[__sycl_detail__::sycl_type(aspect)]]
attribute was to communicate what declaration is the aspect enum declartion (stored in AspectsEnumDecl
member), which then uses that to add the sycl_aspects
metadata listing the aspect names and values. But since this information is now provided by the device config file and I've removed all AspectsEnumDecl
, having two enum declarations with [[__sycl_detail__::sycl_type(aspect)]]
attached to them doesn't do anything, so therefore, it is safe to remove the diagnostic.
To clarify this point for others: in #12727 we need to compare values listed in device config file (strings representing aspects) with aspects metadata attached to kernels (integers that come from Whilst this PR does simplify our implementation by removing special handling of this Even though there is a test case suggested that ensures that we config file contents matches the SYCL headers to prevent hard to debug errors, it is impossible to use the same compiler with a different SYCL headers without updating the One of the main ideas of the existing approach is that we have a generic infrastructure in the compiler, which would work with different implementations in headers by providing an interface in form of Tagging @tahonermann here for awareness, because it impacts our upstreaming effort. Perhaps what we want is to encode strings right away into metadata we generate from |
@AlexeySachkov Thanks for the context, that makes sense. If we decide not to go through with this change, then in terms of follow up for #12727, directly emitting string attributes make sense. Perhaps a simpler solution is instead of |
From what I remember (@asudarsa can correct me if I am misremembering) we needed the cleanup pass because the linker would append the aspect lists, which could cause the aspect lists to be extremely long, despite it being filled with only a handful unique values. Since we didn't previously need them at- or after linking, cleanup pre-linking seemed like a good solution. Reducing the aspects to only those used might help, but we don't avoid the lists growing during linking. Maybe there is a better solution to prevent the aspects lists growing in linking? Can we change the representation of this list in a way that the lists don't get merged? |
@@ -36,8 +36,8 @@ PreservedAnalyses CleanupSYCLMetadataPass::run(Module &M, | |||
// Remove SYCL module-level metadata that will never be used again to avoid | |||
// duplication of their operands during llvm-link hence preventing | |||
// increase of the module size | |||
llvm::SmallVector<llvm::StringRef, 2> ModuleMDToRemove = { | |||
"sycl_aspects", "sycl_types_that_use_aspects"}; | |||
llvm::SmallVector<llvm::StringRef, 1> ModuleMDToRemove = { |
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.
Do we expect this to grow? Otherwise, we can drop the SmallVector and the loop. Just a nit. Thanks
Hi @jzc Looks like a good change. I had a couple of high level questions:
Thanks |
That is true, although my intention was that all the users of the metadata in the code were removed, so there should be no functional changes. I can remove it though if that would not be considered a NFC.
This is possible, but not all the duplication will be removed during compilation - e.g. the linked device code before |
The
sycl_aspects
metadata kept track of the aspect names and their enum values as defined by sycl/include/sycl/info/aspects.def. This metadata was populated by the frontend by looking for the declaration of the SYCL aspects enum. TheCleanupSYCLMetadata
pass then deletes this metadata after device compilation.llvm/clang/lib/CodeGen/BackendUtil.cpp
Lines 1156 to 1158 in f6e73e8
However, some processing in
sycl-post-link
that will be added in #12727 needs thesycl_aspects
metadata (which at that point, the metadata is already deleted byCleanupSYCLMetadata
). To fix this, in this PR, the aspect enum values were added toDeviceConfigFile.td
. By adding this, this makes other uses of thesycl_aspects
data redundant, so the places wheresycl_aspects
were needed were replace by uses of the device config file. (essentially justSYCLPropagateAspectsUsage.cpp
.)Since the aspect values in the device config file are duplicated from
aspects.def
, a test was added indevice_config_file_aspects.cpp
to ensure that these values stay in sync withaspects.def
. Additionally, some other tests had to be updated due to thesycl_aspects
metadata no longer being present.