Author Topic: C/C++ vs Assembler  (Read 66461 times)

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: C/C++ vs Assembler
« Reply #60 on: May 07, 2013, 03:27:10 AM »
:biggrin:  as if the subject has never come up before



oh yes, it's a very new topic.  :lol: :lol: :lol:

Gunther
You have to know the facts before you can distort them.

jj2007

  • Member
  • *****
  • Posts: 13937
  • Assembly is fun ;-)
    • MasmBasic
Re: C/C++ vs Assembler
« Reply #61 on: May 07, 2013, 03:31:40 AM »
Behold and see...

Intel(R) Celeron(R) M CPU        420  @ 1.60GHz (SSE3)
41      cycles for Small 1
38      cycles for Small 2
40      cycles for Small 3
42      cycles for Small 3.1
41      cycles for Small 4
50      cycles for C version
53      cycles for C mod JJ
58      hsz2dw (Microsoft 32-Bit C/C++ optimization compiler v16.00.40219.01)
24      hsz2dw2 (unrolled 4 times)

41      cycles for Small 1
39      cycles for Small 2
41      cycles for Small 3
57      cycles for Small 3.1
23      cycles for Small 4
51      cycles for C version
53      cycles for C mod JJ
31      hsz2dw (Microsoft 32-Bit C/C++ optimization compiler v16.00.40219.01)
24      hsz2dw2 (unrolled 4 times)

43      cycles for Small 1
38      cycles for Small 2
41      cycles for Small 3
42      cycles for Small 3.1
41      cycles for Small 4
50      cycles for C version
51      cycles for C mod JJ
31      hsz2dw (Microsoft 32-Bit C/C++ optimization compiler v16.00.40219.01)
24      hsz2dw2 (unrolled 4 times)


Well, a LUT is difficult to beat ;-)

habran

  • Member
  • *****
  • Posts: 1228
    • uasm
Re: C/C++ vs Assembler
« Reply #62 on: May 07, 2013, 05:43:20 AM »
 :t
Code: [Select]
Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz (SSE4)



7       cycles for Fast version
8       cycles for Fast version under AMD
16      cycles for Small 1
18      cycles for Small 2
19      cycles for Small 3
19      cycles for Small 3.1
19      cycles for Small 4
4       cycles for MMX 1
5       cycles for MMX 2
4       cycles for SSE1

Other's Versions:
23      cycles for Axhex2dw improved by Hutch (1)
22      cycles for Axhex2dw improved by Hutch (2)

3       cycles for Lingo's SSE version
7       cycles for Lingo's BIG integer version
21      cycles for Jochen's WORD-Indexed version
12      cycles for Dave's version (with minor changes)


11      cycles for Fast version
14      cycles for Fast version under AMD
17      cycles for Small 1
19      cycles for Small 2
18      cycles for Small 3
19      cycles for Small 3.1
18      cycles for Small 4
5       cycles for MMX 1
4       cycles for MMX 2
4       cycles for SSE1

Other's Versions:
22      cycles for Axhex2dw improved by Hutch (1)
21      cycles for Axhex2dw improved by Hutch (2)

2       cycles for Lingo's SSE version
7       cycles for Lingo's BIG integer version
5       cycles for Jochen's WORD-Indexed version
12      cycles for Dave's version (with minor changes)


10      cycles for Fast version
13      cycles for Fast version under AMD
17      cycles for Small 1
17      cycles for Small 2
18      cycles for Small 3
19      cycles for Small 3.1
19      cycles for Small 4
5       cycles for MMX 1
6       cycles for MMX 2
5       cycles for SSE1

Other's Versions:
23      cycles for Axhex2dw improved by Hutch (1)
22      cycles for Axhex2dw improved by Hutch (2)

4       cycles for Lingo's SSE version
7       cycles for Lingo's BIG integer version
6       cycles for Jochen's WORD-Indexed version
11      cycles for Dave's version (with minor changes)

==========
Codesizes:
Axhex2dw_Unrolled:      396
Axhex2dw_Unrolled_AMD:  396
Axhex2dw1 - 1:  69
Axhex2dw2 - 2:  48
Axhex2dw3 - 3:  57
Axhex2dw3_1 - 3.1:      56
Axhex2dw3 - 4:  61
Axhex2dw_MMX:   128
Axhex2dw_MMX2:  160
Axhex2dw_SSE:   160
Alex_Short_Hutch:       59
Axhex2dw_Hutch2:        54
Hex2dwLingoSSE: 160
lingo_htodw:    1950
ax_jj_htodw:    174
krbhtodw:       547
--- ok ---
Cod-Father

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: C/C++ vs Assembler
« Reply #63 on: May 07, 2013, 06:25:14 AM »
Jochen,

Well, a LUT is difficult to beat ;-)

that's true, but an old wisdom.

Gunther
You have to know the facts before you can distort them.

Antariy

  • Member
  • ****
  • Posts: 564
