Skip to content

Commit

Permalink
Add the -n (--ndevs) option like cgminer
Browse files Browse the repository at this point in the history
  • Loading branch information
tpruvot committed Mar 27, 2015
1 parent f86784e commit 4426700
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ccminer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2010 Jeff Garzik
* Copyright 2012-2014 pooler
* Copyright 2014-2015 tpruvot
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
Expand Down Expand Up @@ -59,6 +60,7 @@ int cuda_num_devices();
void cuda_devicenames();
void cuda_devicereset();
int cuda_finddevice(char *name);
void cuda_print_devices();

#include "nvml.h"
#ifdef USE_WRAPNVML
Expand Down Expand Up @@ -283,6 +285,7 @@ Options:\n\
-T, --timeout=N network timeout, in seconds (default: 270)\n\
-s, --scantime=N upper bound on time spent scanning current work when\n\
long polling is unavailable, in seconds (default: 10)\n\
-n, --ndevs list cuda devices\n\
-N, --statsavg number of samples used to display hashrate (default: 30)\n\
--no-gbt disable getblocktemplate support (height check in solo)\n\
--no-longpoll disable X-Long-Polling support\n\
Expand Down Expand Up @@ -320,7 +323,7 @@ static char const short_options[] =
#ifdef HAVE_SYSLOG_H
"S"
#endif
"a:c:i:Dhp:Px:qr:R:s:t:T:o:u:O:Vd:f:mv:N:b:";
"a:c:i:Dhp:Px:mnqr:R:s:t:T:o:u:O:Vd:f:v:N:b:";

static struct option const options[] = {
{ "algo", 1, NULL, 'a' },
Expand All @@ -338,6 +341,7 @@ static struct option const options[] = {
{ "debug", 0, NULL, 'D' },
{ "help", 0, NULL, 'h' },
{ "intensity", 1, NULL, 'i' },
{ "ndevs", 0, NULL, 'n' },
{ "no-color", 0, NULL, 1002 },
{ "no-gbt", 0, NULL, 1011 },
{ "no-longpoll", 0, NULL, 1003 },
Expand Down Expand Up @@ -2028,6 +2032,10 @@ void parse_arg(int key, char *arg)
opt_statsavg = INT_MAX;
opt_statsavg = v;
break;
case 'n': /* --ndevs */
cuda_print_devices();
proper_exit(0);
break;
case 'q':
opt_quiet = true;
break;
Expand Down
12 changes: 12 additions & 0 deletions cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ void cuda_devicenames()
}
}

void cuda_print_devices()
{
int ngpus = cuda_num_devices();
for (int n=0; n < ngpus; n++) {
int m = device_map[n];
cudaDeviceProp props;
cudaGetDeviceProperties(&props, m);
if (!opt_n_threads || n < opt_n_threads)
fprintf(stderr, "GPU #%d: SM %d.%d %s\n", m, props.major, props.minor, props.name);
}
}

// Can't be called directly in cpu-miner.c
void cuda_devicereset()
{
Expand Down

0 comments on commit 4426700

Please sign in to comment.