-
Notifications
You must be signed in to change notification settings - Fork 24
[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
Open
rpereira-dev
wants to merge
6
commits into
OpenMP-Validation-and-Verification:master
Choose a base branch
from
rpereira-dev:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[WIP] Taskgraphs #886
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5a7bff8
[wip] Adding tests for taskgraphs
fd47b8d
Warning on static assert
1325771
Replaced some target tasks with host task, and set shared where appro…
95c7f0a
all conditions were inverted, fixed it
091773b
Update tests/6.0/taskgraph/test_taskgraph_if.c
rpereira-dev f7e0560
Fix structured block execution tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| //===-- test_taskgraph.c ------------------------------------------------===// | ||
| // | ||
| // OpenMP API Version 6.0 Nov 2024 | ||
| // | ||
| // Description | ||
| // testTaskgraph(): | ||
| // Create a taskgraph, and ensures the structured block is executed once | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| //===-- 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 once | ||
| // - 3*N tasks 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, x != 1); | ||
| 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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| //===-- test_taskgraph_id.c ------------------------------------------------===// | ||
| // | ||
| // OpenMP API Version 6.0 Nov 2024 | ||
| // | ||
| // Description | ||
| // testTaskgraphId(): | ||
| // Create 'N' taskgraphs with id '0<=i<N' that spawns 3 tasks | ||
| // T1 -> T2 -> T3 | ||
| // | ||
| // Replay each taskgraph 'M' times | ||
| // | ||
| // Ensure that each strucuted block only executed once | ||
| // Ensure that each triplets evexecuted 'N' 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 = 0; | ||
| int y = 0; | ||
|
|
||
| # 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; | ||
|
|
||
| for (int i = 0 ; i < 3 ; ++i) | ||
| { | ||
| # pragma omp task depend(out: y) shared(y) | ||
| { | ||
| # pragma omp atomic | ||
| ++y; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // each taskgraph strucuted block must have executed once | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, x != N); | ||
|
|
||
| // each triplets must have executed N times | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, y != 3*N*M); | ||
|
|
||
| return errors; | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| int errors = 0; | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, testTaskgraphGraphId()); | ||
| OMPVV_REPORT_AND_RETURN(errors); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| //===-- test_taskgraph_if.c ------------------------------------------------===// | ||
| // | ||
| // OpenMP API Version 6.0 Nov 2024 | ||
| // | ||
| // Description | ||
| // testTaskgraphIf(): | ||
| // Call | ||
| // taskgraph if(1) | ||
| // taskgraph if(0) | ||
| // taskgraph if(1) | ||
| // and ensures that the structured block is executed only once, | ||
| // and records 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; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, x != 1); | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, y != 2); | ||
| return errors; | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| int errors = 0; | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, testTaskgraphIf()); | ||
| OMPVV_REPORT_AND_RETURN(errors); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| //===-- test_taskgraph.c ------------------------------------------------===// | ||
| // | ||
| // OpenMP API Version 6.0 Nov 2024 | ||
| // | ||
| // Description | ||
| // testTaskgraphNoGroup(): | ||
| // Create a taskgraph nogroup, replay N times, | ||
| // and ensures the structured block is executed once. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #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, x != 1); | ||
| 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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| //===-- test_taskgraph.c ------------------------------------------------===// | ||
| // | ||
| // OpenMP API Version 6.0 Nov 2024 | ||
| // | ||
| // Description | ||
| // testTaskgraphParallel(): | ||
| // 'N' times, have 'nthreads' threads construcitng/replaying the same taskgraph. | ||
| // It should execute the structured block once, 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; | ||
| # pragma omp task shared(y) | ||
| { | ||
| # pragma omp atomic | ||
| ++y; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, nthreads <= 0); | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, x != 1); | ||
| 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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| //===-- test_taskgraph.c ------------------------------------------------===// | ||
| // | ||
| // OpenMP API Version 6.0 Nov 2024 | ||
| // | ||
| // Description | ||
| // testTaskgraphReplay(): | ||
| // Create a taskgraph of 'M' tasks, replay it 'N' times. | ||
| // Ensures that the structured block is executed only once, | ||
| // and that the tasks are replayed N times | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include <stdio.h> | ||
| #include <assert.h> | ||
| #include <stdlib.h> | ||
| #include <omp.h> | ||
| #include "ompvv.h" | ||
|
|
||
| int testTaskgraphReplay(void) | ||
| { | ||
| int errors = 0; | ||
| # define N 16 | ||
| # define M 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; | ||
| for (int j = 0 ; j < M ; ++j) | ||
| { | ||
| # pragma omp task shared(y) | ||
| { | ||
| # pragma omp atomic | ||
| ++y; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, x != 1); | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, y != M*N); | ||
| return errors; | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| int errors = 0; | ||
| OMPVV_TEST_AND_SET_VERBOSE(errors, testTaskgraphReplay()); | ||
| OMPVV_REPORT_AND_RETURN(errors); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.