CompuServe Thread

#C Benchmark

9 messages in this thread
#114594From: John G. AtaJul 26, 1990 7:46 PM
Does anyone know if there is something in an 80286 that makes it inherently faster than a M68000 (assuming the same clock cycle). I have a program (the infamous pi program, remember that one Mike?) that takes 6-7 seconds to run on the Amiga 2000, while the same program runs in 2 seconds on the PC at work. I thought it might be due to the compiler differences (Aztec on Amiga, and Microsoft on PC) but an examination of the assembly output of these two compilers show that the Aztec is as good and even better in places (at least in this program). There doesn't seem to be anything that explains the 300% improvement. In fact, when Microsoft is run unoptimized, it generates many more instructions per line of C including stack checking, and yet even this version runs in 2-3 seconds. So I'm thinking that it must be the hardware, and yet I am told at work that I am running an 8 MZ 80286. Note that this program does only integral addition, subtraction, multplication, division and modulus. There are no library function calls in the timing loop. It is compiled on the Amiga using 16 bit integers with full optimization to be as compatable as possible with the PC. Does the 80286 perhaps cache memory so that it is quicker? Just wondering… John
#114596From: Mike Spille/ManxJul 26, 1990 7:57 PM
Well, the Amiga is a multitasking machine, and I'm sure there's lots of interesting stuff going on in the background (even when no user tasks are running) which could be slowing it down somewhat, where as the PC wouldn't have any overhead of that type. If I recall, I think the 286 has a somewhat better ratio of clocks per instruction for the average instruction than the 68000 does. In the real world this advantage is balanced by the anemic register count on the '286, but your benchmark may be able to keep most stuff in the '286 registers. The 286 also has a small instruction pre-fetch (16-bytes I believe) – I can't recall if the 68000 has one, but if it doesn't that would also account for somewhat of a difference. Its hard to say exactly without seeing the 8086 and 68000 code side by side (remember smaller code doesn't necessarily mean faster code). -Mike
#114615From: John G. AtaJul 26, 1990 10:35 PM
Thanks Mike. But on further examination of the assembler output, it appears that Manx looses big in a few areas. For example, the following C line: p[j] -= t[j] – 10 Manx C (optimized): move.w d2,a0 add.l _p,a0 move.b (a0),d0 ext.w d0 move.l _t,a1 move.b (a1,d2.w),d1 ext.w d1 add.w d1,d0 sub.w #10,d0 move.b d0,(a0) Microsoft C (unoptimized & optimized): mov a1 sub a1,10 mov bx,_p add [bx][si],a1 Looks like over twice as many instructions (to my untrained eye) in this case for Aztec than Microsoft. Are we overdoing it a bit? In all fairness, this is the worst case I've seen, most other instructions look comparable or better. John
#114672From: Mike Spille/ManxJul 27, 1990 1:30 PM
In that case, it'd be nice to see the microsoft assembly in its entirety. Certain set-up operations are definitely not being done in the Microsofot code (like getting t[j], perhaps this is done in the 1st line, which is incomplete?), which is what's partially slowing us down. The other interesting part is that we're doing sign-extension to a word during intermediate steps where as Microsoft does not – this may or may not be necessary, depending on the exact types of the data object. I'll have to look at it here and get back to ya…. -Mike
#114934From: John G. AtaJul 29, 1990 8:47 PM
Mike, Would you like me to upload the Microsoft assembly listing somewhere where you could look at it? I also have a Microport Unix assembly listing, this is nowhere near as optimized as Microsoft, and yet runs twice as fast…I could upload that also. If so, where would the best place be to upload? Here on AmigaTech, as an Elecronic message or perhaps on the Manx BBS? John
#114986From: Mike Spille/ManxJul 30, 1990 11:52 AM
Well, if you made it with the Microsoft 5.1 (or 6.0 for that matter) compiler, I can simply try it out here (assuming you used the unmodified 'pi' source). What options did you use on MS? -Mike
#114791From: Tom EshelmanJul 28, 1990 4:40 PM
John: None of my cotton-pickin' business, but that Microsoft C code you have in your message to Mike does not consist of final instructions to the 68000 chip. It's been awhile, but they all appear to be illegal. Have you tried to take these instructions and assemble them with an assembler not made by MS? Regards Tom
#114933From: John G. AtaJul 29, 1990 8:47 PM
No Tom, the Microsoft C code I have is for the Intel chip, not the M68000 chip. I was discussing with Mike why a particular program I run on both machines seems to run much faster on the Intel… John
#115084From: Tom EshelmanJul 30, 1990 9:55 PM
John: (Flushed with embarassment)…. That may mean the Intel has more moxie than the Motorola! I seem to recall a mov instruction that had you move from one address to another. You can do this with Vax assembler, but not 68K. The latter requires two steps, as I recall. Address to reg. and reg. to destination address. Would this not explain why a program *would* run faster on the Intel given the same clock speed? The code should be shorter if there are fewer instructions required to effect the same result. Oh my, you may have me return to assembler. Regards Tom