File tree Expand file tree Collapse file tree 8 files changed +65
-27
lines changed Expand file tree Collapse file tree 8 files changed +65
-27
lines changed Original file line number Diff line number Diff line change 1+ #ifndef __CLC_MATH_CLC_MODF_H__
2+ #define __CLC_MATH_CLC_MODF_H__
3+
4+ #define __CLC_FUNCTION __clc_modf
5+ #define __CLC_BODY <clc/math/unary_decl_with_ptr.inc>
6+ #include <clc/math/gentype.inc>
7+
8+ #undef __CLC_BODY
9+ #undef __CLC_FUNCTION
10+
11+ #endif // __CLC_MATH_CLC_MODF_H__
Original file line number Diff line number Diff line change 1+ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION (__CLC_GENTYPE x,
2+ global __CLC_GENTYPE *ptr);
3+ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION (__CLC_GENTYPE x,
4+ local __CLC_GENTYPE *ptr);
5+ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE
6+ __CLC_FUNCTION (__CLC_GENTYPE x, private __CLC_GENTYPE *ptr);
Original file line number Diff line number Diff line change 1+ #include < clc/utils.h>
2+
3+ #ifndef __CLC_FUNCTION
4+ #define __CLC_FUNCTION (x ) __CLC_CONCAT(__clc_, x)
5+ #endif
6+
7+ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION (__CLC_GENTYPE x,
8+ private __CLC_GENTYPE *ptr) {
9+ return __CLC_FUNCTION (FUNCTION)(x, ptr);
10+ }
11+
12+ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION (__CLC_GENTYPE x,
13+ global __CLC_GENTYPE *ptr) {
14+ return __CLC_FUNCTION (FUNCTION)(x, ptr);
15+ }
16+
17+ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION (__CLC_GENTYPE x,
18+ local __CLC_GENTYPE *ptr) {
19+ return __CLC_FUNCTION (FUNCTION)(x, ptr);
20+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ math/clc_copysign.cl
2222math/clc_fabs.cl
2323math/clc_floor.cl
2424math/clc_mad.cl
25+ math/clc_modf.cl
2526math/clc_nextafter.cl
2627math/clc_rint.cl
2728math/clc_trunc.cl
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2014, 2015 Advanced Micro Devices, Inc.
2+ * Copyright (c) 2015 Advanced Micro Devices, Inc.
33 *
44 * Permission is hereby granted, free of charge, to any person obtaining a copy
55 * of this software and associated documentation files (the "Software"), to deal
2020 * THE SOFTWARE.
2121 */
2222
23- _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE modf (__CLC_GENTYPE x, global __CLC_GENTYPE *iptr);
24- _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE modf (__CLC_GENTYPE x, local __CLC_GENTYPE *iptr);
25- _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE modf (__CLC_GENTYPE x, private __CLC_GENTYPE *iptr);
23+ #include <clc/internal/clc.h>
24+ #include <clc/math/clc_copysign.h>
25+ #include <clc/math/clc_trunc.h>
26+ #include <clc/math/math.h>
27+ #include <clc/relational/clc_isinf.h>
28+
29+ #define __CLC_BODY <clc_modf.inc>
30+ #include <clc/math/gentype.inc>
Original file line number Diff line number Diff line change 1919 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2020 * THE SOFTWARE.
2121 */
22-
23- #if __CLC_FPSIZE == 64
24- #define ZERO 0.0
25- #elif __CLC_FPSIZE == 32
26- #define ZERO 0 .0f
27- #elif __CLC_FPSIZE == 16
28- #define ZERO 0 .0h
29- #endif
30-
31- _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE modf (__CLC_GENTYPE x,
32- private __CLC_GENTYPE *iptr) {
33- *iptr = trunc (x);
34- return copysign (isinf (x) ? ZERO : x - *iptr, x);
22+ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_modf (__CLC_GENTYPE x,
23+ private __CLC_GENTYPE *iptr) {
24+ *iptr = __clc_trunc (x);
25+ return __clc_copysign (__clc_isinf (x) ? __CLC_FP_LIT (0.0 ) : x - *iptr, x);
3526}
3627
37- #define MODF_DEF (addrspace ) \
38- _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE modf (__CLC_GENTYPE x, \
39- addrspace __CLC_GENTYPE *iptr) { \
28+ #define CLC_MODF_DEF (addrspace ) \
29+ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_modf ( \
30+ __CLC_GENTYPE x, addrspace __CLC_GENTYPE *iptr) { \
4031 __CLC_GENTYPE private_iptr; \
41- __CLC_GENTYPE ret = modf (x, &private_iptr); \
32+ __CLC_GENTYPE ret = __clc_modf (x, &private_iptr); \
4233 *iptr = private_iptr; \
4334 return ret; \
4435 }
4536
46- MODF_DEF (local);
47- MODF_DEF (global);
37+ CLC_MODF_DEF (local);
38+ CLC_MODF_DEF (global);
4839
49- #undef ZERO
40+ #undef CLC_MODF_DEF
Original file line number Diff line number Diff line change 2020 * THE SOFTWARE.
2121 */
2222
23- #define __CLC_BODY <clc/math/modf.inc>
23+ #define __CLC_FUNCTION modf
24+ #define __CLC_BODY <clc/math/unary_decl_with_ptr.inc>
2425#include <clc/math/gentype.inc>
26+
27+ #undef __CLC_FUNCTION
Original file line number Diff line number Diff line change 2121 */
2222
2323#include <clc/clc.h>
24- #include <clc/math/math .h>
24+ #include <clc/math/clc_modf .h>
2525
26- #define __CLC_BODY <modf.inc>
26+ #define FUNCTION modf
27+ #define __CLC_BODY <clc/math/unary_def_with_ptr.inc>
2728#include <clc/math/gentype.inc>
You can’t perform that action at this time.
0 commit comments