@@ -963,9 +963,9 @@ dpct_memcpy(sycl::ext::oneapi::experimental::image_mem_handle src,
963
963
sycl::range<3 >(w_offset_src / ele_size, h_offset_src, 0 );
964
964
const auto dest_offset = sycl::range<3 >(0 , 0 , 0 );
965
965
const auto dest_extend = sycl::range<3 >(p / ele_size, 0 , 0 );
966
- const auto copy_extend = sycl::range<3 >(w / ele_size, h, 0 );
966
+ const auto copy_extend = sycl::range<3 >(w / ele_size, h, 1 );
967
967
return q.ext_oneapi_copy (src, src_offset, desc_src, dest, dest_offset,
968
- dest_extend , copy_extend);
968
+ desc_src, p , copy_extend);
969
969
}
970
970
971
971
static inline std::vector<sycl::event> dpct_memcpy_to_host (
@@ -983,7 +983,7 @@ static inline std::vector<sycl::event> dpct_memcpy_to_host(
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
985
const auto copy_extend =
986
- sycl::range<3 >((w - w_offset_src) / ele_size, 1 , 0 );
986
+ sycl::range<3 >((w - w_offset_src) / ele_size, 1 , 1 );
987
987
event_list.push_back (q.ext_oneapi_copy (src, src_offset, desc_src,
988
988
dest_host_ptr, dest_offset,
989
989
dest_extend, copy_extend));
@@ -996,7 +996,7 @@ static inline std::vector<sycl::event> dpct_memcpy_to_host(
996
996
sycl::range<3 >(w_offset_src / ele_size, h_offset_src, 0 );
997
997
const auto dest_offset = sycl::range<3 >(offset_dest / ele_size, 0 , 0 );
998
998
const auto dest_extend = sycl::range<3 >(0 , 0 , 0 );
999
- const auto copy_extend = sycl::range<3 >((s - offset_dest) / ele_size, 1 , 0 );
999
+ const auto copy_extend = sycl::range<3 >((s - offset_dest) / ele_size, 1 , 1 );
1000
1000
event_list.push_back (q.ext_oneapi_copy (src, src_offset, desc_src,
1001
1001
dest_host_ptr, dest_offset,
1002
1002
dest_extend, copy_extend));
@@ -1035,7 +1035,7 @@ dpct_memcpy(const void *src,
1035
1035
const auto src_extend = sycl::range<3 >(p / ele_size, 0 , 0 );
1036
1036
const auto dest_offset =
1037
1037
sycl::range<3 >(w_offset_dest / ele_size, h_offset_dest, 0 );
1038
- const auto copy_extend = sycl::range<3 >(w / ele_size, h, 0 );
1038
+ const auto copy_extend = sycl::range<3 >(w / ele_size, h, 1 );
1039
1039
// TODO: Remove const_cast after refining the signature of ext_oneapi_copy.
1040
1040
return q.ext_oneapi_copy (const_cast <void *>(src), src_offset, src_extend,
1041
1041
dest, dest_offset, desc_dest, copy_extend);
@@ -1056,7 +1056,7 @@ static inline std::vector<sycl::event> dpct_memcpy_from_host(
1056
1056
const auto dest_offset =
1057
1057
sycl::range<3 >(w_offset_dest / ele_size, h_offset_dest, 0 );
1058
1058
const auto copy_extend =
1059
- sycl::range<3 >((w - w_offset_dest) / ele_size, 1 , 0 );
1059
+ sycl::range<3 >((w - w_offset_dest) / 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,
@@ -1070,7 +1070,7 @@ static inline std::vector<sycl::event> dpct_memcpy_from_host(
1070
1070
const auto src_extend = sycl::range<3 >(0 , 0 , 0 );
1071
1071
const auto dest_offset =
1072
1072
sycl::range<3 >(w_offset_dest / ele_size, h_offset_dest, 0 );
1073
- const auto copy_extend = sycl::range<3 >((s - offset_src) / ele_size, 1 , 0 );
1073
+ const auto copy_extend = sycl::range<3 >((s - offset_src) / ele_size, 1 , 1 );
1074
1074
// TODO: Remove const_cast after refining the signature of ext_oneapi_copy.
1075
1075
event_list.push_back (q.ext_oneapi_copy (
1076
1076
const_cast <void *>(src_host_ptr), src_offset, src_extend, dest,
@@ -1115,7 +1115,7 @@ dpct_memcpy(const image_mem_wrapper *src, const sycl::id<3> &src_id,
1115
1115
sycl::range<3 >(dest.get_pitch () / ele_size, dest.get_y (), 1 );
1116
1116
const auto copy_extend = sycl::range<3 >(
1117
1117
copy_x_size_byte != 0 ? copy_x_size_byte / ele_size : size[0 ], size[1 ],
1118
- size[2 ]);
1118
+ size[2 ] != 0 ? size[ 2 ] : 1 );
1119
1119
return q.ext_oneapi_copy (src->get_handle (), src_offset, src->get_desc (),
1120
1120
dest.get_data_ptr (), dest_offset, dest_extend,
1121
1121
copy_extend);
@@ -1946,11 +1946,19 @@ static inline void dpct_memcpy(image_mem_wrapper *dest, size_t w_offset_dest,
1946
1946
size_t w_offset_src, size_t h_offset_src,
1947
1947
size_t w, size_t h,
1948
1948
sycl::queue q = get_default_queue()) {
1949
- auto temp = (void *)sycl::malloc_device (w * h, q);
1950
- // TODO: Need change logic when sycl support image_mem to image_mem copy.
1951
- dpct_memcpy (temp, w, src, w_offset_src, h_offset_src, w, h, q);
1952
- dpct_memcpy (dest, w_offset_dest, h_offset_dest, temp, w, w, h, q);
1953
- sycl::free (temp, q);
1949
+ const auto from_ele_size = detail::get_ele_size (src->get_desc ());
1950
+ const auto src_offset = sycl::range<3 >(
1951
+ w_offset_src != 0 ? w_offset_src / from_ele_size : w_offset_src,
1952
+ h_offset_src, 0 );
1953
+ const auto to_ele_size = detail::get_ele_size (dest->get_desc ());
1954
+ const auto dest_offset = sycl::range<3 >(
1955
+ w_offset_dest != 0 ? w_offset_dest / to_ele_size : w_offset_dest,
1956
+ h_offset_dest, 0 );
1957
+ const auto copy_extent = sycl::range<3 >(w / from_ele_size, h, 1 );
1958
+ q.ext_oneapi_copy (src->get_handle (), src_offset, src->get_desc (),
1959
+ dest->get_handle (), dest_offset, dest->get_desc (),
1960
+ copy_extent)
1961
+ .wait ();
1954
1962
}
1955
1963
1956
1964
// / Synchronously copies from image memory to the image memory, The function
@@ -1968,11 +1976,19 @@ static inline void dpct_memcpy(image_mem_wrapper *dest, size_t w_offset_dest,
1968
1976
const image_mem_wrapper *src,
1969
1977
size_t w_offset_src, size_t h_offset_src,
1970
1978
size_t s, sycl::queue q = get_default_queue()) {
1971
- auto temp = (void *)sycl::malloc_device (s, q);
1972
- // TODO: Need change logic when sycl support image_mem to image_mem copy.
1973
- dpct_memcpy (temp, src, w_offset_src, h_offset_src, s, q);
1974
- dpct_memcpy (dest, w_offset_dest, h_offset_dest, temp, s, q);
1975
- sycl::free (temp, q);
1979
+ const auto from_ele_size = detail::get_ele_size (src->get_desc ());
1980
+ const auto src_offset = sycl::range<3 >(
1981
+ w_offset_src != 0 ? w_offset_src / from_ele_size : w_offset_src,
1982
+ h_offset_src, 0 );
1983
+ const auto to_ele_size = detail::get_ele_size (dest->get_desc ());
1984
+ const auto dest_offset = sycl::range<3 >(
1985
+ w_offset_dest != 0 ? w_offset_dest / to_ele_size : w_offset_dest,
1986
+ h_offset_dest, 0 );
1987
+ const auto copy_extent = sycl::range<3 >(s / from_ele_size, 1 , 1 );
1988
+ q.ext_oneapi_copy (src->get_handle (), src_offset, src->get_desc (),
1989
+ dest->get_handle (), dest_offset, dest->get_desc (),
1990
+ copy_extent)
1991
+ .wait ();
1976
1992
}
1977
1993
// A wrapper for sycl fetch_image function for the byte addressing image.
1978
1994
template <typename DataT, typename HintT = DataT, typename CoordT>
0 commit comments