|
#include <stdio.h>
|
|
#include <omp.h>
|
|
|
|
int main(int argc, const char *argv[])
|
|
{
|
|
int sum = 0;
|
|
// Use an atomic operation instead to add up the values
|
|
|
|
#pragma omp parallel for num_threads(2)
|
|
for (int i = 0; i < 10000; i++) {
|
|
sum++;
|
|
}
|
|
|
|
printf("sum: %d\n", sum);
|
|
|
|
return 0;
|
|
}
|