samedi 30 novembre 2019

Using threads to sort in parallel (C++11)

I am trying to sort an array (1,000,000 elements) in parallel using threads but I am getting the error <unresolved overloaded function type>. For the sort function I pass where I want it to start, where I want it to end, and my comparator function. Below is example code:

Thread calling:

thread th1(arraySort, array.begin(), array.begin() + 500000);
thread th2(arraySort, array.begin() + 500001, array.end());

Function:

template <typename ForwardIteratorType>
void arraySort(ForwardIteratorType  start, ForwardIteratorType end) {
    sort(start, end, compare);
}

Note that without threads it works, but I am trying to speed the sorting up.

I am new to multithreading, so let me know what you guys suggest.

Aucun commentaire:

Enregistrer un commentaire