mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-08 21:14:14 +00:00
We already have gpu/cpu from id, so use that. Likely the current convoluted code is wrong and leading to segfaults!
This commit is contained in:
parent
18f8b0f9a5
commit
142576a961
22
cpu-miner.c
22
cpu-miner.c
@ -1378,11 +1378,11 @@ int main (int argc, char *argv[])
|
|||||||
|
|
||||||
/* start GPU mining threads */
|
/* start GPU mining threads */
|
||||||
for (i = 0; i < gpu_threads; i++) {
|
for (i = 0; i < gpu_threads; i++) {
|
||||||
int gpu = i % nDevs;
|
int gpu = gpu_from_thr_id(i);
|
||||||
|
|
||||||
thr = &thr_info[i];
|
thr = &thr_info[i];
|
||||||
thr->id = i;
|
thr->id = i;
|
||||||
if (! (i % opt_g_threads)) {
|
if (!thr->cgpu) {
|
||||||
thr->cgpu = calloc(1, sizeof(struct cgpu_info));
|
thr->cgpu = calloc(1, sizeof(struct cgpu_info));
|
||||||
if (unlikely(!thr->cgpu)) {
|
if (unlikely(!thr->cgpu)) {
|
||||||
applog(LOG_ERR, "Failed to calloc cgpu_info");
|
applog(LOG_ERR, "Failed to calloc cgpu_info");
|
||||||
@ -1391,11 +1391,13 @@ int main (int argc, char *argv[])
|
|||||||
thr->cgpu->is_gpu = 1;
|
thr->cgpu->is_gpu = 1;
|
||||||
thr->cgpu->cpu_gpu = gpu;
|
thr->cgpu->cpu_gpu = gpu;
|
||||||
} else
|
} else
|
||||||
thr->cgpu = thr_info[i - (i % opt_g_threads)].cgpu;
|
thr->cgpu = thr_info[gpu].cgpu;
|
||||||
|
|
||||||
thr->q = tq_new();
|
thr->q = tq_new();
|
||||||
if (!thr->q)
|
if (!thr->q) {
|
||||||
|
applog(LOG_ERR, "tq_new failed in starting gpu mining threads");
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
applog(LOG_INFO, "Init GPU thread %i", i);
|
applog(LOG_INFO, "Init GPU thread %i", i);
|
||||||
clStates[i] = initCl(gpu, name, sizeof(name));
|
clStates[i] = initCl(gpu, name, sizeof(name));
|
||||||
@ -1416,22 +1418,26 @@ int main (int argc, char *argv[])
|
|||||||
|
|
||||||
/* start CPU mining threads */
|
/* start CPU mining threads */
|
||||||
for (i = gpu_threads; i < gpu_threads + opt_n_threads; i++) {
|
for (i = gpu_threads; i < gpu_threads + opt_n_threads; i++) {
|
||||||
|
int cpu = cpu_from_thr_id(i);
|
||||||
|
|
||||||
thr = &thr_info[i];
|
thr = &thr_info[i];
|
||||||
|
|
||||||
thr->id = i;
|
thr->id = i;
|
||||||
if (! (i % opt_n_threads)) {
|
if (!thr->cgpu) {
|
||||||
thr->cgpu = calloc(1, sizeof(struct cgpu_info));
|
thr->cgpu = calloc(1, sizeof(struct cgpu_info));
|
||||||
if (unlikely(!thr->cgpu)) {
|
if (unlikely(!thr->cgpu)) {
|
||||||
applog(LOG_ERR, "Failed to calloc cgpu_info");
|
applog(LOG_ERR, "Failed to calloc cgpu_info");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
thr->cgpu->cpu_gpu = cpu_from_thr_id(i);
|
thr->cgpu->cpu_gpu = cpu;
|
||||||
} else
|
} else
|
||||||
thr->cgpu = thr_info[cpu_from_thr_id(i - (i % opt_n_threads))].cgpu;
|
thr->cgpu = thr_info[cpu].cgpu;
|
||||||
|
|
||||||
thr->q = tq_new();
|
thr->q = tq_new();
|
||||||
if (!thr->q)
|
if (!thr->q) {
|
||||||
|
applog(LOG_ERR, "tq_new failed in starting cpu mining threads");
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (unlikely(pthread_create(&thr->pth, NULL, miner_thread, thr))) {
|
if (unlikely(pthread_create(&thr->pth, NULL, miner_thread, thr))) {
|
||||||
applog(LOG_ERR, "thread %d create failed", i);
|
applog(LOG_ERR, "thread %d create failed", i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user