openmp的测试程序
#include <stdio.h>
#include <time.h>
int main()
{
volatile int i;
volatile int j;
int sum = 0;
double t1, t2;
t1 = clock();
#pragma omp parallel
{
#pragma omp for nowait
for (i = 0 ; i < 10 ; i++)
{
#pragma omp atomic
sum += 1;
printf("the sum is %d\n\r", sum);
}
#pragma omp for
for (j = 0 ; j < 10 ; j++)
{
printf("hahaha%d\n\r", j);
}
}
t2 = clock();
printf("the cost time on this demo is %f\r\n", (t2 - t1)/CLOCKS_PER_SEC);
printf("the sum is %d\n\r", sum);
return 0;
}