[Beignet] [PATCH 1/7] Add a helper function for all information get.
junyan.he at inbox.com
junyan.he at inbox.com
Sat Oct 8 08:47:50 UTC 2016
From: Junyan He <junyan.he at intel.com>
Signed-off-by: Junyan He <junyan.he at intel.com>
---
src/CMakeLists.txt | 1 +
src/cl_utils.c | 36 ++++++++++++++++++++++++++++++++++++
src/cl_utils.h | 2 ++
3 files changed, 39 insertions(+)
create mode 100644 src/cl_utils.c
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 559380a..069a3c4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -90,6 +90,7 @@ set(OPENCL_SRC
cl_command_queue.h
cl_command_queue_gen7.c
cl_command_queue_enqueue.c
+ cl_utils.c
cl_driver.h
cl_driver.cpp
cl_driver_defs.c
diff --git a/src/cl_utils.c b/src/cl_utils.c
new file mode 100644
index 0000000..dd0f146
--- /dev/null
+++ b/src/cl_utils.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "cl_utils.h"
+#include <string.h>
+
+LOCAL cl_int
+cl_get_info_helper(void *src, size_t src_size, void *dst, size_t dst_size, size_t *ret_size)
+{
+ if (dst && dst_size < src_size)
+ return CL_INVALID_VALUE;
+
+ if (dst_size) {
+ memset(dst, 0, dst_size);
+ memcpy(dst, src, src_size);
+ }
+
+ if (ret_size)
+ *ret_size = src_size;
+ return CL_SUCCESS;
+}
diff --git a/src/cl_utils.h b/src/cl_utils.h
index 4af727e..b2fa6a6 100644
--- a/src/cl_utils.h
+++ b/src/cl_utils.h
@@ -19,6 +19,7 @@
#ifndef __CL_UTILS_H__
#define __CL_UTILS_H__
+#include "CL/cl.h"
/* INLINE is forceinline */
#define INLINE __attribute__((always_inline)) inline
@@ -450,4 +451,5 @@ static inline void list_splice_tail(struct list_head *list, struct list_head *he
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
+extern cl_int cl_get_info_helper(void *src, size_t src_size, void *dst, size_t dst_size, size_t *ret_size);
#endif /* __CL_UTILS_H__ */
--
2.7.4
More information about the Beignet
mailing list