Skip to content

Commit

Permalink
hybrid/demos: added task-dep.c demo
Browse files Browse the repository at this point in the history
  • Loading branch information
juhanikataja committed Jun 29, 2024
1 parent 9e2afc2 commit 88ce198
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions hybrid/demos/task-dep.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

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


int main(int argc, char *argv[])
{

int data = 1;
#pragma omp parallel
#pragma omp single
{
for(int i=0;i<5; i++)
{
#pragma omp task depend(in: data) // in: depend on all previous out/inout tasks
{
printf("task A %d\n", i);
sleep(1);
}
#pragma omp task depend(inout: data) // inout: depend on all previous in/inout/out tasks
{
printf("task B %d\n", i);
}
}
#pragma omp task depend(out: data) // out: depend on all previous in/inout/out tasks (same as out)
{
printf("task C\n");
}
}
return 0;
}

0 comments on commit 88ce198

Please sign in to comment.