| 1 |
// See also '../libgomp.oacc-c++/pr96835-1.C'. |
| 2 |
#ifndef ALWAYS_INLINE |
| 3 |
# define ALWAYS_INLINE |
| 4 |
#endif |
| 5 |
|
| 6 |
#pragma omp declare target |
| 7 |
|
| 8 |
template<int sz> |
| 9 |
struct vector { |
| 10 |
int values_[sz]; |
| 11 |
vector(); |
| 12 |
ALWAYS_INLINE |
| 13 |
vector(int const& init_val); |
| 14 |
ALWAYS_INLINE |
| 15 |
int dot(vector o) { |
| 16 |
int res = 0; |
| 17 |
for (int i = 0; i < sz; ++ i) |
| 18 |
res += values_[i] * o.values_[i]; |
| 19 |
return res; |
| 20 |
} |
| 21 |
}; |
| 22 |
|
| 23 |
template<int sz> |
| 24 |
vector<sz>::vector(int const& init_val) { |
| 25 |
for (int i = 0; i < sz; ++ i) values_[i] = init_val; |
| 26 |
} |
| 27 |
template<int sz> |
| 28 |
vector<sz>::vector() : vector(0) { |
| 29 |
} |
| 30 |
|
| 31 |
#pragma omp end declare target |
| 32 |
|
| 33 |
int main() { |
| 34 |
int res = 0; |
| 35 |
#pragma omp target map(from:res) |
| 36 |
#pragma acc serial copyout(res) |
| 37 |
{ |
| 38 |
vector<4> v1(1); |
| 39 |
vector<4> v2(2); |
| 40 |
res = v1.dot(v2); |
| 41 |
} |
| 42 |
if (res != 8) |
| 43 |
__builtin_abort(); |
| 44 |
return 0; |
| 45 |
} |