Method: BOAST::OpenCLRuntime#select_cl_device

Defined in:
lib/BOAST/Runtime/OpenCLRuntime.rb

#select_cl_device(options, context = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/BOAST/Runtime/OpenCLRuntime.rb', line 24

def select_cl_device(options, context = nil)
  return options[:CLDEVICE] if options[:CLDEVICE] and options[:CLDEVICE].is_a?(OpenCL::Device)
  devices = nil
  if context then
    devices = context.devices
  else
    platforms = select_cl_platforms(options)
    type = options[:CLDEVICETYPE] ? OpenCL::Device::Type.const_get(options[:CLDEVICETYPE]) : OpenCL::Device::Type::ALL
    devices = platforms.collect { |plt| plt.devices(type) }
    devices.flatten!
  end
  name_pattern = options[:CLDEVICE]
  if name_pattern then
    devices.select!{ |d|
      d.name.match(name_pattern)
    }
  end
  return devices.first
end