Nadav Rotem
2013-Nov-14 16:38 UTC
[LLVMdev] Vectorization of loops with conditional dereferencing
> > I'm not. :( >I think that this is probably the most important feature for the vectorizer right now. Other features require adding complexity to the vectorizer while this feature is relatively simple.> What kind of pragmas would work for this loop? Something telling that it's safe to speculatively read from m[] at any position? In this reduction case it might be enough. But if this would be an induction store like: > > for () { > if (a[i] > 0) > x[i] = ... + m[i]; >Sure. Vectorization of stores is done by loading the current value from memory, blending the new value and saving it back to memory.> then, the store would be a more complicated way to write to memory and you'd need the read-pragma to not affect such cases.There is no need for read pragma or even a special attribute. The ‘vectorize’ pragma tells the vectorizer that it is safe to access the predicated memory (read or write).
Renato Golin
2013-Nov-14 17:11 UTC
[LLVMdev] Vectorization of loops with conditional dereferencing
On 14 November 2013 16:38, Nadav Rotem <nrotem at apple.com> wrote:> Sure. Vectorization of stores is done by loading the current value from > memory, blending the new value and saving it back to memory. >I guess the cost model could let you know if it's profitable or not with the extra load+mask. But you need to teach it first. I was worried that telling that m[] can be speculatively read/written does not automatically propagate to x[], so maybe you should have to add the same pragma on both to make the induction case work, but only one for the reduction case. cheers, --renato -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131114/fc2f2ee9/attachment.html>
Ralf Karrenberg
2013-Nov-14 18:58 UTC
[LLVMdev] Vectorization of loops with conditional dereferencing
Hi Nadav, On 14/11/13 17:38, Nadav Rotem wrote:> Sure. Vectorization of stores is done by loading the current value from memory, blending the new value and saving it back to memory.Just a side note: You may run into trouble with this approach when people start using the loop vectorizer in combination with multi threading. The load/blend/store scheme introduces a race condition in this scenario. I don't know if this is a valid use case for you, but it may be worth keeping in mind. Cheers, Ralf
Nadav Rotem
2013-Nov-14 19:10 UTC
[LLVMdev] Vectorization of loops with conditional dereferencing
Its a good point. We will need to document the semantics of the vectorization pragma well. On Nov 14, 2013, at 10:58 AM, Ralf Karrenberg <Chareos at gmx.de> wrote:> Hi Nadav, > > On 14/11/13 17:38, Nadav Rotem wrote: >> Sure. Vectorization of stores is done by loading the current value from memory, blending the new value and saving it back to memory. > > Just a side note: You may run into trouble with this approach when people start using the loop vectorizer in combination with multi threading. The load/blend/store scheme introduces a race condition in this scenario. > I don't know if this is a valid use case for you, but it may be worth keeping in mind. > > Cheers, > Ralf
Possibly Parallel Threads
- [LLVMdev] Vectorization of loops with conditional dereferencing
- [LLVMdev] Vectorization of loops with conditional dereferencing
- [LLVMdev] Vectorization of loops with conditional dereferencing
- [LLVMdev] Vectorization of loops with conditional dereferencing
- [LLVMdev] Vectorization of loops with conditional dereferencing