Configure out building and support of all CPU mining code unless --enable-cpumining is enabled.
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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
diff --git a/Makefile.am b/Makefile.am
index 4a6b25e..da4a365 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,7 @@ bin_PROGRAMS = cgminer
bin_SCRIPTS = phatk110817.cl poclbm110817.cl
+if HAS_CPUMINE
cgminer_SOURCES = elist.h miner.h compat.h bench_block.h \
main.c util.c uthash.h \
ocl.c ocl.h findnonce.c findnonce.h \
@@ -29,6 +30,14 @@ cgminer_SOURCES = elist.h miner.h compat.h bench_block.h \
adl.c adl.h adl_functions.h \
phatk110817.cl poclbm110817.cl \
sha2.c sha2.h api.c
+else
+cgminer_SOURCES = elist.h miner.h compat.h bench_block.h \
+ main.c util.c uthash.h \
+ ocl.c ocl.h findnonce.c findnonce.h \
+ adl.c adl.h adl_functions.h \
+ phatk110817.cl poclbm110817.cl \
+ sha2.c sha2.h api.c
+endif
cgminer_LDFLAGS = $(PTHREAD_FLAGS)
cgminer_LDADD = $(DLOPEN_FLAGS) @LIBCURL_LIBS@ @JANSSON_LIBS@ @PTHREAD_LIBS@ \
@@ -36,6 +45,7 @@ cgminer_LDADD = $(DLOPEN_FLAGS) @LIBCURL_LIBS@ @JANSSON_LIBS@ @PTHREAD_LIBS@ \
@MATH_LIBS@ lib/libgnu.a ccan/libccan.a
cgminer_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib @OPENCL_FLAGS@
+if HAS_CPUMINE
if HAVE_x86_64
if HAS_YASM
SUBDIRS += x86_64
@@ -49,3 +59,4 @@ cgminer_LDADD += x86_32/libx8632.a
AM_CFLAGS = -DHAS_YASM
endif
endif
+endif
diff --git a/api.c b/api.c
index 86c7c2d..f6c4615 100644
--- a/api.c
+++ b/api.c
@@ -616,13 +616,16 @@ void summary(SOCKETTYPE c, char *param, bool isjson)
{
double utility, mhs;
+#ifdef WANT_CPUMINE
char *algo = (char *)(algo_names[opt_algo]);
if (algo == NULL)
algo = "(null)";
+#endif
utility = total_accepted / ( total_secs ? total_secs : 1 ) * 60;
mhs = total_mhashes_done / total_secs;
+#ifdef WANT_CPUMINE
if (isjson)
sprintf(io_buffer, "%s," JSON_SUMMARY "{\"Elapsed\":%.0f,\"Algorithm\":\"%s\",\"MHS av\":%.2f,\"Found Blocks\":%d,\"Getworks\":%d,\"Accepted\":%d,\"Rejected\":%d,\"Hardware Errors\":%d,\"Utility\":%.2f,\"Discarded\":%d,\"Stale\":%d,\"Get Failures\":%d,\"Local Work\":%u,\"Remote Failures\":%u,\"Network Blocks\":%u}" JSON_CLOSE,
message(MSG_SUMM, 0, isjson),
@@ -637,6 +640,22 @@ void summary(SOCKETTYPE c, char *param, bool isjson)
total_getworks, total_accepted, total_rejected,
hw_errors, utility, total_discarded, total_stale,
total_go, local_work, total_ro, new_blocks, SEPARATOR);
+#else
+ if (isjson)
+ sprintf(io_buffer, "%s," JSON_SUMMARY "{\"Elapsed\":%.0f,\"MHS av\":%.2f,\"Found Blocks\":%d,\"Getworks\":%d,\"Accepted\":%d,\"Rejected\":%d,\"Hardware Errors\":%d,\"Utility\":%.2f,\"Discarded\":%d,\"Stale\":%d,\"Get Failures\":%d,\"Local Work\":%u,\"Remote Failures\":%u,\"Network Blocks\":%u}" JSON_CLOSE,
+ message(MSG_SUMM, 0, isjson),
+ total_secs, mhs, found_blocks,
+ total_getworks, total_accepted, total_rejected,
+ hw_errors, utility, total_discarded, total_stale,
+ total_go, local_work, total_ro, new_blocks);
+ else
+ sprintf(io_buffer, "%s" _SUMMARY ",Elapsed=%.0f,MHS av=%.2f,Found Blocks=%d,Getworks=%d,Accepted=%d,Rejected=%d,Hardware Errors=%d,Utility=%.2f,Discarded=%d,Stale=%d,Get Failures=%d,Local Work=%u,Remote Failures=%u,Network Blocks=%u%c",
+ message(MSG_SUMM, 0, isjson),
+ total_secs, mhs, found_blocks,
+ total_getworks, total_accepted, total_rejected,
+ hw_errors, utility, total_discarded, total_stale,
+ total_go, local_work, total_ro, new_blocks, SEPARATOR);
+#endif
}
void gpuenable(SOCKETTYPE c, char *param, bool isjson)
diff --git a/configure.ac b/configure.ac
index 2a5e035..f5077c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,6 +119,7 @@ AC_ARG_ENABLE([cpumining],
if test "x$cpumining" = xyes; then
AC_DEFINE_UNQUOTED([WANT_CPUMINE], [1], [Enable CPUMINING])
fi
+AM_CONDITIONAL([HAS_CPUMINE], [test x$cpumining = xyes])
AC_ARG_ENABLE([opencl],
[AC_HELP_STRING([--disable-opencl],[Override detection and disable building with opencl])],
@@ -316,9 +317,15 @@ if test "x$opencl" != xno; then
echo " OpenCL...............: FOUND. GPU mining support enabled"
else
echo " OpenCL...............: NOT FOUND. GPU mining support DISABLED"
+ if test "x$cpumining" != xyes; then
+ AC_MSG_ERROR([No mining configured in])
+ fi
fi
else
echo " OpenCL...............: Detection overrided. GPU mining support DISABLED"
+ if test "x$cpumining" != xyes; then
+ AC_MSG_ERROR([No mining configured in])
+ fi
fi
if test "x$adl" != xno; then
@@ -334,10 +341,10 @@ fi
echo
if test "x$cpumining" = xyes; then
- echo " CPU MINING...........: Enabled"
+ echo " CPU Mining...........: Enabled"
echo " ASM.(for CPU mining).: $has_yasm"
else
- echo " CPU MINING...........: Disabled"
+ echo " CPU Mining...........: Disabled"
fi
echo
echo "Compilation............: make (or gmake)"
diff --git a/main.c b/main.c
index dbcfc27..47ca70b 100644
--- a/main.c
+++ b/main.c
@@ -118,6 +118,7 @@ struct strategies {
{ "Load Balance" },
};
+#ifdef WANT_CPUMINE
static size_t max_name_len = 0;
static char *name_spaces_pad = NULL;
const char *algo_names[] = {
@@ -171,6 +172,7 @@ static const sha256_func sha256_funcs[] = {
[ALGO_SSE4_64] = (sha256_func)scanhash_sse4_64
#endif
};
+#endif
static char packagename[255];
@@ -195,7 +197,8 @@ int opt_scantime = 60;
int opt_expiry = 120;
int opt_bench_algo = -1;
static const bool opt_time = true;
-static bool opt_restart = true;
+
+#ifdef WANT_CPUMINE
#if defined(WANT_X8664_SSE2) && defined(__SSE2__)
enum sha256_algos opt_algo = ALGO_SSE2_64;
#elif defined(WANT_X8632_SSE2) && defined(__SSE2__)
@@ -203,6 +206,16 @@ enum sha256_algos opt_algo = ALGO_SSE2_32;
#else
enum sha256_algos opt_algo = ALGO_C;
#endif
+static bool opt_usecpu;
+static int cpur_thr_id;
+static bool forced_n_threads;
+#endif
+
+#ifdef HAVE_OPENCL
+static bool opt_restart = true;
+static bool opt_nogpu;
+#endif
+
int nDevs;
static int opt_g_threads = 2;
static signed int devices_enabled = 0;
@@ -211,14 +224,11 @@ int total_devices = 0;
struct cgpu_info *devices[MAX_DEVICES];
bool have_opencl = false;
int gpu_threads;
-static bool forced_n_threads;
int opt_n_threads = -1;
int mining_threads;
int num_processors;
bool use_curses = true;
static bool opt_submit_stale;
-static bool opt_nogpu;
-static bool opt_usecpu;
static int opt_shares;
static bool opt_fail_only;
bool opt_autofan;
@@ -241,7 +251,6 @@ static int stage_thr_id;
static int watchdog_thr_id;
static int input_thr_id;
static int gpur_thr_id;
-static int cpur_thr_id;
static int api_thr_id;
static int total_threads;
@@ -466,6 +475,7 @@ static struct pool *current_pool(void)
return pool;
}
+#ifdef WANT_CPUMINE
// Algo benchmark, crash-prone, system independent stage
static double bench_algo_stage3(
enum sha256_algos algo
@@ -939,6 +949,7 @@ static void show_algo(char buf[OPT_SHOW_LEN], const enum sha256_algos *algo)
{
strncpy(buf, algo_names[*algo], OPT_SHOW_LEN);
}
+#endif
static char *set_int_range(const char *arg, int *i, int min, int max)
{
@@ -962,11 +973,13 @@ static char *set_int_1_to_65535(const char *arg, int *i)
return set_int_range(arg, i, 1, 65535);
}
+#ifdef WANT_CPUMINE
static char *force_nthreads_int(const char *arg, int *i)
{
forced_n_threads = true;
return set_int_range(arg, i, 0, 9999);
}
+#endif
static char *set_int_0_to_10(const char *arg, int *i)
{
@@ -1098,6 +1111,7 @@ static char *set_userpass(const char *arg)
return NULL;
}
+#ifdef HAVE_OPENCL
static char *set_vector(const char *arg, int *i)
{
char *err = opt_set_intval(arg, i);
@@ -1108,6 +1122,7 @@ static char *set_vector(const char *arg, int *i)
return "Valid vectors are 1, 2 or 4";
return NULL;
}
+#endif
static char *enable_debug(bool *flag)
{
@@ -1479,6 +1494,7 @@ static char *set_api_description(const char *arg)
/* These options are available from config file or commandline */
static struct opt_table opt_config_table[] = {
+#ifdef WANT_CPUMINE
OPT_WITH_ARG("--algo|-a",
set_algo, show_algo, &opt_algo,
"Specify sha256 implementation for CPU mining:\n"
@@ -1507,6 +1523,7 @@ static struct opt_table opt_config_table[] = {
"\n\taltivec_4way\tAltivec implementation for PowerPC G4 and G5 machines"
#endif
),
+#endif
OPT_WITH_ARG("--api-description",
set_api_description, NULL, NULL,
"Description placed in the API status header, default: cgminer version"),
@@ -1527,12 +1544,14 @@ static struct opt_table opt_config_table[] = {
opt_set_bool, &opt_autoengine,
"Automatically adjust all GPU engine clock speeds to maintain a target temperature"),
#endif
+#ifdef WANT_CPUMINE
OPT_WITH_ARG("--bench-algo|-b",
set_int_0_to_9999, opt_show_intval, &opt_bench_algo,
opt_hidden),
OPT_WITH_ARG("--cpu-threads|-t",
force_nthreads_int, opt_show_intval, &opt_n_threads,
"Number of miner CPU threads"),
+#endif
OPT_WITHOUT_ARG("--debug|-D",
enable_debug, &opt_debug,
"Enable debug output"),
@@ -1548,10 +1567,12 @@ static struct opt_table opt_config_table[] = {
set_float_0_to_99, &opt_show_floatval, &opt_donation,
"Set donation percentage to cgminer author (0.0 - 99.9)"),
#ifdef HAVE_OPENCL
+#ifdef WANT_CPUMINE
OPT_WITHOUT_ARG("--enable-cpu|-C",
opt_set_bool, &opt_usecpu,
"Enable CPU mining with GPU mining (default: no CPU mining if suitable GPUs exist)"),
#endif
+#endif
OPT_WITH_ARG("--expiry|-E",
set_int_0_to_9999, opt_show_intval, &opt_expiry,
"Upper bound on how many seconds after getting work we consider a share from it stale"),
@@ -1813,10 +1834,18 @@ static char *opt_verusage_and_exit(const char *extra)
{
printf("%s\n"
#ifdef HAVE_OPENCL
+#ifdef WANT_CPUMINE
"Built with CPU and GPU mining support.\n"
-#else
+#else /* WANT_CPUMINE */
+ "Built with GPU mining support only.\n"
+#endif /* WANT_CPUMINE */
+#else /* HAVE_OPENCL */
+#ifdef WANT_CPUMINE
"Built with CPU mining support only.\n"
-#endif
+#else /* WANT_CPUMINE */
+ "Built with NO MINING support lol wtf.\n"
+#endif /* WANT_CPUMINE */
+#endif /* HAVE_OPENCL */
, packagename);
printf("%s", opt_usage(opt_argv0, extra));
fflush(stdout);
@@ -2026,8 +2055,10 @@ static void curses_print_status(void)
wattron(statuswin, A_BOLD);
mvwprintw(statuswin, 0, 0, " " PACKAGE " version " VERSION " - Started: %s", datestamp);
+#ifdef WANT_CPUMINE
if (opt_n_threads)
wprintw(statuswin, " CPU Algo: %s", algo_names[opt_algo]);
+#endif
wattroff(statuswin, A_BOLD);
mvwhline(statuswin, 1, 0, '-', 80);
mvwprintw(statuswin, 2, 0, " %s", statusline);
@@ -3123,9 +3154,14 @@ static void write_config(FILE *fcfg)
for(i = 0; i < nDevs; i++)
fprintf(fcfg, "%s%d", i > 0 ? "," : "", gpus[i].adl.targettemp);
#endif
- fputs("\",\n", fcfg);
+ fputs("\"", fcfg);
+#ifdef WANT_CPUMINE
+ fputs(",\n", fcfg);
+#endif
}
+#ifdef WANT_CPUMINE
fprintf(fcfg, "\n\"algo\" : \"%s\"", algo_names[opt_algo]);
+#endif
/* Simple bool and int options */
struct opt_table *opt;
@@ -4716,39 +4752,6 @@ static void start_longpoll(void)
tq_push(thr_info[longpoll_thr_id].q, &ping);
}
-static void *reinit_cpu(void *userdata)
-{
- pthread_detach(pthread_self());
-#if 0
- struct cgpu_info *cgpu = (struct cgpu_info *)userdata;
- int cpu = cgpu->device_id;
- long thr_id = ....(long)userdata;
- struct thr_info *thr = &thr_info[thr_id];
- int cpu = dev_from_id(thr_id);
-
- cpus[cpu].alive = false;
- thr->rolling = thr->cgpu->rolling = 0;
- tq_freeze(thr->q);
- if (!pthread_cancel(*thr->pth))
- pthread_join(*thr->pth, NULL);
- free(thr->q);
- thr->q = tq_new();
- if (!thr->q)
- quit(1, "Failed to tq_new in reinit_cputhread");
-
- applog(LOG_INFO, "Reinit CPU thread %d", thr_id);
-
- if (unlikely(thr_info_create(thr, NULL, miner_thread, thr))) {
- applog(LOG_ERR, "thread %d create failed", thr_id);
- return NULL;
- }
- tq_push(thr->q, &ping);
-
- applog(LOG_WARNING, "Thread %d restarted", thr_id);
-#endif
- return NULL;
-}
-
#ifdef HAVE_OPENCL
/* We have only one thread that ever re-initialises GPUs, thus if any GPU
* init command fails due to a completely wedged GPU, the thread will never
@@ -4859,6 +4862,7 @@ out:
#else
static void *reinit_gpu(void *userdata)
{
+ return NULL;
}
#endif
@@ -5079,8 +5083,10 @@ static 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 (opt_n_threads)
applog(LOG_WARNING, "CPU hasher algorithm used: %s", algo_names[opt_algo]);
+#endif
applog(LOG_WARNING, "Runtime: %d hrs : %d mins : %d secs", hours, mins, secs);
if (total_secs)
applog(LOG_WARNING, "Average hashrate: %.1f Megahash/s", total_mhashes_done / total_secs);
@@ -5347,9 +5353,9 @@ static void enable_curses(void) {
unlock_curses();
}
-
struct device_api cpu_api;
+#ifdef WANT_CPUMINE
static void cpu_detect()
{
int i;
@@ -5493,7 +5499,7 @@ struct device_api cpu_api = {
.thread_init = cpu_thread_init,
.scanhash = cpu_scanhash,
};
-
+#endif
#ifdef HAVE_OPENCL
struct device_api opencl_api;
@@ -5797,7 +5803,6 @@ struct device_api opencl_api = {
};
#endif
-
static int cgminer_id_count = 0;
void enable_device(struct cgpu_info *cgpu)
@@ -5839,7 +5844,9 @@ int main (int argc, char *argv[])
sprintf(packagename, "%s %s", PACKAGE, VERSION);
+#ifdef WANT_CPUMINE
init_max_name_len();
+#endif
handler.sa_handler = &sighandler;
handler.sa_flags = 0;
@@ -5852,7 +5859,7 @@ int main (int argc, char *argv[])
cgminer_path = alloca(PATH_MAX);
strcpy(cgminer_path, dirname(argv[0]));
strcat(cgminer_path, "/");
-
+#ifdef WANT_CPUMINE
// Hack to make cgminer silent when called recursively on WIN32
int skip_to_bench = 0;
#if defined(WIN32)
@@ -5860,6 +5867,7 @@ int main (int argc, char *argv[])
if (GetEnvironmentVariable("CGMINER_BENCH_ALGO", buf, 16))
skip_to_bench = 1;
#endif // defined(WIN32)
+#endif
block = calloc(sizeof(struct block), 1);
if (unlikely(!block))
@@ -5895,6 +5903,7 @@ int main (int argc, char *argv[])
if (want_per_device_stats)
opt_log_output = true;
+#ifdef WANT_CPUMINE
if (0<=opt_bench_algo) {
double rate = bench_algo_stage3(opt_bench_algo);
if (!skip_to_bench) {
@@ -5930,13 +5939,16 @@ int main (int argc, char *argv[])
}
exit(0);
}
+#endif
#ifdef HAVE_OPENCL
if (!opt_nogpu)
opencl_api.api_detect();
#endif
+#ifdef WANT_CPUMINE
cpu_api.api_detect();
+#endif
if (devices_enabled == -1) {
applog(LOG_ERR, "Devices detected:");
@@ -6168,10 +6180,12 @@ retry_pools:
applog(LOG_INFO, "%d gpu miner threads started", gpu_threads);
+#ifdef WANT_CPUMINE
applog(LOG_INFO, "%d cpu miner threads started, "
"using SHA256 '%s' algorithm.",
opt_n_threads,
algo_names[opt_algo]);
+#endif
if (use_curses)
enable_curses();
@@ -6189,6 +6203,8 @@ retry_pools:
quit(1, "input thread create failed");
pthread_detach(thr->pth);
+#if 0
+#ifdef WANT_CPUMINE
/* Create reinit cpu thread */
cpur_thr_id = mining_threads + 5;
thr = &thr_info[cpur_thr_id];
@@ -6197,6 +6213,8 @@ retry_pools:
quit(1, "tq_new failed for cpur_thr_id");
if (thr_info_create(thr, NULL, reinit_cpu, thr))
quit(1, "reinit_cpu thread create failed");
+#endif
+#endif
/* Create reinit gpu thread */
gpur_thr_id = mining_threads + 6;