From 3fd8a77b86af564eb442d5526b78119c8548631f Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Fri, 7 Jan 2011 09:22:48 +0100 Subject: [PATCH] Properly implement Program::getInfo (BZ 254) --- cl.hpp | 35 ++++++++++++++++++++++++++--------- 1 files changed, 26 insertions(+), 9 deletions(-) diff --git a/cl.hpp b/cl.hpp index 99b86a6..0112819 100755 --- a/cl.hpp +++ b/cl.hpp @@ -425,6 +425,9 @@ typedef cl::string STRING_CLASS; #define __MAX_DEFAULT_VECTOR_SIZE 10 #endif +typedef VECTOR_CLASS Sources; +typedef VECTOR_CLASS > Binaries; + /*! \class vector * \brief Fixed sized vector implementation that mirroring * std::vector functionality. @@ -720,17 +723,31 @@ struct GetInfoHelper > // Specialized for getInfo template -struct GetInfoHelper > +struct GetInfoHelper { static cl_int - get(Func f, cl_uint name, VECTOR_CLASS* param) + get(Func f, cl_uint name, Binaries* param) { - cl_uint err = f(name, param->size() * sizeof(char *), &(*param)[0], NULL); - if (err != CL_SUCCESS) { - return err; - } - - return CL_SUCCESS; + VECTOR_CLASS< ::size_t> sizes; + cl_int err = GetInfoHelper >::get(f, CL_PROGRAM_BINARY_SIZES, &sizes); + if (err != CL_SUCCESS) { + return err; + } + + param->resize(sizes.size()); + + VECTOR_CLASS values(param->size()); + for (::size_t i = 0; isize(); ++i) { + (*param)[i].resize(sizes[i]); + values[i]=&(*param)[i].front(); + } + + err = f(name, values.size() * sizeof(unsigned char *), &values[0], NULL); + if (err != CL_SUCCESS) { + return err; + } + + return CL_SUCCESS; } }; @@ -875,7 +892,7 @@ struct GetInfoHelper \ F(cl_program_info, CL_PROGRAM_DEVICES, VECTOR_CLASS) \ F(cl_program_info, CL_PROGRAM_SOURCE, STRING_CLASS) \ F(cl_program_info, CL_PROGRAM_BINARY_SIZES, VECTOR_CLASS< ::size_t>) \ - F(cl_program_info, CL_PROGRAM_BINARIES, VECTOR_CLASS) \ + F(cl_program_info, CL_PROGRAM_BINARIES, Binaries) \ \ F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \ F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, STRING_CLASS) \ -- 1.7.3.1.msysgit.0