icp/oer/courses/c-openmp/sections/01-introduction/01-parallel-for/solution.c

23 lines
522 B
C
Raw Normal View History

2018-05-05 22:18:02 +00:00
#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 num_threads(7)
#pragma omp for
for (int i = 0; i<10; i++) {
printf("Iteration %d in thread: %d\n", i, omp_get_thread_num());
}
return 0;
}