[Libclc-dev] [PATCH v2 1/1] math: Don't use llvm instrinsic for native_log

Jan Vesely via Libclc-dev libclc-dev at lists.llvm.org
Sun Oct 1 10:05:43 PDT 2017


On Sun, 2017-10-01 at 16:25 +0000, Arsenault, Matthew wrote:
> It's still better because the point of using the intrinsics is the
> algebraic optimizations that apply to them

Are there optimizations that would apply to log and not log2?
I'd expect exposing the constant early would be beneficial to
optimization.

I don't mind changing this to:
#if _clang_major_ > 6
	return __clc_native_log(val);
#else
	return native_log2(val) * (1.0f / M_LOG2E_F);
#endif

when Vedran's patch lands.

Jan

> 
> ________________________________
> From: Libclc-dev <libclc-dev-bounces at lists.llvm.org> on behalf of Jan Vesely via Libclc-dev <libclc-dev at lists.llvm.org>
> Sent: Wednesday, September 27, 2017 12:34:26 PM
> To: libclc-dev at lists.llvm.org
> Subject: [Libclc-dev] [PATCH v2 1/1] math: Don't use llvm instrinsic for native_log
> 
> AMDGPU targets don't have insturction for it,
> so it'll be expanded to C * log2 anyway.
> 
> v2: use native_log2 instead of the more precise sw implementation
> 
> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
>  generic/lib/math/native_log.cl  | 5 -----
>  generic/lib/math/native_log.inc | 2 +-
>  2 files changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/generic/lib/math/native_log.cl b/generic/lib/math/native_log.cl
> index f64f012..f8ba08f 100644
> --- a/generic/lib/math/native_log.cl
> +++ b/generic/lib/math/native_log.cl
> @@ -22,11 +22,6 @@
> 
>  #include <clc/clc.h>
> 
> -#define __CLC_FUNCTION __clc_native_log
> -#define __CLC_INTRINSIC "llvm.log"
> -#undef cl_khr_fp64
> -#include <clc/math/unary_intrin.inc>
> -
>  #define __CLC_BODY <native_log.inc>
>  #define __FLOAT_ONLY
>  #include <clc/math/gentype.inc>
> diff --git a/generic/lib/math/native_log.inc b/generic/lib/math/native_log.inc
> index cb4db3f..d4950c2 100644
> --- a/generic/lib/math/native_log.inc
> +++ b/generic/lib/math/native_log.inc
> @@ -21,5 +21,5 @@
>   */
> 
>  _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_log(__CLC_GENTYPE val) {
> -  return __clc_native_log(val);
> +  return native_log2(val) * (1.0f / M_LOG2E_F);
>  }
> --
> 2.13.5
> 
> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/libclc-dev

-- 
Jan Vesely <jan.vesely at rutgers.edu>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/libclc-dev/attachments/20171001/91dc839f/attachment.sig>


More information about the Libclc-dev mailing list