#include #include #include #include void workload() { printf("Thread: %d is working on the workload.\n", omp_get_thread_num()); sleep(1); } int main(int argc, const char *argv[]) { double start = omp_get_wtime(); omp_set_num_threads(5); // For a task to be actually executed in parallel // it needs to be inside a parallel section #pragma omp parallel // As we only want to create 10 tasks we use a single section #pragma omp single for (int i = 0; i<10; i++) { // TODO: Use a task directive to parallelize the workload workload(); } double end = omp_get_wtime(); printf("That took a total of %f seconds.\n", end - start); return 0; }