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. 10
      driver-opencl.c
  3. 7
      miner.h
  4. 14
      ocl.c

10
cgminer.c

@ -107,6 +107,9 @@ int opt_dynamic_interval = 7;
int nDevs; int nDevs;
int opt_g_threads = 2; int opt_g_threads = 2;
int gpu_threads; int gpu_threads;
#ifdef USE_SCRYPT
bool opt_scrypt;
#endif
#endif #endif
bool opt_restart = true; bool opt_restart = true;
static bool opt_nogpu; static bool opt_nogpu;
@ -863,7 +866,7 @@ static struct opt_table opt_config_table[] = {
#ifdef HAVE_OPENCL #ifdef HAVE_OPENCL
OPT_WITH_ARG("--kernel|-k", OPT_WITH_ARG("--kernel|-k",
set_kernel, NULL, NULL, 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 #endif
#ifdef USE_ICARUS #ifdef USE_ICARUS
OPT_WITH_ARG("--icarus-timing", OPT_WITH_ARG("--icarus-timing",
@ -953,6 +956,11 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--sched-stop", OPT_WITH_ARG("--sched-stop",
set_schedtime, NULL, &schedstop, set_schedtime, NULL, &schedstop,
"Set a time of day in HH:MM to stop mining (will quit without a start time)"), "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", OPT_WITH_ARG("--sharelog",
set_sharelog, NULL, NULL, set_sharelog, NULL, NULL,
"Append share log to file"), "Append share log to file"),

10
driver-opencl.c

@ -137,7 +137,7 @@ static enum cl_kernels select_kernel(char *arg)
return KL_POCLBM; return KL_POCLBM;
if (!strcmp(arg, "phatk")) if (!strcmp(arg, "phatk"))
return KL_PHATK; return KL_PHATK;
#ifdef HAVE_SCRYPT #ifdef USE_SCRYPT
if (!strcmp(arg, "scrypt")) if (!strcmp(arg, "scrypt"))
return KL_SCRYPT; return KL_SCRYPT;
#endif #endif
@ -150,6 +150,8 @@ char *set_kernel(char *arg)
int i, device = 0; int i, device = 0;
char *nextptr; char *nextptr;
if (opt_scrypt)
return "Cannot use sha256 kernel with scrypt";
nextptr = strtok(arg, ","); nextptr = strtok(arg, ",");
if (nextptr == NULL) if (nextptr == NULL)
return "Invalid parameters for set kernel"; 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
return status; return status;
} }
#ifdef HAVE_SCRYPT #ifdef USE_SCRYPT
static cl_int queue_scrypt_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint threads) static cl_int queue_scrypt_kernel(_clState *clState, dev_blk_ctx *blk, cl_uint threads)
{ {
cl_int status = 0; cl_int status = 0;
@ -1263,7 +1265,7 @@ static bool opencl_thread_prepare(struct thr_info *thr)
case KL_PHATK: case KL_PHATK:
cgpu->kname = "phatk"; cgpu->kname = "phatk";
break; break;
#ifdef HAVE_SCRYPT #ifdef USE_SCRYPT
case KL_SCRYPT: case KL_SCRYPT:
cgpu->kname = "scrypt"; cgpu->kname = "scrypt";
break; break;
@ -1309,7 +1311,7 @@ static bool opencl_thread_init(struct thr_info *thr)
case KL_DIAKGCN: case KL_DIAKGCN:
thrdata->queue_kernel_parameters = &queue_diakgcn_kernel; thrdata->queue_kernel_parameters = &queue_diakgcn_kernel;
break; break;
#ifdef HAVE_SCRYPT #ifdef USE_SCRYPT
case KL_SCRYPT: case KL_SCRYPT:
thrdata->queue_kernel_parameters = &queue_scrypt_kernel; thrdata->queue_kernel_parameters = &queue_scrypt_kernel;
break; break;

7
miner.h

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

14
ocl.c

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

Loading…
Cancel
Save