Roman Gareev via llvm-dev
2016-Jun-27 10:48 UTC
[llvm-dev] [GSoC 2016] Implementation of the packing transformation
Dear community, the next step of the "Improvement of vectorization process in Polly" project is to implement the packing transformation described in http://www.cs.utexas.edu/users/flame/pubs/TOMS-BLIS-Analytical.pdf. I had a discussion with Tobias and we decided that a packing transformation is in many ways a data-layout transformation that will require to introduce a new array, copy data to the array and change memory access locations of the compute kernel to reference the array. I think that it could be done in IslNodeBuilder::createMark during generation of code for mark nodes, which are created in the ScheduleTreeOptimizer and contain all necessary information about memory access functions that should be changed. Michael, if I'm not mistaken, an ability to change memory access functions to change the arrays a memory access is referencing can be useful for your DE-LICM work. I would be very grateful, if you or someone else could share ideas and patches which can be used as a starting point. -- Thanks, Roman Gareev
Roman Gareev via llvm-dev
2016-Jul-03 09:18 UTC
[llvm-dev] [GSoC 2016] Implementation of the packing transformation
Dear community, I have a few questions about implementation of the packing transformation. I would be very grateful for your ideas and comments about them. 1. Could we set MemoryAccess::NewAccessRelation to modify an access relation of a memory access? As far as I understand, MemoryAccess::NewAccessRelation is only used to import memory accesses from JSCoPs I think that MemoryAccess::NewAccessRelation could be used in the implementation and also help to perform, for example, array expansion. However, the modification would probably cause issues. For example, if we apply tiling, we'll have to substitute old induction variables before analyzing access functions. I'm not sure whether it's possible to do it in ScheduleOptimizer. Another possible issue could arise during import from JSCoPs. In this case, we probably shouldn't modify imported access relations. 2. What should we do to change an array referenced by a memory access? If I'm not mistaken, we can set the value of MemoryAccess::BasePtr to do it. 3. Could we copy data to a new array in IslNodeBuilder::createMark? We can probably create mark nodes, which contain references to memory accesses that should be modified. Subsequently, using information about original and new access relations, IslNodeBuilder::createMark would generate functions that perform such copying. -- Cheers, Roman Gareev.
Tobias Grosser via llvm-dev
2016-Jul-03 12:02 UTC
[llvm-dev] [GSoC 2016] Implementation of the packing transformation
On Sun, Jul 3, 2016, at 02:18 AM, Roman Gareev via llvm-dev wrote:> Dear community,Hi Roman,> I have a few questions about implementation of the packing > transformation. I would be very grateful for your ideas and comments > about them. > > 1. Could we set MemoryAccess::NewAccessRelation to modify an access > relation of a memory access? As far as I understand, > MemoryAccess::NewAccessRelation is only used to import memory accesses > from JSCoPsI already use it in Polly-ACC to modify access relations. If you just want to modify the subscript expression, this should just work. Changing the accessed array may also already work, but is a lot less tested and the information is only partially updated such that further interface changes would be required.> I think that MemoryAccess::NewAccessRelation could be used in the > implementation and also help to perform, for example, array expansion.Yes.> However, the modification would probably cause issues. For example, if > we apply tiling, we'll have to substitute old induction variables > before analyzing access functions.I do not understand this issue. Tiling is a schedule-only transformation that only considers data-dependences for legality. How do access functions come into play here? Why do induction variables need to be substituted. If you did not see this yet, any modification of the polyhedral access function will (except for non-affine accesses) directly be translated to LLVM-IR. This means, we need (almost) no code generation changes to make this work.> I'm not sure whether it's possible > to do it in ScheduleOptimizer. Another possible issue could arise > during import from JSCoPs. In this case, we probably shouldn't modify > imported access relations.You mean we should not overwrite the changes that have been imported? I think overwriting them is OK. If the user prefers to not run schedule optimizations after the input, he can always disable the schedule optimizer when importing changes.> 2. What should we do to change an array referenced by a memory access? > > If I'm not mistaken, we can set the value of MemoryAccess::BasePtr to do > it.To just make it work, it should be sufficient to set an access function that has an isl_id that points to a different ScopArrayInfo object. See: IslExprBuilder::createAccessAddress BaseExpr = isl_ast_expr_get_op_arg(Expr, 0); BaseId = isl_ast_expr_get_id(BaseExpr); isl_ast_expr_free(BaseExpr); const ScopArrayInfo *SAI = ScopArrayInfo::getFromId(BaseId); Base = SAI->getBasePtr(); Now, just resetting the access function leaves the MemoryAccess in a rather inconsistent state. It would be good if we could think about what is needed to provide a consistent interface for such kind of functionality. Also, having jscop test cases to test this functionality would be great.> 3. Could we copy data to a new array in IslNodeBuilder::createMark? > > We can probably create mark nodes, which contain references to memory > accesses that should be modified. Subsequently, using information > about original and new access relations, IslNodeBuilder::createMark > would generate functions that perform such copying.Why mark nodes? An option I have been thinking of was to create new - virtual ScopStmts that have specific semantics. E.g. ones that copy the content from one array location to another. We could test these using jscop and then use them in your schedule transformation to implement the packing. Michael probably has some opinion here. He played in his delicm work with some changes that also require more complex modifications of memory accesses. There is no specific commit (AFAIU), but some changes are mixed in with his prototype work: https://github.com/Meinersbur/polly/commits/delicm2 Best, Tobias