Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Fix usage of uninitialized variable in device_impl #819

Merged
merged 1 commit into from
Nov 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions sycl/include/CL/sycl/detail/device_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,19 @@ class device_impl {
/// Check if device is a CPU device
///
/// @return true if SYCL device is a CPU device
bool is_cpu() const { return (MType == PI_DEVICE_TYPE_CPU); }
bool is_cpu() const { return (!is_host() && (MType == PI_DEVICE_TYPE_CPU)); }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it's right approach. Probably the right approach would be to add new device type(host) to _pi_device_type enum. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think PI wants to cover "host". It is rather interface for offloading. So I think what you are doing is preferable, but is it really OK that we return false in all of these for "host"? Should we return true for is_cpu()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smaslov-intel technically, host device is not CPU, it is host. But I agree with your point about covering host on PI.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, then I am OK with the fix.


/// Check if device is a GPU device
///
/// @return true if SYCL device is a GPU device
bool is_gpu() const { return (MType == PI_DEVICE_TYPE_GPU); }
bool is_gpu() const { return (!is_host() && (MType == PI_DEVICE_TYPE_GPU)); }

/// Check if device is an accelerator device
///
/// @return true if SYCL device is an accelerator device
bool is_accelerator() const { return (MType == PI_DEVICE_TYPE_ACC); }
bool is_accelerator() const {
return (!is_host() && (MType == PI_DEVICE_TYPE_ACC));
}

/// Get associated SYCL platform
///
Expand Down