[Openmp-commits] [PATCH] D60906: [OpenMP][libomptarget][WIP] Add math functions support in OpenMP offloading

Gheorghe-Teodor Bercea via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Apr 19 14:34:45 PDT 2019


gtbercea updated this revision to Diff 195920.
gtbercea added a comment.

- Address comments.


Repository:
  rOMP OpenMP

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60906/new/

https://reviews.llvm.org/D60906

Files:
  libomptarget/deviceRTLs/nvptx/CMakeLists.txt
  libomptarget/deviceRTLs/nvptx/src/interface.h
  libomptarget/deviceRTLs/nvptx/src/math.cu


Index: libomptarget/deviceRTLs/nvptx/src/math.cu
===================================================================
--- /dev/null
+++ libomptarget/deviceRTLs/nvptx/src/math.cu
@@ -0,0 +1,29 @@
+//===------------ math.cu - NVPTX OpenMP math constructs --------- CUDA -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains the implementation of math function not already handled.
+// Function in this file will end up as part of the .bc library of the
+// device and will call libdevice functions.
+//
+//===----------------------------------------------------------------------===//
+
+#include "omptarget-nvptx.h"
+
+EXTERN float __kmpc_powf(float a, float b) { return powf(a, b); }
+EXTERN double __kmpc_pow(double a, double b) { return pow(a, b); }
+// no powl defined for the GPU device so use pow.
+EXTERN long double __kmpc_powl(long double a, long double b) {
+  return pow((double) a, (double) b);
+}
+
+EXTERN float __kmpc_sinf(float a) { return sinf(a); }
+EXTERN double __kmpc_sin(double a) { return sin(a); }
+// no sinl defined for the GPU device so use pow.
+EXTERN long double __kmpc_sinl(long double a) {
+  return sin((double) a);
+}
\ No newline at end of file
Index: libomptarget/deviceRTLs/nvptx/src/interface.h
===================================================================
--- libomptarget/deviceRTLs/nvptx/src/interface.h
+++ libomptarget/deviceRTLs/nvptx/src/interface.h
@@ -567,4 +567,14 @@
 EXTERN void __kmpc_restore_team_static_memory(int16_t isSPMDExecutionMode,
                                               int16_t is_shared);
 
+// POW
+EXTERN float __kmpc_powf(float a, float b);
+EXTERN double __kmpc_pow(double, double);
+EXTERN long double __kmpc_powl(long double a, long double b);
+
+// SIN
+EXTERN float __kmpc_sinf(float);
+EXTERN double __kmpc_sin(double);
+EXTERN long double __kmpc_sinl(long double);
+
 #endif
Index: libomptarget/deviceRTLs/nvptx/CMakeLists.txt
===================================================================
--- libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -53,6 +53,7 @@
       src/reduction.cu
       src/sync.cu
       src/task.cu
+      src/math.cu
   )
 
   set(omp_data_objects src/omp_data.cu)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60906.195920.patch
Type: text/x-patch
Size: 2500 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20190419/3bd6446d/attachment-0001.bin>


More information about the Openmp-commits mailing list