Browse Source

Make SHA256d mining optional

Luke Dashjr 11 years ago
parent
commit
70f17d7540
15 changed files with 152 additions and 48 deletions
  1. 24 17
      Makefile.am
  2. 6 8
      api.c
  3. 11 1
      configure.ac
  4. 2 0
      deviceapi.c
  5. 20 5
      driver-cpu.c
  6. 13 1
      driver-cpu.h
  7. 2 0
      driver-dualminer.c
  8. 20 5
      driver-opencl.c
  9. 4 3
      driver-opencl.h
  10. 2 0
      findnonce.c
  11. 2 0
      findnonce.h
  12. 34 8
      miner.c
  13. 4 0
      miner.h
  14. 4 0
      ocl.c
  15. 4 0
      util.c

+ 24 - 17
Makefile.am

@@ -137,11 +137,7 @@ bfgminer_SOURCES += ocl.c ocl.h findnonce.c findnonce.h
 bfgminer_SOURCES += adl.c adl.h adl_functions.h
 
 kernelsdir = $(pkgdatadir)/opencl
-dist_kernels_DATA = \
-	$(top_srcdir)/opencl/diablo.cl  \
-	$(top_srcdir)/opencl/diakgcn.cl  \
-	$(top_srcdir)/opencl/phatk.cl  \
-	$(top_srcdir)/opencl/poclbm.cl
+dist_kernels_DATA =
 
 dist_doc_DATA += README.GPU
 
@@ -152,29 +148,22 @@ endif
 endif
 
 
-if HAS_SCRYPT
-bfgminer_SOURCES += scrypt.c scrypt.h
-dist_doc_DATA += README.scrypt
-
+if USE_SHA256D
 if HAVE_OPENCL
 dist_kernels_DATA += \
-	$(top_srcdir)/opencl/psw.cl  \
-	$(top_srcdir)/opencl/scrypt.cl  \
-	$(top_srcdir)/opencl/zuikkis.cl
-endif
+	$(top_srcdir)/opencl/diablo.cl  \
+	$(top_srcdir)/opencl/diakgcn.cl  \
+	$(top_srcdir)/opencl/phatk.cl  \
+	$(top_srcdir)/opencl/poclbm.cl
 endif
 
 if HAS_CPUMINE
-dist_doc_DATA += README.CPU
 bfgminer_SOURCES	+= \
 		  sha256_generic.c sha256_via.c	\
 		  sha256_cryptopp.c sha256_sse2_amd64.c		\
 		  sha256_sse4_amd64.c 	\
 		  sha256_altivec_4way.c
 
-# the CPU portion extracted from original main.c
-bfgminer_SOURCES += driver-cpu.h driver-cpu.c
-
 if HAVE_SSE2
 bfgminer_LDADD  += libsse2cpuminer.a
 noinst_LIBRARIES = libsse2cpuminer.a
@@ -203,6 +192,24 @@ endif
 endif # HAVE_x86_64
 endif # HAS_YASM
 endif # HAS_CPUMINE
+endif # USE_SHA256D
+
+if HAS_SCRYPT
+bfgminer_SOURCES += scrypt.c scrypt.h
+dist_doc_DATA += README.scrypt
+
+if HAVE_OPENCL
+dist_kernels_DATA += \
+	$(top_srcdir)/opencl/psw.cl  \
+	$(top_srcdir)/opencl/scrypt.cl  \
+	$(top_srcdir)/opencl/zuikkis.cl
+endif
+endif
+
+if HAS_CPUMINE
+dist_doc_DATA += README.CPU
+bfgminer_SOURCES += driver-cpu.h driver-cpu.c
+endif # HAS_CPUMINE
 
 if NEED_BFG_LOWL_VCOM
 bfgminer_SOURCES += lowl-vcom.c lowl-vcom.h

+ 6 - 8
api.c

@@ -89,7 +89,9 @@ static const char *FALSESTR = "false";
 #ifdef USE_SCRYPT
 static const char *SCRYPTSTR = "scrypt";
 #endif
