-
Notifications
You must be signed in to change notification settings - Fork 20
New 6.0 test for target access alloc using single #860
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
rjenaa
wants to merge
11
commits into
master
Choose a base branch
from
6.0_target_access_alloc
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fd9a265
initial test for preferred device
rjenaa 1d7c48a
updated device
rjenaa 11a002c
iniital test for target access
rjenaa 8ffb949
Initial test for target access with single
rjenaa bd03864
removed unneccessary test
rjenaa 6c91935
updated to use is device ptr and update
rjenaa 009477d
Added a 2nd target region
rjenaa a19bbf9
removed print statements
rjenaa 29bd8ed
updated to use exit data
rjenaa f208b7a
removed failure for not having 2 devices
rjenaa b168985
updated map from
rjenaa 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,78 @@ | ||
//===--- test_target_access_single.c --------------------===// | ||
// | ||
// OpenMP API Version 6.0 | ||
// Tests that the target_access single allocator trait works | ||
// as intended for basic device-host operations and multiple | ||
// device access. | ||
// | ||
//===----------------------------------------------------===// | ||
#include <omp.h> | ||
#include <stdio.h> | ||
#include "ompvv.h" | ||
#define N 16 | ||
|
||
int test_target_access_single() { | ||
int errors = 0; | ||
int *array; | ||
int num_devices = omp_get_num_devices(); | ||
|
||
OMPVV_WARNING_IF(num_devices < 2, "Test requires at least 2 devices, but only %d found.", num_devices); | ||
if (num_devices < 2) { | ||
return errors; | ||
} | ||
|
||
int first_dev = 0; | ||
int second_dev = 1; | ||
|
||
omp_alloctrait_t trait = { omp_atk_target_access, omp_atv_single }; | ||
omp_allocator_handle_t single_allocator = omp_init_allocator(omp_default_mem_space, 1, &trait); | ||
|
||
array = (int*)omp_alloc(N * sizeof(int), single_allocator); | ||
|
||
for (int i = 0; i < N; i++) { | ||
array[i] = i; | ||
} | ||
|
||
// Using first device | ||
#pragma omp target enter data map(to: array[:N]) device(first_dev) | ||
|
||
#pragma omp target is_device_ptr(array) device(first_dev) | ||
{ | ||
for (int i = 0; i < N; i++) { | ||
array[i] = i * N; | ||
} | ||
} | ||
|
||
#pragma omp target exit data map(from: array[:N]) device(first_dev) | ||
|
||
// Using second device | ||
#pragma omp target enter data map(to: array[:N]) device(second_dev) | ||
|
||
#pragma omp target is_device_ptr(array) device(second_dev) | ||
{ | ||
for (int i = 0; i < N; i++) { | ||
array[i] += 5; | ||
} | ||
} | ||
|
||
#pragma omp target exit data map(from: array[:N]) device(second_dev) | ||
|
||
for (int i = 0; i < N; i++) { | ||
OMPVV_TEST_AND_SET_VERBOSE(errors, array[i] != i * N + 5); | ||
} | ||
|
||
omp_free(array, single_allocator); | ||
omp_destroy_allocator(single_allocator); | ||
|
||
return errors; | ||
} | ||
|
||
int main() { | ||
OMPVV_TEST_OFFLOADING; | ||
|
||
int errors = 0; | ||
|
||
OMPVV_TEST_AND_SET_VERBOSE(errors, test_target_access_single() != 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.