[Beignet] [PATCH 1/4] Refine retain/release context api.

junyan.he at inbox.com junyan.he at inbox.com
Mon Oct 10 07:20:07 UTC 2016


From: Junyan He <junyan.he at intel.com>

Signed-off-by: Junyan He <junyan.he at intel.com>
---
 src/cl_api.c         | 20 --------------------
 src/cl_api_context.c | 22 ++++++++++++++++++++++
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/src/cl_api.c b/src/cl_api.c
index 1c9dbb9..d21cc69 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -241,26 +241,6 @@ error:
   return context;
 }
 
-cl_int
-clRetainContext(cl_context context)
-{
-  cl_int err = CL_SUCCESS;
-  CHECK_CONTEXT (context);
-  cl_context_add_ref(context);
-error:
-  return err;
-}
-
-cl_int
-clReleaseContext(cl_context context)
-{
-  cl_int err = CL_SUCCESS;
-  CHECK_CONTEXT (context);
-  cl_context_delete(context);
-error:
-  return err;
-}
-
 cl_command_queue
 clCreateCommandQueue(cl_context                   context,
                      cl_device_id                 device,
diff --git a/src/cl_api_context.c b/src/cl_api_context.c
index d2adb41..f52c56a 100644
--- a/src/cl_api_context.c
+++ b/src/cl_api_context.c
@@ -19,6 +19,28 @@
 #include "cl_context.h"
 
 cl_int
+clRetainContext(cl_context context)
+{
+  if (!CL_OBJECT_IS_CONTEXT(context)) {
+    return CL_INVALID_CONTEXT;
+  }
+
+  cl_context_add_ref(context);
+  return CL_SUCCESS;
+}
+
+cl_int
+clReleaseContext(cl_context context)
+{
+  if (!CL_OBJECT_IS_CONTEXT(context)) {
+    return CL_INVALID_CONTEXT;
+  }
+
+  cl_context_delete(context);
+  return CL_SUCCESS;
+}
+
+cl_int
 clGetContextInfo(cl_context context,
                  cl_context_info param_name,
                  size_t param_value_size,
-- 
2.7.4





More information about the Beignet mailing list