[Libclc-dev] [PATCH 02/11] sqrt: Split function generation to a shared inc file.

Jan Vesely via Libclc-dev libclc-dev at lists.llvm.org
Tue Mar 12 00:56:53 PDT 2019


This will be reused by other functions.
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
 generic/lib/math/sqrt.cl           | 20 ++------------------
 generic/lib/math/unary_builtin.inc | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 18 deletions(-)
 create mode 100644 generic/lib/math/unary_builtin.inc

diff --git a/generic/lib/math/sqrt.cl b/generic/lib/math/sqrt.cl
index b05d6bc..8df25dd 100644
--- a/generic/lib/math/sqrt.cl
+++ b/generic/lib/math/sqrt.cl
@@ -21,23 +21,7 @@
  */
 
 #include <clc/clc.h>
-#include "../clcmacro.h"
 #include "math/clc_sqrt.h"
 
-_CLC_DEFINE_UNARY_BUILTIN(float, sqrt, __clc_sqrt, float)
-
-#ifdef cl_khr_fp64
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-_CLC_DEFINE_UNARY_BUILTIN(double, sqrt, __clc_sqrt, double)
-
-#endif
-
-#ifdef cl_khr_fp16
-
-#pragma OPENCL EXTENSION cl_khr_fp16 : enable
-
-_CLC_DEFINE_UNARY_BUILTIN(half, sqrt, __clc_sqrt, half)
-
-#endif
+#define __CLC_FUNCTION sqrt
+#include "unary_builtin.inc"
diff --git a/generic/lib/math/unary_builtin.inc b/generic/lib/math/unary_builtin.inc
new file mode 100644
index 0000000..4e7ca5b
--- /dev/null
+++ b/generic/lib/math/unary_builtin.inc
@@ -0,0 +1,24 @@
+#include "../clcmacro.h"
+#include "utils.h"
+
+#ifndef __CLC_BUILTIN
+#define __CLC_BUILTIN __CLC_XCONCAT(__clc_, __CLC_FUNCTION)
+#endif
+
+_CLC_DEFINE_UNARY_BUILTIN(float, __CLC_FUNCTION, __CLC_BUILTIN, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_DEFINE_UNARY_BUILTIN(double, __CLC_FUNCTION, __CLC_BUILTIN, double)
+
+#endif
+
+#ifdef cl_khr_fp16
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+_CLC_DEFINE_UNARY_BUILTIN(half, __CLC_FUNCTION, __CLC_BUILTIN, half)
+
+#endif
-- 
2.19.2



More information about the Libclc-dev mailing list