This is an archive of the discontinued LLVM Phabricator instance.

[mlir][spirv] Add OpenCL extended ops: exp, fabs, s_abs
ClosedPublic

Authored by kdobros on Oct 7 2020, 7:32 AM.

Diff Detail

Event Timeline

kdobros created this revision.Oct 7 2020, 7:32 AM
kdobros requested review of this revision.Oct 7 2020, 7:32 AM
mravishankar requested changes to this revision.Oct 7 2020, 9:45 AM

Thanks!

Wondering if these can also be serialized/deserialized similar to the GLSL ops here. This method was written to be general enough to handle any extension instruction, but is only tested on GLSL. Can you verify these work on OpenCL as well?

mlir/include/mlir/Dialect/SPIRV/SPIRVOCLOps.td
82

Nit: Maybe rename this to SPV_OCLExpOp (and similarly below)

This revision now requires changes to proceed.Oct 7 2020, 9:45 AM
kdobros updated this revision to Diff 296775.Oct 7 2020, 12:53 PM

Add serialization roundtrip tests, change c++ operation names to follow CamelCase.

kdobros marked an inline comment as done.Oct 7 2020, 12:57 PM

Thanks!

Wondering if these can also be serialized/deserialized similar to the GLSL ops here. This method was written to be general enough to handle any extension instruction, but is only tested on GLSL. Can you verify these work on OpenCL as well?

Thanks for the review.

I added serialization roundtrip tests, as there seems to no infrastructure to properly check generated spirv assembly.

mravishankar accepted this revision.Oct 7 2020, 1:26 PM

The serialization round trip convert from MLIR to SPIR-V binary and then reads it back. Its not a definitive check, though. Ideally we want to verify with SPIR-V validator, but we cant have that dependency in MLIR.
FWIW, a lot of the SPIR-V dialect is used in IREE which runs SPIR-V generated code on Vulkan drivers. There is also a mlir-vulkan-runner that use Vulkan to run the SPIR-V binaries generated from MLIR. So these validate the overall structure of the serialization/deserialization. Since whats added here is using the same infra as the GLSL ops, I think thats good enough testing. Any additional way to verify the SPIR-V binary would be of course welcome!

This revision is now accepted and ready to land.Oct 7 2020, 1:26 PM

Thank you @mravishankar, could you merge on my behalf?

FYI we have opencl-runner in PlaidML, but I'm afraid its too diverged from mlir to be useful.
If time permits I'll be sure to put something together based on that :)

This revision was automatically updated to reflect the committed changes.