Satoshi Forum Archive
Thread #0184

tcatm's 4-way SSE2 for Linux 32/64-bit is in 0.3.10

satoshi2010-08-15T15:52:09Z

0.3.10 has tcatm's 4-way SSE2 as an option switch.
Use the switch "-4way" to turn it on. Without the switch you get Crypto++ ASM SHA-256.
I could only get this working with Linux.
Download:
Get 0.3.10 from http://bitcointalk.org/index.php?topic=827.0
Please report back your CPU and results! I think it's pretty clear that Core 2 and lower are slower, i5 faster. I don't think we've heard any i7 results yet. We need to know about the different models of AMD or other less common CPUs.

Original message

knightmb2010-08-15T17:02:16Z

I did a quick test, will report back when I try it on more machines.
Pentium E5300 Dual-Core 2.6 GHz (2MB cache, FSB 800MHz)
Processor info: http://en.wikipedia.org/wiki/Wolfdale_%28microprocessor%29
Stock = 2261 khash/s
4-way = 1103 khash/s (64 bit)
Pentium 4 - 3.0GHz (hyper-threading off) 1MB Cache, FSB 800MHz
Processor info: http://en.wikipedia.org/wiki/NetBurst_%28microarchitecture%29
Stock = 1024 khash/s (32 bit)
4-way = 658 khash/s (32 bit)
Pentium 4 - 2.8GHz (hyper-threading off) 1MB Cache, FSB 800MHz
Processor info: http://en.wikipedia.org/wiki/NetBurst_%28microarchitecture%29
Stock = 917 khash/s (64 bit)
4-way = 747 khash/s (64 bit)
If I didn't know better, I would say the key is the CPU cache size. Seems all the CPU that run slower have 2 MB or less onboard cache, where as the Core i5 starts with at least 3MB of onboard CPU cache.

Original message

satoshi2010-08-15T18:23:26Z

I hope someone can test an i5 or AMD to check that I built it right. I don't have either to test with.
I'm also curious if it performs much worse on 32-bit linux vs 64-bit.

Original message

sgtstein2010-08-15T18:26:40Z

Where is the code for this? I'm on a CentOS 5.5 box and need to build it myself. Once I do that I will report back with linux 32-bit and 1MB cache Xeon.

Original message

satoshi2010-08-15T18:43:27Z

