Parallel-Processing
Parallel-Processing copied to clipboard
Issue regarding reduction declaration
https://github.com/madhug-nadig/Parallel-Processing-Nadig/blob/c52c90fc8e93d69dc88198a5948cdb88daac4141/Parallel%20Programming%20in%20C%20-%20Selection%20Sort.c#L17
Should be replaced with:
#pragma omp declare reduction(maximum : struct Compare : omp_out = omp_in.val > omp_out.val ? omp_in : omp_out) initializer(omp_priv=omp_orig)
otherwise the Compare struct members will be initialized to the default value (0) in the body of the for loop that uses the reduction (regardless of the fact that struct members have been initialized before the loop).