mirror of
https://github.com/GOSTSec/ccminer
synced 2025-08-26 13:51:51 +00:00
add gpulog() function helper, simple and multi-threads
when using multiple cpu threads per gpu, use the T prefix, ex: [2015-10-11 09:52:49] GPU #0: app clocks set to P0 (3600/1228) vs [2015-10-11 09:52:51] GPU T0: MSI GTX 960, 5953.35 kH/s Only thr_id is required, the function take care of the dev id
This commit is contained in:
parent
58c0bb5c02
commit
8fbfe2cfda
@ -68,7 +68,7 @@ bool bench_algo_switch_next(int thr_id)
|
|||||||
char rate[32] = { 0 };
|
char rate[32] = { 0 };
|
||||||
double hashrate = stats_get_speed(thr_id, thr_hashrates[thr_id]);
|
double hashrate = stats_get_speed(thr_id, thr_hashrates[thr_id]);
|
||||||
format_hashrate(hashrate, rate);
|
format_hashrate(hashrate, rate);
|
||||||
applog(LOG_NOTICE, "GPU #%d: %s hashrate = %s", dev_id, algo_names[prev_algo], rate);
|
gpulog(LOG_NOTICE, thr_id, "%s hashrate = %s", algo_names[prev_algo], rate);
|
||||||
|
|
||||||
// free current algo memory and track mem usage
|
// free current algo memory and track mem usage
|
||||||
mused = cuda_available_memory(thr_id);
|
mused = cuda_available_memory(thr_id);
|
||||||
@ -77,8 +77,8 @@ bool bench_algo_switch_next(int thr_id)
|
|||||||
|
|
||||||
// check if there is memory leak
|
// check if there is memory leak
|
||||||
if (device_mem_free[thr_id] > mfree) {
|
if (device_mem_free[thr_id] > mfree) {
|
||||||
applog(LOG_WARNING, "GPU #%d, memory leak detected in %s ! %d MB free",
|
gpulog(LOG_WARNING, thr_id, "memory leak detected in %s ! %d MB free",
|
||||||
dev_id, algo_names[prev_algo], mfree);
|
algo_names[prev_algo], mfree);
|
||||||
}
|
}
|
||||||
// store used memory per algo
|
// store used memory per algo
|
||||||
algo_mem_used[thr_id][opt_algo] = device_mem_free[thr_id] - mused;
|
algo_mem_used[thr_id][opt_algo] = device_mem_free[thr_id] - mused;
|
||||||
|
23
ccminer.cpp
23
ccminer.cpp
@ -1407,8 +1407,7 @@ static bool wanna_mine(int thr_id)
|
|||||||
float temp = gpu_temp(cgpu);
|
float temp = gpu_temp(cgpu);
|
||||||
if (temp > opt_max_temp) {
|
if (temp > opt_max_temp) {
|
||||||
if (!conditional_state[thr_id] && !opt_quiet)
|
if (!conditional_state[thr_id] && !opt_quiet)
|
||||||
applog(LOG_INFO, "GPU #%d: temperature too high (%.0f°c), waiting...",
|
gpulog(LOG_INFO, thr_id, "temperature too high (%.0f°c), waiting...", temp);
|
||||||
device_map[thr_id], temp);
|
|
||||||
state = false;
|
state = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1637,7 +1636,7 @@ static void *miner_thread(void *userdata)
|
|||||||
|
|
||||||
// --benchmark [-a auto]
|
// --benchmark [-a auto]
|
||||||
if (opt_benchmark && bench_algo >= 0) {
|
if (opt_benchmark && bench_algo >= 0) {
|
||||||
//applog(LOG_DEBUG, "GPU #%d: loop %d", dev_id, loopcnt);
|
//gpulog(LOG_DEBUG, thr_id, "loop %d", loopcnt);
|
||||||
if (loopcnt >= 3) {
|
if (loopcnt >= 3) {
|
||||||
if (!bench_algo_switch_next(thr_id) && thr_id == 0)
|
if (!bench_algo_switch_next(thr_id) && thr_id == 0)
|
||||||
{
|
{
|
||||||
@ -1795,9 +1794,8 @@ static void *miner_thread(void *userdata)
|
|||||||
|
|
||||||
work.scanned_from = start_nonce;
|
work.scanned_from = start_nonce;
|
||||||
|
|
||||||
if (opt_debug)
|
gpulog(LOG_DEBUG, thr_id, "start=%08x end=%08x range=%08x",
|
||||||
applog(LOG_DEBUG, "GPU #%d: start=%08x end=%08x range=%08x",
|
start_nonce, max_nonce, (max_nonce-start_nonce));
|
||||||
dev_id, start_nonce, max_nonce, (max_nonce-start_nonce));
|
|
||||||
|
|
||||||
hashes_done = 0;
|
hashes_done = 0;
|
||||||
gettimeofday(&tv_start, NULL);
|
gettimeofday(&tv_start, NULL);
|
||||||
@ -1969,8 +1967,7 @@ static void *miner_thread(void *userdata)
|
|||||||
work.scanned_to = max_nonce;
|
work.scanned_to = max_nonce;
|
||||||
if (opt_debug && opt_benchmark) {
|
if (opt_debug && opt_benchmark) {
|
||||||
// to debug nonce ranges
|
// to debug nonce ranges
|
||||||
applog(LOG_DEBUG, "GPU #%d: ends=%08x range=%08x", dev_id,
|
gpulog(LOG_DEBUG, thr_id, "ends=%08x range=%08x", nonceptr[0], (nonceptr[0] - start_nonce));
|
||||||
nonceptr[0], (nonceptr[0] - start_nonce));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1978,9 +1975,9 @@ static void *miner_thread(void *userdata)
|
|||||||
hashlog_remember_scan_range(&work);
|
hashlog_remember_scan_range(&work);
|
||||||
|
|
||||||
/* output */
|
/* output */
|
||||||
if (!opt_quiet && firstwork_time) {
|
if (!opt_quiet && loopcnt > 1) {
|
||||||
format_hashrate(thr_hashrates[thr_id], s);
|
format_hashrate(thr_hashrates[thr_id], s);
|
||||||
applog(LOG_INFO, "GPU #%d: %s, %s", dev_id, device_name[dev_id], s);
|
gpulog(LOG_INFO, thr_id, "%s, %s", device_name[dev_id], s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ignore first loop hashrate */
|
/* ignore first loop hashrate */
|
||||||
@ -3191,6 +3188,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (!opt_n_threads)
|
if (!opt_n_threads)
|
||||||
opt_n_threads = active_gpus;
|
opt_n_threads = active_gpus;
|
||||||
|
else if (active_gpus > opt_n_threads)
|
||||||
|
active_gpus = opt_n_threads;
|
||||||
|
|
||||||
// generally doesn't work... let 1
|
// generally doesn't work... let 1
|
||||||
gpu_threads = opt_n_threads / active_gpus;
|
gpu_threads = opt_n_threads / active_gpus;
|
||||||
@ -3270,7 +3269,7 @@ int main(int argc, char *argv[])
|
|||||||
bool gpu_reinit = (opt_cudaschedule >= 0); //false
|
bool gpu_reinit = (opt_cudaschedule >= 0); //false
|
||||||
cuda_devicenames(); // refresh gpu vendor name
|
cuda_devicenames(); // refresh gpu vendor name
|
||||||
applog(LOG_INFO, "NVML GPU monitoring enabled.");
|
applog(LOG_INFO, "NVML GPU monitoring enabled.");
|
||||||
for (int n=0; n < opt_n_threads; n++) {
|
for (int n=0; n < active_gpus; n++) {
|
||||||
if (nvml_set_pstate(hnvml, device_map[n]) == 1)
|
if (nvml_set_pstate(hnvml, device_map[n]) == 1)
|
||||||
gpu_reinit = true;
|
gpu_reinit = true;
|
||||||
if (nvml_set_plimit(hnvml, device_map[n]) == 1)
|
if (nvml_set_plimit(hnvml, device_map[n]) == 1)
|
||||||
@ -3285,7 +3284,7 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
// force reinit to set default device flags
|
// force reinit to set default device flags
|
||||||
if (opt_cudaschedule >= 0 && !hnvml) {
|
if (opt_cudaschedule >= 0 && !hnvml) {
|
||||||
for (int n=0; n < opt_n_threads; n++) {
|
for (int n=0; n < active_gpus; n++) {
|
||||||
cuda_reset_device(n, NULL);
|
cuda_reset_device(n, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
cuda.cpp
3
cuda.cpp
@ -246,8 +246,7 @@ cudaError_t MyStreamSynchronize(cudaStream_t stream, int situation, int thr_id)
|
|||||||
void cudaReportHardwareFailure(int thr_id, cudaError_t err, const char* func)
|
void cudaReportHardwareFailure(int thr_id, cudaError_t err, const char* func)
|
||||||
{
|
{
|
||||||
struct cgpu_info *gpu = &thr_info[thr_id].gpu;
|
struct cgpu_info *gpu = &thr_info[thr_id].gpu;
|
||||||
int dev_id = device_map[thr_id % MAX_GPUS];
|
|
||||||
gpu->hw_errors++;
|
gpu->hw_errors++;
|
||||||
applog(LOG_ERR, "GPU #%d: %s %s", dev_id, func, cudaGetErrorString(err));
|
gpulog(LOG_ERR, thr_id, "%s %s", func, cudaGetErrorString(err));
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
2
miner.h
2
miner.h
@ -526,7 +526,7 @@ uint32_t cuda_default_throughput(int thr_id, uint32_t defcount);
|
|||||||
|
|
||||||
extern void format_hashrate(double hashrate, char *output);
|
extern void format_hashrate(double hashrate, char *output);
|
||||||
extern void applog(int prio, const char *fmt, ...);
|
extern void applog(int prio, const char *fmt, ...);
|
||||||
#define gpulog(prio, fmt, thr_id, ...) applog(prio, fmt, thr_id, __VA_ARGS__)
|
extern void gpulog(int prio, int thr_id, const char *fmt, ...);
|
||||||
void get_defconfig_path(char *out, size_t bufsize, char *argv0);
|
void get_defconfig_path(char *out, size_t bufsize, char *argv0);
|
||||||
extern void cbin2hex(char *out, const char *in, size_t len);
|
extern void cbin2hex(char *out, const char *in, size_t len);
|
||||||
extern char *bin2hex(const unsigned char *in, size_t len);
|
extern char *bin2hex(const unsigned char *in, size_t len);
|
||||||
|
31
util.cpp
31
util.cpp
@ -147,6 +147,37 @@ void applog(int prio, const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int gpu_threads;
|
||||||
|
// Use different prefix if multiple cpu threads per gpu
|
||||||
|
// Also, auto hide LOG_DEBUG if --debug (-D) is not used
|
||||||
|
void gpulog(int prio, int thr_id, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
char _ALIGN(128) pfmt[128];
|
||||||
|
char _ALIGN(128) line[256];
|
||||||
|
int len, dev_id = device_map[thr_id % MAX_GPUS];
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
if (prio == LOG_DEBUG && !opt_debug)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (gpu_threads > 1)
|
||||||
|
len = snprintf(pfmt, 128, "GPU T%d: %s", thr_id, fmt);
|
||||||
|
else
|
||||||
|
len = snprintf(pfmt, 128, "GPU #%d: %s", dev_id, fmt);
|
||||||
|
pfmt[sizeof(pfmt)-1]='\0';
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
|
||||||
|
if (len && vsnprintf(line, sizeof(line), pfmt, ap)) {
|
||||||
|
line[sizeof(line)-1]='\0';
|
||||||
|
applog(prio, "%s", line);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s OOM!\n", __func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get default config.json path (system specific) */
|
/* Get default config.json path (system specific) */
|
||||||
void get_defconfig_path(char *out, size_t bufsize, char *argv0)
|
void get_defconfig_path(char *out, size_t bufsize, char *argv0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user