[LLVMdev] parallel loop metadata simplification
Redmond, Paul
paul.redmond at intel.com
Thu Feb 28 14:37:16 PST 2013
Hi Pekka,
On 2013-02-28, at 4:21 PM, Pekka Jääskeläinen wrote:
> Hi Paul,
>
> On 02/28/2013 09:30 PM, Redmond, Paul wrote:
>> I'd like to reopen the discussion on requiring the
>> llvm.mem.parallel_loop_access metadata. I understand the reason for the
>> metadata is to protect against transformations that may introduce unsafe
>> parallel memory accesses (the reg2mem example.) I'm wondering if perhaps we
>> can make the metadata more user-friendly by providing a single loop metadata
>> which can be expanded into "safer" metadata as required. Specifically a loop
>> pass could be added that expands llvm.loop.parallel into
>> llvm.loop.parallel_protected + llvm.mem.parallel_loop_access.
>
> Did I understand this correctly: llvm.loop.parallel would become
> a version which does not require the parallel_loop_access? Basically it
> would be a placeholder for a later pass (before unsafe optimizations?) that
> converts it to the "safe" metadata pair? Then you can generate the loads/stores
> in Clang without worrying about the mem metadata but add the safe
> metadata once and for all.
>
Yes, that is correct.
> The problem I see with this is that I do not think there is use for
> "unsafe"/"unprotected" parallel metadata after Clang. Thus, the
> "unprotected metadata" would be merely book keeping until the final IR is
> generated in Clang (with the safe metadata). Maybe some other book keeping
> mechanism could do? If it's not easily workable (I'm not a Clang expert)
> then I'd propose a descriptive name for the new metadata like llvm.loop.parallel_under_construction that strongly states that
> it's for this purpose only and should not be used for anything
> during optimizations (as it's not safe to do so!).
>
Those are fair points and I can't say whether or not there are other potential users. Certainly clang could use custom loop metadata and the pass could live in its codegen.
Another option is two make Loop::isParallel aware of both safe and unsafe parallel metadata and not requires translation at all. In practice, passes like reg2mem are not run so the concern goes away. Perhaps a single loop metadata is good enough for most uses?
paul
> --
> --Pekka
More information about the llvm-dev
mailing list