Define max gpudevices in one macro.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
diff --git a/main.c b/main.c
index adf1e51..6e236a8 100644
--- a/main.c
+++ b/main.c
@@ -210,7 +210,7 @@ static int nDevs;
static int opt_g_threads = 2;
static int opt_device;
static int total_devices;
-static bool gpu_devices[16];
+static bool gpu_devices[MAX_GPUDEVICES];
static int gpu_threads;
static bool forced_n_threads;
static int opt_n_threads;
@@ -1146,7 +1146,7 @@ static char *set_gpu_engine(char *arg)
}
if (device == 1) {
- for (i = 1; i < 16; i++) {
+ for (i = 1; i < MAX_GPUDEVICES; i++) {
gpus[i].min_engine = gpus[0].min_engine;
gpus[i].gpu_engine = gpus[0].gpu_engine;
}
@@ -1182,7 +1182,7 @@ static char *set_gpu_fan(char *arg)
}
if (device == 1) {
- for (i = 1; i < 16; i++) {
+ for (i = 1; i < MAX_GPUDEVICES; i++) {
gpus[i].min_fan = gpus[0].min_fan;
gpus[i].gpu_fan = gpus[0].gpu_fan;
}
@@ -1212,8 +1212,10 @@ static char *set_gpu_memclock(char *arg)
gpus[device++].gpu_memclock = val;
}
- for (i = device; i < 16; i++)
- gpus[i].gpu_memclock = val;
+ if (device == 1) {
+ for (i = device; i < MAX_GPUDEVICES; i++)
+ gpus[i].gpu_memclock = gpus[0].gpu_memclock;
+ }
return NULL;
}
@@ -1239,8 +1241,10 @@ static char *set_gpu_powertune(char *arg)
gpus[device++].gpu_powertune = val;
}
- for (i = device; i < 16; i++)
- gpus[i].gpu_powertune = val;
+ if (device == 1) {
+ for (i = device; i < MAX_GPUDEVICES; i++)
+ gpus[i].gpu_powertune = gpus[0].gpu_powertune;
+ }
return NULL;
}
@@ -1267,8 +1271,10 @@ static char *set_gpu_vddc(char *arg)
gpus[device++].gpu_vddc = val;
}
- for (i = device; i < 16; i++)
- gpus[i].gpu_vddc = val;
+ if (device == 1) {
+ for (i = device; i < MAX_GPUDEVICES; i++)
+ gpus[i].gpu_vddc = gpus[0].gpu_vddc;
+ }
return NULL;
}
@@ -1297,7 +1303,7 @@ static char *set_temp_cutoff(char *arg)
*tco = val;
}
if (device == 1) {
- for (i = device; i < 16; i++) {
+ for (i = device; i < MAX_GPUDEVICES; i++) {
tco = &gpus[i].adl.cutofftemp;
*tco = val;
}
@@ -1330,7 +1336,7 @@ static char *set_temp_overheat(char *arg)
*to = val;
}
if (device == 1) {
- for (i = device; i < 16; i++) {
+ for (i = device; i < MAX_GPUDEVICES; i++) {
to = &gpus[i].adl.overtemp;
*to = val;
}
@@ -1363,7 +1369,7 @@ static char *set_temp_target(char *arg)
*tt = val;
}
if (device == 1) {
- for (i = device; i < 16; i++) {
+ for (i = device; i < MAX_GPUDEVICES; i++) {
tt = &gpus[i].adl.targettemp;
*tt = val;
}
@@ -1771,7 +1777,7 @@ static WINDOW *mainwin, *statuswin, *logwin;
static double total_secs = 0.1;
static char statusline[256];
static int cpucursor, gpucursor, logstart, logcursor;
-struct cgpu_info gpus[16]; /* Maximum number apparently possible */
+struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */
static struct cgpu_info *cpus;
static inline void unlock_curses(void)
@@ -3980,7 +3986,7 @@ enum {
};
#ifdef HAVE_OPENCL
-static _clState *clStates[16];
+static _clState *clStates[MAX_GPUDEVICES];
static cl_int queue_poclbm_kernel(_clState *clState, dev_blk_ctx *blk)
{
@@ -5141,7 +5147,7 @@ int main (int argc, char *argv[])
#ifdef HAVE_OPENCL
if (!skip_to_bench) {
- for (i = 0; i < 16; i++)
+ for (i = 0; i < MAX_GPUDEVICES; i++)
gpu_devices[i] = false;
nDevs = clDevicesNum();
if (nDevs < 0) {
@@ -5224,7 +5230,7 @@ int main (int argc, char *argv[])
if (total_devices) {
if (total_devices > nDevs)
quit(1, "More devices specified than exist");
- for (i = 0; i < 16; i++)
+ for (i = 0; i < MAX_GPUDEVICES; i++)
if (gpu_devices[i] && i + 1 > nDevs)
quit (1, "Command line options set a device that doesn't exist");
} else {
diff --git a/miner.h b/miner.h
index 97d0d4e..378f004 100644
--- a/miner.h
+++ b/miner.h
@@ -377,12 +377,15 @@ struct work_restart {
char padding[128 - sizeof(unsigned long)];
};
+
+#define MAX_GPUDEVICES 16
+
extern int hw_errors;
extern bool use_syslog;
extern struct thr_info *thr_info;
extern int longpoll_thr_id;
extern struct work_restart *work_restart;
-extern struct cgpu_info gpus[16];
+extern struct cgpu_info gpus[MAX_GPUDEVICES];
#ifdef HAVE_OPENCL
typedef struct {