compute_unit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5caf721411458c1307f2714ba330c737ddd5987433a51d7753b6004649a92429
4
+ data.tar.gz: ef3bacd1c4662e1ffe33dafad9c48f44c6fc3cefe161098957cc476e7ecac78d
5
+ SHA512:
6
+ metadata.gz: 73b107433ce4ffcb3d6a5d35a8711cf39489ed111ccc368cb66d5f788f36690382242a3437c0bd6d40147c2ca727856d2fffd48b8b5edbaa8f4dd22b5ab228da
7
+ data.tar.gz: 2debc1c284e7200efd00ca0e064d3b48f55a935d55409cc77f33db2db9344efabcdaadc3cd2bfd909174e58ba38727ed4ed845dad0395a19e08dc5ee0f54a428
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ Gemfile.lock
3
+ pci.ids
4
+ /.yardoc
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
@@ -0,0 +1,45 @@
1
+ # This file is a template, and might need editing before it works on your project.
2
+ # Official language image. Look for the different tagged releases at:
3
+ # https://hub.docker.com/r/library/ruby/tags/
4
+ image: "ruby:2.6"
5
+
6
+ # Cache gems in between builds
7
+ cache:
8
+ paths:
9
+ - vendor/ruby
10
+
11
+ before_script:
12
+ - ruby -v # Print out ruby version for debugging
13
+ - gem update bundler
14
+ - bundle install -j $(nproc) --path vendor # Install dependencies into ./vendor/ruby
15
+
16
+ # Optional - Delete if not using `rubocop`
17
+ rubocop:
18
+ allow_failure: true
19
+ script:
20
+ - bundle exec rubocop
21
+
22
+ rspec2_5:
23
+ image: "ruby:2.5"
24
+ script:
25
+ - bundle exec rake spec
26
+
27
+ rspec2_6:
28
+ image: "ruby:2.6"
29
+ script:
30
+ - bundle exec rake spec
31
+
32
+ rspec2_7:
33
+ image: "ruby:2.7"
34
+ script:
35
+ - bundle exec rake spec
36
+
37
+ # This deploy job uses a simple deploy flow to Heroku, other providers, e.g. AWS Elastic Beanstalk
38
+ # are supported too: https://github.com/travis-ci/dpl
39
+ deploy:
40
+ when: manual
41
+ type: deploy
42
+ environment: production
43
+ script:
44
+ - gem install dpl
45
+ #- dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_PRODUCTION_KEY
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,12 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ # The behavior of RuboCop can be controlled via the .rubocop.yml
4
+ # configuration file. It makes it possible to enable/disable
5
+ # certain cops (checks) and to alter their behavior if they accept
6
+ # any parameters. The file can be placed either in your home
7
+ # directory or in some project directory.
8
+ #
9
+ # RuboCop will start looking for the configuration file in the directory
10
+ # where the inspected file is and continue its way up to the root directory.
11
+ #
12
+ # See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
@@ -0,0 +1,139 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2019-12-14 19:23:33 -0800 using RuboCop version 0.77.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ # Layout/CommentIndentation:
12
+ # Exclude:
13
+ # - 'lib/compute_unit/device.rb'
14
+
15
+ # Offense count: 1
16
+ # Cop supports --auto-correct.
17
+ # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
18
+ # Layout/ExtraSpacing:
19
+ # Exclude:
20
+ # - 'compute_unit.gemspec'
21
+
22
+ # Offense count: 2
23
+ # Cop supports --auto-correct.
24
+ # Configuration parameters: EnforcedStyle.
25
+ # SupportedStyles: normal, indented_internal_methods
26
+ # Layout/IndentationConsistency:
27
+ # Exclude:
28
+ # - 'lib/compute_unit/device.rb'
29
+ # - 'lib/compute_unit/gpu.rb'
30
+
31
+ # Offense count: 2
32
+ # Cop supports --auto-correct.
33
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
34
+ # SupportedStyles: aligned, indented
35
+ Layout/MultilineOperationIndentation:
36
+ Exclude:
37
+ - 'lib/compute_unit.rb'
38
+
39
+ # Offense count: 5
40
+ Lint/DuplicateMethods:
41
+ Exclude:
42
+ - 'lib/compute_unit/compute_base.rb'
43
+ - 'lib/compute_unit/device.rb'
44
+ - 'lib/compute_unit/gpu.rb'
45
+
46
+ # Offense count: 1
47
+ Lint/UnreachableCode:
48
+ Exclude:
49
+ - 'lib/compute_unit/cpu.rb'
50
+
51
+ # Offense count: 9
52
+ Metrics/AbcSize:
53
+ Max: 27
54
+
55
+ # Offense count: 4
56
+ # Configuration parameters: CountComments.
57
+ Metrics/ClassLength:
58
+ Max: 290
59
+
60
+ # Offense count: 12
61
+ # Configuration parameters: CountComments, ExcludedMethods.
62
+ Metrics/MethodLength:
63
+ Max: 32
64
+
65
+ # Offense count: 2
66
+ # Configuration parameters: EnforcedStyleForLeadingUnderscores.
67
+ # SupportedStylesForLeadingUnderscores: disallowed, required, optional
68
+ Naming/MemoizedInstanceVariableName:
69
+ Exclude:
70
+ - 'lib/compute_unit/gpus/amd_gpu.rb'
71
+
72
+ # Offense count: 1
73
+ # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
74
+ # AllowedNames: io, id, to, by, on, in, at, ip, db, os
75
+ Naming/MethodParameterName:
76
+ Exclude:
77
+ - 'lib/compute_unit/device.rb'
78
+
79
+ # Offense count: 8
80
+ Style/Documentation:
81
+ Exclude:
82
+ - 'spec/**/*'
83
+ - 'test/**/*'
84
+ - 'lib/compute_unit.rb'
85
+ - 'lib/compute_unit/asic.rb'
86
+ - 'lib/compute_unit/compute_base.rb'
87
+ - 'lib/compute_unit/cpu.rb'
88
+ - 'lib/compute_unit/device.rb'
89
+ - 'lib/compute_unit/gpu.rb'
90
+ - 'lib/compute_unit/gpus/amd_gpu.rb'
91
+ - 'lib/compute_unit/gpus/nvidia_gpu.rb'
92
+
93
+ # Offense count: 1
94
+ # Cop supports --auto-correct.
95
+ Style/ExpandPathArguments:
96
+ Exclude:
97
+ - 'compute_unit.gemspec'
98
+
99
+ # Offense count: 5
100
+ # Cop supports --auto-correct.
101
+ # Configuration parameters: EnforcedStyle.
102
+ # SupportedStyles: always, never
103
+
104
+ # Offense count: 1
105
+ # Cop supports --auto-correct.
106
+ # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
107
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
108
+ # Style/HashSyntax:
109
+ # Exclude:
110
+ # - 'Rakefile'
111
+
112
+ # Offense count: 4
113
+ # Cop supports --auto-correct.
114
+ # Configuration parameters: Strict.
115
+ Style/NumericLiterals:
116
+ MinDigits: 8
117
+
118
+ # Offense count: 4
119
+ # Cop supports --auto-correct.
120
+ # Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
121
+ # SupportedStyles: predicate, comparison
122
+ Style/NumericPredicate:
123
+ Exclude:
124
+ - 'spec/**/*'
125
+ - 'lib/compute_unit/gpus/amd_gpu.rb'
126
+
127
+ # Offense count: 11
128
+ # Cop supports --auto-correct.
129
+ # Configuration parameters: .
130
+ # SupportedStyles: compact, exploded
131
+ Style/RaiseArgs:
132
+ EnforcedStyle: compact
133
+
134
+ # Offense count: 87
135
+ # Cop supports --auto-correct.
136
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
137
+ # URISchemes: http, https
138
+ Metrics/LineLength:
139
+ Max: 273
@@ -0,0 +1 @@
1
+ 2.6.5
@@ -0,0 +1,3 @@
1
+ # Compute Unit Changelog
2
+
3
+ ## initial version 0.1.0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at opselite@protonmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+
6
+ gem 'opencl_ruby_ffi', '~> 1.3.4'
7
+ gem 'compute_unit', path: '.'
8
+
9
+ group :test do
10
+ gem 'pry'
11
+ gem 'rubocop'
12
+ gem 'rubocop-rspec'
13
+ gem 'ruby-prof'
14
+ gem 'simplecov'
15
+ gem 'rake', '~> 10.0'
16
+ gem 'rspec', '~> 3.0'
17
+ gem 'bundler', '~> 2.0'
18
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Corey Osman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,74 @@
1
+ # Compute Unit Ruby Library
2
+ The compute unit library helps you write future abstractions and tooling for crypto mining, machine learning or just general purpose usage. This library was extracted out of the crypto mining tool [Crossbelt](https://crossbelt.blockops.party) to help spur more tooling to ruby.
3
+
4
+ Uses the sysfs filesystem to quickly read and write compute unit data. More information about sysfs can be found [here](https://www.kernel.org/doc/Documentation/filesystems/sysfs-pci.txt)
5
+
6
+ This library will:
7
+
8
+ * Detect all compute devices such as cpu, gpu, and anything else we add to this library.
9
+ * Provide the ability to control GPU fans.
10
+ * Get temperature of units.
11
+ * Change or view voltage, core clock, memory clock and other tunning parameters used for overclocking.
12
+ * Provide inventory data of all the devices with make, model and other important information.
13
+ * Provide realtime status information of various data points. Useful for real-time tunning.
14
+
15
+ This library was open sourced to allow further refinement and usage throughout the ruby community.
16
+ Since machine learning is not popular on ruby due to device and program support, I hope this gem will
17
+ make ML and crypto more viable for ruby.
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'compute_unit'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install compute_unit
34
+
35
+ ## Usage
36
+
37
+ ```
38
+ require 'compute_unit'
39
+ devices = ComputeUnit.find_all
40
+
41
+ ```
42
+
43
+
44
+ ## Make and Model information
45
+ This library uses the pci database maintained here https://pci-ids.ucw.cz/ which is also used by `lspci` and other linux tools. If your device is giving the wrong info the problem is likely due to the database being incorrect.
46
+
47
+ You can also manually refresh the pci database file programmatically via `ComputeUnit.refresh_pci_database`
48
+
49
+ If you want to refresh the database every time with finding all the devices you can use: `ComputeUnit.find_all_with_database`
50
+
51
+ Or you can also run the simple cli tool. `update_pcidb` that comes with this library.
52
+
53
+ ## Kernel support
54
+ There will likely be changes with reading and writing information to sysfs as new kerneles are released. This library has been tested against.
55
+
56
+ * 4.15 - 4.20
57
+
58
+ ## Development
59
+
60
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
61
+
62
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/logicminds/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.
67
+
68
+ ## License
69
+
70
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
71
+
72
+ ## Code of Conduct
73
+
74
+ Everyone interacting in the ComputeUnit project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/logicminds/compute_unit/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'compute_unit'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)