Skip to content

Commit f35734b

Browse files
committed
Simplified host_tasks in _put
1 parent b69a415 commit f35734b

File tree

1 file changed

+21
-28
lines changed

1 file changed

+21
-28
lines changed

dpctl/tensor/libtensor/source/integer_advanced_indexing.cpp

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -599,22 +599,21 @@ usm_ndarray_take(dpctl::tensor::usm_ndarray src,
599599
std::shared_ptr<shT> host_ind_offsets_shp =
600600
std::make_shared<shT>(k, ind_allocator);
601601

602-
std::copy(ind_sh_sts.begin(), ind_sh_sts.end(),
603-
host_ind_shapes_strides_shp->begin());
604-
std::copy(ind_ptrs.begin(), ind_ptrs.end(), host_ind_ptrs_shp->begin());
605-
std::copy(ind_offsets.begin(), ind_offsets.end(),
606-
host_ind_offsets_shp->begin());
607-
608602
std::vector<sycl::event> host_task_events;
609603
host_task_events.reserve(5);
610604

605+
std::copy(ind_sh_sts.begin(), ind_sh_sts.end(),
606+
host_ind_shapes_strides_shp->begin());
611607
sycl::event packed_ind_ptrs_copy_ev = exec_q.copy<char *>(
612608
host_ind_ptrs_shp->data(), packed_ind_ptrs, host_ind_ptrs_shp->size());
613609

610+
std::copy(ind_ptrs.begin(), ind_ptrs.end(), host_ind_ptrs_shp->begin());
614611
sycl::event packed_ind_shapes_strides_copy_ev = exec_q.copy<py::ssize_t>(
615612
host_ind_shapes_strides_shp->data(), packed_ind_shapes_strides,
616613
host_ind_shapes_strides_shp->size());
617614

615+
std::copy(ind_offsets.begin(), ind_offsets.end(),
616+
host_ind_offsets_shp->begin());
618617
sycl::event packed_ind_offsets_copy_ev = exec_q.copy<py::ssize_t>(
619618
host_ind_offsets_shp->data(), packed_ind_offsets,
620619
host_ind_offsets_shp->size());
@@ -1011,40 +1010,34 @@ usm_ndarray_put(dpctl::tensor::usm_ndarray dst,
10111010
std::shared_ptr<shT> host_ind_offsets_shp =
10121011
std::make_shared<shT>(k, ind_allocator);
10131012

1014-
std::copy(ind_sh_sts.begin(), ind_sh_sts.end(),
1015-
host_ind_shapes_strides_shp->begin());
1016-
std::copy(ind_ptrs.begin(), ind_ptrs.end(), host_ind_ptrs_shp->begin());
1017-
std::copy(ind_offsets.begin(), ind_offsets.end(),
1018-
host_ind_offsets_shp->begin());
1019-
10201013
std::vector<sycl::event> host_task_events;
1021-
host_task_events.reserve(7);
1014+
host_task_events.reserve(5);
10221015

1016+
std::copy(ind_ptrs.begin(), ind_ptrs.end(), host_ind_ptrs_shp->begin());
10231017
sycl::event device_ind_ptrs_copy_ev = exec_q.copy<char *>(
10241018
host_ind_ptrs_shp->data(), packed_ind_ptrs, host_ind_ptrs_shp->size());
1025-
sycl::event ind_ptrs_host_task = exec_q.submit([&](sycl::handler &cgh) {
1026-
cgh.depends_on(device_ind_ptrs_copy_ev);
1027-
cgh.host_task([host_ind_ptrs_shp]() {});
1028-
});
1029-
host_task_events.push_back(ind_ptrs_host_task);
10301019

1020+
std::copy(ind_sh_sts.begin(), ind_sh_sts.end(),
1021+
host_ind_shapes_strides_shp->begin());
10311022
sycl::event device_ind_shapes_strides_copy_ev = exec_q.copy<py::ssize_t>(
10321023
host_ind_shapes_strides_shp->data(), packed_ind_shapes_strides,
10331024
host_ind_shapes_strides_shp->size());
1034-
sycl::event ind_sh_st_host_task = exec_q.submit([&](sycl::handler &cgh) {
1035-
cgh.depends_on(device_ind_shapes_strides_copy_ev);
1036-
cgh.host_task([host_ind_shapes_strides_shp]() {});
1037-
});
1038-
host_task_events.push_back(ind_sh_st_host_task);
10391025

1026+
std::copy(ind_offsets.begin(), ind_offsets.end(),
1027+
host_ind_offsets_shp->begin());
10401028
sycl::event device_ind_offsets_copy_ev = exec_q.copy<py::ssize_t>(
10411029
host_ind_offsets_shp->data(), packed_ind_offsets,
10421030
host_ind_offsets_shp->size());
1043-
sycl::event ind_offsets_host_task = exec_q.submit([&](sycl::handler &cgh) {
1044-
cgh.depends_on(device_ind_offsets_copy_ev);
1045-
cgh.host_task([host_ind_offsets_shp]() {});
1046-
});
1047-
host_task_events.push_back(ind_offsets_host_task);
1031+
1032+
sycl::event shared_ptr_cleanup_host_task =
1033+
exec_q.submit([&](sycl::handler &cgh) {
1034+
cgh.depends_on(device_ind_ptrs_copy_ev);
1035+
cgh.depends_on(device_ind_shapes_strides_copy_ev);
1036+
cgh.depends_on(device_ind_offsets_copy_ev);
1037+
cgh.host_task([host_ind_ptrs_shp, host_ind_shapes_strides_shp,
1038+
host_ind_offsets_shp]() {});
1039+
});
1040+
host_task_events.push_back(shared_ptr_cleanup_host_task);
10481041

10491042
std::vector<sycl::event> ind_pack_depends{device_ind_ptrs_copy_ev,
10501043
device_ind_shapes_strides_copy_ev,

0 commit comments

Comments
 (0)