Page 1 of 3
Are core2duos slower than single cores?
Posted: Sun Dec 03, 2006 4:01 pm
by Derek
Can anyone test and post their results to this bit of code.
It seems that my core2duo isn't as fast as I would have hoped.
Code: Select all
OpenConsole()
start = ElapsedMilliseconds()
For n = 1 To 50000000
x = 1/Sqr(100)
Next
stop = ElapsedMilliseconds()
PrintN(Str(stop-start))
Input()
With debugger enabled I get about 6485 and without I get about 2390.
I'm only doing this test to see if PureBasic works as fast as it should with dual cores!
Posted: Sun Dec 03, 2006 4:51 pm
by tmyke
It is normal, it's necessary that the application works both cores.
In this case, it's mono thread and thus that uses one of both core.
to work both core, it is necessary to write multithread application.

Posted: Sun Dec 03, 2006 4:56 pm
by Rescator
AMD Athlon 64 single core 1.8Ghz, WinXP 32bit:
w/Debugger = 5140 ms
without = 1172 ms
Most likely it's a optimization issue, multiple cpu systems only perform better with multiple threads.
Hyperthreading and similar however may benefit from pairing.
I.e. instead of reading a value from memory then using it,
it may be better to read two values, then use the two values.
Another issue is floating point handling,
switching between integer and float is more expensive than just integer or just float.
commented asm of your loop
Code: Select all
MOV dword [v_start],eax
; For n = 1 To 50000000
MOV dword [v_n],1
_For1:
MOV eax,50000000
CMP eax,dword [v_n]
JL _Next2
; x = 1/Sqr(100)
FLD dword [F1]
FSQRT
FDIVR qword [D1]
FISTP dword [v_x]
; Next
_NextContinue2:
INC dword [v_n]
JMP _For1
_Next2:
I'm no asm expert but that FISTP is slow if I recall correctly.
I' sure that doing the loop directly in asm would allow it to be made differently and much faster.
If you intend to compare single and multicore/multi cpu systems,
then simply compare the slowest cpu/core with the single cpu system.
What is the speed of the two cores/slowest core/cpu?
And which windows version do you run by the way?
PS! multi cpu/multi core do provide a benefit. The OS should be able to "spread out" the processes over the cores/cpu's so overall system perfomance should be better, two heavy programs can run at once while still performing well etc.
Posted: Sun Dec 03, 2006 5:20 pm
by Derek
@Rescator, I'm using XPsp2 32bit.
I know the benefits of having dual core with programs multitasking etc.
I was just wondering why the program runs so slow.
I would have thought that even without making multiple threads and just treating the cpu that the program is running on as a single core that the core2s would run the program faster than they are.
You used to know where you were in the past with computers having a mhz rating but now some go slower than others with a lower rating but better architecture and vice versa.
Posted: Sun Dec 03, 2006 5:34 pm
by Kale
Derek wrote:@Rescator, I'm using XPsp2 32bit.
I know the benefits of having dual core with programs multitasking etc.
I was just wondering why the program runs so slow.
I would have thought that even without making multiple threads and just treating the cpu that the program is running on as a single core that the core2s would run the program faster than they are.
You used to know where you were in the past with computers having a mhz rating but now some go slower than others with a lower rating but better architecture and vice versa.
Basically you are only using one core if you don't run programs that utilise both.
Posted: Sun Dec 03, 2006 6:11 pm
by Derek
@kale, thats my point exactly, I have two cores running at 1.8 ghz each, if I run the program on one core why is it so slow compared to a computer with only one core also running at 1.8 ghz.
Rescator = 1172 ms
Me = 2390 ms
I know we are using different chips and different manufacturers but should the difference (time wise) really be that much??
Shouldn't the single core be busy with all the little things that make the computer tick while the dual core has a friend to help out and should be belting along.

