@@ -524,14 +524,13 @@ copy_usm_ndarray_into_usm_ndarray(dpctl::tensor::usm_ndarray src,
524
524
}
525
525
}
526
526
527
- // check same contexts
527
+ // check compatibility of execution queue and allocation queue
528
528
sycl::queue src_q = src.get_queue ();
529
529
sycl::queue dst_q = dst.get_queue ();
530
530
531
- sycl::context exec_ctx = exec_q.get_context ();
532
- if (src_q.get_context () != exec_ctx || dst_q.get_context () != exec_ctx) {
531
+ if (!dpctl::utils::queues_are_compatible (exec_q, {src_q, dst_q})) {
533
532
throw py::value_error (
534
- " Execution queue context is not the same as allocation contexts " );
533
+ " Execution queue is not compatible with allocation queues " );
535
534
}
536
535
537
536
int src_typenum = src.get_typenum ();
@@ -938,10 +937,9 @@ copy_usm_ndarray_for_reshape(dpctl::tensor::usm_ndarray src,
938
937
sycl::queue src_q = src.get_queue ();
939
938
sycl::queue dst_q = dst.get_queue ();
940
939
941
- sycl::context exec_ctx = exec_q.get_context ();
942
- if (src_q.get_context () != exec_ctx || dst_q.get_context () != exec_ctx) {
940
+ if (!dpctl::utils::queues_are_compatible (exec_q, {src_q, dst_q})) {
943
941
throw py::value_error (
944
- " Execution queue context is not the same as allocation contexts " );
942
+ " Execution queue is not compatible with allocation queues " );
945
943
}
946
944
947
945
if (src_nelems == 1 ) {
@@ -1255,10 +1253,9 @@ void copy_numpy_ndarray_into_usm_ndarray(
1255
1253
1256
1254
sycl::queue dst_q = dst.get_queue ();
1257
1255
1258
- sycl::context exec_ctx = exec_q.get_context ();
1259
- if (dst_q.get_context () != exec_ctx) {
1260
- throw py::value_error (" Execution queue context is not the same as the "
1261
- " allocation context" );
1256
+ if (!dpctl::utils::queues_are_compatible (exec_q, {dst_q})) {
1257
+ throw py::value_error (" Execution queue is not compatible with the "
1258
+ " allocation queue" );
1262
1259
}
1263
1260
1264
1261
// here we assume that NumPy's type numbers agree with ours for types
0 commit comments