Skip to content

[NFC][libclc] Refactor _CLC_*_VECTORIZE macros to functions in .inc files #145678

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

Merged
merged 3 commits into from
Jun 30, 2025
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
113 changes: 0 additions & 113 deletions libclc/clc/include/clc/clcmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,111 +12,6 @@
#include <clc/internal/clc.h>
#include <clc/utils.h>

#define _CLC_UNARY_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE) \
DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x) { \
return (RET_TYPE##2)(FUNCTION(x.s0), FUNCTION(x.s1)); \
} \
\
DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x) { \
return (RET_TYPE##3)(FUNCTION(x.s0), FUNCTION(x.s1), FUNCTION(x.s2)); \
} \
\
DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x) { \
return (RET_TYPE##4)(FUNCTION(x.s0), FUNCTION(x.s1), FUNCTION(x.s2), \
FUNCTION(x.s3)); \
} \
\
DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x) { \
return (RET_TYPE##8)(FUNCTION(x.s0), FUNCTION(x.s1), FUNCTION(x.s2), \
FUNCTION(x.s3), FUNCTION(x.s4), FUNCTION(x.s5), \
FUNCTION(x.s6), FUNCTION(x.s7)); \
} \
\
DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x) { \
return (RET_TYPE##16)( \
FUNCTION(x.s0), FUNCTION(x.s1), FUNCTION(x.s2), FUNCTION(x.s3), \
FUNCTION(x.s4), FUNCTION(x.s5), FUNCTION(x.s6), FUNCTION(x.s7), \
FUNCTION(x.s8), FUNCTION(x.s9), FUNCTION(x.sa), FUNCTION(x.sb), \
FUNCTION(x.sc), FUNCTION(x.sd), FUNCTION(x.se), FUNCTION(x.sf)); \
}

#define _CLC_BINARY_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE, \
ARG2_TYPE) \
DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x, ARG2_TYPE##2 y) { \
return (RET_TYPE##2)(FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1)); \
} \
\
DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x, ARG2_TYPE##3 y) { \
return (RET_TYPE##3)(FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1), \
FUNCTION(x.s2, y.s2)); \
} \
\
DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x, ARG2_TYPE##4 y) { \
return (RET_TYPE##4)(FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1), \
FUNCTION(x.s2, y.s2), FUNCTION(x.s3, y.s3)); \
} \
\
DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x, ARG2_TYPE##8 y) { \
return (RET_TYPE##8)(FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1), \
FUNCTION(x.s2, y.s2), FUNCTION(x.s3, y.s3), \
FUNCTION(x.s4, y.s4), FUNCTION(x.s5, y.s5), \
FUNCTION(x.s6, y.s6), FUNCTION(x.s7, y.s7)); \
} \
\
DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x, ARG2_TYPE##16 y) { \
return (RET_TYPE##16)( \
FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1), FUNCTION(x.s2, y.s2), \
FUNCTION(x.s3, y.s3), FUNCTION(x.s4, y.s4), FUNCTION(x.s5, y.s5), \
FUNCTION(x.s6, y.s6), FUNCTION(x.s7, y.s7), FUNCTION(x.s8, y.s8), \
FUNCTION(x.s9, y.s9), FUNCTION(x.sa, y.sa), FUNCTION(x.sb, y.sb), \
FUNCTION(x.sc, y.sc), FUNCTION(x.sd, y.sd), FUNCTION(x.se, y.se), \
FUNCTION(x.sf, y.sf)); \
}

#define _CLC_TERNARY_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE, \
ARG2_TYPE, ARG3_TYPE) \
DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x, ARG2_TYPE##2 y, \
ARG3_TYPE##2 z) { \
return (RET_TYPE##2)(FUNCTION(x.s0, y.s0, z.s0), \
FUNCTION(x.s1, y.s1, z.s1)); \
} \
\
DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x, ARG2_TYPE##3 y, \
ARG3_TYPE##3 z) { \
return (RET_TYPE##3)(FUNCTION(x.s0, y.s0, z.s0), \
FUNCTION(x.s1, y.s1, z.s1), \
FUNCTION(x.s2, y.s2, z.s2)); \
} \
\
DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x, ARG2_TYPE##4 y, \
ARG3_TYPE##4 z) { \
return (RET_TYPE##4)( \
FUNCTION(x.s0, y.s0, z.s0), FUNCTION(x.s1, y.s1, z.s1), \
FUNCTION(x.s2, y.s2, z.s2), FUNCTION(x.s3, y.s3, z.s3)); \
} \
\
DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x, ARG2_TYPE##8 y, \
ARG3_TYPE##8 z) { \
return (RET_TYPE##8)( \
FUNCTION(x.s0, y.s0, z.s0), FUNCTION(x.s1, y.s1, z.s1), \
FUNCTION(x.s2, y.s2, z.s2), FUNCTION(x.s3, y.s3, z.s3), \
FUNCTION(x.s4, y.s4, z.s4), FUNCTION(x.s5, y.s5, z.s5), \
FUNCTION(x.s6, y.s6, z.s6), FUNCTION(x.s7, y.s7, z.s7)); \
} \
\
DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x, ARG2_TYPE##16 y, \
ARG3_TYPE##16 z) { \
return (RET_TYPE##16)( \
FUNCTION(x.s0, y.s0, z.s0), FUNCTION(x.s1, y.s1, z.s1), \
FUNCTION(x.s2, y.s2, z.s2), FUNCTION(x.s3, y.s3, z.s3), \
FUNCTION(x.s4, y.s4, z.s4), FUNCTION(x.s5, y.s5, z.s5), \
FUNCTION(x.s6, y.s6, z.s6), FUNCTION(x.s7, y.s7, z.s7), \
FUNCTION(x.s8, y.s8, z.s8), FUNCTION(x.s9, y.s9, z.s9), \
FUNCTION(x.sa, y.sa, z.sa), FUNCTION(x.sb, y.sb, z.sb), \
FUNCTION(x.sc, y.sc, z.sc), FUNCTION(x.sd, y.sd, z.sd), \
FUNCTION(x.se, y.se, z.se), FUNCTION(x.sf, y.sf, z.sf)); \
}

