@@ -949,9 +949,9 @@ dpct_memcpy(sycl::ext::oneapi::experimental::image_mem_handle src,
949
949
sycl::range<3 >(w_offset_src / ele_size, h_offset_src, 0 );
950
950
const auto dest_offset = sycl::range<3 >(0 , 0 , 0 );
951
951
const auto dest_extend = sycl::range<3 >(p / ele_size, 0 , 0 );
952
- const auto copy_extend = sycl::range<3 >(w / ele_size, h, 0 );
952
+ const auto copy_extend = sycl::range<3 >(w / ele_size, h, 1 );
953
953
return q.ext_oneapi_copy (src, src_offset, desc_src, dest, dest_offset,
954
- dest_extend , copy_extend);
954
+ desc_src, p , copy_extend);
955
955
}
956
956
957
957
static inline std::vector<sycl::event> dpct_memcpy_to_host (
@@ -969,7 +969,7 @@ static inline std::vector<sycl::event> dpct_memcpy_to_host(
969
969
const auto dest_offset = sycl::range<3 >(offset_dest / ele_size, 0 , 0 );
970
970
const auto dest_extend = sycl::range<3 >(0 , 0 , 0 );
971
971
const auto copy_extend =
972
- sycl::range<3 >((w - w_offset_src) / ele_size, 1 , 0 );
972
+ sycl::range<3 >((w - w_offset_src) / ele_size, 1 , 1 );
973
973
event_list.push_back (q.ext_oneapi_copy (src, src_offset, desc_src,
974
974
dest_host_ptr, dest_offset,
975
975
dest_extend, copy_extend));
@@ -982,7 +982,7 @@ static inline std::vector<sycl::event> dpct_memcpy_to_host(
982
982
sycl::range<3 >(w_offset_src / ele_size, h_offset_src, 0 );
983
983
const auto dest_offset = sycl::range<3 >(offset_dest / ele_size, 0 , 0 );
984
984
const auto dest_extend = sycl::range<3 >(0 , 0 , 0 );
985
- const auto copy_extend = sycl::range<3 >((s - offset_dest) / ele_size, 1 , 0 );
985
+ const auto copy_extend = sycl::range<3 >((s - offset_dest) / ele_size, 1 , 1 );
986
986
event_list.push_back (q.ext_oneapi_copy (src, src_offset, desc_src,
987
987
dest_host_ptr, dest_offset,
988
988
dest_extend, copy_extend));
@@ -1021,7 +1021,7 @@ dpct_memcpy(const void *src,
1021
1021
const auto src_extend = sycl::range<3 >(p / ele_size, 0 , 0 );
1022
1022
const auto dest_offset =
1023
1023
sycl::range<3 >(w_offset_dest / ele_size, h_offset_dest, 0 );
1024
- const auto copy_extend = sycl::range<3 >(w / ele_size, h, 0 );
1024
+ const auto copy_extend = sycl::range<3 >(w / ele_size, h, 1 );
1025
1025
// TODO: Remove const_cast after refining the signature of ext_oneapi_copy.
1026
1026
return q.ext_oneapi_copy (const_cast <void *>(src), src_offset, src_extend,
1027
1027
dest, dest_offset, desc_dest, copy_extend);
@@ -1042,7 +1042,7 @@ static inline std::vector<sycl::event> dpct_memcpy_from_host(
1042
1042
const auto dest_offset =
1043
1043
sycl::range<3 >(w_offset_dest / ele_size, h_offset_dest, 0 );
1044
1044
const auto copy_extend =
1045
- sycl::range<3 >((w - w_offset_dest) / ele_size, 1 , 0 );
1045
+ sycl::range<3 >((w - w_offset_dest) / ele_size, 1 , 1 );
1046
1046
// TODO: Remove const_cast after refining the signature of ext_oneapi_copy.
1047
1047
event_list.push_back (q.ext_oneapi_copy (
1048
1048
const_cast <void *>(src_host_ptr), src_offset, src_extend, dest,
@@ -1056,7 +1056,7 @@ static inline std::vector<sycl::event> dpct_memcpy_from_host(
1056
1056
const auto src_extend = sycl::range<3 >(0 , 0 , 0 );
1057
1057
const auto dest_offset =
1058
1058
sycl::range<3 >(w_offset_dest / ele_size, h_offset_dest, 0 );
1059
- const auto copy_extend = sycl::range<3 >((s - offset_src) / ele_size, 1 , 0 );
1059
+ const auto copy_extend = sycl::range<3 >((s - offset_src) / ele_size, 1 , 1 );
1060
1060
// TODO: Remove const_cast after refining the signature of ext_oneapi_copy.
1061
1061
event_list.push_back (q.ext_oneapi_copy (
1062
1062
const_cast <void *>(src_host_ptr), src_offset, src_extend, dest,
@@ -1101,7 +1101,7 @@ dpct_memcpy(const image_mem_wrapper *src, const sycl::id<3> &src_id,
1101
1101
sycl::range<3 >(dest.get_pitch () / ele_size, dest.get_y (), 1 );
1102
1102
const auto copy_extend = sycl::range<3 >(
1103
1103
copy_x_size_byte != 0 ? copy_x_size_byte / ele_size : size[0 ], size[1 ],
1104
- size[2 ]);
1104
+ size[2 ] != 0 ? size[ 2 ] : 1 );
1105
1105
return q.ext_oneapi_copy (src->get_handle (), src_offset, src->get_desc (),
1106
1106
dest.get_data_ptr (), dest_offset, dest_extend,
1107
1107
copy_extend);
@@ -2001,11 +2001,19 @@ static inline void dpct_memcpy(image_mem_wrapper *dest, size_t w_offset_dest,
2001
2001
size_t w_offset_src, size_t h_offset_src,
2002
2002
size_t w, size_t h,
2003
2003
sycl::queue q = get_default_queue()) {
2004
- auto temp = (void *)sycl::malloc_device (w * h, q);
2005
- // TODO: Need change logic when sycl support image_mem to image_mem copy.
2006
- dpct_memcpy (temp, w, src, w_offset_src, h_offset_src, w, h, q);
2007
- dpct_memcpy (dest, w_offset_dest, h_offset_dest, temp, w, w, h, q);
2008
- sycl::free (temp, q);
2004
+ const auto from_ele_size = detail::get_ele_size (src->get_desc ());
2005
+ const auto src_offset = sycl::range<3 >(
2006
+ w_offset_src != 0 ? w_offset_src / from_ele_size : w_offset_src,
2007
+ h_offset_src, 0 );
2008
+ const auto to_ele_size = detail::get_ele_size (dest->get_desc ());
2009
+ const auto dest_offset = sycl::range<3 >(
2010
+ w_offset_dest != 0 ? w_offset_dest / to_ele_size : w_offset_dest,
2011
+ h_offset_dest, 0 );
2012
+ const auto copy_extent = sycl::range<3 >(w / from_ele_size, h, 1 );
2013
+ q.ext_oneapi_copy (src->get_handle (), src_offset, src->get_desc (),
2014
+ dest->get_handle (), dest_offset, dest->get_desc (),
2015
+ copy_extent)
2016
+ .wait ();
2009
2017
}
2010
2018
2011
2019
// / Synchronously copies from image memory to the image memory, The function
@@ -2023,11 +2031,19 @@ static inline void dpct_memcpy(image_mem_wrapper *dest, size_t w_offset_dest,
2023
2031
const image_mem_wrapper *src,
2024
2032
size_t w_offset_src, size_t h_offset_src,
2025
2033
size_t s, sycl::queue q = get_default_queue()) {
2026
- auto temp = (void *)sycl::malloc_device (s, q);
2027
- // TODO: Need change logic when sycl support image_mem to image_mem copy.
2028
- dpct_memcpy (temp, src, w_offset_src, h_offset_src, s, q);
2029
- dpct_memcpy (dest, w_offset_dest, h_offset_dest, temp, s, q);
2030
- sycl::free (temp, q);
2034
+ const auto from_ele_size = detail::get_ele_size (src->get_desc ());
2035
+ const auto src_offset = sycl::range<3 >(
2036
+ w_offset_src != 0 ? w_offset_src / from_ele_size : w_offset_src,
2037
+ h_offset_src, 0 );
2038
+ const auto to_ele_size = detail::get_ele_size (dest->get_desc ());
2039
+ const auto dest_offset = sycl::range<3 >(
2040
+ w_offset_dest != 0 ? w_offset_dest / to_ele_size : w_offset_dest,
2041
+ h_offset_dest, 0 );
2042
+ const auto copy_extent = sycl::range<3 >(s / from_ele_size, 1 , 1 );
2043
+ q.ext_oneapi_copy (src->get_handle (), src_offset, src->get_desc (),
2044
+ dest->get_handle (), dest_offset, dest->get_desc (),
2045
+ copy_extent)
2046
+ .wait ();
2031
2047
}
2032
2048
// A wrapper for sycl fetch_image function for the byte addressing image.
2033
2049
template <typename DataT, typename HintT = DataT, typename CoordT>
0 commit comments