compute_unit 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +4 -4
- data/lib/compute_unit/compute_base.rb +0 -21
- data/lib/compute_unit/cpu.rb +15 -4
- data/lib/compute_unit/utils.rb +1 -1
- data/lib/compute_unit/version.rb +1 -1
- metadata +2 -3
- data/lib/compute_unit/formatters.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f51ca7c79e4dfb8a97f4221a0798a59169ddf4c925978bd2cff52633412573ab
|
4
|
+
data.tar.gz: 8e5b1cf6adad26fac8c54cdc54f3178af1a8e2325657e997419f98d8306d9e86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b18314336244f86d4c7417def3bf97d90762696df44cd9a1f6bced80b6dca142afe6deb5cd8954795e773c974061d8737bf7635307305e96d9018e1a59fcef17
|
7
|
+
data.tar.gz: 9f3bc81ca0e1a0694733880217b6574e959e4eef538ab24bae28b081dafc962d763aa02214598bfa846603d9d83dbf497e1559a690e707655a7dc9cfae532544
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -144,7 +144,7 @@ Instead of monkey patching this code you can simply subclass the objects. The f
|
|
144
144
|
|
145
145
|
```ruby
|
146
146
|
# coolproject/vegagpu.rb
|
147
|
-
require '
|
147
|
+
require 'compute_unit/gpu/amdgpu'
|
148
148
|
module CoolProject
|
149
149
|
class VegaGpu < ::ComputeUnit::Gpu::AmdGpu
|
150
150
|
include CoolProject::Metrics
|
@@ -189,7 +189,7 @@ The opencl_ruby_ffi gem is optionally used to gather additional info about the G
|
|
189
189
|
|
190
190
|
There is some caution when using OpenCL. If a GPU is dead, OpenCL tends to hang/freeze thus forcing a reboot. This is not a bug in the compute_unit or opencl_ruby_ffi gem but in the OpenCL library instead.
|
191
191
|
|
192
|
-
Getting data from OpenCL also takes a long time! So if you have multiple GPUs in your system this could takes multiple seconds to return data. Because of this we cache the responses for the next query. This response is cached until the system checksum changes. This checksum is a special
|
192
|
+
Getting data from OpenCL also takes a long time! So if you have multiple GPUs in your system this could takes multiple seconds to return data. Because of this we cache the responses for the next query. This response is cached until the system checksum changes. This checksum is a special calculatulation of all the devices present in the system. So if you ever added or changed the equipment in the system, a new OpenCL query would ensue.
|
193
193
|
|
194
194
|
To enable OpenCL you just need to pass a boolean value to any of the find_all methods:
|
195
195
|
|
@@ -207,7 +207,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
207
207
|
|
208
208
|
## Contributing
|
209
209
|
|
210
|
-
Bug reports and pull requests are welcome on GitHub at https://
|
210
|
+
Bug reports and pull requests are welcome on GitHub at https://gitlab.com/blockops/compute_unit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
211
211
|
|
212
212
|
## License
|
213
213
|
|
@@ -215,4 +215,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
215
215
|
|
216
216
|
## Code of Conduct
|
217
217
|
|
218
|
-
Everyone interacting in the ComputeUnit project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://
|
218
|
+
Everyone interacting in the ComputeUnit project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/blockops/compute_unit/-/blob/master/CODE_OF_CONDUCT.md).
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'time'
|
4
|
-
require 'compute_unit/formatters'
|
5
4
|
require 'compute_unit/logger'
|
6
5
|
require 'compute_unit/device'
|
7
6
|
require 'sys/proctable'
|
@@ -13,7 +12,6 @@ module ComputeUnit
|
|
13
12
|
attr_reader :type, :serial, :meta, :uuid, :timestamp, :index, :compute_type
|
14
13
|
attr_accessor :power_offset
|
15
14
|
|
16
|
-
include ComputeUnit::Formatters
|
17
15
|
include ComputeUnit::Logger
|
18
16
|
|
19
17
|
# timeout value
|
@@ -73,24 +71,5 @@ module ComputeUnit
|
|
73
71
|
def expired_metadata?
|
74
72
|
(timestamp + CACHE_TIMEOUT) < Time.now.to_i
|
75
73
|
end
|
76
|
-
|
77
|
-
def experimental_on?
|
78
|
-
unless ENV['XB_EXPERIMENTAL'].to_s == '1'
|
79
|
-
logger.warn('You must set environment variable XB_EXPERIMENTAL=1 to use this feature')
|
80
|
-
return false
|
81
|
-
end
|
82
|
-
true
|
83
|
-
end
|
84
|
-
|
85
|
-
def micro_formatter(item, add_unit = false)
|
86
|
-
data = {}
|
87
|
-
item.each do |key, value|
|
88
|
-
if %i[hourly_cost hourly_earnings kwh_cost].include?(key)
|
89
|
-
v = (value * 1_000_000).round(4)
|
90
|
-
data[key] = add_unit ? "#{v} \u00B5BTC" : v
|
91
|
-
end
|
92
|
-
end
|
93
|
-
item.merge(data)
|
94
|
-
end
|
95
74
|
end
|
96
75
|
end
|
data/lib/compute_unit/cpu.rb
CHANGED
@@ -15,6 +15,10 @@ module ComputeUnit
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def bios
|
19
|
+
'N/A'
|
20
|
+
end
|
21
|
+
|
18
22
|
def utilization
|
19
23
|
1 # until we can calculate this. Is loadavg a good metric? or load / cpus
|
20
24
|
end
|
@@ -118,7 +122,7 @@ module ComputeUnit
|
|
118
122
|
end
|
119
123
|
|
120
124
|
def power
|
121
|
-
ENV.fetch('CPU_POWER', 60) # until we can calculate power we will just use 60
|
125
|
+
ENV.fetch('CPU_POWER', 60).to_i # until we can calculate power we will just use 60
|
122
126
|
end
|
123
127
|
|
124
128
|
def fan
|
@@ -134,7 +138,7 @@ module ComputeUnit
|
|
134
138
|
end
|
135
139
|
|
136
140
|
def status_info
|
137
|
-
{ index:
|
141
|
+
{ index: uuid,
|
138
142
|
name: model,
|
139
143
|
bios: 'N/A',
|
140
144
|
core_clock: current_freq_mhz,
|
@@ -149,6 +153,7 @@ module ComputeUnit
|
|
149
153
|
|
150
154
|
def metrics
|
151
155
|
{
|
156
|
+
uuid: uuid,
|
152
157
|
temp: temp,
|
153
158
|
minFreqMhz: min_freq_mhz,
|
154
159
|
maxFreqMhz: max_freq_mhz,
|
@@ -169,9 +174,15 @@ module ComputeUnit
|
|
169
174
|
def initialize(_device_path, opts)
|
170
175
|
super
|
171
176
|
@type = :CPU
|
172
|
-
@pci_loc = device_path
|
173
|
-
|
177
|
+
@pci_loc = device_path
|
178
|
+
@index = opts[:index].to_i
|
174
179
|
@power_offset = 0
|
180
|
+
@uuid = opts[:uuid] || opts[:serial]
|
181
|
+
end
|
182
|
+
|
183
|
+
# @return [String] - the type and index of the device
|
184
|
+
def uuid
|
185
|
+
@uuid ||= "#{type}#{index}"
|
175
186
|
end
|
176
187
|
|
177
188
|
def self.create_from_path(device_path, index)
|
data/lib/compute_unit/utils.rb
CHANGED
data/lib/compute_unit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compute_unit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Osman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sys-proctable
|
@@ -125,7 +125,6 @@ files:
|
|
125
125
|
- lib/compute_unit/cpu.rb
|
126
126
|
- lib/compute_unit/device.rb
|
127
127
|
- lib/compute_unit/exceptions.rb
|
128
|
-
- lib/compute_unit/formatters.rb
|
129
128
|
- lib/compute_unit/gpu.rb
|
130
129
|
- lib/compute_unit/gpus/amd_gpu.rb
|
131
130
|
- lib/compute_unit/gpus/nvidia_gpu.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ComputeUnit
|
4
|
-
module Formatters
|
5
|
-
def micro_formatter(item, add_unit = false)
|
6
|
-
data = {}
|
7
|
-
item.each do |key, value|
|
8
|
-
if %i[hourly_cost hourly_earnings kwh_cost].include?(key)
|
9
|
-
v = (value * 1000000).round(4)
|
10
|
-
data[key] = add_unit ? "#{v} \u00B5BTC" : v
|
11
|
-
end
|
12
|
-
end
|
13
|
-
item.merge(data)
|
14
|
-
end
|
15
|
-
|
16
|
-
def value_micro_formatter(value, add_unit = false)
|
17
|
-
v = (value * 1000000).round(1)
|
18
|
-
add_unit ? "#{v} \u00B5BTC" : v
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|