Thursday, December 18, 2008

The wonder of OpenMP

It took me about 5 minutes to make an app multithreaded with openMP.

Step 1 : Turn on openMP flag


Step 2 :  Add #pragma omp parallel for to the existing for statement like so
#pragma omp parallel for
for ( int i = 0; i < parlist.count(); i++)
    // Do your code here.
   // Cannot jump out of for loop. No breaks, no returns.
Step 3 : Profit!

1 comment:

James Chan said...

Also remember that you can't modify the iterator at all.

DeFlac showed great speed improvement.

The best improvement comes when a lot of work is going to be done within the thread. Simple comparisons... bleh. Even worse performance than normal.