[Beignet] [PATCH 3/5] Refine clRetain/Release MemObject

junyan.he at inbox.com junyan.he at inbox.com
Thu Oct 13 08:40:55 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_mem.c | 22 ++++++++++++++++++++++
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/src/cl_api.c b/src/cl_api.c
index 34242af..210b817 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -312,26 +312,6 @@ error:
 }
 
 cl_int
-clRetainMemObject(cl_mem memobj)
-{
-  cl_int err = CL_SUCCESS;
-  CHECK_MEM (memobj);
-  cl_mem_add_ref(memobj);
-error:
-  return err;
-}
-
-cl_int
-clReleaseMemObject(cl_mem memobj)
-{
-  cl_int err = CL_SUCCESS;
-  CHECK_MEM (memobj);
-  cl_mem_delete(memobj);
-error:
-  return err;
-}
-
-cl_int
 clGetSupportedImageFormats(cl_context         ctx,
                            cl_mem_flags       flags,
                            cl_mem_object_type image_type,
diff --git a/src/cl_api_mem.c b/src/cl_api_mem.c
index 7f1f5c7..7f04637 100644
--- a/src/cl_api_mem.c
+++ b/src/cl_api_mem.c
@@ -2413,3 +2413,25 @@ clEnqueueFillImage(cl_command_queue command_queue,
 
   return err;
 }
+
+cl_int
+clRetainMemObject(cl_mem memobj)
+{
+  if (!CL_OBJECT_IS_MEM(memobj)) {
+    return CL_INVALID_MEM_OBJECT;
+  }
+
+  cl_mem_add_ref(memobj);
+  return CL_SUCCESS;
+}
+
+cl_int
+clReleaseMemObject(cl_mem memobj)
+{
+  if (!CL_OBJECT_IS_MEM(memobj)) {
+    return CL_INVALID_MEM_OBJECT;
+  }
+
+  cl_mem_delete(memobj);
+  return CL_SUCCESS;
+}
-- 
2.7.4





More information about the Beignet mailing list