-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Target][TOPI] Use LLVM for x86 CPU feature lookup #15685
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.
Looks good. Thanks!
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 an awesome feature I've been thinking of Thanks for the patch!
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.
LGTM! Thank you for your contribution. It is very useful!
The CI fails because the LLVM version on CI is pretty low (==10). I'm curious if there's any variant of this API on LLVM 10? If not, we should bump LLVM to 15 or 16 |
Folks, Yes, I am aware of this I am strongly opting for a backward compatibility for this case. The API fracture, at a first glance:
Allow a little time (1-2 day) to investigate a way going down |
Details of investigation: Post
Implementation here is slim, infos coming from LLVM are precise and maintained. Prior
There is a burden of @junrushao , @kparzysz-quic, @echuraev There are quite some changes now, please help re-reviewing them. Thanks. |
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.
Hello @cbalint13! Thank you for big work and good improvement and unification of target check. For me it looks like that "avx512bw" is not the best name to split usual avx512 (e.g. for skylake) and avx512 with VNNI (e.g. for cascadelake), may be return "avx512", I do not see places where it uses in other context
Good question regarding Please help me with a double check on these statements below:
There are also other avx512 subsets, but none holding instructions for our topi/tir intrinsics, on their names here:
UPDATE: a much clear view on what Some arches investigated here:
BTW, "alderlake" here, is the only "strangeness" having
I put Cc @Qianshui-Jiang (author of #13642) he might help us with a second opinion in this too. |
Hello @cbalint13! Very hard work! One note I should say TVM needs three avx512 intrinsics: vpmaddwd, vpmaddubsw and vpaddd. For the latter "+" is used but it is automatically replaced by intrinsics by llvm, and it is in avx512f set (I checked it here). |
See now, very good point ! Let's ask for booth, will change with these comments:
Just as side note (curiosity) on this topic:
Anyway, let's go now with |
Hello @elvin-n! May be second opinion from your to double check |
One more informal experiment:
So once again lets enforce |
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.
LGTM
@cbalint13 @vvchernov big thanks for your hard work and dicussion! Here is few comments. And start from Now when we move to Yes ur right, I support to let TVM use features names to decide the schedule method, seems much clear than using arch name. |
Thank you much for your time & clarifications ! |
To sum it up:
There is a comprehensive test unit that also checks the old behaviour (by incorporating the old static lookup table). This is the final state, passing the CI, until explicit review-requests. |
I am very excited about this feature and cannot wait to try it out myself! Thank you @cbalint13 for this super well-documented and well-tested PR, and it's going to be super useful for downstream applications! |
Was just a simple idea of utility, crediting the work already done before: @vvchernov , @Qianshui-Jiang and @elvin-n (the original lookup). Thanks folks ! |
Hi folks,
This PR leverage LLVM itself for CPU features lookup, replacing hard-coded lists.
In order to keep maintainability with X86 families & features we can rely on LLVM.
Changes:
target_has_feature(XXX)
replacing alltarget_has_XXX()
llvm_x86_get_archlist
,llvm_x86_get_features
&llvm_x86_has_feature
target_has_feature
wrapper to_ffi.llvm_x86_has_feature
There is a test unit for a comprehensive check with the old behaviour.
For better reliability, this way of feature checking can be implemented for other arches.
Thanks,
~Cristian.
Cc: @elvin-n , @vvchernov , @echuraev , @vinx13 , @jcf94 , @masahi