[Beignet] [PATCH OCL20 08/11] runtime: extension size not enough.
Xiuli Pan
xiuli.pan at intel.com
Wed Mar 2 03:02:01 UTC 2016
From: Luo Xionghu <xionghu.luo at intel.com>
define a MACRO to hold the value.
v2: use same MACRO in cl_extensions.h; add header file protection for
cl_extension.h.
Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang at intel.com>
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
src/cl_device_id.h | 5 ++++-
src/cl_extensions.c | 2 +-
src/cl_extensions.h | 6 +++++-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/cl_device_id.h b/src/cl_device_id.h
index fd75933..27ed5a5 100644
--- a/src/cl_device_id.h
+++ b/src/cl_device_id.h
@@ -20,6 +20,9 @@
#ifndef __CL_DEVICE_ID_H__
#define __CL_DEVICE_ID_H__
+#define EXTENSTION_LENGTH 512
+
+#include "cl_khr_icd.h"
/* Store complete information about the device */
struct _cl_device_id {
DEFINE_ICD(dispatch)
@@ -108,7 +111,7 @@ struct _cl_device_id {
const char *version;
const char *profile;
const char *opencl_c_version;
- const char extensions[256];
+ const char extensions[EXTENSTION_LENGTH];
const char *driver_version;
const char *spir_versions;
const char *built_in_kernels;
diff --git a/src/cl_extensions.c b/src/cl_extensions.c
index 3e714ac..ede4278 100644
--- a/src/cl_extensions.c
+++ b/src/cl_extensions.c
@@ -140,7 +140,7 @@ cl_intel_platform_enable_extension(cl_device_id device, uint32_t ext)
memcpy((char*)device->extensions, ext_str, strlen(ext_str));
device->extensions_sz = strlen(ext_str) + 1;
} else {
- assert(device->extensions_sz + 1 + strlen(ext_str) < 256);
+ assert(device->extensions_sz + 1 + strlen(ext_str) < EXTENSTION_LENGTH);
*(char*)(device->extensions + device->extensions_sz - 1) = ' ';
memcpy((char*)device->extensions + device->extensions_sz, ext_str, strlen(ext_str));
device->extensions_sz = device->extensions_sz + strlen(ext_str) + 1;
diff --git a/src/cl_extensions.h b/src/cl_extensions.h
index 0006651..c42d364 100644
--- a/src/cl_extensions.h
+++ b/src/cl_extensions.h
@@ -1,3 +1,5 @@
+#ifndef __CL_EXTENSIONS_H__
+#define __CL_EXTENSIONS_H__
/* The following approved Khronos extension
* names must be returned by all device that
* support OpenCL C 1.2. */
@@ -87,9 +89,10 @@ typedef union {
#undef DECL_EXT
} extension_union;
+#include "cl_device_id.h"
typedef struct cl_extensions {
extension_union extensions[cl_khr_extension_id_max];
- char ext_str[256];
+ char ext_str[EXTENSTION_LENGTH];
} cl_extensions_t;
extern void
@@ -98,3 +101,4 @@ extern void
cl_intel_platform_enable_extension(cl_device_id device, uint32_t name);
extern void
cl_intel_platform_get_default_extension(cl_device_id device);
+#endif /* __CL_EXTENSIONS_H__ */
--
2.5.0
More information about the Beignet
mailing list