Module: ComputeUnit
- Defined in:
- lib/compute_unit/device.rb,
lib/compute_unit.rb,
lib/compute_unit/cpu.rb,
lib/compute_unit/gpu.rb,
lib/compute_unit/asic.rb,
lib/compute_unit/utils.rb,
lib/compute_unit/logger.rb,
lib/compute_unit/version.rb,
lib/compute_unit/exceptions.rb,
lib/compute_unit/formatters.rb,
lib/compute_unit/cache_store.rb,
lib/compute_unit/compute_base.rb,
lib/compute_unit/gpus/amd_gpu.rb,
lib/compute_unit/gpus/nvidia_gpu.rb
Overview
More information about sysfs can be found here - www.kernel.org/doc/Documentation/filesystems/sysfs-pci.txt
Defined Under Namespace
Modules: Exceptions, Formatters, Logger, Utils Classes: AmdGpu, Asic, CacheStore, ComputeBase, Cpu, Device, Gpu, NvidiaGpu
Constant Summary collapse
- CACHE_DIR =
File.join('/var', 'run', 'compute_unit_cache')
- SYSFS_PATH =
ENV['SYSFS_PATH'] || '/sys'
- SYS_DEVICE_PATH =
File.join(SYSFS_PATH, 'bus/pci/devices')
- PCI_DATABASE_PATH =
File.join(File.dirname(__dir__), 'pci.ids')
- PCI_DATABASE_URL =
'http://pci-ids.ucw.cz/v2.2/pci.ids'- DEFAULT_PCIDB_PATH =
'/usr/share/misc/pci.ids'- VERSION =
'0.4.0'
Class Method Summary collapse
-
.copy_default_database ⇒ Object
copies the default pci database from linux filesystem over to the gem path.
-
.find_all(use_opencl = false) ⇒ Array
-
return a list of compute units.
-
-
.find_all_with_database(use_opencl = false) ⇒ Array
get a fresh copy of the database and then use find_all.
-
.refresh_pci_database ⇒ Object
downloads the pci database.
Class Method Details
.copy_default_database ⇒ Object
copies the default pci database from linux filesystem over to the gem path
31 32 33 |
# File 'lib/compute_unit.rb', line 31 def self.copy_default_database FileUtils.cp(DEFAULT_PCIDB_PATH, PCI_DATABASE_PATH) end |
.find_all(use_opencl = false) ⇒ Array
Returns - return a list of compute units.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/compute_unit.rb', line 18 def self.find_all(use_opencl = false) require 'compute_unit/gpu' require 'compute_unit/cpu' require 'compute_unit/asic' copy_default_database unless File.exist?(PCI_DATABASE_PATH) ComputeUnit::Gpu.find_all(use_opencl) + ComputeUnit::Cpu.find_all + ComputeUnit::Asic.find_all end |
.find_all_with_database(use_opencl = false) ⇒ Array
get a fresh copy of the database and then use find_all
38 39 40 41 |
# File 'lib/compute_unit.rb', line 38 def self.find_all_with_database(use_opencl = false) refresh_pci_database find_all(use_opencl) end |
.refresh_pci_database ⇒ Object
downloads the pci database
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/compute_unit.rb', line 44 def self.refresh_pci_database ComputeUnit::Utils.check_for_root require 'net/http' require 'uri' uri = URI.parse(PCI_DATABASE_URL) response = Net::HTTP.get_response(uri) # I can't write to it unless it has correct permissions File.chmod(0o644, PCI_DATABASE_PATH) if File.exist?(PCI_DATABASE_PATH) File.write(PCI_DATABASE_PATH, response.body) if response.code == '200' File.chmod(0o644, PCI_DATABASE_PATH) PCI_DATABASE_PATH end |