Method: ComputeUnit::Device.device_lookup

Defined in:
lib/compute_unit/device.rb

.device_lookup(device_id) ⇒ String

queries the pci_database that is shipped with this gem and looks up the device

Parameters:

  • - (String)

    the device id such as ‘686f’

Returns:

  • (String)
    • the device name



382
383
384
385
386
387
388
389
390
391
392
393
394
# File 'lib/compute_unit/device.rb', line 382

def self.device_lookup(device_id)
  # "\t687f  Vega 10 XT [Radeon RX Vega 64]\n"
  re = Regexp.new(/\A\t#{device_id}/)
  d = pci_database.find do |line|
    re.match(line)
  rescue ArgumentError
    next
  end
  return d unless d

  name = d[/\t\w+\s+(.*)\n/, 1]
  name[/.*\[(.*)\]/, 1] || name if name
end