Fast parallel sort algorithm?
In my application sorting a vector of this struct takes with std::sort (by weight) about 30 sec with 50000 items and is a major bottle neck. [code]struct Weight_Index { double weight; size_t index; }; struct by_weight_incr { bool operator()(Weight_Index const &left, Weight_Index const &right) { return left.weight < right.weight; } }; [/code] Can anyone suggest a gpu-algorithm that does the job (much) faster? Preferably with some code example:-)
In my application sorting a vector of this struct takes with std::sort (by weight) about 30 sec with 50000 items and is a major bottle neck.

struct Weight_Index {
double weight;
size_t index;
};
struct by_weight_incr {
bool operator()(Weight_Index const &left, Weight_Index const &right) {
return left.weight < right.weight;
}
};


Can anyone suggest a gpu-algorithm that does the job (much) faster? Preferably with some code example:-)

#1
Posted 11/14/2017 11:20 AM   
Both [url=https://nvlabs.github.io/cub/]CUB[/url] and [url=https://thrust.github.io/]Thrust[/url] provide sorting algorithms. You can try these.
Both CUB and Thrust provide sorting algorithms. You can try these.

#2
Posted 11/14/2017 12:54 PM   
I suspect your choice of cointainer may be the bottleneck here. 50000 16 byte elements like yours should be piece of cake to sort for a CPU. Try sorting these elements in a std::vector<>, and also try a std::list<> for comparison when benchmarking the CPU based sort. were you using std::sort() or qsort() ? Christian
I suspect your choice of cointainer may be the bottleneck here.

50000 16 byte elements like yours should be piece of cake to sort for a CPU.

Try sorting these elements in a std::vector<>, and also try a std::list<> for comparison when benchmarking the CPU based sort.

were you using std::sort() or qsort() ?

Christian

#3
Posted 11/15/2017 04:51 PM   
The container to be sorted is a vector<Weight_Index> and I am using std::sort. I have every little experience with C++ and do not know what to expect.
The container to be sorted is a vector<Weight_Index> and I am using std::sort.
I have every little experience with C++ and do not know what to expect.

#4
Posted 11/15/2017 07:16 PM   
Scroll To Top

Add Reply