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

pipeline scheduling tasks

urykhy
Beginner
456 Views
Hi,

a have a problem with pipeline:
say i have a 4 threads, 4 tasks, and 3 pipeline stages:
emit(serial), worker(not serial), and join(serial)

but if i run a code - a got following output:

processing with 4 files (4 threads)
emit __cdb_tbench-0
emit __cdb_tbench-1
worker: __cdb_tbench-0
emit __cdb_tbench-2
emit __cdb_tbench-3
worker: __cdb_tbench-0 done
joining : __cdb_tbench-0
worker: __cdb_tbench-1
joining : __cdb_tbench-0 done: 10000000
worker: __cdb_tbench-1 done
joining : __cdb_tbench-1
worker: __cdb_tbench-2
joining : __cdb_tbench-1 done: 10000000
worker: __cdb_tbench-2 done
joining : __cdb_tbench-2
worker: __cdb_tbench-3
joining : __cdb_tbench-2 done: 10000000
worker: __cdb_tbench-3 done
joining : __cdb_tbench-3
joining : __cdb_tbench-3 done: 10000000
Done.

worker stage is nearly to 1 sec, join is faster.

looks like stages are interleaved, but worker() never called in parallel,
can you advise why ?

code looks like:

template
struct Stage : public tbb::filter {
T& ticket;
Stage(T& ticketIn) : tbb::filter(serial), ticket(ticketIn) {}
virtual ~Stage() throw() {}
virtual void* operator()(void* item)
{
return ((&ticket)->*callback)(item);
}
....
tbb::pipeline pl;
internal::Stage s1(ticket);
internal::Stage s2(ticket);
internal::Stage s3(ticket);

pl.add_filter(s1);
pl.add_filter(s2);
pl.add_filter(s3);
pl.run(data.size());

0 Kudos
1 Reply
urykhy
Beginner
456 Views
oh... i find a problem:

a should not name my argument as `serial` in Stage template



0 Kudos
Reply