<div dir="ltr">To follow on here:<div><br></div><div>This is most assuredly just the tip of the iceberg if you need to co-mingle two targets as part of the module. Basically any solution is going to be better than trying to do that.</div><div><br></div><div>-eric<br><br><div class="gmail_quote"><div dir="ltr">On Wed, Apr 25, 2018 at 5:49 PM Hal Finkel via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p>Hi, Jin,</p>
<p>Can you please back up a bit and talk about the programming
environment in which this problem manifests?</p>
<p>If I have a host and a target with different ABIs, then it seems
we have lots of problems. For one thing, the layouts of structures
are different, the sizes of some integer types are different, the
sizes of pointers are different, and so on. It seems like a
solution in this space should address, somehow, this general
translation problem. Fixing this particular problem with the
dispatch function's parameters feels like only the tip of the
iceberg. What if I'm passing a pointer to some structure, or a
pointer to other pointers, etc.?</p>
<p>I understand that OpenMP v5 is expected to have some custom
"mappers" to handle deep copying and translation. Is this related
to the design space here?</p>
<p>Thanks again,</p>
<p>Hal<br>
</p></div><div text="#000000" bgcolor="#FFFFFF">
<br>
<div class="m_896052177612937197moz-cite-prefix">On 04/25/2018 07:22 PM, Lin, Jin via
llvm-dev wrote:<br>
</div>
<blockquote type="cite">
<div class="m_896052177612937197WordSection1">
<p class="MsoNormal"><span style="color:#1f497d">For the
firstprivate clause, the compiler generates code to pass it
by value or by reference to the outlined function. The
reason the first private scalars is generally passed by
value is for the performance reason.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">For this
particular case, the compiler cannot generate code to pass
the double @gg by value under i386-pc-linux-gnu since the
value is 64 bit while the architecture is 32bit.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">For the host
compilation, the compiler generates the code to pass the
data as well as the outlined function name to the OMP
runtime.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">For the target
compilation, the compiler generates the outlined function so
that it can be called by the OMP runtime.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">So, the
compiler is required to generate a single call on the host
to support all the targets. All the target versions must
have the same interface. So the common interface of the
outline function should be used. For this particular
example, the variable @gcc should be passed by reference
under x86_64-mic.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">Please let me
know if you have more questions.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">Jin<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:normal">
<a name="m_896052177612937197______replyseparator"></a><b><span style="color:windowtext">From:</span></b><span style="color:windowtext"> Friedman, Eli
[<a class="m_896052177612937197moz-txt-link-freetext" href="mailto:efriedma@codeaurora.org" target="_blank">mailto:efriedma@codeaurora.org</a>]
<br>
<b>Sent:</b> Wednesday, April 25, 2018 4:14 PM<br>
<b>To:</b> Lin, Jin <a class="m_896052177612937197moz-txt-link-rfc2396E" href="mailto:jin.lin@intel.com" target="_blank"><jin.lin@intel.com></a>;
'<a class="m_896052177612937197moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>'
<a class="m_896052177612937197moz-txt-link-rfc2396E" href="mailto:llvm-dev@lists.llvm.org" target="_blank"><llvm-dev@lists.llvm.org></a><br>
<b>Subject:</b> Re: [llvm-dev] [LLVM][RFC] Representing
the target device information in the LLVM IR<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On 4/25/2018 3:48 PM, Lin, Jin wrote:<span style="font-size:12.0pt;line-height:105%"><u></u><u></u></span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="color:#0070c0">Given a
global variable @gg, the compiler has to generate code on
the host to specify whether it is passed by value or
passed by reference. In the following example, if the
compiler generates the code for passing by value, the
outlined function on the target </span><span style="font-family:"\000026quot",serif;color:#0070c0;border:none windowtext 1.0pt;padding:0in">i386-pc-linux-gnu</span><span style="color:#0070c0"> cannot get the correct value since
it assumes the variable @gg is passed by reference. </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#0070c0"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#0070c0">Here is the
corresponding IR on the host side.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:red"> %0 = load
double, double* @gg, align 8, !tbaa !3</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:red"> %1 = bitcast
double %0 to i64</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"> …</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#0070c0"> %12 =
getelementptr inbounds [4 x i8*], [4 x i8*]*
%.offload_baseptrs, i32 0, i32 2</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#0070c0"> %13 =
bitcast i8** %12 to i64*</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:red"> store i64 %1,
i64* %13, align 8</span><u></u><u></u></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:normal">
<span><br>
Could you describe the overall process of calling an
offloaded function in a bit more detail? How do you
describe the ABI of the called function to the OpenMP
runtime?<br>
<br>
I suspect you shouldn't be trying to store things which
aren't pointers into offload_baseptrs.<br>
<br>
-Eli<br>
<br>
<br>
<u></u><u></u></span></p>
<pre>-- <u></u><u></u></pre>
<pre>Employee of Qualcomm Innovation Center, Inc.<u></u><u></u></pre>
<pre>Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project<u></u><u></u></pre>
</div>
<br>
<fieldset class="m_896052177612937197mimeAttachmentHeader"></fieldset>
<br>
<pre>_______________________________________________
LLVM Developers mailing list
<a class="m_896052177612937197moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a class="m_896052177612937197moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
</div><div text="#000000" bgcolor="#FFFFFF"><pre class="m_896052177612937197moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div></div>