Yep, the idea behind openMP is related to what you normally call directives or pragmas[1]. OpenMP offers a set of such directives so you can choose ways to parallelize *chunks* of your code accordingly to the best option you want. List of pragmas here [2].
int main(int argc, char *argv[]) { const int N = 100000; int i, a[N]; #pragma omp parallel for for (i = 0; i < N; i++) a[i] = 2 * i; return 0; }
On Mon, 6 Dec 2010, Claude Heiland-Allen wrote:I don't know how OpenMP works, but is there a way to apply it selectively to only part of a project ? I'm just guessing that it could make a big difference, e.g. if you don't apply it to numop*.cxx but you do apply it to much of the rest (perhaps also exclude gridflow.cxx itself because it contains the BitPacking class).
NB: while it does use more than one core, I just compared with the single core version of gridflow without openmp and it uses only 25% of my cpu (on one core) while the openmp version uses 145% of my cpu (spread over two cores). So, it's no magic bullet...
I just had this idea because of what you told me on the #dataflow chat.
_______________________________________________________________________
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC