summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunjie Bai <bai@in.tum.de>2019-03-01 00:02:56 -0800
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2019-03-01 00:05:46 -0800
commit212024282b8d0c1ede192238314e79a71c7eb689 (patch)
tree4ecd318019219556f7fd9da9e191eda3662e8870
parentd3fcd0d798a0188ae4fffafe13d7c71f4186f4ce (diff)
downloadpytorch-212024282b8d0c1ede192238314e79a71c7eb689.tar.gz
pytorch-212024282b8d0c1ede192238314e79a71c7eb689.tar.bz2
pytorch-212024282b8d0c1ede192238314e79a71c7eb689.zip
Mark cudaGetLastError return value unused in C10_CUDA_CHECK
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/17605 Reviewed By: xw285cornell Differential Revision: D14277586 Pulled By: bddppq fbshipit-source-id: 38879208f2ab83cf39d8a8a61b288cd09fcafd9a
-rw-r--r--c10/cuda/CUDAException.h5
-rw-r--r--c10/macros/Macros.h7
2 files changed, 10 insertions, 2 deletions
diff --git a/c10/cuda/CUDAException.h b/c10/cuda/CUDAException.h
index 3836865eb5..9dfdd89001 100644
--- a/c10/cuda/CUDAException.h
+++ b/c10/cuda/CUDAException.h
@@ -1,6 +1,7 @@
#pragma once
#include "c10/util/Exception.h"
+#include "c10/macros/Macros.h"
#include "cuda.h"
// Note [CHECK macro]
@@ -10,11 +11,11 @@
// macro and a function implementation if we pass along __LINE__
// and __FILE__, but no one has found this worth doing.
-#define C10_CUDA_CHECK(EXPR) \
+#define C10_CUDA_CHECK(EXPR) \
do { \
cudaError_t __err = EXPR; \
if (__err != cudaSuccess) { \
- cudaGetLastError(); \
+ auto error_unused C10_UNUSED = cudaGetLastError(); \
AT_ERROR("CUDA error: ", cudaGetErrorString(__err)); \
} \
} while (0)
diff --git a/c10/macros/Macros.h b/c10/macros/Macros.h
index b12d8b7839..884abe6b3a 100644
--- a/c10/macros/Macros.h
+++ b/c10/macros/Macros.h
@@ -50,6 +50,13 @@
#endif
#endif
+// suppress an unused variable.
+#ifdef _MSC_VER
+#define C10_UNUSED
+#else
+#define C10_UNUSED __attribute__((__unused__))
+#endif //_MSC_VER
+
// Simply define the namespace, in case a dependent library want to refer to
// the c10 namespace but not any nontrivial files.
namespace c10 {} // namespace c10