44 this->
V.
width =
static_cast<unsigned int>(num_points);
87 this->kd_tree_values->elements, 0,
NULL,
NULL);
90 this->kd_tree_splits->elements, 0,
NULL,
NULL);
92 if(
m_ret != CL_SUCCESS)
99 unsigned int warpSize = 32;
104 size_t local_item_size =
static_cast<size_t>(warpSize);
105 size_t global_item_size =
static_cast<size_t>(threadsPerBlock);
125 if(
m_ret != CL_SUCCESS)
133 &global_item_size, &local_item_size, 0,
NULL,
NULL);
136 if(
m_ret != CL_SUCCESS)
142 this->m_distances.elements, 0,
NULL,
NULL);
144 if(
m_ret != CL_SUCCESS)
163 std::cout <<
"sum " << sum <<
"sq_sum " << sq_sum << std::endl;
229 if(
m_ret != CL_SUCCESS)
233 if(
m_ret != CL_SUCCESS)
265 if(
m_ret != CL_SUCCESS)
267 std::cerr <<
"ClSOR::loadKernel() - Create Program " <<
getErrorString(
m_ret) << std::endl;
272 printf(
"Error: Failed to create compute program!\n");
279 if (
m_ret != CL_SUCCESS)
284 printf(
"Error: Failed to build program executable!\n");
287 printf(
"%s\n", buffer);
293 if(
m_ret != CL_SUCCESS)
305 case 0:
return "CL_SUCCESS";
306 case -1:
return "CL_DEVICE_NOT_FOUND";
307 case -2:
return "CL_DEVICE_NOT_AVAILABLE";
308 case -3:
return "CL_COMPILER_NOT_AVAILABLE";
309 case -4:
return "CL_MEM_OBJECT_ALLOCATION_FAILURE";
310 case -5:
return "CL_OUT_OF_RESOURCES";
311 case -6:
return "CL_OUT_OF_HOST_MEMORY";
312 case -7:
return "CL_PROFILING_INFO_NOT_AVAILABLE";
313 case -8:
return "CL_MEM_COPY_OVERLAP";
314 case -9:
return "CL_IMAGE_FORMAT_MISMATCH";
315 case -10:
return "CL_IMAGE_FORMAT_NOT_SUPPORTED";
316 case -11:
return "CL_BUILD_PROGRAM_FAILURE";
317 case -12:
return "CL_MAP_FAILURE";
318 case -13:
return "CL_MISALIGNED_SUB_BUFFER_OFFSET";
319 case -14:
return "CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST";
320 case -15:
return "CL_COMPILE_PROGRAM_FAILURE";
321 case -16:
return "CL_LINKER_NOT_AVAILABLE";
322 case -17:
return "CL_LINK_PROGRAM_FAILURE";
323 case -18:
return "CL_DEVICE_PARTITION_FAILED";
324 case -19:
return "CL_KERNEL_ARG_INFO_NOT_AVAILABLE";
327 case -30:
return "CL_INVALID_VALUE";
328 case -31:
return "CL_INVALID_DEVICE_TYPE";
329 case -32:
return "CL_INVALID_PLATFORM";
330 case -33:
return "CL_INVALID_DEVICE";
331 case -34:
return "CL_INVALID_CONTEXT";
332 case -35:
return "CL_INVALID_QUEUE_PROPERTIES";
333 case -36:
return "CL_INVALID_COMMAND_QUEUE";
334 case -37:
return "CL_INVALID_HOST_PTR";
335 case -38:
return "CL_INVALID_MEM_OBJECT";
336 case -39:
return "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR";
337 case -40:
return "CL_INVALID_IMAGE_SIZE";
338 case -41:
return "CL_INVALID_SAMPLER";
339 case -42:
return "CL_INVALID_BINARY";
340 case -43:
return "CL_INVALID_BUILD_OPTIONS";
341 case -44:
return "CL_INVALID_PROGRAM";
342 case -45:
return "CL_INVALID_PROGRAM_EXECUTABLE";
343 case -46:
return "CL_INVALID_KERNEL_NAME";
344 case -47:
return "CL_INVALID_KERNEL_DEFINITION";
345 case -48:
return "CL_INVALID_KERNEL";
346 case -49:
return "CL_INVALID_ARG_INDEX";
347 case -50:
return "CL_INVALID_ARG_VALUE";
348 case -51:
return "CL_INVALID_ARG_SIZE";
349 case -52:
return "CL_INVALID_KERNEL_ARGS";
350 case -53:
return "CL_INVALID_WORK_DIMENSION";
351 case -54:
return "CL_INVALID_WORK_GROUP_SIZE";
352 case -55:
return "CL_INVALID_WORK_ITEM_SIZE";
353 case -56:
return "CL_INVALID_GLOBAL_OFFSET";
354 case -57:
return "CL_INVALID_EVENT_WAIT_LIST";
355 case -58:
return "CL_INVALID_EVENT";
356 case -59:
return "CL_INVALID_OPERATION";
357 case -60:
return "CL_INVALID_GL_OBJECT";
358 case -61:
return "CL_INVALID_BUFFER_SIZE";
359 case -62:
return "CL_INVALID_MIP_LEVEL";
360 case -63:
return "CL_INVALID_GLOBAL_WORK_SIZE";
361 case -64:
return "CL_INVALID_PROPERTY";
362 case -65:
return "CL_INVALID_IMAGE_DESCRIPTOR";
363 case -66:
return "CL_INVALID_COMPILER_OPTIONS";
364 case -67:
return "CL_INVALID_LINKER_OPTIONS";
365 case -68:
return "CL_INVALID_DEVICE_PARTITION_COUNT";
368 case -1000:
return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR";
369 case -1001:
return "CL_PLATFORM_NOT_FOUND_KHR";
370 case -1002:
return "CL_INVALID_D3D10_DEVICE_KHR";
371 case -1003:
return "CL_INVALID_D3D10_RESOURCE_KHR";
372 case -1004:
return "CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR";
373 case -1005:
return "CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR";
374 default:
return "Unknown OpenCL error";
384 cl_uint num_platforms;
387 if(platform_id >= num_platforms)
389 std::cerr <<
"Wrong platform id " << std::endl;
393 cl_platform_id* platforms = (cl_platform_id*)malloc(
sizeof(cl_platform_id) * num_platforms);
396 cl_platform_id platform = platforms[platform_id];
399 checkOclErrors(clGetPlatformInfo(platform, CL_PLATFORM_NAME,
sizeof(buffer), buffer,
NULL));
401 checkOclErrors(clGetPlatformInfo(platform, CL_PLATFORM_VENDOR,
sizeof(buffer), buffer,
NULL));
403 checkOclErrors(clGetPlatformInfo(platform, CL_PLATFORM_VERSION,
sizeof(buffer), buffer,
NULL));
405 checkOclErrors(clGetPlatformInfo(platform, CL_PLATFORM_PROFILE,
sizeof(buffer), buffer,
NULL));
407 checkOclErrors(clGetPlatformInfo(platform, CL_PLATFORM_EXTENSIONS,
sizeof(buffer), buffer,
NULL));
414 if(device_id >= num_devices)
416 std::cerr <<
"Wrong device id " << std::endl;
420 cl_device_id* devices = (cl_device_id*)malloc(
sizeof(cl_device_id) * num_devices);
421 checkOclErrors(clGetDeviceIDs(platform, CL_DEVICE_TYPE_ALL, num_devices, devices,
NULL));
423 cl_device_id device = devices[device_id];
433 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_NAME,
sizeof(buffer), buffer,
NULL));
437 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_VENDOR,
sizeof(buffer), buffer,
NULL));
440 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_VENDOR_ID,
sizeof(vendor_id), &vendor_id,
NULL));
442 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_VERSION,
sizeof(buffer), buffer,
NULL));
444 checkOclErrors(clGetDeviceInfo(device, CL_DRIVER_VERSION,
sizeof(buffer), buffer,
NULL));
446 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_OPENCL_C_VERSION,
sizeof(buffer), buffer,
NULL));
448 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_PROFILE,
sizeof(buffer), buffer,
NULL));
450 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS,
sizeof(buffer), buffer,
NULL));
452 cl_uint max_compute_units;
453 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS,
454 sizeof(max_compute_units), &max_compute_units,
NULL));
455 this->
m_mps = max_compute_units;
458 cl_uint max_work_item_dimensions;
459 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,
460 sizeof(max_work_item_dimensions), &max_work_item_dimensions,
NULL));
462 size_t* max_work_item_sizes = (
size_t*)malloc(
sizeof(
size_t) * max_work_item_dimensions);
463 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES,
464 sizeof(
size_t) * max_work_item_dimensions, max_work_item_sizes,
NULL));
466 free(max_work_item_sizes);
467 size_t max_work_group_size;
468 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE,
469 sizeof(max_work_group_size), &max_work_group_size,
NULL));
476 cl_uint preferred_vector_width_char;
477 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR,
478 sizeof(preferred_vector_width_char), &preferred_vector_width_char,
NULL));
480 cl_uint preferred_vector_width_short;
481 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT,
482 sizeof(preferred_vector_width_short), &preferred_vector_width_short,
NULL));
484 cl_uint preferred_vector_width_int;
485 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT,
486 sizeof(preferred_vector_width_int), &preferred_vector_width_int,
NULL));
488 cl_uint preferred_vector_width_long;
489 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG,
490 sizeof(preferred_vector_width_long), &preferred_vector_width_long,
NULL));
492 cl_uint preferred_vector_width_float;
493 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT,
494 sizeof(preferred_vector_width_float), &preferred_vector_width_float,
NULL));
496 cl_uint preferred_vector_width_double;
497 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE,
498 sizeof(preferred_vector_width_double), &preferred_vector_width_double,
NULL));
500 cl_uint preferred_vector_width_half;
501 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF,
502 sizeof(preferred_vector_width_half), &preferred_vector_width_half,
NULL));
504 cl_uint native_vector_width_char;
505 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR,
506 sizeof(native_vector_width_char), &native_vector_width_char,
NULL));
508 cl_uint native_vector_width_short;
509 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT,
510 sizeof(native_vector_width_short), &native_vector_width_short,
NULL));
512 cl_uint native_vector_width_int;
513 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT,
514 sizeof(native_vector_width_int), &native_vector_width_int,
NULL));
516 cl_uint native_vector_width_long;
517 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG,
518 sizeof(native_vector_width_long), &native_vector_width_long,
NULL));
520 cl_uint native_vector_width_float;
521 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT,
522 sizeof(native_vector_width_float), &native_vector_width_float,
NULL));
524 cl_uint native_vector_width_double;
525 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE,
526 sizeof(native_vector_width_double), &native_vector_width_double,
NULL));
528 cl_uint native_vector_width_half;
529 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF,
530 sizeof(native_vector_width_half), &native_vector_width_half,
NULL));
532 cl_uint max_clock_frequency;
533 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_MAX_CLOCK_FREQUENCY,
534 sizeof(max_clock_frequency), &max_clock_frequency,
NULL));
536 cl_uint address_bits;
538 sizeof(address_bits), &address_bits,
NULL));
540 cl_ulong max_mem_alloc_size;
541 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE,
542 sizeof(max_mem_alloc_size), &max_mem_alloc_size,
NULL));
543 cl_bool image_support;
544 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT,
sizeof(image_support),
545 &image_support,
NULL));
547 size_t max_parameter_size;
548 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_MAX_PARAMETER_SIZE,
549 sizeof(max_parameter_size), &max_parameter_size,
NULL));
551 cl_device_mem_cache_type global_mem_cache_type;
552 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE,
553 sizeof(global_mem_cache_type), &global_mem_cache_type,
NULL));
554 cl_uint global_mem_cacheline_size;
555 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE,
556 sizeof(global_mem_cacheline_size), &global_mem_cacheline_size,
NULL));
557 cl_ulong global_mem_cache_size;
558 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE,
559 sizeof(global_mem_cache_size), &global_mem_cache_size,
NULL));
560 cl_ulong global_mem_size;
562 sizeof(global_mem_size), &global_mem_size,
NULL));
565 cl_ulong max_constant_buffer_size;
566 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE,
567 sizeof(max_constant_buffer_size), &max_constant_buffer_size,
NULL));
568 cl_uint max_constant_args;
569 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_MAX_CONSTANT_ARGS,
sizeof(max_constant_args),
570 &max_constant_args,
NULL));
572 cl_device_local_mem_type local_mem_type;
573 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_TYPE,
sizeof(local_mem_type),
574 &local_mem_type,
NULL));
578 cl_ulong local_mem_size;
579 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_SIZE,
sizeof(local_mem_size),
580 &local_mem_size,
NULL));
582 cl_bool error_correction_support;
583 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_ERROR_CORRECTION_SUPPORT,
584 sizeof(error_correction_support), &error_correction_support,
NULL));
586 cl_bool host_unified_memory;
587 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_HOST_UNIFIED_MEMORY,
588 sizeof(host_unified_memory), &host_unified_memory,
NULL));
590 size_t profiling_timer_resolution;
591 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_PROFILING_TIMER_RESOLUTION,
592 sizeof(profiling_timer_resolution), &profiling_timer_resolution,
NULL));
594 cl_bool endian_little;
595 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_ENDIAN_LITTLE,
sizeof(endian_little),
596 &endian_little,
NULL));
599 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_AVAILABLE,
sizeof(available), &available,
NULL));
601 cl_bool compier_available;
602 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_COMPILER_AVAILABLE,
603 sizeof(compier_available), &compier_available,
NULL));
605 cl_bool linker_available;
606 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_LINKER_AVAILABLE,
sizeof(linker_available),
607 &linker_available,
NULL));
609 cl_device_exec_capabilities exec_capabilities;
610 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_EXECUTION_CAPABILITIES,
611 sizeof(exec_capabilities), &exec_capabilities,
NULL));
612 cl_command_queue_properties queue_properties;
613 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(queue_properties),
614 &queue_properties,
NULL));
615 size_t printf_buffer_size;
616 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_PRINTF_BUFFER_SIZE,
617 sizeof(printf_buffer_size), &printf_buffer_size,
NULL));
618 cl_bool preferred_interop_user_sync;
619 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC,
620 sizeof(preferred_interop_user_sync), &preferred_interop_user_sync,
NULL));
624 cl_uint reference_count;
625 checkOclErrors(clGetDeviceInfo(device, CL_DEVICE_REFERENCE_COUNT,
sizeof(reference_count),
626 &reference_count,
NULL));
static int getNumThreads()
Returns the number of supported threads (or 1 if OpenMP is not supported)
ClSOR(floatArr &points, size_t num_points, int k, int device=0)
cl_uint m_threads_per_block
const char * getErrorString(cl_int error)
LBPointArray< unsigned char > * kd_tree_splits
void initKdTree()
PRIVATE ///.
cl_command_queue m_command_queue
void setK(int k)
Set the number of k nearest neighbors k-neighborhood.
cl_platform_id m_platform_id
void getDeviceInformation(int platform_id=0, int device_id=0)
boost::shared_array< unsigned int > indexArray
boost::shared_array< float > floatArr
int getInliers(lvr2::indexArray &inliers)
cl_ulong m_device_global_memory
const char * SOR_KERNEL_STRING
static void generatePointArray(LBPointArray< T > &m, int width, int dim)
KF_EXPORTS void error(const char *error_string, const char *file, const int line, const char *func="")
Error handler. All GPU functions from this subsystem call the function to report an error...
boost::shared_ptr< LBKdTree > kd_tree_gen
LBPointArray< float > m_distances
The LBKdTree class implements a left-balanced array-based index kd-tree. Left-Balanced: minimum memor...
#define checkOclErrors(err)
LBPointArray< float > * kd_tree_values