Hi PA;
only playing around quickly and glancing at the patch; I need to have a
real look at this later.
Paul-Antoine Arras:
This patch adds C++ support for the `dispatch` construct and the `adjust_args`
clause. It relies on the c-family bits comprised in the corresponding C front
end patch for pragmas and attributes.
Regarding the parsing, I am wondering whether you could do the same as
proposed for the C parser, i.e. instead of swallowing '(' just checking
whether it is there - and then call the normaler parser, followed by
checking that it is only the call and not expressions involving that call.
* * *
Starting with playing around a bit:
----------------------------
int variant_fn(int *, int * = nullptr);
#pragma omp declare variant(variant_fn) match(construct={dispatch})
adjust_args(need_device_ptr : x, y)
int bar(int *x, int *y = nullptr);
void sub(int *a, int *b)
{
int x;
#pragma omp dispatch
x = bar(a);
}
----------------------------
D.2973 = __builtin_omp_get_default_device ();
D.2974 = __builtin_omp_get_mapped_ptr (0B, D.2973);
D.2975 = __builtin_omp_get_mapped_ptr (a, D.2973);
x = variant_fn (D.2975, D.2974);
This code should work, but converting the NULL pointer is is a bit
pointless and OpenMP (current 6.0 draft) states:
"For each adjust_args clause that is present on the selected function
variant, the adjustment operation specified by the adjust-op modifier is
applied to each argument specified in the clause before being passed to
the selected function variant. Any argument specified in the clause that
does not exist at a given function call site is ignored."
* * *
The following testcase produces an odd error in the C++ FE:
int& variant_fn();
#pragma omp declare variant(variant_fn) match(construct={dispatch})
int& bar();
void sub(int a)
{
#pragma omp dispatch
bar();
#pragma omp dispatch
a = bar();
}
* * *
Tobias