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

Aaron Watry via Libclc-dev libclc-dev at lists.llvm.org
Mon Oct 23 18:12:01 PDT 2017


On Wed, Oct 11, 2017 at 10:36 PM, Jan Vesely via Libclc-dev
<libclc-dev at lists.llvm.org> wrote:
> 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
> v3: move to amdgpu
>
> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
>  amdgpu/lib/SOURCES             |  1 +
>  amdgpu/lib/math/native_log.cl  | 27 +++++++++++++++++++++++++++
>  amdgpu/lib/math/native_log.inc | 25 +++++++++++++++++++++++++
>  3 files changed, 53 insertions(+)
>  create mode 100644 amdgpu/lib/math/native_log.cl
>  create mode 100644 amdgpu/lib/math/native_log.inc
>
> diff --git a/amdgpu/lib/SOURCES b/amdgpu/lib/SOURCES
> index ce5fe66..8cbe1d4 100644
> --- a/amdgpu/lib/SOURCES
> +++ b/amdgpu/lib/SOURCES
> @@ -1,2 +1,3 @@
> +math/native_log.cl
>  math/nextafter.cl
>  math/sqrt.cl
> diff --git a/amdgpu/lib/math/native_log.cl b/amdgpu/lib/math/native_log.cl
> new file mode 100644
> index 0000000..f8ba08f
> --- /dev/null
> +++ b/amdgpu/lib/math/native_log.cl
> @@ -0,0 +1,27 @@
> +/*
> + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +#include <clc/clc.h>
> +
> +#define __CLC_BODY <native_log.inc>
> +#define __FLOAT_ONLY
> +#include <clc/math/gentype.inc>
> diff --git a/amdgpu/lib/math/native_log.inc b/amdgpu/lib/math/native_log.inc
> new file mode 100644
> index 0000000..d4950c2
> --- /dev/null
> +++ b/amdgpu/lib/math/native_log.inc
> @@ -0,0 +1,25 @@
> +/*
> + * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +
> +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_log(__CLC_GENTYPE val) {
> +  return native_log2(val) * (1.0f / M_LOG2E_F);

Looks ok to me.

But similar to the other patch in this 2-part series, you can probably
exclude the AMD copyright statement since you're the author here.

--Aaron

> +}
> --
> 2.13.6
>
> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/libclc-dev


More information about the Libclc-dev mailing list