Skip to content

[libclc] Implement clc_log/sinpi/sqrt with __nv_* functions #150174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libclc/clc/lib/ptx-nvidiacl/SOURCES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
math/clc_log.cl
math/clc_sinpi.cl
math/clc_sqrt.cl
workitem/clc_get_global_id.cl
workitem/clc_get_group_id.cl
workitem/clc_get_local_id.cl
Expand Down
34 changes: 34 additions & 0 deletions libclc/clc/lib/ptx-nvidiacl/math/clc_log.cl
Original file line number Diff line number Diff line change
@@ -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 changes: 34 additions & 0 deletions libclc/clc/lib/ptx-nvidiacl/math/clc_sinpi.cl
Original file line number Diff line number Diff line change
@@ -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 changes: 34 additions & 0 deletions libclc/clc/lib/ptx-nvidiacl/math/clc_sqrt.cl
Original file line number Diff line number Diff line change
@@ -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>
Loading