[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

Jonas Hahnfeld via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 7 07:39:33 PDT 2018


Hahnfeld added a comment.

In https://reviews.llvm.org/D47849#1125019, @gtbercea wrote:

> It's precisely the issue which you report here. Since you don't use device specific math functions, you can run into the problem where you may end up calling assembly instructions for a different architecture. I may have mis-classified this as a correctness issue.


I think the issue is slightly different, the assembly is not necessarily in the called functions, as I said `sqrt` seems to work fine. Clang just errors because they are included via the header.

This is because `clang::InitializePreprocessor` has this:

  // FIXME: This will create multiple definitions for most of the predefined
  // macros. This is not the right way to handle this.
  if ((LangOpts.CUDA || LangOpts.OpenMPIsDevice) && PP.getAuxTargetInfo())
    InitializePredefinedMacros(*PP.getAuxTargetInfo(), LangOpts, FEOpts,
                               Builder);

So we will end up with all host defines (including `__SSE2_MATH__` as @hfinkel wrote) during target compilation :-(


Repository:
  rC Clang

https://reviews.llvm.org/D47849





More information about the cfe-commits mailing list