summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuo Yejun <yejun.guo@intel.com>2014-12-31 13:12:26 +0800
committerZhigang Gong <zhigang.gong@intel.com>2015-01-06 17:55:07 +0800
commitf37867b45ca91be23f04135bb6dc0e4346d19da7 (patch)
tree965d53d5fd3d71b573868c1058920703485289bf
parentcf437cdd4164c69412b8ff9bc00018499c007e73 (diff)
fix utest build for some old gcc version
change the keyword from constexpr to const, update the code for explicit type conversion and std::map's iterator. Signed-off-by: Guo Yejun <yejun.guo@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r--utests/compiler_displacement_map_element.cpp4
-rw-r--r--utests/compiler_saturate.cpp2
-rw-r--r--utests/compiler_saturate_sub.cpp2
-rw-r--r--utests/get_cl_info.cpp40
-rw-r--r--utests/vload_bench.cpp4
5 files changed, 26 insertions, 26 deletions
diff --git a/utests/compiler_displacement_map_element.cpp b/utests/compiler_displacement_map_element.cpp
index 98041ec4..f031d99f 100644
--- a/utests/compiler_displacement_map_element.cpp
+++ b/utests/compiler_displacement_map_element.cpp
@@ -1,8 +1,8 @@
#include "utest_helper.hpp"
typedef unsigned int uint;
-constexpr int W = 16, H = 16;
-constexpr int SIZE = W * H;
+const int W = 16, H = 16;
+const int SIZE = W * H;
uint in_1[SIZE];
uint disp_map[SIZE];
uint out_1[SIZE];
diff --git a/utests/compiler_saturate.cpp b/utests/compiler_saturate.cpp
index 6880df01..97420db6 100644
--- a/utests/compiler_saturate.cpp
+++ b/utests/compiler_saturate.cpp
@@ -2,7 +2,7 @@
namespace {
-constexpr int n = 16;
+const int n = 16;
// declaration only, we should create each template specification for each type.
template<typename T>
diff --git a/utests/compiler_saturate_sub.cpp b/utests/compiler_saturate_sub.cpp
index 1c95e2d0..5c576251 100644
--- a/utests/compiler_saturate_sub.cpp
+++ b/utests/compiler_saturate_sub.cpp
@@ -2,7 +2,7 @@
namespace {
-constexpr int n = 16;
+const int n = 16;
// declaration only, we should create each template specification for each type.
template<typename T>
diff --git a/utests/get_cl_info.cpp b/utests/get_cl_info.cpp
index 807739b0..e2dc0d77 100644
--- a/utests/get_cl_info.cpp
+++ b/utests/get_cl_info.cpp
@@ -160,8 +160,8 @@ Info_Result<T>* cast_as(void *info)
cl_int ret; \
size_t ret_size; \
\
- Info_Result<TYPE>* info = cast_as<TYPE>(x.second); \
- ret = FUNC (__VA_ARGS__, x.first, \
+ Info_Result<TYPE>* info = cast_as<TYPE>(x->second); \
+ ret = FUNC (__VA_ARGS__, x->first, \
info->size, info->get_ret(), &ret_size); \
OCL_ASSERT((!ret)); \
OCL_ASSERT((info->check_result())); \
@@ -221,8 +221,8 @@ void get_program_info(void)
maps.insert(make_pair(CL_PROGRAM_BINARIES,
(void *)(new Info_Result<char **>(&expect_source, &sz, 1))));
- std::for_each(maps.begin(), maps.end(), [](pair<cl_program_info, void *> x) {
- switch (x.first) {
+ for (map<cl_program_info, void *>::iterator x = maps.begin(); x != maps.end(); ++x) {
+ switch (x->first) {
case CL_PROGRAM_REFERENCE_COUNT:
case CL_PROGRAM_NUM_DEVICES:
CALL_PROGINFO_AND_RET(cl_uint);
@@ -245,7 +245,7 @@ void get_program_info(void)
default:
break;
}
- });
+ }
}
MAKE_UTEST_FROM_FUNCTION(get_program_info);
@@ -296,8 +296,8 @@ void get_queue_info(void)
(void *)(new Info_Result<cl_command_queue_properties>(
((cl_command_queue_properties)prop)))));
- std::for_each(maps.begin(), maps.end(), [](pair<cl_program_info, void *> x) {
- switch (x.first) {
+ for (map<cl_program_info, void *>::iterator x = maps.begin(); x != maps.end(); ++x) {
+ switch (x->first) {
case CL_QUEUE_CONTEXT:
CALL_QUEUEINFO_AND_RET(cl_context);
break;
@@ -313,7 +313,7 @@ void get_queue_info(void)
default:
break;
}
- });
+ }
}
MAKE_UTEST_FROM_FUNCTION(get_queue_info);
@@ -345,8 +345,8 @@ void get_program_build_info(void)
maps.insert(make_pair(CL_PROGRAM_BUILD_LOG, /* not supported now, just "" */
(void *)(new Info_Result<char *>(log, sz))));
- std::for_each(maps.begin(), maps.end(), [](pair<cl_program_info, void *> x) {
- switch (x.first) {
+ for (map<cl_program_info, void *>::iterator x = maps.begin(); x != maps.end(); ++x) {
+ switch (x->first) {
case CL_PROGRAM_BUILD_STATUS:
CALL_PROG_BUILD_INFO_AND_RET(cl_build_status);
break;
@@ -359,7 +359,7 @@ void get_program_build_info(void)
default:
break;
}
- });
+ }
}
MAKE_UTEST_FROM_FUNCTION(get_program_build_info);
@@ -409,8 +409,8 @@ void get_context_info(void)
(void *)(new Info_Result<char*>(
(const char*)NULL, 100*sizeof(cl_context_properties)))));
- std::for_each(maps.begin(), maps.end(), [](pair<cl_context_info, void *> x) {
- switch (x.first) {
+ for (map<cl_program_info, void *>::iterator x = maps.begin(); x != maps.end(); ++x) {
+ switch (x->first) {
case CL_CONTEXT_NUM_DEVICES:
CALL_CONTEXTINFO_AND_RET(cl_uint);
break;
@@ -426,7 +426,7 @@ void get_context_info(void)
default:
break;
}
- });
+ }
}
MAKE_UTEST_FROM_FUNCTION(get_context_info);
@@ -469,8 +469,8 @@ void get_kernel_info(void)
maps.insert(make_pair(CL_KERNEL_FUNCTION_NAME,
(void *)(new Info_Result<char*>(expected_name, strlen(expected_name)+1))));
- std::for_each(maps.begin(), maps.end(), [](pair<cl_kernel_info, void *> x) {
- switch (x.first) {
+ for (map<cl_program_info, void *>::iterator x = maps.begin(); x != maps.end(); ++x) {
+ switch (x->first) {
case CL_KERNEL_PROGRAM:
CALL_KERNELINFO_AND_RET(cl_program);
break;
@@ -489,7 +489,7 @@ void get_kernel_info(void)
default:
break;
}
- });
+ }
}
MAKE_UTEST_FROM_FUNCTION(get_kernel_info);
@@ -600,8 +600,8 @@ void get_mem_info(void)
maps.insert(make_pair(CL_MEM_OFFSET,
(void *)(new Info_Result<size_t>(((size_t)expect_ref)))));
- std::for_each(maps.begin(), maps.end(), [](pair<cl_mem_info, void *> x) {
- switch (x.first) {
+ for (map<cl_program_info, void *>::iterator x = maps.begin(); x != maps.end(); ++x) {
+ switch (x->first) {
case CL_MEM_TYPE:
CALL_GETMEMINFO_AND_RET(cl_mem_object_type);
break;
@@ -633,7 +633,7 @@ void get_mem_info(void)
default:
break;
}
- });
+ }
clEnqueueUnmapMemObject(queue, buf[0], map_ptr, 0, NULL, NULL);
}
diff --git a/utests/vload_bench.cpp b/utests/vload_bench.cpp
index 37659961..a7703fcd 100644
--- a/utests/vload_bench.cpp
+++ b/utests/vload_bench.cpp
@@ -11,7 +11,7 @@ static double vload_bench(const char *kernelFunc, uint32_t N, uint32_t offset, b
struct timeval start, end;
// Setup kernel and buffers
- std::string kernelName = kernelFunc + std::to_string(N);
+ std::string kernelName = kernelFunc + std::to_string((long long unsigned int)N);
OCL_CALL (cl_kernel_init, "vload_bench.cl", kernelName.c_str(), SOURCE, NULL);
//OCL_CREATE_KERNEL("compiler_array");
buf_data[0] = (T*) malloc(sizeof(T) * n);
@@ -42,7 +42,7 @@ static double vload_bench(const char *kernelFunc, uint32_t N, uint32_t offset, b
OCL_MAP_BUFFER(0);
OCL_MAP_BUFFER(1);
for (uint32_t i = 0; i < globals[0]; ++i) {
- OCL_ASSERT(((T*)buf_data[0])[i + offset] == ((uint32_t*)buf_data[1])[i]);
+ OCL_ASSERT((uint32_t)(((T*)buf_data[0])[i + offset]) == ((uint32_t*)buf_data[1])[i]);
}
return 0;
}