Skip to content

Commit

Permalink
xmr: link the --bfactor setting (0-11)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpruvot committed Jan 12, 2017
1 parent e231343 commit 23be7f3
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 33 deletions.
11 changes: 8 additions & 3 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Vertcoin Lyra2RE
Ziftrcoin (ZR5)
Boolberry (Wild Keccak)
Monero (Cryptonight)
Aeon (Cryptonight-light)
Aeon (Cryptonight-lite)

where some of these coins have a VERY NOTABLE nVidia advantage
over competing AMD (OpenCL Only) implementations.
Expand Down Expand Up @@ -193,11 +193,16 @@ Scrypt specific options:
cache for mining. Kepler devices may profit.
--no-autotune disable auto-tuning of kernel launch parameters


XMR and Wildkeccak specific:
CryptoNight specific options:
-l, --launch-config gives the launch configuration for each kernel
in a comma separated list, one per device.
--bfactor=[0-12] Run Cryptonight core kernel in smaller pieces,
From 0 (ui freeze) to 12 (smooth), win default is 11
This is a per-device setting like the launch config.

Wildkeccak specific:
-l, --launch-config gives the launch configuration for each kernel
in a comma separated list, one per device.
-k, --scratchpad url Url used to download the scratchpad cache.


Expand Down
2 changes: 2 additions & 0 deletions algos.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ static inline int algo_to_int(char* arg)
i = ALGO_AUTO;
else if (!strcasecmp("cryptonight-light", arg))
i = ALGO_CRYPTOLIGHT;
else if (!strcasecmp("cryptonight-lite", arg))
i = ALGO_CRYPTOLIGHT;
else if (!strcasecmp("flax", arg))
i = ALGO_C11;
else if (!strcasecmp("diamond", arg))
Expand Down
40 changes: 36 additions & 4 deletions ccminer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ int device_singlememory[MAX_GPUS] = { 0 };
// implemented scrypt options
int parallel = 2; // All should be made on GPU
char *device_config[MAX_GPUS] = { 0 };
int device_backoff[MAX_GPUS] = { 0 };
int device_backoff[MAX_GPUS] = { 0 }; // scrypt
int device_bfactor[MAX_GPUS] = { 0 }; // cryptonight
int device_lookup_gap[MAX_GPUS] = { 0 };
int device_interactive[MAX_GPUS] = { 0 };
int opt_nfactor = 0;
Expand Down Expand Up @@ -371,8 +372,9 @@ struct option options[] = {
{ "interactive", 1, NULL, 1050 }, // scrypt
{ "lookup-gap", 1, NULL, 'L' }, // scrypt
{ "texture-cache", 1, NULL, 1051 },// scrypt
{ "launch-config", 1, NULL, 'l' }, // scrypt & bbr
{ "launch-config", 1, NULL, 'l' }, // scrypt bbr xmr
{ "scratchpad", 1, NULL, 'k' }, // bbr
{ "bfactor", 1, NULL, 1055 }, // xmr
{ "max-temp", 1, NULL, 1060 },
{ "max-diff", 1, NULL, 1061 },
{ "max-rate", 1, NULL, 1062 },
Expand Down Expand Up @@ -442,7 +444,16 @@ Scrypt specific options:\n\
";

static char const xmr_usage[] = "\n\
CryptoNote specific options:\n\
CryptoNight specific options:\n\
-l, --launch-config gives the launch configuration for each kernel\n\
in a comma separated list, one per device.\n\
--bfactor=[0-12] Run Cryptonight core kernel in smaller pieces,\n\
From 0 (ui freeze) to 12 (smooth), win default is 11\n\
This is a per-device setting like the launch config.\n\
";

static char const bbr_usage[] = "\n\
Boolberry specific options:\n\
-l, --launch-config gives the launch configuration for each kernel\n\
in a comma separated list, one per device.\n\
-k, --scratchpad url Url used to download the scratchpad cache.\n\
Expand Down Expand Up @@ -2441,6 +2452,7 @@ static void *miner_thread(void *userdata)
if (opt_led_mode == LED_MODE_SHARES)
gpu_led_percent(dev_id, 50);

work.submit_nonce_id = 0;
nonceptr[0] = work.nonces[0];
if (!submit_work(mythr, &work))
break;
Expand Down Expand Up @@ -2468,6 +2480,7 @@ static void *miner_thread(void *userdata)
if (!submit_work(mythr, &work))
break;
nonceptr[0] = curnonce;
work.nonces[1] = 0; // reset
}
}
}
Expand Down Expand Up @@ -2852,12 +2865,16 @@ static void show_usage_and_exit(int status)
fprintf(stderr, "Try `" PROGRAM_NAME " --help' for more information.\n");
else
printf(usage);

