Index: libomptarget/plugins/cuda/src/rtl.cpp =================================================================== --- libomptarget/plugins/cuda/src/rtl.cpp +++ libomptarget/plugins/cuda/src/rtl.cpp @@ -446,6 +446,16 @@ DP("Entry point " DPxMOD " maps to global %s (" DPxMOD ")\n", DPxPTR(e - HostBegin), e->name, DPxPTR(cuptr)); entry.addr = (void *)cuptr; + if (DeviceInfo.RequiresFlags & OMP_REQ_UNIFIED_SHARED_MEMORY && + e->flags & OMP_DECLARE_TARGET_LINK) { + // If unified memory is present any target link variables + // can access host addresses directly. There is no longer a + // need for device copies. + cuMemcpyHtoD(cuptr, e->addr, sizeof(void *)); + DP("Copy linked variable host address (" DPxMOD ")" + "to device address (" DPxMOD ")\n", + DPxPTR(*((void**)e->addr)), DPxPTR(cuptr)); + } DeviceInfo.addOffloadEntry(device_id, entry);