Browse Source

scrypt: autotune, launch-config and lookup-gap options

also enhance scrypt variants algo checks to be case insensitive
master
Tanguy Pruvot 10 years ago
parent
commit
b8b810f30d
  1. 55
      ccminer.cpp
  2. 2
      scrypt/salsa_kernel.cu
  3. 35
      scrypt/salsa_kernel.h

55
ccminer.cpp

@ -189,16 +189,18 @@ short device_map[MAX_GPUS] = { 0 };
long device_sm[MAX_GPUS] = { 0 }; long device_sm[MAX_GPUS] = { 0 };
uint32_t gpus_intensity[MAX_GPUS] = { 0 }; uint32_t gpus_intensity[MAX_GPUS] = { 0 };
// un-implemented scrypt options
int device_interactive[MAX_GPUS] = { 0 }; int device_interactive[MAX_GPUS] = { 0 };
int device_batchsize[MAX_GPUS] = { 0 }; int device_batchsize[MAX_GPUS] = { 0 };
int device_backoff[MAX_GPUS] = { 0 };
int device_lookup_gap[MAX_GPUS] = { 0 };
int device_texturecache[MAX_GPUS] = { 0 }; int device_texturecache[MAX_GPUS] = { 0 };
int device_singlememory[MAX_GPUS] = { 0 }; int device_singlememory[MAX_GPUS] = { 0 };
// implemented scrypt options
int parallel = 2; // All should be made on GPU
char *device_config[MAX_GPUS] = { 0 }; char *device_config[MAX_GPUS] = { 0 };
int device_backoff[MAX_GPUS] = { 0 };
int device_lookup_gap[MAX_GPUS] = { 0 };
int opt_nfactor = 0; int opt_nfactor = 0;
int parallel = 2; bool opt_autotune = true;
bool autotune = true;
bool abort_flag = false; bool abort_flag = false;
char *jane_params = NULL; char *jane_params = NULL;
@ -345,7 +347,7 @@ static char const short_options[] =
#ifdef HAVE_SYSLOG_H #ifdef HAVE_SYSLOG_H
"S" "S"
#endif #endif
"a:c:i:Dhp:Px:mnqr:R:s:t:T:o:u:O:Vd:f:v:N:b:"; "a:c:i:Dhp:Px:mnqr:R:s:t:T:o:u:O:Vd:f:v:N:b:l:L:";
static struct option const options[] = { static struct option const options[] = {
{ "algo", 1, NULL, 'a' }, { "algo", 1, NULL, 'a' },
@ -368,6 +370,9 @@ static struct option const options[] = {
{ "no-gbt", 0, NULL, 1011 }, { "no-gbt", 0, NULL, 1011 },
{ "no-longpoll", 0, NULL, 1003 }, { "no-longpoll", 0, NULL, 1003 },
{ "no-stratum", 0, NULL, 1007 }, { "no-stratum", 0, NULL, 1007 },
{ "no-autotune", 0, NULL, 1004 }, // scrypt
{ "launch-config", 0, NULL, 'l' }, // scrypt
{ "lookup-gap", 0, NULL, 'L' }, // scrypt
{ "pass", 1, NULL, 'p' }, { "pass", 1, NULL, 'p' },
{ "protocol-dump", 0, NULL, 'P' }, { "protocol-dump", 0, NULL, 'P' },
{ "proxy", 1, NULL, 'x' }, { "proxy", 1, NULL, 'x' },
@ -393,6 +398,16 @@ static struct option const options[] = {
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
static char const scrypt_usage[] = "\n\
Scrypt specific options:\n\
-l, --launch-config gives the launch configuration for each kernel\n\
in a comma separated list, one per device.\n\
-L, --lookup-gap Divides the per-hash memory requirement by this factor\n\
by storing only every N'th value in the scratchpad.\n\
Default is 1.\n\
--no-autotune disable auto-tuning of kernel launch parameters\n\
";
struct work _ALIGN(64) g_work; struct work _ALIGN(64) g_work;
time_t g_work_time; time_t g_work_time;
pthread_mutex_t g_work_lock; pthread_mutex_t g_work_lock;
@ -1966,6 +1981,9 @@ static void show_usage_and_exit(int status)
fprintf(stderr, "Try `" PROGRAM_NAME " --help' for more information.\n"); fprintf(stderr, "Try `" PROGRAM_NAME " --help' for more information.\n");
else else
printf(usage); printf(usage);
if (opt_algo == ALGO_SCRYPT || opt_algo == ALGO_SCRYPT_JANE) {
printf(scrypt_usage);
}
proper_exit(status); proper_exit(status);
} }
@ -2228,6 +2246,33 @@ void parse_arg(int key, char *arg)
case 1002: case 1002:
use_colors = false; use_colors = false;
break; break;
case 1004:
opt_autotune = false;
break;
case 'l': /* scrypt --launch-config */
{
char *last = NULL, *pch = strtok(arg,",");
int n = 0;
while (pch != NULL) {
device_config[n++] = last = strdup(pch);
pch = strtok(NULL, ",");
}
while (n < MAX_GPUS)
device_config[n++] = last;
}
break;
case 'L': /* scrypt --lookup-gap */
{
char *pch = strtok(arg,",");
int n = 0, last = 0;
while (pch != NULL) {
device_lookup_gap[n++] = last = atoi(pch);
pch = strtok(NULL, ",");
}
while (n < MAX_GPUS)
device_lookup_gap[n++] = last;
}
break;
case 1005: case 1005:
opt_benchmark = true; opt_benchmark = true;
want_longpoll = false; want_longpoll = false;

2
scrypt/salsa_kernel.cu

@ -526,7 +526,7 @@ int find_optimal_blockcount(int thr_id, KernelInterface* &kernel, bool &concurre
if (device_config[thr_id] != NULL && strcasecmp("auto", device_config[thr_id])) if (device_config[thr_id] != NULL && strcasecmp("auto", device_config[thr_id]))
applog(LOG_WARNING, "GPU #%d: Given launch config '%s' does not validate.", device_map[thr_id], device_config[thr_id]); applog(LOG_WARNING, "GPU #%d: Given launch config '%s' does not validate.", device_map[thr_id], device_config[thr_id]);
if (autotune) if (opt_autotune)
{ {
applog(LOG_INFO, "GPU #%d: Performing auto-tuning, please wait 2 minutes...", device_map[thr_id]); applog(LOG_INFO, "GPU #%d: Performing auto-tuning, please wait 2 minutes...", device_map[thr_id]);

35
scrypt/salsa_kernel.h

@ -11,34 +11,41 @@
#define MAX_DEVICES MAX_GPUS #define MAX_DEVICES MAX_GPUS
#define A_SCRYPT 0
#define A_SCRYPT_JANE 1
// from ccminer.cpp // from ccminer.cpp
extern short device_map[MAX_GPUS]; extern short device_map[MAX_GPUS];
extern int device_interactive[MAX_GPUS]; extern int device_interactive[MAX_GPUS]; // cudaminer -i
extern int device_batchsize[MAX_GPUS]; extern int device_batchsize[MAX_GPUS]; // cudaminer -b
extern int device_backoff[MAX_GPUS]; extern int device_texturecache[MAX_GPUS]; // cudaminer -C
extern int device_lookup_gap[MAX_GPUS]; extern int device_singlememory[MAX_GPUS]; // cudaminer -m
extern int device_texturecache[MAX_GPUS]; extern int device_lookup_gap[MAX_GPUS]; // -L
extern int device_singlememory[MAX_GPUS]; extern int device_backoff[MAX_GPUS]; // WIN32/LINUX var
extern char *device_config[MAX_GPUS]; extern char *device_config[MAX_GPUS]; // -l
extern char *device_name[MAX_GPUS]; extern char *device_name[MAX_GPUS];
extern bool autotune;
extern bool opt_autotune;
extern int opt_nfactor; extern int opt_nfactor;
extern char *jane_params; extern char *jane_params;
extern bool abort_flag; extern bool abort_flag;
extern bool autotune;
extern int parallel; extern int parallel;
extern void get_currentalgo(char* buf, int sz); extern void get_currentalgo(char* buf, int sz);
typedef unsigned int uint32_t; // define this as 32 bit type derived from int typedef unsigned int uint32_t; // define this as 32 bit type derived from int
// scrypt variants
#define A_SCRYPT 0
#define A_SCRYPT_JANE 1
static char algo[64] = { 0 }; static char algo[64] = { 0 };
static __inline bool IS_SCRYPT() { if (algo[0] == '\0') get_currentalgo(algo, 64); return !strcmp(algo,"scrypt"); } static int scrypt_algo = -1;
static __inline bool IS_SCRYPT_JANE() { if (algo[0] == '\0') get_currentalgo(algo, 64); return !strcmp(algo,"scrypt-jane"); } static __inline int get_scrypt_type() {
if (scrypt_algo != -1) return scrypt_algo;
get_currentalgo(algo, 64);
if (!strcasecmp(algo,"scrypt-jane")) scrypt_algo = A_SCRYPT_JANE;
else if (!strcasecmp(algo,"scrypt")) scrypt_algo = A_SCRYPT;
return scrypt_algo;
}
static __inline bool IS_SCRYPT() { get_scrypt_type(); return (scrypt_algo == A_SCRYPT); }
static __inline bool IS_SCRYPT_JANE() { get_scrypt_type(); return (scrypt_algo == A_SCRYPT_JANE); }
// CUDA externals // CUDA externals
extern int cuda_num_devices(); extern int cuda_num_devices();

Loading…
Cancel
Save