-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[flang][OpenMP] Support custom mappers in target update to/from clauses #169673
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: main
Are you sure you want to change the base?
Changes from 2 commits
b2a07c5
f378223
d17b0ca
52992b7
6b6ce4e
c620237
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,51 @@ | ||
| ! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s | ||
|
|
||
| ! Test mapper usage in target update to/from clauses | ||
|
|
||
| program target_update_mapper | ||
| implicit none | ||
|
|
||
| integer, parameter :: n = 4 | ||
|
|
||
| type :: typ | ||
| integer, allocatable :: a(:) | ||
| integer, allocatable :: b(:) | ||
| end type typ | ||
|
|
||
| !$omp declare mapper(custom: typ :: t) map(t%a) | ||
|
|
||
| ! CHECK-LABEL: omp.declare_mapper @_QQFcustom : !fir.type<_QFTtyp{a:!fir.box<!fir.heap<!fir.array<?xi32>>>,b:!fir.box<!fir.heap<!fir.array<?xi32>>>}> | ||
|
|
||
| type(typ) :: t | ||
|
|
||
| allocate(t%a(n), source=1) | ||
| allocate(t%b(n), source=2) | ||
|
|
||
| !$omp target enter data map(alloc: t) | ||
|
|
||
| ! Test target update to with custom mapper | ||
| ! CHECK: %[[MAP_INFO:.*]] = omp.map.info var_ptr(%{{.*}} : {{.*}}, {{.*}}) map_clauses(to) capture(ByRef) mapper(@_QQFcustom) -> {{.*}} | ||
| ! CHECK: omp.target_update map_entries(%[[MAP_INFO]] : {{.*}}) | ||
| t%a = 42 | ||
| !$omp target update to(mapper(custom): t) | ||
|
|
||
| !$omp target | ||
| t%a(:) = t%a(:) / 2 | ||
| t%b(:) = -1 | ||
| !$omp end target | ||
|
|
||
| ! Test target update from with custom mapper | ||
| ! CHECK: %[[MAP_INFO2:.*]] = omp.map.info var_ptr(%{{.*}} : {{.*}}, {{.*}}) map_clauses(from) capture(ByRef) mapper(@_QQFcustom) -> {{.*}} | ||
| ! CHECK: omp.target_update map_entries(%[[MAP_INFO2]] : {{.*}}) | ||
| !$omp target update from(mapper(custom): t) | ||
|
|
||
| ! Test target update to with default mapper | ||
| ! CHECK: %[[MAP_INFO3:.*]] = omp.map.info var_ptr(%{{.*}} : {{.*}}, {{.*}}) map_clauses(to) capture(ByRef) mapper(@_QQFtyp_omp_default_mapper) -> {{.*}} | ||
| ! CHECK: omp.target_update map_entries(%[[MAP_INFO3]] : {{.*}}) | ||
| !$omp target update to(mapper(default): t) | ||
|
|
||
| !$omp target exit data map(delete: t) | ||
| deallocate(t%a) | ||
| deallocate(t%b) | ||
|
|
||
| end program target_update_mapper |
KrxGu marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| ! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=52 | ||
|
|
||
| ! Test mapper usage in target update to/from clauses | ||
|
|
||
| program target_update_mapper | ||
| implicit none | ||
|
|
||
| integer, parameter :: n = 4 | ||
|
|
||
| type :: typ | ||
| integer, allocatable :: a(:) | ||
| integer, allocatable :: b(:) | ||
| end type typ | ||
|
|
||
| !$omp declare mapper(custom: typ :: t) map(t%a) | ||
|
|
||
| type(typ) :: t | ||
| integer :: not_a_mapper | ||
| allocate(t%a(n), source=1) | ||
| allocate(t%b(n), source=2) | ||
|
|
||
| !$omp target enter data map(alloc: t) | ||
|
|
||
| ! Valid: using custom mapper with target update to | ||
| t%a = 42 | ||
| !$omp target update to(mapper(custom): t) | ||
|
|
||
| !$omp target | ||
| t%a(:) = t%a(:) / 2 | ||
| t%b(:) = -1 | ||
| !$omp end target | ||
|
|
||
| ! Valid: using custom mapper with target update from | ||
| !$omp target update from(mapper(custom): t) | ||
|
|
||
| ! Valid: using default mapper explicitly | ||
| !$omp target update to(mapper(default): t) | ||
|
|
||
| print*, t%a | ||
| print*, t%b | ||
|
|
||
| !$omp target exit data map(delete: t) | ||
| deallocate(t%a) | ||
| deallocate(t%b) | ||
|
|
||
| ! Test error case: undefined mapper | ||
| !ERROR: 'undefined_mapper' not declared | ||
| !$omp target update to(mapper(undefined_mapper): t) | ||
|
|
||
| ! Test error case: wrong kind of symbol | ||
| !ERROR: Name 'not_a_mapper' should be a mapper name | ||
| !$omp target update from(mapper(not_a_mapper): t) | ||
|
|
||
| end program target_update_mapper |
Uh oh!
There was an error while loading. Please reload this page.