The OpenMP ARB supports various international events to help educate and inform the OpenMP community. Notices about upcoming conferences and events will be posted here.
- Posts: 1
- Joined: Mon Aug 29, 2016 8:41 am
I'm trying to parallelize an insertion sort algorithm in the following way:
Code: Select all
void insertionsort(int vetor, int tam)
int i, j, tmp;
#pragma omp parallel for shared (vetor, tam, tmp) private (i,j)
for(i = 1; i < tam; i++)
j = i;
while(j > 0 && vetor[j-1] > vetor[j])
tmp = vetor[j];
vetor[j] = vetor[j-1];
vetor[j-1] = tmp;
But doesn't return the correct ordering. Can someone help me?
- Posts: 808
- Joined: Thu Jan 08, 2009 10:12 am
- Location: EPCC, University of Edinburgh
You can't parallelise insertion sort like this: each iteration of the loop must be executed after the previous one.
(Please post questions like this in the Using OpenMP forum http://openmp.org/forum/viewforum.php?f=3