I was able to reproduce your issue and I agree that it looks like a bug! I have reported it to engineering as TPR#39009. I will let you know when I find out more information. I did test a workaround that seemed to work - doing the write through a local pointer instead of the structured one:
#include <stdlib.h>
typedef struct {
double *buffer;
} buffer_state;
#pragma acc routine
void copy_rows(buffer_state *state)
{
int i;
double *p = state->buffer;
for (i = 0; i < 4; i++) {
#pragma acc atomic write
p[i] = 0.0;
}
}
int main(void)
{
double *buffer = calloc(4, sizeof(*buffer));
buffer_state state;
if (!buffer)
return 1;
state.buffer = buffer;
#pragma acc enter data copyin(buffer[0:4])
#pragma acc enter data copyin(state)
#pragma acc enter data attach(state.buffer)
#pragma acc parallel present(state)
{
copy_rows(&state);
}
#pragma acc exit data detach(state.buffer)
#pragma acc exit data copyout(buffer[0:4])
#pragma acc exit data delete(state)
for (int i = 0; i < 4; i++) {
if (buffer[i] != 0.0)
return 1;
}
free(buffer);
return 0;
}
I hope this helps! Let me know if you have any other problems I can help with! And please report any other issues you find - all feedback makes the compiler better!