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

task parallel in pipeline stages

Xingjing_Lu
Beginner
313 Views

In a four-state pipeline, I employ task parallelism in two stages. 

1) ReadFilter::operator(){

 // 1) Create task-queues. 
  ReadTask *T[RLIDATASKNUM];
  task_list TL;
  for( int i = 0; i < RLIDATASKNUM; i++){
    PtrQueue= &next_rwtrace->TaskQueue[0];
    PtrLen = 0;
    T = new(task::allocate_root()) ReadTask(i, Length, &PtrLen, PtrItems, PtrQueue );
    T->set_ref_count(0);
    TL.push_back(*T);
  }
  task::spawn_root_and_wait(TL);  // error  happens here.

}

 

2) ProcessFilter::operator{

LIDATask *T[RLIDATASKNUM];
    task_list TL;
    for(int i = 0; i < RLIDATASKNUM; i++){
      PtrQueue= &input->TaskQueue[0];
      T = new(task::allocate_root()) LIDATask(LoopIter,
            &NewAccAddr[0], PtrQueue, PtrLen,
            LRStreamNum, LWPresNum, this, i );
      T->set_ref_count(0);
      TL.push_back(*T);
    }
    task::spawn_root_and_wait(TL);

}

 

When I only parallelized the 2) ProcessFilter, it can run sucessfully; but when I parallelized both stages with task, it ran into errors:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fc09fd0f700 (LWP 13899)]
0x00007fc0a0d4a04d in tbb::task::state (this=0xea60) at ../../include/tbb/task.h:793
793         state_type state() const {return state_type(prefix().state);}
(gdb) bt
#0  0x00007fc0a0d4a04d in tbb::task::state (this=0xea60) at ../../include/tbb/task.h:793
#1  0x00007fc0a0d5ca7b in tbb::internal::custom_scheduler<tbb::internal::IntelSchedulerTraits>::local_wait_for_all (this=0x7fc0a02f7e00, parent=..., child=0x7fc0a02feb40) at ../../src/tbb/custom_scheduler.h:477
#2  0x00007fc0a0d50c1e in tbb::internal::arena::process (this=0x7fc0a0132180, s=...)
    at ../../src/tbb/arena.cpp:94
#3  0x00007fc0a0d4f0a0 in tbb::internal::market::process (this=0x7fc0a031fd80, j=...)
    at ../../src/tbb/market.cpp:477
#4  0x00007fc0a0d464ab in tbb::internal::rml::private_worker::run (this=0x7fc0a0317700)
    at ../../src/tbb/private_server.cpp:273
#5  0x00007fc0a0d46326 in tbb::internal::rml::private_worker::thread_routine (arg=0x7fc0a0317700)
    at ../../src/tbb/private_server.cpp:226
#6  0x0000003f316079d1 in start_thread () from /lib64/libpthread.so.0
#7  0x0000003f312e88fd in clone () from /lib64/libc.so.6

0 Kudos
1 Reply
Xingjing_Lu
Beginner
313 Views

I know the reason of the error.

A return is needed in the class of task. I added "return NULL".

 

0 Kudos
Reply