Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

parallelize vector array with intelTBB

pascual__carlos
Beginner
194 Views

Hi, I´m new in IntelTBB and I am trying to parallelize an array of vector. This is the function, in which I pass the array as a pointer.

void calculate(map<int,string> &m, vector<order>* ord, auto&k, string &dir){

for(int i=0;i<k;i++){

   //here I declare a series of variables
   
   for(int j=0; j<ord.size()-1; j++){

        // here I do a series of calculations with the values of 
        // the array and I generate one file for each row of the array
        // with this calculations, to do this I declare more variables
   }


}


}

I want to parallelize this function so that it can process several rows of the array at the same time. I have tried to do this with parallel_for as follows:

void calculate(map<int,string> &m, vector<order>* ord, auto&k, string &dir){


tbb::parallel_for(tbb::blocked_range<int>(0,k),[&](tbb::blocked_range<int> r)
{

for(int i=r.begin(); ;i<r.end();i++){

   //here I declare a series of variables
   
   for(int j=0; j<ord.size()-1; j++){

        // here I do a series of calculations with the values of 
        // the array and I generate one file for each row of the array
        // with this calculations, to do this I declare more variables
   }


}
});


}

This program compile well, but when it is executed, sometimes I obtain one result (generate text file that I need) with wrong calculations, but normally  I obtain an error like this: 

TBB Warning : Exact exception propagation is requested by application but the linked library i
is built without support for it
terminate called after throwing an instance of 'tbb::capture_exception'

I don´t know if this formis the correct form to do it. Can anybody help me?.

Thank you!

0 Kudos
2 Replies
Alexei_K_Intel
Employee
194 Views

Hi,

Looks like there are at least two issues:

  • The application is built with C++11/14 (or newer) compiler options. However, the TBB library is taken from a wrong directory. Do you have a Linux-based system?
  • The algorithm throws an exception during parallel processing but this exception is not handled properly and the application terminates.

Regards,
Alex

pascual__carlos
Beginner
194 Views

Hi Alex,

I am using Oracle VM Virtual Box with Ubuntu 16.04, and I compile as follows:

g++ -std=c++14 p1.cpp -ltbb

I checked the execution of another simpler example and it worked well with Intel TBB. I guess the problem is in parallelizing my application, but I am not sure.

 Is it possible to parallelize this function that I have?

Thank you Alex!

Regards.

Reply