Skip to content

Commit

Permalink
[SYCL] Fix usage of uninitialized variable in device_impl (#819)
Browse files Browse the repository at this point in the history
MType variable is not initialized for the host device. The patch
changes several device_impl methods to avoid using MType if a
device is a host one.

Signed-off-by: Vlad Romanov <vlad.romanov@intel.com>
  • Loading branch information
romanovvlad authored and bader committed Nov 14, 2019
1 parent 47c4c71 commit 30493bb
Showing 1 changed file with 5 additions and 3 deletions.
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)); }

/// 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

0 comments on commit 30493bb

Please sign in to comment.