Understanding update clauses

I’m trying to understand update clauses. I’ve been playing around with them and I keep encountering some strange errors which makes me think that I don’t know how they are used.

I have this case (embedded in a larger program) where I have the following sequence of acc directives:

...#pragma acc update host(B,C)
... #pragma acc enter data create(A)
... #pragma acc update device(A)
... #pragma acc update host(A) ...

Now, A, B, and C are placeholders for the arrays i’m working with. Basically, I have some computation that I did on the GPU that I need back on the host. Then I create a new array that I’m going to do some stuff with, but I fill it with data derived from B and C on the CPU, and then copy that back to the device. Now, at the point in my test program, I’m just copying that array back out to the host and then copying it into another array. What I’ve found, though, is that the final update seems to cause problems. If I leave out that final update host(A) clause, then everything works fine and the copy of the data goes as I expect. However, if I put in that update host(A) at the end, I get corrupt data.

From this it appears as though the update device(A) clause isn’t actually sending the data over to the device, but at this point I fear I’m not understanding how to use update correctly at this point. To me, assuming I’m not doing any editing of the data between the last two clauses, it would seem to me that the data on the host would be the same, almost a NOOP.

Where is A getting initialized?

My thought is that you might be updating the device it before initializing it on the host, or initializing it on the device then overwriting it by updating it from the host.

Can you post or send to PGI Customer Service (trs@pgroup.com) a reproducing example?

  • Mat

I finally got it figured out. There was a size mismatch on the device copying clause that caused it only to copy a part of the array. Now things are working as they should. Thanks for the help!