From be73cd1ae0c68dadc08947a12d34bc61f2a72556 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Thu, 3 Dec 2015 14:57:09 +0100 Subject: [PATCH] improve the device mapping and a possible segfault when using -n, work_restart array was not allocated --- README.txt | 5 ++++- ccminer.cpp | 2 +- configure.ac | 2 +- cpuminer-config.h | 6 +++--- cuda.cpp | 25 +++++++++++++------------ scrypt-jane.cpp | 3 +-- scrypt.cpp | 3 +-- 7 files changed, 24 insertions(+), 22 deletions(-) diff --git a/README.txt b/README.txt index b320a58..00faf83 100644 --- a/README.txt +++ b/README.txt @@ -1,5 +1,5 @@ -ccMiner release 1.7.0 (Nov 2015) "Mining Diff & basic MultiAlgo" +ccMiner release 1.7.1 (Dec 2015) "Mining Diff & basic MultiAlgo" --------------------------------------------------------------- *************************************************************** @@ -231,6 +231,9 @@ features. >>> RELEASE HISTORY <<< + Dec. 03th 2015 v1.7.1 + Small bug fixes about device ids mapping (and vendor names) + Nov. 06th 2015 v1.7 Improve old devices compatibility (x11, lyra2v2, quark, qubit...) Add windows support for SM 2.1 and drop SM 3.5 (x86) diff --git a/ccminer.cpp b/ccminer.cpp index ab52139..be73088 100644 --- a/ccminer.cpp +++ b/ccminer.cpp @@ -1415,7 +1415,7 @@ void restart_threads(void) if (opt_debug && !opt_quiet) applog(LOG_DEBUG,"%s", __FUNCTION__); - for (int i = 0; i < opt_n_threads; i++) + for (int i = 0; i < opt_n_threads && work_restart; i++) work_restart[i].restart = 1; } diff --git a/configure.ac b/configure.ac index 8001fdf..438a11e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([ccminer], [1.7]) +AC_INIT([ccminer], [1.7.1]) AC_PREREQ([2.59c]) AC_CANONICAL_SYSTEM diff --git a/cpuminer-config.h b/cpuminer-config.h index ce9cced..5b29661 100644 --- a/cpuminer-config.h +++ b/cpuminer-config.h @@ -162,7 +162,7 @@ #define PACKAGE_NAME "ccminer" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "ccminer 1.7" +#define PACKAGE_STRING "ccminer 1.7.1" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "ccminer" @@ -171,7 +171,7 @@ #define PACKAGE_URL "http://github.com/tpruvot/ccminer" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.7" +#define PACKAGE_VERSION "1.7.1" /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be @@ -185,7 +185,7 @@ #define STDC_HEADERS 1 /* Version number of package */ -#define VERSION "1.7" +#define VERSION "1.7.1" /* Define curl_free() as free() if our version of curl lacks curl_free. */ /* #undef curl_free */ diff --git a/cuda.cpp b/cuda.cpp index deb58f6..0186ce2 100644 --- a/cuda.cpp +++ b/cuda.cpp @@ -68,25 +68,26 @@ void cuda_devicenames() for (int i=0; i < GPU_N; i++) { char vendorname[32] = { 0 }; + int dev_id = device_map[i]; cudaDeviceProp props; - cudaGetDeviceProperties(&props, device_map[i]); + cudaGetDeviceProperties(&props, dev_id); - device_sm[i] = (props.major * 100 + props.minor * 10); + device_sm[dev_id] = (props.major * 100 + props.minor * 10); - if (device_name[i]) { - free(device_name[i]); - device_name[i] = NULL; + if (device_name[dev_id]) { + free(device_name[dev_id]); + device_name[dev_id] = NULL; } #ifdef USE_WRAPNVML if (gpu_vendor((uint8_t)props.pciBusID, vendorname) > 0 && strlen(vendorname)) { - device_name[i] = (char*) calloc(1, strlen(vendorname) + strlen(props.name) + 2); + device_name[dev_id] = (char*) calloc(1, strlen(vendorname) + strlen(props.name) + 2); if (!strncmp(props.name, "GeForce ", 8)) - sprintf(device_name[i], "%s %s", vendorname, &props.name[8]); + sprintf(device_name[dev_id], "%s %s", vendorname, &props.name[8]); else - sprintf(device_name[i], "%s %s", vendorname, props.name); + sprintf(device_name[dev_id], "%s %s", vendorname, props.name); } else #endif - device_name[i] = strdup(props.name); + device_name[dev_id] = strdup(props.name); } } @@ -95,11 +96,11 @@ void cuda_print_devices() int ngpus = cuda_num_devices(); cuda_devicenames(); for (int n=0; n < ngpus; n++) { - int m = device_map[n % MAX_GPUS]; + int dev_id = device_map[n % MAX_GPUS]; cudaDeviceProp props; - cudaGetDeviceProperties(&props, m); + cudaGetDeviceProperties(&props, dev_id); if (!opt_n_threads || n < opt_n_threads) { - fprintf(stderr, "GPU #%d: SM %d.%d %s\n", m, props.major, props.minor, device_name[n]); + fprintf(stderr, "GPU #%d: SM %d.%d %s\n", dev_id, props.major, props.minor, device_name[dev_id]); } } } diff --git a/scrypt-jane.cpp b/scrypt-jane.cpp index f49e950..070092d 100644 --- a/scrypt-jane.cpp +++ b/scrypt-jane.cpp @@ -638,8 +638,7 @@ int scanhash_scrypt_jane(int thr_id, struct work *work, uint32_t max_nonce, unsi gettimeofday(tv_end, NULL); return 1; } else { - applog(LOG_WARNING, "GPU #%d: %s result does not validate on CPU! (i=%d, s=%d)", - device_map[thr_id], device_name[thr_id], i, cur); + gpulog(LOG_WARNING, thr_id, "result does not validate on CPU! (i=%d, s=%d)", i, cur); } } } diff --git a/scrypt.cpp b/scrypt.cpp index 9483cd7..5dd3f27 100644 --- a/scrypt.cpp +++ b/scrypt.cpp @@ -932,8 +932,7 @@ int scanhash_scrypt(int thr_id, struct work *work, uint32_t max_nonce, unsigned } if (!good) { - applog(LOG_WARNING, "GPU #%d: %s result does not validate on CPU! (i=%d, s=%d)", - device_map[thr_id], device_name[thr_id], i, cur); + gpulog(LOG_WARNING, thr_id, "result does not validate on CPU! (i=%d, s=%d)", i, cur); } else { *hashes_done = n - pdata[19]; work_set_target_ratio(work, refhash);