Browse Source

Provide initial support for the scrypt kernel to compile with and mine scrypt with the --scrypt option.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
dd740caa98
  1. 10
      cgminer.c
  2. 44
      driver-opencl.c
  3. 7
      miner.h
  4. 20
      ocl.c

10
cgminer.c

@ -107,6 +107,9 @@ int opt_dynamic_interval = 7; @@ -107,6 +107,9 @@ int opt_dynamic_interval = 7;
int nDevs;
int opt_g_threads = 2;
int gpu_threads;
#ifdef USE_SCRYPT
bool opt_scrypt;
#endif
#endif
bool opt_restart = true;
static bool opt_nogpu;
@ -863,7 +866,7 @@ static struct opt_table opt_config_table[] = { @@ -863,7 +866,7 @@ static struct opt_table opt_config_table[] = {
#ifdef HAVE_OPENCL
OPT_WITH_ARG("--kernel|-k",
set_kernel, NULL, NULL,
"Override kernel to use (diablo, poclbm, phatk or diakgcn) - one value or comma separated"),
"Override sha256 kernel to use (diablo, poclbm, phatk or diakgcn) - one value or comma separated"),
#endif
#ifdef USE_ICARUS
OPT_WITH_ARG("--icarus-timing",
@ -953,6 +956,11 @@ static struct opt_table opt_config_table[] = { @@ -953,6 +956,11 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--sched-stop",
set_schedtime, NULL, &schedstop,
"Set a time of day in HH:MM to stop mining (will quit without a start time)"),
#ifdef USE_SCRYPT
OPT_WITHOUT_ARG("--scrypt",
opt_set_bool, &opt_scrypt,
"Use the scrypt algorithm for mining (litecoin only)"),
#endif
OPT_WITH_ARG("--sharelog",
set_sharelog, NULL, NULL,
"Append share log to file"),

44
driver-opencl.c

@ -137,7 +137,7 @@ static enum cl_kernels select_kernel(char *arg) @@ -137,7 +137,7 @@ static enum cl_kernels select_kernel(char *arg)
return KL_POCLBM;
if (!strcmp(arg, "phatk"))
return KL_PHATK;
#ifdef HAVE_SCRYPT
#ifdef USE_SCRYPT
if (!strcmp(arg, "scrypt"))
return KL_SCRYPT;
#endif
@ -150,6 +150,8 @@ char *set_kernel(char *arg) @@ -150,6 +150,8 @@ char *set_kernel(char *arg)
int i, device = 0;
char *nextptr;
if (opt_scrypt)
return "Cannot use sha256 kernel with scrypt";
nextptr = strtok(arg, ",");
if (nextptr == NULL)
return "Invalid parameters for set kernel";
@ -990,7 +992,7 @@ static cl_int queue_diablo_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint t @@ -990,7 +992,7 @@ static cl_int queue_diablo_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint t
return status;
}
#ifdef HAVE_SCRYPT
#ifdef USE_SCRYPT
static cl_int queue_scrypt_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint threads)
{
cl_int status = 0;
@ -1254,25 +1256,25 @@ static bool opencl_thread_prepare(struct thr_info *thr) @@ -1254,25 +1256,25 @@ static bool opencl_thread_prepare(struct thr_info *thr)
if (!cgpu->kname)
{
switch (clStates[i]->chosen_kernel) {
case KL_DIABLO:
cgpu->kname = "diablo";
break;
case KL_DIAKGCN:
cgpu->kname = "diakgcn";
break;
case KL_PHATK:
cgpu->kname = "phatk";
break;
#ifdef HAVE_SCRYPT
case KL_SCRYPT:
cgpu->kname = "scrypt";
break;
case KL_DIABLO:
cgpu->kname = "diablo";
break;
case KL_DIAKGCN:
cgpu->kname = "diakgcn";
break;
case KL_PHATK:
cgpu->kname = "phatk";
break;
#ifdef USE_SCRYPT
case KL_SCRYPT:
cgpu->kname = "scrypt";
break;
#endif
case KL_POCLBM:
cgpu->kname = "poclbm";
break;
default:
break;
case KL_POCLBM:
cgpu->kname = "poclbm";
break;
default:
break;
}
}
applog(LOG_INFO, "initCl() finished. Found %s", name);
@ -1309,7 +1311,7 @@ static bool opencl_thread_init(struct thr_info *thr) @@ -1309,7 +1311,7 @@ static bool opencl_thread_init(struct thr_info *thr)
case KL_DIAKGCN:
thrdata->queue_kernel_parameters = &queue_diakgcn_kernel;
break;
#ifdef HAVE_SCRYPT
#ifdef USE_SCRYPT
case KL_SCRYPT:
thrdata->queue_kernel_parameters = &queue_scrypt_kernel;
break;

7
miner.h

@ -262,7 +262,7 @@ enum cl_kernels { @@ -262,7 +262,7 @@ enum cl_kernels {
KL_PHATK,
KL_DIAKGCN,
KL_DIABLO,
#ifdef HAVE_SCRYPT
#ifdef USE_SCRYPT
KL_SCRYPT,
#endif
};
@ -620,6 +620,11 @@ extern bool use_syslog; @@ -620,6 +620,11 @@ extern bool use_syslog;
extern struct thr_info *thr_info;
extern struct cgpu_info gpus[MAX_GPUDEVICES];
extern int gpu_threads;
#ifdef USE_SCRYPT
extern bool opt_scrypt;
#else
#define opt_scrypt (0)
#endif
extern double total_secs;
extern int mining_threads;
extern struct cgpu_info *cpus;

20
ocl.c

@ -354,8 +354,11 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize) @@ -354,8 +354,11 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
char numbuf[10];
if (gpus[gpu].kernel == KL_NONE) {
/* Detect all 2.6 SDKs not with Tahiti and use diablo kernel */
if (!strstr(name, "Tahiti") &&
if (opt_scrypt) {
applog(LOG_INFO, "Selecting scrypt kernel");
clState->chosen_kernel = KL_SCRYPT;
} else if (!strstr(name, "Tahiti") &&
/* Detect all 2.6 SDKs not with Tahiti and use diablo kernel */
(strstr(vbuff, "844.4") || // Linux 64 bit ATI 2.6 SDK
strstr(vbuff, "851.4") || // Windows 64 bit ""
strstr(vbuff, "831.4") ||
@ -407,6 +410,10 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize) @@ -407,6 +410,10 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
strcpy(filename, DIAKGCN_KERNNAME".cl");
strcpy(binaryfilename, DIAKGCN_KERNNAME);
break;
case KL_SCRYPT:
strcpy(filename, SCRYPT_KERNNAME".cl");
strcpy(binaryfilename, SCRYPT_KERNNAME);
break;
case KL_NONE: /* Shouldn't happen */
case KL_DIABLO:
strcpy(filename, DIABLO_KERNNAME".cl");
@ -528,8 +535,13 @@ build: @@ -528,8 +535,13 @@ build:
/* create a cl program executable for all the devices specified */
char *CompilerOptions = calloc(1, 256);
sprintf(CompilerOptions, "-D WORKSIZE=%d -D VECTORS%d -D WORKVEC=%d",
(int)clState->wsize, clState->vwidth, (int)clState->wsize * clState->vwidth);
if (opt_scrypt) {
sprintf(CompilerOptions, "-D LOOKUP_GAP=2 -D CONCURRENT_THREADS=6144 -D WORKSIZE=%d",
(int)clState->wsize);
} else {
sprintf(CompilerOptions, "-D WORKSIZE=%d -D VECTORS%d -D WORKVEC=%d",
(int)clState->wsize, clState->vwidth, (int)clState->wsize * clState->vwidth);
}
applog(LOG_DEBUG, "Setting worksize to %d", clState->wsize);
if (clState->vwidth > 1)
applog(LOG_DEBUG, "Patched source to suit %d vectors", clState->vwidth);

Loading…
Cancel
Save