+#ifdef USE_SHA256D
 static const char *SHA256STR = "sha256";
+#endif
 
 static const char *OSINFO =
 #if defined(__linux)
@@ -1987,12 +1989,6 @@ static void summary(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __mayb
 	bool io_open;
 	double utility, mhs, work_utility;
 
-#ifdef WANT_CPUMINE
-	char *algo = (char *)(algo_names[opt_algo]);
-	if (algo == NULL)
-		algo = (char *)NULLSTR;
-#endif
-
 	message(io_data, MSG_SUMM, 0, NULL, isjson);
 	io_open = io_add(io_data, isjson ? COMSTR JSON_SUMMARY : _SUMMARY COMSTR);
 
@@ -2004,9 +2000,9 @@ static void summary(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __mayb
 	work_utility = total_diff1 / ( total_secs ? total_secs : 1 ) * 60;
 
 	root = api_add_elapsed(root, "Elapsed", &(total_secs), true);
-#ifdef WANT_CPUMINE
+#if defined(WANT_CPUMINE) && defined(USE_SHA256D)
 	if (opt_n_threads > 0)
-	root = api_add_string(root, "Algorithm", algo, false);
+		root = api_add_string(root, "Algorithm", (algo_names[opt_algo] ?: NULLSTR), false);
 #endif
 	root = api_add_mhs(root, "MHS av", &(mhs), false);
 	char mhsname[27];
@@ -3097,9 +3093,11 @@ static void minecoin(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __may
 				root = api_add_const(root, "Hash Method", SCRYPTSTR, false);
 				break;
 #endif
+#ifdef USE_SHA256D
 			case POW_SHA256D:
 				root = api_add_const(root, "Hash Method", SHA256STR, false);
 				break;
+#endif
 			default:
 				break;
 		}

+ 11 - 1
configure.ac

@@ -116,7 +116,7 @@ AC_FUNC_ALLOCA
 
 lowllist=
 driverlist=
-algolist=SHA256d
+algolist=
 optlist=
 
 has_fpga=no
@@ -271,6 +271,15 @@ AM_CONDITIONAL([USE_UDEVRULES_GROUP], [$use_udevrules_group])
 AC_SUBST([UDEVRULES_GROUP], [$udevrules_group])
 
 
+algolist="$algolist SHA256d"
+AC_ARG_ENABLE([sha256d],
+	[AC_HELP_STRING([--disable-sha256d],[Compile support for SHA256d mining (default enabled)])],
+	[sha256d=$enableval],
+	[sha256d=yes])
+if test "x$sha256d" = xyes; then
+	AC_DEFINE([USE_SHA256D], [1], [Defined to 1 if SHA256d mining support is wanted])
+fi
+
 algolist="$algolist scrypt"
 AC_ARG_ENABLE([scrypt],
 	[AC_HELP_STRING([--enable-scrypt],[Compile support for scrypt mining (default disabled)])],
@@ -1515,6 +1524,7 @@ AM_CONDITIONAL([NEED_BFG_LOWL_SPI], [test x$need_lowl_spi = xyes])
 AM_CONDITIONAL([NEED_BFG_LOWLEVEL], [test x$need_lowlevel = xyes])
 AM_CONDITIONAL([NEED_BFG_WORK2D], [test x$need_work2d = xyes])
 AM_CONDITIONAL([NEED_KNC_ASIC], [test x$need_knc_asic = xyes])
+AM_CONDITIONAL([USE_SHA256D], [test x$sha256d = xyes])
 AM_CONDITIONAL([HAS_SCRYPT], [test x$scrypt = xyes])
 AM_CONDITIONAL([HAVE_CURSES], [test x$curses = xyes])
 AM_CONDITIONAL([HAVE_SENSORS], [test x$with_sensors = xyes])

+ 2 - 0
deviceapi.c

@@ -94,8 +94,10 @@ float common_sha256d_and_scrypt_min_nonce_diff(struct cgpu_info * const proc, co
 		case POW_SCRYPT:
 			return 1./0x10000;
 #endif
+#ifdef USE_SHA256D
 		case POW_SHA256D:
 			return 1.;
+#endif
 		default:
 			return -1.;
 	}

+ 20 - 5
driver-cpu.c

@@ -99,9 +99,13 @@ extern bool scanhash_scrypt(struct thr_info *, struct work *, uint32_t max_nonce
 
 
 #ifdef WANT_CPUMINE
+#ifdef USE_SHA256D
 static size_t max_name_len = 0;
 static char *name_spaces_pad = NULL;
+#endif
+
 const char *algo_names[] = {
+#ifdef USE_SHA256D
 	[ALGO_C]		= "c",
 #ifdef WANT_SSE2_4WAY
 	[ALGO_4WAY]		= "4way",
@@ -125,13 +129,17 @@ const char *algo_names[] = {
 #ifdef WANT_ALTIVEC_4WAY
     [ALGO_ALTIVEC_4WAY] = "altivec_4way",
 #endif
+#endif
 #ifdef WANT_SCRYPT
     [ALGO_SCRYPT] = "scrypt",
 #endif
+#ifdef USE_SHA256D
 	[ALGO_FASTAUTO] = "fastauto",
 	[ALGO_AUTO] = "auto",
+#endif
 };
 
+#ifdef USE_SHA256D
 static const sha256_func sha256_funcs[] = {
 	[ALGO_C]		= (sha256_func)scanhash_c,
 #ifdef WANT_SSE2_4WAY
@@ -156,19 +164,21 @@ static const sha256_func sha256_funcs[] = {
 #ifdef WANT_X8664_SSE4
 	[ALGO_SSE4_64]		= (sha256_func)scanhash_sse4_64,
 #endif
-#ifdef WANT_SCRYPT
-	[ALGO_SCRYPT]		= (sha256_func)scanhash_scrypt
-#endif
 };
 #endif
+#endif
 
 
 
 #ifdef WANT_CPUMINE
+#ifdef USE_SHA256D
 enum sha256_algos opt_algo = ALGO_FASTAUTO;
+#endif
+
 static bool forced_n_threads;
 #endif
 
+#ifdef USE_SHA256D
 const uint32_t hash1_init[] = {
 	0,0,0,0,0,0,0,0,
 	0x80000000,
@@ -635,6 +645,7 @@ void show_algo(char buf[OPT_SHOW_LEN], const enum sha256_algos *algo)
 {
 	strncpy(buf, algo_names[*algo], OPT_SHOW_LEN);
 }
+#endif  /* USE_SHA256D */
 #endif
 
 #ifdef WANT_CPUMINE
@@ -699,7 +710,9 @@ static int cpu_autodetect()
 		cgpu->drv = &cpu_drv;
 		cgpu->deven = DEV_ENABLED;
 		cgpu->threads = 1;
+#ifdef USE_SHA256D
 		cgpu->kname = algo_names[opt_algo];
+#endif
 		add_cgpu(cgpu);
 	}
 	return opt_n_threads;
@@ -732,6 +745,7 @@ static uint64_t cpu_can_limit_work(struct thr_info __maybe_unused *thr)
 static bool cpu_thread_init(struct thr_info *thr)
 {
 	const int thr_id = thr->id;
+#ifdef USE_SHA256D
 	struct cgpu_info *cgpu = thr->cgpu;
 
 	mutex_lock(&cpualgo_lock);
@@ -746,6 +760,7 @@ static bool cpu_thread_init(struct thr_info *thr)
 	mutex_unlock(&cpualgo_lock);
 
 	cgpu->kname = algo_names[opt_algo];
+#endif
 	
 	/* Set worker threads to nice 19 and then preferentially to SCHED_IDLE
 	 * and if that fails, then SCHED_BATCH. No need for this to be an
@@ -761,12 +776,10 @@ static bool cpu_thread_init(struct thr_info *thr)
 
 static int64_t cpu_scanhash(struct thr_info *thr, struct work *work, int64_t max_nonce)
 {
-	unsigned char hash1[64];
 	uint32_t first_nonce = work->blk.nonce;
 	uint32_t last_nonce;
 	bool rc;
 
-	memcpy(&hash1[0], &hash1_init[0], sizeof(hash1));
 CPUSearch:
 	last_nonce = first_nonce;
 	rc = false;
@@ -781,9 +794,11 @@ CPUSearch:
 				func = scanhash_scrypt;
 				break;
 #endif
+#ifdef USE_SHA256D
 			case POW_SHA256D:
 				func = sha256_funcs[opt_algo];
 				break;
+#endif
 		}
 		if (unlikely(!func))
 			applogr(0, LOG_ERR, "%"PRIpreprv": Unknown mining algorithm", thr->cgpu->proc_repr);

+ 13 - 1
driver-cpu.h

@@ -22,6 +22,8 @@
 #define OPT_SHOW_LEN 80
 #endif
 
+#ifdef USE_SHA256D
+
 #if defined(__i386__) && defined(HAVE_SSE2)
 #define WANT_SSE2_4WAY 1
 #endif
@@ -46,11 +48,14 @@
 #define WANT_X8664_SSE4 1
 #endif
 
+#endif  /* USE_SHA256D */
+
 #ifdef USE_SCRYPT
 #define WANT_SCRYPT
 #endif
 
 enum sha256_algos {
+#ifdef USE_SHA256D
 	ALGO_C,			/* plain C */
 	ALGO_4WAY,		/* parallel SSE2 */
 	ALGO_VIA,		/* VIA padlock */
@@ -60,10 +65,17 @@ enum sha256_algos {
 	ALGO_SSE2_64,		/* SSE2 for x86_64 */
 	ALGO_SSE4_64,		/* SSE4 for x86_64 */
 	ALGO_ALTIVEC_4WAY,	/* parallel Altivec */
+#endif
+#ifdef USE_SCRYPT
 	ALGO_SCRYPT,		/* scrypt */
+#endif
 	
+#ifdef USE_SHA256D
 	ALGO_FASTAUTO,		/* fast autodetect */
-	ALGO_AUTO		/* autodetect */
+	ALGO_AUTO,		/* autodetect */
+#endif
+	
+	CUSTOM_CPU_MINING_ALGOS_COUNT,
 };
 
 extern const char *algo_names[];

+ 2 - 0
driver-dualminer.c

@@ -164,8 +164,10 @@ float dualminer_min_nonce_diff(struct cgpu_info * const proc, const struct minin
 		case POW_SCRYPT:
 			return ((!info) || dualminer_is_scrypt(info)) ? (1./0x10000) : -1.;
 #endif
+#ifdef USE_SHA256D
 		case POW_SHA256D:
 			return (info && dualminer_is_scrypt(info)) ? -1. : 1.;
+#endif
 		default:
 			return -1.;
 	}

+ 20 - 5
driver-opencl.c

@@ -411,10 +411,19 @@ bool _set_kernel(struct cgpu_info * const cgpu, const char *_val)
 		return false;
 	free(src);
 	
-	char **kfp = &data->kernel_file_sha256d;
+	char **kfp =
+#ifdef USE_SHA256D
+		&data->kernel_file_sha256d;
+#else
+		NULL;
+#endif
 #ifdef USE_SCRYPT
 	if (interface == KL_SCRYPT)
 		kfp = &data->kernel_file_scrypt;
+#endif
+#ifndef USE_SHA256D
+	if (!kfp)
+		return false;
 #endif
 	free(*kfp);
 	*kfp = strdup(_val);
@@ -989,14 +998,12 @@ const char *opencl_tui_handle_choice(struct cgpu_info *cgpu, int input)
 #define CL_SET_ARG(var) status |= clSetKernelArg(*kernel, num++, sizeof(var), (void *)&var)
 #define CL_SET_VARG(args, var) status |= clSetKernelArg(*kernel, num++, args * sizeof(uint), (void *)var)
 
+#ifdef USE_SHA256D
 static
 void *_opencl_work_data_dup(struct work * const work)
 {
 	struct opencl_work_data *p = malloc(sizeof(*p));
 	memcpy(p, work->device_data, sizeof(*p));
-#ifdef USE_SCRYPT
-	p->work = work;
-#endif
 	return p;
 }
 
@@ -1235,6 +1242,7 @@ cl_int queue_diablo_kernel(const struct opencl_kernel_info * const kinfo, _clSta
 
 	return status;
 }
+#endif
 
 #ifdef USE_SCRYPT
 static
@@ -1266,10 +1274,12 @@ cl_int queue_scrypt_kernel(const struct opencl_kernel_info * const kinfo, _clSta
 static
 struct opencl_kernel_interface kernel_interfaces[] = {
 	{NULL},
+#ifdef USE_SHA256D
 	{"poclbm",  queue_poclbm_kernel },
 	{"phatk",   queue_phatk_kernel  },
 	{"diakgcn", queue_diakgcn_kernel},
 	{"diablo",  queue_diablo_kernel },
+#endif
 #ifdef USE_SCRYPT
 	{"scrypt",  queue_scrypt_kernel },
 #endif
@@ -1680,7 +1690,7 @@ static bool opencl_thread_init(struct thr_info *thr)
 	return true;
 }
 
-
+#ifdef USE_SHA256D
 static bool opencl_prepare_work(struct thr_info __maybe_unused *thr, struct work *work)
 {
 	const struct mining_algorithm * const malgo = work_mining_algorithm(work);
@@ -1691,6 +1701,7 @@ static bool opencl_prepare_work(struct thr_info __maybe_unused *thr, struct work
 	}
 	return true;
 }
+#endif
 
 extern int opt_dynamic_interval;
 
@@ -1701,6 +1712,7 @@ const struct opencl_kernel_info *opencl_scanhash_get_kernel(struct cgpu_info * c
 	char *kernel_file;
 	switch (malgo->algo)
 	{
+#ifdef USE_SHA256D
 		case POW_SHA256D:
 			kernelinfo = &clState->kernel_sha256d;
 			if (!data->kernel_file_sha256d)
@@ -1738,6 +1750,7 @@ const struct opencl_kernel_info *opencl_scanhash_get_kernel(struct cgpu_info * c
 			}
 			kernel_file = data->kernel_file_sha256d;
 			break;
+#endif
 #ifdef USE_SCRYPT
 		case POW_SCRYPT:
 			kernelinfo = &clState->kernel_scrypt;
@@ -1968,7 +1981,9 @@ struct device_drv opencl_api = {
 	.get_api_extra_device_status = get_opencl_api_extra_device_status,
 	.thread_prepare = opencl_thread_prepare,
 	.thread_init = opencl_thread_init,
+#ifdef USE_SHA256D
 	.prepare_work = opencl_prepare_work,
+#endif
 	.scanhash = opencl_scanhash,
 	.thread_shutdown = opencl_thread_shutdown,
 };

+ 4 - 3
driver-opencl.h

@@ -32,7 +32,9 @@ struct opencl_device_data {
 	
 	cl_uint vwidth;
 	size_t work_size;
+#ifdef USE_SHA256D
 	char *kernel_file_sha256d;
+#endif
 	cl_ulong max_alloc;
 	
 	enum opencl_binary_usage opt_opencl_binaries;
@@ -68,6 +70,7 @@ extern float opencl_proc_get_intensity(struct cgpu_info *, const char **iunit);
 extern unsigned long xintensity_to_oclthreads(double xintensity, cl_uint max_compute_units);
 extern bool opencl_set_intensity_from_str(struct cgpu_info *, const char *newvalue);
 
+#ifdef USE_SHA256D
 struct opencl_work_data {
 	cl_uint ctx_a; cl_uint ctx_b; cl_uint ctx_c; cl_uint ctx_d;
 	cl_uint ctx_e; cl_uint ctx_f; cl_uint ctx_g; cl_uint ctx_h;
@@ -91,10 +94,8 @@ struct opencl_work_data {
 	cl_uint B1addK6, PreVal0addK7, W16addK16, W17addK17;
 	cl_uint zeroA, zeroB;
 	cl_uint oneA, twoA, threeA, fourA, fiveA, sixA, sevenA;
-#ifdef USE_SCRYPT
-	struct work *work;
-#endif
 };
+#endif
 
 extern void opencl_early_init();
 extern char *print_ndevs_and_exit(int *ndevs);

+ 2 - 0
findnonce.c

@@ -22,6 +22,7 @@
 #include "miner.h"
 #include "scrypt.h"
 
+#ifdef USE_SHA256D
 const uint32_t SHA256_K[64] = {
 	0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
 	0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
@@ -133,6 +134,7 @@ void precalc_hash(struct opencl_work_data *blk, uint32_t *state, uint32_t *data)
 	blk->sixA = blk->ctx_g + SHA256_K[6];
 	blk->sevenA = blk->ctx_h + SHA256_K[7];
 }
+#endif
 
 struct pc_data {
 	struct thr_info *thr;

+ 2 - 0
findnonce.h

@@ -23,7 +23,9 @@
 #endif
 
 #ifdef HAVE_OPENCL
+#ifdef USE_SHA256D
 extern void precalc_hash(struct opencl_work_data *blk, uint32_t *state, uint32_t *data);
+#endif
 extern void postcalc_hash_async(struct thr_info *thr, struct work *work, uint32_t *res);
 #endif /* HAVE_OPENCL */
 #endif /*__FINDNONCE_H__*/

+ 34 - 8
miner.c

@@ -516,7 +516,11 @@ float drv_min_nonce_diff(const struct device_drv * const drv, struct cgpu_info *
 {
 	if (drv->drv_min_nonce_diff)
 		return drv->drv_min_nonce_diff(proc, malgo);
+#ifdef USE_SHA256D
 	return (malgo->algo == POW_SHA256D) ? 1. : -1.;
+#else
+	return -1.;
+#endif
 }
 
 char *devpath_to_devid(const char *devpath)
@@ -1030,7 +1034,7 @@ struct mining_algorithm *mining_algorithm_by_alias(const char * const alias)
 }
 
 
-#ifdef HAVE_OPENCL
+#if defined(USE_SHA256D) && defined(HAVE_OPENCL)
 static
 float opencl_oclthreads_to_intensity_sha256d(const unsigned long oclthreads)
 {
@@ -1044,6 +1048,7 @@ unsigned long opencl_intensity_to_oclthreads_sha256d(float intensity)
 }
 #endif
 
+#ifdef USE_SHA256D
 static struct mining_algorithm malgo_sha256d = {
 	.name = "SHA256d",
 	.aliases = "SHA256d|SHA256|SHA2",
@@ -1063,6 +1068,7 @@ static struct mining_algorithm malgo_sha256d = {
 	.opencl_max_oclthreads = 0x20000000,  // intensity  14
 #endif
 };
+#endif
 
 
 #ifdef USE_SCRYPT
@@ -1111,7 +1117,9 @@ static
 __attribute__((constructor))
 void init_mining_goals(struct mining_goal_info * const goal, const struct mining_algorithm * const malgo)
 {
+#ifdef USE_SHA256D
 	LL_APPEND(mining_algorithms, (&malgo_sha256d));
+#endif
 #ifdef USE_SCRYPT
 	LL_APPEND(mining_algorithms, (&malgo_scrypt));
 #endif
@@ -1159,7 +1167,12 @@ struct mining_goal_info *get_mining_goal(const char * const name)
 			.blkchain = blkchain,
 			.current_diff = 0xFFFFFFFFFFFFFFFFULL,
 		};
+#ifdef HAVE_SHA256D
 		goal_set_malgo(goal, &malgo_sha256d);
+#else
+		// NOTE: Basically random default
+		goal_set_malgo(goal, mining_algorithms);
+#endif
 		HASH_ADD_STR(mining_goals, name, goal);
 		HASH_SORT(mining_goals, mining_goals_name_cmp);
 		
@@ -1322,6 +1335,14 @@ struct pool *current_pool(void)
 	return pool;
 }
 
+#if defined(USE_CPUMINING) && !defined(USE_SHA256D)
+static
+char *arg_ignored(const char * const arg)
+{
+	return NULL;
+}
+#endif
+
 static
 char *set_bool_ignore_arg(const char * const arg, bool * const b)
 {
@@ -2295,6 +2316,7 @@ static char *set_null(const char __maybe_unused *arg)
 /* These options are available from config file or commandline */
 static struct opt_table opt_config_table[] = {
 #ifdef WANT_CPUMINE
+#ifdef USE_SHA256D
 	OPT_WITH_ARG("--algo",
 		     set_algo, show_algo, &opt_algo,
 		     "Specify sha256 implementation for CPU mining:\n"
@@ -2327,7 +2349,11 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITH_ARG("-a",
 	             set_algo, show_algo, &opt_algo,
 	             opt_hidden),
-#endif
+#else
+	// NOTE: Silently ignoring option, since it is plausable a non-SHA256d miner was using it just to skip benchmarking
+	OPT_WITH_ARG("--algo|-a", arg_ignored, NULL, NULL, opt_hidden),
+#endif  /* USE_SHA256D */
+#endif  /* WANT_CPUMINE */
 	OPT_WITH_ARG("--api-allow",
 		     set_api_allow, NULL, NULL,
 		     "Allow API access only to the given list of [G:]IP[/Prefix] addresses[/subnets]"),
@@ -7831,7 +7857,7 @@ void write_config(FILE *fcfg)
 #ifdef HAVE_OPENCL
 	write_config_opencl(fcfg);
 #endif
-#ifdef WANT_CPUMINE
+#if defined(WANT_CPUMINE) && defined(USE_SHA256D)
 	fprintf(fcfg, ",\n\"algo\" : \"%s\"", algo_names[opt_algo]);
 #endif
 
@@ -11683,7 +11709,7 @@ void print_summary(void)
 	applog(LOG_WARNING, "Started at %s", datestamp);
 	if (total_pools == 1)
 		applog(LOG_WARNING, "Pool: %s", pools[0]->rpc_url);
-#ifdef WANT_CPUMINE
+#if defined(WANT_CPUMINE) && defined(USE_SHA256D)
 	if (opt_n_threads > 0)
 		applog(LOG_WARNING, "CPU hasher algorithm used: %s", algo_names[opt_algo]);
 #endif
@@ -11977,7 +12003,7 @@ out:
 }
 #endif
 
-#if BLKMAKER_VERSION > 1
+#if BLKMAKER_VERSION > 1 && defined(USE_SHA256D)
 static
 bool _add_local_gbt(const char * const filepath, void *userp)
 {
@@ -13172,7 +13198,7 @@ int main(int argc, char *argv[])
 
 	snprintf(packagename, sizeof(packagename), "%s %s", PACKAGE, VERSION);
 
-#ifdef WANT_CPUMINE
+#if defined(WANT_CPUMINE) && defined(USE_SHA256D)
 	init_max_name_len();
 #endif
 
@@ -13454,7 +13480,7 @@ int main(int argc, char *argv[])
 	switch_logsize();
 #endif
 
-#if BLKMAKER_VERSION > 1
+#if BLKMAKER_VERSION > 1 && defined(USE_SHA256D)
 	if (opt_load_bitcoin_conf && !(get_mining_goal("default")->malgo->algo != POW_SHA256D || opt_benchmark))
 		add_local_gbt(total_pools);
 #endif
@@ -13605,7 +13631,7 @@ begin_bench:
 		pause_dynamic_threads(i);
 #endif
 
-#ifdef WANT_CPUMINE
+#if defined(WANT_CPUMINE) && defined(USE_SHA256D)
 	if (opt_n_threads > 0)
 		applog(LOG_INFO, "%d cpu miner threads started, using '%s' algorithm.",
 		       opt_n_threads, algo_names[opt_algo]);

+ 4 - 0
miner.h

@@ -277,7 +277,9 @@ struct gpu_adl {
 #endif
 
 enum pow_algorithm {
+#ifdef USE_SHA256D
 	POW_SHA256D = 1,
+#endif
 #ifdef USE_SCRYPT
 	POW_SCRYPT  = 2,
 #endif
@@ -372,10 +374,12 @@ enum dev_enable {
 
 enum cl_kernels {
 	KL_NONE,
+#ifdef USE_SHA256D
 	KL_POCLBM,
 	KL_PHATK,
 	KL_DIAKGCN,
 	KL_DIABLO,
+#endif
 #ifdef USE_SCRYPT
 	KL_SCRYPT,
 #endif

+ 4 - 0
ocl.c

@@ -733,6 +733,7 @@ bool opencl_load_kernel(struct cgpu_info * const cgpu, _clState * const clState,
 			       cgpu->dev_repr, kernel_file);
 			free(source);
 			return false;
+#ifdef USE_SHA256D
 		case KL_PHATK:
 			if ((strstr(vbuff, "844.4") || strstr(vbuff, "851.4") ||
 			     strstr(vbuff, "831.4") || strstr(vbuff, "898.1") ||
@@ -743,6 +744,7 @@ bool opencl_load_kernel(struct cgpu_info * const cgpu, _clState * const clState,
 				applog(LOG_WARNING, "Downgrade your SDK and delete any .bin files before starting again.");
 				applog(LOG_WARNING, "Or allow BFGMiner to automatically choose a more suitable kernel.");
 			}
+#endif
 		default:
 			;
 	}
@@ -754,6 +756,7 @@ bool opencl_load_kernel(struct cgpu_info * const cgpu, _clState * const clState,
 		int kernel_goffset_support = 0;  // 0 = none; 1 = optional; 2 = required
 		switch (kernelinfo->interface)
 		{
+#ifdef USE_SHA256D
 			case KL_DIABLO:
 			case KL_DIAKGCN:
 			case KL_POCLBM:
@@ -762,6 +765,7 @@ bool opencl_load_kernel(struct cgpu_info * const cgpu, _clState * const clState,
 			case KL_PHATK:
 				kernel_goffset_support = 0;
 				break;
+#endif
 			case KL_NONE: case OPENCL_KERNEL_INTERFACE_COUNT:
 #ifdef USE_SCRYPT
 			case KL_SCRYPT:

+ 4 - 0
util.c

@@ -790,6 +790,7 @@ char *ucs2_to_utf8_dup(uint16_t * const in, size_t sz)
 	return out;
 }
 
+#ifdef USE_SHA256D
 void hash_data(void *out_hash, const void *data)
 {
 	unsigned char blkheader[80];
@@ -800,6 +801,7 @@ void hash_data(void *out_hash, const void *data)
 	// double-SHA256 to get the block hash
 	gen_hash(blkheader, out_hash, 80);
 }
+#endif
 
 // Example output: 0000000000000000000000000000000000000000000000000000ffff00000000 (bdiff 1)
 void real_block_target(unsigned char *target, const unsigned char *data)
@@ -2659,8 +2661,10 @@ static bool parse_diff(struct pool *pool, json_t *val)
 		diff = bdiff_to_pdiff(diff);
 	}
 	
+#ifdef USE_SHA256D
 	if (malgo->algo == POW_SHA256D && diff < 1 && diff > 0.999)
 		diff = 1;
+#endif
 	
 #ifdef USE_SCRYPT
 	// Broken Scrypt pools multiply difficulty by 0x10000