This op is the counterpart to LLVM's atomicrmw instruction. Note that
volatile and syncscope attributes are not yet supported.
This will be useful for upcoming parallel versions of affine.for and generally
for reduction-like semantics.
Differential D72741
[MLIR] LLVM dialect: Add llvm.atomicrmw flaub on Jan 14 2020, 3:49 PM. Authored by
Details This op is the counterpart to LLVM's atomicrmw instruction. Note that This will be useful for upcoming parallel versions of affine.for and generally
Diff Detail
Event Timeline
Comment Actions Unit tests: pass. 61744 tests passed, 0 failed and 780 were skipped. clang-tidy: unknown. clang-format: pass. Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml
Comment Actions Thanks! Most of my comments are minor. Please also add a translation test to test/Target/llvmir.mlir.
Comment Actions Thanks for the review :) I'll try to follow up tomorrow and also look at writing a translation test (I wasn't aware of it, thanks for the heads up).
Comment Actions Unit tests: pass. 61744 tests passed, 0 failed and 780 were skipped. clang-tidy: unknown. clang-format: pass. Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml Comment Actions From a cursory glance this looks good, I'd use the capital name for enums that conflict with C/C++ keywords. I'm also very +1 on mirroring LLVM and staying in sync with https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/Support/AtomicOrdering.h#L81. But it seems this would be a good topic to bring to the LLVM community as a whole and then MLIR can just follow?
Comment Actions Unit tests: pass. 61744 tests passed, 0 failed and 780 were skipped. clang-tidy: unknown. clang-format: pass. Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml Comment Actions @ftynse I believe this is ready to go, anything else you'd like? Also, I don't yet have committer access, so I'll need some help getting it landed. Comment Actions Please resolve the question I asked, either here or with a follow-up plan. @mehdi_amini's suggestion was good. Comment Actions I don't think this commit should be about making changes to LLVM IR. I can do that in a followup, but this commit should be in sync with whatever LLVM IR is today. There seems to be consensus with this approach. Comment Actions @jfb What process do I need to follow to ensure that any changes I make to LLVM IR doesn't break the world? This would include updates to the documentation. I'm new here and I'm not sure which tests I should focus on and where the docs live. Comment Actions Agreed this shouldn't make changes to LLVM IR. However, I'd like to understand whether:
You're making a new IR, and that's exactly the right time to revisit basic things like this instead of copying LLVM IR. This is so minor, I'm baffled by the pushback. You don't have consensus as evidenced by this discussion, and unwillingness to engage in such a basic question is super worrying. Please don't copy LLVM IR and instead understand why it's designed in a certain manner and what mistakes (however minor) it might contain. I'm not blocking this patch indefinitely, I'm asking you to answer these questions before proceeding. That should take a few minutes. Comment Actions Changing LLVM IR should _not_ be in this commit, it's semantically different and requires separate discussion with relevant people involved. I also don't see a compelling reason to block this from landing until LLVM IR changes (or decides not to). LLVM dialect models LLVM IR in its current state, whatever the state is. Comment Actions I'm happy to do whatever the community wants to do. I was under the impression from @ftynse that we shouldn't be changing the MLIR IR, that it should match exactly whatever the LLVM IR is. It's unclear to me what the ramifications of making such a change in LLVM IR are, so I don't feel qualified at this time to make such a change. But, I could certainly take some guidance on this. (this is where my pushback is coming from, sorry if this came off the wrong way). Comment Actions To clarify further, LLVM dialect in MLIR is not a new IR, it's essentially a representation of LLVM IR using MLIR. It's supposed to minimize the cost of translation from MLIR to LLVM IR. While it does diverge from LLVM IR proper, it does so for modeling reasons: there's no first-class constants in MLIR, neither are there phi nodes. Changing the name of an enumerand locally to the LLVM dialect will increase the cost of translation, which goes against the goal of this dialect. That being said, I do agree that we should use this opportunity to reflect on LLVM IR design and update it following the proper process. Comment Actions I wasn't intending to block this revision, I am aligned with @ftynse and @nicolasvasilache that the LLVM dialect in MLIR is intended to mirror as close as possible LLVM IR and so aligning the naming makes sense to me. I am very supportive to take the opportunity of revisions like the current one to surface issues with LLVM and work towards fixing them, I don't think we need to block the progress on the work on completing the MLIR<->LLVM mapping though. Comment Actions Maybe what is causing confusion is that we also have the MLIR standard dialect, which is more of a new IR itself. We are actually quite careful about things going in the standard dialect and it isn't bound by LLVM IR (other that we try to think about how to map down to LLVM). Another way to put it is that the LLVM Dialect is only a layer intended to be hiding the LLVM IR Builders: while in MLIR you lower down to the LLVM Dialect instead of emitting directly LLVM IR. The reason is that this composes better (you can lower progressively to LLVM and not as a one shot conversion). So the LLVM dialect "embeds" the LLVM IR inside MLIR. Comment Actions @flaub and I talked over Discord, and I think we're on the same page! Thanks Mehdi as well. Let's move this forward, and have the naming discussion separately. Comment Actions Sorry about the noise. Should be fixed now. I didn't realize that 'blocking reviewer' was the default action on herald rules. |
This is unfortunate that this is conflicting with C++ keywords. I differentiated between enum case names (capitalized and thus non-conflicting) and the printed syntax for linkage attributes. That required boilerplate switches in parsing and printing though. I'm fine with these names, but we should consider a general solution for this problem eventually.