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

3
adl.c

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

2
api.c

@ -25,7 +25,7 @@
#include "compat.h" #include "compat.h"
#include "miner.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__) #if defined(unix) || defined(__APPLE__)
#include <errno.h> #include <errno.h>

89
cgminer.c

@ -44,8 +44,8 @@
#include "miner.h" #include "miner.h"
#include "findnonce.h" #include "findnonce.h"
#include "adl.h" #include "adl.h"
#include "device-cpu.h" #include "driver-cpu.h"
#include "device-gpu.h" #include "driver-opencl.h"
#include "bench_block.h" #include "bench_block.h"
#if defined(unix) #if defined(unix)
@ -1164,7 +1164,10 @@ WINDOW *mainwin, *statuswin, *logwin;
#endif #endif
double total_secs = 0.1; double total_secs = 0.1;
static char statusline[256]; static char statusline[256];
/* logstart is where the log window should start */
static int devcursor, logstart, logcursor; 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 gpus[MAX_GPUDEVICES]; /* Maximum number apparently possible */
struct cgpu_info *cpus; struct cgpu_info *cpus;
@ -1257,7 +1260,7 @@ static void curses_print_status(void)
wclrtoeol(statuswin); wclrtoeol(statuswin);
mvwprintw(statuswin, 5, 0, " Block: %s... Started: %s", current_hash, blocktime); mvwprintw(statuswin, 5, 0, " Block: %s... Started: %s", current_hash, blocktime);
mvwhline(statuswin, 6, 0, '-', 80); 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", mvwprintw(statuswin, devcursor - 1, 1, "[P]ool management %s[S]ettings [D]isplay options [Q]uit",
have_opencl ? "[G]PU management " : ""); have_opencl ? "[G]PU management " : "");
} }
@ -1275,10 +1278,11 @@ static void curses_print_devstatus(int thr_id)
char logline[255]; char logline[255];
cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60; 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) { if (cgpu->api->get_statline_before) {
logline[0] = '\0'; logline[0] = '\0';
cgpu->api->get_statline_before(logline, cgpu); cgpu->api->get_statline_before(logline, cgpu);
@ -1327,16 +1331,31 @@ static void print_status(int thr_id)
static inline bool change_logwinsize(void) static inline bool change_logwinsize(void)
{ {
int x, y, logx, logy; int x, y, logx, logy;
bool ret = false;
getmaxyx(mainwin, y, x); 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; y -= logcursor;
getmaxyx(logwin, logy, logx);
/* Detect screen size change */ /* Detect screen size change */
if ((x != logx || y != logy) && x >= 80 && y >= 25) { if (x != logx || y != logy) {
wresize(logwin, y, x); wresize(logwin, y, x);
return true; ret = true;
} }
return false; return ret;
} }
static void check_winsizes(void) static void check_winsizes(void)
@ -1347,7 +1366,12 @@ static void check_winsizes(void)
int y, x; int y, x;
x = getmaxx(statuswin); 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); getmaxyx(mainwin, y, x);
y -= logcursor; y -= logcursor;
wresize(logwin, y, x); wresize(logwin, y, x);
@ -4373,6 +4397,7 @@ void enable_curses(void) {
cbreak(); cbreak();
noecho(); noecho();
curses_active = true; curses_active = true;
statusy = logstart;
unlock_curses(); unlock_curses();
} }
#endif #endif
@ -4412,6 +4437,31 @@ void enable_device(struct cgpu_info *cgpu)
#endif #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[]) int main(int argc, char *argv[])
{ {
struct block *block, *tmpblock; struct block *block, *tmpblock;
@ -4598,7 +4648,11 @@ int main(int argc, char *argv[])
if (devices_enabled == -1) { if (devices_enabled == -1) {
applog(LOG_ERR, "Devices detected:"); applog(LOG_ERR, "Devices detected:");
for (i = 0; i < total_devices; ++i) { 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); quit(0, "%d devices listed", total_devices);
} }
@ -4632,18 +4686,7 @@ int main(int argc, char *argv[])
load_temp_cutoffs(); load_temp_cutoffs();
if (total_devices <= 14) {
logstart += total_devices; 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; logcursor = logstart + 1;
#ifdef HAVE_CURSES #ifdef HAVE_CURSES

14
bitforce.c → driver-bitforce.c

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

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

@ -32,7 +32,7 @@
#include "compat.h" #include "compat.h"
#include "miner.h" #include "miner.h"
#include "bench_block.h" #include "bench_block.h"
#include "device-cpu.h" #include "driver-cpu.h"
#if defined(unix) #if defined(unix)
#include <errno.h> #include <errno.h>
@ -739,13 +739,13 @@ static void cpu_detect()
for (i = 0; i < opt_n_threads; ++i) { for (i = 0; i < opt_n_threads; ++i) {
struct cgpu_info *cgpu; struct cgpu_info *cgpu;
cgpu = devices[total_devices + i] = &cpus[i]; cgpu = &cpus[i];
cgpu->api = &cpu_api; cgpu->api = &cpu_api;
cgpu->deven = DEV_ENABLED; cgpu->deven = DEV_ENABLED;
cgpu->device_id = i;
cgpu->threads = 1; 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) static void reinit_cpu_device(struct cgpu_info *cpu)
@ -827,6 +827,7 @@ CPUSearch:
} }
struct device_api cpu_api = { struct device_api cpu_api = {
.dname = "cpu",
.name = "CPU", .name = "CPU",
.api_detect = cpu_detect, .api_detect = cpu_detect,
.reinit_device = reinit_cpu_device, .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)
struct cgpu_info *icarus; struct cgpu_info *icarus;
icarus = calloc(1, sizeof(struct cgpu_info)); icarus = calloc(1, sizeof(struct cgpu_info));
icarus->api = &icarus_api; icarus->api = &icarus_api;
icarus->device_id = total_devices;
icarus->device_path = strdup(devpath); icarus->device_path = strdup(devpath);
icarus->threads = 1; icarus->threads = 1;
devices[total_devices++] = icarus; add_cgpu(icarus);
applog(LOG_INFO, "Found Icarus at %s, mark as %d", applog(LOG_INFO, "Found Icarus at %s, mark as %d",
devpath, icarus->device_id); devpath, icarus->device_id);
@ -333,7 +332,8 @@ static void icarus_shutdown(struct thr_info *thr)
} }
struct device_api icarus_api = { struct device_api icarus_api = {
.name = "ICA", .dname = "icarus",
.name = "PGA",
.api_detect = icarus_detect, .api_detect = icarus_detect,
.thread_prepare = icarus_prepare, .thread_prepare = icarus_prepare,
.scanhash = icarus_scanhash, .scanhash = icarus_scanhash,

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

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

5
miner.h

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

2
sha256_4way.c

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

2
sha256_altivec_4way.c

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

2
sha256_sse2_amd64.c

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

2
sha256_sse2_i386.c

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

2
sha256_sse4_amd64.c

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

2
sha256_via.c

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

Loading…
Cancel
Save