Page MenuHomePhabricator

[mlir][spirv] Add lowering of std alloca to SPIR-V
Needs RevisionPublic

Authored by ThomasRaoux on Jun 25 2020, 6:42 PM.

Details

Summary

alloca in function or private address space can be lowered to VariableOp. This allow values in memory if needed.

Diff Detail

Event Timeline

ThomasRaoux created this revision.Jun 25 2020, 6:42 PM
hanchung added inline comments.Jun 26 2020, 12:17 AM
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
306–307

I think we can rename spirvType as ptrType, and then we can remove the comment. What do you think?

311

/*initializer=*/=nullptr

bondhugula added inline comments.
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
296–300

You may have to check if the parent op has the AutomaticAllocationScope trait. When is the stack space for VariableOps reclaimed when they aren't immediately not surrounded by SPIRV functions? (or are they always are?)

antiagainst accepted this revision.Jun 26 2020, 7:02 AM
antiagainst added inline comments.
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
289

Is it possible to have std.alloca outside of builtin func? So I think we only have Function storage class case here?

296–300

SPIR-V variable ops outside spv.func (that is, with Private storage class) have the lifetime as the SPIR-V module. But is it possible to have std.alloca outside of builtin func? std.alloca's semantics seem to allow that; I'm wondering whether we will see such cases in reality though.

This revision is now accepted and ready to land.Jun 26 2020, 7:02 AM
mravishankar requested changes to this revision.Jul 31 2020, 11:16 PM
mravishankar added inline comments.
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
290

I am not really sure we want to support AllocaOps. The lifetime of the buffers cannot be enforced. So we are potentially breaking that semantics (I dont see a way of deallocating the OpVariable. Maybe some use case info might help

This revision now requires changes to proceed.Jul 31 2020, 11:16 PM