decred / gominer

Go (golang) based GPU miner for Decred.
GNU General Public License v3.0
162 stars 80 forks source link

add automatic fan control to maintain a target temperature #115

Closed jolan closed 8 years ago

jolan commented 8 years ago

This is a rough implementation of automatic fan control to maintain a target temperature that closes #104. (Will open a new issue for tracking improvements) I just wanted to get this PR'd since the diff is getting huge. I've wrapped this behind an --experimental flag so it's clear that it's not ready for prime time.

Main items done:

TODO items:

Example ADL run with target of 75 degrees:

16:10:26 2016-09-27 [INF] MAIN: Version 0.4.1-beta OpenCL ADL 16:10:26 2016-09-27 [INF] POOL: Using pool: stratum+tcp://dcr.coinmine.pl:2222 16:10:26 2016-09-27 [INF] POOL: Stratum difficulty set to 16 16:10:29 2016-09-27 [INF] MINR: DEV #1: Work size set to 869107712 ('intensity' 29.69495974619433) 16:10:29 2016-09-27 [INF] MINR: Global stats: Accepted: 0, Rejected: 0, Stale: 0, Total: 0 16:10:29 2016-09-27 [INF] MINR: Started DEV #1: Hawaii 16:10:29 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 0H/s Fan=28% T=66C 16:10:29 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 28% to 18% to raise temp 16:10:29 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 28% to 23% to raise temp 16:10:34 2016-09-27 [INF] MINR: Global stats: Accepted: 0, Rejected: 0, Stale: 0, Total: 0 16:10:34 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 716MH/s Fan=23% T=69C 16:10:34 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 23% to 18% to raise temp 16:10:39 2016-09-27 [INF] MINR: Global stats: Accepted: 0, Rejected: 0, Stale: 0, Total: 0 16:10:39 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 781MH/s Fan=18% T=70C 16:10:39 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 18% to 13% to raise temp 16:10:44 2016-09-27 [INF] MINR: Global stats: Accepted: 0, Rejected: 0, Stale: 0, Total: 0 16:10:44 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 537MH/s Fan=13% T=71C 16:10:44 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 13% to 8% to raise temp 16:10:49 2016-09-27 [INF] MINR: Global stats: Accepted: 0, Rejected: 0, Stale: 0, Total: 0 16:10:49 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 818MH/s Fan=8% T=72C 16:10:54 2016-09-27 [INF] MINR: Global stats: Accepted: 0, Rejected: 0, Stale: 0, Total: 0 16:10:54 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 661MH/s Fan=8% T=74C 16:10:59 2016-09-27 [INF] MINR: Global stats: Accepted: 0, Rejected: 0, Stale: 0, Total: 0 16:10:59 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 831MH/s Fan=8% T=75C 16:11:04 2016-09-27 [INF] MINR: Global stats: Accepted: 0, Rejected: 0, Stale: 0, Total: 0 16:11:04 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 716MH/s Fan=8% T=77C 16:11:09 2016-09-27 [INF] MINR: Global stats: Accepted: 0, Rejected: 0, Stale: 0, Total: 0 16:11:09 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 943MH/s Fan=8% T=78C 16:11:11 2016-09-27 [INF] MINR: DEV #1 Found hash with work below target! 000000000b99912e3f4c1d556fef19de637c3049ae18ae661f8204fb078efa3c (yay) 16:11:11 2016-09-27 [INF] MINR: Global stats: Accepted: 0, Rejected: 0, Stale: 0, Total: 0 16:11:11 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.099GH/s Fan=8% T=79C 16:11:11 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 8% to 13% to lower temp 16:11:11 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 8% to 13% to lower temp 16:11:14 2016-09-27 [INF] MINR: Global stats: Accepted: 1, Rejected: 0, Stale: 0, Total: 1 16:11:14 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.027GH/s Fan=13% T=80C 16:11:14 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 13% to 18% to lower temp 16:11:19 2016-09-27 [INF] MINR: Global stats: Accepted: 1, Rejected: 0, Stale: 0, Total: 1 16:11:19 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.179GH/s Fan=18% T=80C 16:11:19 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 18% to 23% to lower temp 16:11:24 2016-09-27 [INF] MINR: Global stats: Accepted: 1, Rejected: 0, Stale: 0, Total: 1 16:11:24 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.381GH/s Fan=23% T=81C 16:11:24 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 23% to 28% to lower temp 16:11:29 2016-09-27 [INF] MINR: Global stats: Accepted: 1, Rejected: 0, Stale: 0, Total: 1 16:11:29 2016-09-27 [INF] MINR: Global utility (accepted shares/min): 1 16:11:29 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.479GH/s Fan=28% T=81C 16:11:29 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 28% to 33% to lower temp 16:11:34 2016-09-27 [INF] MINR: Global stats: Accepted: 1, Rejected: 0, Stale: 0, Total: 1 16:11:34 2016-09-27 [INF] MINR: Global utility (accepted shares/min): 0.9230769230769231 16:11:34 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.627GH/s Fan=33% T=81C 16:11:34 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 33% to 38% to lower temp 16:11:39 2016-09-27 [INF] MINR: Global stats: Accepted: 1, Rejected: 0, Stale: 0, Total: 1 16:11:39 2016-09-27 [INF] MINR: Global utility (accepted shares/min): 0.8571428571428571 16:11:39 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.573GH/s Fan=38% T=81C 16:11:39 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 38% to 43% to lower temp 16:11:44 2016-09-27 [INF] MINR: Global stats: Accepted: 1, Rejected: 0, Stale: 0, Total: 1 16:11:44 2016-09-27 [INF] MINR: Global utility (accepted shares/min): 0.8 16:11:44 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.582GH/s Fan=43% T=80C 16:11:44 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 43% to 48% to lower temp 16:11:49 2016-09-27 [INF] MINR: Global stats: Accepted: 1, Rejected: 0, Stale: 0, Total: 1 16:11:49 2016-09-27 [INF] MINR: Global utility (accepted shares/min): 0.75 16:11:49 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.538GH/s Fan=48% T=79C 16:11:49 2016-09-27 [INF] MINR: DEV #1 successfully adjusted fan from 48% to 53% to lower temp 16:11:54 2016-09-27 [INF] MINR: Global stats: Accepted: 1, Rejected: 0, Stale: 0, Total: 1 16:11:54 2016-09-27 [INF] MINR: Global utility (accepted shares/min): 0.7058823529411764 16:11:54 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.548GH/s Fan=53% T=78C 16:11:59 2016-09-27 [INF] MINR: Global stats: Accepted: 1, Rejected: 0, Stale: 0, Total: 1 16:11:59 2016-09-27 [INF] MINR: Global utility (accepted shares/min): 0.6666666666666666 16:11:59 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.510GH/s Fan=53% T=77C 16:12:02 2016-09-27 [INF] MINR: DEV #1 Found hash with work below target! 00000000033b51a224c011b9484e509a5187a19d82b802abded008ef1a55b899 (yay) 16:12:02 2016-09-27 [INF] MINR: Global stats: Accepted: 1, Rejected: 0, Stale: 0, Total: 1 16:12:02 2016-09-27 [INF] MINR: Global utility (accepted shares/min): 0.6451612903225806 16:12:02 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.508GH/s Fan=53% T=77C 16:12:04 2016-09-27 [INF] MINR: Global stats: Accepted: 2, Rejected: 0, Stale: 0, Total: 2 16:12:04 2016-09-27 [INF] MINR: Global utility (accepted shares/min): 1.2631578947368423 16:12:04 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.476GH/s Fan=53% T=76C 16:12:09 2016-09-27 [INF] MINR: Global stats: Accepted: 2, Rejected: 0, Stale: 0, Total: 2 16:12:09 2016-09-27 [INF] MINR: Global utility (accepted shares/min): 1.2 16:12:09 2016-09-27 [INF] MINR: DEV #1 (Hawaii) 1.488GH/s Fan=53% T=75C

