- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am using template parallel_for and I have a seg fault at execution. (It's not the first time that I try using parallel_for). here is my serial code :
And here is my code :
It compiles. But It crashes at runtime with segmentation fault. It does not enter the operator() method ( a printf just before the loop doesn't appear).
And gdb show that segfault occurs in tbb::parallel_for....get_obj_for()
I don't know what to do now.
I am using template parallel_for and I have a seg fault at execution. (It's not the first time that I try using parallel_for). here is my serial code :
template
void MyNode::get_obj( std::vector
&objects,
const Q in_rect ) const
{
for( unsigned int i = 0; i < this->elem_list.size( ); i++ )
{
Node*sample = this->elem_list.at( i );
if( sample->get_foo().bar( in_rect ) == true )
{
sample_fcnB( objects, in_rect );
}
}
}
And here is my code :
template
class get_obj_for {
const vect< Node* > &my_elem_list;
const B &my_in_rect ;
vector&my_objects ;
public:
void operator()( const blocked_range& r ) const {
for( unsigned int i = r.begin(); i < r.end(); i++ )
{
Node*sample = my_elem_list.at( i );
if( sample->get_foo().bar( my_in_rect ) == true )
{
sample_fcnB( my_objects, my_in_rect );
}
}
}
// Constructor
get_obj_for(
& nbsp; const vect< Node* > &liste_elem,
const B &rect,
vector&objects) :
my_m_elel_list(liste_elem),
my_in_rect(rect),
my_objects(objects)
{}
};
It compiles. But It crashes at runtime with segmentation fault. It does not enter the operator() method ( a printf just before the loop doesn't appear).
And gdb show that segfault occurs in tbb::parallel_for....get_obj_for()
I don't know what to do now.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does your code crash even with a single thread?
What I usually do is run with a single thread (e.g. "tbb::use task_scheduler_init init(1);" and see if the code crashses. If so, then I debug the code like I would debug serial. code (e.g. single step it, or look at the traceback).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Problem solved. I had forgotten to initialize tbb...

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page