Browse Source

Merge branch 'master' into build-msvs2010-upd

Conflicts (resolved):
	sgminer.c
nfactor-troky
Noel Maersk 11 years ago
parent
commit
b97a641ed9
  1. 9
      AUTHORS.md
  2. 8
      README.md
  3. 21
      api.c
  4. 22
      compat.h
  5. 3
      doc/BUGS.md
  6. 4
      doc/KERNEL.md
  7. 1
      miner.h
  8. 13
      ocl.c
  9. 43
      sgminer.c

9
AUTHORS.md

@ -19,17 +19,18 @@ updated by many others.
* alexkarnew/alexkarold: Alexey Karimov LMqRcHdwnZtTMH6c2kWoxSoKM5KySfaP5C * alexkarnew/alexkarold: Alexey Karimov LMqRcHdwnZtTMH6c2kWoxSoKM5KySfaP5C
## Testing and bug fixes ## Testing, bug fixes, improvements
* Gabriel Devenyi <gdevenyi> * Gabriel Devenyi <gdevenyi>
* Benjamin Herrenschmidt <ozbenh> * Benjamin Herrenschmidt <ozbenh>
* Joe4782 * Joe4782 <Joe4782>
* gacheson * gacheson <gacheson>
* tonobitc <tonobitc>
* Perry Huang <perryh>
...and many others. See: ...and many others. See:
* [veox/sgminer](https://github.com/veox/sgminer/graphs/contributors) * [veox/sgminer](https://github.com/veox/sgminer/graphs/contributors)
* [ckolivas/cgminer](https://github.com/ckolivas/cgminer/graphs/contributors)
## Legacy ## Legacy

8
README.md

@ -8,7 +8,13 @@ This is a multi-threaded multi-pool GPU miner with ATI GPU monitoring,
cgminer by Con Kolivas (ckolivas), which is in turn based on cpuminer by cgminer by Con Kolivas (ckolivas), which is in turn based on cpuminer by
Jeff Garzik (jgarzik). Jeff Garzik (jgarzik).
GIT TREE: https://github.com/veox/sgminer **releases**: https://github.com/veox/sgminer/releases
**git tree**: https://github.com/veox/sgminer
**issues**: https://github.com/veox/sgminer/issues
**irc**: `#sgminer` on freenode
License: GPLv3. See `COPYING` for details. License: GPLv3. See `COPYING` for details.

21
api.c

@ -756,6 +756,7 @@ static struct api_data *api_add_data_full(struct api_data *root, char *name, enu
case API_DOUBLE: case API_DOUBLE:
case API_ELAPSED: case API_ELAPSED:
case API_MHS: case API_MHS:
case API_KHS:
case API_MHTOTAL: case API_MHTOTAL:
case API_UTILITY: case API_UTILITY:
case API_FREQ: case API_FREQ:
@ -868,6 +869,11 @@ struct api_data *api_add_mhs(struct api_data *root, char *name, double *data, bo
return api_add_data_full(root, name, API_MHS, (void *)data, copy_data); return api_add_data_full(root, name, API_MHS, (void *)data, copy_data);
} }
struct api_data *api_add_khs(struct api_data *root, char *name, double *data, bool copy_data)
{
return api_add_data_full(root, name, API_KHS, (void *)data, copy_data);
}
struct api_data *api_add_mhtotal(struct api_data *root, char *name, double *data, bool copy_data) struct api_data *api_add_mhtotal(struct api_data *root, char *name, double *data, bool copy_data)
{ {
return api_add_data_full(root, name, API_MHTOTAL, (void *)data, copy_data); return api_add_data_full(root, name, API_MHTOTAL, (void *)data, copy_data);
@ -983,6 +989,9 @@ static struct api_data *print_data(struct api_data *root, char *buf, bool isjson
case API_MHS: case API_MHS:
sprintf(buf, "%.4f", *((double *)(root->data))); sprintf(buf, "%.4f", *((double *)(root->data)));
break; break;
case API_KHS:
sprintf(buf, "%.0f", *((double *)(root->data)));
break;
case API_VOLTS: case API_VOLTS:
sprintf(buf, "%.3f", *((float *)(root->data))); sprintf(buf, "%.3f", *((float *)(root->data)));
break; break;
@ -1672,6 +1681,12 @@ static void gpustatus(struct io_data *io_data, int gpu, bool isjson, bool precom
char mhsname[27]; char mhsname[27];
sprintf(mhsname, "MHS %ds", opt_log_interval); sprintf(mhsname, "MHS %ds", opt_log_interval);
root = api_add_mhs(root, mhsname, &(cgpu->rolling), false); root = api_add_mhs(root, mhsname, &(cgpu->rolling), false);
double khs_avg = mhs * 1000.0;
double khs_rolling = cgpu->rolling * 1000.0;
root = api_add_khs(root, "KHS av", &khs_avg, false);
char khsname[27];
sprintf(khsname, "KHS %ds", opt_log_interval);
root = api_add_khs(root, khsname, &khs_rolling, false);
root = api_add_int(root, "Accepted", &(cgpu->accepted), false); root = api_add_int(root, "Accepted", &(cgpu->accepted), false);
root = api_add_int(root, "Rejected", &(cgpu->rejected), false); root = api_add_int(root, "Rejected", &(cgpu->rejected), false);
root = api_add_int(root, "Hardware Errors", &(cgpu->hw_errors), false); root = api_add_int(root, "Hardware Errors", &(cgpu->hw_errors), false);
@ -1879,6 +1894,12 @@ static void summary(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __mayb
char mhsname[27]; char mhsname[27];
sprintf(mhsname, "MHS %ds", opt_log_interval); sprintf(mhsname, "MHS %ds", opt_log_interval);
root = api_add_mhs(root, mhsname, &(total_rolling), false); root = api_add_mhs(root, mhsname, &(total_rolling), false);
double khs_avg = mhs * 1000.0;
double khs_rolling = total_rolling * 1000.0;
root = api_add_khs(root, "KHS av", &khs_avg, false);
char khsname[27];
sprintf(khsname, "KHS %ds", opt_log_interval);
root = api_add_khs(root, khsname, &khs_rolling, false);
root = api_add_uint(root, "Found Blocks", &(found_blocks), true); root = api_add_uint(root, "Found Blocks", &(found_blocks), true);
root = api_add_int(root, "Getworks", &(total_getworks), true); root = api_add_int(root, "Getworks", &(total_getworks), true);
root = api_add_int(root, "Accepted", &(total_accepted), true); root = api_add_int(root, "Accepted", &(total_accepted), true);

22
compat.h

@ -47,16 +47,18 @@ static inline int nanosleep(const struct timespec *req, struct timespec *rem)
} }
#endif #endif
/* Reported unneded in https://github.com/veox/sgminer/issues/37 */ #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
/* static inline int sleep(unsigned int secs) */ // Reported unneded in https://github.com/veox/sgminer/issues/37 */
/* { */ static inline int sleep(unsigned int secs)
/* struct timespec req, rem; */ {
/* req.tv_sec = secs; */ struct timespec req, rem;
/* req.tv_nsec = 0; */ req.tv_sec = secs;
/* if (!nanosleep(&req, &rem)) */ req.tv_nsec = 0;
/* return 0; */ if (!nanosleep(&req, &rem))
/* return rem.tv_sec + (rem.tv_nsec ? 1 : 0); */ return 0;
/* } */ return rem.tv_sec + (rem.tv_nsec ? 1 : 0);
}
#endif
enum { enum {
PRIO_PROCESS = 0, PRIO_PROCESS = 0,

3
doc/BUGS.md

@ -16,7 +16,8 @@ Information that is most often relevant:
* AMD APP SDK version; * AMD APP SDK version;
* AMD ADL version; * AMD ADL version;
* GPUs used (`sgminer --ndevs`); * GPUs used (`sgminer --ndevs`);
* `sgminer` version (`sgminer --version` or `git describe`); * whether you're using a pre-compiled binary or bult from source;
* `sgminer` version (`sgminer --version` and/or `git describe`);
* contents of the configuration file; * contents of the configuration file;
* launch procedure (manual or via script); * launch procedure (manual or via script);
* steps to repeat; * steps to repeat;

4
doc/KERNEL.md

@ -18,7 +18,7 @@ A description of how to do this is available in `doc/MINING`.
### alexkarnew ### alexkarnew
Alaxey Karimov's optimised kernel, based on `ckolivas`. For Catalyst >=13.4. Alexey Karimov's optimised kernel, based on `ckolivas`. For Catalyst >=13.4.
Only supports `vectors=1`. Only supports `vectors=1`.
@ -27,7 +27,7 @@ Only supports `vectors=1`.
### alexkarold ### alexkarold
Alaxey Karimov's optimised kernel, based on `ckolivas`. For Catalyst <13.4. Alexey Karimov's optimised kernel, based on `ckolivas`. For Catalyst <13.4.
Only supports `vectors=1`. Only supports `vectors=1`.

1
miner.h

@ -1439,6 +1439,7 @@ enum api_data_type {
API_TIMEVAL, API_TIMEVAL,
API_TIME, API_TIME,
API_MHS, API_MHS,
API_KHS,
API_MHTOTAL, API_MHTOTAL,
API_TEMP, API_TEMP,
API_UTILITY, API_UTILITY,

13
ocl.c

@ -41,10 +41,9 @@ char *file_contents(const char *filename, int *length)
void *buffer; void *buffer;
FILE *f; FILE *f;
/* Try in the optional kernel path first, defaults to PREFIX */
strcpy(fullpath, opt_kernel_path); strcpy(fullpath, opt_kernel_path);
strcat(fullpath, filename); strcat(fullpath, filename);
/* Try in the optional kernel path or installed prefix first */
f = fopen(fullpath, "rb"); f = fopen(fullpath, "rb");
if (!f) { if (!f) {
/* Then try from the path sgminer was called */ /* Then try from the path sgminer was called */
@ -52,12 +51,20 @@ char *file_contents(const char *filename, int *length)
strcat(fullpath, filename); strcat(fullpath, filename);
f = fopen(fullpath, "rb"); f = fopen(fullpath, "rb");
} }
if (!f) {
/* Then from `pwd`/kernel/ */
strcpy(fullpath, sgminer_path);
strcat(fullpath, "kernel/");
strcat(fullpath, filename);
f = fopen(fullpath, "rb");
}
/* Finally try opening it directly */ /* Finally try opening it directly */
if (!f) if (!f)
f = fopen(filename, "rb"); f = fopen(filename, "rb");
if (!f) { if (!f) {
applog(LOG_ERR, "Unable to open %s or %s for reading", filename, fullpath); applog(LOG_ERR, "Unable to open %s or %s for reading",
filename, fullpath);
return NULL; return NULL;
} }

43
sgminer.c

@ -35,6 +35,7 @@
#ifndef WIN32 #ifndef WIN32
#include <sys/resource.h> #include <sys/resource.h>
#else #else
#include <winsock2.h>
#include <windows.h> #include <windows.h>
#endif #endif
#include <ccan/opt/opt.h> #include <ccan/opt/opt.h>
@ -211,7 +212,7 @@ static struct pool *currentpool = NULL;
int total_pools, enabled_pools; int total_pools, enabled_pools;
enum pool_strategy pool_strategy = POOL_FAILOVER; enum pool_strategy pool_strategy = POOL_FAILOVER;
int opt_rotate_period; int opt_rotate_period;
static int total_urls, total_users, total_passes, total_userpasses, total_poolnames; static int total_urls, total_users, total_passes, total_userpasses;
static int json_array_index; static int json_array_index;
static static
@ -509,15 +510,12 @@ struct pool *add_pool(void)
pool = (struct pool *)calloc(sizeof(struct pool), 1); pool = (struct pool *)calloc(sizeof(struct pool), 1);
if (!pool) if (!pool)
quit(1, "Failed to malloc pool in add_pool"); quit(1, "Failed to calloc pool in add_pool");
pool->pool_no = pool->prio = total_pools; pool->pool_no = pool->prio = total_pools;
/* Default pool name */ /* Default pool name */
char buf[32]; char buf[32];
sprintf(buf, "%s%s%s", sprintf(buf, "Pool %d", pool->pool_no);
pool->sockaddr_url,
pool->has_stratum ? ":" : "",
pool->has_stratum ? pool->stratum_port : "");
pool->poolname = strdup(buf); pool->poolname = strdup(buf);
pools = realloc(pools, sizeof(struct pool *) * (total_pools + 2)); pools = realloc(pools, sizeof(struct pool *) * (total_pools + 2));
@ -741,11 +739,11 @@ static char *set_poolname(char *arg)
{ {
struct pool *pool; struct pool *pool;
total_poolnames++; while ((json_array_index + 1) > total_pools)
if (total_poolnames > total_pools)
add_pool(); add_pool();
pool = pools[json_array_index];
pool = pools[total_poolnames - 1]; applog(LOG_DEBUG, "Setting pool %i name to %s", pool->pool_no, arg);
opt_set_charp(arg, &pool->poolname); opt_set_charp(arg, &pool->poolname);
return NULL; return NULL;
@ -807,7 +805,6 @@ static char *set_pool_state(char *arg)
pool = pools[json_array_index]; pool = pools[json_array_index];
applog(LOG_INFO, "Setting pool %s state to %s", pool->poolname, arg); applog(LOG_INFO, "Setting pool %s state to %s", pool->poolname, arg);
if (strcmp(arg, "disabled") == 0) { if (strcmp(arg, "disabled") == 0) {
pool->state = POOL_DISABLED; pool->state = POOL_DISABLED;
} else if (strcmp(arg, "enabled") == 0) { } else if (strcmp(arg, "enabled") == 0) {
@ -3045,7 +3042,7 @@ static void kill_mining(void)
if (thr && PTH(thr) != 0L) if (thr && PTH(thr) != 0L)
pth = &thr->pth; pth = &thr->pth;
thr_info_cancel(thr); thr_info_cancel(thr);
#ifndef WIN32 #if !defined(WIN32) || defined(__MINGW64_VERSION_MAJOR)
if (pth && *pth) if (pth && *pth)
pthread_join(*pth, NULL); pthread_join(*pth, NULL);
#else #else
@ -4715,7 +4712,7 @@ retry:
immedok(logwin, false); immedok(logwin, false);
opt_loginput = false; opt_loginput = false;
} }
#endif #endif /* HAVE_CURSES */
void default_save_file(char *filename) void default_save_file(char *filename)
{ {
@ -4750,7 +4747,7 @@ static void set_options(void)
clear_logwin(); clear_logwin();
retry: retry:
wlogprint("[Q]ueue: %d\n[S]cantime: %d\n[E]xpiry: %d\n" wlogprint("[Q]ueue: %d\n[S]cantime: %d\n[E]xpiry: %d\n"
"[W]rite config file\n[C]gminer restart\n", "[W]rite config file\n[R]estart\n",
opt_queue, opt_scantime, opt_expiry); opt_queue, opt_scantime, opt_expiry);
wlogprint("Select an option or any other key to return\n"); wlogprint("Select an option or any other key to return\n");
logwin_update(); logwin_update();
@ -4810,7 +4807,7 @@ retry:
fclose(fcfg); fclose(fcfg);
goto retry; goto retry;
} else if (!strncasecmp(&input, "c", 1)) { } else if (!strncasecmp(&input, "r", 1)) {
wlogprint("Are you sure?\n"); wlogprint("Are you sure?\n");
input = getch(); input = getch();
if (!strncasecmp(&input, "y", 1)) if (!strncasecmp(&input, "y", 1))
@ -4856,7 +4853,7 @@ static void *input_thread(void __maybe_unused *userdata)
return NULL; return NULL;
} }
#endif #endif /* HAVE_CURSES */
static void *api_thread(void *userdata) static void *api_thread(void *userdata)
{ {
@ -7705,19 +7702,22 @@ int main(int argc, char *argv[])
sigemptyset(&handler.sa_mask); sigemptyset(&handler.sa_mask);
sigaction(SIGTERM, &handler, &termhandler); sigaction(SIGTERM, &handler, &termhandler);
sigaction(SIGINT, &handler, &inthandler); sigaction(SIGINT, &handler, &inthandler);
#endif
/* opt_kernel_path defaults to SGMINER_PREFIX */
opt_kernel_path = (char *)alloca(PATH_MAX); opt_kernel_path = (char *)alloca(PATH_MAX);
strcpy(opt_kernel_path, SGMINER_PREFIX); strcpy(opt_kernel_path, SGMINER_PREFIX);
/* sgminer_path is current dir */
sgminer_path = (char *)alloca(PATH_MAX); sgminer_path = (char *)alloca(PATH_MAX);
#ifndef _MSC_VER
s = strdup(argv[0]); s = strdup(argv[0]);
strcpy(sgminer_path, dirname(s)); strcpy(sgminer_path, dirname(s));
free(s); free(s);
strcat(sgminer_path, "/"); strcat(sgminer_path, "/");
#else #else
opt_kernel_path = (char*)alloca(PATH_MAX);
strcpy(opt_kernel_path, SGMINER_PREFIX);
sgminer_path = (char*)alloca(PATH_MAX);
GetCurrentDirectory(PATH_MAX - 1, sgminer_path); GetCurrentDirectory(PATH_MAX - 1, sgminer_path);
strcat(sgminer_path, "\\");
#endif #endif
devcursor = 8; devcursor = 8;
@ -7738,7 +7738,7 @@ int main(int argc, char *argv[])
for (i = 0; i < MAX_GPUDEVICES; i++) for (i = 0; i < MAX_GPUDEVICES; i++)
gpus[i].dynamic = true; gpus[i].dynamic = true;
/* parse command line */ /* parse config and command line */
opt_register_table(opt_config_table, opt_register_table(opt_config_table,
"Options for both config file and command line"); "Options for both config file and command line");
opt_register_table(opt_cmdline_table, opt_register_table(opt_cmdline_table,
@ -7860,12 +7860,10 @@ int main(int argc, char *argv[])
#endif #endif
} }
#ifdef USE_SCRYPT // I don't really know if this is relevant for other mining platforms
if (!getenv("GPU_MAX_ALLOC_PERCENT")) if (!getenv("GPU_MAX_ALLOC_PERCENT"))
applog(LOG_WARNING, "WARNING: GPU_MAX_ALLOC_PERCENT is not specified!"); applog(LOG_WARNING, "WARNING: GPU_MAX_ALLOC_PERCENT is not specified!");
if (!getenv("GPU_USE_SYNC_OBJECTS")) if (!getenv("GPU_USE_SYNC_OBJECTS"))
applog(LOG_WARNING, "WARNING: GPU_USE_SYNC_OBJECTS is not specified!"); applog(LOG_WARNING, "WARNING: GPU_USE_SYNC_OBJECTS is not specified!");
#endif
if (!total_pools) { if (!total_pools) {
applog(LOG_WARNING, "Need to specify at least one pool server."); applog(LOG_WARNING, "Need to specify at least one pool server.");
@ -7960,6 +7958,7 @@ int main(int argc, char *argv[])
enable_pool(pool); enable_pool(pool);
break; break;
case POOL_HIDDEN: case POOL_HIDDEN:
i--; /* Reiterate over this index. */
remove_pool(pool); remove_pool(pool);
break; break;
case POOL_REJECTING: case POOL_REJECTING:
@ -8176,7 +8175,7 @@ retry:
applog(LOG_DEBUG, "Generated getwork work"); applog(LOG_DEBUG, "Generated getwork work");
stage_work(work); stage_work(work);
push_curl_entry(ce, pool); push_curl_entry(ce, pool);
#endif #endif /* HAVE_LIBCURL */
} }
return 0; return 0;

Loading…
Cancel
Save