[Beignet] [PATCH] fix utest build for some old gcc version

Zhigang Gong zhigang.gong at linux.intel.com
Tue Jan 6 16:38:12 PST 2015


LGTM, just pushed, thanks.

On Wed, Dec 31, 2014 at 01:12:26PM +0800, Guo Yejun wrote:
> 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 at intel.com>
> ---
>  utests/compiler_displacement_map_element.cpp |  4 +--
>  utests/compiler_saturate.cpp                 |  2 +-
>  utests/compiler_saturate_sub.cpp             |  2 +-
>  utests/get_cl_info.cpp                       | 40 ++++++++++++++--------------
>  utests/vload_bench.cpp                       |  4 +--
>  5 files changed, 26 insertions(+), 26 deletions(-)
> 
> diff --git a/utests/compiler_displacement_map_element.cpp b/utests/compiler_displacement_map_element.cpp
> index 98041ec..f031d99 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 6880df0..97420db 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 1c95e2d..5c57625 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 807739b..e2dc0d7 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 3765996..a7703fc 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;
>    }
> -- 
> 1.9.1
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list