mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 23:49:22 +08:00
[libclc] Implement clc_log/sinpi/sqrt with __nv_* functions (#150174)
This is to upstream implementations in https://github.com/intel/llvm/tree/sycl/libclc/clc/lib/ptx-nvidiacl/math
This commit is contained in:
@@ -80,6 +80,7 @@
|
||||
#define __CLC_U_GENTYPE __CLC_XCONCAT(uint, __CLC_VECSIZE)
|
||||
|
||||
#define __CLC_GENTYPE float
|
||||
#define __CLC_BIT_INT int
|
||||
#define __CLC_BIT_INTN int
|
||||
#define __CLC_SCALAR
|
||||
#define __CLC_VECSIZE
|
||||
@@ -131,6 +132,7 @@
|
||||
#include __CLC_BODY
|
||||
#undef __CLC_VECSIZE
|
||||
#undef __CLC_GENTYPE
|
||||
#undef __CLC_BIT_INT
|
||||
#undef __CLC_BIT_INTN
|
||||
|
||||
#undef __CLC_VECSIZE_OR_1
|
||||
@@ -159,6 +161,7 @@
|
||||
#define __CLC_VECSIZE
|
||||
#define __CLC_VECSIZE_OR_1 1
|
||||
#define __CLC_GENTYPE double
|
||||
#define __CLC_BIT_INT long
|
||||
#define __CLC_BIT_INTN long
|
||||
#include __CLC_BODY
|
||||
#undef __CLC_VECSIZE_OR_1
|
||||
@@ -207,6 +210,7 @@
|
||||
#include __CLC_BODY
|
||||
#undef __CLC_VECSIZE
|
||||
#undef __CLC_GENTYPE
|
||||
#undef __CLC_BIT_INT
|
||||
#undef __CLC_BIT_INTN
|
||||
|
||||
#undef __CLC_VECSIZE_OR_1
|
||||
@@ -235,6 +239,7 @@
|
||||
#define __CLC_VECSIZE
|
||||
#define __CLC_VECSIZE_OR_1 1
|
||||
#define __CLC_GENTYPE half
|
||||
#define __CLC_BIT_INT short
|
||||
#define __CLC_BIT_INTN short
|
||||
#include __CLC_BODY
|
||||
#undef __CLC_GENTYPE
|
||||
@@ -283,6 +288,7 @@
|
||||
#include __CLC_BODY
|
||||
#undef __CLC_VECSIZE
|
||||
#undef __CLC_GENTYPE
|
||||
#undef __CLC_BIT_INT
|
||||
#undef __CLC_BIT_INTN
|
||||
|
||||
#undef __CLC_VECSIZE_OR_1
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
math/clc_log.cl
|
||||
math/clc_rsqrt.cl
|
||||
math/clc_sinpi.cl
|
||||
math/clc_sqrt.cl
|
||||
mem_fence/clc_mem_fence.cl
|
||||
synchronization/clc_work_group_barrier.cl
|
||||
workitem/clc_get_global_id.cl
|
||||
@@ -7,3 +11,4 @@ workitem/clc_get_local_size.cl
|
||||
workitem/clc_get_max_sub_group_size.cl
|
||||
workitem/clc_get_num_groups.cl
|
||||
workitem/clc_get_sub_group_local_id.cl
|
||||
relational/clc_isinf.cl
|
||||
|
||||
34
libclc/clc/lib/ptx-nvidiacl/math/clc_log.cl
Normal file
34
libclc/clc/lib/ptx-nvidiacl/math/clc_log.cl
Normal file
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <clc/math/clc_log.h>
|
||||
|
||||
float __nv_logf(float);
|
||||
double __nv_log(double);
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF float __clc_log(float x) { return __nv_logf(x); }
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF double __clc_log(double x) { return __nv_log(x); }
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef cl_khr_fp16
|
||||
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF half __clc_log(half x) {
|
||||
return (half)__clc_log((float)x);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define FUNCTION __clc_log
|
||||
#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
|
||||
#include <clc/math/gentype.inc>
|
||||
34
libclc/clc/lib/ptx-nvidiacl/math/clc_rsqrt.cl
Normal file
34
libclc/clc/lib/ptx-nvidiacl/math/clc_rsqrt.cl
Normal file
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <clc/math/clc_rsqrt.h>
|
||||
|
||||
float __nv_rsqrtf(float);
|
||||
double __nv_rsqrt(double);
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF float __clc_rsqrt(float x) { return __nv_rsqrtf(x); }
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF double __clc_rsqrt(double x) { return __nv_rsqrt(x); }
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef cl_khr_fp16
|
||||
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF half __clc_rsqrt(half x) {
|
||||
return (half)__clc_rsqrt((float)x);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define FUNCTION __clc_rsqrt
|
||||
#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
|
||||
#include <clc/math/gentype.inc>
|
||||
34
libclc/clc/lib/ptx-nvidiacl/math/clc_sinpi.cl
Normal file
34
libclc/clc/lib/ptx-nvidiacl/math/clc_sinpi.cl
Normal file
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <clc/math/clc_sinpi.h>
|
||||
|
||||
float __nv_sinpif(float);
|
||||
double __nv_sinpi(double);
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF float __clc_sinpi(float x) { return __nv_sinpif(x); }
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF double __clc_sinpi(double x) { return __nv_sinpi(x); }
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef cl_khr_fp16
|
||||
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF half __clc_sinpi(half x) {
|
||||
return (half)__clc_sinpi((float)x);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define FUNCTION __clc_sinpi
|
||||
#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
|
||||
#include <clc/math/gentype.inc>
|
||||
34
libclc/clc/lib/ptx-nvidiacl/math/clc_sqrt.cl
Normal file
34
libclc/clc/lib/ptx-nvidiacl/math/clc_sqrt.cl
Normal file
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <clc/math/clc_sqrt.h>
|
||||
|
||||
float __nv_sqrtf(float);
|
||||
double __nv_sqrt(double);
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF float __clc_sqrt(float x) { return __nv_sqrtf(x); }
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF double __clc_sqrt(double x) { return __nv_sqrt(x); }
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef cl_khr_fp16
|
||||
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF half __clc_sqrt(half x) {
|
||||
return (half)__clc_sqrt((float)x);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define FUNCTION __clc_sqrt
|
||||
#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
|
||||
#include <clc/math/gentype.inc>
|
||||
33
libclc/clc/lib/ptx-nvidiacl/relational/clc_isinf.cl
Normal file
33
libclc/clc/lib/ptx-nvidiacl/relational/clc_isinf.cl
Normal file
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <clc/relational/clc_isinf.h>
|
||||
|
||||
int __nv_isinff(float);
|
||||
int __nv_isinfd(double);
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF int __clc_isinf(float x) { return __nv_isinff(x); }
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF int __clc_isinf(double x) { return __nv_isinfd(x); }
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef cl_khr_fp16
|
||||
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF int __clc_isinf(half x) { return __clc_isinf((float)x); }
|
||||
|
||||
#endif
|
||||
|
||||
#define FUNCTION __clc_isinf
|
||||
#define __CLC_BODY <clc/shared/unary_def_scalarize.inc>
|
||||
#define __CLC_RET_TYPE __CLC_BIT_INT
|
||||
#include <clc/math/gentype.inc>
|
||||
Reference in New Issue
Block a user