Skip to content

Commit 30493bb

Browse files
romanovvladbader
authored andcommitted
[SYCL] Fix usage of uninitialized variable in device_impl (#819)
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 <[email protected]>
1 parent 47c4c71 commit 30493bb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sycl/include/CL/sycl/detail/device_impl.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,19 @@ class device_impl {
7474
/// Check if device is a CPU device
7575
///
7676
/// @return true if SYCL device is a CPU device
77-
bool is_cpu() const { return (MType == PI_DEVICE_TYPE_CPU); }
77+
bool is_cpu() const { return (!is_host() && (MType == PI_DEVICE_TYPE_CPU)); }
7878

7979
/// Check if device is a GPU device
8080
///
8181
/// @return true if SYCL device is a GPU device
82-
bool is_gpu() const { return (MType == PI_DEVICE_TYPE_GPU); }
82+
bool is_gpu() const { return (!is_host() && (MType == PI_DEVICE_TYPE_GPU)); }
8383

8484
/// Check if device is an accelerator device
8585
///
8686
/// @return true if SYCL device is an accelerator device
87-
bool is_accelerator() const { return (MType == PI_DEVICE_TYPE_ACC); }
87+
bool is_accelerator() const {
88+
return (!is_host() && (MType == PI_DEVICE_TYPE_ACC));
89+
}
8890

8991
/// Get associated SYCL platform
9092
///

0 commit comments

Comments
 (0)