https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95590
Bug ID: 95590 Summary: OpenACC 'attach' behavior if already attached to different data Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: openacc Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: tschwinge at gcc dot gnu.org CC: jakub at gcc dot gnu.org, jules at gcc dot gnu.org Target Milestone: --- Created attachment 48709 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48709&action=edit 'mdc-3_.c' Consider the 'mdc-3_.c' test case I'm attaching, in particular its 'data_work = data_2' case, and then OpenACC 2.6, 2.7.2. "Data Clause Actions", "Attach Action", which states that "If the _attachment counter_ for _var_ ['data_work'] is nonzero [true; has been attached to 'data_1'] and the pointer in device memory already points to the device copy of the data in _var_ [false; still points to 'data_1_d'], [not relevant]. Otherwise, the pointer in device memory is _attached_ to the device copy of the data by initiating an update for the pointer in device memory to point to the device copy of the data and setting the _attachment counter_ for the pointer _var_ to one. I read that to mean that after 'data_work = data_2' has been set, the 'acc_attach((void **) &data_work)' should then "drop" the attachment of the device copy of 'data_work' to currently 'data_1_d', and "re-attach" to the new '*data_work', that is, to 'data_2_d', and re-initialize the _attachment counter_ to one. (PGI 19.10 seems to agree with my interpretation, for what that's worth.)