Pārlūkot izejas kodu

OpenCL: when memory allocation fails, returns an error instead of aborting. StarPU can cope with the situation

Nathalie Furmento 14 gadi atpakaļ
vecāks
revīzija
cc004131a4
2 mainītis faili ar 11 papildinājumiem un 2 dzēšanām
  1. 6 1
      include/starpu_opencl.h
  2. 5 1
      src/drivers/opencl/driver_opencl.c

+ 6 - 1
include/starpu_opencl.h

@@ -25,7 +25,7 @@
 extern "C" {
 #endif
 
-#define STARPU_OPENCL_REPORT_ERROR(status)                                     \
+#define STARPU_OPENCL_DISPLAY_ERROR(status)                                     \
 	do {                                                            \
 		char *errormsg;                                         \
 		switch (status) {                                       \
@@ -172,6 +172,11 @@ extern "C" {
 			break;			                        \
 		}                                                       \
 		printf("oops in %s ... <%s> (%d) \n", __func__, errormsg, status); \
+	} while (0)
+
+#define STARPU_OPENCL_REPORT_ERROR(status)                                     \
+	do {                                                            \
+        	STARPU_OPENCL_DISPLAY_ERROR(status);			\
 		assert(0);	                                        \
 	} while (0)
 

+ 5 - 1
src/drivers/opencl/driver_opencl.c

@@ -162,7 +162,11 @@ cl_int _starpu_opencl_allocate_memory(void **addr, size_t size, cl_mem_flags fla
         struct starpu_worker_s *worker = _starpu_get_local_worker_key();
 
 	address = clCreateBuffer(contexts[worker->devid], flags, size, NULL, &err);
-	if (err != CL_SUCCESS) STARPU_OPENCL_REPORT_ERROR(err);
+	if (err != CL_SUCCESS)
+        {
+                STARPU_OPENCL_DISPLAY_ERROR(err);
+                return err;
+        }
 
         *addr = address;
         return CL_SUCCESS;