Skip to content

Commit 2dfb29a

Browse files
authored
[libclc] Move nan to the CLC library (#128521)
1 parent a88167a commit 2dfb29a

File tree

7 files changed

+37
-16
lines changed

7 files changed

+37
-16
lines changed

libclc/clc/include/clc/math/clc_nan.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef __CLC_MATH_CLC_NAN_H__
2+
#define __CLC_MATH_CLC_NAN_H__
3+
4+
#define __CLC_FUNCTION __clc_nan
5+
#define __CLC_BODY <clc/math/clc_nan.inc>
6+
7+
#include <clc/math/gentype.inc>
8+
9+
#undef __CLC_BODY
10+
#undef __CLC_FUNCTION
11+
12+
#endif // __CLC_MATH_CLC_NAN_H__
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_nan(__CLC_U_GENTYPE code);

libclc/clc/lib/generic/SOURCES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ math/clc_floor.cl
2525
math/clc_frexp.cl
2626
math/clc_mad.cl
2727
math/clc_modf.cl
28+
math/clc_nan.cl
2829
math/clc_nextafter.cl
2930
math/clc_rint.cl
3031
math/clc_sw_fma.cl
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <clc/internal/clc.h>
2+
#include <clc/utils.h>
3+
4+
#define __CLC_BODY <clc_nan.inc>
5+
#include <clc/math/gentype.inc>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#if __CLC_FPSIZE == 64
2+
#define NAN_MASK 0x7ff0000000000000ul
3+
#elif __CLC_FPSIZE == 32
4+
#define NAN_MASK 0x7fc00000
5+
#elif __CLC_FPSIZE == 16
6+
#define NAN_MASK 0x7e00
7+
#endif
8+
9+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_nan(__CLC_U_GENTYPE code) {
10+
const __CLC_U_GENTYPE mask = NAN_MASK;
11+
const __CLC_U_GENTYPE res = code | mask;
12+
return __CLC_AS_GENTYPE(res);
13+
}
14+
15+
#undef NAN_MASK

libclc/generic/lib/math/nan.cl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#include <clc/clc.h>
2-
#include <clc/utils.h>
1+
#include <clc/clcmacro.h>
2+
#include <clc/math/clc_nan.h>
33

4-
#define __OPENCL_AS_GENTYPE __CLC_XCONCAT(as_, __CLC_GENTYPE)
54
#define __CLC_BODY <nan.inc>
65
#include <clc/math/gentype.inc>

libclc/generic/lib/math/nan.inc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
#if __CLC_FPSIZE == 64
2-
#define NAN_MASK 0x7ff0000000000000ul
3-
#elif __CLC_FPSIZE == 32
4-
#define NAN_MASK 0x7fc00000
5-
#elif __CLC_FPSIZE == 16
6-
#define NAN_MASK 0x7e00
7-
#endif
8-
91
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE nan(__CLC_U_GENTYPE code) {
10-
const __CLC_U_GENTYPE mask = NAN_MASK;
11-
const __CLC_U_GENTYPE res = code | mask;
12-
return __OPENCL_AS_GENTYPE(res);
2+
return __clc_nan(code);
133
}
14-
15-
#undef NAN_MASK

0 commit comments

Comments
 (0)