-
Notifications
You must be signed in to change notification settings - Fork 72
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
Implements CVectorExtensionsTarget #557
base: main
Are you sure you want to change the base?
Conversation
test/test_target.py
Outdated
knl = lp.make_kernel( | ||
"{[i, j1, j2, j3]: 0<=i<10 and 0<=j1,j2,j3<4}", | ||
""" | ||
<> temp1[j1] = x[i, j1] | ||
<> temp2[j2] = 2*temp1[j2] + 1 {inames=i:j2} | ||
y[i, j3] = temp2[j3] | ||
""", | ||
[lp.GlobalArg("x, y", shape=lp.auto, dtype=float)], | ||
seq_dependencies=True, | ||
target=lp.CVectorExtensionsTarget(), | ||
lang_version=(2018, 2)) | ||
|
||
knl = lp.tag_inames(knl, {"j1": lp.VectorizeTag(lp.OpenMPSIMDTag()), | ||
"j2": lp.VectorizeTag(lp.OpenMPSIMDTag()), | ||
"j3": lp.VectorizeTag(lp.OpenMPSIMDTag())}) |
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.
@inducer: Any big red signals with the user-facing interface of specifying fallbacks?
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 OpenMPSIMDTag
shoudl be renamed to something more generic, and then this fallback could be automatic.
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.
Yep, this has been restructured.
5ac2e2e
to
3d3c1de
Compare
This is ready for a look, for a better reviewing experience please see the patch on a commit-by-commit basis. |
ad2372f
to
5b0f9c2
Compare
There are two things which we definitely still need before we are able to fully automate this into the Firedrake/PyOP2 code.
--> Fix in PR
An example of a test where we run into that is tests/slate/test_slate_infrastructure.py::test_arguments[dg1-mesh0] --> Fix in PR
--> This was a bug on our side. Fixed in PyOP2
It looks like the iname for |
So I had a look at the code. I think I can fix the first issue by adding a
(and potentially other supported math functions) and throw a |
This looks like a bug in loopy's vectorization implementation, with reductions in them.
I think falling back to omp-simd might make more sense. Looks like that's already being done here: Lines 91 to 97 in dd1ad18
|
b1982b8
to
6ea1c80
Compare
6ea1c80
to
8713fc3
Compare
56ab5dc
to
6ffe97a
Compare
6ffe97a
to
fa1d552
Compare
42390e3
to
fd4ae30
Compare
688aa94
to
4c0c013
Compare
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.
Some initial thoughts from a quick scroll.
assert isinstance(inner, CodeGenerationResult) | ||
if isinstance(inner.current_ast(novec_self), | ||
astb.ast_comment_class): | ||
# loop body is a comment => do not emit the loop |
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 puzzling. Could you explain what leads to this?
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.
A noop instruction is emitted as a comment.
loopy/codegen/control.py
Outdated
elif filter_iname_tags_by_type(tags, OpenMPSIMDTag): | ||
func = generate_openmp_simd_loop |
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.
As written, I think this is very weird, as OpenMP is clearly target-specific. But the concept of a loop with no dependencies between iterations is universal. So maybe that's what the tag should reflect?
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.
Yep, agreed. Bleeding OpenMP-specific things into iname tags was an abstraction failure. Restructured to specify the fallback via target attributes.
loopy/check.py
Outdated
# do not check for vec-inames as their implementation is accompanied | ||
# with a fallback machinery | ||
par_inames = {iname for iname in dom_inames | ||
if (kernel.iname_tags_of_type(iname, ConcurrentTag) | ||
and not kernel.iname_tags_of_type(iname, VectorizeTag))} |
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.
Explain that the fallback is "don't vectorize".
test/test_target.py
Outdated
knl = lp.make_kernel( | ||
"{[i, j1, j2, j3]: 0<=i<10 and 0<=j1,j2,j3<4}", | ||
""" | ||
<> temp1[j1] = x[i, j1] | ||
<> temp2[j2] = 2*temp1[j2] + 1 {inames=i:j2} | ||
y[i, j3] = temp2[j3] | ||
""", | ||
[lp.GlobalArg("x, y", shape=lp.auto, dtype=float)], | ||
seq_dependencies=True, | ||
target=lp.CVectorExtensionsTarget(), | ||
lang_version=(2018, 2)) | ||
|
||
knl = lp.tag_inames(knl, {"j1": lp.VectorizeTag(lp.OpenMPSIMDTag()), | ||
"j2": lp.VectorizeTag(lp.OpenMPSIMDTag()), | ||
"j3": lp.VectorizeTag(lp.OpenMPSIMDTag())}) |
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 OpenMPSIMDTag
shoudl be renamed to something more generic, and then this fallback could be automatic.
From the Firedrake side this looks like its good to go. Thanks for all your work on it Kaushik! |
3bdd997
to
57e2440
Compare
57e2440
to
47eb2d5
Compare
Some tests in the actions for the automatic vectorisation of Firedrake are currently failing due to the issue I reported in #648 |
47eb2d5
to
b132997
Compare
Co-authored-by: Sophia Vorderwuelbecke <[email protected]>
b132997
to
df179b5
Compare
Hi! I have tested the updated branch together with the updated version of Firedrake and PyOP2 and both CIs are passing. The PRs in both components were already approved and I am not around for long anymore. It would be awesome if you could merge this into Loo.py, so that we can merge it on our side and make vectorisation available to all of our users. |
/cc @sv2518
Adds support for GNU vector extensions.
TODO:
OMPSimdInameTag
.loopy.codegen.expression
infer the fallback mechanisms from the target.kernel.arguments
in non-executable targets' lowered code #650