Provide initial support for the scrypt kernel to compile with and mine scrypt with the --scrypt option.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
diff --git a/cgminer.c b/cgminer.c
index 55d3943..c0084ab 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -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[] = {
#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[] = {
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"),
diff --git a/driver-opencl.c b/driver-opencl.c
index e8a901d..0d77b4a 100644
--- a/driver-opencl.c
+++ b/driver-opencl.c
@@ -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)
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
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)
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)
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;
diff --git a/miner.h b/miner.h
index 7482473..c1cbe74 100644
--- a/miner.h
+++ b/miner.h
@@ -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;
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;
diff --git a/ocl.c b/ocl.c
index 464cb4e..7b80257 100644
--- a/ocl.c
+++ b/ocl.c
@@ -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)
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:
/* 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);