<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><font face="Hack Nerd Font Mono">Oh, I forgot about this one.</font></p>
    <p><font face="Hack Nerd Font Mono"><br>
      </font></p>
    <p><font face="Hack Nerd Font Mono">The math stuff works because all
        declare variant functions are static.</font></p>
    <p><font face="Hack Nerd Font Mono">I think if we need to replace
        the `.` with a symbol that the user cannot</font></p>
    <p><font face="Hack Nerd Font Mono">use but the ptax assembler is
        not upset about. we should also move</font></p>
    <p><font face="Hack Nerd Font Mono">`getOpenMPVariantManglingSeparatorStr`
        from `Decl.h` into</font></p>
    <p><font face="Hack Nerd Font Mono">`llvm/lib/Frontends/OpenMP/OMPContext.h`,
        I forgot why I didn't.<br>
      </font></p>
    <p> </p>
    <p>You should also be able to use the clang builtin atomics and even
      the</p>
    <p>`omp atomic` should eventually resolve to the same thing (I
      hope).<br>
    </p>
    <p><br>
    </p>
    <p>Let me know if that helps,</p>
    <p>  Johannes</p>
    <p><br>
    </p>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 5/18/20 10:33 AM, Lukas Sommer via
      Openmp-dev wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:d2c93b55-fe98-2f40-3b2c-fdfd46188563@esa.tu-darmstadt.de">
      <pre class="moz-quote-pre" wrap="">Hi all,

what's the current status of declare variant when compiling for Nvidia
GPUs?

In my code, I have declared a variant of a function, that uses CUDA's
built-in atomicAdd (using the syntax from OpenMP TR8):

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">#pragma omp begin declare variant match(device={kind(nohost)})

void atom_add(double* address, double val){
        atomicAdd(address, val);
}

#pragma omp end declare variant
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">When compiling with Clang from master, ptxas fails:

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">clang++ -fopenmp   -O3 -std=c++11 -fopenmp
-fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_72 -v
[...]
ptxas kernel-openmp-nvptx64-nvidia-cuda.s, line 322; fatal   : Parsing
error near '.ompvariant': syntax error
ptxas fatal   : Ptx assembly aborted due to errors
[...]
clang-11: error: ptxas command failed with exit code 255 (use -v to
see invocation)
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">The line mentioned in the ptxas error looks like this:

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">        // .globl       _Z33atom_add.ompvariant.S2.s6.PnohostPdd
.visible .func _Z33atom_add.ompvariant.S2.s6.PnohostPdd(
        .param .b64 _Z33atom_add.ompvariant.S2.s6.PnohostPdd_param_0,
        .param .b64 _Z33atom_add.ompvariant.S2.s6.PnohostPdd_param_1
)
{
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">My guess was that ptxas stumbles across the ".ompvariant"-part of the
mangled function name.

Is declare variant currently supported when compiling for Nvidia GPUs?
If not, is there a workaround (macro defined only for device
compilation, access to the atomic CUDA functions, ...)?

Thanks in advance,

Best

Lukas

</pre>
    </blockquote>
  </body>
</html>