#define _CLC_V_V_VP_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE, \
ADDR_SPACE, ARG2_TYPE) \
DECLSPEC __CLC_XCONCAT(RET_TYPE, 2) \
Expand Down Expand Up @@ -171,12 +66,4 @@
FUNCTION(x.sf, ptr + 15)); \
}

#define _CLC_DEFINE_BINARY_BUILTIN(RET_TYPE, FUNCTION, BUILTIN, ARG1_TYPE, \
ARG2_TYPE) \
_CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \
return BUILTIN(x, y); \
} \
_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, RET_TYPE, FUNCTION, ARG1_TYPE, \
ARG2_TYPE)

#endif // __CLC_CLCMACRO_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/geometric/clc_fast_distance.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include <clc/math/gentype.inc>

#undef __FLOAT_ONLY
#undef __CLC_FUNCTION

#endif // __CLC_GEOMETRIC_CLC_FAST_DISTANCE_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/geometric/clc_fast_length.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include <clc/math/gentype.inc>

#undef __FLOAT_ONLY
#undef __CLC_FUNCTION

#endif // __CLC_GEOMETRIC_CLC_FAST_LENGTH_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/geometric/clc_fast_normalize.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@

#undef __CLC_FUNCTION
#undef __CLC_GEOMETRIC_RET_GENTYPE
#undef __FLOAT_ONLY

#endif // __CLC_GEOMETRIC_CLC_FAST_NORMALIZE_H__
2 changes: 0 additions & 2 deletions libclc/clc/include/clc/math/clc_exp_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@

#include <clc/math/gentype.inc>

#undef __DOUBLE_ONLY

#endif // __CLC_MATH_CLC_EXP_HELPER
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_cos.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_COS_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_divide.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_DIVIDE_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_exp.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_EXP_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_exp10.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_EXP10_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_exp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_EXP2_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_LOG_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_log10.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_LOG10_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_log2.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_LOG2_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_powr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_POWR_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_recip.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_RECIP_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_rsqrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_RSQRT_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_sin.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_SIN_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_sqrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_SQRT_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_half_tan.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_HALF_TAN_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_cos.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_COS_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_divide.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_DIVIDE_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_exp.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_EXP_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_exp10.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_EXP10_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_exp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_EXP2_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_LOG_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_log10.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_LOG10_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_log2.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_LOG2_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_powr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_POWR_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_recip.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_RECIP_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_rsqrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_RSQRT_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_sin.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_SIN_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_sqrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_SQRT_H__
1 change: 0 additions & 1 deletion libclc/clc/include/clc/math/clc_native_tan.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
#include <clc/math/gentype.inc>

#undef __CLC_FUNCTION
#undef __FLOAT_ONLY

#endif // __CLC_MATH_CLC_NATIVE_TAN_H__
4 changes: 0 additions & 4 deletions libclc/clc/include/clc/math/clc_sincos_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@

#include <clc/math/gentype.inc>

#undef __FLOAT_ONLY

#define __DOUBLE_ONLY
#define __CLC_BODY <clc/math/clc_sincos_helpers_fp64.inc>

#include <clc/math/gentype.inc>

#undef __DOUBLE_ONLY

#endif // __CLC_MATH_CLC_SINCOS_HELPERS_H__
4 changes: 4 additions & 0 deletions libclc/clc/include/clc/math/gentype.inc
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,7 @@

#undef __CLC_AS_GENTYPE
#undef __CLC_CONVERT_GENTYPE

#undef __HALF_ONLY
#undef __FLOAT_ONLY
#undef __DOUBLE_ONLY
Loading
Loading