[llvm-dev] [GSoC 2016] Implementation of the packing transformation
Tobias Grosser via llvm-dev
llvm-dev at lists.llvm.org
Sun Jul 3 05:02:05 PDT 2016
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 JSCoPs
I 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
More information about the llvm-dev
mailing list