Changeset View
Changeset View
Standalone View
Standalone View
openmp/libomptarget/src/api.cpp
Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | if (src_device == omp_get_initial_device() && | ||||
dst_device == omp_get_initial_device()) { | dst_device == omp_get_initial_device()) { | ||||
DP("copy from host to host\n"); | DP("copy from host to host\n"); | ||||
const void *p = memcpy(dstAddr, srcAddr, length); | const void *p = memcpy(dstAddr, srcAddr, length); | ||||
if (p == NULL) | if (p == NULL) | ||||
rc = OFFLOAD_FAIL; | rc = OFFLOAD_FAIL; | ||||
} else if (src_device == omp_get_initial_device()) { | } else if (src_device == omp_get_initial_device()) { | ||||
DP("copy from host to device\n"); | DP("copy from host to device\n"); | ||||
DeviceTy& DstDev = Devices[dst_device]; | DeviceTy& DstDev = Devices[dst_device]; | ||||
rc = DstDev.data_submit(dstAddr, srcAddr, length); | rc = DstDev.data_submit(dstAddr, srcAddr, length, nullptr); | ||||
} else if (dst_device == omp_get_initial_device()) { | } else if (dst_device == omp_get_initial_device()) { | ||||
DP("copy from device to host\n"); | DP("copy from device to host\n"); | ||||
DeviceTy& SrcDev = Devices[src_device]; | DeviceTy& SrcDev = Devices[src_device]; | ||||
rc = SrcDev.data_retrieve(dstAddr, srcAddr, length); | rc = SrcDev.data_retrieve(dstAddr, srcAddr, length, nullptr); | ||||
} else { | } else { | ||||
DP("copy from device to device\n"); | DP("copy from device to device\n"); | ||||
void *buffer = malloc(length); | void *buffer = malloc(length); | ||||
DeviceTy& SrcDev = Devices[src_device]; | DeviceTy& SrcDev = Devices[src_device]; | ||||
DeviceTy& DstDev = Devices[dst_device]; | DeviceTy& DstDev = Devices[dst_device]; | ||||
rc = SrcDev.data_retrieve(buffer, srcAddr, length); | rc = SrcDev.data_retrieve(buffer, srcAddr, length, nullptr); | ||||
if (rc == OFFLOAD_SUCCESS) | if (rc == OFFLOAD_SUCCESS) | ||||
rc = DstDev.data_submit(dstAddr, buffer, length); | rc = DstDev.data_submit(dstAddr, buffer, length, nullptr); | ||||
free(buffer); | free(buffer); | ||||
} | } | ||||
DP("omp_target_memcpy returns %d\n", rc); | DP("omp_target_memcpy returns %d\n", rc); | ||||
return rc; | return rc; | ||||
} | } | ||||
EXTERN int omp_target_memcpy_rect(void *dst, void *src, size_t element_size, | EXTERN int omp_target_memcpy_rect(void *dst, void *src, size_t element_size, | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |