In OpenMP 3.0 in Fortran reduction is supported with the special construct, while in C/C++ it is delegated to a programmer. I was wondering if there is a special reason for that, because OpenMP 3.0 came out in 2008, so I thought it was enough time to implement it for C/C++ also. Is there any particular technical reason associated with C/C++, why it is still not supported for C/C++?
Asked
Active
Viewed 206 times
0
-
Why are people still using Fortran? And why do many people still use ANSI C89 restrictions in 2014 even when most C compilers use GNU89 which is closer to C99 than C89? – Z boson Apr 03 '14 at 19:18
-
@Zboson so sarcastic :) I guess my question is not clear. I meant if there any particular technical reason why it is not supported in C/C++, not a philosophical question. – romants Apr 03 '14 at 19:43
-
1Fortran always knows the size of its arrays, no matter if static or dynamically allocated. C/C++ only know the size of static arrays. – Hristo Iliev Apr 04 '14 at 06:26
-
@romantsegelskyi, well I guess Hristo Iliev answered your question. BTW, I did not down vote you. But anyway, it's pretty easy to do an array reduction yourself. I often do reductions by hand anyway. – Z boson Apr 04 '14 at 06:33
-
@HristoIliev thanks a lot, that was an answer I was looking for. – romants Apr 04 '14 at 12:50
1 Answers
1
As was mentioned in the comments the reason for OpenMP not supporting reduction by default for arrays is that it does not know the size of an array. Fortran supports reduction on arrays by default because it always knows the size of its arrays, no matter if static or dynamically allocated. C/C++ only know the size of static arrays.

romants
- 3,660
- 1
- 21
- 33
-
2Just as a side note: OpenMP up to version 3.1 does not allow aggregate objects, including arrays, to be used in reduction operations in C and C++. OpenMP 4.0 introduced the ability to use classes with overloaded operators in C++, therefore it is now possible to have array reduction using classes that implement arrays and overload both `operator+()` to performing element-wise summation and `operator=()` to perform array initialisation from scalars. – Hristo Iliev Apr 04 '14 at 14:45