What is the correct syntax for updating a subarray in c

At high level in program copy data to GPU
double atoms[1000]
#pragma acc enter data copyin(atoms, vr0, ve0, vg0, vp, vq, vg02)

This seems ok


later in recurring function want to do partial updates when possible (only atoms changes)

#pragma acc data present_or_copyin(atoms, vr0, ve0, vg0, vp, vq, vg02)
#pragma acc update device(atoms[beg:end])
#pragma acc parallel reduction(+:uel) reduction(+:urep)
for(int i=0; i<size; ++i)
{

}

This seems to work fine if beg=0 and end = 999. However that is very expensive since only one atom (4 elements) are changing between the parallel section and it defeats the purpose of doing a partial update.

So the question is to update 4 elements 100,101,102,103 what is the proper syntax/values using the pgi compiler
#pragma update device(atoms[100:103]) OR
#pragma update device(atoms[100:4]) OR other?


#pragma update device(atoms[500:503])
causes an error
FATAL ERROR: variable in data clause is partially present on the device: name=atoms
file:/home/dmreitz/workspace/csi/MonteCarloSmaLdaAcc.h computeSummaryPotentialScalar__Q2_3Csi25MonteCarloSmaLdaPotentialFdUl line:405
atoms lives at 0x7097e0 size 4032 not present
Present table dump for device[1]: NVIDIA Tesla GPU 1, compute capability 2.1
[ 0xb0b6e0] host:0x708720 device:0x700300a00 size:24 presentcount:2 line:879 name:vr0
[ 0xb0b740] host:0x708740 device:0x700300800 size:24 presentcount:2 line:879 name:ve0
[ 0xb0b7a0] host:0x708760 device:0x700300600 size:24 presentcount:2 line:879 name:vg0
[ 0xb0b800] host:0x708780 device:0x700300400 size:24 presentcount:2 line:879 name:vp
[ 0xb0b860] host:0x7087a0 device:0x700300200 size:24 presentcount:2 line:879 name:vq
[ 0xb0b8c0] host:0x7087c0 device:0x700300000 size:24 presentcount:2 line:879 name:vg02
[ 0xb0b680] host:0x708840 device:0x700200000 size:8000 presentcount:2 line:879 name:atoms

Any suggestions would be appreciated.

Thank you,

Hi dreitz,

It’s the beginning element followed by the number of elements to copy. So

#pragma update device(atoms[100:4])

is correct.

Hope this helps,
Mat