Skip to content
Merged
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
2 changes: 0 additions & 2 deletions libclc/amdgcn/lib/SOURCES
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
cl_khr_int64_extended_atomics/minmax_helpers.ll
math/fmax.cl
math/fmin.cl
mem_fence/fence.cl
synchronization/barrier.cl
workitem/get_global_offset.cl
Expand Down
53 changes: 0 additions & 53 deletions libclc/amdgcn/lib/math/fmax.cl

This file was deleted.

53 changes: 0 additions & 53 deletions libclc/amdgcn/lib/math/fmin.cl

This file was deleted.

20 changes: 20 additions & 0 deletions libclc/clc/include/clc/math/clc_fmax.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_MATH_CLC_FMAX_H__
#define __CLC_MATH_CLC_FMAX_H__

#define __CLC_FUNCTION __clc_fmax
#define __CLC_BODY <clc/shared/binary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_BODY
#undef __CLC_FUNCTION

#endif // __CLC_MATH_CLC_FMAX_H__
20 changes: 20 additions & 0 deletions libclc/clc/include/clc/math/clc_fmin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef __CLC_MATH_CLC_FMIN_H__
#define __CLC_MATH_CLC_FMIN_H__

#define __CLC_FUNCTION __clc_fmin
#define __CLC_BODY <clc/shared/binary_decl.inc>

#include <clc/math/gentype.inc>

#undef __CLC_BODY
#undef __CLC_FUNCTION

#endif // __CLC_MATH_CLC_FMIN_H__
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
__CLC_GENTYPE y);

#ifndef __CLC_SCALAR
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
__CLC_SCALAR_GENTYPE y);
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===----------------------------------------------------------------------===//
//
// 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/utils.h>

#ifndef __CLC_FUNCTION
#define __CLC_FUNCTION(x) __CLC_CONCAT(__clc_, x)
#endif

_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE a,
__CLC_GENTYPE b) {
return __CLC_FUNCTION(FUNCTION)(a, b);
}

#ifndef __CLC_SCALAR
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE a,
__CLC_SCALAR_GENTYPE b) {
return __CLC_FUNCTION(FUNCTION)(a, (__CLC_GENTYPE)b);
}
#endif
2 changes: 2 additions & 0 deletions libclc/clc/lib/amdgcn/SOURCES
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
math/clc_fmax.cl
math/clc_fmin.cl
math/clc_ldexp_override.cl
49 changes: 49 additions & 0 deletions libclc/clc/lib/amdgcn/math/clc_fmax.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// 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/clcmacro.h>
#include <clc/internal/clc.h>
#include <clc/relational/clc_isnan.h>

_CLC_DEF _CLC_OVERLOAD float __clc_fmax(float x, float y) {
// fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise
// fmax instruction flushes the values for comparison, but outputs original
// denormal
x = __builtin_canonicalizef(x);
y = __builtin_canonicalizef(y);
return __builtin_fmaxf(x, y);
}
_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, __clc_fmax, float, float)

#ifdef cl_khr_fp64

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

_CLC_DEF _CLC_OVERLOAD double __clc_fmax(double x, double y) {
x = __builtin_canonicalize(x);
y = __builtin_canonicalize(y);
return __builtin_fmax(x, y);
}
_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, __clc_fmax, double,
double)

#endif
#ifdef cl_khr_fp16

#pragma OPENCL EXTENSION cl_khr_fp16 : enable

_CLC_DEF _CLC_OVERLOAD half __clc_fmax(half x, half y) {
if (__clc_isnan(x))
return y;
if (__clc_isnan(y))
return x;
return (y < x) ? x : y;
}
_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __clc_fmax, half, half)

#endif
50 changes: 50 additions & 0 deletions libclc/clc/lib/amdgcn/math/clc_fmin.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// 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/clcmacro.h>
#include <clc/internal/clc.h>
#include <clc/relational/clc_isnan.h>

_CLC_DEF _CLC_OVERLOAD float __clc_fmin(float x, float y) {
// fcanonicalize removes sNaNs and flushes denormals if not enabled. Otherwise
// fmin instruction flushes the values for comparison, but outputs original
// denormal
x = __builtin_canonicalizef(x);
y = __builtin_canonicalizef(y);
return __builtin_fminf(x, y);
}
_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, __clc_fmin, float, float)

#ifdef cl_khr_fp64

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

_CLC_DEF _CLC_OVERLOAD double __clc_fmin(double x, double y) {
x = __builtin_canonicalize(x);
y = __builtin_canonicalize(y);
return __builtin_fmin(x, y);
}
_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, __clc_fmin, double,
double)

#endif

#ifdef cl_khr_fp16

#pragma OPENCL EXTENSION cl_khr_fp16 : enable

_CLC_DEF _CLC_OVERLOAD half __clc_fmin(half x, half y) {
if (__clc_isnan(x))
return y;
if (__clc_isnan(y))
return x;
return (y < x) ? y : x;
}
_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __clc_fmin, half, half)

#endif
4 changes: 3 additions & 1 deletion libclc/clc/lib/generic/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ math/clc_expm1.cl
math/clc_exp_helper.cl
math/clc_fabs.cl
math/clc_fma.cl
math/clc_fmod.cl
math/clc_fmax.cl
math/clc_fmin.cl
math/clc_floor.cl
math/clc_fmod.cl
math/clc_frexp.cl
math/clc_hypot.cl
math/clc_ldexp.cl
Expand Down
36 changes: 36 additions & 0 deletions libclc/clc/lib/generic/math/clc_fmax.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// 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/clcmacro.h>
#include <clc/internal/clc.h>
#include <clc/relational/clc_isnan.h>

_CLC_DEFINE_BINARY_BUILTIN(float, __clc_fmax, __builtin_fmaxf, float, float);

#ifdef cl_khr_fp64

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

_CLC_DEFINE_BINARY_BUILTIN(double, __clc_fmax, __builtin_fmax, double, double);

#endif

#ifdef cl_khr_fp16

#pragma OPENCL EXTENSION cl_khr_fp16 : enable

_CLC_DEF _CLC_OVERLOAD half __clc_fmax(half x, half y) {
if (__clc_isnan(x))
return y;
if (__clc_isnan(y))
return x;
return (x < y) ? y : x;
}
_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __clc_fmax, half, half)

#endif
36 changes: 36 additions & 0 deletions libclc/clc/lib/generic/math/clc_fmin.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// 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/clcmacro.h>
#include <clc/internal/clc.h>
#include <clc/relational/clc_isnan.h>

_CLC_DEFINE_BINARY_BUILTIN(float, __clc_fmin, __builtin_fminf, float, float);

#ifdef cl_khr_fp64

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

_CLC_DEFINE_BINARY_BUILTIN(double, __clc_fmin, __builtin_fmin, double, double);

#endif

#ifdef cl_khr_fp16

#pragma OPENCL EXTENSION cl_khr_fp16 : enable

_CLC_DEF _CLC_OVERLOAD half __clc_fmin(half x, half y) {
if (__clc_isnan(x))
return y;
if (__clc_isnan(y))
return x;
return (y < x) ? y : x;
}
_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __clc_fmin, half, half)

#endif
2 changes: 2 additions & 0 deletions libclc/clc/lib/r600/SOURCES
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
math/clc_fmax.cl
math/clc_fmin.cl
math/clc_native_rsqrt.cl
math/clc_rsqrt_override.cl
Loading