[Openmp-commits] [PATCH] D93718: [OpenMP][Docs] Add FAQ entry about math and complex on GPUs

Johannes Doerfert via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Dec 22 10:50:06 PST 2020


jdoerfert created this revision.
jdoerfert added a reviewer: tianshilei1992.
Herald added subscribers: guansong, bollu, yaxunl.
jdoerfert requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: OpenMP.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93718

Files:
  openmp/docs/SupportAndFAQ.rst


Index: openmp/docs/SupportAndFAQ.rst
===================================================================
--- openmp/docs/SupportAndFAQ.rst
+++ openmp/docs/SupportAndFAQ.rst
@@ -91,3 +91,32 @@
 Q: Does OpenMP offloading support work in packages distributed as part of my OS?
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 For now, the answer is most likely *no*. Please see :ref:`build_offload_capable_compiler`.
+
+
+.. _math_and_complex_in_target_regions:
+
+Q: Does Clang support `<math.h>` and `<complex.h>` operations in OpenMP target on GPUs?
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Yes, LLVM/Clang allows math functions and complex arithmetic inside of OpenMP target regions
+that are compiled for GPUs.
+
+Clang provides a set of wrapper headers that are found first when `math.h`,
+`cmath`, `complex.h`, or similar headers are included by the application. These
+wrappers will eventually include the system version of the corresponding header
+file after setting up a target device specific environment. The fact that the
+system header is included is important because they differ based on the
+architecture and operating system and may contain preprocessor, variable, and
+function definitions that need to be available in the target region regardless
+of the targeted device architecture. However, various functions may require
+specialized device versions, e.g., `sin`, and others are only available on
+certain devices, e.g., `__umul64hi`. To provide "native" support for math and
+complex on the respective architecture, Clang will wrap the "native" math
+functions, e.g., as provided by the device vendor, in an OpenMP begin/end
+declare variant. These functions will then be picked up instead of the host
+versions while host only variables and function definitions are still
+available. Complex arithmetic and functions are support through a similar
+mechanism. It is worth noting that this support requires `extensions to the
+OpenMP begin/end declare variant context selector
+<https://clang.llvm.org/docs/AttributeReference.html#pragma-omp-declare-variant>`__
+that are exposed through LLVM/Clang.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93718.313392.patch
Type: text/x-patch
Size: 2206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20201222/1a84d167/attachment.bin>


More information about the Openmp-commits mailing list