Browse Source

Merge branch 'master' into ztex

nfactor-troky
Luke Dashjr 13 years ago
parent
commit
657716e563
  1. 10
      Makefile.am
  2. 3
      adl.c
  3. 2
      api.c
  4. 89
      cgminer.c
  5. 14
      driver-bitforce.c
  6. 9
      driver-cpu.c
  7. 0
      driver-cpu.h
  8. 6
      driver-icarus.c
  9. 26
      driver-opencl.c
  10. 0
      driver-opencl.h
  11. 6
      driver-ztex.c
  12. 5
      miner.h
  13. 2
      sha256_4way.c
  14. 2
      sha256_altivec_4way.c
  15. 2
      sha256_sse2_amd64.c
  16. 2
      sha256_sse2_i386.c
  17. 2
      sha256_sse4_amd64.c
  18. 2
      sha256_via.c

10
Makefile.am

@ -37,7 +37,7 @@ cgminer_SOURCES += logging.c @@ -37,7 +37,7 @@ cgminer_SOURCES += logging.c
# GPU sources, TODO: make them selectable
# the GPU portion extracted from original main.c
cgminer_SOURCES += device-gpu.h device-gpu.c
cgminer_SOURCES += driver-opencl.h driver-opencl.c
# the original GPU related sources, unchanged
cgminer_SOURCES += ocl.c ocl.h findnonce.c findnonce.h
@ -53,7 +53,7 @@ cgminer_SOURCES += \ @@ -53,7 +53,7 @@ cgminer_SOURCES += \
sha256_altivec_4way.c
# the CPU portion extracted from original main.c
cgminer_SOURCES += device-cpu.h device-cpu.c
cgminer_SOURCES += driver-cpu.h driver-cpu.c
if HAS_YASM
AM_CFLAGS = -DHAS_YASM
@ -68,13 +68,13 @@ endif # HAS_YASM @@ -68,13 +68,13 @@ endif # HAS_YASM
endif # HAS_CPUMINE
if HAS_BITFORCE
cgminer_SOURCES += bitforce.c
cgminer_SOURCES += driver-bitforce.c
endif
if HAS_ICARUS
cgminer_SOURCES += icarus.c
cgminer_SOURCES += driver-icarus.c
endif
if HAS_ZTEX
cgminer_SOURCES += ztex.c libztex.c
cgminer_SOURCES += driver-ztex.c libztex.c
endif

3
adl.c

@ -352,6 +352,9 @@ void init_adl(int nDevs) @@ -352,6 +352,9 @@ void init_adl(int nDevs)
}
applog(LOG_INFO, "GPU %d %s hardware monitoring enabled", gpu, lpInfo[i].strAdapterName);
if (gpus[gpu].name)
free(gpus[gpu].name);
gpus[gpu].name = lpInfo[i].strAdapterName;
gpus[gpu].has_adl = true;
/* Flag adl as active if any card is successfully activated */
adl_active = true;

2
api.c

@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
#include "compat.h"
#include "miner.h"
#include "device-cpu.h" /* for algo_names[], TODO: re-factor dependency */
#include "driver-cpu.h" /* for algo_names[], TODO: re-factor dependency */
#if defined(unix) || defined(__APPLE__)
#include <errno.h>

89
cgminer.c

