Class: OpenCL::Event

Inherits:
FFI::ManagedStruct
  • Object
show all
Defined in:
lib/opencl_ruby_ffi/Event.rb,
lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb

Overview

Maps the cl_event object

Constant Summary collapse

COMMAND_QUEUE =

:stopdoc:

0x11D0
COMMAND_TYPE =
0x11D1
REFERENCE_COUNT =
0x11D2
COMMAND_EXECUTION_STATUS =
0x11D3
CONTEXT =
0x11D4

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr, retain = true) ⇒ Event

Creates a new Event and retains it if specified and aplicable



1569
1570
1571
1572
1573
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 1569

def initialize(ptr, retain = true)
  super(ptr)
  OpenCL.clRetainEvent(ptr) if retain
  #STDERR.puts "Allocating Event: #{ptr}"
end

Class Method Details

.release(ptr) ⇒ Object

method called at Event deletion, releases the object if aplicable



1584
1585
1586
1587
1588
1589
1590
1591
1592
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 1584

def self.release(ptr)
  #STDERR.puts "Releasing Event: #{ptr}"
  #ref_count = FFI::MemoryPointer::new( :cl_uint ) 
  #OpenCL.clGetEventInfo(ptr, OpenCL::Event::REFERENCE_COUNT, ref_count.size, ref_count, nil)
  #STDERR.puts "reference counter: #{ref_count.read_cl_uint}"
  error = OpenCL.clReleaseEvent(ptr)
  #STDERR.puts "Object released! #{error}"
  OpenCL.error_check( error )
end

Instance Method Details

#command_execution_statusObject

Returns a CommandExecutionStatus corresponding to the status of the command associtated with the Event



95
96
97
98
99
100
# File 'lib/opencl_ruby_ffi/Event.rb', line 95

def command_execution_status
  ptr = FFI::MemoryPointer::new( :cl_int )
  error = OpenCL.clGetEventInfo(self, OpenCL::Event::COMMAND_EXECUTION_STATUS, ptr.size, ptr, nil )
  OpenCL.error_check(error)
  return OpenCL::CommandExecutionStatus::new( ptr.read_cl_int )
end

#command_queueObject

Returns the CommandQueue associated with the Event, if it exists



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/opencl_ruby_ffi/Event.rb', line 71

def command_queue
  ptr = FFI::MemoryPointer::new( OpenCL::CommandQueue )
  error = OpenCL.clGetEventInfo(self, OpenCL::Event::COMMAND_QUEUE, OpenCL::CommandQueue.size, ptr, nil)
  OpenCL.error_check(error)
  pt = ptr.read_pointer
  if pt.null? then
    return nil
  else
    return OpenCL::CommandQueue::new( pt )
  end
end

#contextObject

Returns the Context associated with the Event



84
85
86
87
88
89
# File 'lib/opencl_ruby_ffi/Event.rb', line 84

def context
  ptr = FFI::MemoryPointer::new( OpenCL::Context )
  error = OpenCL.clGetEventInfo(self, OpenCL::Event::CONTEXT, OpenCL::Context.size, ptr, nil)
  OpenCL.error_check(error)
  return OpenCL::Context::new( ptr.read_pointer )
end

#get_infoObject

:method: reference_count() Returns the reference counter of th Event



105
# File 'lib/opencl_ruby_ffi/Event.rb', line 105

eval OpenCL.get_info("Event", :cl_uint, "REFERENCE_COUNT")

#profiling_command_endObject

Returns the date the command corresponding to Event ended



132
133
134
135
136
137
# File 'lib/opencl_ruby_ffi/Event.rb', line 132

def profiling_command_end
   ptr = FFI::MemoryPointer::new( :cl_ulong )
   error = OpenCL.clGetEventProfilingInfo(self, OpenCL::PROFILING_COMMAND_END, ptr.size, ptr, nil )
   OpenCL.error_check(error)
   return ptr.read_cl_ulong
end

#profiling_command_queuedObject

Returns the date the command corresponding to Event was queued



108
109
110
111
112
113
# File 'lib/opencl_ruby_ffi/Event.rb', line 108

def profiling_command_queued
   ptr = FFI::MemoryPointer::new( :cl_ulong )
   error = OpenCL.clGetEventProfilingInfo(self, OpenCL::PROFILING_COMMAND_QUEUED, ptr.size, ptr, nil )
   OpenCL.error_check(error)
   return ptr.read_cl_ulong
end

#profiling_command_startObject

Returns the date the command corresponding to Event started



124
125
126
127
128
129
# File 'lib/opencl_ruby_ffi/Event.rb', line 124

def profiling_command_start
   ptr = FFI::MemoryPointer::new( :cl_ulong )
   error = OpenCL.clGetEventProfilingInfo(self, OpenCL::PROFILING_COMMAND_START, ptr.size, ptr, nil )
   OpenCL.error_check(error)
   return ptr.read_cl_ulong
end

#profiling_command_submitObject

Returns the date the command corresponding to Event was submited



116
117
118
119
120
121
# File 'lib/opencl_ruby_ffi/Event.rb', line 116

def profiling_command_submit
   ptr = FFI::MemoryPointer::new( :cl_ulong )
   error = OpenCL.clGetEventProfilingInfo(self, OpenCL::PROFILING_COMMAND_SUBMIT, ptr.size, ptr, nil )
   OpenCL.error_check(error)
   return ptr.read_cl_ulong
end

#set_event_callback(command_exec_callback_type, options = {}, &proc) ⇒ Object Also known as: set_callback

Attaches a callback to the Event that will be called on the given transition

Attributes

  • options - a hash containing named options

  • block - a callback invoked when the given Event occurs. Signature of the callback is { |Event, :cl_int event_command_exec_status, FFI::Pointer to user_data| … }

Options

  • :user_data - a Pointer (or convertible to Pointer using to_ptr) to the memory area to pass to the callback



156
157
158
# File 'lib/opencl_ruby_ffi/Event.rb', line 156

def set_event_callback( command_exec_callback_type, options={}, &proc )
  return OpenCL.set_event_callback( self, command_exec_callback_type, options={}, &proc )
end

#set_user_event_status(execution_status) ⇒ Object Also known as: set_status

Sets the satus of Event (a user event) to the given execution status



140
141
142
# File 'lib/opencl_ruby_ffi/Event.rb', line 140

def set_user_event_status( execution_status )
  return OpenCL.set_user_event_status( self, execution_status )
end

#to_sObject



1575
1576
1577
1578
1579
1580
1581
# File 'lib/opencl_ruby_ffi/opencl_ruby_ffi_base_gen.rb', line 1575

def to_s
  if self.respond_to?(:name) then
    return self.name
  else
    return super
  end
end