Pages:
Author

Topic: An (even more) optimized version of cpuminer (pooler's cpuminer, CPU-only) - page 28. (Read 1958260 times)

hero member
Activity: 838
Merit: 507
From a practical viewpoint it is unlikely that anybody would be able to hash every nonce in a given block given the present state of available hardware with the possible exception of banks of super computers deep in the bowels of the NSA or other government entity somewhere.
That is incorrect. It only takes about 72 MH/s to check every possible nonce in less than a minute, and dual-CPU systems are already able to attain such rates for SHA-256d.
newbie
Activity: 6
Merit: 0
The gap that you see between nonce ranges is needed to avoid checking some nonces twice, as some of the core algorithm implementations may compute more hashes than requested (because of parallelization). The fact that we may skip checking a tiny fraction (0.000004%) of the nonce space is far from being a problem.

From a practical viewpoint it is unlikely that anybody would be able to hash every nonce in a given block given the present state of available hardware with the possible exception of banks of super computers deep in the bowels of the NSA or other government entity somewhere. From that perspective the gap is irrelevant. By the same token, even the overlap (without the subtract of 32) is irrelevant also and amounts to about the number of threads and still leaves a gap at the upper end of the 32-bit range.

I just wondered if there was something more specific to mining than that that necessitated the gap. It is the algorithm you use to calculate the range for each thread that attracted my attention. It looks like something I used to do with small microprocessors in embedded applications where I needed to play with numbers larger than the available precision of the machine. Very clever and not something I see often any more. The purist in me, though, would want to see each block on a neat zero boundary with no overlap.

Just for fun I adjusted your algorithm so that each block starts on a neat zero boundary with no overlaps.

Code:
	uint32_t end_nonce = 0xffffffffU / opt_n_threads * (thr_id + 1) - 0x20;
becomes
uint32_t end_nonce = 0xffffffffU / opt_n_threads * (thr_id + 1) + thr_id;

and

work.data[19] = 0xffffffffU / opt_n_threads * thr_id;
becomes
  work.data[19] = 0xffffffffU / opt_n_threads * thr_id + thr_id;

This produces (for 8 threads):

thread = 0 start_nonse = 0x00000000 end_nonse = 0x1fffffff
thread = 1 start_nonse = 0x20000000 end_nonse = 0x3fffffff
thread = 2 start_nonse = 0x40000000 end_nonse = 0x5fffffff
thread = 3 start_nonse = 0x60000000 end_nonse = 0x7fffffff
thread = 4 start_nonse = 0x80000000 end_nonse = 0x9fffffff
thread = 5 start_nonse = 0xa0000000 end_nonse = 0xbfffffff
thread = 6 start_nonse = 0xc0000000 end_nonse = 0xdfffffff
thread = 7 start_nonse = 0xe0000000 end_nonse = 0xffffffff

This is using gcc 4.8.2 with -O3 optimization on Fedora linux kernel 3.13.0 and AMD FX8350.

Thanks for your timely response.
hero member
Activity: 838
Merit: 507
I understand most of what's going on but I've got a few questions about what I've found in the code. Actually, it's a question about some curious code. Here's the extract from cpu-miner.c. I've removed the irrelevant portions.
Code:
static void *miner_thread(void *userdata)
{
. . .
uint32_t end_nonce = 0xffffffffU / opt_n_threads * (thr_id + 1) - 0x20;
. . .
if (memcmp(work.data, g_work.data, 76)) {
memcpy(&work, &g_work, sizeof(struct work));
work.data[19] = 0xffffffffU / opt_n_threads * thr_id;
} else
work.data[19]++;
. . .
}
This code appears to set up an initial start and end boundary for nonce checking on new work. It also seems to be attempting some cleverness to avoid doing expensive computation on 'long long int' type.  I'm assuming that the intent is to set start and end boundaries at the beginning of each thread's block (relative offset of 0) and then then end at one by before the start of the next thread's block. That's not what the effect is and the following block shows:
Code:
thread = 0 start_nonse = 0x00000000 end_nonse = 0x1fffffdf
thread = 1 start_nonse = 0x1fffffff end_nonse = 0x3fffffde
thread = 2 start_nonse = 0x3ffffffe end_nonse = 0x5fffffdd
thread = 3 start_nonse = 0x5ffffffd end_nonse = 0x7fffffdc
thread = 4 start_nonse = 0x7ffffffc end_nonse = 0x9fffffdb
thread = 5 start_nonse = 0x9ffffffb end_nonse = 0xbfffffda
thread = 6 start_nonse = 0xbffffffa end_nonse = 0xdfffffd9
thread = 7 start_nonse = 0xdffffff9 end_nonse = 0xffffffd8
I created a programme that output the boundaries of each thread block and this is what I got.

The purpose of that piece of code is to share the same work unit (block header) between all miner threads, so that we don't need to fetch different work (if using getwork) or to compute a different Merkle root hash (if using Stratum) for every thread. This is accomplished by partitioning the nonce space and by assigning a distinct nonce range to each thread, so that no two ranges overlap. Because of how mining works, the search over the nonce space doesn't have to be exhaustive, meaning that it is OK if we don't check all possible nonces before fetching new work.
The gap that you see between nonce ranges is needed to avoid checking some nonces twice, as some of the core algorithm implementations may compute more hashes than requested (because of parallelization). The fact that we may skip checking a tiny fraction (0.000004%) of the nonce space is far from being a problem.
newbie
Activity: 6
Merit: 0
I'm new to Bitcoin and this forum and am trying to learn all I can about it. One way I've always found to learn how things work is to go through the code.  I've already slogged through the code standard Bitcoin implementation, bitcoind/bitcoin-qt, and some of BitcoinArmory. I'm now looking through cpuminer. The code for cpuminer is fairly easy to read being written in standard C.

I understand most of what's going on but I've got a few questions about what I've found in the code. Actually, it's a question about some curious code. Here's the extract from cpu-miner.c. I've removed the irrelevant portions.
Code:
static void *miner_thread(void *userdata)
{
. . .
uint32_t end_nonce = 0xffffffffU / opt_n_threads * (thr_id + 1) - 0x20;
. . .
if (memcmp(work.data, g_work.data, 76)) {
memcpy(&work, &g_work, sizeof(struct work));
work.data[19] = 0xffffffffU / opt_n_threads * thr_id;
} else
work.data[19]++;
. . .
}
This code appears to set up an initial start and end boundary for nonce checking on new work. It also seems to be attempting some cleverness to avoid doing expensive computation on 'long long int' type.  I'm assuming that the intent is to set start and end boundaries at the beginning of each thread's block (relative offset of 0) and then then end at one by before the start of the next thread's block. That's not what the effect is and the following block shows:
Code:
thread = 0 start_nonse = 0x00000000 end_nonse = 0x1fffffdf
thread = 1 start_nonse = 0x1fffffff end_nonse = 0x3fffffde
thread = 2 start_nonse = 0x3ffffffe end_nonse = 0x5fffffdd
thread = 3 start_nonse = 0x5ffffffd end_nonse = 0x7fffffdc
thread = 4 start_nonse = 0x7ffffffc end_nonse = 0x9fffffdb
thread = 5 start_nonse = 0x9ffffffb end_nonse = 0xbfffffda
thread = 6 start_nonse = 0xbffffffa end_nonse = 0xdfffffd9
thread = 7 start_nonse = 0xdffffff9 end_nonse = 0xffffffd8
I created a programme that output the boundaries of each thread block and this is what I got.

The question is: is this intentional, and if so to what end? I know that the end boundary is later adjusted (downwards) based on the hash rate of the machine that the programme calculates on a running basis. It just seems a little odd to me. If this is a bug, a simple fix will make the cleverness work.

Thanks for you insite.
full member
Activity: 462
Merit: 100
Here's a great 24 hours comparison done by ReviewOutlaw for ALL CPU COINS.
http://www.reviewoutlaw.com/most-profitable-cpu-coin-list-alt-coin-profits-24-hours-mining/

Guess who the winner is? Smiley
MemoryCoin of course!

Here's another thread explaining how to CPU mine MMC efficiently:
https://bitcointalksearch.org/topic/profitable-cpu-mining-mine-from-home-work-tutorial-439874
(This doesn't use CPUMiner but rather a different miner which is built specifically for MMC mining)

hero member
Activity: 838
Merit: 507
Quote
--time-limit      maximum time (s) to mine before exiting the program.
Would be cool to see --time-limit parameter in cpuminer, too.
The same result can be obtained by using the timeout command from GNU coreutils (also available via Cygwin and Homebrew).
newbie
Activity: 16
Merit: 0
https://github.com/cbuchner1/CudaMiner/commit/670c8ea83346006180ece0994c6044536873b9f9

Quote
--time-limit      maximum time (s) to mine before exiting the program.

Would be cool to see --time-limit parameter in cpuminer, too.
legendary
Activity: 1512
Merit: 1009
Checksums in the first post don't match with the files, more specifically with the win32 one... Anything wrong?
Re-downloaded it just now from Sourceforge, and it matches.
Code:
$ sha256sum pooler-cpuminer-2.3.2-win32.zip
5cd04f0324f9f18f4bd989e981b1ac72edb68bf6b76498e616d22cfe0a798122  pooler-cpuminer-2.3.2-win32.zip

It matches. My mistake. Thank you.
hero member
Activity: 838
Merit: 507
Checksums in the first post don't match with the files, more specifically with the win32 one... Anything wrong?
Re-downloaded it just now from Sourceforge, and it matches.
Code:
$ sha256sum pooler-cpuminer-2.3.2-win32.zip
5cd04f0324f9f18f4bd989e981b1ac72edb68bf6b76498e616d22cfe0a798122  pooler-cpuminer-2.3.2-win32.zip
legendary
Activity: 1512
Merit: 1009
Checksums in the first post don't match with the files, more specifically with the win32 one... Anything wrong?
newbie
Activity: 12
Merit: 0
Hi,

I am trying to compile on XP 32bit (that's all I currently have available) and I am having some problems:

I have installed MinGW32, MSYS, C, and C++ compilers.
Downloaded and compiled curl-7.30.0.tar.gz, and copied over the libcurl.m4 and curl-config files.
Downloaded 'pooler-cpuminer-2.3.2.tar.gz' from Sourceforge (I am assuming this is the source to use?).

I am trying to build for 32bit Windows, so I use the config command:

Code:
./configure --host=i686-w64-mingw32 CFLAGS="-O3"

This appears to complete without any issues, so I issue the make command and get the following error message:

Code:
noveske@xp /c/cpuminer-2.3.2
$ make
make  all-recursive
make[1]: Entering directory `/c/cpuminer-2.3.2'
Making all in compat
make[2]: Entering directory `/c/cpuminer-2.3.2/compat'
Making all in jansson
make[3]: Entering directory `/c/cpuminer-2.3.2/compat/jansson'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/c/cpuminer-2.3.2/compat/jansson'
make[3]: Entering directory `/c/cpuminer-2.3.2/compat'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/c/cpuminer-2.3.2/compat'
make[2]: Leaving directory `/c/cpuminer-2.3.2/compat'
make[2]: Entering directory `/c/cpuminer-2.3.2'
gcc -std=gnu99 -DHAVE_CONFIG_H -I.  -fno-strict-aliasing -I./compat/jansson -I/c/MinGW/include   -O3 -MT minerd-cpu-miner.o -MD -MP -MF .deps/minerd-cpu-miner.Tpo -c -o minerd-cpu-miner.o `test -f 'cpu-miner.c' || echo './'`cpu-miner.c
In file included from c:\mingw\include\curl\curlbuild.h:124:0,
                 from c:\mingw\include\curl\curl.h:34,
                 from cpu-miner.c:37:
c:\mingw\include\ws2tcpip.h:38:2: error: #error "ws2tcpip.h is not compatible with winsock.h. Include winsock2.h instead."
 #error "ws2tcpip.h is not compatible with winsock.h. Include winsock2.h instead."
  ^
In file included from c:\mingw\include\curl\curlbuild.h:124:0,
                 from c:\mingw\include\curl\curl.h:34,
                 from cpu-miner.c:37:
c:\mingw\include\ws2tcpip.h:147:8: error: redefinition of 'struct ip_mreq'
 struct ip_mreq {
        ^
In file included from c:\mingw\include\windows.h:93:0,
                 from cpu-miner.c:23:
c:\mingw\include\winsock.h:315:8: note: originally defined here
 struct ip_mreq {
        ^
In file included from cpu-miner.c:39:0:
miner.h:9:21: fatal error: pthread.h: No such file or directory
 #include
                     ^
compilation terminated.
make[2]: *** [minerd-cpu-miner.o] Error 1
make[2]: Leaving directory `/c/cpuminer-2.3.2'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/c/cpuminer-2.3.2'
make: *** [all] Error 2

noveske@xp /c/cpuminer-2.3.2

Any help would be great, thanks
hero member
Activity: 838
Merit: 507
My GPU mining through cgminer is going fine to my pool, however CPUMiner is acting strange. It is not showing me sending any hashes. This is what it is showing almost all the time: https://i.imgur.com/eakS25T.png
What's going on?
If you send me the exact parameters you're using to connect I can give it a try.
minerd.exe -o http://127.0.0.1:8332 -u -p
I am connecting to middlecoin.com:3333 within my Mining Proxy that is listening on 8332.
Which fork of slush's proxy are you using, exactly? Are you also connecting cgminer through the proxy, and if yes with what parameters? Does the issue also arise if you stay connected to the getwork port instead of letting it switch to Stratum (pass --no-stratum to minerd)?
newbie
Activity: 7
Merit: 0
minerd.exe – url=stratum+tcp://stratum7.dogehouse.org:9090 –userpass=ikinga:x
Please make sure those options start with two hyphens (--), not with a Unicode dash, and that there is no space after the hyphens.

My GPU mining through cgminer is going fine to my pool, however CPUMiner is acting strange. It is not showing me sending any hashes. This is what it is showing almost all the time: https://i.imgur.com/eakS25T.png
What's going on?
If you send me the exact parameters you're using to connect I can give it a try.

minerd.exe -o http://127.0.0.1:8332 -u -p

I am connecting to middlecoin.com:3333 within my Mining Proxy that is listening on 8332.
hero member
Activity: 838
Merit: 507
minerd.exe – url=stratum+tcp://stratum7.dogehouse.org:9090 –userpass=ikinga:x
Please make sure those options start with two hyphens (--), not with a Unicode dash, and that there is no space after the hyphens.

My GPU mining through cgminer is going fine to my pool, however CPUMiner is acting strange. It is not showing me sending any hashes. This is what it is showing almost all the time: https://i.imgur.com/eakS25T.png
What's going on?
If you send me the exact parameters you're using to connect I can give it a try.
newbie
Activity: 16
Merit: 0
Thanks for cpuminer! Smiley

I have two small wishes:
- add "--shares" parameter, as seen in CGMiner/BFGMiner, to quit the program after n number of shares.
- add "--sharelog" parameter, as seen in CGMiner/BFGMiner, to log the mining process to a text file.

BFGMiner's README.txt:
--sharelog    Append share log to file
--shares      Quit after mining N shares (default: unlimited)

Henri.
newbie
Activity: 7
Merit: 0
Hi, I downloaded it and configured it by creating a shortcut to the "minered" and edited it with:

C:\Users\my.name.domain\Documents\mine\pooler-cpuminer-2.3.2-win64\minerd.exe – url=stratum+tcp://stratum7.dogehouse.org:9090 –userpass=ikinga:x

my.name.domain are obviously my personal info...

when I double click on it... it crashes. What did I do wrong?

Make a bat file instead of a shortcut, with the same command line information. However, after the main line in the bat, add a second line that says Pause. This will keep the command prompt window open instead of closing, showing you the error you are encountering.

Is mining on the CPU less effective than GPU, and that is why solutions aren't coming up as commonly as they do in a GPU based miner?
It depends on what you mean by "effective", but I would say it is. Mining with a "good" GPU is certainly more efficient than mining with a CPU, at least. For a more complete answer you should consult the mining hardware comparison.
The rate at which solutions get accepted depends both on your hash rate and on the share difficulty set by the pool. In general you need not care about it, especially given that share difficulty can vary dynamically.

xxxxx\pooler-cpuminer-2.3.2-win64\minerd.exe --url=stratum+tcp://de2.miningpool.co:4101 --userpass=xx:xx
Any other commands to expand on this as after 5 minutes it gets disconnected.
No. If it gets disconnected it's almost certainly either the pool's or your Internet connection's fault (most probably the pool's). I'm always happy to test mining servers for compatibility, but I cannot even connect to the one mentioned above.

My GPU mining through cgminer is going fine to my pool, however CPUMiner is acting strange. It is not showing me sending any hashes. This is what it is showing almost all the time: https://i.imgur.com/eakS25T.png

What's going on?
newbie
Activity: 1
Merit: 0
Hi, I downloaded it and configured it by creating a shortcut to the "minered" and edited it with:

C:\Users\my.name.domain\Documents\mine\pooler-cpuminer-2.3.2-win64\minerd.exe – url=stratum+tcp://stratum7.dogehouse.org:9090 –userpass=ikinga:x

my.name.domain are obviously my personal info...

when I double click on it... it crashes. What did I do wrong?
newbie
Activity: 8
Merit: 0
Is cpuminer customized for each type of coin, or can the same minerd be used to work against all kinds of coin mining pools?
Thanks
hero member
Activity: 838
Merit: 507
Is mining on the CPU less effective than GPU, and that is why solutions aren't coming up as commonly as they do in a GPU based miner?
It depends on what you mean by "effective", but I would say it is. Mining with a "good" GPU is certainly more efficient than mining with a CPU, at least. For a more complete answer you should consult the mining hardware comparison.
The rate at which solutions get accepted depends both on your hash rate and on the share difficulty set by the pool. In general you need not care about it, especially given that share difficulty can vary dynamically.

xxxxx\pooler-cpuminer-2.3.2-win64\minerd.exe --url=stratum+tcp://de2.miningpool.co:4101 --userpass=xx:xx
Any other commands to expand on this as after 5 minutes it gets disconnected.
No. If it gets disconnected it's almost certainly either the pool's or your Internet connection's fault (most probably the pool's). I'm always happy to test mining servers for compatibility, but I cannot even connect to the one mentioned above.
legendary
Activity: 924
Merit: 1000
xxxxx\pooler-cpuminer-2.3.2-win64\minerd.exe --url=stratum+tcp://de2.miningpool.co:4101 --userpass=xx:xx

Any other commands to expand on this as after 5 minutes it gets disconnected.
Pages:
Jump to: