[libclc] [libclc] Move ceil/fabs/floor/rint/trunc to CLC library (PR #114774)

Fraser Cormack via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 4 03:15:56 PST 2024


https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/114774

>From 625b491279f81dc9b55e80bf422d0e15f44f02bb Mon Sep 17 00:00:00 2001
From: Fraser Cormack <fraser at codeplay.com>
Date: Thu, 31 Oct 2024 13:11:00 +0000
Subject: [PATCH] [libclc] Move ceil/fabs/floor/rint/trunc to CLC library

These functions are all mapped to LLVM intrinsics.

The clspv and spirv targets don't declare or define any of these CLC
functions, and instead map these to their corresponding OpenCL symbols.
---
 libclc/clc/include/clc/math/clc_ceil.h        | 19 +++++++++++++++++++
 libclc/clc/include/clc/math/clc_fabs.h        | 19 +++++++++++++++++++
 libclc/clc/include/clc/math/clc_floor.h       | 19 +++++++++++++++++++
 libclc/clc/include/clc/math/clc_rint.h        | 19 +++++++++++++++++++
 libclc/clc/include/clc/math/clc_trunc.h       | 19 +++++++++++++++++++
 .../include/clc/math/unary_decl.inc           |  0
 .../include/clc}/math/unary_intrin.inc        |  8 +++++---
 libclc/clc/include/clc/utils.h                | 10 ++++++++++
 libclc/generic/lib/clcmacro.h                 |  1 +
 libclc/generic/lib/math/ceil.cl               |  8 ++------
 libclc/generic/lib/math/clc_fmod.cl           |  6 ++++--
 libclc/generic/lib/math/clc_pow.cl            |  3 ++-
 libclc/generic/lib/math/clc_pown.cl           |  3 ++-
 libclc/generic/lib/math/clc_powr.cl           |  3 ++-
 libclc/generic/lib/math/clc_remainder.cl      |  6 ++++--
 libclc/generic/lib/math/clc_remquo.cl         |  6 ++++--
 libclc/generic/lib/math/clc_rootn.cl          |  3 ++-
 libclc/generic/lib/math/clc_sqrt.cl           |  2 +-
 libclc/generic/lib/math/clc_tan.cl            |  4 +++-
 libclc/generic/lib/math/fabs.cl               |  8 ++------
 libclc/generic/lib/math/floor.cl              |  8 ++------
 .../lib/math/native_unary_intrinsic.inc       |  2 +-
 libclc/generic/lib/math/rint.cl               |  6 +-----
 libclc/generic/lib/math/round.cl              |  2 +-
 libclc/generic/lib/math/trunc.cl              |  6 +-----
 25 files changed, 145 insertions(+), 45 deletions(-)
 create mode 100644 libclc/clc/include/clc/math/clc_ceil.h
 create mode 100644 libclc/clc/include/clc/math/clc_fabs.h
 create mode 100644 libclc/clc/include/clc/math/clc_floor.h
 create mode 100644 libclc/clc/include/clc/math/clc_rint.h
 create mode 100644 libclc/clc/include/clc/math/clc_trunc.h
 rename libclc/{generic => clc}/include/clc/math/unary_decl.inc (100%)
 rename libclc/{generic/include => clc/include/clc}/math/unary_intrin.inc (88%)
 create mode 100644 libclc/clc/include/clc/utils.h

diff --git a/libclc/clc/include/clc/math/clc_ceil.h b/libclc/clc/include/clc/math/clc_ceil.h
new file mode 100644
index 00000000000000..66590687c34220
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_ceil.h
@@ -0,0 +1,19 @@
+#ifndef __CLC_MATH_CLC_CEIL_H__
+#define __CLC_MATH_CLC_CEIL_H__
+
+#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
+// clspv and spir-v targets provide their own OpenCL-compatible ceil
+#define __clc_ceil ceil
+#else
+
+// Map the function to an LLVM intrinsic
+#define __CLC_FUNCTION __clc_ceil
+#define __CLC_INTRINSIC "llvm.ceil"
+#include <clc/math/unary_intrin.inc>
+
+#undef __CLC_INTRINSIC
+#undef __CLC_FUNCTION
+
+#endif
+
+#endif // __CLC_MATH_CLC_CEIL_H__
diff --git a/libclc/clc/include/clc/math/clc_fabs.h b/libclc/clc/include/clc/math/clc_fabs.h
new file mode 100644
index 00000000000000..93367b57313713
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_fabs.h
@@ -0,0 +1,19 @@
+#ifndef __CLC_MATH_CLC_FABS_H__
+#define __CLC_MATH_CLC_FABS_H__
+
+#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
+// clspv and spir-v targets provide their own OpenCL-compatible fabs
+#define __clc_fabs fabs
+#else
+
+// Map the function to an LLVM intrinsic
+#define __CLC_FUNCTION __clc_fabs
+#define __CLC_INTRINSIC "llvm.fabs"
+#include <clc/math/unary_intrin.inc>
+
+#undef __CLC_INTRINSIC
+#undef __CLC_FUNCTION
+
+#endif
+
+#endif // __CLC_MATH_CLC_FABS_H__
diff --git a/libclc/clc/include/clc/math/clc_floor.h b/libclc/clc/include/clc/math/clc_floor.h
new file mode 100644
index 00000000000000..9919872ec633c6
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_floor.h
@@ -0,0 +1,19 @@
+#ifndef __CLC_MATH_CLC_FLOOR_H__
+#define __CLC_MATH_CLC_FLOOR_H__
+
+#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
+// clspv and spir-v targets provide their own OpenCL-compatible floor
+#define __clc_floor floor
+#else
+
+// Map the function to an LLVM intrinsic
+#define __CLC_FUNCTION __clc_floor
+#define __CLC_INTRINSIC "llvm.floor"
+#include <clc/math/unary_intrin.inc>
+
+#undef __CLC_INTRINSIC
+#undef __CLC_FUNCTION
+
+#endif
+
+#endif // __CLC_MATH_CLC_FLOOR_H__
diff --git a/libclc/clc/include/clc/math/clc_rint.h b/libclc/clc/include/clc/math/clc_rint.h
new file mode 100644
index 00000000000000..3761407ad326d7
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_rint.h
@@ -0,0 +1,19 @@
+#ifndef __CLC_MATH_CLC_RINT_H__
+#define __CLC_MATH_CLC_RINT_H__
+
+#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
+// clspv and spir-v targets provide their own OpenCL-compatible rint
+#define __clc_rint rint
+#else
+
+// Map the function to an LLVM intrinsic
+#define __CLC_FUNCTION __clc_rint
+#define __CLC_INTRINSIC "llvm.rint"
+#include <clc/math/unary_intrin.inc>
+
+#undef __CLC_INTRINSIC
+#undef __CLC_FUNCTION
+
+#endif
+
+#endif // __CLC_MATH_CLC_RINT_H__
diff --git a/libclc/clc/include/clc/math/clc_trunc.h b/libclc/clc/include/clc/math/clc_trunc.h
new file mode 100644
index 00000000000000..c78c8899d85238
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_trunc.h
@@ -0,0 +1,19 @@
+#ifndef __CLC_MATH_CLC_TRUNC_H__
+#define __CLC_MATH_CLC_TRUNC_H__
+
+#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
+// clspv and spir-v targets provide their own OpenCL-compatible trunc
+#define __clc_trunc trunc
+#else
+
+// Map the function to an LLVM intrinsic
+#define __CLC_FUNCTION __clc_trunc
+#define __CLC_INTRINSIC "llvm.trunc"
+#include <clc/math/unary_intrin.inc>
+
+#undef __CLC_INTRINSIC
+#undef __CLC_FUNCTION
+
+#endif
+
+#endif // __CLC_MATH_CLC_TRUNC_H__
diff --git a/libclc/generic/include/clc/math/unary_decl.inc b/libclc/clc/include/clc/math/unary_decl.inc
similarity index 100%
rename from libclc/generic/include/clc/math/unary_decl.inc
rename to libclc/clc/include/clc/math/unary_decl.inc
diff --git a/libclc/generic/include/math/unary_intrin.inc b/libclc/clc/include/clc/math/unary_intrin.inc
similarity index 88%
rename from libclc/generic/include/math/unary_intrin.inc
rename to libclc/clc/include/clc/math/unary_intrin.inc
index 532bb1f9d26158..c331d3ff08a61d 100644
--- a/libclc/generic/include/math/unary_intrin.inc
+++ b/libclc/clc/include/clc/math/unary_intrin.inc
@@ -3,7 +3,8 @@ _CLC_OVERLOAD float2 __CLC_FUNCTION(float2 f) __asm(__CLC_INTRINSIC ".v2f32");
 _CLC_OVERLOAD float3 __CLC_FUNCTION(float3 f) __asm(__CLC_INTRINSIC ".v3f32");
 _CLC_OVERLOAD float4 __CLC_FUNCTION(float4 f) __asm(__CLC_INTRINSIC ".v4f32");
 _CLC_OVERLOAD float8 __CLC_FUNCTION(float8 f) __asm(__CLC_INTRINSIC ".v8f32");
-_CLC_OVERLOAD float16 __CLC_FUNCTION(float16 f) __asm(__CLC_INTRINSIC ".v16f32");
+_CLC_OVERLOAD float16 __CLC_FUNCTION(float16 f) __asm(__CLC_INTRINSIC
+                                                      ".v16f32");
 
 #ifdef cl_khr_fp64
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
@@ -12,11 +13,12 @@ _CLC_OVERLOAD double2 __CLC_FUNCTION(double2 d) __asm(__CLC_INTRINSIC ".v2f64");
 _CLC_OVERLOAD double3 __CLC_FUNCTION(double3 d) __asm(__CLC_INTRINSIC ".v3f64");
 _CLC_OVERLOAD double4 __CLC_FUNCTION(double4 d) __asm(__CLC_INTRINSIC ".v4f64");
 _CLC_OVERLOAD double8 __CLC_FUNCTION(double8 d) __asm(__CLC_INTRINSIC ".v8f64");
-_CLC_OVERLOAD double16 __CLC_FUNCTION(double16 d) __asm(__CLC_INTRINSIC ".v16f64");
+_CLC_OVERLOAD double16 __CLC_FUNCTION(double16 d) __asm(__CLC_INTRINSIC
+                                                        ".v16f64");
 #endif
 
 #ifdef cl_khr_fp16
-#pragma OPENCL EXTENSION cl_khr_fp16: enable
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 _CLC_OVERLOAD half __CLC_FUNCTION(half d) __asm(__CLC_INTRINSIC ".f16");
 _CLC_OVERLOAD half2 __CLC_FUNCTION(half2 d) __asm(__CLC_INTRINSIC ".v2f16");
 _CLC_OVERLOAD half3 __CLC_FUNCTION(half3 d) __asm(__CLC_INTRINSIC ".v3f16");
diff --git a/libclc/clc/include/clc/utils.h b/libclc/clc/include/clc/utils.h
new file mode 100644
index 00000000000000..b53b6a39c615c1
--- /dev/null
+++ b/libclc/clc/include/clc/utils.h
@@ -0,0 +1,10 @@
+#ifndef __CLC_UTILS_H__
+#define __CLC_UTILS_H__
+
+#define __CLC_CONCAT(x, y) x##y
+#define __CLC_XCONCAT(x, y) __CLC_CONCAT(x, y)
+
+#define __CLC_STR(x) #x
+#define __CLC_XSTR(x) __CLC_STR(x)
+
+#endif // __CLC_UTILS_H__
diff --git a/libclc/generic/lib/clcmacro.h b/libclc/generic/lib/clcmacro.h
index f655368967c9ee..fa302b398adc68 100644
--- a/libclc/generic/lib/clcmacro.h
+++ b/libclc/generic/lib/clcmacro.h
@@ -1,3 +1,4 @@
+#include <clc/clc.h>
 #include <utils.h>
 
 #define _CLC_UNARY_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE) \
diff --git a/libclc/generic/lib/math/ceil.cl b/libclc/generic/lib/math/ceil.cl
index 9f7154c6e6e477..68240892ee1e32 100644
--- a/libclc/generic/lib/math/ceil.cl
+++ b/libclc/generic/lib/math/ceil.cl
@@ -1,10 +1,6 @@
-#include <clc/clc.h>
 #include "../clcmacro.h"
-
-// Map the llvm intrinsic to an OpenCL function.
-#define __CLC_FUNCTION __clc_ceil
-#define __CLC_INTRINSIC "llvm.ceil"
-#include "math/unary_intrin.inc"
+#include <clc/clc.h>
+#include <clc/math/clc_ceil.h>
 
 #undef __CLC_FUNCTION
 #define __CLC_FUNCTION ceil
diff --git a/libclc/generic/lib/math/clc_fmod.cl b/libclc/generic/lib/math/clc_fmod.cl
index ea9f0e47e7aa0c..c167dc893942ca 100644
--- a/libclc/generic/lib/math/clc_fmod.cl
+++ b/libclc/generic/lib/math/clc_fmod.cl
@@ -21,6 +21,8 @@
  */
 
 #include <clc/clc.h>
+#include <clc/math/clc_floor.h>
+#include <clc/math/clc_trunc.h>
 
 #include <math/clc_remainder.h>
 #include "../clcmacro.h"
@@ -119,7 +121,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_fmod(double x, double y)
 
     for (i = 0; i < ntimes; i++) {
         // Compute integral multiplier
-        t = trunc(dx / w);
+        t = __clc_trunc(dx / w);
 
         // Compute w * t in quad precision
         p = w * t;
@@ -138,7 +140,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_fmod(double x, double y)
 
     // One more time
     // Variable todd says whether the integer t is odd or not
-    t = floor(dx / w);
+    t = __clc_floor(dx / w);
     long lt = (long)t;
     int todd = lt & 1;
 
diff --git a/libclc/generic/lib/math/clc_pow.cl b/libclc/generic/lib/math/clc_pow.cl
index 02063a2e6b3e59..a41ca2bc1a761c 100644
--- a/libclc/generic/lib/math/clc_pow.cl
+++ b/libclc/generic/lib/math/clc_pow.cl
@@ -21,6 +21,7 @@
  */
 
 #include <clc/clc.h>
+#include <clc/math/clc_fabs.h>
 
 #include "config.h"
 #include "math.h"
@@ -80,7 +81,7 @@ _CLC_DEF _CLC_OVERLOAD float __clc_pow(float x, float y)
      *  First handle case that x is close to 1
      */
     float r = 1.0f - as_float(ax);
-    int near1 = fabs(r) < 0x1.0p-4f;
+    int near1 = __clc_fabs(r) < 0x1.0p-4f;
     float r2 = r*r;
 
     /* Coefficients are just 1/3, 1/4, 1/5 and 1/6 */
diff --git a/libclc/generic/lib/math/clc_pown.cl b/libclc/generic/lib/math/clc_pown.cl
index 1a1e2acec6eda5..84668dc0abbb95 100644
--- a/libclc/generic/lib/math/clc_pown.cl
+++ b/libclc/generic/lib/math/clc_pown.cl
@@ -21,6 +21,7 @@
  */
 
 #include <clc/clc.h>
+#include <clc/math/clc_fabs.h>
 
 #include "config.h"
 #include "math.h"
@@ -78,7 +79,7 @@ _CLC_DEF _CLC_OVERLOAD float __clc_pown(float x, int ny)
     // Extra precise log calculation
     // First handle case that x is close to 1
     float r = 1.0f - as_float(ax);
-    int near1 = fabs(r) < 0x1.0p-4f;
+    int near1 = __clc_fabs(r) < 0x1.0p-4f;
     float r2 = r*r;
 
     // Coefficients are just 1/3, 1/4, 1/5 and 1/6
diff --git a/libclc/generic/lib/math/clc_powr.cl b/libclc/generic/lib/math/clc_powr.cl
index ef97d3c322bd6b..a67d524c7a6bb9 100644
--- a/libclc/generic/lib/math/clc_powr.cl
+++ b/libclc/generic/lib/math/clc_powr.cl
@@ -21,6 +21,7 @@
  */
 
 #include <clc/clc.h>
+#include <clc/math/clc_fabs.h>
 
 #include "config.h"
 #include "math.h"
@@ -76,7 +77,7 @@ _CLC_DEF _CLC_OVERLOAD float __clc_powr(float x, float y)
     // Extra precise log calculation
     // First handle case that x is close to 1
     float r = 1.0f - as_float(ax);
-    int near1 = fabs(r) < 0x1.0p-4f;
+    int near1 = __clc_fabs(r) < 0x1.0p-4f;
     float r2 = r*r;
 
     // Coefficients are just 1/3, 1/4, 1/5 and 1/6
diff --git a/libclc/generic/lib/math/clc_remainder.cl b/libclc/generic/lib/math/clc_remainder.cl
index ba50ee345191dc..2275ff0c0e701d 100644
--- a/libclc/generic/lib/math/clc_remainder.cl
+++ b/libclc/generic/lib/math/clc_remainder.cl
@@ -21,6 +21,8 @@
  */
 
 #include <clc/clc.h>
+#include <clc/math/clc_floor.h>
+#include <clc/math/clc_trunc.h>
 
 #include <math/clc_remainder.h>
 #include "../clcmacro.h"
@@ -129,7 +131,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_remainder(double x, double y)
 
     for (i = 0; i < ntimes; i++) {
         // Compute integral multiplier
-        t = trunc(dx / w);
+        t = __clc_trunc(dx / w);
 
         // Compute w * t in quad precision
         p = w * t;
@@ -148,7 +150,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_remainder(double x, double y)
 
     // One more time
     // Variable todd says whether the integer t is odd or not
-    t = floor(dx / w);
+    t = __clc_floor(dx / w);
     long lt = (long)t;
     int todd = lt & 1;
 
diff --git a/libclc/generic/lib/math/clc_remquo.cl b/libclc/generic/lib/math/clc_remquo.cl
index edf4422610f4f5..1ece44e93f28ea 100644
--- a/libclc/generic/lib/math/clc_remquo.cl
+++ b/libclc/generic/lib/math/clc_remquo.cl
@@ -21,6 +21,8 @@
  */
 
 #include <clc/clc.h>
+#include <clc/math/clc_floor.h>
+#include <clc/math/clc_trunc.h>
 
 #include <math/clc_remainder.h>
 #include "../clcmacro.h"
@@ -154,7 +156,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_remquo(double x, double y, __private int *pq
 
     for (i = 0; i < ntimes; i++) {
         // Compute integral multiplier
-        t = trunc(dx / w);
+        t = __clc_trunc(dx / w);
 
         // Compute w * t in quad precision
         p = w * t;
@@ -173,7 +175,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_remquo(double x, double y, __private int *pq
 
     // One more time
     // Variable todd says whether the integer t is odd or not
-    t = floor(dx / w);
+    t = __clc_floor(dx / w);
     long lt = (long)t;
     int todd = lt & 1;
 
diff --git a/libclc/generic/lib/math/clc_rootn.cl b/libclc/generic/lib/math/clc_rootn.cl
index 040b614f5feb4c..e27356b77d8686 100644
--- a/libclc/generic/lib/math/clc_rootn.cl
+++ b/libclc/generic/lib/math/clc_rootn.cl
@@ -21,6 +21,7 @@
  */
 
 #include <clc/clc.h>
+#include <clc/math/clc_fabs.h>
 
 #include "config.h"
 #include "math.h"
@@ -78,7 +79,7 @@ _CLC_DEF _CLC_OVERLOAD float __clc_rootn(float x, int ny)
     // Extra precise log calculation
     // First handle case that x is close to 1
     float r = 1.0f - as_float(ax);
-    int near1 = fabs(r) < 0x1.0p-4f;
+    int near1 = __clc_fabs(r) < 0x1.0p-4f;
     float r2 = r*r;
 
     // Coefficients are just 1/3, 1/4, 1/5 and 1/6
diff --git a/libclc/generic/lib/math/clc_sqrt.cl b/libclc/generic/lib/math/clc_sqrt.cl
index 14a48aa82f23e5..92c7f6e73b11ee 100644
--- a/libclc/generic/lib/math/clc_sqrt.cl
+++ b/libclc/generic/lib/math/clc_sqrt.cl
@@ -25,7 +25,7 @@
 // Map the llvm sqrt intrinsic to an OpenCL function.
 #define __CLC_FUNCTION __clc_llvm_intr_sqrt
 #define __CLC_INTRINSIC "llvm.sqrt"
-#include <math/unary_intrin.inc>
+#include <clc/math/unary_intrin.inc>
 #undef __CLC_FUNCTION
 #undef __CLC_INTRINSIC
 
diff --git a/libclc/generic/lib/math/clc_tan.cl b/libclc/generic/lib/math/clc_tan.cl
index 36e5fe55219351..29b0369ceb142d 100644
--- a/libclc/generic/lib/math/clc_tan.cl
+++ b/libclc/generic/lib/math/clc_tan.cl
@@ -20,6 +20,7 @@
  * THE SOFTWARE.
  */
 #include <clc/clc.h>
+#include <clc/math/clc_fabs.h>
 
 #include "math.h"
 #include "sincos_helpers.h"
@@ -48,7 +49,7 @@ _CLC_UNARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_tan, float);
 #include "sincosD_piby4.h"
 
 _CLC_DEF _CLC_OVERLOAD double __clc_tan(double x) {
-  double y = fabs(x);
+  double y = __clc_fabs(x);
 
   double r, rr;
   int regn;
@@ -66,4 +67,5 @@ _CLC_DEF _CLC_OVERLOAD double __clc_tan(double x) {
   return isnan(x) || isinf(x) ? as_double(QNANBITPATT_DP64) : as_double(t);
 }
 _CLC_UNARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, double, __clc_tan, double);
+
 #endif
diff --git a/libclc/generic/lib/math/fabs.cl b/libclc/generic/lib/math/fabs.cl
index 0a7037088b2e7f..888c01d9e231de 100644
--- a/libclc/generic/lib/math/fabs.cl
+++ b/libclc/generic/lib/math/fabs.cl
@@ -1,10 +1,6 @@
-#include <clc/clc.h>
 #include "../clcmacro.h"
-
-// Map the llvm intrinsic to an OpenCL function.
-#define __CLC_FUNCTION __clc_fabs
-#define __CLC_INTRINSIC "llvm.fabs"
-#include "math/unary_intrin.inc"
+#include <clc/clc.h>
+#include <clc/math/clc_fabs.h>
 
 #undef __CLC_FUNCTION
 #define __CLC_FUNCTION fabs
diff --git a/libclc/generic/lib/math/floor.cl b/libclc/generic/lib/math/floor.cl
index de215e437474b1..2d7ec4182f4855 100644
--- a/libclc/generic/lib/math/floor.cl
+++ b/libclc/generic/lib/math/floor.cl
@@ -1,10 +1,6 @@
-#include <clc/clc.h>
 #include "../clcmacro.h"
-
-// Map the llvm intrinsic to an OpenCL function.
-#define __CLC_FUNCTION __clc_floor
-#define __CLC_INTRINSIC "llvm.floor"
-#include "math/unary_intrin.inc"
+#include <clc/clc.h>
+#include <clc/math/clc_floor.h>
 
 #undef __CLC_FUNCTION
 #define __CLC_FUNCTION floor
diff --git a/libclc/generic/lib/math/native_unary_intrinsic.inc b/libclc/generic/lib/math/native_unary_intrinsic.inc
index 5640141ed61936..dbea2882a128ec 100644
--- a/libclc/generic/lib/math/native_unary_intrinsic.inc
+++ b/libclc/generic/lib/math/native_unary_intrinsic.inc
@@ -27,7 +27,7 @@
 #define __CLC_INTRINSIC "llvm." __CLC_XSTR(__CLC_NATIVE_INTRINSIC)
 
 #undef cl_khr_fp64
-#include <math/unary_intrin.inc>
+#include <clc/math/unary_intrin.inc>
 
 #endif
 
diff --git a/libclc/generic/lib/math/rint.cl b/libclc/generic/lib/math/rint.cl
index 5d9f4b119af85e..185bbbbf8c91d2 100644
--- a/libclc/generic/lib/math/rint.cl
+++ b/libclc/generic/lib/math/rint.cl
@@ -1,9 +1,5 @@
 #include <clc/clc.h>
-
-// Map the llvm intrinsic to an OpenCL function.
-#define __CLC_FUNCTION __clc_rint
-#define __CLC_INTRINSIC "llvm.rint"
-#include "math/unary_intrin.inc"
+#include <clc/math/clc_rint.h>
 
 #undef __CLC_FUNCTION
 #define __CLC_FUNCTION rint
diff --git a/libclc/generic/lib/math/round.cl b/libclc/generic/lib/math/round.cl
index 17c72c985fef97..285328aaa5d563 100644
--- a/libclc/generic/lib/math/round.cl
+++ b/libclc/generic/lib/math/round.cl
@@ -3,7 +3,7 @@
 // Map the llvm intrinsic to an OpenCL function.
 #define __CLC_FUNCTION __clc_round
 #define __CLC_INTRINSIC "llvm.round"
-#include "math/unary_intrin.inc"
+#include <clc/math/unary_intrin.inc>
 
 #undef __CLC_FUNCTION
 #define __CLC_FUNCTION round
diff --git a/libclc/generic/lib/math/trunc.cl b/libclc/generic/lib/math/trunc.cl
index 62c7b18bdaa704..00c2a4a80015fe 100644
--- a/libclc/generic/lib/math/trunc.cl
+++ b/libclc/generic/lib/math/trunc.cl
@@ -1,9 +1,5 @@
 #include <clc/clc.h>
-
-// Map the llvm intrinsic to an OpenCL function.
-#define __CLC_FUNCTION __clc_trunc
-#define __CLC_INTRINSIC "llvm.trunc"
-#include "math/unary_intrin.inc"
+#include <clc/math/clc_trunc.h>
 
 #undef __CLC_FUNCTION
 #define __CLC_FUNCTION trunc



More information about the cfe-commits mailing list