-
Notifications
You must be signed in to change notification settings - Fork 24
declare_target local #883
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
andrewkallai
wants to merge
19
commits into
master
Choose a base branch
from
test_target_data_local
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
declare_target local #883
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f660be6
Adding rough test
andrewkallai 2187c88
Adding new changes
andrewkallai 8de5952
Adding checking
andrewkallai 1ed4322
Adding checking
andrewkallai 6a360c7
Adding the target directive test
andrewkallai 6a7210c
Update and rename test_declare_target_directive_local.c to test_decla…
spophale 5b86436
Update tests/6.0/declare_target/test_declare_target_local.c
andrewkallai 84ef3a8
Update tests/6.0/declare_target/test_declare_target_local.c
andrewkallai 39e31a1
Update tests/6.0/declare_target/test_declare_target_local.c
andrewkallai 00eaa02
Update tests/6.0/declare_target/test_declare_target_local.c
andrewkallai 57e3185
Update tests/6.0/declare_target/test_declare_target_local.c
andrewkallai ed81eb1
Update tests/6.0/declare_target/test_declare_target_local.c
andrewkallai 49db4e2
Update tests/6.0/declare_target/test_declare_target_local.c
andrewkallai c39ca32
Update tests/6.0/declare_target/test_declare_target_local.c
andrewkallai 86c2119
Adding changes
andrewkallai d2f06e6
Adding the changes for testing
andrewkallai 618a7c6
More changes
andrewkallai 0e2b1c0
Adding the updated test with complete changes
andrewkallai 73aafb4
Removing extra macro definition.
andrewkallai 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
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
91 changes: 91 additions & 0 deletions
91
tests/6.0/declare_target/test_declare_target_directive_local.c
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,91 @@ | ||
| //--------------- test_declare_target_directive_local.c--------------------------------// | ||
| // OpenMP API Version 6.0 November 2024 | ||
| // Pg. 902, line 4 | ||
| // *********** | ||
| // DIRECTIVE: declare_target | ||
| // CLAUSE: local | ||
| // The declare_target directive is used with the local clause to make data | ||
| // persist on multiple devices, each with their own copy of the referenced | ||
| // variables in the clause. If the values retrieved from each of the available | ||
| // devices add up to the expected amount, the test will pass. | ||
| //-------------------------------------------------------------------------------------// | ||
|
|
||
| #include "ompvv.h" | ||
| #include <omp.h> | ||
|
|
||
| #define N 100 | ||
|
|
||
| int sum; | ||
| int x[N]; | ||
|
|
||
| #pragma omp declare_target to(sum, x) // local(sum, x) | ||
| #pragma omp begin declare_target | ||
| // void init_x(int dev_id) { | ||
| // for (int j = 0; j < N; ++j) { | ||
| // x[j] = j + dev_id; | ||
| // } | ||
| // } | ||
| void foo(int dev_id) { | ||
| int i; | ||
| for (int j = 0; j < N; ++j) { | ||
| x[j] = j + dev_id; | ||
| } | ||
| #pragma omp for reduction(+ : sum) | ||
| for (i = 0; i < N; i++) { | ||
| sum += x[i]; | ||
| } | ||
| } | ||
| #pragma omp end declare target | ||
|
|
||
| int test_declare_target_local() { | ||
| int errors = 0; | ||
| int TotGpus = omp_get_num_devices(); | ||
| int errors_arr[TotGpus]; | ||
| int sum_array[TotGpus]; | ||
|
|
||
andrewkallai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for (int i = 0; i < TotGpus; i++) { | ||
| sum_array[i] = 0; | ||
| errors_arr[i] = 0; | ||
| // #pragma omp target device(i) map(tofrom : sum_array) | ||
| // { | ||
| // // init_x(i); | ||
| // // sum = 0; | ||
| // sum_array[i] = 0; | ||
| // } | ||
| } | ||
|
|
||
| for (int i = 0; i < TotGpus; i++) { | ||
| #pragma omp target parallel device(i) nowait | ||
| { | ||
| foo(i); | ||
| } | ||
| } | ||
| #pragma omp taskwait | ||
|
|
||
| for (int i = 0; i < TotGpus; i++) { | ||
| #pragma omp target map(tofrom : errors_arr) device(i) | ||
| { | ||
| if ((N) * (N - 1) / 2 + (N)*i != sum_array[i]) { | ||
| ++errors_arr[i]; | ||
| } | ||
| } | ||
| } | ||
| for (int i = 0; i < TotGpus; i++) { | ||
| errors += errors_arr[i]; | ||
| } | ||
| OMPVV_TEST_AND_SET(errors, errors != 0); | ||
andrewkallai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return errors; | ||
| } | ||
|
|
||
| int main() { | ||
| int errors = 0, test_exit_code = 0; | ||
| int TotGpus = omp_get_num_devices(); | ||
| OMPVV_WARNING_IF(TotGpus < 1, "Test requires non-host devices, but none were " | ||
| "found. \n This test will be skipped.\n"); | ||
| OMPVV_CHECK_TO_SKIP(TotGpus < 1) | ||
| OMPVV_TEST_OFFLOADING; | ||
|
|
||
| OMPVV_TEST_AND_SET(errors, test_declare_target_local() != 0); | ||
| OMPVV_REPORT_AND_RETURN(errors); | ||
| } | ||
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.