int main (int argc, char **argv) { const int N = 256; int i; unsigned char *h; void *d; h = (unsigned char *) malloc (N); for (i = 0; i < N; i++) { h[i] = i; } d = acc_copyin (h, N); if (!d) abort (); memset (&h[0], 0, N); acc_update_self (0, N); for (i = 0; i < N; i++) { if (h[i] != i) abort (); } acc_delete (h, N); free (h); return 0; }
void GOACC_update (int device, const void *offload_table, size_t mapnum, void **hostaddrs, size_t *sizes, unsigned short *kinds, int async, int num_waits, ...) { bool host_fallback = device == GOMP_DEVICE_HOST_FALLBACK; size_t i; select_acc_device (device); struct goacc_thread *thr = goacc_thread (); struct gomp_device_descr *acc_dev = thr->dev; if ((acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM) || host_fallback) return; if (num_waits > 0) { va_list ap; va_start (ap, num_waits); goacc_wait (async, num_waits, ap); va_end (ap); } acc_dev->openacc.async_set_async_func (async); for (i = 0; i < mapnum; ++i) { unsigned char kind = kinds[i] & 0xff; switch (kind) { case GOMP_MAP_POINTER: case GOMP_MAP_TO_PSET: break; case GOMP_MAP_FORCE_TO: acc_update_device (hostaddrs[i], sizes[i]); break; case GOMP_MAP_FORCE_FROM: acc_update_self (hostaddrs[i], sizes[i]); break; default: gomp_fatal (">>>> GOACC_update UNHANDLED kind 0x%.2x", kind); break; } } acc_dev->openacc.async_set_async_func (acc_async_sync); }