diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-06-12 13:45:23 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-10-07 19:19:30 +0800 |
commit | ec6a548ee3555813d83f86f82bd25694bfd9c303 (patch) | |
tree | 9d0ec5022dc952f7b1053b85382df07347bc48f0 /cmd | |
parent | 8b865fa9bf75e728d5d76f5a1460e0c37d8b5f9e (diff) | |
download | go-tangerine-ec6a548ee3555813d83f86f82bd25694bfd9c303.tar.gz go-tangerine-ec6a548ee3555813d83f86f82bd25694bfd9c303.tar.zst go-tangerine-ec6a548ee3555813d83f86f82bd25694bfd9c303.zip |
all: Add GPU mining, disabled by default
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/geth/js_test.go | 3 | ||||
-rw-r--r-- | cmd/geth/main.go | 45 | ||||
-rw-r--r-- | cmd/utils/flags.go | 6 |
3 files changed, 51 insertions, 3 deletions
diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index 1f5b28e3a..7b3bb09a8 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -468,8 +468,7 @@ func processTxs(repl *testjethre, t *testing.T, expTxc int) bool { t.Errorf("incorrect number of pending transactions, expected %v, got %v", expTxc, txc) return false } - - err = repl.ethereum.StartMining(runtime.NumCPU()) + err = repl.ethereum.StartMining(runtime.NumCPU(), "") if err != nil { t.Errorf("unexpected error mining: %v", err) return false diff --git a/cmd/geth/main.go b/cmd/geth/main.go index a9aa9f61f..ec61dedff 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -107,6 +107,22 @@ Regular users do not need to execute it. `, }, { + Action: gpuinfo, + Name: "gpuinfo", + Usage: "gpuinfo", + Description: ` +Prints OpenCL device info for all found GPUs. +`, + }, + { + Action: gpubench, + Name: "gpubench", + Usage: "benchmark GPU", + Description: ` +Runs quick benchmark on first GPU found. +`, + }, + { Action: version, Name: "version", Usage: "print ethereum version numbers", @@ -298,6 +314,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.GasPriceFlag, utils.MinerThreadsFlag, utils.MiningEnabledFlag, + utils.MiningGPUFlag, utils.AutoDAGFlag, utils.NATFlag, utils.NatspecEnabledFlag, @@ -586,7 +603,10 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) { } } if ctx.GlobalBool(utils.MiningEnabledFlag.Name) { - if err := eth.StartMining(ctx.GlobalInt(utils.MinerThreadsFlag.Name)); err != nil { + err := eth.StartMining( + ctx.GlobalInt(utils.MinerThreadsFlag.Name), + ctx.GlobalString(utils.MiningGPUFlag.Name)) + if err != nil { utils.Fatalf("%v", err) } } @@ -740,6 +760,29 @@ func makedag(ctx *cli.Context) { } } +func gpuinfo(ctx *cli.Context) { + eth.PrintOpenCLDevices() +} + +func gpubench(ctx *cli.Context) { + args := ctx.Args() + wrongArgs := func() { + utils.Fatalf(`Usage: geth gpubench <gpu number>`) + } + switch { + case len(args) == 1: + n, err := strconv.ParseUint(args[0], 0, 64) + if err != nil { + wrongArgs() + } + eth.GPUBench(n) + case len(args) == 0: + eth.GPUBench(0) + default: + wrongArgs() + } +} + func version(c *cli.Context) { fmt.Println(ClientIdentifier) fmt.Println("Version:", Version) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index ad474f17d..a5395424a 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -149,6 +149,12 @@ var ( } // miner settings + // TODO: refactor CPU vs GPU mining flags + MiningGPUFlag = cli.StringFlag{ + Name: "minegpu", + Usage: "Mine with given GPUs. '--minegpu 0,1' will mine with the first two GPUs found.", + } + MinerThreadsFlag = cli.IntFlag{ Name: "minerthreads", Usage: "Number of miner threads", |