diff options
author | Aaron Watry <awatry@gmail.com> | 2013-03-20 17:48:04 -0500 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2013-04-08 07:12:54 -0700 |
commit | e07aecc393c93298e68157cb8c14e1e76e046e3b (patch) | |
tree | 66dbfba952ff50ced65f86c4377981b2f5584622 | |
parent | e8551666607a377420ecf3a4ec7e9dbf4114ec62 (diff) |
libclc: Add clamp() builtin for integer/floating point
Created under a new shared/ directory for functions which are available for
both integer and floating point types.
-rw-r--r-- | generic/include/clc/clc.h | 3 | ||||
-rw-r--r-- | generic/include/clc/shared/clamp.h | 5 | ||||
-rw-r--r-- | generic/include/clc/shared/clamp.inc | 1 | ||||
-rw-r--r-- | generic/lib/SOURCES | 1 | ||||
-rw-r--r-- | generic/lib/shared/clamp.cl | 11 | ||||
-rw-r--r-- | generic/lib/shared/clamp.inc | 3 |
6 files changed, 24 insertions, 0 deletions
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h index f6668a3..80ecd01 100644 --- a/generic/include/clc/clc.h +++ b/generic/include/clc/clc.h @@ -67,6 +67,9 @@ #include <clc/integer/max.h> #include <clc/integer/sub_sat.h> +/* 6.11.2 and 6.11.3 Shared Integer/Math Functions */ +#include <clc/shared/clamp.h> + /* 6.11.5 Geometric Functions */ #include <clc/geometric/cross.h> #include <clc/geometric/dot.h> diff --git a/generic/include/clc/shared/clamp.h b/generic/include/clc/shared/clamp.h new file mode 100644 index 0000000..5c2ebd0 --- /dev/null +++ b/generic/include/clc/shared/clamp.h @@ -0,0 +1,5 @@ +#define BODY <clc/shared/clamp.inc> +#include <clc/integer/gentype.inc> + +#define BODY <clc/shared/clamp.inc> +#include <clc/math/gentype.inc> diff --git a/generic/include/clc/shared/clamp.inc b/generic/include/clc/shared/clamp.inc new file mode 100644 index 0000000..3e3a435 --- /dev/null +++ b/generic/include/clc/shared/clamp.inc @@ -0,0 +1 @@ +_CLC_OVERLOAD _CLC_DECL GENTYPE clamp(GENTYPE x, GENTYPE y, GENTYPE z); diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES index a97213b..0d477ba 100644 --- a/generic/lib/SOURCES +++ b/generic/lib/SOURCES @@ -18,5 +18,6 @@ math/hypot.cl math/mad.cl math/max.cl relational/any.cl +shared/clamp.cl workitem/get_global_id.cl workitem/get_global_size.cl diff --git a/generic/lib/shared/clamp.cl b/generic/lib/shared/clamp.cl new file mode 100644 index 0000000..0e8d223 --- /dev/null +++ b/generic/lib/shared/clamp.cl @@ -0,0 +1,11 @@ +#include <clc/clc.h> + +#define BODY <clamp.inc> +#include <clc/integer/gentype.inc> + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#endif + +#define BODY <clamp.inc> +#include <clc/math/gentype.inc> diff --git a/generic/lib/shared/clamp.inc b/generic/lib/shared/clamp.inc new file mode 100644 index 0000000..ed49b8e --- /dev/null +++ b/generic/lib/shared/clamp.inc @@ -0,0 +1,3 @@ +_CLC_OVERLOAD _CLC_DEF GENTYPE clamp(GENTYPE x, GENTYPE y, GENTYPE z) { + return (x > z ? z : (x < y ? y : x)); +} |