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

Gheorghe-Teodor Bercea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 6 15:45:24 PDT 2018


gtbercea created this revision.
gtbercea added reviewers: Hahnfeld, tra, hfinkel, carlo.bertolli, caomhin, ABataev.
Herald added subscribers: cfe-commits, guansong, mgorny.

In current Clang, on the OpenMP NVPTX toolchain, math functions are resolved as math functions for the host. For example, a call to sqrt() in a target region will result in an LLVM-IR call which looks like this:

  call double sqrt(double %1)

This patch allows for math functions in OpenMP NVPTX target regions to call the same math functions that CUDA code calls. For example, for sqrt we get:

  call double @llvm.nvvm.sqrt.rn.d(double %1)

This is necessary for both correctness and performance.


Repository:
  rC Clang

https://reviews.llvm.org/D47849

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_libdevice_declares.h
  test/CodeGen/nvptx_device_math_functions.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47849.150210.patch
Type: text/x-patch
Size: 52876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180606/211d0797/attachment-0001.bin>


More information about the cfe-commits mailing list