Map GPU devices to virtual devices in their true physical order based on BusNumber.
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
diff --git a/adl.c b/adl.c
index 3c6450d..373e1ee 100644
--- a/adl.c
+++ b/adl.c
@@ -364,29 +364,38 @@ void init_adl(int nDevs)
ga->lasttemp = __gpu_temp(ga);
}
- /* Search for twin GPUs on a single card. They will be separated by one
- * bus id and one will have fanspeed while the other won't. */
for (gpu = 0; gpu < devices; gpu++) {
struct gpu_adl *ga = &gpus[gpu].adl;
+ struct cgpu_info *cgpu = &gpus[gpu];
int j;
- if (ga->has_fanspeed)
- continue;
-
+ cgpu->virtual_gpu = 0;
for (j = 0; j < devices; j++) {
struct gpu_adl *other_ga;
if (j == gpu)
continue;
+
other_ga = &gpus[j].adl;
- if (fanspeed_twin(ga, other_ga)) {
- applog(LOG_INFO, "Dual GPUs detected: %d and %d",
- ga->gpu, other_ga->gpu);
- ga->twin = other_ga;
- other_ga->twin = ga;
- break;
+
+ /* Find the real GPU order based on their order
+ * according to their iBusNumber value */
+ if (other_ga->iBusNumber < ga->iBusNumber)
+ cgpu->virtual_gpu++;
+
+ /* Search for twin GPUs on a single card. They will be
+ * separated by one bus id and one will have fanspeed
+ * while the other won't. */
+ if (!ga->has_fanspeed) {
+ if (fanspeed_twin(ga, other_ga)) {
+ applog(LOG_INFO, "Dual GPUs detected: %d and %d",
+ ga->gpu, other_ga->gpu);
+ ga->twin = other_ga;
+ other_ga->twin = ga;
+ }
}
}
+ applog(LOG_INFO, "GPU %d mapped to virtual GPU %d", gpu, cgpu->virtual_gpu);
}
}
diff --git a/adl.h b/adl.h
index 50bd5b8..c7341e2 100644
--- a/adl.h
+++ b/adl.h
@@ -20,8 +20,18 @@ void change_gpusettings(int gpu);
void gpu_autotune(int gpu, bool *enable);
void clear_adl(int nDevs);
#else /* HAVE_ADL */
+#include "miner.h"
#define adl_active (0)
-static inline void init_adl(int nDevs) {}
+static inline void init_adl(int nDevs)
+{
+ int i;
+
+ for (i = 0; i < nDevs; i++) {
+ struct cgpu_info *cgpu = &gpus[i];
+
+ cgpu->virtual_gpu = i;
+ }
+}
static inline void change_gpusettings(int gpu) { }
static inline void clear_adl(int nDevs) {}
#endif
diff --git a/miner.h b/miner.h
index 88a7fd3..d91b82f 100644
--- a/miner.h
+++ b/miner.h
@@ -277,6 +277,7 @@ struct cgpu_info {
int threads;
struct thr_info *thread;
+ int virtual_gpu;
bool dynamic;
int intensity;
#ifdef HAVE_ADL