[Beignet] [PATCH] do not use const pointer
Guo Yejun
yejun.guo at intel.com
Mon Jul 18 01:04:16 UTC 2016
Signed-off-by: Guo Yejun <yejun.guo at intel.com>
---
utests/builtin_acos_asin.cpp | 8 ++++++--
utests/builtin_exp.cpp | 8 ++++++--
utests/builtin_pow.cpp | 7 ++++++-
utests/utest_generator.py | 8 ++++++--
4 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/utests/builtin_acos_asin.cpp b/utests/builtin_acos_asin.cpp
index 395460b..21fe461 100644
--- a/utests/builtin_acos_asin.cpp
+++ b/utests/builtin_acos_asin.cpp
@@ -10,7 +10,9 @@
printf("\033[0m");\
}
-const float input_data[] = {-30, -1, -0.92, -0.5, -0.09, 0, 0.09, 0.5, 0.92, 1, 30};
+namespace {
+
+float input_data[] = {-30, -1, -0.92, -0.5, -0.09, 0, 0.09, 0.5, 0.92, 1, 30};
const int count_input = sizeof(input_data) / sizeof(input_data[0]);
const int max_function = 5;
@@ -44,7 +46,8 @@ static void builtin_acos_asin(void)
locals[0] = 1;
clEnqueueWriteBuffer( queue, buf[1], CL_TRUE, 0, count_input * sizeof(float), input_data, 0, NULL, NULL);
- clEnqueueWriteBuffer( queue, buf[2], CL_TRUE, 0, sizeof(int), &max_function , 0, NULL, NULL);
+ int maxfunc = max_function;
+ clEnqueueWriteBuffer( queue, buf[2], CL_TRUE, 0, sizeof(int), &maxfunc, 0, NULL, NULL);
// Run the kernel
OCL_NDRANGE( 1 );
@@ -85,3 +88,4 @@ static void builtin_acos_asin(void)
}
MAKE_UTEST_FROM_FUNCTION(builtin_acos_asin)
+}
diff --git a/utests/builtin_exp.cpp b/utests/builtin_exp.cpp
index 6d51c33..2c214bd 100644
--- a/utests/builtin_exp.cpp
+++ b/utests/builtin_exp.cpp
@@ -15,7 +15,9 @@
printf("\033[0m");\
}
-const float input_data[] = {FLT_MAX, -FLT_MAX, FLT_MIN, -FLT_MIN, 80, -80, 3.14, -3.14, -0.5, 0.5, 1, -1, 0.0 };
+namespace{
+
+float input_data[] = {FLT_MAX, -FLT_MAX, FLT_MIN, -FLT_MIN, 80, -80, 3.14, -3.14, -0.5, 0.5, 1, -1, 0.0 };
const int count_input = sizeof(input_data) / sizeof(input_data[0]);
const int max_function = 5;
@@ -51,7 +53,8 @@ static void builtin_exp(void)
locals[0] = 1;
clEnqueueWriteBuffer( queue, buf[1], CL_TRUE, 0, count_input * sizeof(float), input_data, 0, NULL, NULL);
- clEnqueueWriteBuffer( queue, buf[2], CL_TRUE, 0, sizeof(int), &max_function , 0, NULL, NULL);
+ int maxfunc = max_function;
+ clEnqueueWriteBuffer( queue, buf[2], CL_TRUE, 0, sizeof(int), &maxfunc, 0, NULL, NULL);
// Run the kernel
OCL_NDRANGE( 1 );
@@ -100,3 +103,4 @@ static void builtin_exp(void)
}
MAKE_UTEST_FROM_FUNCTION(builtin_exp)
+}
diff --git a/utests/builtin_pow.cpp b/utests/builtin_pow.cpp
index 21fa895..1f6af0e 100644
--- a/utests/builtin_pow.cpp
+++ b/utests/builtin_pow.cpp
@@ -10,6 +10,9 @@
printf( __VA_ARGS__ );\
printf("\033[0m");\
}
+
+namespace {
+
const float ori_data[] = {-20.5, -1, -0.9, -0.01, 0, 0.01, 0.9, 1.0, 20.5};
const int count_input_ori = sizeof(ori_data) / sizeof(ori_data[0]);
const int count_input = count_input_ori * count_input_ori;
@@ -59,7 +62,8 @@ static void builtin_pow(void)
clEnqueueWriteBuffer( queue, buf[1], CL_TRUE, 0, count_input * sizeof(float), input_data1, 0, NULL, NULL);
clEnqueueWriteBuffer( queue, buf[2], CL_TRUE, 0, count_input * sizeof(float), input_data2, 0, NULL, NULL);
- clEnqueueWriteBuffer( queue, buf[3], CL_TRUE, 0, sizeof(int), &max_function, 0, NULL, NULL);
+ int maxfunc = max_function;
+ clEnqueueWriteBuffer( queue, buf[3], CL_TRUE, 0, sizeof(int), &maxfunc, 0, NULL, NULL);
// Run the kernel
OCL_NDRANGE( 1 );
@@ -100,3 +104,4 @@ static void builtin_pow(void)
}
MAKE_UTEST_FROM_FUNCTION(builtin_pow)
+}
diff --git a/utests/utest_generator.py b/utests/utest_generator.py
index bcb9ac4..2c02ad6 100644
--- a/utests/utest_generator.py
+++ b/utests/utest_generator.py
@@ -280,9 +280,9 @@ which can print more values and information to assist debuging the issue.
vals = vals[0:128]
break
vals += self.values[i]
- self.cpplines += [ "const %s input_data%d[] = {%s};" %(self.argtype(i,index),i+1,str(vals).strip('[]').replace('\'','')) ]
+ self.cpplines += [ "%s input_data%d[] = {%s};" %(self.argtype(i,index),i+1,str(vals).strip('[]').replace('\'','')) ]
self.cpplines += [ "const int count_input = sizeof(input_data1) / sizeof(input_data1[0]);" ]
- self.cpplines += [ "const int vector = %s;\n"%(vlen) ]
+ self.cpplines += [ "int vector = %s;\n"%(vlen) ]
#####Cpu Function
def GenCpuCompilerMath(self,index):
@@ -457,6 +457,8 @@ static void %s_%s(void)
#The head:
self.cpplines += [self.Head]
+ self.cpplines += ["namespace {\n"]
+
#Parameters:
self.GenInputValues(i)
@@ -469,6 +471,8 @@ static void %s_%s(void)
#utest function
self.utestFunc(i)
+ self.cpplines += ["}\n"]
+
#kernel cl
self.genCL(i)
--
1.9.1
More information about the Beignet
mailing list