@ -44,8 +44,8 @@ @@ -44,8 +44,8 @@
#include "miner.h"
#include "findnonce.h"
#include "adl.h"
#include "device-cpu.h"
#include "device-gpu.h"
#include "driver-cpu.h"
#include "driver-opencl.h"
#include "bench_block.h"
#if defined(unix)
@ -1164,7 +1164,10 @@ WINDOW *mainwin, *statuswin, *logwin; @@ -1164,7 +1164,10 @@ WINDOW *mainwin, *statuswin, *logwin;
#endif
double total_secs = 0.1;
static char statusline[256];
/* logstart is where the log window should start */
static int devcursor, logstart, logcursor;
/* statusy is where the status window goes up to in cases where it won't fit at startup */
static int statusy;
struct cgpu_info gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */
struct cgpu_info *cpus;
@ -1257,7 +1260,7 @@ static void curses_print_status(void) @@ -1257,7 +1260,7 @@ static void curses_print_status(void)
wclrtoeol(statuswin);
mvwprintw(statuswin, 5, 0, " Block: %s... Started: %s", current_hash, blocktime);
mvwhline(statuswin, 6, 0, '-', 80);
mvwhline(statuswin, logstart - 1, 0, '-', 80);
mvwhline(statuswin, statusy - 1, 0, '-', 80);
mvwprintw(statuswin, devcursor - 1, 1, "[P]ool management %s[S]ettings [D]isplay options [Q]uit",
have_opencl ? "[G]PU management " : "");
}
@ -1275,10 +1278,11 @@ static void curses_print_devstatus(int thr_id) @@ -1275,10 +1278,11 @@ static void curses_print_devstatus(int thr_id)
char logline[255];
cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
if (total_devices > 14)
return;
mvwprintw(statuswin, devcursor + cgpu->cgminer_id, 0, " %s %d: ", cgpu->api->name, cgpu->device_id);
/* Check this isn't out of the window size */
if (wmove(statuswin,devcursor + cgpu->cgminer_id, 0) == ERR)
return;
wprintw(statuswin, " %s %d: ", cgpu->api->name, cgpu->device_id);
if (cgpu->api->get_statline_before) {
logline[0] = '\0';
cgpu->api->get_statline_before(logline, cgpu);
@ -1327,16 +1331,31 @@ static void print_status(int thr_id) @@ -1327,16 +1331,31 @@ static void print_status(int thr_id)
static inline bool change_logwinsize(void)
{
int x, y, logx, logy;
bool ret = false;
getmaxyx(mainwin, y, x);
getmaxyx(logwin, logy, logx);
if (x < 80 || y < 25)
return ret;
if (y > statusy + 2 && statusy < logstart) {
if (y - 2 < logstart)
statusy = y - 2;
else
statusy = logstart;
logcursor = statusy + 1;
mvwin(logwin, logcursor, 0);
wresize(statuswin, statusy, x);
ret = true;
}
y -= logcursor;
getmaxyx(logwin, logy, logx);
/* Detect screen size change */
if ((x != logx || y != logy) && x >= 80 && y >= 25) {
if (x != logx || y != logy) {
wresize(logwin, y, x);
return true;
ret = true;
}
return false;
return ret;
}
static void check_winsizes(void)
@ -1347,7 +1366,12 @@ static void check_winsizes(void) @@ -1347,7 +1366,12 @@ static void check_winsizes(void)
int y, x;
x = getmaxx(statuswin);
wresize(statuswin, logstart, x);
if (logstart > LINES - 2)
statusy = LINES - 2;
else
statusy = logstart;
logcursor = statusy + 1;
wresize(statuswin, statusy, x);
getmaxyx(mainwin, y, x);
y -= logcursor;
wresize(logwin, y, x);
@ -4373,6 +4397,7 @@ void enable_curses(void) { @@ -4373,6 +4397,7 @@ void enable_curses(void) {
cbreak();
noecho();
curses_active = true;
statusy = logstart;
unlock_curses();
}
#endif
@ -4412,6 +4437,31 @@ void enable_device(struct cgpu_info *cgpu) @@ -4412,6 +4437,31 @@ void enable_device(struct cgpu_info *cgpu)
#endif
}
struct _cgpu_devid_counter {
char name[4];
int lastid;
UT_hash_handle hh;
};
bool add_cgpu(struct cgpu_info*cgpu)
{
static struct _cgpu_devid_counter *devids = NULL;
struct _cgpu_devid_counter *d;
HASH_FIND_STR(devids, cgpu->api->name, d);
if (d)
cgpu->device_id = ++d->lastid;
else
{
d = malloc(sizeof(*d));
memcpy(d->name, cgpu->api->name, sizeof(d->name));
cgpu->device_id = d->lastid = 0;
HASH_ADD_STR(devids, name, d);
}
devices[total_devices++] = cgpu;
return true;
}
int main(int argc, char *argv[])
{
struct block *block, *tmpblock;
@ -4598,7 +4648,11 @@ int main(int argc, char *argv[]) @@ -4598,7 +4648,11 @@ int main(int argc, char *argv[])
if (devices_enabled == -1) {
applog(LOG_ERR, "Devices detected:");
for (i = 0; i < total_devices; ++i) {
applog(LOG_ERR, " %2d. %s%d", i, devices[i]->api->name, devices[i]->device_id);
struct cgpu_info *cgpu = devices[i];
if (cgpu->name)
applog(LOG_ERR, " %2d. %s %d: %s (driver: %s)", i, cgpu->api->name, cgpu->device_id, cgpu->name, cgpu->api->dname);
else
applog(LOG_ERR, " %2d. %s %d (driver: %s)", i, cgpu->api->name, cgpu->device_id, cgpu->api->dname);
}
quit(0, "%d devices listed", total_devices);
}
@ -4632,18 +4686,7 @@ int main(int argc, char *argv[]) @@ -4632,18 +4686,7 @@ int main(int argc, char *argv[])
load_temp_cutoffs();
if (total_devices <= 14) {
logstart += total_devices;
} else {
applog(LOG_NOTICE, "Too many devices exist for per-device status lines");
for (i = 0; i < total_devices; ++i) {
struct cgpu_info *cgpu = devices[i];
applog(LOG_NOTICE, "%s%d: %s", cgpu->api->name, cgpu->device_id,
cgpu->deven == DEV_ENABLED? "Enabled" : "Disabled");
}
applog(LOG_NOTICE, "%d devices found, disabling per-device status lines", total_devices);
}
logcursor = logstart + 1;
#ifdef HAVE_CURSES

14
bitforce.c → driver-bitforce.c

@ -91,8 +91,8 @@ static void BFwrite(int fd, const void *buf, ssize_t bufLen) @@ -91,8 +91,8 @@ static void BFwrite(int fd, const void *buf, ssize_t bufLen)
static bool bitforce_detect_one(const char *devpath)
{
char *s;
char pdevbuf[0x100];
static int i = 0;
if (total_devices == MAX_DEVICES)
return false;
@ -117,14 +117,17 @@ static bool bitforce_detect_one(const char *devpath) @@ -117,14 +117,17 @@ static bool bitforce_detect_one(const char *devpath)
// We have a real BitForce!
struct cgpu_info *bitforce;
bitforce = calloc(1, sizeof(*bitforce));
devices[total_devices++] = bitforce;
bitforce->api = &bitforce_api;
bitforce->device_id = i++;
bitforce->device_path = strdup(devpath);
bitforce->deven = DEV_ENABLED;
bitforce->threads = 1;
if (likely((!memcmp(pdevbuf, ">>>ID: ", 7)) && (s = strstr(pdevbuf + 3, ">>>"))))
{
s[0] = '\0';
bitforce->name = strdup(pdevbuf + 7);
}
return true;
return add_cgpu(bitforce);
}
static bool bitforce_detect_auto_udev()
@ -358,7 +361,8 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6 @@ -358,7 +361,8 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
}
struct device_api bitforce_api = {
.name = "BFL",
.dname = "bitforce",
.name = "PGA",
.api_detect = bitforce_detect,
.get_statline_before = get_bitforce_statline_before,
.thread_prepare = bitforce_thread_prepare,

9
device-cpu.c → driver-cpu.c

@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
#include "compat.h"
#include "miner.h"
#include "bench_block.h"
#include "device-cpu.h"
#include "driver-cpu.h"
#if defined(unix)
#include <errno.h>
@ -739,13 +739,13 @@ static void cpu_detect() @@ -739,13 +739,13 @@ static void cpu_detect()
for (i = 0; i < opt_n_threads; ++i) {
struct cgpu_info *cgpu;
cgpu = devices[total_devices + i] = &cpus[i];
cgpu = &cpus[i];
cgpu->api = &cpu_api;
cgpu->deven = DEV_ENABLED;
cgpu->device_id = i;
cgpu->threads = 1;
cgpu->kname = algo_names[opt_algo];
add_cgpu(cgpu);
}
total_devices += opt_n_threads;
}
static void reinit_cpu_device(struct cgpu_info *cpu)
@ -827,6 +827,7 @@ CPUSearch: @@ -827,6 +827,7 @@ CPUSearch:
}
struct device_api cpu_api = {
.dname = "cpu",
.name = "CPU",
.api_detect = cpu_detect,
.reinit_device = reinit_cpu_device,

0
device-cpu.h → driver-cpu.h

6
icarus.c → driver-icarus.c

@ -194,10 +194,9 @@ static bool icarus_detect_one(const char *devpath) @@ -194,10 +194,9 @@ static bool icarus_detect_one(const char *devpath)
struct cgpu_info *icarus;
icarus = calloc(1, sizeof(struct cgpu_info));
icarus->api = &icarus_api;
icarus->device_id = total_devices;
icarus->device_path = strdup(devpath);
icarus->threads = 1;
devices[total_devices++] = icarus;
add_cgpu(icarus);
applog(LOG_INFO, "Found Icarus at %s, mark as %d",
devpath, icarus->device_id);
@ -333,7 +332,8 @@ static void icarus_shutdown(struct thr_info *thr) @@ -333,7 +332,8 @@ static void icarus_shutdown(struct thr_info *thr)
}
struct device_api icarus_api = {
.name = "ICA",
.dname = "icarus",
.name = "PGA",
.api_detect = icarus_detect,
.thread_prepare = icarus_prepare,
.scanhash = icarus_scanhash,

26
device-gpu.c → driver-opencl.c

@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
#include "compat.h"
#include "miner.h"
#include "device-gpu.h"
#include "driver-opencl.h"
#include "findnonce.h"
#include "ocl.h"
#include "adl.h"
@ -1107,12 +1107,13 @@ static void opencl_detect() @@ -1107,12 +1107,13 @@ static void opencl_detect()
for (i = 0; i < nDevs; ++i) {
struct cgpu_info *cgpu;
cgpu = devices[total_devices++] = &gpus[i];
cgpu = &gpus[i];
cgpu->deven = DEV_ENABLED;
cgpu->api = &opencl_api;
cgpu->device_id = i;
cgpu->threads = opt_g_threads;
cgpu->virtual_gpu = i;
add_cgpu(cgpu);
}
if (!opt_noadl)
@ -1208,6 +1209,26 @@ static bool opencl_thread_prepare(struct thr_info *thr) @@ -1208,6 +1209,26 @@ static bool opencl_thread_prepare(struct thr_info *thr)
return false;
}
if (!cgpu->name)
cgpu->name = strdup(name);
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;
case KL_POCLBM:
cgpu->kname = "poclbm";
default:
break;
}
}
applog(LOG_INFO, "initCl() finished. Found %s", name);
gettimeofday(&now, NULL);
get_datestamp(cgpu->init, &now);
@ -1404,6 +1425,7 @@ static void opencl_thread_shutdown(struct thr_info *thr) @@ -1404,6 +1425,7 @@ static void opencl_thread_shutdown(struct thr_info *thr)
}
struct device_api opencl_api = {
.dname = "opencl",
.name = "GPU",
.api_detect = opencl_detect,
.reinit_device = reinit_opencl_device,

0
device-gpu.h → driver-opencl.h

6
ztex.c → driver-ztex.c

@ -51,10 +51,9 @@ static void ztex_detect() @@ -51,10 +51,9 @@ static void ztex_detect()
struct cgpu_info *ztex;
ztex = calloc(1, sizeof(struct cgpu_info));
ztex->api = &ztex_api;
ztex->device_id = total_devices;
ztex->device = ztex_devices[i]->dev;
ztex->threads = 1;
devices[total_devices++] = ztex;
add_cgpu(ztex);
applog(LOG_WARNING,"%s: Found Ztex, mark as %d", ztex->device->repr, ztex->device_id);
}
@ -313,7 +312,8 @@ static void ztex_disable (struct thr_info *thr) @@ -313,7 +312,8 @@ static void ztex_disable (struct thr_info *thr)
}
struct device_api ztex_api = {
.name = "ZTX",
.dname = "ztex",
.name = "PGA",
.api_detect = ztex_detect,
.get_statline_before = ztex_statline_before,
.thread_prepare = ztex_prepare,

5
miner.h

@ -195,6 +195,7 @@ struct thr_info; @@ -195,6 +195,7 @@ struct thr_info;
struct work;
struct device_api {
char*dname;
char*name;
// API-global functions
@ -255,6 +256,7 @@ struct cgpu_info { @@ -255,6 +256,7 @@ struct cgpu_info {
int cgminer_id;
struct device_api *api;
int device_id;
char *name;
char *device_path;
FILE *device_file;
#ifdef USE_ZTEX
@ -281,6 +283,7 @@ struct cgpu_info { @@ -281,6 +283,7 @@ struct cgpu_info {
int virtual_gpu;
int intensity;
bool dynamic;
char *kname;
#ifdef HAVE_OPENCL
cl_uint vwidth;
size_t work_size;
@ -319,6 +322,8 @@ struct cgpu_info { @@ -319,6 +322,8 @@ struct cgpu_info {
int dev_thermal_cutoff_count;
};
extern bool add_cgpu(struct cgpu_info*);
struct thread_q {
struct list_head q;

2
sha256_4way.c

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
// tcatm's 4-way 128-bit SSE2 SHA-256
#include "device-cpu.h"
#include "driver-cpu.h"
#ifdef WANT_SSE2_4WAY

2
sha256_altivec_4way.c

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
//
#include "device-cpu.h"
#include "driver-cpu.h"
#ifdef WANT_ALTIVEC_4WAY

2
sha256_sse2_amd64.c

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
*
*/
#include "device-cpu.h"
#include "driver-cpu.h"
#ifdef WANT_X8664_SSE2

2
sha256_sse2_i386.c

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
*
*/
#include "device-cpu.h"
#include "driver-cpu.h"
#ifdef WANT_X8632_SSE2

2
sha256_sse4_amd64.c

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
*
*/
#include "device-cpu.h"
#include "driver-cpu.h"
#ifdef WANT_X8664_SSE4

2
sha256_via.c

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#include "device-cpu.h"
#include "driver-cpu.h"
#include <stdint.h>
#include <stdlib.h>

Loading…
Cancel
Save