Skip to content

Commit

Permalink
Fix is_ptr_accessible_on_host
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions committed Jun 4, 2024
1 parent 0933112 commit 657880c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/sparse_blas/backends/mkl_common/mkl_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ template <typename T>
inline bool is_ptr_accessible_on_host(sycl::queue &queue, const T *host_or_device_ptr) {
auto alloc_type = sycl::get_pointer_type(host_or_device_ptr, queue.get_context());
// Note sycl::usm::alloc::host may not be accessible on the host according to SYCL specification.
return alloc_type == sycl::usm::alloc::shared;
// sycl::usm::alloc::unknown is returned if the pointer is not a USM allocation which is assumed to be a normal host pointer.
return alloc_type == sycl::usm::alloc::shared || alloc_type == sycl::usm::alloc::unknown;
}

/// Throw an exception if the scalar is not accessible in the host
template <typename T>
void check_ptr_is_host_accessible(const std::string &function_name, const std::string &scalar_name,
sycl::queue &queue, const T *host_or_device_ptr) {
if (is_ptr_accessible_on_host(queue, host_or_device_ptr)) {
if (!is_ptr_accessible_on_host(queue, host_or_device_ptr)) {
throw mkl::invalid_argument(
"sparse_blas", function_name,
"Scalar " + scalar_name + "must be accessible on the host for buffer functions.");
"Scalar " + scalar_name + " must be accessible on the host for buffer functions.");
}
}

Expand Down

0 comments on commit 657880c

Please sign in to comment.