[polly] r311322 - [GPGPU] Add log / logf to the libdevice supported functions

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 21 02:00:32 PDT 2017


Author: grosser
Date: Mon Aug 21 02:00:31 2017
New Revision: 311322

URL: http://llvm.org/viewvc/llvm-project?rev=311322&view=rev
Log:
[GPGPU] Add log / logf to the libdevice supported functions

These two functions are used in COSMO

Modified:
    polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
    polly/trunk/test/GPGPU/Inputs/libdevice-functions-copied-into-kernel_libdevice.ll
    polly/trunk/test/GPGPU/libdevice-functions-copied-into-kernel.ll

Modified: polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp?rev=311322&r1=311321&r2=311322&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Mon Aug 21 02:00:31 2017
@@ -1380,8 +1380,8 @@ isl_bool collectReferencesInGPUStmt(__is
 
 /// A list of functions that are available in NVIDIA's libdevice.
 const std::set<std::string> CUDALibDeviceFunctions = {
-    "exp",  "expf",  "expl",     "cos",       "cosf",
-    "sqrt", "sqrtf", "copysign", "copysignf", "copysignl"};
+    "exp",   "expf",     "expl",      "cos",       "cosf", "sqrt",
+    "sqrtf", "copysign", "copysignf", "copysignl", "log",  "logf"};
 
 /// Return the corresponding CUDA libdevice function name for @p F.
 ///

Modified: polly/trunk/test/GPGPU/Inputs/libdevice-functions-copied-into-kernel_libdevice.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/GPGPU/Inputs/libdevice-functions-copied-into-kernel_libdevice.ll?rev=311322&r1=311321&r2=311322&view=diff
==============================================================================
--- polly/trunk/test/GPGPU/Inputs/libdevice-functions-copied-into-kernel_libdevice.ll (original)
+++ polly/trunk/test/GPGPU/Inputs/libdevice-functions-copied-into-kernel_libdevice.ll Mon Aug 21 02:00:31 2017
@@ -4,3 +4,6 @@ define float @__nv_expf(float %a) {
 define float @__nv_cosf(float %a) {
   ret float %a
 }
+define float @__nv_logf(float %a) {
+  ret float %a
+}

Modified: polly/trunk/test/GPGPU/libdevice-functions-copied-into-kernel.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/GPGPU/libdevice-functions-copied-into-kernel.ll?rev=311322&r1=311321&r2=311322&view=diff
==============================================================================
--- polly/trunk/test/GPGPU/libdevice-functions-copied-into-kernel.ll (original)
+++ polly/trunk/test/GPGPU/libdevice-functions-copied-into-kernel.ll Mon Aug 21 02:00:31 2017
@@ -20,6 +20,7 @@
 ; Check that the intrinsic call is present in the kernel IR.
 ; KERNEL-IR:   %p_expf = tail call float @__nv_expf(float %A.arr.i.val_p_scalar_)
 ; KERNEL-IR:   %p_cosf = tail call float @__nv_cosf(float %p_expf)
+; KERNEL-IR:   %p_logf = tail call float @__nv_logf(float %p_cosf)
 
 ; Check that kernel launch is generated in host IR.
 ; the declare would not be generated unless a call to a kernel exists.
@@ -29,9 +30,10 @@
 ; void f(float *A, float *B, int N) {
 ;   for(int i = 0; i < N; i++) {
 ;       float tmp0 = A[i];
-;       float tmp1 = expf(tmp1);
-;       tmp1 = cosf(tmp1);
-;       B[i] = tmp1;
+;       float expf  = expf(tmp1);
+;       cosf = cosf(expf);
+;       logf = logf(cosf);
+;       B[i] = logf;
 ;   }
 ; }
 
@@ -55,8 +57,9 @@ for.body:
   ; Call to intrinsics that should be part of the kernel.
   %expf = tail call float @expf(float %A.arr.i.val)
   %cosf = tail call float @cosf(float %expf)
+  %logf = tail call float @logf(float %cosf)
   %B.arr.i = getelementptr inbounds float, float* %B, i64 %indvars.iv
-  store float %expf, float* %B.arr.i, align 4
+  store float %logf, float* %B.arr.i, align 4
 
   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
   %wide.trip.count = zext i32 %N to i64
@@ -73,6 +76,7 @@ for.end:
 ; Function Attrs: nounwind readnone
 declare float @expf(float) #0
 declare float @cosf(float) #0
+declare float @logf(float) #0
 
 attributes #0 = { nounwind readnone }
 




More information about the llvm-commits mailing list