HPC Magazine - OpenACC 2.0 - The new data management features
Listing 3: Custom implementation of a present_or_copy(A[n]) using API calls.
int A[n] ; ... /* A[0:n] may or may not be present on the device */ int was_present ; was_present = acc_is_present( A , n*sizeof(int) ); if ( !was_present ) { acc_copyin( A , n*sizeof(int) ) } ... /* A[0:n] is now present on the device */ ... if ( !was_present ) { acc_delete( A , n*sizeof(int) ) } /* A[0:n] may or may not be present on the device */ ...