https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96835

--- Comment #6 from Tobias Weinzierl <tobias.weinzierl at durham dot ac.uk> ---
We've found some more stuff. This works:

#include <iostream>

#define mydt double

#pragma omp declare target
struct vector {  
  vector(mydt x, mydt y);
  mydt dot(vector o);
  mydt v[2];
}; 

vector::vector(mydt x, mydt y) {
  v[0]=x;
  v[1]=y;
}

mydt vector::dot(vector o) { return v[0] * o.v[0] + v[1]*o.v[1]; }  
#pragma omp end declare target

int main() {
  mydt res;
  vector v1(1,1);
  vector v2(1,3);
  #pragma omp target map(from:res)
  {
    res = v1.dot(v2); 
  }
  std::cout << res << "\n";
}

As soon as you instantiate the vector within the target region, it does not
work anymore:


int main() {
  mydt res;
  #pragma omp target map(from:res)
  {
    vector v1(1,1);
    vector v2(1,3);
    res = v1.dot(v2); 
  }
  std::cout << res << "\n";
}

Reply via email to