[Libclc-dev] [PATCH 1/1] Implement trunc builtin.

Tom Stellard tom at stellard.net
Thu Dec 19 18:13:59 PST 2013


On Mon, Dec 16, 2013 at 06:37:16PM -0500, Jan Vesely wrote:
> OpenCL C lang says that trunc rounds towards zero.
> llvm.trunc.* intrinsic rounds to integer not larger in magnitude.
> These definitions are equivalent.
> 

I've committed this, thanks.

-Tom

> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
> 
>  I tested this (with follow up patch to llvm) on AMD Turks, and gegl test 'posterize' that uses trunc passes.
> 
>  generic/include/clc/clc.h        | 1 +
>  generic/include/clc/math/trunc.h | 9 +++++++++
>  2 files changed, 10 insertions(+)
>  create mode 100644 generic/include/clc/math/trunc.h
> 
> diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
> index 8f0dbd3..c14d072 100644
> --- a/generic/include/clc/clc.h
> +++ b/generic/include/clc/clc.h
> @@ -51,6 +51,7 @@
>  #include <clc/math/round.h>
>  #include <clc/math/sin.h>
>  #include <clc/math/sqrt.h>
> +#include <clc/math/trunc.h>
>  #include <clc/math/native_cos.h>
>  #include <clc/math/native_divide.h>
>  #include <clc/math/native_exp.h>
> diff --git a/generic/include/clc/math/trunc.h b/generic/include/clc/math/trunc.h
> new file mode 100644
> index 0000000..d34f661
> --- /dev/null
> +++ b/generic/include/clc/math/trunc.h
> @@ -0,0 +1,9 @@
> +#undef trunc
> +#define trunc __clc_trunc
> +
> +#define __CLC_FUNCTION __clc_trunc
> +#define __CLC_INTRINSIC "llvm.trunc"
> +#include <clc/math/unary_intrin.inc>
> +
> +#undef __CLC_FUNCTION
> +#undef __CLC_INTRINSIC
> -- 
> 1.8.3.1
> 
> 
> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at pcc.me.uk
> http://www.pcc.me.uk/cgi-bin/mailman/listinfo/libclc-dev




More information about the Libclc-dev mailing list