icp/oer/courses/c-openmp/sections/02-advanced/04-atomic/solution.c

22 lines
506 B
C

#include <stdio.h>
#include <unistd.h>
#include <omp.h>
void workload()
{
// We are simulating a workload by sleeping the thread
// This is obviously not an accurate representation
// of real computation, but it works for this example
sleep(1);
}
int main(int argc, const char *argv[])
{
// TODO: parallelize this:
#pragma omp parallel for num_threads(7)
for (int i = 0; i<10; i++) {
printf("Iteration %d in thread: %d\n", i, omp_get_thread_num());
}
return 0;
}