Skip to content
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

intrinsics: add support for X86 vector intrinsics #1117

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

artagnon
Copy link
Contributor

This work was originally authored by Zhengyang Liu [email protected], and was motivated by the development of the Minotaur project [https://arxiv.org/abs/2306.00229]. This is a draft, asking the maintainers of Alive2 if there is interest in having this work be part of Alive2 upstream: if so, some work is required to clean up the patch, and break it up into digestible bits. I've fixed up Minotaur, and checked that all tests pass, when it is based on this work. The motivation to try and upstream this is so that we can get more eyes on this code to iron out the bugs: I plan to build upon this work to also support RISC-V vectors; my employer is very supportive of the project.

CC: @regehr

This work was originally authored by Zhengyang Liu <[email protected]>,
and was motivated by the development of the Minotaur project
[https://arxiv.org/abs/2306.00229].
@regehr
Copy link
Contributor

regehr commented Nov 27, 2024

a few comments about this, in no particular order.

  • we've done some focused randomized testing of these semantics, and also used them as part of Minotaur optimizing plenty of real applications, without seeing breakage. so we're decently confident in them, but of course there could still be bugs
  • there's some maintenance burden here. I'm not sure if we can count on Zhengyang to help much, he's pretty busy lately. obviously the top-level decision about this rests on Nuno since he's the primary Alive2 developer and maintainer
  • previously, when adding code to Alive2 that Nuno was not interested in maintaining, I've tried to make it as easily removable as possible, and then basically told Nuno that I would commit to either maintaining it or removing it. if we decide to proceed with this patch, I would suggest that we do something similar (but it's @artagnon maintaining it, not me)

@regehr
Copy link
Contributor

regehr commented Nov 27, 2024

in particular, the approximation stuff requires some careful thought

@artagnon
Copy link
Contributor Author

I can't say that I'm familiar with X86 vector intrinsics, but it seems like a small additional burden over the RISC-V vector intrinsics, which I plan to add and maintain. The code is quite independent, and should be easy to strip out if it falls out of maintenance in the future. I will split out the parts that will also be useful for RISC-V vector intrinsics (FP approximation, FakeShuffle), so that the X86-specific parts can be reverted easily. An alternative is to maintain the X86 and RISC-V specific parts downstream, and just get the generic support merged: I'm quite open to this, as I don't think the mechanical intrinsic-matching code needs review.

Like John said, I do need the FP approximation part reviewed.

@nunoplopes
Copy link
Member

This would be great to have!
I suggest creating a new file in the ir directory (e.g., x86_intrinsics.cpp) and move the new code there to avoid making the instr.cpp file even longer.
Also, please revert some of the unrelated changes like formatting and etc. And pay attention to missing/extra newlines a bit all over.

I suggest we start with the intrinsics that have precise semantics. Then work over the approximations, as these require more thought.

@artagnon
Copy link
Contributor Author

artagnon commented Dec 3, 2024

I suggest we start with the intrinsics that have precise semantics. Then work over the approximations, as these require more thought.

I think you misunderstood: all the intrinsics have precise semantics, and the FP exactness is a configuration option that's not required for correctness of X86 intrinsics within Alive2: it is used by Minotaur to synthesize certain fp operations correctly.

Thanks for the suggestions; I've put up #1128 and #1129. With both applied, all tests in Minotaur pass. The rest of the code in this draft is unnecessary/dead.

@@ -19,6 +19,8 @@ using namespace smt;
using namespace util;
using namespace std;

bool useApprox = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option along with all its users is dead code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants