#include <stdio.h>
#include <unistd.h>
#include <omp.h>
#include <time.h>

void workload()
{
    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++) {
        // Use a task to parallelize the workload
        #pragma omp task
        workload();
    }

    double end = omp_get_wtime();
    printf("That took a total of %f seconds.\n", end - start);
    
    return 0;
}
