English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. C/C++ (https://eab.abime.net/forumdisplay.php?f=118)
-   -   cycle counting with vamos (https://eab.abime.net/showthread.php?t=114400)

bebbo 01 May 2023 11:17

cycle counting with vamos
 
Here is a simple bash script to get the cycle count for instructions in vamos:
Code:

#!/bin/bash
[ "$1" != "" ] && cpu=-C$1
case $1 in
  20)
        rts=10
  ;;
  *)
        rts=16
  ;;
esac
readarray -t f < asm
for i in "${!f[@]}"; do
  line="${f[$i]}"
  echo "  $line" >x.s
  echo "  rts" >>x.s
  /opt/amiga/bin/m68k-amigaos-gcc x.s -o x -nostdlib
  r=$(vamos -v $cpu x |& grep cycles)
  r=${r#*cycles:}
  r=$[r - $rts]
  echo "$line = $r"
done

now put the statments into the file `asm` and run the script. Sample `asm`file:
Code:

add.l  d0,d0
lsl.l  #2,d0
move.b  d0,(a0)
move.w  d0,(a0)
move.l  d0,(a0)
move.l  d0,(a0)+
move.l  d0,-(a0)
move.l  (a0)+,d0
move.l  -(a0),d0
move.l  d0,(2,a0)
move.l  d0,(2,a0,d0)
move.l  (a0),(a0)
move.l  (2,a0),(2,a0)
move.l  (2,a0,d0),(2,a0,d0)
move.l  0x10000,d0
move.l  d0,0x10000
mulu    #0x2,d0
mulu    #0x3,d0
mulu    #0x101,d0
muls    #0x5555,d0
lea (a5,a5.l),a1

and my output based on my vamos fork:
Code:

add.l  d0,d0 = 6
lsl.l  #2,d0 = 12
move.b  d0,(a0) = 8
move.w  d0,(a0) = 8
move.l  d0,(a0) = 12
move.l  d0,(a0)+ = 12
move.l  d0,-(a0) = 12
move.l  (a0)+,d0 = 12
move.l  -(a0),d0 = 14
move.l  d0,(2,a0) = 16
move.l  d0,(2,a0,d0) = 18
move.l  (a0),(a0) = 20
move.l  (2,a0),(2,a0) = 28
move.l  (2,a0,d0),(2,a0,d0) = 32
move.l  0x10000,d0 = 20
move.l  d0,0x10000 = 20
mulu    #0x2,d0 = 44
mulu    #0x3,d0 = 46
mulu    #0x101,d0 = 46
muls    #0x5555,d0 = 72
lea (a5,a5.l),a1 = 12


Karlos 01 May 2023 12:09

Interesting! Does it estimate best/worse cases for 68020+ or is it just for 68000 ?

bebbo 01 May 2023 13:34

I updated the script to support the parameter "20" for 68020. Output is then
Code:

add.l  d0,d0 = 2
lsl.l  #2,d0 = 4
move.b  d0,(a0) = 4
move.w  d0,(a0) = 4
move.l  d0,(a0) = 4
move.l  d0,(a0)+ = 4
move.l  d0,-(a0) = 5
move.l  (a0)+,d0 = 6
move.l  -(a0),d0 = 7
move.l  d0,(2,a0) = 5
move.l  d0,(2,a0,d0) = 7
move.l  (a0),(a0) = 8
move.l  (2,a0),(2,a0) = 10
move.l  (2,a0,d0),(2,a0,d0) = 14
move.l  0x10000,d0 = 6
move.l  d0,0x10000 = 6
mulu    #0x2,d0 = 29
mulu    #0x3,d0 = 29
mulu    #0x101,d0 = 29
muls    #0x5555,d0 = 29
lea (a5,a5.l),a1 = 9

(fixed lsl for 020 too)

Karlos 01 May 2023 14:03

So does it just count cycles for each instruction or does it also take into consideration pipelining across a sequence of instructions?

hooverphonique 01 May 2023 16:01

Quote:

Originally Posted by Karlos (Post 1613240)
So does it just count cycles for each instruction or does it also take into consideration pipelining across a sequence of instructions?

As far as I can see, the script invokes the compiler and vamos separately for each line/instruction in the "asm" file.


All times are GMT +2. The time now is 15:24.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.04213 seconds with 11 queries