[arrayfire] 130/408: Ensure CUDA and OpenCL return proper errors when out of memory
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:11:37 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/sid
in repository arrayfire.
commit 981cb4ade4833ee73283a2bb7455c7d228ac72f9
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date: Fri Jul 10 09:59:05 2015 -0400
Ensure CUDA and OpenCL return proper errors when out of memory
---
src/backend/cuda/err_cuda.hpp | 33 ++++++++++++++++++---------------
src/backend/opencl/err_opencl.hpp | 22 +++++++++++++---------
2 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/src/backend/cuda/err_cuda.hpp b/src/backend/cuda/err_cuda.hpp
index c9dbffe..0692f1e 100644
--- a/src/backend/cuda/err_cuda.hpp
+++ b/src/backend/cuda/err_cuda.hpp
@@ -16,19 +16,22 @@
throw SupportError(__FILE__, __LINE__, "CUDA"); \
} while(0)
-#define CUDA_CHECK(fn) do { \
- cudaError_t _cuda_error = fn; \
- if (_cuda_error != cudaSuccess) { \
- char cuda_err_msg[1024]; \
- snprintf(cuda_err_msg, \
- sizeof(cuda_err_msg), \
- "CUDA Error (%d): %s\n", \
- (int)(_cuda_error), \
- cudaGetErrorString( \
- _cuda_error)); \
- \
- AF_ERROR(cuda_err_msg, \
- AF_ERR_INTERNAL); \
- } \
+#define CUDA_CHECK(fn) do { \
+ cudaError_t _cuda_error = fn; \
+ if (_cuda_error != cudaSuccess) { \
+ char cuda_err_msg[1024]; \
+ snprintf(cuda_err_msg, \
+ sizeof(cuda_err_msg), \
+ "CUDA Error (%d): %s\n", \
+ (int)(_cuda_error), \
+ cudaGetErrorString( \
+ cudaGetLastError())); \
+ \
+ if (_cuda_error == cudaErrorMemoryAllocation) { \
+ AF_ERROR(cuda_err_msg, AF_ERR_NO_MEM); \
+ } else { \
+ AF_ERROR(cuda_err_msg, \
+ AF_ERR_INTERNAL); \
+ } \
+ } \
} while(0)
-
diff --git a/src/backend/opencl/err_opencl.hpp b/src/backend/opencl/err_opencl.hpp
index 7369cfd..0379402 100644
--- a/src/backend/opencl/err_opencl.hpp
+++ b/src/backend/opencl/err_opencl.hpp
@@ -18,15 +18,19 @@
throw SupportError(__FILE__, __LINE__, "OPENCL"); \
} while(0)
-#define CL_TO_AF_ERROR(ERR) do { \
- char opencl_err_msg[1024]; \
- snprintf(opencl_err_msg, \
- sizeof(opencl_err_msg), \
- "OpenCL Error: %s when calling %s", \
- getErrorMessage(ERR.err()).c_str(), \
- ERR.what()); \
- AF_ERROR(opencl_err_msg, \
- AF_ERR_INTERNAL); \
+#define CL_TO_AF_ERROR(ERR) do { \
+ char opencl_err_msg[1024]; \
+ snprintf(opencl_err_msg, \
+ sizeof(opencl_err_msg), \
+ "OpenCL Error: %s when calling %s", \
+ getErrorMessage(ERR.err()).c_str(), \
+ ERR.what()); \
+ if (ERR.err() == CL_MEM_OBJECT_ALLOCATION_FAILURE) { \
+ AF_ERROR(opencl_err_msg, AF_ERR_NO_MEM); \
+ } else { \
+ AF_ERROR(opencl_err_msg, \
+ AF_ERR_INTERNAL); \
+ } \
} while(0)
namespace opencl
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git
More information about the debian-science-commits
mailing list