diff options
Diffstat (limited to 'liboffloadmic/plugin')
-rw-r--r-- | liboffloadmic/plugin/libgomp-plugin-intelmic.cpp | 23 | ||||
-rw-r--r-- | liboffloadmic/plugin/offload_target_main.cpp | 24 |
2 files changed, 47 insertions, 0 deletions
diff --git a/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp b/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp index 9ebd070..26ac6fe 100644 --- a/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp +++ b/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp @@ -477,6 +477,29 @@ GOMP_OFFLOAD_dev2host (int device, void *host_ptr, const void *tgt_ptr, return host_ptr; } +extern "C" void * +GOMP_OFFLOAD_dev2dev (int device, void *dst_ptr, const void *src_ptr, + size_t size) +{ + TRACE ("(dst_ptr = %p, src_ptr = %p, size = %d)", dst_ptr, src_ptr, size); + if (!size) + return dst_ptr; + + VarDesc vd1[3] = { vd_host2tgt, vd_host2tgt, vd_host2tgt }; + vd1[0].ptr = &dst_ptr; + vd1[0].size = sizeof (void *); + vd1[1].ptr = &src_ptr; + vd1[1].size = sizeof (void *); + vd1[2].ptr = &size; + vd1[2].size = sizeof (size); + VarDesc2 vd1g[3] = { { "dst_ptr", 0 }, { "src_ptr", 0 }, { "size", 0 } }; + + offload (__FILE__, __LINE__, device, "__offload_target_tgt2tgt", 3, vd1, + vd1g); + + return dst_ptr; +} + extern "C" void GOMP_OFFLOAD_run (int device, void *tgt_fn, void *tgt_vars) { diff --git a/liboffloadmic/plugin/offload_target_main.cpp b/liboffloadmic/plugin/offload_target_main.cpp index 3fead01..18b0146 100644 --- a/liboffloadmic/plugin/offload_target_main.cpp +++ b/liboffloadmic/plugin/offload_target_main.cpp @@ -299,6 +299,29 @@ __offload_target_tgt2host_p2 (OFFLOAD ofldt) __offload_target_leave (ofldt); } +/* Copy SIZE bytes from SRC_PTR to DST_PTR. */ +static void +__offload_target_tgt2tgt (OFFLOAD ofldt) +{ + void *src_ptr = NULL; + void *dst_ptr = NULL; + size_t size = 0; + + VarDesc vd1[3] = { vd_host2tgt, vd_host2tgt, vd_host2tgt }; + vd1[0].ptr = &dst_ptr; + vd1[0].size = sizeof (void *); + vd1[1].ptr = &src_ptr; + vd1[1].size = sizeof (void *); + vd1[2].ptr = &size; + vd1[2].size = sizeof (size); + VarDesc2 vd1g[3] = { { "dst_ptr", 0 }, { "src_ptr", 0 }, { "size", 0 } }; + + __offload_target_enter (ofldt, 3, vd1, vd1g); + TRACE ("(dst_ptr = %p, src_ptr = %p, size = %d)", dst_ptr, src_ptr, size); + memcpy (dst_ptr, src_ptr, size); + __offload_target_leave (ofldt); +} + /* Call offload function by the address fn_ptr and pass vars_ptr to it. */ static void __offload_target_run (OFFLOAD ofldt) @@ -363,5 +386,6 @@ REGISTER (host2tgt_p1); REGISTER (host2tgt_p2); REGISTER (tgt2host_p1); REGISTER (tgt2host_p2); +REGISTER (tgt2tgt); REGISTER (run); #undef REGISTER |