Hello,

I was hoping someone could help me find my error in pulling data back from the device and updating the host. I read the earlier post (OpenACC declare and update directives) about how you need to initialize data on the GPU after a create data pragma, or else you will only get uninitialized values back. My problem is very similar, as I am only getting “zeroed” out values when I try to update host after doing calculations on the device, but I am pretty sure I have the initializing correct, I think my problem may be in the pragma pulling the data to host.

The 2 pieces of data are (C++std ) vector< vector > p_density_vector (aka host data) and double ** gpu_p_dentsity_vector (aka device data) and the idea is that gpu_p_density_vector is initialized through pointers to the values of p_density_vectors, then gpu_p_density_vector is altered on the gpu in the work loop, then gpu_p_density_vectors is updated on the host, and finally p_density_vectors is updated by the new values of gpu_p_density_vectors.

This is the code to transfer and initializing

```
void Microenvironment::transfer_3D()
{
// start gpu_p_density_vectors
const int bin_p_density_vectors = (*p_density_vectors).size();
gpu_p_density_vectors = new double*[bin_p_density_vectors];
sizes_p_density_vectors = new int[bin_p_density_vectors];
#pragma acc enter data copyin(this[0:1])
#pragma acc enter data create(this->gpu_p_density_vectors[0:bin_p_density_vectors][0:0])
for (int i = 0; i < bin_p_density_vectors; i++){
int sze = (*p_density_vectors)[i].size();
sizes_p_density_vectors[i] = sze;
gpu_p_density_vectors[i] = (*p_density_vectors)[i].data();
#pragma acc enter data copyin(this->gpu_p_density_vectors[i:1][:sze])
}
#pragma acc enter data copyin(this->sizes_p_density_vectors[:bin_p_density_vectors])
// end gpu_p_density_vectors
}
```

Then there is a work loop, altering gpu_p_density_vectors on GPU

This is the code to update the host, and update p_density_vectors with the new values in gpu_p_density_vectors

```
void Microenvironment::translate_array_to_vector()
/* translate_array_to_vector is actually an update between the two versions
* of p_density_vector (DEVICE = gpu_p_density_vector, HOST = p_density_vector),
* updating the host with the current values of the
* device gpu_p_density_vector
*/
{
const int bin_p_density_vectors = (*p_density_vectors).size();
for (int i = 0; i < bin_p_density_vectors; i++){
int sze = (*p_density_vectors)[i].size();
#pragma acc update host(this->gpu_p_density_vectors[i:1][:sze])
}
#pragma acc update host(this->sizes_p_density_vectors[:bin_p_density_vectors])
for (int i = 0; i < bin_p_density_vectors; i++) {
for (int j = 0; j < this->sizes_p_density_vectors[i]; j++) {
(*p_density_vectors)[i][j] = this->gpu_p_density_vectors[i][j];
}
}
}
```

But the problem is in examples, the values are “nothing” as in they are still the initial values as if no work had been done, but with nvidia-smi I can see the data on the gpu. Would anyone be able to help me by pointing out my error?

Thanks a bunch!