我需要使用OpenMP实现并行选择排序算法, 但我无法在Stack Overflow或一般的互联网上找到太多信息。
这是我的串行代码:
这是我的串行代码:
void selectionsort(int* arr, int size)
{
for (int i = size - 1; i > 0; --i)
{
int max = i;
for (int j = i - 1; j >= 0; --j)
{
if (arr[j] > arr[max])
{
max = j;
}
}
swap(arr[i], arr[max]);
}
}
有没有人知道如何并行实现这种类型的排序算法?至少在理论上?
pragma omp
,这可以轻松地并行化。 - P. Brunet