Intel® Threading Building Blocks

parallel_reduce

A loop can do a reduction, as in this summation:

float SerialSumFoo( float a[], size_t n ) {
    float sum = 0;
    for( size_t i=0; i!=n; ++i )
        sum += Foo(a[i]);
    return sum;
}

If the iterations are independent, you can parallelize this loop using the template class parallel_reduce as follows:

Lock Pathologies

Locks can introduce performance and correctness problems. If you are new to locking, here are some of the problems to avoid:

Deadlock

Deadlock happens when threads are trying to acquire more than one lock, and each holds some of the locks the other threads need to proceed. More precisely, deadlock happens when:

Subscribe to Intel® Threading Building Blocks