Re: C/C++ vs Assembler
« Reply #64 on: May 07, 2013, 08:43:59 AM »
OK - I obviously missed the "spirit" of this thread...

No, it's OK, your code is good - fast and well readable, really :t Thanks for posting it :biggrin: It was informational test, too, now in this strange thread (@Dave - :biggrin:) we do have rolled and unrolled C (and you have provided both) and ASM versions of the code, mixed in a crazy testbeds :biggrin:

Antariy

  • Member
  • ****
  • Posts: 564
Re: C/C++ vs Assembler
« Reply #65 on: May 07, 2013, 09:15:23 AM »
:t

Thank you, habran :t

If your OS is 32 bit, then it really seems as a best idea to run 32 bit proggies under 32 bit OS :biggrin:

habran

  • Member
  • *****
  • Posts: 1228
    • uasm
Re: C/C++ vs Assembler
« Reply #66 on: May 07, 2013, 12:19:15 PM »
It is 64 bit Win 7 :biggrin:
IMO there is no penalty for running 32 on 64 but 64 is certainly faster because of 64 bit programing :t
Cod-Father

Antariy

  • Member
  • ****
  • Posts: 564
Re: C/C++ vs Assembler
« Reply #67 on: May 07, 2013, 01:02:50 PM »
That was my assumption just because your timing results seem to be smaller than other's with the same CPU :biggrin:

habran

  • Member
  • *****
  • Posts: 1228
    • uasm
Re: C/C++ vs Assembler
« Reply #68 on: May 07, 2013, 02:18:51 PM »
It is Toshiba Qosmio 16 gig ram laptop with 2.3 gig i7 and 64 bit Windows 7 Home with AVX :t
I think that qWord has got the same one
It is a great toy :bgrin:
Cod-Father

Antariy

  • Member
  • ****
  • Posts: 564
Re: C/C++ vs Assembler
« Reply #69 on: May 07, 2013, 02:43:12 PM »

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: C/C++ vs Assembler
« Reply #70 on: May 07, 2013, 10:46:22 PM »
Hi habran,

It is Toshiba Qosmio 16 gig ram laptop with 2.3 gig i7 and 64 bit Windows 7 Home with AVX :t
I think that qWord has got the same one
It is a great toy :bgrin:

it's probably the Ivy Bridge, isn't it?

Gunther
You have to know the facts before you can distort them.

habran

  • Member
  • *****
  • Posts: 1228
    • uasm
Re: C/C++ vs Assembler
« Reply #71 on: May 07, 2013, 11:20:17 PM »
Yes Gunther, the Ivy Bridge it is :biggrin:
Quote
I already posted this before
here are specifications:                 
                                         
Intel® Core™ i7-3610QM Processor         
(6M Cache, up to 3.30 GHz)               
Specifications                           
Essentials                               
Status   Launched                         
Launch Date   Q2'12                       
Processor Number   i7-3610QM             
# of Cores   4                           
# of Threads   8                         
Clock Speed   2.3 GHz                     
Max Turbo Frequency   3.3 GHz             
Intel® Smart Cache   6 MB                 
Bus/Core Ratio   23                       
DMI   5 GT/s                             
Instruction Set   64-bit                 
Instruction Set Extensions   AVX         
Embedded Options Available   No           
Lithography   22 nm                       
Max TDP   45 W                           
Recommended Customer Price   TRAY: $378.00
Cod-Father

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: C/C++ vs Assembler
« Reply #72 on: May 08, 2013, 07:20:53 AM »
Hi habran,

Quote
I already posted this before
here are specifications:                 
                                         
Intel® Core™ i7-3610QM Processor         
(6M Cache, up to 3.30 GHz)               
Specifications                           
Essentials                               
Status   Launched                         
Launch Date   Q2'12                       
Processor Number   i7-3610QM             
# of Cores   4                           
# of Threads   8                         
Clock Speed   2.3 GHz                     
Max Turbo Frequency   3.3 GHz             
Intel® Smart Cache   6 MB                 
Bus/Core Ratio   23                       
DMI   5 GT/s                             
Instruction Set   64-bit                 
Instruction Set Extensions   AVX         
Embedded Options Available   No           
Lithography   22 nm                       
Max TDP   45 W                           
Recommended Customer Price   TRAY: $378.00

an excellent machine. Runs Windows 64 as the only OS? How did you manage the new "BIOS"?

Gunther
You have to know the facts before you can distort them.

habran

  • Member
  • *****
  • Posts: 1228
    • uasm
Re: C/C++ vs Assembler
« Reply #73 on: May 08, 2013, 08:44:43 AM »
Thanks Gunther
I did not have to touch anything
I just installed my tools and copyed my projects  :biggrin:
Cod-Father

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: C/C++ vs Assembler
« Reply #74 on: May 09, 2013, 02:42:42 AM »
Hi habran,

I did not have to touch anything
I just installed my tools and copyed my projects  :biggrin:

so, do you have an EFI drive, too? Or is your hard disk not over 2.2 GB size?

Gunther
You have to know the facts before you can distort them.