| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-additional-options "-fdump-tree-gimple" } */ |
| 3 |
|
| 4 |
void f1 (void* p, int arr[]); |
| 5 |
#pragma omp declare variant (f1) match (construct={dispatch}) adjust_args (need_device_ptr: p, arr) |
| 6 |
void f2 (void* p, int arr[]); |
| 7 |
|
| 8 |
void test (void) |
| 9 |
{ |
| 10 |
void *p; |
| 11 |
int arr[2]; |
| 12 |
|
| 13 |
/* Note there are multiple matches because every variable capturing matches in addition, |
| 14 |
i.e. scan-tree-dump-times = 1 plus number of captures used for backward references. |
| 15 |
|
| 16 |
For the first scan-tree-dump, on some targets the __builtin_omp_get_mapped_ptr get |
| 17 |
swapped. As the counting does not work well with variable-name capturing, it only |
| 18 |
uses 'scan-tree-dump' and not 'scan-tree-dump-times'. */ |
| 19 |
|
| 20 |
#pragma omp dispatch |
| 21 |
/* { dg-final { scan-tree-dump "#pragma omp dispatch\[ \t\n\r\{]*int (D\.\[0-9]+);\[ \t\n\r]*void \\* (D\.\[0-9]+);\[ \t\n\r]*void \\* (D\.\[0-9]+);\[ \t\n\r]*\\1 = __builtin_omp_get_default_device \\(\\);\[ \t\n\r]*\\2 = __builtin_omp_get_mapped_ptr \\(&arr, \\1\\);\[ \t\n\r]*\\3 = __builtin_omp_get_mapped_ptr \\(p, \\1\\);\[ \t\n\r]*f1 \\(\\3, \\2\\);|#pragma omp dispatch\[ \t\n\r\{]*int (D\.\[0-9]+);\[ \t\n\r]*void \\* (D\.\[0-9]+);\[ \t\n\r]*void \\* (D\.\[0-9]+);\[ \t\n\r]*\\4 = __builtin_omp_get_default_device \\(\\);\[ \t\n\r]*\\5 = __builtin_omp_get_mapped_ptr \\(p, \\4\\);\[ \t\n\r]*\\6 = __builtin_omp_get_mapped_ptr \\(&arr, \\4\\);\[ \t\n\r]*f1 \\(\\5, \\6\\);" "gimple" } } */ |
| 22 |
f2 (p, arr); |
| 23 |
#pragma omp dispatch is_device_ptr(p) |
| 24 |
/* { dg-final { scan-tree-dump-times "#pragma omp dispatch is_device_ptr\\(p\\)\[ \t\n\r\{]*int (D\.\[0-9]+);\[ \t\n\r]*void \\* (D\.\[0-9]+);\[ \t\n\r]*\\1 = __builtin_omp_get_default_device \\(\\);\[ \t\n\r]*\\2 = __builtin_omp_get_mapped_ptr \\(&arr, \\1\\);\[ \t\n\r]*f1 \\(p, \\2\\);" 3 "gimple" } } */ |
| 25 |
f2 (p, arr); |
| 26 |
#pragma omp dispatch is_device_ptr(arr) |
| 27 |
/* { dg-final { scan-tree-dump-times "#pragma omp dispatch is_device_ptr\\(arr\\)\[ \t\n\r\{]*int (D\.\[0-9]+);\[ \t\n\r]*void \\* (D\.\[0-9]+);\[ \t\n\r]*\\1 = __builtin_omp_get_default_device \\(\\);\[ \t\n\r]*\\2 = __builtin_omp_get_mapped_ptr \\(p, \\1\\);\[ \t\n\r]*f1 \\(\\2, &arr\\);" 3 "gimple" } } */ |
| 28 |
f2 (p, arr); |
| 29 |
#pragma omp dispatch is_device_ptr(p, arr) |
| 30 |
/* { dg-final { scan-tree-dump-times "#pragma omp dispatch is_device_ptr\\(arr\\) is_device_ptr\\(p\\)\[ \t\n\r\{]*f1 \\(p, &arr\\);" 1 "gimple" } } */ |
| 31 |
f2 (p, arr); |
| 32 |
} |
| 33 |
|
| 34 |
|