Is there false-sharing with sum[]
in the following snippet of code that computes the row-wise sums of a sparse CSR matrix since independent threads update distinct locations of the array which could potentially be mapped to the same cache-line?
If yes, how can we avoid this assuming sum[] is pre-allocated and cannot be re-defined to have elements map to unique cachelines.
#pragma omp parallel for
for (int i = 0; i < N; i++)
float row_sum = 0.;
for (int k = rowOffsets[i]; k < rowOffsets[i+1]; k++){
row_sum += values[k];
}
sum[i] = row_sum;
}