-
Notifications
You must be signed in to change notification settings - Fork 25
[WIP] Taskgraphs #886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[WIP] Taskgraphs #886
Changes from 6 commits
5a7bff8
fd47b8d
1325771
95c7f0a
091773b
f7e0560
cd017b5
b343b41
bfa752e
2ec5abe
b2aded1
4577cad
8d512e0
6c157a6
eb45071
cec5249
0fd9333
7156dc8
0461fec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| //===-- test_taskgraph.c ------------------------------------------------===// | ||
| // | ||
| // OpenMP API Version 6.0 Nov 2024 | ||
| // | ||
| // Description | ||
| // testTaskgraph(): | ||
| // Create a taskgraph | ||
| // Ensures the structured block is executed | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <stdio.h> | ||
| #include <assert.h> | ||
| #include <stdlib.h> | ||
| #include <omp.h> | ||
| #include "ompvv.h" | ||
|
|
||
| int testTaskgraph(void) | ||
| { | ||
| int errors = 0; | ||
| int x = 0; | ||
| #pragma omp parallel shared(x) | ||
| { | ||
| # pragma omp single | ||
| { | ||
| # pragma omp taskgraph | ||
| { | ||
| ++x; | ||
| } | ||
| } | ||
| } | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, x != 1); | ||
| return errors; | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| int errors = 0; | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, testTaskgraph()); | ||
| OMPVV_REPORT_AND_RETURN(errors); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| //===-- test_taskgraph.c ------------------------------------------------===// | ||
| // | ||
| // OpenMP API Version 6.0 Nov 2024 | ||
| // | ||
| // Description | ||
| // testTaskgraphHeterogeneous(): | ||
| // Create a taskgraph, spawns 3 dependent tasks | ||
| // T1 -> T2 -> T3 | ||
| // with (T1, T3) on device, (T2) on host. | ||
| // | ||
| // Ensures that | ||
| // - the structured block is executed 1 to N times | ||
| // - 3*N tasks are executed/replayed | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <stdio.h> | ||
| #include <assert.h> | ||
| #include <stdlib.h> | ||
| #include <omp.h> | ||
| #include "ompvv.h" | ||
|
|
||
| int testTaskgraphHeterogeneous(void) | ||
| { | ||
| int errors = 0; | ||
|
|
||
| # define N 16 | ||
| int x = 0; | ||
| int y = 0; | ||
|
|
||
| # pragma omp parallel shared(x, y) | ||
| { | ||
| # pragma omp single | ||
| { | ||
| for (int i = 0 ; i < N ; ++i) | ||
| { | ||
| # pragma omp taskgraph | ||
| { | ||
| ++x; | ||
|
|
||
| # pragma omp target nowait map(tofrom: y) depend(out: y) shared(y) | ||
| ++y; | ||
|
|
||
| # pragma omp task depend(out: y) shared(y) | ||
| ++y; | ||
|
|
||
| # pragma omp target nowait map(tofrom: y) depend(out: y) shared(y) | ||
| ++y; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| OMPVV_TEST_AND_SET_VERBOSE(errors, !(0 < x && x <= N)); | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, y != 3*N); | ||
| return errors; | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| int errors = 0; | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, testTaskgraphHeterogeneous()); | ||
| OMPVV_REPORT_AND_RETURN(errors); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| //===-- test_taskgraph_id.c ------------------------------------------------===// | ||
| // | ||
| // OpenMP API Version 6.0 Nov 2024 | ||
| // | ||
| // Description | ||
| // testTaskgraphId(): | ||
| // M times, run N taskgraphs constructs with id '0<=i<N' that spawns 3 tasks | ||
| // T1 -> T2 -> T3 | ||
| // Ensure that each taskgraph' structured block executed 1 to M times | ||
| // Ensure that each triplets executed precisely M times | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <stdio.h> | ||
| #include <assert.h> | ||
| #include <stdlib.h> | ||
| #include <omp.h> | ||
| #include "ompvv.h" | ||
|
|
||
| int testTaskgraphGraphId(void) | ||
| { | ||
| int errors = 0; | ||
|
|
||
| # define N 16 | ||
| # define M 16 | ||
|
|
||
| int x[N]; | ||
| int y[N]; | ||
| memset(x, 0, sizeof(x)); | ||
| memset(y, 0, sizeof(y)); | ||
|
|
||
| # pragma omp parallel shared(x, y) | ||
| { | ||
| # pragma omp single | ||
| { | ||
| for (int j = 0 ; j < M ; ++j) | ||
| { | ||
| for (int i = 0 ; i < N ; ++i) | ||
| { | ||
| # pragma omp taskgraph graph_id(i) | ||
| { | ||
| ++x[i]; | ||
| for (int i = 0 ; i < 3 ; ++i) | ||
rpereira-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| # pragma omp task depend(out: y) shared(y) | ||
| { | ||
| # pragma omp atomic | ||
| ++y[i]; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| for (int i = 0 ; i < N ; ++i) | ||
| { | ||
| // each taskgraph strucuted block must have executed 1 to M times | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, !(0 < x[i] && x[i] <= M)); | ||
|
|
||
| // each triplets must have executed M times | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, y[i] != M); | ||
rpereira-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| return errors; | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| int errors = 0; | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, testTaskgraphGraphId()); | ||
| OMPVV_REPORT_AND_RETURN(errors); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| //===-- test_taskgraph_if.c ------------------------------------------------===// | ||
| // | ||
| // OpenMP API Version 6.0 Nov 2024 | ||
| // | ||
| // Description | ||
| // testTaskgraphIf(): | ||
| // Call | ||
| // taskgraph if(0) --> execute taskgraph construct, optionally creating a taskgraph record | ||
| // taskgraph if(1) --> skip | ||
| // taskgraph if(2) --> execute taskgraph construct, maybe replay taskgraph | ||
| // record, or optionally create a taskgraph record | ||
| // ensures that the structured block is executed 1 or 2 times | ||
| // ensures that tasks are executed twice | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <stdio.h> | ||
| #include <assert.h> | ||
| #include <stdlib.h> | ||
| #include <omp.h> | ||
| #include "ompvv.h" | ||
|
|
||
| int testTaskgraphIf(void) | ||
| { | ||
| int errors = 0; | ||
| int x = 0; | ||
| int y = 0; | ||
| #pragma omp parallel shared(x, y) | ||
| { | ||
| # pragma omp single | ||
| { | ||
| for (int i = 0 ; i < 3 ; ++i) | ||
| { | ||
| # pragma omp taskgraph if(i != 1) | ||
| { | ||
| ++x; | ||
|
|
||
| # pragma omp task shared(y) | ||
| ++y; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // the structured block must have been executed once or twice | ||
| // (once if creating a taskgraph record, twice if creating no taskgraph record) | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, !(x == 1 || x == 2)); | ||
rpereira-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
rpereira-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // the task must execute precisely twice | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, y != 2); | ||
rpereira-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| return errors; | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| int errors = 0; | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, testTaskgraphIf()); | ||
| OMPVV_REPORT_AND_RETURN(errors); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| //===-- test_taskgraph.c ------------------------------------------------===// | ||
rpereira-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // | ||
| // OpenMP API Version 6.0 Nov 2024 | ||
| // | ||
| // Description | ||
| // testTaskgraphNoGroup(): | ||
| // Run a taskgraph nogroup construct N times, | ||
| // ensures the structured block is executed from 1 to N times | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <stdio.h> | ||
| #include <assert.h> | ||
| #include <stdlib.h> | ||
| #include <omp.h> | ||
| #include "ompvv.h" | ||
|
|
||
| int testTaskgraphNoGroup(void) | ||
| { | ||
| int errors = 0; | ||
|
|
||
| # define N 16 | ||
| int x = 0; | ||
| int y = 0; | ||
| #pragma omp parallel shared(x, y) | ||
| { | ||
| # pragma omp single | ||
| { | ||
| for (int i = 0 ; i < N ; ++i) | ||
| { | ||
| # pragma omp taskgraph nogroup | ||
| { | ||
| ++x; | ||
| # pragma omp task shared(y) | ||
| { | ||
| # pragma omp atomic | ||
| ++y; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, !(0 < x && x <= N)); | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, y != N); | ||
| return errors; | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| int errors = 0; | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, testTaskgraphNoGroup()); | ||
| OMPVV_REPORT_AND_RETURN(errors); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| //===-- test_taskgraph.c ------------------------------------------------===// | ||
| // | ||
| // OpenMP API Version 6.0 Nov 2024 | ||
| // | ||
| // Description | ||
| // testTaskgraphParallel(): | ||
| // N times, have 'nthreads' threads call the same taskgraph construct | ||
| // | ||
| // ensure the structured block executed 1 to N times, | ||
|
||
| // and the replayable task 'N*nthreads' times | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <stdio.h> | ||
| #include <assert.h> | ||
| #include <stdlib.h> | ||
| #include <omp.h> | ||
| #include "ompvv.h" | ||
|
|
||
| int testTaskgraphParallel(void) | ||
| { | ||
| int errors = 0; | ||
|
|
||
| # define N 16 | ||
| int x = 0; | ||
| int y = 0; | ||
| int nthreads = -1; | ||
|
|
||
| #pragma omp parallel shared(x, y, nthreads) | ||
| { | ||
| # pragma omp single | ||
| { | ||
| nthreads = omp_get_num_threads(); | ||
| } | ||
|
|
||
| for (int i = 0 ; i < N ; ++i) | ||
| { | ||
| # pragma omp taskgraph | ||
| { | ||
| ++x; | ||
rpereira-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
rpereira-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # pragma omp task shared(y) | ||
| { | ||
| # pragma omp atomic | ||
| ++y; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, nthreads <= 0); | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, !(0 < x && x <= N)); | ||
rpereira-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| OMPVV_TEST_AND_SET_VERBOSE(errors, y != nthreads*N); | ||
|
|
||
| return errors; | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| int errors = 0; | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, testTaskgraphParallel()); | ||
| OMPVV_REPORT_AND_RETURN(errors); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.