tasks and C++ references

The public comment period closed January 31, 2008. This forum is now locked (read only).

tasks and C++ references

Postby jakub » Wed May 07, 2008 4:40 am

While variables with reference type are not permitted in private/firstprivate clauses and thus before introduction of #pragma omp task they were always shared, I'm wondering how they should behave in tasks where some variables are firstprivate even when they aren't mentioned in the firstprivate clause. E.g. in:
Code: Select all
struct A { A (); ~A (); A (const A &); };
void foo (A &);

void bar ()
  A a;
  A &b = a;
  #pragma omp task
    foo (b);
  #pragma omp barrier
  #pragma omp taskwait

b has reference type and is private in the enclosing context. Should it be firstprivate then, and be a reference to a shared variable a (given that a isn't mentioned in the task construct), so if the task is scheduled in a different thread than the thread that encountered the task construct, a firstprivate var b would reference variable a in the thread that encountered the task construct?
Posts: 74
Joined: Fri Oct 26, 2007 3:19 am

Re: tasks and C++ references

Postby Federico » Wed May 07, 2008 9:18 am

All firstprivate restrictions apply to variables which can be implicitly determined firstprivate in a task construct.
In your example, I'd expect the compiler to give a compile time error and abort, forcing me to make b shared (and take the responsibility of this) or to take other appropriate measure.

Return to Draft 3.0 Public Comment

Who is online

Users browsing this forum: No registered users and 1 guest