OpenACC compatibility with std::vector

Hi,

at GPU Tech Conf I learnt that PGI has C++ support for OpenACC. A lot of our code uses std::vector. According to the standard std::vector guarantees contiguous memory and in principal it can be used like a C array by means of &v[0].
Can std::vectors be used in acc parallel loop sections and if so how do you address them in acc data clauses as v in the typical e.g. copy(v) would be of type std::vector and not double*.
Or would I have to workaround it locally with double* p = &v[0] if I were not willing to change all std::vectors to C arrays in my code?

Thanks,
Lutz

Lutz-

We do not yet support vectors in OpenACC regions. The “” operator may work like
C, but vectors require constructors, destructors, and other functions masquerading
as operators. These functions can not yet be run in OpenAcc regions. You would
have to work around it locally with a C array.

Hi Deborah,

thanks for the quick response. Your answer somehow implies that you might support this in the future. In case you have this on your list how would rate the priority (high - medium - low)?

Thanks,
Lutz

We are still investigating the technical issues involved in implementing this, and have not
yet added it to our schedule. It does not have high priority. User interest
plays a part in all of this. Please file a bug report/request for enhancement if this
issue is important to you.

Hi,

Is OpenACC still not supporting std::vector in C++???

Support for stl::vectors has been in for a few years now (circa 2014). Though there are a few caveats.

  1. stl::vector is not thread safe, especially when pushing, popping, inserting values. Limit the device code to using operations that access or query the vector, such as the access operator (“”), “empty”, or “size”.

  2. Data management between the device and host copies of the vector is very tricky to perform via data directives. It’s recommended to use CUDA Unified Memory (-ta=telsa:managed) instead.

-Mat