--- OpenCL/OpenCL.pm 2011/11/20 22:29:36 1.23 +++ OpenCL/OpenCL.pm 2012/04/19 12:55:30 1.33 @@ -103,11 +103,11 @@ system. for my $platform (OpenCL::platforms) { - printf "platform: %s\n", $platform->info (OpenCL::PLATFORM_NAME); - printf "extensions: %s\n", $platform->info (OpenCL::PLATFORM_EXTENSIONS); + printf "platform: %s\n", $platform->name; + printf "extensions: %s\n", $platform->extensions; for my $device ($platform->devices) { - printf "+ device: %s\n", $device->info (OpenCL::DEVICE_NAME); - my $ctx = $device->context; + printf "+ device: %s\n", $device->name; + my $ctx = $platform->context (undef, [$device]); # do stuff } } @@ -151,8 +151,8 @@ functions. my $src = ' - __kernel void - squareit (__global float *input, __global float *output) + kernel void + squareit (global float *input, global float *output) { $id = get_global_id (0); output [id] = input [id] * input [id]; @@ -163,7 +163,7 @@ # build croaks on compile errors, so catch it and print the compile errors eval { $prog->build ($dev); 1 } - or die $prog->build_info ($dev, OpenCL::PROGRAM_BUILD_LOG); + or die $prog->build_log; my $kernel = $prog->kernel ("squareit"); @@ -288,9 +288,9 @@ =item $str = OpenCL::enum2str $enum -Converts most enum values (inof parameter names, image format constants, +Converts most enum values (of parameter names, image format constants, object types, addressing and filter modes, command types etc.) into a -human readbale string. When confronted with some random integer it can be +human readable string. When confronted with some random integer it can be very helpful to pass it through this function to maybe get some readable string out of it. @@ -328,7 +328,7 @@ L -=item $ctx = $device->context ($properties = undef, @$devices, $notify = undef) +=item $ctx = $platform->context ($properties = undef, @$devices, $notify = undef) Create a new OpenCL::Context object using the given device object(s)- a CL_CONTEXT_PLATFORM property is supplied automatically. @@ -350,23 +350,23 @@ =item $string = $platform->profile -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $platform->version -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $platform->name -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $platform->vendor -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $platform->extensions -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end platform @@ -386,267 +386,267 @@ =item $device_type = $device->type -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->vendor_id -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->max_compute_units -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->max_work_item_dimensions -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $device->max_work_group_size -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item @ints = $device->max_work_item_sizes -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->preferred_vector_width_char -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->preferred_vector_width_short -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->preferred_vector_width_int -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->preferred_vector_width_long -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->preferred_vector_width_float -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->preferred_vector_width_double -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->max_clock_frequency -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $bitfield = $device->address_bits -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->max_read_image_args -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->max_write_image_args -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ulong = $device->max_mem_alloc_size -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $device->image2d_max_width -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $device->image2d_max_height -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $device->image3d_max_width -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $device->image3d_max_height -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $device->image3d_max_depth -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->image_support -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $device->max_parameter_size -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->max_samplers -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->mem_base_addr_align -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->min_data_type_align_size -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $device_fp_config = $device->single_fp_config -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $device_mem_cache_type = $device->global_mem_cache_type -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->global_mem_cacheline_size -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ulong = $device->global_mem_cache_size -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ulong = $device->global_mem_size -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ulong = $device->max_constant_buffer_size -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->max_constant_args -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $device_local_mem_type = $device->local_mem_type -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ulong = $device->local_mem_size -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $boolean = $device->error_correction_support -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $device->profiling_timer_resolution -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $boolean = $device->endian_little -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $boolean = $device->available -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $boolean = $device->compiler_available -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $device_exec_capabilities = $device->execution_capabilities -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $command_queue_properties = $device->properties -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ = $device->platform -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $device->name -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $device->vendor -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $device->driver_version -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $device->profile -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $device->version -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $device->extensions -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->preferred_vector_width_half -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->native_vector_width_char -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->native_vector_width_short -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->native_vector_width_int -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->native_vector_width_long -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->native_vector_width_float -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->native_vector_width_double -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->native_vector_width_half -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $device_fp_config = $device->double_fp_config -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $device_fp_config = $device->half_fp_config -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $boolean = $device->host_unified_memory -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $device = $device->parent_device_ext -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item @device_partition_property_exts = $device->partition_types_ext -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item @device_partition_property_exts = $device->affinity_domains_ext -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $device->reference_count_ext -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item @device_partition_property_exts = $device->partition_style_ext -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end device @@ -670,26 +670,58 @@ =item $buf = $ctx->buffer ($flags, $len) -Creates a new OpenCL::Buffer object with the given flags and octet-size. +Creates a new OpenCL::Buffer (actually OpenCL::BufferObj) object with the +given flags and octet-size. L =item $buf = $ctx->buffer_sv ($flags, $data) -Creates a new OpenCL::Buffer object and initialise it with the given data values. +Creates a new OpenCL::Buffer (actually OpenCL::BufferObj) object and +initialise it with the given data values. =item $img = $ctx->image2d ($flags, $channel_order, $channel_type, $width, $height, $row_pitch = 0, $data = undef) -Creates a new OpenCL::Image2D object and optionally initialises it with the given data values. +Creates a new OpenCL::Image2D object and optionally initialises it with +the given data values. L =item $img = $ctx->image3d ($flags, $channel_order, $channel_type, $width, $height, $depth, $row_pitch = 0, $slice_pitch = 0, $data = undef) -Creates a new OpenCL::Image3D object and optionally initialises it with the given data values. +Creates a new OpenCL::Image3D object and optionally initialises it with +the given data values. L +=item $buffer = $ctx->gl_buffer ($flags, $bufobj) + +Creates a new OpenCL::Buffer (actually OpenCL::BufferObj) object that refers to the given +OpenGL buffer object. + +http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLBuffer.html + +=item $ctx->gl_texture2d ($flags, $target, $miplevel, $texture) + +Creates a new OpenCL::Image2D object that refers to the given OpenGL +2D texture object. + +http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLTexture2D.html + +=item $ctx->gl_texture3d ($flags, $target, $miplevel, $texture) + +Creates a new OpenCL::Image3D object that refers to the given OpenGL +3D texture object. + +http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLTexture3D.html + +=item $ctx->gl_renderbuffer ($flags, $renderbuffer) + +Creates a new OpenCL::Image2D object that refers to the given OpenGL +render buffer. + +http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLRenderbuffer.html + =item @formats = $ctx->supported_image_formats ($flags, $image_type) Returns a list of matching image formats - each format is an arrayref with @@ -719,19 +751,19 @@ =item $uint = $context->reference_count -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item @devices = $context->devices -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item @property_ints = $context->properties -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $context->num_devices -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end context @@ -773,23 +805,25 @@ L -=item $ev = $queue->enqueue_read_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) +=item $ev = $queue->enqueue_read_buffer_rect (OpenCL::Memory buf, cl_bool blocking, $buf_x, $buf_y, $buf_z, $host_x, $host_y, $host_z, $width, $height, $depth, $buf_row_pitch, $buf_slice_pitch, $host_row_pitch, $host_slice_pitch, $data, $wait_events...) -L +http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadBufferRect.html -=item $ev = $queue->enqueue_write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) +=item $ev = $queue->enqueue_write_buffer_rect (OpenCL::Memory buf, cl_bool blocking, $buf_x, $buf_y, $buf_z, $host_x, $host_y, $host_z, $width, $height, $depth, $buf_row_pitch, $buf_slice_pitch, $host_row_pitch, $host_slice_pitch, $data, $wait_events...) -L +http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html -=item $ev = $queue->enqueue_copy_buffer_rect ($src, $dst, $src_x, $src_y, $src_z, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $src_row_pitch, $src_slice_pitch, $dst_row_pitch, $dst_slice_pitch, $wait_event...) - -Yeah. +=item $ev = $queue->enqueue_read_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) L =item $ev = $queue->enqueue_copy_buffer_to_image ($src_buffer, $dst_image, $src_offset, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) -L. +L + +=item $ev = $queue->enqueue_write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) + +L =item $ev = $queue->enqueue_copy_image ($src_image, $dst_image, $src_x, $src_y, $src_z, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) @@ -799,6 +833,12 @@ L +=item $ev = $queue->enqueue_copy_buffer_rect ($src, $dst, $src_x, $src_y, $src_z, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $src_row_pitch, $src_slice_pitch, $dst_row_pitch, $dst_slice_pitch, $wait_event...) + +Yeah. + +L. + =item $ev = $queue->enqueue_task ($kernel, $wait_events...) L @@ -851,19 +891,19 @@ =item $ctx = $command_queue->context -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $device = $command_queue->device -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $command_queue->reference_count -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $command_queue_properties = $command_queue->properties -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end command_queue @@ -886,44 +926,67 @@ =item $mem_object_type = $mem->type -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $mem_flags = $mem->flags -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $mem->size -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ptr_value = $mem->host_ptr -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $mem->map_count -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $mem->reference_count -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ctx = $mem->context -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $mem = $mem->associated_memobject -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $mem->offset -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end mem =back +=head2 THE OpenCL::Buffer CLASS + +This is a subclass of OpenCL::Memory, and the superclass of +OpenCL::BufferObj. Its purpose is simply to distinguish between buffers +and sub-buffers. + +=head2 THE OpenCL::BufferObj CLASS + +This is a subclass of OpenCL::Buffer and thus OpenCL::Memory. It exists +because one cna create sub buffers of OpenLC::BufferObj objects, but not +sub buffers from these sub buffers. + +=over 4 + +=item $subbuf = $buf_obj->sub_buffer_region ($flags, $origin, $size) + +Creates an OpenCL::Buffer objects from this buffer and returns it. The +C is assumed to be C. + +L + +=back + =head2 THE OpenCL::Image CLASS This is the superclass of all image objects - OpenCL::Image2D and OpenCL::Image3D. @@ -943,27 +1006,27 @@ =item $int = $image->element_size -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $image->row_pitch -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $image->slice_pitch -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $image->width -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $image->height -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $image->depth -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end image @@ -983,23 +1046,23 @@ =item $uint = $sampler->reference_count -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ctx = $sampler->context -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $addressing_mode = $sampler->normalized_coords -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $filter_mode = $sampler->addressing_mode -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $boolean = $sampler->filter_mode -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end sampler @@ -1033,15 +1096,15 @@ =item $build_status = $program->build_status ($device) -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $program->build_options ($device) -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $program->build_log ($device) -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end program_build @@ -1055,27 +1118,27 @@ =item $uint = $program->reference_count -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ctx = $program->context -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $program->num_devices -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item @devices = $program->devices -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $string = $program->source -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item @ints = $program->binary_sizes -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end program @@ -1106,23 +1169,23 @@ =item $string = $kernel->function_name -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $kernel->num_args -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $kernel->reference_count -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ctx = $kernel->context -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $program = $kernel->program -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end kernel @@ -1139,23 +1202,23 @@ =item $int = $kernel->work_group_size ($device) -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item @ints = $kernel->compile_work_group_size ($device) -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ulong = $kernel->local_mem_size ($device) -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $int = $kernel->preferred_work_group_size_multiple ($device) -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ulong = $kernel->private_mem_size ($device) -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end kernel_work_group @@ -1199,23 +1262,23 @@ =item $queue = $event->command_queue -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $command_type = $event->command_type -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $event->reference_count -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $uint = $event->command_execution_status -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ctx = $event->context -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end event @@ -1232,19 +1295,19 @@ =item $ulong = $event->profiling_command_queued -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ulong = $event->profiling_command_submit -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ulong = $event->profiling_command_start -Calls C with C and returns the result(s). +Calls C with C and returns the result. =item $ulong = $event->profiling_command_end -Calls C with C and returns the result(s). +Calls C with C and returns the result. =for gengetinfo end profiling @@ -1269,18 +1332,20 @@ use common::sense; BEGIN { - our $VERSION = '0.55'; + our $VERSION = '0.92'; require XSLoader; XSLoader::load (__PACKAGE__, $VERSION); - @OpenCL::Buffer::ISA = - @OpenCL::Image::ISA = OpenCL::Memory::; + @OpenCL::Buffer::ISA = + @OpenCL::Image::ISA = OpenCL::Memory::; + + @OpenCL::BufferObj::ISA = OpenCL::Buffer::; - @OpenCL::Image2D::ISA = - @OpenCL::Image3D::ISA = OpenCL::Image::; + @OpenCL::Image2D::ISA = + @OpenCL::Image3D::ISA = OpenCL::Image::; - @OpenCL::UserEvent::ISA = OpenCL::Event::; + @OpenCL::UserEvent::ISA = OpenCL::Event::; } 1;