Author Topic: Instruction Timing  (Read 839 times)

jj2007

  • Member
  • *****
  • Posts: 11783
  • Assembler is fun ;-)
    • MasmBasic
Re: Instruction Timing
« Reply #15 on: November 24, 2021, 01:31:55 AM »
AMD Ryzen 5 3400G

As already seen in the other thread, AMD sucks for lodsb :cool:

594 ticks for movzx+inc
1515 ticks for lodsb

TimoVJL

  • Member
  • ****
  • Posts: 838
Re: Instruction Timing
« Reply #16 on: November 24, 2021, 01:48:12 AM »
Mine is old Zen 2 gen, 12 nm, with integral graphics.
We still wait Zen 3 gen results.
May the source be with you

Greenhorn

  • Member
  • **
  • Posts: 204
Re: Instruction Timing
« Reply #17 on: November 24, 2021, 11:39:01 AM »
Ryzen 5 3400G is Zen+.

Attached is Zen 2 (AMD Ryzen 7 3700X)

TimoVJL

  • Member
  • ****
  • Posts: 838
Re: Instruction Timing
« Reply #18 on: November 24, 2021, 05:10:16 PM »
Thanks.
Ryzen 5 3400G is Zen+.
Yes, Zen+ based (2nd generation)

Code: [Select]
Instr. Operands Bytes Intel Intel AMD AMD
--------- ----------------- ------ ------ ------ ------
lodsb 1 4 5 4 12 6
lodsw 2 4 5 4 12 6
lodsd 1 4 5 3 12 12
...
xchg reg64,mem64 6 77 83 75 119 68
xchg mem64,reg64 6 77 83 75 119 68
May the source be with you

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8755
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Instruction Timing
« Reply #19 on: November 24, 2021, 05:54:03 PM »
Something missing in the ZIP file.

Intel(R) Core(TM) i7-5820K CPU @ 3.30GHz (AVX2)
------------------------------------------------
Instr.     Operands         Bytes  Clocks
------------------------------------------------
error reading: bin\mov_reg64_reg64.bin
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

TimoVJL

  • Member
  • ****
  • Posts: 838
Re: Instruction Timing
« Reply #20 on: November 24, 2021, 06:02:00 PM »
That test needs asmc64.exe too, in path or in same folder.
May the source be with you

Greenhorn

  • Member
  • **
  • Posts: 204
Re: Instruction Timing
« Reply #21 on: November 25, 2021, 04:24:05 AM »
Thanks.
Ryzen 5 3400G is Zen+.
Yes, Zen+ based (2nd generation)

Sorry, I missed the period after the "2". My eyes get bad.

nidud

  • Member
  • *****
  • Posts: 2311
    • https://github.com/nidud/asmc
Re: Instruction Timing
« Reply #22 on: November 25, 2021, 08:12:45 AM »
Here's a simplified version.

Instructions are now in a text file so you may add or subtract from the list without rebuilding the binary.
Instructions.txt:
; name op1 op2 op3 imm-value

adc reg64 reg64 0 0
adc reg64 mem64 0 0

The creation of .bin files is now in a batch file.
asmtobin.cmd:
@echo off
if [%1] == [] (
    echo Usage: asmtobin name
    exit
)
\asmc\bin\asmc64 -q -bin -Fo bin\\%1.bin asm\\%1.asm
REM \jwasm\jwasm -q -bin -Fo bin\\%1.bin asm\\%1.asm
REM \uasm\uasm64 -q -bin -Fo bin\\%1.bin asm\\%1.asm

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8755
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Instruction Timing
« Reply #23 on: November 25, 2021, 09:56:11 AM »
You guys worry me, a working executable file should be trivial to make.

Intel(R) Core(TM) i7-5820K CPU @ 3.30GHz (AVX2)
------------------------------------------------
Instr.     Operands         Bytes  Clocks
------------------------------------------------
The system cannot find the path specified.
error reading: bin\mov_reg64_reg64.bin

A:\InstructionTiming>
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

nidud

  • Member
  • *****
  • Posts: 2311
    • https://github.com/nidud/asmc
Re: Instruction Timing
« Reply #24 on: November 25, 2021, 10:30:18 AM »
 :biggrin:

The bin\mov_reg64_reg64.bin file is part of the executable so you have to build it to get it working.

The input to the program is source code.

.code
Instruction proc uses rsi rdi rbx
    mov rdi,rcx
    mov rsi,rdx
    for op1,<rcx,rdx,r8,r9,r10,r11,rax>
        for op2,<rbx,r12,r13,r14,r15,rcx,rdx,r8,r9,r10,r11,rax>
            mov op1,op2
        endm
    endm
    ret
Instruction endp
end

This is assembled to mov_reg64_reg64.bin and loaded into the code segment and executed so you need an assembler.

nidud

  • Member
  • *****
  • Posts: 2311
    • https://github.com/nidud/asmc
Re: Instruction Timing
« Reply #25 on: November 25, 2021, 11:10:38 AM »
However, it's not a test bonanza as the result is already in the first post. The code is the same so the result will be similar for the same architecture regardless of speed/size of the CPU. You will see some improvements for CMPS/MOVS/SCAS and other instructions in newer hardware, both for Intel and AMD.

What the result basically shows is the difference between fast and slow instructions, or more correctly: the difference between MOV REG,REG and other instructions.

TimoVJL

  • Member
  • ****
  • Posts: 838
Re: Instruction Timing
« Reply #26 on: November 25, 2021, 05:24:22 PM »
@hutch--
Pre-created binaries with empty asmc64.cmd.
Perhaps now you can have results for excel table.
May the source be with you

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8755
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Instruction Timing
« Reply #27 on: November 25, 2021, 06:33:07 PM »
Hi Timo,

I downloaded the Excel reader you posted, had a look at the table but deleted it after as it was squarking crap with a nag screen. At least I understood what the data was and the CPU comparisons it contained.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

TimoVJL

  • Member
  • ****
  • Posts: 838
Re: Instruction Timing
« Reply #28 on: November 25, 2021, 06:55:26 PM »
Ok,
Attached results in tabular format and tiny viewer for it.
May the source be with you

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8755
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Instruction Timing
« Reply #29 on: November 25, 2021, 07:38:30 PM »
Thanks,

That worked OK.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: