From b5bbc54a9b92492b08a0a767a61b0d78769a115e Mon Sep 17 00:00:00 2001 From: Vlad Romanov Date: Tue, 12 Nov 2019 09:03:49 +0300 Subject: [PATCH] [SYCL] Fix usage of uninitialized variable in device_impl 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 --- sycl/include/CL/sycl/detail/device_impl.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sycl/include/CL/sycl/detail/device_impl.hpp b/sycl/include/CL/sycl/detail/device_impl.hpp index b87d78e1ed2d5..879dba8ae9c2b 100644 --- a/sycl/include/CL/sycl/detail/device_impl.hpp +++ b/sycl/include/CL/sycl/detail/device_impl.hpp @@ -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 ///