Initial test nicehash support.

This commit is contained in:
XMRig 2017-05-20 07:08:41 +03:00
parent e67a95bd8b
commit 2baccab0f9
4 changed files with 26 additions and 5 deletions

View file

@ -48,6 +48,7 @@ bool opt_keepalive = false;
bool opt_background = false; bool opt_background = false;
bool opt_double_hash = false; bool opt_double_hash = false;
bool opt_safe = false; bool opt_safe = false;
bool opt_nicehash = false;
char *opt_url = NULL; char *opt_url = NULL;
char *opt_backup_url = NULL; char *opt_backup_url = NULL;
char *opt_userpass = NULL; char *opt_userpass = NULL;
@ -97,6 +98,7 @@ static struct option const options[] = {
{ "help", 0, NULL, 'h' }, { "help", 0, NULL, 'h' },
{ "keepalive", 0, NULL ,'k' }, { "keepalive", 0, NULL ,'k' },
{ "max-cpu-usage", 1, NULL, 1004 }, { "max-cpu-usage", 1, NULL, 1004 },
{ "nicehash", 0, NULL, 1006 },
{ "no-color", 0, NULL, 1002 }, { "no-color", 0, NULL, 1002 },
{ "pass", 1, NULL, 'p' }, { "pass", 1, NULL, 'p' },
{ "retries", 1, NULL, 'r' }, { "retries", 1, NULL, 'r' },
@ -331,6 +333,10 @@ static void parse_arg(int key, char *arg) {
opt_donate_level = v; opt_donate_level = v;
break; break;
case 1006: /* --nicehash */
opt_nicehash = true;
break;
default: default:
show_usage_and_exit(1); show_usage_and_exit(1);
} }

View file

@ -65,6 +65,7 @@ extern bool opt_keepalive;
extern bool opt_background; extern bool opt_background;
extern bool opt_double_hash; extern bool opt_double_hash;
extern bool opt_safe; extern bool opt_safe;
extern bool opt_nicehash;
extern char *opt_url; extern char *opt_url;
extern char *opt_backup_url; extern char *opt_backup_url;
extern char *opt_userpass; extern char *opt_userpass;

View file

@ -27,14 +27,14 @@
#define APP_ID "xmrig" #define APP_ID "xmrig"
#define APP_NAME "XMRig" #define APP_NAME "XMRig"
#define APP_DESC "Monero (XMR) CPU miner" #define APP_DESC "Monero (XMR) CPU miner"
#define APP_VERSION "0.8.0" #define APP_VERSION "0.8.1"
#define APP_DOMAIN "xmrig.com" #define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com" #define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2017 xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2017 xmrig.com"
#define APP_VER_MAJOR 0 #define APP_VER_MAJOR 0
#define APP_VER_MINOR 8 #define APP_VER_MINOR 8
#define APP_VER_BUILD 0 #define APP_VER_BUILD 1
#define APP_VER_REV 0 #define APP_VER_REV 0
#endif /* __VERSION_H__ */ #endif /* __VERSION_H__ */

20
xmrig.c
View file

@ -280,7 +280,14 @@ static void *miner_thread(void *userdata) {
if (memcmp(work.job_id, stratum_ctx->g_work.job_id, 64)) { if (memcmp(work.job_id, stratum_ctx->g_work.job_id, 64)) {
work_copy(&work, &stratum_ctx->g_work); work_copy(&work, &stratum_ctx->g_work);
nonceptr = (uint32_t*) (((char*) work.blob) + 39); nonceptr = (uint32_t*) (((char*) work.blob) + 39);
*nonceptr = 0xffffffffU / opt_n_threads * thr_id;
if (opt_nicehash) {
end_nonce = (*nonceptr & 0xff000000U) + (0xffffffU / opt_n_threads * (thr_id + 1) - 0x20);
*nonceptr = (*nonceptr & 0xff000000U) + (0xffffffU / opt_n_threads * thr_id);
}
else {
*nonceptr = 0xffffffffU / opt_n_threads * thr_id;
}
} }
pthread_mutex_unlock(&stratum_ctx->work_lock); pthread_mutex_unlock(&stratum_ctx->work_lock);
@ -356,8 +363,15 @@ static void *miner_thread_double(void *userdata) {
nonceptr0 = (uint32_t*) (((char*) double_blob) + 39); nonceptr0 = (uint32_t*) (((char*) double_blob) + 39);
nonceptr1 = (uint32_t*) (((char*) double_blob) + 39 + work.blob_size); nonceptr1 = (uint32_t*) (((char*) double_blob) + 39 + work.blob_size);
*nonceptr0 = 0xffffffffU / (opt_n_threads * 2) * thr_id; if (opt_nicehash) {
*nonceptr1 = 0xffffffffU / (opt_n_threads * 2) * (thr_id + opt_n_threads); end_nonce = (*nonceptr0 & 0xff000000U) + (0xffffffU / (opt_n_threads * 2) * (thr_id + 1) - 0x20);
*nonceptr0 = (*nonceptr0 & 0xff000000U) + (0xffffffU / (opt_n_threads * 2) * thr_id);
*nonceptr1 = (*nonceptr1 & 0xff000000U) + (0xffffffU / (opt_n_threads * 2) * (thr_id + opt_n_threads));
}
else {
*nonceptr0 = 0xffffffffU / (opt_n_threads * 2) * thr_id;
*nonceptr1 = 0xffffffffU / (opt_n_threads * 2) * (thr_id + opt_n_threads);
}
} }
pthread_mutex_unlock(&stratum_ctx->work_lock); pthread_mutex_unlock(&stratum_ctx->work_lock);