I just uploaded a quick build so testers can check if I built it right. (I don't have an i5 or AMD) If it checks out, I'll put together the full package and do all the release stuff.

Original message

sgtstein2010-08-15T18:46:25Z

Okay, makes sense. I have an i7 930 I'll try and test out with too.

Original message

tcatm2010-08-15T21:50:41Z

Quote from: knightmb on August 15, 2010, 05:02:16 PM (https://bitcointalk.org/index.php?topic=820.msg9457#msg9457)

If I didn't know better, I would say the key is the CPU cache size. Seems all the CPU that run slower have 2 MB or less onboard cache, where as the Core i5 starts with at least 3MB of onboard CPU cache.

That's unlikely. The loop accesses 432 bytes of data. That should fit in most caches.

Original message

Ground Loop2010-08-15T23:49:40Z

5,911 khash with -4way
11,260 without
(Dual Xeon E5450, 64-bit, 8 threads)

Original message

tcatm2010-08-16T00:03:18Z

-4way: 12518 khash/s
without: 6550 khash/s
It's a little bit slower than my patch (~14000kash/s).
edit: I ran the binary on an older AMD Athlon(tm) 64 X2 Dual Core Processor 4200+ with the same effect we see on older intel cpus:
-4way: 1120khash/s
without: 2012khash/s

Original message

tcatm2010-08-16T00:08:38Z

Did anyone verify it to produce correct results on 32 bit hosts?

Original message

gebler2010-08-16T00:32:57Z

Running 32-bit Linux on an AMD Athlon 64 X2, I get the following results:
normal: 2850 khash/s
with -4way: 1708 khash/s
I haven't checked if the hashes are correct, just the speed.

Original message

aceat642010-08-16T00:37:54Z

I created a wiki page so we can keep track of the results: http://www.bitcoin.org/wiki/doku.php?id=4-way_sse2

Original message

tcatm2010-08-16T00:43:39Z

I propose to compile sha256.cpp with -O3 -march=amdfamk10 (will work on 32bit and 64bit) as only CPUs supporting this instruction set (AMD Phenom, Intel i5 and newer) benefit from -4way and it'll improve performance by ~9%.

Original message

HostFat2010-08-16T00:47:23Z

Quote from: tcatm on August 16, 2010, 12:43:39 AM (https://bitcointalk.org/index.php?topic=820.msg9617#msg9617)

I propose to compile sha256.cpp with -O3 -march=amdfamk10 (will work on 32bit and 64bit) as only CPUs supporting this instruction set (AMD Phenom, Intel i5 and newer) benefit from -4way and it'll improve performance by ~9%.

Good ![Cheesy](https://bitcointalk.org/static/img/emoticons/cheesy.gif)
Will this also work on Windows OS?

Original message

tcatm2010-08-16T00:50:04Z

Quote from: Joozero on August 16, 2010, 12:47:23 AM (https://bitcointalk.org/index.php?topic=820.msg9620#msg9620)

Quote from: tcatm on August 16, 2010, 12:43:39 AM (https://bitcointalk.org/index.php?topic=820.msg9617#msg9617)

I propose to compile sha256.cpp with -O3 -march=amdfamk10 (will work on 32bit and 64bit) as only CPUs supporting this instruction set (AMD Phenom, Intel i5 and newer) benefit from -4way and it'll improve performance by ~9%.

Good ![Cheesy](https://bitcointalk.org/static/img/emoticons/cheesy.gif)
Will this also work on Windows OS?

Didn't try it, but CFLAGS are not OS dependent at all so I guess it'll work.

Original message

NewLibertyStandard2010-08-16T01:49:01Z

Quote from: aceat64 on August 16, 2010, 12:37:54 AM (https://bitcointalk.org/index.php?topic=820.msg9613#msg9613)

I created a wiki page so we can keep track of the results: http://www.bitcoin.org/wiki/doku.php?id=4-way_sse2

You might want to add columns for whether hyper-threading is enabled, number of physical cores and how many cores Bitcoin is using. Without 4way, I get very slightly better results when I have half of my virtual cores hashing. With 4way, I get significantly better performance when I have all my virtual cores enabled. I think I get about the same amount of hashes when hyper threading is turned off with or without 4way.

Original message

aceat642010-08-16T02:13:28Z

Quote from: NewLibertyStandard on August 16, 2010, 01:49:01 AM (https://bitcointalk.org/index.php?topic=820.msg9630#msg9630)

Quote from: aceat64 on August 16, 2010, 12:37:54 AM (https://bitcointalk.org/index.php?topic=820.msg9613#msg9613)

I created a wiki page so we can keep track of the results: http://www.bitcoin.org/wiki/doku.php?id=4-way_sse2

You might want to add columns for whether hyper-threading is enabled, number of physical cores and how many cores Bitcoin is using. Without 4way, I get very slightly better results when I have half of my virtual cores hashing. With 4way, I get significantly better performance when I have all my virtual cores enabled. I think I get about the same amount of hashes when hyper threading is turned off with or without 4way.

I've updated the page with your suggestions, I've also added footnotes to explain some of the fields.

Original message

jgarzik2010-08-16T02:30:52Z

My -4way results: slower for two older boxes, faster for newer one.
("model name" comes from Linux's /proc/cpuinfo, which reports directly from CPU)
1) model name : Intel(R) Pentium(R) D CPU 3.00GHz
total cores: 2
without -4way: 0.999 Mhash/sec
with -4way: 0.850 Mhash/sec
2) model name : Dual Core AMD Opteron(tm) Processor 280
total cores: 4
without -4way: 4.6 Mhash/sec
with -4way: 4.0 Mhash/sec
3) model name : Genuine Intel(R) CPU 000 @ 3.20GHz
total cores: 4
without -4way: 5.7 Mhash/sec
with -4way: 7.0 Mhash/sec

Original message

satoshi2010-08-16T02:57:57Z

Quote from: tcatm on August 16, 2010, 12:43:39 AM (https://bitcointalk.org/index.php?topic=820.msg9617#msg9617)

I propose to compile sha256.cpp with -O3 -march=amdfamk10 (will work on 32bit and 64bit) as only CPUs supporting this instruction set (AMD Phenom, Intel i5 and newer) benefit from -4way and it'll improve performance by ~9%.

GCC 4.3.3 doesn't support -march=amdfamk10. I get:
sha256.cpp:1: error: bad value (amdfamk10) for -march= switch

Quote from: NewLibertyStandard on August 16, 2010, 01:49:01 AM (https://bitcointalk.org/index.php?topic=820.msg9630#msg9630)

With 4way, I get significantly better performance when I have all my virtual cores enabled. I think I get about the same amount of hashes when hyper threading is turned off with or without 4way.

Hey, you may be onto something!
hyperthreading didn't help before because all the work was in the arithmetic and logic units, which the hyperthreads share.
tcatm's SSE2 code must be a mix of normal x86 instructions and SSE2 instructions, so while one is doing x86 code, the other can do SSE2.
How much of an improvement do you get with hyperthreading?
Some numbers? What CPU is that?

Original message

lfm2010-08-16T03:10:34Z

model name : AMD Phenom(tm) II X4 940 Processor at 3.0 ghz linux 64
with -4way "hashespersec" : 11132770
without "hashespersec" : 5877668

Original message

gridecon2010-08-16T03:15:44Z

I have two quadcore Phenom II 64-bit linux machines (ubuntu 9.10 both) and the -4way option increases my hashing speed so much I'm suspicious. I get about 5-6khash/sec on these boxes previously and without -4way option. With -4way I get over 11khash/sec! In other words, the -4way switch almost DOUBLES the reported hashing speed. This level of improvement seems more than expected and makes me wonder if my boxes are really doing the hashing that much faster or if there could possible be an issue where the math operations are actually being skipped over for some reason, causing illusory speed and an inability to actually generate blocks?

Original message

Vasiliev2010-08-16T03:17:07Z

Quote from: satoshi on August 16, 2010, 02:57:57 AM (https://bitcointalk.org/index.php?topic=820.msg9655#msg9655)

Quote from: tcatm on August 16, 2010, 12:43:39 AM (https://bitcointalk.org/index.php?topic=820.msg9617#msg9617)

I propose to compile sha256.cpp with -O3 -march=amdfamk10 (will work on 32bit and 64bit) as only CPUs supporting this instruction set (AMD Phenom, Intel i5 and newer) benefit from -4way and it'll improve performance by ~9%.

GCC 4.3.3 doesn't support -march=amdfamk10. I get:
sha256.cpp:1: error: bad value (amdfamk10) for -march= switch

try -march=amdfam10

Original message

satoshi2010-08-16T03:23:04Z

Quote from: Vasiliev on August 16, 2010, 03:17:07 AM (https://bitcointalk.org/index.php?topic=820.msg9660#msg9660)

try -march=amdfam10

That works.
That's strange... are we sure that's the same thing? tcatm, try amdfam10 and make sure you get the same speed measurement.

Original message

Vasiliev2010-08-16T03:27:35Z

http://www.google.com/search?q=amdfamk10
I think he misremembered it since AMD arches are K#.

Original message

lfm2010-08-16T03:30:35Z

model name : Intel(R) Core(TM)2 Quad CPU Q9450 @ 2.66GHz, linux 64
no difference at about 4950 khash/s

Original message

jgarzik2010-08-16T03:35:28Z

Update for

Code:

cpu family : 6
model : 26
model name : Genuine Intel(R) CPU 000 @ 3.20GHz
stepping : 4

Machine has 4 cores, each with 2 hyperthreads. /proc/cpuinfo shows 8 virtual processors.
without -4way, setgen 4: 5.7 Mhash/sec
without -4way, setgen 8: 5.0 Mhash/sec
with -4way, setgen 4: 7.0 Mhash/sec
with -4way, setgen 8: 9.3 Mhash/sec
So, the old wisdom of "hyperthreading slows things down" is now shattered, on this machine.

Original message

Ground Loop2010-08-16T04:34:20Z

No winners for 4way in my other three Intel machines either:
Intel(R) Core(TM)2 Duo CPU E8500 @ 3.16GHz (64-bit Linux)
4way: 1565 std: 3002
Intel(R) Xeon(TM) CPU 3.00GHz (32-bit Linux)
4way: 1243 std: 2048
Intel(R) Core(TM)2 CPU 6300 @ 1.86GHz
4way: 932 std: 1733
(All running 0.3.10, -1 proclimit)
Experiments with proclimit weren't any better.

Original message

satoshi2010-08-16T04:36:59Z

Quote from: jgarzik on August 16, 2010, 03:35:28 AM (https://bitcointalk.org/index.php?topic=820.msg9665#msg9665)

Code:

cpu family : 6
model : 26
model name : Genuine Intel(R) CPU 000 @ 3.20GHz
stepping : 4

cpu family 6 model 26 stepping 4 is an Intel Core i7.
That's a 23% speedup with -4way, 63% total speedup with -4way + hyperthreading.
33% faster with hyperthreading than without it.

Original message

NewLibertyStandard2010-08-16T05:02:31Z

Quote from: gridecon on August 16, 2010, 03:15:44 AM (https://bitcointalk.org/index.php?topic=820.msg9659#msg9659)

I have two quadcore Phenom II 64-bit linux machines (ubuntu 9.10 both) and the -4way option increases my hashing speed so much I'm suspicious. I get about 5-6khash/sec on these boxes previously and without -4way option. With -4way I get over 11khash/sec! In other words, the -4way switch almost DOUBLES the reported hashing speed. This level of improvement seems more than expected and makes me wonder if my boxes are really doing the hashing that much faster or if there could possible be an issue where the math operations are actually being skipped over for some reason, causing illusory speed and an inability to actually generate blocks?

o_O... good luck hashing, you're gonna need it!

Quote from: satoshi on August 16, 2010, 02:57:57 AM (https://bitcointalk.org/index.php?topic=820.msg9655#msg9655)

Quote from: NewLibertyStandard on August 16, 2010, 01:49:01 AM (https://bitcointalk.org/index.php?topic=820.msg9630#msg9630)

With 4way, I get significantly better performance when I have all my virtual cores enabled. I think I get about the same amount of hashes when hyper threading is turned off with or without 4way.

Hey, you may be onto something!
hyperthreading didn't help before because all the work was in the arithmetic and logic units, which the hyperthreads share.
tcatm's SSE2 code must be a mix of normal x86 instructions and SSE2 instructions, so while one is doing x86 code, the other can do SSE2.
How much of an improvement do you get with hyperthreading?
Some numbers? What CPU is that?

Here are the results from my very poor memory on an i7 860 2.8 GHz with Ubuntu 10.04 amd64. Some of the numbers may be a bit off.
Without 4way, with HT, 4/8 virtual cores, 4.5-5 Mhash/sec
Without 4way, with HT, 8/8 virtual cores, a bit less than above, but basically the same
With 4way, with HT, 8/8 virtual cores, 6.5-8 Mhash/sec (It may be my imagination, but it seems noticeably more variable.)
With 4way, with HT, 4/8 virtual cores, 5-6 Mhash/sec
Without 4way, without HT, 4/4 physical cores, 4.5-5 Mhas/sec (But a bit slower than the first result.)
With 4way, without HT, 4/4 physical cores, 5-6 Mhash/sec

Original message

gridecon2010-08-16T05:30:15Z

Quote from: NewLibertyStandard on August 16, 2010, 05:02:31 AM (https://bitcointalk.org/index.php?topic=820.msg9680#msg9680)

Quote from: gridecon on August 16, 2010, 03:15:44 AM (https://bitcointalk.org/index.php?topic=820.msg9659#msg9659)

I have two quadcore Phenom II 64-bit linux machines (ubuntu 9.10 both) and the -4way option increases my hashing speed so much I'm suspicious. I get about 5-6khash/sec on these boxes previously and without -4way option. With -4way I get over 11khash/sec! In other words, the -4way switch almost DOUBLES the reported hashing speed. This level of improvement seems more than expected and makes me wonder if my boxes are really doing the hashing that much faster or if there could possible be an issue where the math operations are actually being skipped over for some reason, causing illusory speed and an inability to actually generate blocks?

o_O... good luck hashing, you're gonna need it!

I guess that should read either mhash/sec or THOUSANDS of khash/sec...but hey, what's 3 orders of magnitude among friends?
Perhaps that typographical error is why nobody has answered whether or not a nearly 100% speeded from the -4way option is at all realistic? I'm not convinced the crypto hashing is really taking place at the rate of 11000khash/sec on my desktop box.

Original message

jgarzik2010-08-16T05:33:56Z

Quote from: satoshi on August 16, 2010, 04:36:59 AM (https://bitcointalk.org/index.php?topic=820.msg9676#msg9676)

Quote from: jgarzik on August 16, 2010, 03:35:28 AM (https://bitcointalk.org/index.php?topic=820.msg9665#msg9665)

Code:

cpu family : 6
model : 26
model name : Genuine Intel(R) CPU 000 @ 3.20GHz
stepping : 4

cpu family 6 model 26 stepping 4 is an Intel Core i7.
That's a 23% speedup with -4way, 63% total speedup with -4way + hyperthreading.
33% faster with hyperthreading than without it.

Does bitcoin perform any self-tests at startup, to verify that hashing is working?

Original message

NewLibertyStandard2010-08-16T06:16:44Z

More importantly, about how long should it take 10 Mhash/sec to verify difficulty 1 blocks?
After the 64-bit Linux hashing bug was fixed I generated a block or two in short order, but since that one or two blocks, I have not generated a single block. It's starting to seem a little fishy.
I'm currently testing Bitcoin on two Linux 64-bit computers. Is there anything in the code blocking early block verification?
Edit: Never mind. I used the Bitcoin Generation Calculator (http://www.alloscomp.com/bitcoin/calculator.php) and divided out the difficulty. Everything is fine here, I've generated a couple blocks with 4way. About to start testing without 4way.
Another Edit: My test only verifies that hashing works. It does not verify whether I'm really getting the displayed speed.

Original message

tcatm2010-08-16T11:15:04Z

@satoshi: Oops, I meant -march=amdfam10. Sorry.
@everyone confused about improvement on Phenoms: I developed the code on a Phenom (940) and verified it (at least in 64bit mode) and the improvement you see is real.
Concerning Hyperthreading: It seems to give a little performance gain, maybe from running load/store instructions in parallel with aritmethic instructions. There's only a tiny bit of plain x86 instructions for glueing the function into the ABI. They take less than ~2% of the total CPU time (measured with gprof).

Original message

teknohog2010-08-16T12:31:51Z

On a Core 2 Duo T7200, the default code gives about 1.8 Mhash/s, and 4way is slower at 1.0 Mhash/s. It has 4 MB of L2 cache, so it is probably not a question of cache size, as suggested at some point.
Unfortunately, the code (from svn) no longer compiles on ARM, as it now has SSE intrinsics hardcoded. I have removed the -msse2 and -DFOURWAYSSE2 flags from the makefile, and it still produces errors like this

Code:

sha256.cpp:8:23: error: xmmintrin.h: No such file or directory
sha256.cpp:34: error: ‘__m128i’ does not name a type

but hopefully this is easy to fix.

Original message

satoshi2010-08-16T13:38:01Z

I wrapped sha256.cpp in
#ifdef FOURWAYSSE2
#endif // FOURWAYSSE2
try it now.

Original message

tommy2010-08-16T15:42:55Z

model name : AMD Athlon(tm) 64 X2 Dual Core Processor 5600+
w/o -4way "hashespersec" : 2539397
with -4way "hashespersec" : 2108791
Linux, Debian, 32 bit.

Original message

teknohog2010-08-16T16:41:31Z

Quote from: satoshi on August 16, 2010, 01:38:01 PM (https://bitcointalk.org/index.php?topic=820.msg9736#msg9736)

I wrapped sha256.cpp in
#ifdef FOURWAYSSE2
#endif // FOURWAYSSE2
try it now.

Thanks, works fine now.

Original message

hugolp2010-08-17T18:26:27Z

Model: Intel Atom n330 (2 cores, 4 virtual).
OS: Ubuntu 10.04 64bit
Using the -4way option I get half the speed than using no option.

Original message

denaje2010-08-18T19:06:04Z

64-bit Gentoo / Intel Core i7
W/O 4way: 4324294
With 4way: 7649415
32-bit Ubuntu VM on XP host / Intel Core 2 Duo
W/O 4way: 1751518
With 4way: 793100

Original message

Ground Loop2010-08-18T23:00:08Z

So is it accurate to say that, so far, only Intel Core i7 processors and certain (Phenom?) AMD processors enjoy a speed bump from -4way?

Original message

nelisky2010-08-18T23:02:25Z

Quote from: Ground Loop on August 18, 2010, 11:00:08 PM (https://bitcointalk.org/index.php?topic=820.msg10163#msg10163)

So is it accurate to say that, so far, only Intel Core i7 processors and certain (Phenom?) AMD processors enjoy a speed bump from -4way?

And i5, at least on my macbookpro

Original message

Ground Loop2010-08-18T23:14:26Z

Any non-Mac i5 love?
Windows i5 64-bit got slower here.
[correction -- not true. Windows doesn't have -4way, and the Linux machines are Xeons.]

Original message

vess2010-08-19T06:41:27Z

My Core i5 laptop (Ubuntu) doubled in speed. Actually, it didn't double in speed. It stayed the same speed, but only uses half the CPU now. I can't get it to go back to full CPU usage. That said, my laptop is a lot cooler when generating blocks now. I'll post back if I see it successfully go up to 100% usage.

Original message

satoshi2010-08-19T19:07:43Z

Quote from: Ground Loop on August 18, 2010, 11:14:26 PM (https://bitcointalk.org/index.php?topic=820.msg10167#msg10167)

Any non-Mac i5 love?
Windows i5 64-bit got slower here.

That's the first I've heard anyone say i5 was slower. Everyone else has said 4way was faster on i5. Moreso with hyperthreading enabled.

Quote from: nelisky on August 18, 2010, 11:02:25 PM (https://bitcointalk.org/index.php?topic=820.msg10164#msg10164)

And i5, at least on my macbookpro

Good, so I take it that's a confirmation that it's working on Mac as well?
Laszlo told me he did compile in the -4way stuff on Mac, so the -4way switch is also available to try on Mac. I don't think makefile.osx on SVN has it yet, just the built version.

Original message

nelisky2010-08-19T20:28:19Z

Quote from: satoshi on August 19, 2010, 07:07:43 PM (https://bitcointalk.org/index.php?topic=820.msg10281#msg10281)

Quote from: nelisky on August 18, 2010, 11:02:25 PM (https://bitcointalk.org/index.php?topic=820.msg10164#msg10164)

And i5, at least on my macbookpro

Good, so I take it that's a confirmation that it's working on Mac as well?
Laszlo told me he did compile in the -4way stuff on Mac, so the -4way switch is also available to try on Mac. I don't think makefile.osx on SVN has it yet, just the built version.

Yep, it's working all right. The number I had posted were from an old svn revision patched with tcatm's changes, but today I compiled trunk and while I had to once again tweak the makefile, after I did it works great with the numbers matching what I experienced before.
Changes I did for my system are below, and while some are cosmetic, like removing wx-config from making bitcoind, just to avoid the warnings if you don't have it installed, others are system specific, like the DEPS dir, and the fact I don't have 32bit libs which makes the link step fail if -arch i386 is there.
The bsddb changes are, I believe, a typo. Includes and Libs point to db46, but then the object list for the linker states db48. Anyway, here's the diff for what got me going:

Code:

Index: makefile.osx
===================================================================
--- makefile.osx (revision 139)
+++ makefile.osx (working copy)
@@ -6,29 +6,29 @@
# Laszlo Hanyecz (solar@heliacal.net)

CXX=llvm-g++
-DEPSDIR=/Users/macosuser/bitcoin/deps
+DEPSDIR=/opt/local

INCLUDEPATHS= \
- -I"$(DEPSDIR)/include"
+ -I"$(DEPSDIR)/include" -I"$(DEPSDIR)/include/db46"

LIBPATHS= \
- -L"$(DEPSDIR)/lib"
+ -L"$(DEPSDIR)/lib" -L"$(DEPSDIR)/lib/db46"

-WXLIBS=$(shell $(DEPSDIR)/bin/wx-config --libs --static)
+WXLIBS=

LIBS= -dead_strip \
- $(DEPSDIR)/lib/libdb_cxx-4.8.a \
- $(DEPSDIR)/lib/libboost_system.a \
- $(DEPSDIR)/lib/libboost_filesystem.a \
- $(DEPSDIR)/lib/libboost_program_options.a \
- $(DEPSDIR)/lib/libboost_thread.a \
+ $(DEPSDIR)/lib/db46/libdb_cxx-4.6.a \
+ $(DEPSDIR)/lib/libboost_system-mt.a \
+ $(DEPSDIR)/lib/libboost_filesystem-mt.a \
+ $(DEPSDIR)/lib/libboost_program_options-mt.a \
+ $(DEPSDIR)/lib/libboost_thread-mt.a \
$(DEPSDIR)/lib/libcrypto.a

-DEFS=$(shell $(DEPSDIR)/bin/wx-config --cxxflags) -D__WXMAC_OSX__ -DNOPCH -DMSG_NOSIGNAL=0
+DEFS=-D__WXMAC_OSX__ -DNOPCH -DMSG_NOSIGNAL=0 -DFOURWAYSSE2

DEBUGFLAGS=-g -DwxDEBUG_LEVEL=0
# ppc doesn't work because we don't support big-endian
-CFLAGS=-mmacosx-version-min=10.5 -arch i386 -arch x86_64 -O3 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
+CFLAGS=-mmacosx-version-min=10.5 -arch x86_64 -O3 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h

@@ -42,6 +42,7 @@
obj/rpc.o \
obj/init.o \
cryptopp/obj/sha.o \
+ obj/sha256.o \
cryptopp/obj/cpu.o

@@ -55,7 +56,7 @@
$(CXX) -c $(CFLAGS) -O3 -DCRYPTOPP_DISABLE_ASM -o $@ $<

bitcoin: $(OBJS) obj/ui.o obj/uibase.o
- $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS)
+ $(CXX) $(shell $(DEPSDIR)/bin/wx-config --cxxflags) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(shell $(DEPSDIR)/bin/wx-config --libs --static) $(LIBS)

obj/nogui/%.o: %.cpp $(HEADERS)

Original message

ArtForz2010-08-21T16:56:31Z

The difference between new and older CPUs is pretty easy to explain.
Older microarchitectures have 64-bit mmx/sse execution units and split 128bit sse ops into 2 64bit microops.
Newer archs have 128bit sse units.
- AMD K8: 2 64bit units
- intel Core/Core2: 3 64bit units
- AMD K10: 2 128bit units
- intel nehalem: 3 128bit unitsK10 = Opterons with 4 or more cores, Phenom, Phenom II, Athlon II
nehalem = xeon 34xx/35xx/36xx/55xx/56xx/65xx/75xx, i3/i5/i7

Original message

satoshi2010-08-22T23:21:50Z

Thanks for clearing that up. I read the link someone posted about AMD making that change around 2007, but I didn't know what the story was for Intel.
There's no hope for Core/Core2 then. They only have half the SSE2 hardware.
Strange that Intel has 3 128bit units, but AMD with 2 128bit units is the faster one.

Original message

Ground Loop2010-08-23T05:45:17Z

Intel Atom 230 @ 1.60GHz. Linux 32-bit.
(Acer Aspire Revo)
Stock: 438 khash/sec (1 proc gives 354)
4way: 254 khash/sec
So you can take this one off the powerhouse list. ![Smiley](https://bitcointalk.org/static/img/emoticons/smiley.gif)
![Grin](https://bitcointalk.org/static/img/emoticons/grin.gif)

Original message

sgtstein2010-08-24T17:31:08Z

Anybody catch the new AMD Bulldozer press release? If I understand correctly, it should be capable of processing 8 64bit hashes, per core, at the same time. Would be quite a speed boost using this same code design.
Slashdot (http://hardware.slashdot.org/story/10/08/24/1521203/AMD-Details-Upcoming-Bulldozer-Architecture) has the article.
PC Perspective (http://www.pcper.com/article.php?aid=985&type=expert) has the details.
Was also covered by AnandTech (http://www.anandtech.com/show/2872) back in November, 2009.

Original message

satoshi2010-08-24T22:43:56Z

Quote from: ArtForz on August 21, 2010, 04:56:31 PM (https://bitcointalk.org/index.php?topic=820.msg10609#msg10609)

- AMD K10: 2 128bit units
- intel nehalem: 3 128bit units

This probably explains why hyperthreading increases performance with -4way. If three SSE2 units is excessive, then hyperthreading would help keep them all busy.

Original message

tcatm2010-08-28T00:27:08Z

I just reviewed the sourcecode as I had a few ideas to optimize it further and I noticed that 4way is partly broken:
from main.cpp:

Code:

for (int j = 0; j < NPAR; j++)
{
if (thash[7][j] == 0)
{
for (int i = 0; i < sizeof(hash)/4; i++)
((unsigned int*)&hash)[i] = thash[i][j];
pblock->nNonce = ByteReverse(tmp.block.nNonce + j);
}
}

The code will only process one hash (the last with thash[7] == 0) out of 32 hashes even when there is more than one hash that might be a correct one.
Somethine like this should fix it but it won't be safe at higher difficulties. Also, I'm not sure whether the byte order should be reversed or not. Could someone review this?

Code:

unsigned int min_hash = ~1;
for (int j = 0; j < NPAR; j++)
{
if (thash[7][j] == 0)
{
if(thash[6][j] < min_hash) {
min_hash = thash[6][j];
for (int i = 0; i < sizeof(hash)/4; i++)
((unsigned int*)&hash)[i] = thash[i][j];
pblock->nNonce = ByteReverse(tmp.block.nNonce + j);
}
}
}

Original message

satoshi2010-08-28T14:27:15Z

The simplification is intentional. There will only be more than one thash[7]=0 in one out of 134,217,728 cases. It only makes it 0.0000007% slower.

Original message