Open huangcj123456 opened 1 month ago
Could you please elaborate why is this UB? I'm not an expert in OpenMP, so pointers to standard would help.
SIMD Reduction:
The reduction is done with the addition operator +, which combines local_sum from all threads into the final result.
But why is it UB without reduction
?
I used the Yargen tool and found a bug in the tool.
wrong code: void test(int acc, int inc) {
pragma omp simd
for (int i = 0; i < 16; i++) acc += inc; }
OK code: void test(int acc, int inc) {
pragma omp simd reduction(+:acc[0])
for (int i = 0; i < 16; i++) acc += inc; } The absence of the "reduction" keyword leads to undefined behavior in this test case.
Who knows how to solve this problem?