<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Wed, Aug 7, 2013 at 6:24 PM, Pete Cooper <span dir="ltr"><<a href="mailto:peter_cooper@apple.com" target="_blank">peter_cooper@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Aug 7, 2013, at 2:54 PM, Michele Scandale <<a href="mailto:michele.scandale@gmail.com">michele.scandale@gmail.com</a>> wrote:<br>
<br>
>> I don’t know if CUDA has aliasing address spaces, but that would also be<br>
>> useful to consider. Something simple like this might work. Note i’m<br>
>> using the examples from the clang discussion, that is "1 = opencl/cuda<br>
>> global, 2 = opencl_local/cuda_shared, 3 = opencl/cuda constant"<br>
><br>
> You are assuming that the target device has different physical address spaces (like, PTX or R600 or TCE). What for those one with an unique address space (e.g. X86, ARM) where all opencl/cuda address spaces are mapped (correctly) to the target address space 0?<br>
</div>That seems like something only the backend needs to care about, but it is a very important thing to consider.<br>
<br>
You could extend my approach below with one more field which for each address space tells you the HW address space it maps to. Then the selection DAG builder can use that information (if it exists) to do the translation. Thats perhaps not the cleanest implementation, but it would work.<br>
<br>
I was going to suggest that an alternative is to pass this information in to the load/store instructions in the backend, but it looks like that information is already available. That is, MachinePointerInfo has a getAddrSpace() method. This could potentially allow you to optimize MachineInstrs using the same knowledge you have here, e.g., constness for addrspace(3) in MachineLICM.\<br>
</blockquote><div><br></div><div>I don't believe MachinePointerInfo is guaranteed to be meaningful for all loads/stores. It is populated with an llvm::Value*, but loads/stores generated in a backend may not be associated with a Value*.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">><br>
>><br>
>> !address_spaces = !{!0, !1, !2, !3}<br>
>><br>
>> ; Address space tuple. { address space number, parent address space,<br>
>> additional properties }<br>
>> !0 = metadata !{ i32 0, !{}, !{} }<br>
>> !1 = metadata !{ i32 1, !0, !{} }<br>
>> !2 = metadata !{ i32 2, !0, !{} }<br>
>> !3 = metadata !{ i32 3, !0, !4 }<br>
>><br>
>> !4 = metadata !{ “constant” }<br>
>><br>
>><br>
>> This corresponds to 3 address spaces which all are members of address<br>
>> space 0, but which otherwise do not alias each other. I think this is<br>
>> roughly how TBAA does things. You can introduce any nodes in the tree<br>
>> of address spaces you need to make children in the tree alias each other.<br>
>><br>
>> Additionally, the last address space is marked as constant which could<br>
>> be used for optimization, e.g. LICM.<br>
><br>
</div>> You mean that 1, 2, 3 do not alias each other, but they all alias with 0, right? The address space 0 in used to represent opencl __private address space, I think it would not alias with the others…<br>
Yeah, thats right, i have them all alias 0. If 0 is private and doesn’t alias anything then thats even better. Potentially that means that the optimizer will be able to reorder any access to globals with any other access to the stack for example. That will really help it optimize very well.<br>
<div class="im">><br>
> BTW, I like the approach: it allows a fine description of relationship between address spaces that can be used in the middle-end, and the frontend is responsible for the correct emission of this language specific information. That's great!<br>
</div>Thanks :)<br>
<div class="HOEnZb"><div class="h5">><br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div>
</div></div>