summaryrefslogtreecommitdiff
path: root/src/kernels/common.opencl
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2016-09-13 21:14:51 +0200
committerGitHub <noreply@github.com>2016-09-13 21:14:51 +0200
commitf07ac22f5b57d22756d779d2e53620f988d786ee (patch)
treee8bcbc331683ca6fd807f5a5b83bb05c6e6fed69 /src/kernels/common.opencl
parent7c13bacf129291e3e295ecb6e833788477085fa0 (diff)
parent4b94afda941a86f363064ff02f97e21eb9618794 (diff)
Merge pull request #99 from CNugteren/development
Update to version 0.9.0
Diffstat (limited to 'src/kernels/common.opencl')
-rw-r--r--src/kernels/common.opencl17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/kernels/common.opencl b/src/kernels/common.opencl
index 08c47d87..223501fd 100644
--- a/src/kernels/common.opencl
+++ b/src/kernels/common.opencl
@@ -109,6 +109,16 @@ R"(
typedef real singlereal;
#endif
+// Converts a 'real argument' value to a 'real' value as passed to the kernel. Normally there is no
+// conversion, but half-precision is not supported as kernel argument so it is converted from float.
+#if PRECISION == 16
+ typedef float real_arg;
+ #define GetRealArg(x) (half)x
+#else
+ typedef real real_arg;
+ #define GetRealArg(x) x
+#endif
+
// =================================================================================================
// Don't use the non-IEEE754 compliant OpenCL built-in mad() instruction per default. For specific
@@ -138,6 +148,13 @@ R"(
#define SetToOne(a) a = ONE
#endif
+// Determines whether a variable is zero
+#if PRECISION == 3232 || PRECISION == 6464
+ #define IsZero(a) ((a.x == ZERO) && (a.y == ZERO))
+#else
+ #define IsZero(a) (a == ZERO)
+#endif
+
// The absolute value (component-wise)
#if PRECISION == 3232 || PRECISION == 6464
#define AbsoluteValue(value) value.x = fabs(value.x); value.y = fabs(value.y)