<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 1/14/20 11:28 AM, Jon Chesterfield wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAOUYtQCND9FjG29GQyBA5dWmWZBZsrzuBFbo3ETqw1YOASWAKw@mail.gmail.com">
<div dir="ltr">
<div dir="ltr">Hi Hal,
<div><br>
</div>
<div>In this case (atomicInc) it's a target specific IR intrinsic but there are other cases where there is target-independent IR support but not clang. OpenCL memory fences for one.</div>
<div><br>
</div>
<div>So the general question is what do do about functions with IR/asm support but no clang builtins.</div>
</div>
</div>
</blockquote>
<p><br>
</p>
<p>My general preference is just to add the Clang intrinsic. Adding target-specific intrinsics is, generically, pretty easy (one line in include/clang/Basic/BuiltinsAMDGPU.def and a few lines of code in CodeGenFunction::EmitAMDGPUBuiltinExpr in lib/CodeGen/CGBuiltin.cpp
 and some lines for testing in test/CodeGen/builtins-amdgcn.c (which, unfortunately, doesn't seem to exist, but just make one like test/CodeGen/builtins-nvptx.c or like test/CodeGen/builtins-nvptx-sm_70.cu).</p>
<p>For the target-independent ones, please post an RFC to cfe-dev about adding the intrinsics so that we can settle on that before you need them.</p>
<p>If there's something complicated about the frontend work, I recommend a .ll file as a work-around.</p>
<p> -Hal<br>
</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:CAOUYtQCND9FjG29GQyBA5dWmWZBZsrzuBFbo3ETqw1YOASWAKw@mail.gmail.com">
<div dir="ltr">
<div dir="ltr">
<div><br>
</div>
<div>Thanks!</div>
<div><br>
</div>
<div>Jon</div>
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Jan 14, 2020 at 5:15 PM Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov" moz-do-not-send="true">hfinkel@anl.gov</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">
<div>
<p><br>
</p>
<div>On 1/14/20 10:37 AM, Jon Chesterfield via Openmp-dev wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hello OpenMP dev,
<div><br>
</div>
<div>A motivating example is atomicInc for amdgcn. There is ISA support for this so a good implementation folds to a single instruction. There is no corresponding clang intrinsic, though there is an llvm intrinsic.</div>
</div>
</blockquote>
<p><br>
</p>
<p>Do you mean a target-specific intrinsic, or a target-independent intrinsic?</p>
<p> -Hal<br>
</p>
<p><br>
</p>
<blockquote type="cite">
<div dir="ltr">
<div>
<div><br>
<div>I see the following options:</div>
<div>- Implement it in IR, linked into deviceRTL</div>
<div>- Inline assembly</div>
<div>- Delay implementation until the intrinsic can be added to clang</div>
<div>- Implement in terms of CAS</div>
<div>- Your suggestion here</div>
<div><br>
</div>
<div>Adding atomicInc.ll to the source tree is the easy short term fix. It has drawbacks in terms of future ABI change, build complexity and limited precedent - libclc does this, but nowhere else.</div>
<div><br>
</div>
<div>Inline assembly works (modulo getting the syntax right) and hits the right instruction.</div>
<div><br>
</div>
<div>Implementing in terms of CAS means one can stay in HIP or OpenCL, but performance suffers.</div>
<div><br>
</div>
<div>What would the you prefer out of these options?<br>
</div>
<div><br>
</div>
<div>Thanks,</div>
<div><br>
</div>
<div>Jon</div>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
Openmp-dev mailing list
<a href="mailto:Openmp-dev@lists.llvm.org" target="_blank" moz-do-not-send="true">Openmp-dev@lists.llvm.org</a>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev" target="_blank" moz-do-not-send="true">https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev</a>
</pre>
</blockquote>
<pre cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</div>
</blockquote>
</div>
</div>
</blockquote>
<pre class="moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>