From e131dfab319f7899fba5b0baf8af402f8e456153 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 13 Mar 2012 12:18:23 -0400 Subject: [PATCH] Unify drivers as driver-*.c and add driver name to API --- Makefile.am | 8 ++++---- api.c | 2 +- cgminer.c | 6 +++--- bitforce.c => driver-bitforce.c | 3 ++- device-cpu.c => driver-cpu.c | 3 ++- device-cpu.h => driver-cpu.h | 0 icarus.c => driver-icarus.c | 3 ++- device-gpu.c => driver-opencl.c | 3 ++- device-gpu.h => driver-opencl.h | 0 miner.h | 1 + sha256_4way.c | 2 +- sha256_altivec_4way.c | 2 +- sha256_sse2_amd64.c | 2 +- sha256_sse2_i386.c | 2 +- sha256_sse4_amd64.c | 2 +- sha256_via.c | 2 +- 16 files changed, 23 insertions(+), 18 deletions(-) rename bitforce.c => driver-bitforce.c (99%) rename device-cpu.c => driver-cpu.c (99%) rename device-cpu.h => driver-cpu.h (100%) rename icarus.c => driver-icarus.c (99%) rename device-gpu.c => driver-opencl.c (99%) rename device-gpu.h => driver-opencl.h (100%) diff --git a/Makefile.am b/Makefile.am index d319329c..edcb53d0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 += \ 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,9 +68,9 @@ 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 diff --git a/api.c b/api.c index dd2af0b7..0e3c86b9 100644 --- a/api.c +++ b/api.c @@ -21,7 +21,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 diff --git a/cgminer.c b/cgminer.c index c336f8b4..11a7218e 100644 --- a/cgminer.c +++ b/cgminer.c @@ -42,8 +42,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) @@ -4430,7 +4430,7 @@ 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); + applog(LOG_ERR, " %2d. %s%d (driver: %s)", i, devices[i]->api->name, devices[i]->device_id, devices[i]->api->dname); } quit(0, "%d devices listed", total_devices); } diff --git a/bitforce.c b/driver-bitforce.c similarity index 99% rename from bitforce.c rename to driver-bitforce.c index e0636648..3a6deeff 100644 --- a/bitforce.c +++ b/driver-bitforce.c @@ -350,7 +350,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, diff --git a/device-cpu.c b/driver-cpu.c similarity index 99% rename from device-cpu.c rename to driver-cpu.c index c99cdfb1..04d307c9 100644 --- a/device-cpu.c +++ b/driver-cpu.c @@ -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 @@ -827,6 +827,7 @@ CPUSearch: } struct device_api cpu_api = { + .dname = "cpu", .name = "CPU", .api_detect = cpu_detect, .reinit_device = reinit_cpu_device, diff --git a/device-cpu.h b/driver-cpu.h similarity index 100% rename from device-cpu.h rename to driver-cpu.h diff --git a/icarus.c b/driver-icarus.c similarity index 99% rename from icarus.c rename to driver-icarus.c index 1d59657d..ba96b64e 100644 --- a/icarus.c +++ b/driver-icarus.c @@ -326,7 +326,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, diff --git a/device-gpu.c b/driver-opencl.c similarity index 99% rename from device-gpu.c rename to driver-opencl.c index 70dea39f..a0666115 100644 --- a/device-gpu.c +++ b/driver-opencl.c @@ -25,7 +25,7 @@ #include "compat.h" #include "miner.h" -#include "device-gpu.h" +#include "driver-opencl.h" #include "findnonce.h" #include "ocl.h" #include "adl.h" @@ -1373,6 +1373,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, diff --git a/device-gpu.h b/driver-opencl.h similarity index 100% rename from device-gpu.h rename to driver-opencl.h diff --git a/miner.h b/miner.h index 5f5fd68d..aa46beb6 100644 --- a/miner.h +++ b/miner.h @@ -187,6 +187,7 @@ struct thr_info; struct work; struct device_api { + char*dname; char*name; // API-global functions diff --git a/sha256_4way.c b/sha256_4way.c index 7bad83b3..27293d2a 100644 --- a/sha256_4way.c +++ b/sha256_4way.c @@ -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 diff --git a/sha256_altivec_4way.c b/sha256_altivec_4way.c index 13cafba4..43a96b2b 100644 --- a/sha256_altivec_4way.c +++ b/sha256_altivec_4way.c @@ -9,7 +9,7 @@ // -#include "device-cpu.h" +#include "driver-cpu.h" #ifdef WANT_ALTIVEC_4WAY diff --git a/sha256_sse2_amd64.c b/sha256_sse2_amd64.c index 952431b8..ad1f45dc 100644 --- a/sha256_sse2_amd64.c +++ b/sha256_sse2_amd64.c @@ -9,7 +9,7 @@ * */ -#include "device-cpu.h" +#include "driver-cpu.h" #ifdef WANT_X8664_SSE2 diff --git a/sha256_sse2_i386.c b/sha256_sse2_i386.c index 1a4bb2f6..3008e0d6 100644 --- a/sha256_sse2_i386.c +++ b/sha256_sse2_i386.c @@ -9,7 +9,7 @@ * */ -#include "device-cpu.h" +#include "driver-cpu.h" #ifdef WANT_X8632_SSE2 diff --git a/sha256_sse4_amd64.c b/sha256_sse4_amd64.c index b08a2a1e..172da2bb 100644 --- a/sha256_sse4_amd64.c +++ b/sha256_sse4_amd64.c @@ -9,7 +9,7 @@ * */ -#include "device-cpu.h" +#include "driver-cpu.h" #ifdef WANT_X8664_SSE4 diff --git a/sha256_via.c b/sha256_via.c index b74c272e..2d7d7731 100644 --- a/sha256_via.c +++ b/sha256_via.c @@ -1,5 +1,5 @@ -#include "device-cpu.h" +#include "driver-cpu.h" #include #include