This is an archive of the discontinued LLVM Phabricator instance.

Add vp2intersect to AVX512 dialect.
ClosedPublic

Authored by springerm on Jan 23 2021, 7:32 PM.

Details

Summary

Adds vp2intersect to the AVX512 dialect and defines a lowering to the
LLVM dialect.

Author: Matthias Springer <springerm@google.com>

Diff Detail

Event Timeline

springerm created this revision.Jan 23 2021, 7:32 PM
springerm requested review of this revision.Jan 23 2021, 7:32 PM

Looks great, thanks @springerm !

Let's address the nits and land this, please lmk if you need help landing.
If you do need help landing, please also read https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access.

mlir/include/mlir/Dialect/AVX512/AVX512.td
106

In LLVM OSS we just write // TODO: stufff.

107

I wouldn't leave this as a TODO but more as a simple note.

mlir/include/mlir/Dialect/LLVMIR/LLVMAVX512.td
49

Note that this op and the one above are candidates to just disappearing and mlir-translate just converting the ops from AVX512/AVX512.td directly.
This requires machinery so don't worry about it for now.

However, note that this is not the case for the ops you just added as the struct result type does not exist in std.

mlir/test/Conversion/AVX512ToLLVM/convert-to-llvm.mlir
29

nit: missing newline

mlir/test/Dialect/AVX512/roundtrip.mlir
32

nit: missing newline

This revision is now accepted and ready to land.Jan 24 2021, 11:13 AM
ftynse added inline comments.Jan 25 2021, 2:47 AM
mlir/include/mlir/Dialect/AVX512/AVX512Dialect.h
19

We shouldn't be needing the OpImplementation header in another _header_, as its name indicates. LLVM in general prefers not to include headers in other headers unless strictly necessary to reduce compilation time.

mlir/include/mlir/Dialect/LLVMIR/LLVMAVX512.td
49

However, note that this is not the case for the ops you just added as the struct result type does not exist in std.

We can use multi-return ops and convert them to struct-return + extract-element...

56–57

Nit: We have a preference for op def names (which will end up being C++ class names) to match the mnemonic of the operation, it's easier to understand what in the code produces which IR this way. So epi64 -> q.

mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
81–85

: public ConvertOpToLLVMPattern<Vp2IntersectOp> will likely save some boilerplate.

mlir/test/Dialect/AVX512/roundtrip.mlir
23

Generally, there is no need to test generated code such as the syntax obtained from let assemblyFormat. We checked the generator instead.

springerm updated this revision to Diff 318966.Jan 25 2021, 4:45 AM
springerm marked 6 inline comments as done.

Minor changes.

springerm requested review of this revision.Jan 25 2021, 4:46 AM
springerm added inline comments.
mlir/include/mlir/Dialect/AVX512/AVX512Dialect.h
19

Without this, the generated Dialect/AVX512/AVX512.h.inc file does not compile:

[...] AVX512IncGen/mlir/Dialect/AVX512/AVX512.h.inc:162:240: error: no member named 'OpAsmOpInterface' in namespace 'mlir'
class Vp2IntersectOp : public ::mlir::Op<Vp2IntersectOp, ::mlir::OpTrait::ZeroRegion, ::mlir::OpTrait::NResults<2>::Impl, ::mlir::OpTrait::ZeroSuccessor, ::mlir::OpTrait::NOperands<2>::Impl, ::mlir::MemoryEffectOpInterface::Trait, ::mlir::OpAsmOpInterface::Trait> {
[...]

Not sure what the OpAsmOpInterface is doing, but it is added only when specifying a second output in the td file.

Is there a better way to fix this?

mlir/test/Dialect/AVX512/roundtrip.mlir
23

So you mean

// CHECK: avx512.vp2intersect {{.*}} : vector<16xi32>

could be simplified to just

// CHECK: avx512.vp2intersect {{.*}}

and I can just return a single value such as %0 for simplicity?

ftynse added inline comments.Jan 25 2021, 4:59 AM
mlir/include/mlir/Dialect/AVX512/AVX512Dialect.h
19

Hmm, seems like layering was broken in some of these headers. Okay to keep the include for now.

mlir/test/Dialect/AVX512/roundtrip.mlir
23

I mean the entire test in roundtrip.mlir here is useless, it does not exercise C++ you wrote, only the code that was generated from ODS and we have already tested the generator.

mlir/test/Dialect/AVX512/roundtrip.mlir
23

Hmm, I generally find those useful as general documentation that runs (whatever people add in the .td has no guarantee of executing and not getting stale).
If we drop this, should we start a more general cleanup effort to hunt down ops all such ops that come from an assembly format?

ftynse added inline comments.Jan 25 2021, 5:39 AM
mlir/test/Dialect/AVX512/roundtrip.mlir
23

It's fine to keep some minimal amount of these IMO, but having a lot is just extra review/maintenance load.

Cool to see new AVX512 stuff, thanks!

mlir/include/mlir/Dialect/LLVMIR/LLVMAVX512.td
31

super minor nit (since it is only local), but we tend to use "unsigned" instead of int for such situations

mlir/test/Dialect/AVX512/roundtrip.mlir
23

+1 on having such tests since it acts as some documentation

ftynse added inline comments.Jan 25 2021, 10:11 AM
mlir/include/mlir/Dialect/LLVMIR/LLVMAVX512.td
31

There is no unsigned in tablegen AFAIK.

aartbik added inline comments.Jan 25 2021, 12:20 PM
mlir/include/mlir/Dialect/LLVMIR/LLVMAVX512.td
31

Ah, in that case sorry for the noise.

nicolasvasilache edited the summary of this revision. (Show Details)Jan 25 2021, 11:29 PM
This revision was not accepted when it landed; it landed in state Needs Review.Jan 25 2021, 11:37 PM
This revision was automatically updated to reflect the committed changes.