As we have seen earlier, typically map transfers a variable to the device at the beginning of a target region and back to the host at the end of the region. However, there might be cases where we just want to allocate memory on the device without copying any data. The alloc map-type allocates device memory without copying data to or from the host. This is useful for temporary arrays that are only needed on the device.

alloc map-type
Device Allocation API

Device memory can also be allocated directly using OpenMP API calls similar to CUDA: omp_target_alloc(size, device_id) allocates memory on the device and omp_target_free(d_ptr, device_id) frees it. Using these device pointers inside a target region requires the is_device_ptr(d_ptr) clause to indicate that the pointer is a device pointer. Otherwise, the pointer may be assumed as a regular variable.

 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Access Statement
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)