pytorch/c10/cuda/CUDAException.h
Junjie Bai 212024282b 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
2019-03-01 00:05:46 -08:00

22 lines
828 B
C

#pragma once
#include "c10/util/Exception.h"
#include "c10/macros/Macros.h"
#include "cuda.h"
// Note [CHECK macro]
// ~~~~~~~~~~~~~~~~~~
// This is a macro so that AT_ERROR can get accurate __LINE__
// and __FILE__ information. We could split this into a short
// 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) \
do { \
cudaError_t __err = EXPR; \
if (__err != cudaSuccess) { \
auto error_unused C10_UNUSED = cudaGetLastError(); \
AT_ERROR("CUDA error: ", cudaGetErrorString(__err)); \
} \
} while (0)