OpenMP, pour la boucle à l'intérieur de la section

Je voudrais exécuter le code suivant (ci-dessous). Je veux pondre deux threads indépendants, chacun pourrait s'exécuter en parallèle une boucle for. Malheureusement, j'obtiens une erreur. Apparemment, parallèle for ne peut pas être généré à l'intérieur de section. Comment résoudre ce problème?

#include <omp.h>
#include "stdio.h"

int main()
{

omp_set_num_threads(10);

#pragma omp parallel    
#pragma omp sections
  {
#pragma omp section
#pragma omp for
    for(int i=0; i<5; i++) {
        printf("x %d\n", i);
    }

#pragma omp section
#pragma omp for
    for(int i=0; i<5; i++) {
        printf(". %d\n", i);
    }
  } //end parallel and end sections
}

Et l'erreur:

main.cpp: In function int main()’:
main.cpp:14:9: warning: work-sharing region may not be closely nested inside of work-sharing, critical, ordered, master or explicit task region [enabled by default]
main.cpp:20:9: warning: work-sharing region may not be closely nested inside of work-sharing, critical, ordered, master or explicit task region [enabled by default]

OriginalL'auteur Jakub M. | 2011-10-27