/* * very simple example of using tasks */ #include #include #include /* OpenMP header file */ #define NTASKS 20 int main(void) { printf("starting program\n"); int ntasks = NTASKS; #pragma omp parallel shared(ntasks) { /* run this in a single thread */ #pragma omp single for (int n = 0; n < ntasks; ++n) { #pragma omp task { printf("hello, world, from task %d in thread %d\n", n, omp_get_thread_num()); } } } printf("all done\n"); return EXIT_SUCCESS; }