Zeigt Verwendung der OpenMP #pragma omp parallel for Direktive
#include <stdio.h>
#include <omp.h>
int main(int argc, char** argv)
{
#pragma omp parallel for
for (int i = 0; i<=10; i++)
{
int threadNum = omp_get_thread_num();
#pragma omp critical(c1)
{
printf("Thread %d performs iteration %d\n", threadNum, i);
}
}
return 0;
}
Kommentare zum Snippet