Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2424 Discussions

parallel_sort does not sort for input size > ~500

sinedie
Beginner
96 Views
Hello,
The following code produces seg fault with v2.0 and v2.1 of TBB on "Linux office.iiita.ac.in 2.6.27-desktop-0.rc8.2mnb #1 SMP i686 Intel Core2 CPU 4400 @ 2.00GHz GNU/Linux" with 1 GB RAM. I am unable to find the fix or source of the problem. Help please!

[cpp]#include 
#include 
#include 

#define N 400

using namespace std;
using namespace tbb;

void SortExample(float *a)
{
        for( int i = 0; i < N; i++ ) {
                a = (float) rand() / RAND_MAX;
        }
        parallel_sort(a, a + N - 10);
}

int main()
{
        float *a = (float *) malloc(N * sizeof(float));

        SortExample(a);

        for (int i=0; i<25; i++) {
                printf("%12.9fn", a);
        }

        return 0;
}

[/cpp]

0 Kudos
3 Replies
Alexey_K_Intel3
Employee
96 Views
You did not activate TBB worker threads.
See the TBB Tutorial for how to do that, or search the forum for "task_scheduler_init".
sinedie
Beginner
96 Views
You did not activate TBB worker threads.
See the TBB Tutorial for how to do that, or search the forum for "task_scheduler_init".
Thanks Alexey! It was a silly mistake!
jimdempseyatthecove
Black Belt
96 Views

If you are interested in parallel sorting the Threading Challenge has recently completed using the RadixSort method. I haven't looked at all the entries, one of them is likely using TBB. Even for non-TBB entries it may be a good place to find a good (simple) parallel sort technique.

Jim Dempsey
Reply