Skip to content
Snippets Groups Projects
Commit f256cc4c authored by Alam's avatar Alam
Browse files

Reduce false sharing by late array assignment

parent d06e272f
No related merge requests found
No preview for this file type
No preview for this file type
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -101,6 +101,9 @@ int main(int argc, char *argv[]) { ...@@ -101,6 +101,9 @@ int main(int argc, char *argv[]) {
// find local minima // find local minima
#pragma omp parallel num_threads(thread_count) shared(minimumLocalDist,minimumLocalNode,graph,minDist) #pragma omp parallel num_threads(thread_count) shared(minimumLocalDist,minimumLocalNode,graph,minDist)
{ {
int minLocalDist = -1;
int minLocalNode = -1;
int my_rank = omp_get_thread_num(); int my_rank = omp_get_thread_num();
for (int node = binSize * my_rank; node < binSize * (my_rank + 1); node++) { for (int node = binSize * my_rank; node < binSize * (my_rank + 1); node++) {
if (!visited[node]) { if (!visited[node]) {
...@@ -108,15 +111,18 @@ int main(int argc, char *argv[]) { ...@@ -108,15 +111,18 @@ int main(int argc, char *argv[]) {
minDist[node] = minDist[activeNode] + graph[activeNode * n_nodes + node]; minDist[node] = minDist[activeNode] + graph[activeNode * n_nodes + node];
} }
if (minimumLocalDist[my_rank] == -1) { if (minLocalDist == -1) {
minimumLocalDist[my_rank] = minDist[node]; minLocalDist = minDist[node];
minimumLocalNode[my_rank] = node; minLocalNode = node;
} else if (minimumLocalDist[my_rank] > minDist[node]) { } else if (minLocalDist > minDist[node]) {
minimumLocalDist[my_rank] = minDist[node]; minLocalDist = minDist[node];
minimumLocalNode[my_rank] = node; minLocalNode = node;
} }
} }
} }
minimumLocalDist[my_rank] = minLocalDist;
minimumLocalNode[my_rank] = minLocalNode;
} }
thrMinimum = 0; thrMinimum = 0;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment