Skip to content

Commit c54f5f6

Browse files
authored
[flang] Address missed cases for REDUCE change, fixes shared lib build (#95481)
My recent change that distinguishes pass-by-reference from pass-by-value reduction operation functions missed the "CppReduceComplex" cases, and also broke the shared library build-bots. Fix.
1 parent 01a429c commit c54f5f6

File tree

2 files changed

+94
-36
lines changed

2 files changed

+94
-36
lines changed

flang/runtime/complex-reduction.c

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,23 +157,39 @@ ADAPT_REDUCTION(DotProductComplex16, CFloat128ComplexType, CppComplexFloat128,
157157
#endif
158158

159159
/* REDUCE() */
160-
#define RARGS REDUCE_ARGS(float_Complex_t)
161-
ADAPT_REDUCTION(ReduceComplex4, float_Complex_t, CppComplexFloat, CMPLXF, RARGS,
162-
REDUCE_ARG_NAMES)
160+
#define RARGS REDUCE_ARGS(float_Complex_t, float_Complex_t_ref_op)
161+
ADAPT_REDUCTION(ReduceComplex4Ref, float_Complex_t, CppComplexFloat, CMPLXF,
162+
RARGS, REDUCE_ARG_NAMES)
163+
#undef RARGS
164+
#define RARGS REDUCE_ARGS(float_Complex_t, float_Complex_t_value_op)
165+
ADAPT_REDUCTION(ReduceComplex4Value, float_Complex_t, CppComplexFloat, CMPLXF,
166+
RARGS, REDUCE_ARG_NAMES)
167+
#undef RARGS
168+
#define RARGS REDUCE_ARGS(double_Complex_t, double_Complex_t_ref_op)
169+
ADAPT_REDUCTION(ReduceComplex8Ref, double_Complex_t, CppComplexDouble, CMPLX,
170+
RARGS, REDUCE_ARG_NAMES)
163171
#undef RARGS
164-
#define RARGS REDUCE_ARGS(double_Complex_t)
165-
ADAPT_REDUCTION(ReduceComplex8, double_Complex_t, CppComplexDouble, CMPLX,
172+
#define RARGS REDUCE_ARGS(double_Complex_t, double_Complex_t_value_op)
173+
ADAPT_REDUCTION(ReduceComplex8Value, double_Complex_t, CppComplexDouble, CMPLX,
166174
RARGS, REDUCE_ARG_NAMES)
167175
#undef RARGS
168176
#if LDBL_MANT_DIG == 64
169-
#define RARGS REDUCE_ARGS(long_double_Complex_t)
170-
ADAPT_REDUCTION(ReduceComplex10, long_double_Complex_t, CppComplexLongDouble,
177+
#define RARGS REDUCE_ARGS(long_double_Complex_t, long_double_Complex_t_ref_op)
178+
ADAPT_REDUCTION(ReduceComplex10Ref, long_double_Complex_t, CppComplexLongDouble,
171179
CMPLXL, RARGS, REDUCE_ARG_NAMES)
172180
#undef RARGS
181+
#define RARGS REDUCE_ARGS(long_double_Complex_t, long_double_Complex_t_value_op)
182+
ADAPT_REDUCTION(ReduceComplex10Value, long_double_Complex_t,
183+
CppComplexLongDouble, CMPLXL, RARGS, REDUCE_ARG_NAMES)
184+
#undef RARGS
173185
#endif
174186
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
175-
#define RARGS REDUCE_ARGS(CFloat128ComplexType)
176-
ADAPT_REDUCTION(ReduceComplex16, CFloat128ComplexType, CppComplexFloat128,
187+
#define RARGS REDUCE_ARGS(CFloat128ComplexType, CFloat128ComplexType_ref_op)
188+
ADAPT_REDUCTION(ReduceComplex16Ref, CFloat128ComplexType, CppComplexFloat128,
189+
CMPLXF128, RARGS, REDUCE_ARG_NAMES)
190+
#undef RARGS
191+
#define RARGS REDUCE_ARGS(CFloat128ComplexType, CFloat128ComplexType_value_op)
192+
ADAPT_REDUCTION(ReduceComplex16Value, CFloat128ComplexType, CppComplexFloat128,
177193
CMPLXF128, RARGS, REDUCE_ARG_NAMES)
178194
#undef RARGS
179195
#endif

flang/runtime/complex-reduction.h

Lines changed: 69 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -69,49 +69,91 @@ long_double_Complex_t RTNAME(DotProductComplex10)(DOT_PRODUCT_ARGS);
6969
CFloat128ComplexType RTNAME(DotProductComplex16)(DOT_PRODUCT_ARGS);
7070
#endif
7171

72-
#define REDUCE_ARGS(T) \
73-
T##_op operation, const struct CppDescriptor *x, \
74-
const struct CppDescriptor *y, const char *source, int line, \
75-
int dim /*=0*/, const struct CppDescriptor *mask /*=NULL*/, \
76-
const T *identity /*=NULL*/, _Bool ordered /*=true*/
72+
#define REDUCE_ARGS(T, OP) \
73+
OP operation, const struct CppDescriptor *x, const struct CppDescriptor *y, \
74+
const char *source, int line, int dim /*=0*/, \
75+
const struct CppDescriptor *mask /*=NULL*/, const T *identity /*=NULL*/, \
76+
_Bool ordered /*=true*/
7777
#define REDUCE_ARG_NAMES \
7878
operation, x, y, source, line, dim, mask, identity, ordered
7979

80-
typedef float_Complex_t (*float_Complex_t_op)(
80+
typedef float_Complex_t (*float_Complex_t_ref_op)(
8181
const float_Complex_t *, const float_Complex_t *);
82-
typedef double_Complex_t (*double_Complex_t_op)(
82+
typedef float_Complex_t (*float_Complex_t_value_op)(
83+
float_Complex_t, float_Complex_t);
84+
typedef double_Complex_t (*double_Complex_t_ref_op)(
8385
const double_Complex_t *, const double_Complex_t *);
84-
typedef long_double_Complex_t (*long_double_Complex_t_op)(
86+
typedef double_Complex_t (*double_Complex_t_value_op)(
87+
double_Complex_t, double_Complex_t);
88+
typedef long_double_Complex_t (*long_double_Complex_t_ref_op)(
8589
const long_double_Complex_t *, const long_double_Complex_t *);
86-
87-
float_Complex_t RTNAME(ReduceComplex2)(REDUCE_ARGS(float_Complex_t));
88-
float_Complex_t RTNAME(ReduceComplex3)(REDUCE_ARGS(float_Complex_t));
89-
float_Complex_t RTNAME(ReduceComplex4)(REDUCE_ARGS(float_Complex_t));
90-
double_Complex_t RTNAME(ReduceComplex8)(REDUCE_ARGS(double_Complex_t));
91-
long_double_Complex_t RTNAME(ReduceComplex10)(
92-
REDUCE_ARGS(long_double_Complex_t));
90+
typedef long_double_Complex_t (*long_double_Complex_t_value_op)(
91+
long_double_Complex_t, long_double_Complex_t);
92+
93+
float_Complex_t RTNAME(ReduceComplex2Ref)(
94+
REDUCE_ARGS(float_Complex_t, float_Complex_t_ref_op));
95+
float_Complex_t RTNAME(ReduceComplex2Value)(
96+
REDUCE_ARGS(float_Complex_t, float_Complex_t_value_op));
97+
float_Complex_t RTNAME(ReduceComplex3Ref)(
98+
REDUCE_ARGS(float_Complex_t, float_Complex_t_ref_op));
99+
float_Complex_t RTNAME(ReduceComplex3Value)(
100+
REDUCE_ARGS(float_Complex_t, float_Complex_t_value_op));
101+
float_Complex_t RTNAME(ReduceComplex4Ref)(
102+
REDUCE_ARGS(float_Complex_t, float_Complex_t_ref_op));
103+
float_Complex_t RTNAME(ReduceComplex4Value)(
104+
REDUCE_ARGS(float_Complex_t, float_Complex_t_value_op));
105+
double_Complex_t RTNAME(ReduceComplex8Ref)(
106+
REDUCE_ARGS(double_Complex_t, double_Complex_t_ref_op));
107+
double_Complex_t RTNAME(ReduceComplex8Value)(
108+
REDUCE_ARGS(double_Complex_t, double_Complex_t_value_op));
109+
long_double_Complex_t RTNAME(ReduceComplex10Ref)(
110+
REDUCE_ARGS(long_double_Complex_t, long_double_Complex_t_ref_op));
111+
long_double_Complex_t RTNAME(ReduceComplex10Value)(
112+
REDUCE_ARGS(long_double_Complex_t, long_double_Complex_t_value_op));
93113
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
94-
typedef CFloat128ComplexType (*CFloat128ComplexType_op)(
114+
typedef CFloat128ComplexType (*CFloat128ComplexType_ref_op)(
95115
const CFloat128ComplexType *, const CFloat128ComplexType *);
96-
CFloat128ComplexType RTNAME(ReduceComplex16)(REDUCE_ARGS(CFloat128ComplexType));
116+
typedef CFloat128ComplexType (*CFloat128ComplexType_value_op)(
117+
CFloat128ComplexType, CFloat128ComplexType);
118+
CFloat128ComplexType RTNAME(ReduceComplex16Ref)(
119+
REDUCE_ARGS(CFloat128ComplexType, CFloat128ComplexType_ref_op));
120+
CFloat128ComplexType RTNAME(ReduceComplex16Value)(
121+
REDUCE_ARGS(CFloat128ComplexType, CFloat128ComplexType_value_op));
97122
#endif
98123

99-
#define REDUCE_DIM_ARGS(T) \
100-
struct CppDescriptor *result, T##_op operation, \
101-
const struct CppDescriptor *x, const struct CppDescriptor *y, \
102-
const char *source, int line, int dim, \
124+
#define REDUCE_DIM_ARGS(T, OP) \
125+
struct CppDescriptor *result, OP operation, const struct CppDescriptor *x, \
126+
const struct CppDescriptor *y, const char *source, int line, int dim, \
103127
const struct CppDescriptor *mask /*=NULL*/, const T *identity /*=NULL*/, \
104128
_Bool ordered /*=true*/
105129
#define REDUCE_DIM_ARG_NAMES \
106130
result, operation, x, y, source, line, dim, mask, identity, ordered
107131

108-
void RTNAME(ReduceComplex2Dim)(REDUCE_DIM_ARGS(float_Complex_t));
109-
void RTNAME(ReduceComplex3Dim)(REDUCE_DIM_ARGS(float_Complex_t));
110-
void RTNAME(ReduceComplex4Dim)(REDUCE_DIM_ARGS(float_Complex_t));
111-
void RTNAME(ReduceComplex8Dim)(REDUCE_DIM_ARGS(double_Complex_t));
112-
void RTNAME(ReduceComplex10Dim)(REDUCE_DIM_ARGS(long_double_Complex_t));
132+
void RTNAME(ReduceComplex2DimRef)(
133+
REDUCE_DIM_ARGS(float_Complex_t, float_Complex_t_ref_op));
134+
void RTNAME(ReduceComplex2DimValue)(
135+
REDUCE_DIM_ARGS(float_Complex_t, float_Complex_t_value_op));
136+
void RTNAME(ReduceComplex3DimRef)(
137+
REDUCE_DIM_ARGS(float_Complex_t, float_Complex_t_ref_op));
138+
void RTNAME(ReduceComplex3DimValue)(
139+
REDUCE_DIM_ARGS(float_Complex_t, float_Complex_t_value_op));
140+
void RTNAME(ReduceComplex4DimRef)(
141+
REDUCE_DIM_ARGS(float_Complex_t, float_Complex_t_ref_op));
142+
void RTNAME(ReduceComplex4DimValue)(
143+
REDUCE_DIM_ARGS(float_Complex_t, float_Complex_t_value_op));
144+
void RTNAME(ReduceComplex8DimRef)(
145+
REDUCE_DIM_ARGS(double_Complex_t, double_Complex_t_ref_op));
146+
void RTNAME(ReduceComplex8DimValue)(
147+
REDUCE_DIM_ARGS(double_Complex_t, double_Complex_t_value_op));
148+
void RTNAME(ReduceComplex10DimRef)(
149+
REDUCE_DIM_ARGS(long_double_Complex_t, long_double_Complex_t_ref_op));
150+
void RTNAME(ReduceComplex10DimValue)(
151+
REDUCE_DIM_ARGS(long_double_Complex_t, long_double_Complex_t_value_op));
113152
#if LDBL_MANT_DIG == 113 || HAS_FLOAT128
114-
void RTNAME(ReduceComplex16Dim)(REDUCE_DIM_ARGS(CFloat128ComplexType));
153+
void RTNAME(ReduceComplex16DimRef)(
154+
REDUCE_DIM_ARGS(CFloat128ComplexType, CFloat128ComplexType_ref_op));
155+
void RTNAME(ReduceComplex16DimValue)(
156+
REDUCE_DIM_ARGS(CFloat128ComplexType, CFloat128ComplexType_value_op));
115157
#endif
116158

117159
#endif // FORTRAN_RUNTIME_COMPLEX_REDUCTION_H_

0 commit comments

Comments
 (0)