From 5ffe7b92e0b7601887be4f2130383e7157072b19 Mon Sep 17 00:00:00 2001 From: Chao Chen Date: Tue, 20 Sep 2022 21:38:20 +0000 Subject: [PATCH] [ROCm] fixed gpuGetDevice unused message --- .../Eigen/CXX11/src/Tensor/TensorDeviceGpu.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceGpu.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceGpu.h index 3b09a0fc7..8ea1bf0d4 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceGpu.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceGpu.h @@ -130,7 +130,13 @@ class GpuStreamDevice : public StreamInterface { public: // Use the default stream on the current device GpuStreamDevice() : stream_(&default_stream), scratch_(NULL), semaphore_(NULL) { - gpuGetDevice(&device_); + gpuError_t status = gpuGetDevice(&device_); + if (status != gpuSuccess) { + std::cerr << "Failed to get the GPU devices " + << gpuGetErrorString(status) + << std::endl; + gpu_assert(status == gpuSuccess); + } } // Use the default stream on the specified device GpuStreamDevice(int device) : stream_(&default_stream), device_(device), scratch_(NULL), semaphore_(NULL) {} @@ -141,7 +147,13 @@ class GpuStreamDevice : public StreamInterface { GpuStreamDevice(const gpuStream_t* stream, int device = -1) : stream_(stream), device_(device), scratch_(NULL), semaphore_(NULL) { if (device < 0) { - gpuGetDevice(&device_); + gpuError_t status = gpuGetDevice(&device_); + if (status != gpuSuccess) { + std::cerr << "Failed to get the GPU devices " + << gpuGetErrorString(status) + << std::endl; + gpu_assert(status == gpuSuccess); + } } else { int num_devices; gpuError_t err = gpuGetDeviceCount(&num_devices);