jcvernaleo commented 8 years ago

Could you point out in the help which options (-t) are only allowed with --experimental?

jcvernaleo commented 8 years ago
12:50:38 2016-09-27 [ERR] MINR: ignoring temperature target of 82 for device #0; fan control is not supported on device kind Unknown

I kind of think it should abort at that point rather than ignoring an option that cannot work (that is when built with the opencl tag so no fan control possible.

marcopeereboom commented 8 years ago

Overall this code seems pretty hacky. I actively dislike using sysfs the way we are since it is incompatible with windows and changes willy-nilly.

Functions are long and hard to read. Splitting some of this code up may help readability.

jolan commented 8 years ago

@jcvernaleo I fixed both things you mentioned.

@marcopeereboom AMD used to have a unified-ish driver for Linux/Windows and the AMD Display Library (ADL) SDK worked on both platforms for many years. That driver is now deprecated on Linux (last release December 2015) in favor of AMDGPU. So now using the sysfs functionality of AMDGPU is the only supported way to do fan control on Linux.

jolan commented 8 years ago

These are Linux-only paths so I don't see any advantages to using filepath.

I've cleaned it up a bunch to address comments and some things I noticed myself. Successfully re-tested to make sure I didn't break anything.

jolan commented 8 years ago

OK, got all the stragglers dealt with now.