23 lines
522 B
C
23 lines
522 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 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;
|
||
|
}
|