Skip to content

Commit

Permalink
Fix csr_accessor crash when moving data from USM or host memory to ho…
Browse files Browse the repository at this point in the history
…st memory (#2662)

The implementation of copy_all2all backend function was changed: copy(...) was replaces with memcpy(...) that copies exactly the requested number of bytes. In the previous implementation the copy(...) function was multiplying the requested number of bytes to the type size which produces the wrong size of the copied array.

csr_accessor test was extended to cover the cases that were failing previously.
  • Loading branch information
Vika-F authored Feb 14, 2024
1 parent 3257425 commit e0f791e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cpp/oneapi/dal/backend/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ inline sycl::event copy_all2all(sycl::queue& queue,
event = memcpy_host2usm(queue, dest, src, sizeof(T) * n, deps);
}
else {
copy(dest, src, sizeof(T) * n);
memcpy(dest, src, sizeof(T) * n);
}
return event;
}
Expand Down
18 changes: 8 additions & 10 deletions cpp/oneapi/dal/table/test/csr_accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,10 @@ TEMPLATE_LIST_TEST_M(csr_accessor_test,
test_alloc_kind::usm_device,
test_alloc_kind::usm_shared);

this->accessor_alloc_ = GENERATE(test_alloc_kind::usm_device, test_alloc_kind::usm_shared);

// Furter improvement: Add support of the following accessor allocation types:
// test_alloc_kind::host,
// test_alloc_kind::usm_host.
this->accessor_alloc_ = GENERATE(test_alloc_kind::host,
test_alloc_kind::usm_host,
test_alloc_kind::usm_device,
test_alloc_kind::usm_shared);
#else
this->table_alloc_ = test_alloc_kind::host;
this->accessor_alloc_ = test_alloc_kind::host;
Expand All @@ -379,11 +378,10 @@ TEMPLATE_LIST_TEST_M(csr_accessor_test,
test_alloc_kind::usm_device,
test_alloc_kind::usm_shared);

this->accessor_alloc_ = GENERATE(test_alloc_kind::usm_device, test_alloc_kind::usm_shared);

// Furter improvement: Add support of the following accessor allocation types:
// test_alloc_kind::host,
// test_alloc_kind::usm_host.
this->accessor_alloc_ = GENERATE(test_alloc_kind::host,
test_alloc_kind::usm_host,
test_alloc_kind::usm_device,
test_alloc_kind::usm_shared);
#else
this->table_alloc_ = test_alloc_kind::host;
this->accessor_alloc_ = test_alloc_kind::host;
Expand Down

0 comments on commit e0f791e

Please sign in to comment.