Intel® Threading Building Blocks

Can I use tbb::thread?

Quick question. Why is tbb::thread not part of the "disclosed" API? Currently I'm using Boost::thread, but was wondering if there might be any benefits in switching to tbb's thread, however since its not officially documented I was wondering if its not meant to be used by end-users, perhaps tbb's devs want to reserve the rights to swap the low level threading API as needed so it's not a reliable API, or something else like that.


parallel algorithm is no faster than serial...

I wrote a program to calculate every factorial of i from i=0 to n, but the parallel portion of the program runs no faster (sometimes slower), than the serial version. This is still the first program I've written using TBB (and the first time using a template library), so I was hoping someone might see something obvious that would cause this behavior. (I'm using Linux and I've compiled using intel c++ and gcc, with the same results).

Using both, Threads and Tasks. Does it make sense?


I am not very familiar with Intel TBB, but while reading a bit in the docs and looking at some presentations I was wondering whether it makes sense to use both, Threads and Tasks.

The background is the following: I am thinking of an internet TCP server that accepts several connections. To handle input I would start a new thread for each client in order not to block the main loop with any networks troubles. For any other actions I would create tasks.

TBB design patterns/architecture question

Sorry for the long post but I hope some of you may find this unusual application of TBB interesting.

I am trying to build an event processing framework using TBB. Based on helpful comments received in another thread, I have a few questions about the right design for this system and in fact, if TBB is indeed the right solution for this problem. I appreciate your suggestions.

odd behavior on simple program (factorials)

I'm trying to get a grasp of TBB, so I started out by writing a simple program to calculate the factorial of i, from i=0 to n. I've been working with the GNU MP (bignum) library, so I decided to use it as well to handle the large factorials. I'm really just looking to get a simple program to behave properly...but I'm having some difficulties with it. When I run the following code (printing out the "i" in the parallel loop), I get some very strange results....

Need help with pipeline deadlock

Hi everyone,

I have a problem concerning proper termination of pipelines and I'm running out of ideas on where the problem might be.

The setup is as follows. I have one class that handles loading and decompressing of video streams. This process is realised via the TBB pipeline mechanism. Once the start() method of my class is called, it begins loading and decompressing frames and delivers them to a follow-up component.

Equivalent of omp parallel sections?


I know that tbb is not supposed to be a direct replacement for openmp, but having dabbled with openmp a little bit I think that in general TBB suits my needs more than openmp so I was planning to use tbb exclusively

However, I'm still unsure how I would effect an omp parallel sections piece of code:


#pragma omp parallel sections
#pragma omp section
#pragma omp section
#pragma omp section

I would guess that using the task scheduler directly is the way to do it?

Spin wait implementation in TBB

In src\tbb\TBB_misc.h there is a spin wait which embeds a looped PAUSE instruction in a while wait, something like this:

while (!condition)


if( count<=LOOPS_BEFORE_YIELD ) {

//[hanm] this is actually a looped PAUSE
} else {


My question is, why doing this looped PAUSE, instead of issuing *a single* PAUSE instruction in the spin wait? Someting looks like:

int count = 0;

while (!condition)


PAUSE; //emit asm here

count ++;

error when compiling sample code with g++

I am beginning to work with the Threading Building Blocks and I'm having an issue compiling the sample program (sub_string_finder.cpp) with g++. However, when I use intel's c++ compiler, it compiles just fine.

To compile with g++, I execute:

g++ sub_string_finder.cpp -ltbb

and I get an error:
sub_string_finder.cpp:60: error: first argument of int main(size_t, char**) should be int

However, when I execute: icpc sub_string_finder.cpp -ltbb

parallel_Reduces memory access problem

hi all,

I am trying to figure out for last 2 days why this code is not working. The code is giving me memory access error.

The code is as follows:-

#include "tbb/task_scheduler_init.h"
#include "tbb/parallel_reduce.h"
#include "tbb/blocked_range.h"

using namespace tbb;
using namespace std;

class Parallel_StringFinder{

vector edgeList;
vector nodeList;
set::iterator it;
bool flag1,flag2,toInsert;


Subscribe to Intel® Threading Building Blocks