This patch is an initial attempt to re-structure cgminer source
code from its monolithic design (with nearly all code being
concentrated in main.c) to a more modular one.
In this first stage, the conditionally compiled functions for
GPU and CPU mining were extracted into dedicated files:
* device-cpu.h and device-cpu.c covering WANT_CPUMINE functions
* device-gpu.h and device-gpu.c covering HAVE_OPENCL functions
The main.c file is left untouched as reference, while the
remainder without the extracted parts is located in cgminer.c.
The Makefile.am has been updated to use the re-structured
source files for the build.
Above pure re-structuring *NO* functional modifications were
made. The sources were tested to compile and run on on a
current Linux system with working CPU and GPU mining
(Bitforce not tested due to loack of hardware).
cgminer will scan for and mine BitForce FPGAs on USB ports by providing the
new --scan-serial <device> option, or autodetect them by searching
/dev/serial/by-id for *BitFORCE_SHA256*
- Before, some returned bool, and others returned int (which was then turned
into a bool with a comparison); now, everything returns a bool
- Before, some set hashes_done to nonce - 1 when a share was found and others
set it to nonce + 1 or 2. This caused some algorithms to scan/submit shares
twice with the new cpu_scanhash function. Now, it has all been replaced with
last_nonce, which is set to the final nonce checked by the scanhash_* func.
- VIA needs the full data, and cannot use midstate. All the others were
expecting midstate and data+64 for their parameters. Now, we pass midstate
and the full data pointer, and let the scanhash_* function choose which to
use.
This expands on the device API, by taking the actual main thread out of the
device's code, and calling the API only for specific tasks. This brings
various changes that were made to the GPU thread code into the CPU miner.
It also fixes a bug where shares found on old GPU work were discarded when
it switched to a new work.