c++ - for_each print data not correct -



c++ - for_each print data not correct -

i learning opencl, , trying write "hello world" example; create platform, device, , context.

now want device info device create , save info in vector print them. using clgetdeviceinfo.

the problem homecoming info phone call in different format , trying write print function print data, have problem when utilize for_each print data. can' print of info because can pass 1 type info print function, , print function prints info in same type only. remaining info prints incorrectly.

the homecoming info clgetdeviceinfo http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clgetdeviceinfo.html

template <typename t > void print (void *data ) { boost::any _t = static_cast<t> (data); cout << boost::any_cast<t> (_t) << endl << endl; } cl_device_info devinfo_list[] = { cl_device_type , cl_device_vendor_id , cl_device_max_compute_units , cl_device_max_work_item_dimensions , cl_device_max_work_item_sizes , cl_device_max_work_group_size , cl_device_preferred_vector_width_char , cl_device_preferred_vector_width_short, cl_device_preferred_vector_width_int , cl_device_preferred_vector_width_long, cl_device_preferred_vector_width_float, cl_device_preferred_vector_width_double, cl_device_preferred_vector_width_half, cl_device_native_vector_width_char , cl_device_native_vector_width_short, cl_device_native_vector_width_int, cl_device_native_vector_width_long, cl_device_native_vector_width_float, cl_device_native_vector_width_double, cl_device_native_vector_width_half, cl_device_max_clock_frequency , cl_device_address_bits , cl_device_max_mem_alloc_size , cl_device_image_support , cl_device_max_read_image_args , cl_device_max_write_image_args , cl_device_image2d_max_width , cl_device_image2d_max_height , cl_device_image3d_max_width , cl_device_image3d_max_height, cl_device_image3d_max_depth , cl_device_max_samplers , cl_device_max_parameter_size , cl_device_mem_base_addr_align , cl_device_min_data_type_align_size , cl_device_single_fp_config , cl_device_global_mem_cache_type , cl_device_global_mem_cacheline_size , cl_device_global_mem_cache_size , cl_device_global_mem_size , cl_device_max_constant_buffer_size , cl_device_max_constant_args, cl_device_local_mem_type , cl_device_local_mem_size , cl_device_error_correction_support , cl_device_profiling_timer_resolution , cl_device_endian_little , cl_device_available, cl_device_compiler_available, cl_device_execution_capabilities , cl_device_queue_properties , cl_device_name , cl_device_vendor , cl_driver_version , cl_device_profile , cl_device_version , cl_device_extensions , cl_device_platform , }; vector<void*> _data; size_t h = null ; ( unsigned int infos = 0 ; infos<arraysize(devinfo_list) ; infos++) { err = ::clgetdeviceinfo ( devices[0] ,devinfo_list[infos] ,null, null ,&h); if ( err == 0 ) { _data.resize ( _data.size() + 1 ); _data.at(_data.size() - 1) = alloca(h); } err = ::clgetdeviceinfo ( devices[0] ,devinfo_list[infos], h ,_data.at(_data.size() - 1),null); } for_each ( _data.begin() , _data.end() , print<char*>); // info char* print crrectly

i read documentation , function returns result within void* , must cast whatever type expecting. see have list of types returned different parameters.

i solve in way not have list of cl_device_info store types return, utilize info cast. if struct or 2-dimensional array you.

c++ opencl

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -