opencl_ruby_ffi 0.994 → 0.995

Sign up to get free protection for your applications and to get access to all the features.
@@ -1040,37 +1040,42 @@ module OpenCL
1040
1040
 
1041
1041
  # Maps the cl_command_queue object of OpenCL
1042
1042
  class CommandQueue
1043
+ include InnerInterface
1044
+
1045
+ class << self
1046
+ include InnerGenerator
1047
+ end
1043
1048
 
1044
1049
  # Returns the Context associated to the CommandQueue
1045
1050
  def context
1046
- ptr = FFI::MemoryPointer::new( OpenCL::Context )
1051
+ ptr = FFI::MemoryPointer::new( Context )
1047
1052
  error = OpenCL.clGetCommandQueueInfo(self, CONTEXT, Context.size, ptr, nil)
1048
- OpenCL.error_check(error)
1049
- return OpenCL::Context::new( ptr.read_pointer )
1053
+ error_check(error)
1054
+ return Context::new( ptr.read_pointer )
1050
1055
  end
1051
1056
 
1052
1057
  # Returns the Device associated to the CommandQueue
1053
1058
  def device
1054
- ptr = FFI::MemoryPointer::new( OpenCL::Device )
1059
+ ptr = FFI::MemoryPointer::new( Device )
1055
1060
  error = OpenCL.clGetCommandQueueInfo(self, DEVICE, Device.size, ptr, nil)
1056
- OpenCL.error_check(error)
1057
- return OpenCL::Device::new( ptr.read_pointer )
1061
+ error_check(error)
1062
+ return Device::new( ptr.read_pointer )
1058
1063
  end
1059
1064
 
1060
1065
  ##
1061
1066
  # :method: reference_count
1062
1067
  # Returns the reference count of the CommandQueue
1063
- eval OpenCL.get_info("CommandQueue", :cl_uint, "REFERENCE_COUNT")
1068
+ eval get_info("CommandQueue", :cl_uint, "REFERENCE_COUNT")
1064
1069
 
1065
1070
  ##
1066
1071
  # :method: size
1067
1072
  # Returns the currently specified size for the command queue (2.0 and for device queue only)
1068
- eval OpenCL.get_info("CommandQueue", :cl_uint, "SIZE")
1073
+ eval get_info("CommandQueue", :cl_uint, "SIZE")
1069
1074
 
1070
1075
  ##
1071
1076
  # :method: properties
1072
1077
  # Returns the :cl_command_queue_properties used to create the CommandQueue
1073
- eval OpenCL.get_info("CommandQueue", :cl_command_queue_properties, "PROPERTIES")
1078
+ eval get_info("CommandQueue", :cl_command_queue_properties, "PROPERTIES")
1074
1079
 
1075
1080
  # Enqueues a native kernel using the CommandQueue
1076
1081
  # not yet fully implemented
@@ -49,18 +49,23 @@ module OpenCL
49
49
 
50
50
  #Maps the cl_context object of OpenCL
51
51
  class Context
52
+ include InnerInterface
53
+
54
+ class << self
55
+ include InnerGenerator
56
+ end
52
57
 
53
58
  ##
54
59
  # :method: reference_count
55
60
  # Returns the reference count of the Context
56
61
  %w( REFERENCE_COUNT ).each { |prop|
57
- eval OpenCL.get_info("Context", :cl_uint, prop)
62
+ eval get_info("Context", :cl_uint, prop)
58
63
  }
59
64
 
60
65
  ##
61
66
  # :method: properties
62
67
  # the Array of :cl_context_properties used to create the Context
63
- eval OpenCL.get_info_array("Context", :cl_context_properties, "PROPERTIES")
68
+ eval get_info_array("Context", :cl_context_properties, "PROPERTIES")
64
69
 
65
70
  # Returns the platform associated to the Context
66
71
  def platform
@@ -71,8 +76,8 @@ module OpenCL
71
76
  def num_devices
72
77
  d_n = 0
73
78
  ptr = FFI::MemoryPointer::new( :size_t )
74
- error = OpenCL.clGetContextInfo(self, OpenCL::Context::DEVICES, 0, nil, ptr)
75
- OpenCL.error_check(error)
79
+ error = OpenCL.clGetContextInfo(self, DEVICES, 0, nil, ptr)
80
+ error_check(error)
76
81
  d_n = ptr.read_size_t / Platform.size
77
82
  # else
78
83
  # ptr = FFI::MemoryPointer::new( :cl_uint )
@@ -87,10 +92,10 @@ module OpenCL
87
92
  def devices
88
93
  n = self.num_devices
89
94
  ptr2 = FFI::MemoryPointer::new( Device, n )
90
- error = OpenCL.clGetContextInfo(self, OpenCL::Context::DEVICES, Device.size*n, ptr2, nil)
91
- OpenCL.error_check(error)
95
+ error = OpenCL.clGetContextInfo(self, DEVICES, Device.size*n, ptr2, nil)
96
+ error_check(error)
92
97
  return ptr2.get_array_of_pointer(0, n).collect { |device_ptr|
93
- OpenCL::Device::new(device_ptr)
98
+ Device::new(device_ptr)
94
99
  }
95
100
  end
96
101
 
@@ -104,16 +109,16 @@ module OpenCL
104
109
  #
105
110
  # * +:flags+ - a single or an Array of :cl_mem_flags specifying the flags to be used when creating the Buffer
106
111
  def supported_image_formats( image_type, options = {} )
107
- flags = OpenCL.get_flags( options )
112
+ flags = get_flags( options )
108
113
  num_image_formats = FFI::MemoryPointer::new( :cl_uint )
109
114
  error = OpenCL.clGetSupportedImageFormats( self, flags, image_type, 0, nil, num_image_formats )
110
- OpenCL.error_check(error)
115
+ error_check(error)
111
116
  num_entries = num_image_formats.read_cl_uint
112
117
  image_formats = FFI::MemoryPointer::new( ImageFormat, num_entries )
113
118
  error = OpenCL.clGetSupportedImageFormats( self, flags, image_type, num_entries, image_formats, nil )
114
- OpenCL.error_check(error)
119
+ error_check(error)
115
120
  return num_entries.times.collect { |i|
116
- OpenCL::ImageFormat::from_pointer( image_formats + i * ImageFormat.size )
121
+ ImageFormat::from_pointer( image_formats + i * ImageFormat.size )
117
122
  }
118
123
  end
119
124
 
@@ -334,7 +339,7 @@ module OpenCL
334
339
  #
335
340
  # * +device_list+ - an Array of Device to create the program for
336
341
  # * +kernel_names+ - a single or an Array of String representing the kernel names
337
- def self.create_program_with_built_in_kernels( device_list, kernel_names )
342
+ def create_program_with_built_in_kernels( device_list, kernel_names )
338
343
  return OpenCL.create_program_with_built_in_kernels(self, device_list, kernel_names )
339
344
  end
340
345
 
@@ -31,6 +31,11 @@ module OpenCL
31
31
 
32
32
  # Maps the cl_device_id object of OpenCL
33
33
  class Device
34
+ include InnerInterface
35
+
36
+ class << self
37
+ include InnerGenerator
38
+ end
34
39
 
35
40
  # :stopdoc:
36
41
  DRIVER_VERSION = 0x102D
@@ -40,10 +45,10 @@ module OpenCL
40
45
  def extensions
41
46
  extensions_size = FFI::MemoryPointer::new( :size_t )
42
47
  error = OpenCL.clGetDeviceInfo( self, EXTENSIONS, 0, nil, extensions_size)
43
- OpenCL.error_check(error)
48
+ error_check(error)
44
49
  ext = FFI::MemoryPointer::new( extensions_size.read_size_t )
45
50
  error = OpenCL.clGetDeviceInfo( self, EXTENSIONS, extensions_size.read_size_t, ext, nil)
46
- OpenCL.error_check(error)
51
+ error_check(error)
47
52
  ext_string = ext.read_string
48
53
  return ext_string.split(" ")
49
54
  end
@@ -52,92 +57,92 @@ module OpenCL
52
57
  def built_in_kernels
53
58
  built_in_kernels_size = FFI::MemoryPointer::new( :size_t )
54
59
  error = OpenCL.clGetDeviceInfo( self, BUILT_IN_KERNELS, 0, nil, built_in_kernels_size)
55
- OpenCL.error_check(error)
60
+ error_check(error)
56
61
  ker = FFI::MemoryPointer::new( built_in_kernels_size.read_size_t )
57
62
  error = OpenCL.clGetDeviceInfo( self, BUILT_IN_KERNELS, built_in_kernels_size.read_size_t, ker, nil)
58
- OpenCL.error_check(error)
63
+ error_check(error)
59
64
  ker_string = ext.read_string
60
65
  return ker_string.split(";")
61
66
  end
62
67
 
63
68
  %w( BUILT_IN_KERNELS DRIVER_VERSION VERSION VENDOR PROFILE OPENCL_C_VERSION NAME ).each { |prop|
64
- eval OpenCL.get_info("Device", :string, prop)
69
+ eval get_info("Device", :string, prop)
65
70
  }
66
71
 
67
72
  %w( MAX_MEM_ALLOC_SIZE MAX_CONSTANT_BUFFER_SIZE LOCAL_MEM_SIZE GLOBAL_MEM_CACHE_SIZE GLOBAL_MEM_SIZE ).each { |prop|
68
- eval OpenCL.get_info("Device", :cl_ulong, prop)
73
+ eval get_info("Device", :cl_ulong, prop)
69
74
  }
70
75
 
71
76
  %w( IMAGE_PITCH_ALIGNMENT IMAGE_BASE_ADDRESS_ALIGNMENT REFERENCE_COUNT PARTITION_MAX_SUB_DEVICES VENDOR_ID PREFERRED_VECTOR_WIDTH_HALF PREFERRED_VECTOR_WIDTH_CHAR PREFERRED_VECTOR_WIDTH_SHORT PREFERRED_VECTOR_WIDTH_INT PREFERRED_VECTOR_WIDTH_LONG PREFERRED_VECTOR_WIDTH_FLOAT PREFERRED_VECTOR_WIDTH_DOUBLE NATIVE_VECTOR_WIDTH_CHAR NATIVE_VECTOR_WIDTH_SHORT NATIVE_VECTOR_WIDTH_INT NATIVE_VECTOR_WIDTH_LONG NATIVE_VECTOR_WIDTH_FLOAT NATIVE_VECTOR_WIDTH_DOUBLE NATIVE_VECTOR_WIDTH_HALF MIN_DATA_TYPE_ALIGN_SIZE MEM_BASE_ADDR_ALIGN MAX_WRITE_IMAGE_ARGS MAX_READ_WRITE_IMAGE_ARGS MAX_WORK_ITEM_DIMENSIONS MAX_SAMPLERS MAX_READ_IMAGE_ARGS MAX_CONSTANT_ARGS MAX_COMPUTE_UNITS MAX_CLOCK_FREQUENCY ADDRESS_BITS GLOBAL_MEM_CACHELINE_SIZE QUEUE_ON_DEVICE_PREFERRED_SIZE QUEUE_ON_DEVICE_MAX_SIZE MAX_ON_DEVICE_QUEUES MAX_ON_DEVICE_EVENTS MAX_PIPE_ARGS PIPE_MAX_ACTIVE_RESERVATIONS PIPE_MAX_PACKET_SIZE PREFERRED_PLATFORM_ATOMIC_ALIGNMENT PREFERRED_GLOBAL_ATOMIC_ALIGNMENT PREFERRED_LOCAL_ATOMIC_ALIGNMENT).each { |prop|
72
- eval OpenCL.get_info("Device", :cl_uint, prop)
77
+ eval get_info("Device", :cl_uint, prop)
73
78
  }
74
79
 
75
80
  %w( PRINTF_BUFFER_SIZE IMAGE_MAX_BUFFER_SIZE IMAGE_MAX_ARRAY_SIZE PROFILING_TIMER_RESOLUTION MAX_WORK_GROUP_SIZE MAX_PARAMETER_SIZE IMAGE2D_MAX_WIDTH IMAGE2D_MAX_HEIGHT IMAGE3D_MAX_WIDTH IMAGE3D_MAX_HEIGHT IMAGE3D_MAX_DEPTH MAX_GLOBAL_VARIABLE_SIZE GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE).each { |prop|
76
- eval OpenCL.get_info("Device", :size_t, prop)
81
+ eval get_info("Device", :size_t, prop)
77
82
  }
78
83
 
79
84
  %w( PREFERRED_INTEROP_USER_SYNC LINKER_AVAILABLE IMAGE_SUPPORT HOST_UNIFIED_MEMORY COMPILER_AVAILABLE AVAILABLE ENDIAN_LITTLE ERROR_CORRECTION_SUPPORT ).each { |prop|
80
- eval OpenCL.get_info("Device", :cl_bool, prop)
85
+ eval get_info("Device", :cl_bool, prop)
81
86
  }
82
87
 
83
88
  %w( SINGLE_FP_CONFIG HALF_FP_CONFIG DOUBLE_FP_CONFIG ).each { |prop|
84
- eval OpenCL.get_info("Device", :cl_device_fp_config, prop)
89
+ eval get_info("Device", :cl_device_fp_config, prop)
85
90
  }
86
91
 
87
92
  ##
88
93
  # :method: execution_capabilities()
89
94
  # Returns an ExecCpabilities representing the execution capabilities corresponding to the Device
90
- eval OpenCL.get_info("Device", :cl_device_exec_capabilities, "EXECUTION_CAPABILITIES")
95
+ eval get_info("Device", :cl_device_exec_capabilities, "EXECUTION_CAPABILITIES")
91
96
 
92
97
  ##
93
98
  # :method: global_mem_cache_type()
94
99
  # Returns a MemCacheType representing the type of the global cache memory on the Device
95
- eval OpenCL.get_info("Device", :cl_device_mem_cache_type, "GLOBAL_MEM_CACHE_TYPE")
100
+ eval get_info("Device", :cl_device_mem_cache_type, "GLOBAL_MEM_CACHE_TYPE")
96
101
 
97
102
  ##
98
103
  # :method: local_mem_type()
99
104
  # Returns a LocalMemType rpresenting the type of the local memory on the Device
100
- eval OpenCL.get_info("Device", :cl_device_local_mem_type, "LOCAL_MEM_TYPE")
105
+ eval get_info("Device", :cl_device_local_mem_type, "LOCAL_MEM_TYPE")
101
106
 
102
107
  ##
103
108
  # :method: queue_properties()
104
109
  # Returns a CommandQueue::Properties representing the properties supported by a CommandQueue targetting the Device
105
- eval OpenCL.get_info("Device", :cl_command_queue_properties, "QUEUE_PROPERTIES")
110
+ eval get_info("Device", :cl_command_queue_properties, "QUEUE_PROPERTIES")
106
111
 
107
112
  ##
108
113
  # :method: queue_on_device_properties()
109
114
  # Returns a CommandQueue::Properties representing the properties supported by a CommandQueue on the Device
110
- eval OpenCL.get_info("Device", :cl_command_queue_properties, "QUEUE_ON_DEVICE_PROPERTIES")
115
+ eval get_info("Device", :cl_command_queue_properties, "QUEUE_ON_DEVICE_PROPERTIES")
111
116
 
112
117
  ##
113
118
  # :method: queue_on_host_properties()
114
119
  # Returns a CommandQueue::Properties representing the properties supported by a CommandQueue targetting the Device
115
- eval OpenCL.get_info("Device", :cl_command_queue_properties, "QUEUE_ON_HOST_PROPERTIES")
120
+ eval get_info("Device", :cl_command_queue_properties, "QUEUE_ON_HOST_PROPERTIES")
116
121
 
117
122
  ##
118
123
  # :method: type()
119
124
  # Returns a Device::Type representing the type of the Device
120
- eval OpenCL.get_info("Device", :cl_device_type, "TYPE")
125
+ eval get_info("Device", :cl_device_type, "TYPE")
121
126
 
122
127
  ##
123
128
  # :method: partition_affinity_domain()
124
129
  # Returns an AffinityDomain representing the list of supported affinity domains for partitioning the Device using OpenCL::Device::PARTITION_BY_AFFINITY_DOMAIN
125
- eval OpenCL.get_info("Device", :cl_device_affinity_domain, "PARTITION_AFFINITY_DOMAIN")
130
+ eval get_info("Device", :cl_device_affinity_domain, "PARTITION_AFFINITY_DOMAIN")
126
131
 
127
132
  ##
128
133
  # :method: max_work_item_sizes()
129
134
  # Maximum number of work-items that can be specified in each dimension of the work-group to clEnqueueNDRangeKernel for the Device
130
- eval OpenCL.get_info_array("Device", :size_t, "MAX_WORK_ITEM_SIZES")
135
+ eval get_info_array("Device", :size_t, "MAX_WORK_ITEM_SIZES")
131
136
 
132
137
  ##
133
138
  # :method: partition_properties()
134
139
  # Returns the list of partition types supported by the Device
135
- eval OpenCL.get_info_array("Device", :cl_device_partition_property, "PARTITION_PROPERTIES")
140
+ eval get_info_array("Device", :cl_device_partition_property, "PARTITION_PROPERTIES")
136
141
 
137
142
  ##
138
143
  # :method: svm_capabilities()
139
144
  # Returns an SVMCapabilities representing the the SVM capabilities corresponding to the device
140
- eval OpenCL.get_info_array("Device", :cl_device_svm_capabilities, "SVM_CAPABILITIES")
145
+ eval get_info_array("Device", :cl_device_svm_capabilities, "SVM_CAPABILITIES")
141
146
 
142
147
  # Return an Array of partition properties names representing the partition type supported by the device
143
148
  def partition_properties_names
@@ -151,13 +156,13 @@ module OpenCL
151
156
  ##
152
157
  # :method: partition_type()
153
158
  # Returns a list of :cl_device_partition_property used to create the Device
154
- eval OpenCL.get_info_array("Device", :cl_device_partition_property, "PARTITION_TYPE")
159
+ eval get_info_array("Device", :cl_device_partition_property, "PARTITION_TYPE")
155
160
 
156
161
  # Returns the platform the Device belongs to
157
162
  def platform
158
163
  ptr = FFI::MemoryPointer::new( OpenCL::Platform )
159
164
  error = OpenCL.clGetDeviceInfo(self, PLATFORM, OpenCL::Platform.size, ptr, nil)
160
- OpenCL.error_check(error)
165
+ error_check(error)
161
166
  return OpenCL::Platform::new(ptr.read_pointer)
162
167
  end
163
168
 
@@ -165,7 +170,7 @@ module OpenCL
165
170
  def parent_device
166
171
  ptr = FFI::MemoryPointer::new( Device )
167
172
  error = OpenCL.clGetDeviceInfo(self, PARENT_DEVICE, Device.size, ptr, nil)
168
- OpenCL.error_check(error)
173
+ error_check(error)
169
174
  return nil if ptr.null?
170
175
  return Device::new(ptr.read_pointer)
171
176
  end
@@ -67,73 +67,78 @@ module OpenCL
67
67
 
68
68
  # Maps the cl_event object
69
69
  class Event
70
+ include InnerInterface
71
+
72
+ class << self
73
+ include InnerGenerator
74
+ end
70
75
 
71
76
  # Returns the CommandQueue associated with the Event, if it exists
72
77
  def command_queue
73
- ptr = FFI::MemoryPointer::new( OpenCL::CommandQueue )
74
- error = OpenCL.clGetEventInfo(self, COMMAND_QUEUE, OpenCL::CommandQueue.size, ptr, nil)
75
- OpenCL.error_check(error)
78
+ ptr = FFI::MemoryPointer::new( CommandQueue )
79
+ error = OpenCL.clGetEventInfo(self, COMMAND_QUEUE, CommandQueue.size, ptr, nil)
80
+ error_check(error)
76
81
  pt = ptr.read_pointer
77
82
  if pt.null? then
78
83
  return nil
79
84
  else
80
- return OpenCL::CommandQueue::new( pt )
85
+ return CommandQueue::new( pt )
81
86
  end
82
87
  end
83
88
 
84
89
  # Returns the Context associated with the Event
85
90
  def context
86
- ptr = FFI::MemoryPointer::new( OpenCL::Context )
87
- error = OpenCL.clGetEventInfo(self, CONTEXT, OpenCL::Context.size, ptr, nil)
88
- OpenCL.error_check(error)
89
- return OpenCL::Context::new( ptr.read_pointer )
91
+ ptr = FFI::MemoryPointer::new( Context )
92
+ error = OpenCL.clGetEventInfo(self, CONTEXT, Context.size, ptr, nil)
93
+ error_check(error)
94
+ return Context::new( ptr.read_pointer )
90
95
  end
91
96
 
92
97
  # Returns a CommandType corresponding to the type of the command associated with the Event
93
- eval OpenCL.get_info("Event", :cl_command_type, "COMMAND_TYPE")
98
+ eval get_info("Event", :cl_command_type, "COMMAND_TYPE")
94
99
 
95
100
  # Returns a CommandExecutionStatus corresponding to the status of the command associtated with the Event
96
101
  def command_execution_status
97
102
  ptr = FFI::MemoryPointer::new( :cl_int )
98
103
  error = OpenCL.clGetEventInfo(self, COMMAND_EXECUTION_STATUS, ptr.size, ptr, nil )
99
- OpenCL.error_check(error)
100
- return OpenCL::CommandExecutionStatus::new( ptr.read_cl_int )
104
+ error_check(error)
105
+ return CommandExecutionStatus::new( ptr.read_cl_int )
101
106
  end
102
107
 
103
108
  ##
104
109
  # :method: reference_count()
105
110
  # Returns the reference counter of th Event
106
- eval OpenCL.get_info("Event", :cl_uint, "REFERENCE_COUNT")
111
+ eval get_info("Event", :cl_uint, "REFERENCE_COUNT")
107
112
 
108
113
  # Returns the date the command corresponding to Event was queued
109
114
  def profiling_command_queued
110
115
  ptr = FFI::MemoryPointer::new( :cl_ulong )
111
- error = OpenCL.clGetEventProfilingInfo(self, OpenCL::PROFILING_COMMAND_QUEUED, ptr.size, ptr, nil )
112
- OpenCL.error_check(error)
116
+ error = OpenCL.clGetEventProfilingInfo(self, PROFILING_COMMAND_QUEUED, ptr.size, ptr, nil )
117
+ error_check(error)
113
118
  return ptr.read_cl_ulong
114
119
  end
115
120
 
116
121
  # Returns the date the command corresponding to Event was submited
117
122
  def profiling_command_submit
118
123
  ptr = FFI::MemoryPointer::new( :cl_ulong )
119
- error = OpenCL.clGetEventProfilingInfo(self, OpenCL::PROFILING_COMMAND_SUBMIT, ptr.size, ptr, nil )
120
- OpenCL.error_check(error)
124
+ error = OpenCL.clGetEventProfilingInfo(self, PROFILING_COMMAND_SUBMIT, ptr.size, ptr, nil )
125
+ error_check(error)
121
126
  return ptr.read_cl_ulong
122
127
  end
123
128
 
124
129
  # Returns the date the command corresponding to Event started
125
130
  def profiling_command_start
126
131
  ptr = FFI::MemoryPointer::new( :cl_ulong )
127
- error = OpenCL.clGetEventProfilingInfo(self, OpenCL::PROFILING_COMMAND_START, ptr.size, ptr, nil )
128
- OpenCL.error_check(error)
132
+ error = OpenCL.clGetEventProfilingInfo(self, PROFILING_COMMAND_START, ptr.size, ptr, nil )
133
+ error_check(error)
129
134
  return ptr.read_cl_ulong
130
135
  end
131
136
 
132
137
  # Returns the date the command corresponding to Event ended
133
138
  def profiling_command_end
134
139
  ptr = FFI::MemoryPointer::new( :cl_ulong )
135
- error = OpenCL.clGetEventProfilingInfo(self, OpenCL::PROFILING_COMMAND_END, ptr.size, ptr, nil )
136
- OpenCL.error_check(error)
140
+ error = OpenCL.clGetEventProfilingInfo(self, PROFILING_COMMAND_END, ptr.size, ptr, nil )
141
+ error_check(error)
137
142
  return ptr.read_cl_ulong
138
143
  end
139
144
 
@@ -199,7 +199,6 @@ module OpenCL
199
199
  # Maps the cl_mem OpenCL objects of type CL_MEM_OBJECT_IMAGE*
200
200
  class Image
201
201
 
202
-
203
202
  ##
204
203
  # :method: element_size
205
204
  # Returns the element_size of the Image
@@ -228,7 +227,7 @@ module OpenCL
228
227
  # :method: array_size
229
228
  # Returns the array_size of the Image
230
229
  %w( ELEMENT_SIZE ROW_PITCH SLICE_PITCH WIDTH HEIGHT DEPTH ARRAY_SIZE ).each { |prop|
231
- eval OpenCL.get_info("Image", :size_t, prop)
230
+ eval get_info("Image", :size_t, prop)
232
231
  }
233
232
 
234
233
  ##
@@ -239,29 +238,29 @@ module OpenCL
239
238
  # :method: num_samples
240
239
  # Returns the num_samples of the Image
241
240
  %w( NUM_MIP_LEVELS NUM_SAMPLES ).each { |prop|
242
- eval OpenCL.get_info("Image", :cl_uint, prop)
241
+ eval get_info("Image", :cl_uint, prop)
243
242
  }
244
243
 
245
244
  # Returns the ImageDesc corresponding to the Image
246
245
  def desc
247
- return OpenCL::ImageDesc::new( self.type, self.width, self.height, self.depth, self.array_size, self.row_pitch, self.slice_pitch, self.num_mip_levels, self.num_samples, self.buffer )
246
+ return ImageDesc::new( self.type, self.width, self.height, self.depth, self.array_size, self.row_pitch, self.slice_pitch, self.num_mip_levels, self.num_samples, self.buffer )
248
247
  end
249
248
 
250
249
  # Returns the ImageFormat corresponding to the image
251
250
  def format
252
- image_format = FFI::MemoryPointer::new( OpenCL::ImageFormat )
251
+ image_format = FFI::MemoryPointer::new( ImageFormat )
253
252
  error = OpenCL.clGetImageInfo( self, FORMAT, image_format.size, image_format, nil)
254
- OpenCL.error_check(error)
255
- return OpenCL::ImageFormat::from_pointer( image_format )
253
+ error_check(error)
254
+ return ImageFormat::from_pointer( image_format )
256
255
  end
257
256
 
258
257
  # Returns the associated Buffer if any, nil otherwise
259
258
  def buffer
260
- ptr = FFI::MemoryPointer::new( OpenCL::Buffer )
261
- error = OpenCL.clGetImageInfo(self, BUFFER, OpenCL::Buffer.size, ptr, nil)
262
- OpenCL.error_check(error)
259
+ ptr = FFI::MemoryPointer::new( Buffer )
260
+ error = OpenCL.clGetImageInfo(self, BUFFER, Buffer.size, ptr, nil)
261
+ error_check(error)
263
262
  return nil if ptr.null?
264
- return OpenCL::Buffer::new(ptr.read_pointer)
263
+ return Buffer::new(ptr.read_pointer)
265
264
  end
266
265
 
267
266
  end
@@ -37,9 +37,19 @@ module OpenCL
37
37
 
38
38
  # Maps the cl_kernel object
39
39
  class Kernel
40
+ include InnerInterface
41
+
42
+ class << self
43
+ include InnerGenerator
44
+ end
40
45
 
41
46
  # Maps the logical cl arg object
42
47
  class Arg
48
+ include InnerInterface
49
+
50
+ class << self
51
+ include InnerGenerator
52
+ end
43
53
  # Returns the index of the Arg in the list
44
54
  attr_reader :index
45
55
  # Returns the Kernel this Arg belongs to
@@ -53,58 +63,58 @@ module OpenCL
53
63
 
54
64
  # Returns an AddressQualifier corresponding to the Arg
55
65
  def address_qualifier
56
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
66
+ error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
57
67
  ptr = FFI::MemoryPointer::new( :cl_kernel_arg_address_qualifier )
58
68
  error = OpenCL.clGetKernelArgInfo(@kernel, @index, ADDRESS_QUALIFIER, ptr.size, ptr, nil)
59
- OpenCL.error_check(error)
69
+ error_check(error)
60
70
  return AddressQualifier::new( ptr.read_cl_kernel_arg_address_qualifier )
61
71
  end
62
72
 
63
73
  # Returns an AccessQualifier corresponding to the Arg
64
74
  def access_qualifier
65
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
75
+ error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
66
76
  ptr = FFI::MemoryPointer::new( :cl_kernel_arg_access_qualifier )
67
77
  error = OpenCL.clGetKernelArgInfo(@kernel, @index, ACCESS_QUALIFIER, ptr.size, ptr, nil)
68
- OpenCL.error_check(error)
78
+ error_check(error)
69
79
  return AccessQualifier::new( ptr.read_cl_kernel_arg_access_qualifier )
70
80
  end
71
81
 
72
82
  # Returns a TypeQualifier corresponding to the Arg
73
83
  def type_qualifier
74
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
84
+ error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
75
85
  ptr = FFI::MemoryPointer::new( :cl_kernel_arg_type_qualifier )
76
86
  error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_QUALIFIER, ptr.size, ptr, nil)
77
- OpenCL.error_check(error)
87
+ error_check(error)
78
88
  return TypeQualifier::new( ptr.read_cl_kernel_arg_type_qualifier )
79
89
  end
80
90
 
81
91
  # Returns a String corresponding to the Arg type name
82
92
  def type_name
83
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
93
+ error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
84
94
  ptr1 = FFI::MemoryPointer::new( :size_t, 1)
85
95
  error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_NAME, 0, nil, ptr1)
86
- OpenCL.error_check(error)
96
+ error_check(error)
87
97
  ptr2 = FFI::MemoryPointer::new( ptr1.read_size_t )
88
98
  error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_NAME, ptr1.read_size_t, ptr2, nil)
89
- OpenCL.error_check(error)
99
+ error_check(error)
90
100
  return ptr2.read_string
91
101
  end
92
102
 
93
103
  # Returns a String corresponding to the Arg name
94
104
  def name
95
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
105
+ error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2
96
106
  ptr1 = FFI::MemoryPointer::new( :size_t, 1)
97
107
  error = OpenCL.clGetKernelArgInfo(@kernel, @index, NAME, 0, nil, ptr1)
98
- OpenCL.error_check(error)
108
+ error_check(error)
99
109
  ptr2 = FFI::MemoryPointer::new( ptr1.read_size_t )
100
110
  error = OpenCL.clGetKernelArgInfo(@kernel, @index, NAME, ptr1.read_size_t, ptr2, nil)
101
- OpenCL.error_check(error)
111
+ error_check(error)
102
112
  return ptr2.read_string
103
113
  end
104
114
 
105
115
  # Sets this Arg to value. The size of value can be specified.
106
116
  def set(value, size = nil)
107
- if value.class == OpenCL::SVMPointer and @kernel.context.platform.version_number >= 2.0 then
117
+ if value.class == SVMPointer and @kernel.context.platform.version_number >= 2.0 then
108
118
  OpenCL.set_kernel_arg_svm_pointer( @kernel, @index, value )
109
119
  else
110
120
  OpenCL.set_kernel_arg(@kernel, @index, value, size)
@@ -125,24 +135,24 @@ module OpenCL
125
135
 
126
136
  # Specifies the list of SVM pointers the kernel will be using
127
137
  def set_svm_ptrs( ptrs )
128
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if self.context.platform.version_number < 2.0
138
+ error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.0
129
139
  pointers = [ptrs].flatten
130
140
  pt = FFI::MemoryPointer::new( :pointer, pointers.length )
131
141
  pointers.each_with_index { |p, i|
132
142
  pt[i].write_pointer(p)
133
143
  }
134
144
  error = OpenCL.clSetKernelExecInfo( self, EXEC_INFO_SVM_PTRS, pt.size, pt)
135
- OpenCL.error_check(error)
145
+ error_check(error)
136
146
  return self
137
147
  end
138
148
 
139
149
  # Specifies the granularity of the SVM system.
140
150
  def set_svm_fine_grain_system( flag )
141
- OpenCL.error_check(OpenCL::INVALID_OPERATION) if self.context.platform.version_number < 2.0
151
+ error_check(INVALID_OPERATION) if self.context.platform.version_number < 2.0
142
152
  pt = FFI::MemoryPointer::new( :cl_bool )
143
153
  pt.write_cl_bool( flag )
144
154
  error = OpenCL.clSetKernelExecInfo( self, EXEC_INFO_SVM_FINE_GRAIN_SYSTEL, pt.size, pt)
145
- OpenCL.error_check(error)
155
+ error_check(error)
146
156
  return self
147
157
  end
148
158
 
@@ -154,7 +164,7 @@ module OpenCL
154
164
  # :method: attributes()
155
165
  # returns a String containing the attributes qualifier used at kernel definition
156
166
  %w( FUNCTION_NAME ATTRIBUTES ).each { |prop|
157
- eval OpenCL.get_info("Kernel", :string, prop)
167
+ eval get_info("Kernel", :string, prop)
158
168
  }
159
169
 
160
170
  alias name function_name
@@ -167,23 +177,23 @@ module OpenCL
167
177
  # :method: reference_count
168
178
  # Returns the reference counter for the Kernel
169
179
  %w( NUM_ARGS REFERENCE_COUNT ).each { |prop|
170
- eval OpenCL.get_info("Kernel", :cl_uint, prop)
180
+ eval get_info("Kernel", :cl_uint, prop)
171
181
  }
172
182
 
173
183
  # Returns the Context the Kernel is associated with
174
184
  def context
175
185
  ptr = FFI::MemoryPointer::new( Context )
176
186
  error = OpenCL.clGetKernelInfo(self, CONTEXT, Context.size, ptr, nil)
177
- OpenCL.error_check(error)
178
- return OpenCL::Context::new( ptr.read_pointer )
187
+ error_check(error)
188
+ return Context::new( ptr.read_pointer )
179
189
  end
180
190
 
181
191
  # Returns the Program the Kernel was created from
182
192
  def program
183
193
  ptr = FFI::MemoryPointer::new( Program )
184
194
  error = OpenCL.clGetKernelInfo(self, PROGRAM, Program.size, ptr, nil)
185
- OpenCL.error_check(error)
186
- return OpenCL::Program::new(ptr.read_pointer)
195
+ error_check(error)
196
+ return Program::new(ptr.read_pointer)
187
197
  end
188
198
 
189
199
  # Set the index th argument of the Kernel to value. The size of value can be specified.
@@ -199,15 +209,15 @@ module OpenCL
199
209
  # Enqueues the Kernel in the given queue, specifying the global_work_size. Arguments for the kernel are specified afterwards. Last, a hash containing options for enqueuNDrange kernel can be specified
200
210
  def enqueue_with_args(command_queue, global_work_size, *args)
201
211
  n = self.num_args
202
- OpenCL.error_check(OpenCL::INVALID_KERNEL_ARGS) if args.length < n
203
- OpenCL.error_check(OpenCL::INVALID_KERNEL_ARGS) if args.length > n + 1
212
+ error_check(INVALID_KERNEL_ARGS) if args.length < n
213
+ error_check(INVALID_KERNEL_ARGS) if args.length > n + 1
204
214
  if args.length == n + 1
205
215
  options = args.last
206
216
  else
207
217
  options = {}
208
218
  end
209
219
  n.times { |i|
210
- if args[i].class == OpenCL::SVMPointer and self.context.platform.version_number >= 2.0 then
220
+ if args[i].class == SVMPointer and self.context.platform.version_number >= 2.0 then
211
221
  self.set_arg_svm_pointer(i, args[i])
212
222
  else
213
223
  self.set_arg(i, args[i])