Posted: Sun Dec 03, 2006 6:15 pm
by Rescator
Derek, you never mentioned the speed of your core2duo but I'll assume that it 's Ghz is somewhat lower compared to a intel single core cpu of the same price range.
Also, 2 cores or 2 cpu's do not double the performance.
At least not with current OS or applications.
I guess the performance will crawl from the 0-10% range it is now up to maybe 50-80% in the future depending on the applications and OS obviously.
Another issue is the cores (and multiple cpus) share resources like memory.
In this respect AMD has an edge over intel due to the built in memory manager, I have no idea what intel is doing to improve stuff like that as I prefer AMD myself so (it's all about price/performance).
Now! If you do the same example but in with two different threads,
you should (in theory) see the multi core/cpu system perform at least 50% better than a single cpu system.
But since Ghz is not the sole benchmark of performance any more it's hard to compare cpu against cpu easily these days.
Just pray that neither intel nor AMD get sleazy about the marketing
and call a dual core cpu where each core is 2Ghz for a 4Ghz cpu as that would be a lie, if anything it would be a 2x2Ghz cpu then

Posted: Sun Dec 03, 2006 6:21 pm
by Derek
@Rescator, the ironic thing is that I always bought AMD and actually had an amd3000 64bit upto a couple of months ago when something broke big time and I kind of rushed out and got this core2duo 6300.
I would of bought an amd 3800+ dual core but the socket wasn't the new sort so I changed my mind.
Anyway, you can see from my previous post the reasons I am puzzled.
Not that any of this matters really, it was just something that I came across.
Posted: Sun Dec 03, 2006 6:25 pm
by Trond
Derek wrote:@kale, thats my point exactly, I have two cores running at 1.8 ghz each, if I run the program on one core why is it so slow compared to a computer with only one core also running at 1.8 ghz.
Rescator = 1172 ms
Me = 2390 ms
I know we are using different chips and different manufacturers but should the difference (time wise) really be that much??
Me: 1250 ms. I have a normal single-core thing from AMD. Its name is 2400+, but the real speed is in theory 1.8 Ghz. The point here is than an 1.8 Ghz from AMD performs much better than a processor with the same frequency from Intel, but, each Mhz is also more expensive.
So let's say you buy an 2.2 Ghz intel processor and an 1.8 Ghz AMD processor they may cost the same and perform the same.
Edit: Almost 2000 ms when I use battery power. Because then Windows slows down the processor to save power.
Edit again:
A threaded version that does twice the work uses 2350 ms here. How fast does it run for you?
Code: Select all
Procedure DoIt(Void)
For n = 1 To 50000000
x = 1/Sqr(100)
Next
EndProcedure
OpenConsole()
start = ElapsedMilliseconds()
Thread = CreateThread(@DoIt(), 1)
DoIt(0)
WaitThread(Thread)
stop = ElapsedMilliseconds()
PrintN(Str(ID) + ": " + Str(stop-start))
Input()
Posted: Sun Dec 03, 2006 6:50 pm
by Derek
@Trond
It takes 2391, the same as before.
Posted: Sun Dec 03, 2006 6:54 pm
by Derek
Is this just another amd vs intel thing or does this happen on all dual cores regardless of manufacturer.
Posted: Sun Dec 03, 2006 7:42 pm
by Trond
Derek wrote:@Trond
It takes 2391, the same as before.
And remember it does twice the work. That's the point of the dual core.
Posted: Sun Dec 03, 2006 7:55 pm
by Derek
Just tried the same program in Blitz3d (yes, I own both programs!) and I get 1248 and 5740 so what is blitz doing right that pb isn't?
Posted: Sun Dec 03, 2006 8:46 pm
by Trond
Probably using a register for the loop variable. That doesn't make any difference here, though. But it's faster if you declare x as float.
Edit:
I forgot: Blitz is known to cheat and use low-precision math functions. They are faster, but they give less accurate results.
Posted: Sun Dec 03, 2006 8:58 pm
by Derek
PB
Code: Select all
OpenConsole()
start = ElapsedMilliseconds()
For n = 1 To 50000000
x.f = x.f+(1.0/Sqr(n))
Next
stop = ElapsedMilliseconds()
PrintN(Str(stop-start))
PrintN(StrF(x.f))
Input()
Blitz
Code: Select all
start = MilliSecs()
For n = 1 To 50000000
x# = x#+(1.0/Sqr(n))
Next
Stp = MilliSecs()
Print Str(Stp-start)
Print x#
Repeat
Until KeyHit(1)
PB=2360 and 8192.000000
Blitz=1291 and 8192.0
Probably right about the precision but I still think something is up with PB and its way that it works with dual cores!