if (opt_algo == ALGO_SCRYPT || opt_algo == ALGO_SCRYPT_JANE) {
printf(scrypt_usage);
}
if (opt_algo == ALGO_CRYPTONIGHT || opt_algo == ALGO_CRYPTOLIGHT || opt_algo == ALGO_WILDKECCAK) {
else if (opt_algo == ALGO_CRYPTONIGHT || opt_algo == ALGO_CRYPTOLIGHT) {
printf(xmr_usage);
}
else if (opt_algo == ALGO_WILDKECCAK) {
printf(bbr_usage);
}
proper_exit(status);
}

Expand Down Expand Up @@ -3187,6 +3204,20 @@ void parse_arg(int key, char *arg)
device_texturecache[n++] = last;
}
break;
case 1055: /* cryptonight --bfactor */
{
char *pch = strtok(arg, ",");
int n = 0, last = atoi(arg);
while (pch != NULL) {
last = atoi(pch);
if (last > 15) last = 15;
device_bfactor[n++] = last;
pch = strtok(NULL, ",");
}
while (n < MAX_GPUS)
device_bfactor[n++] = last;
}
break;
case 1070: /* --gpu-clock */
{
char *pch = strtok(arg,",");
Expand Down Expand Up @@ -3659,6 +3690,7 @@ int main(int argc, char *argv[])
device_name[i] = NULL;
device_config[i] = NULL;
device_backoff[i] = is_windows() ? 12 : 2;
device_bfactor[i] = is_windows() ? 11 : 0;
device_lookup_gap[i] = 1;
device_batchsize[i] = 1024;
device_interactive[i] = -1;
Expand Down
17 changes: 5 additions & 12 deletions crypto/cryptolight-core.cu
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@
#include <sys/time.h>
#include <unistd.h>

#include <cuda.h>
#include <cuda_runtime.h>

#include "cryptolight.h"
#define LONG_SHL_IDX 18
#define LONG_LOOPS32 0x40000

#ifdef WIN32
static __thread int cn_bfactor = 11;
static __thread int cn_bsleep = 100;
#else
static __thread int cn_bfactor = 0;
static __thread int cn_bsleep = 0;
#endif
extern int device_backoff[MAX_GPUS];

#include "cn_aes.cuh"

Expand Down Expand Up @@ -259,6 +250,8 @@ void cryptolight_core_gpu_phase3(int threads, const uint32_t * __restrict__ long
}
}

extern int device_bfactor[MAX_GPUS];

__host__
void cryptolight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_long_state, uint32_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2)
{
Expand All @@ -267,8 +260,8 @@ void cryptolight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_
dim3 block4(threads << 2);
dim3 block8(threads << 3);

const int bfactor = cn_bfactor; // device_bfactor[thr_id];
const int bsleep = cn_bsleep; //device_bsleep[thr_id];
const int bfactor = device_bfactor[thr_id];
const int bsleep = bfactor ? 100 : 0;

int i, partcount = 1 << bfactor;
int dev_id = device_map[thr_id];
Expand Down
18 changes: 4 additions & 14 deletions crypto/cryptonight-core.cu
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,10 @@
#include <sys/time.h>
#include <unistd.h>

#include <cuda.h>
#include <cuda_runtime.h>

#include "cryptonight.h"
#define LONG_SHL_IDX 19
#define LONG_LOOPS32 0x80000

#ifdef WIN32
// to prevent ui freeze
static __thread int cn_bfactor = 11;
static __thread int cn_bsleep = 100;
#else
static __thread int cn_bfactor = 0;
static __thread int cn_bsleep = 0;
#endif

#include "cn_aes.cuh"

#define MUL_SUM_XOR_DST(a,c,dst) { \
Expand Down Expand Up @@ -264,6 +252,8 @@ void cryptonight_core_gpu_phase3(int threads, const uint32_t * __restrict__ long
}
}

extern int device_bfactor[MAX_GPUS];

__host__
void cryptonight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_long_state, uint32_t *d_ctx_state, uint32_t *d_ctx_a, uint32_t *d_ctx_b, uint32_t *d_ctx_key1, uint32_t *d_ctx_key2)
{
Expand All @@ -272,8 +262,8 @@ void cryptonight_core_cpu_hash(int thr_id, int blocks, int threads, uint32_t *d_
dim3 block4(threads << 2);
dim3 block8(threads << 3);

const int bfactor = cn_bfactor; // device_bfactor[thr_id];
const int bsleep = cn_bsleep; //device_bsleep[thr_id];
const int bfactor = device_bfactor[thr_id];
const int bsleep = bfactor ? 100 : 0;

int i, partcount = 1 << bfactor;
int dev_id = device_map[thr_id];
Expand Down

0 comments on commit 23be7f3

Please sign in to comment.