<div dir="ltr"><div>This comment is inspired by discussion on <a href="https://github.com/ofiwg/libfabric/pull/1436">https://github.com/ofiwg/libfabric/pull/1436</a>.</div><div><br></div><div>According to the signature, the input argument (buf) is 'const void *' (the output is 'void *').</div><div><br></div><div><pre style="padding:9.5px;font-family:Monaco,Menlo,Consolas,'Courier New',monospace;font-size:13px;color:rgb(51,51,51);border-radius:4px;margin-top:0px;margin-bottom:10px;line-height:20px;word-wrap:break-word;white-space:pre-wrap;border:1px solid rgba(0,0,0,0.14902);background-color:rgb(245,245,245)"><code class="" style="padding:0px;font-family:Monaco,Menlo,Consolas,'Courier New',monospace;font-size:12px;color:inherit;border-radius:3px;border:0px;background-color:transparent"><span class="" style="color:rgb(68,85,136);font-weight:bold">ssize_t</span> <span class="" style="color:rgb(153,0,0);font-weight:bold">fi_fetch_atomic</span><span class="">(</span><span class="" style="font-weight:bold">struct</span> <span class="">fid_ep</span> <span class="" style="font-weight:bold">*</span><span class="">ep</span><span class="">,</span> <span class="" style="font-weight:bold">const</span> <span class="" style="color:rgb(68,85,136);font-weight:bold">void</span> <span class="" style="font-weight:bold">*</span><span class="">buf</span><span class="">,</span>
        <span class="" style="color:rgb(68,85,136);font-weight:bold">size_t</span> <span class="">count</span><span class="">,</span> <span class="" style="color:rgb(68,85,136);font-weight:bold">void</span> <span class="" style="font-weight:bold">*</span><span class="">desc</span><span class="">,</span> <span class="" style="color:rgb(68,85,136);font-weight:bold">void</span> <span class="" style="font-weight:bold">*</span><span class="">result</span><span class="">,</span> <span class="" style="color:rgb(68,85,136);font-weight:bold">void</span> <span class="" style="font-weight:bold">*</span><span class="">result_desc</span><span class="">,</span>
        <span class="" style="color:rgb(68,85,136);font-weight:bold">fi_addr_t</span> <span class="">dest_addr</span><span class="">,</span> <span class="" style="color:rgb(68,85,136);font-weight:bold">uint64_t</span> <span class="">addr</span><span class="">,</span> <span class="" style="color:rgb(68,85,136);font-weight:bold">uint64_t</span> <span class="">key</span><span class="">,</span>
        <span class="" style="font-weight:bold">enum</span> <span class="">fi_datatype</span> <span class="">datatype</span><span class="">,</span> <span class="" style="font-weight:bold">enum</span> <span class="">fi_op</span> <span class="">op</span><span class="">,</span> <span class="" style="color:rgb(68,85,136);font-weight:bold">void</span> <span class="" style="font-weight:bold">*</span><span class="">context</span><span class="">);</span></code></pre></div><div><br></div><div>I'm sure it's valid C and I appreciate that restrict isn't there for a reason, but it is nonetheless gross to update buf when it is a const pointer when the underlying data is aliased by result.  Of course the user should no better, but why design an API like this?</div><div><br></div><div>Is there a reason why buf and result can't be restrict pointers?  I see zero value in enabling the case of aliased local buffers when the side effects are (1) a const buffer is modified and (2) the potential code optimization demonstrated in my pull request is disallowed (without specializing the macro for the aliased and non-aliased cases, of course).</div><br>Note that MPI does not allow aliasing here: "The origin and result buffers (origin_addr and result_addr) must be disjoint."  UPC uses restrict extensively, so I doubt this is possible there.  OpenSHMEM cannot have this usage since the result is the return value of the function, meaning it is going to be allocated in an automatic variable inside of the function.<div><br><div>Jeff</div><div><br></div>-- <br><div class="gmail_signature">Jeff Hammond<br><a href="mailto:jeff.science@gmail.com" target="_blank">jeff.science@gmail.com</a><br><a href="http://jeffhammond.github.io/" target="_blank">http://jeffhammond.github.io/</a></div>
</div></div>