[Libclc-dev] [PATCH] math: Add fmod implementation
Matt Arsenault
Matthew.Arsenault at amd.com
Wed Sep 10 10:17:37 PDT 2014
On 09/10/2014 11:59 AM, Aaron Watry wrote:
> Passes piglit tests on evergreen (sent to piglit list).
>
> Signed-off-by: Aaron Watry <awatry at gmail.com>
> ---
> generic/include/clc/clc.h | 1 +
> generic/include/clc/math/fmod.h | 7 +++++++
> generic/lib/SOURCES | 1 +
> generic/lib/math/fmod.cl | 15 +++++++++++++++
> 4 files changed, 24 insertions(+)
> create mode 100644 generic/include/clc/math/fmod.h
> create mode 100644 generic/lib/math/fmod.cl
>
> diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
> index b8c1cb9..94557a1 100644
> --- a/generic/include/clc/clc.h
> +++ b/generic/include/clc/clc.h
> @@ -47,6 +47,7 @@
> #include <clc/math/fma.h>
> #include <clc/math/fmax.h>
> #include <clc/math/fmin.h>
> +#include <clc/math/fmod.h>
> #include <clc/math/hypot.h>
> #include <clc/math/log.h>
> #include <clc/math/log2.h>
> diff --git a/generic/include/clc/math/fmod.h b/generic/include/clc/math/fmod.h
> new file mode 100644
> index 0000000..737679f
> --- /dev/null
> +++ b/generic/include/clc/math/fmod.h
> @@ -0,0 +1,7 @@
> +#define __CLC_BODY <clc/math/binary_decl.inc>
> +#define __CLC_FUNCTION fmod
> +
> +#include <clc/math/gentype.inc>
> +
> +#undef __CLC_BODY
> +#undef __CLC_FUNCTION
> diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
> index e4ba1d1..45e12aa 100644
> --- a/generic/lib/SOURCES
> +++ b/generic/lib/SOURCES
> @@ -39,6 +39,7 @@ math/exp.cl
> math/exp10.cl
> math/fmax.cl
> math/fmin.cl
> +math/fmod.cl
> math/hypot.cl
> math/mad.cl
> math/mix.cl
> diff --git a/generic/lib/math/fmod.cl b/generic/lib/math/fmod.cl
> new file mode 100644
> index 0000000..091035b
> --- /dev/null
> +++ b/generic/lib/math/fmod.cl
> @@ -0,0 +1,15 @@
> +#include <clc/clc.h>
> +
> +#ifdef cl_khr_fp64
> +#pragma OPENCL EXTENSION cl_khr_fp64 : enable
> +#endif
> +
> +#define FUNCTION fmod
> +#define FUNCTION_IMPL(x, y) ( (x) - (y) * trunc((x) / (y)))
> +
> +#define __CLC_BODY <binary_impl.inc>
> +#include <clc/math/gentype.inc>
> +
> +#undef __CLC_BODY
> +#undef FUNCTION
> +#undef FUNCTION_IMPL
> \ No newline at end of file
I think this can use the LLVM frem instruction instead, and would be
better expanded in the backend. I have most of a patch that expands
ISD::FREM for SI that I forgot about somewhere
More information about the Libclc-dev
mailing list