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

Data-Oblivious scf.if Transformation #737

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MeronZerihun
Copy link

@MeronZerihun MeronZerihun commented Jun 14, 2024

Draft of an implementation for a pass that hoists instructions out of an scf.if operation and finally substitutes it with a select-operation.

@AlexanderViand-Intel AlexanderViand-Intel changed the title Naive If-transformation Data-Oblivious If-transformation Jun 14, 2024
@AlexanderViand-Intel AlexanderViand-Intel changed the title Data-Oblivious If-transformation Data-Oblivious 'scf.if' Transformation Jun 14, 2024
@AlexanderViand-Intel AlexanderViand-Intel changed the title Data-Oblivious 'scf.if' Transformation Data-Oblivious scf.if Transformation Jun 14, 2024
@AlexanderViand-Intel AlexanderViand-Intel marked this pull request as ready for review June 17, 2024 17:41
@AlexanderViand-Intel AlexanderViand-Intel marked this pull request as draft June 17, 2024 17:42
Copy link
Collaborator

@AlexanderViand-Intel AlexanderViand-Intel left a comment

Choose a reason for hiding this comment

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

👍 Let's work on getting the tests rewritten to FileCheck today and then we can focus on the required data analyses next :)

lib/Transforms/IfTransform/run.sh Outdated Show resolved Hide resolved
@MeronZerihun MeronZerihun force-pushed the if-dev branch 3 times, most recently from 3888fbf to fe43d87 Compare June 25, 2024 14:48
AlexanderViand-Intel

This comment was marked as duplicate.

Copy link
Collaborator

@AlexanderViand-Intel AlexanderViand-Intel left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together! Despite my many (mostly nit-picky) comments, I think this actually looks great, especially the IfToSelectConversion Pattern is significantly more elegant/simple than I would have initially expected possible!

@j2kun
Copy link
Collaborator

j2kun commented Jun 27, 2024

In lieu of a proper greeting during the meeting this morning, Hello @MeronZerihun! It's great to have you in our merry band of cryptographers. This PR looks very well done and thorough so far, and I'll give it a second pass after you address Alex's review comments.

A dataflow analysis is the right approach, but in the interim you can get away with something as simple as this, which checks if the condition to the if is a direct operand of the secret.generic op containing the if:

if (auto genericOp = ifOp.getParentOfType<secret::GenericOp>()) {
  if (OpOperand operand = genericOp.getOpOperandForBlockArgument(condition)) {
    // it's an OpOperand to the containing secret.generic
    if (isa<secret::SecretType>(operand.get().getType())) {
      // it's a secret!
    }
  }
}

@MeronZerihun MeronZerihun force-pushed the if-dev branch 2 times, most recently from 79af940 to 0d0a24d Compare June 28, 2024 16:29
@AlexanderViand-Intel AlexanderViand-Intel marked this pull request as ready for review June 28, 2024 16:43
Copy link
Collaborator

@j2kun j2kun left a comment

Choose a reason for hiding this comment

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

LGTM! One optional change suggested, then let's get it merged.

tests/convert_if_to_select/expected_outputs.mlir Outdated Show resolved Hide resolved
Copy link
Collaborator

@AlexanderViand-Intel AlexanderViand-Intel left a comment

Choose a reason for hiding this comment

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

LGTM, too, just some minor cleanup around the tests and then we should be able to get this merged👍

@AlexanderViand-Intel
Copy link
Collaborator

image
@j2kun / @asraa Any idea why the other actions aren't showing up after the last push?

@j2kun
Copy link
Collaborator

j2kun commented Jun 28, 2024

That is bizarre... maybe GitHub had a brain fart. Try force-pushing again with a trivial change?

@j2kun j2kun added the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label Jun 28, 2024
Basic pass that converts all scf.if operations to arith.select operations.
@asraa
Copy link
Collaborator

asraa commented Jul 2, 2024

Hey! @MeronZerihun super big apologies, but could you rebase cd909c8 on top of main? (Sorry for attempting to resolve the commit with my last merge commit, I had a mental fart too and realized we needed to squash commits)

@AlexanderViand-Intel
Copy link
Collaborator

Oh, wow, this PR is really hitting all the CI issues xD Now we've got a Google internal checks FAILED?
@asraa Is it something we need to fix on our side, or something you can fix internally?

@j2kun
Copy link
Collaborator

j2kun commented Jul 2, 2024 via email

@asraa
Copy link
Collaborator

asraa commented Jul 2, 2024

Oh, wow, this PR is really hitting all the CI issues xD Now we've got a Google internal checks FAILED?

Ah yes, all good now! I can now take it from here to fix up the build issues and merge :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants