Enhance GPU To SPIR-V conversion to support builtins and load/store ops.
authorMahesh Ravishankar <ravishankarm@google.com>
Tue, 27 Aug 2019 17:49:53 +0000 (10:49 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Tue, 27 Aug 2019 17:50:23 +0000 (10:50 -0700)
commit4ced99c085e62f681276a06e0ce842b190900d32
tree8673d234eeb5aeae9f985437ee4c33a89819c2f8
parent8f2dfb51d4a448754f0c76a8f4d97643d73add3c
Enhance GPU To SPIR-V conversion to support builtins and load/store ops.

To support a conversion of a simple load-compute-store kernel from GPU
dialect to SPIR-V dialect, the conversion of operations like
"gpu.block_dim", "gpu.thread_id" which allow threads to get the launch
conversion is needed. In SPIR-V these are specified as global
variables with builin attributes. This CL adds support to specify
builtin variables in SPIR-V conversion framework. This is used to
convert the relevant operations from GPU dialect to SPIR-V dialect.
Also add support for conversion of load/store operation in Standard
dialect to SPIR-V dialect.
To simplify the conversion add a method to build a spv.AccessChain
operation that automatically determines the return type based on the
base pointer type and the indices provided.

PiperOrigin-RevId: 265718525
mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h
mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td
mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.td
mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
mlir/test/Conversion/GPUToSPIRV/builtins.mlir [new file with mode: 0644]
mlir/test/Conversion/GPUToSPIRV/load_store.mlir [new file with mode: 0644]