Presentation is loading. Please wait.

Presentation is loading. Please wait.

Simple Scalar 설치 및 사용법 일반대학원 전산학과 강서일 (2003 ) 손재락 (20047046)

Similar presentations


Presentation on theme: "Simple Scalar 설치 및 사용법 일반대학원 전산학과 강서일 (2003 ) 손재락 (20047046)"— Presentation transcript:

1 Simple Scalar 설치 및 사용법 일반대학원 전산학과 강서일 ( ) 손재락 ( )

2 구현 환경 CPU : P-Ⅲ 866Mhz Memory : 256㎆ OS : Red Hat Linux 7.3
$DIR : /edu

3 설치 내용 시뮬레이터 : simplesim-3v0d GNU utilities : gnu binutils-2.5.2
C 컴파일러 : gcc-2.6.3

4 예제프로그램 fibo.c #include <stdio.h> #include <time.h>
void fib2(int n); void input(); void main() { clock_t a,b; a = clock(); input(); b = clock(); printf("수행시간 = %f \n",(double)(b-a)/CLK_TCK); }

5 예제프로그램 void input() { int n; printf("몇번째 피보나찌 수열을 구하시겠습니까? : ");
scanf("%d",&n); if(n<0) printf("ERROR : 0보다 큰정수를 입력해주세요..."); printf("\n몇번째 피보나찌 수열을 구하시겠습니까? : "); } fib2(n);

6 예제프로그램 void fib2(int n) { long f[1000]; f[0] = 0; if(n > 0)
for(int i = 2; i<=n; i++) f[i] = f[i-1] + f[i-2]; } printf("%d\n",f[n]);

7 컴파일 예 sslittle-na-sstrix-gcc –o fibo.ss fibo.c
sslittle-na-sstrix-gcc –S fibo.c cat fibo.s .file 1 "fibo.c" # GNU C [AL 1.1, MM 40, tma 0.1] SimpleScalar running sstrix compiled by GNU C # Cc1 defaults: # -mgas -mgpOPT # Cc1 arguments (-G value = 8, Cpu = default, ISA = 1): # -quiet -dumpbase -o

8 컴파일 예 gcc2_compiled.: __gnu_compiled_c: .rdata .align 2 $LC0:
.ascii "\274\366\307\340\275\303\260\243 = %f \n\000" .sdata .align 3 $LC1: .word 0x # 60 .word 0x404e0000 .text .globl main .end fib2

9 컴파일 예 $LC2: .ascii "\270\356\271\370\302\260 \307\307\272\270\263\252\302\356" .ascii " \274\366\277\255\300\273 \261\270\307\317\275\303\260\332" .ascii "\275\300\264\317\261\356? : \000" .sdata .align 2 $LC3: .ascii "%d\000" .rdata $LC4: .ascii "ERROR : 0\272\270\264\331 \305\253\301\244\274\366\270\246" .ascii " \300\324\267\302\307\330\301\326\274\274\277\344...\000" $LC5: .ascii "\n\270\356\271\370\302\260 \307\307\272\270\263\252\302\356"

10 컴파일 예 .text .align 2 .globl input .sdata $LC6: .ascii "%d\n\000"
.globl fib2 .comm i,4 .loc 1 10 .ent main

11 컴파일 예 main: .frame $fp,32,$31 # vars= 8, regs= 2/0, args= 16, extra= 0
.mask 0xc ,-4 .fmask 0x ,0 subu $sp,$sp,32 sw $31,28($sp) sw $fp,24($sp) move $fp,$sp jal __main jal clock sw $2,16($fp) jal input sw $2,20($fp) lw $2,20($fp) lw $3,16($fp) subu $2,$2,$3 mtc1 $2,$f0 #nop

12 컴파일 예 cvt.d.w $f0,$f0 l.d $f2,$LC1 div.d $f0,$f0,$f2 la $4,$LC0
dmfc1 $6,$f0 jal printf $L1: move $sp,$fp # sp not trusted here lw $31,28($sp) lw $fp,24($sp) addu $sp,$sp,32 j $31 .end main .loc 1 20 .ent input input: .frame $fp,32,$31 # vars= 8, regs= 2/0, args= 16, extra= 0

13 컴파일 예 .mask 0xc0000000,-4 .fmask 0x00000000,0 subu $sp,$sp,32
sw $31,28($sp) sw $fp,24($sp) move $fp,$sp la $4,$LC2 jal printf la $4,$LC3 addu $5,$fp,16 jal scanf lw $2,16($fp) bgez $2,$L3 la $4,$LC4 la $4,$LC5

14 컴파일 예 $L3: lw $4,16($fp) jal fib2 $L2:
move $sp,$fp # sp not trusted here lw $31,28($sp) lw $fp,24($sp) addu $sp,$sp,32 j $31 .end input .loc 1 34 .ent fib2 fib2: .frame $fp,4024,$31 # vars= 4000, regs= 2/0, args= 16, extra= 0 .mask 0xc ,-4 .fmask 0x ,0 subu $sp,$sp,4024

15 컴파일 예 sw $31,4020($sp) sw $fp,4016($sp) move $fp,$sp sw $4,4024($fp)
lw $2,4024($fp) blez $2,$L5 li $2,0x # 1 sw $2,20($fp) li $2,0x # 2 sw $2,i $L6: lw $2,i lw $3,4024($fp) slt $2,$3,$2 beq $2,$0,$L9 j $L7 $L9:

16 컴파일 예 move $3,$2 sll $2,$3,2 addu $4,$fp,16 addu $3,$2,$4 move $2,$3
lw $3,i move $4,$3 sll $3,$4,2 addu $3,$3,$4 subu $4,$3,4 move $3,$4 lw $4,i move $5,$4 sll $4,$5,2 addu $5,$fp,16 addu $4,$4,$5 subu $5,$4,8 move $4,$5

17 컴파일 예 lw $3,0($3) lw $4,0($4) addu $3,$3,$4 sw $3,0($2) $L8: lw $3,i
move $3,$2 sw $3,i j $L6 $L7: $L5: lw $2,4024($fp) sll $2,$3,2 addu $3,$fp,16 addu $2,$2,$3 la $4,$LC6

18 컴파일 예 lw $5,0($3) jal printf $L4: move $sp,$fp # sp not trusted here
lw $31,4020($sp) lw $fp,4016($sp) addu $sp,$sp,4024 j $31 .end fib2

19 sim-safe 수행 예 /edu/simplesim-3.0/sim-safe fibo.ss > fibo2.txt
sim-safe: SimpleScalar/PISA Tool Set version 3.0 of August, 2003. Copyright (c) by Todd M. Austin, Ph.D. and SimpleScalar, LLC. All Rights Reserved. This version of SimpleScalar is licensed for academic non-commercial use. No portion of this work may be used by any commercial entity, or for any commercial purpose, without the prior written permission of SimpleScalar, LLC sim: command line: ./sim-safe ../bin/fibo.ss sim: simulation Mon Apr 26 22:45: , options follow: sim-safe: This simulator implements a functional simulator. This functional simulator is the simplest, most user-friendly simulator in the simplescalar tool set. Unlike sim-fast, this functional simulator checks for all instruction errors, and the implementation is crafted for clarity rather than speed.

20 sim-safe 수행 예 # -config # load configuration from a file
# -dumpconfig # dump configuration to a file # -h false # print help message # -v false # verbose operation # -d false # enable debug message # -i false # start in Dlite debugger -seed # random number generator seed (0 for timer seed) # -q false # initialize and terminate immediately # -chkpt <null> # restore EIO trace execution from <fname> # -redir:sim <null> # redirect simulator output to file (non-interactive only) # -redir:prog <null> # redirect simulated program output to file -nice # simulator scheduling priority -max:inst # maximum number of inst's to execute sim: ** starting functional simulation ** 몇번째 피보나찌 수열을 구하시겠습니까? : 55 수행시간 =

21 sim-safe 수행 예 sim: ** simulation statistics **
sim_num_insn # total number of instructions executed sim_num_refs # total number of loads and stores executed sim_elapsed_time # total simulation time in seconds sim_inst_rate # simulation speed (in insts/sec) ld_text_base x # program text (code) segment base ld_text_size # program text (code) size in bytes ld_data_base x # program initialized data segment base ld_data_size # program init'ed `.data' and uninit'ed `.bss' size in bytes ld_stack_base x7fffc000 # program stack segment base (highest address in stack) ld_stack_size # program initial stack size ld_prog_entry x # program entry point (initial PC) ld_environ_base x7fff8000 # program environment base address address ld_target_big_endian # target executable endian-ness, non-zero if big endian

22 sim-safe 수행 예 mem.page_count 35 # total number of pages allocated
mem.page_mem k # total size of memory pages allocated mem.ptab_misses # total first level page table misses mem.ptab_accesses # total page table accesses mem.ptab_miss_rate # first level page table miss rate

23 Dlite! 디버거 사용 예 simplesim-3.0]$ ./sim-safe -i ../bin/fibo.ss sim-safe: SimpleScalar/PISA Tool Set version 3.0 of August, 2003. Copyright (c) by Todd M. Austin, Ph.D. and SimpleScalar, LLC. All Rights Reserved. This version of SimpleScalar is licensed for academic non-commercial use. No portion of this work may be used by any commercial entity, or for any commercial purpose, without the prior written permission of SimpleScalar, LLC sim: command line: ./sim-safe -i ../bin/fibo.ss sim: simulation Mon Apr 26 23:04: , options follow: sim-safe: This simulator implements a functional simulator. This functional simulator is the simplest, most user-friendly simulator in the simplescalar tool set. Unlike sim-fast, this functional simulator checks for all instruction errors, and the implementation is crafted for clarity rather than speed.

24 Dlite! 디버거 사용 예 # -config # load configuration from a file
# -dumpconfig # dump configuration to a file # -h false # print help message # -v false # verbose operation # -d false # enable debug message # -i true # start in Dlite debugger -seed # random number generator seed (0 for timer seed) # -q false # initialize and terminate immediately # -chkpt <null> # restore EIO trace execution from <fname> # -redir:sim <null> # redirect simulator output to file (non-interacti ve only) # -redir:prog <null> # redirect simulated program output to file -nice # simulator scheduling priority -max:inst # maximum number of inst's to execute sim: ** starting functional simulation ** [ ] 0x : lw r16,0(r29)

25 Dlite! 디버거 사용 예 DLite! > dis main 0x004001f0: addiu r29,r29,-32
0x004001f8: sw r31,28(r29) 0x : sw r30,24(r29) 0x : addu r30,r0,r29 0x : jal x400728 0x : jal x400950 0x : sw r2,16(r30) 0x : jal x4002c0 0x : jal x400950 0x : sw r2,20(r30) 0x : lw r2,20(r30) 0x : lw r3,16(r30) 0x : subu r2,r2,r3 0x : mtc r2,f0 0x : cvt.d.w f0,f0 0x : l.d f2,-32768(r28)

26 Dlite! 디버거 사용 예 DLite! > dis fib2 0x004003a0: addiu r29,r29,-4024
0x004003a8: sw r31,4020(r29) 0x004003b0: sw r30,4016(r29) 0x004003b8: addu r30,r0,r29 0x004003c0: sw r4,4024(r30) 0x004003c8: sw r0,16(r30) 0x004003d0: lw r2,4024(r30) 0x004003d8: blez r2,0x400510 0x004003e0: addiu r2,r0,1 0x004003e8: sw r2,20(r30) 0x004003f0: addiu r2,r0,2 0x004003f8: sw r2,-31744(r28) 0x : lw r2,-31744(r28) 0x : lw r3,4024(r30) 0x : slt r2,r3,r2 0x : beq r2,r0,0x400428

27 Dlite! 디버거 사용 예 DLite! > break 0x004^H^[[3~
Dlite: error: too many arguments DLite! > break 0x breakpoint #1 class: exec DLite! > cont 몇번째 피보나찌 수열을 구하시겠습니까? : 10 55 Stopping at code breakpoint 0x [ ] 0x : lw r2,20(r30)

28 Dlite! 디버거 사용 예 DLite! > iregs PC: 0x00400238 NPC: 0x00400240
HI: 0x LO: 0x00020d00 FCC: 0x $r0: /0x $r1: /0x a $r2: /0x00000bb8 $r3: /0x $r4: /0x $r5: /0x $r6: /0x $r7: /0x $r8: /0x $r9: /0x $r10: /0x $r11: /0x $r12: /0x $r13: /0x $r14: /0x $r15: /0x7fff6f2f $r16: /0x $r17: /0x7fff8004 $r18: /0x7fff800c $r19: /0x $r20: /0x $r21: /0x $r22: /0x $r23: /0x $r24: /0x $r25: /0x $r26: /0x $r27: /0x $r28: /0x1000a040 $r29: /0x7fff7fc8 $r30: /0x7fff7fc8 $r31: /0x

29 Dlite! 디버거 사용 예 DLite! > step [ 9373] 0x00400248: lw r3,16(r30)
[ ] 0x : subu r2,r2,r3 DLite! > iregs PC: 0x NPC: 0x HI: 0x LO: 0x00020d00 FCC: 0x $r0: /0x $r1: /0x a $r2: /0x00000bb8 $r3: /0x00000bb8 $r4: /0x $r5: /0x $r6: /0x $r7: /0x $r8: /0x $r9: /0x

30 Dlite! 디버거 사용 예 $r10: 0/0x00000000 $r11: 1342177280/0x50000000
$r14: /0x $r15: /0x7fff6f2f $r16: /0x $r17: /0x7fff8004 $r18: /0x7fff800c $r19: /0x $r20: /0x $r21: /0x $r22: /0x $r23: /0x $r24: /0x $r25: /0x $r26: /0x $r27: /0x $r28: /0x1000a040 $r29: /0x7fff7fc8 $r30: /0x7fff7fc8 $r31: /0x DLite! > dump $r 0x100021a0: f0 bf 0x100021b0: f0 3f 0x100021c0: f0 bf f8 ff [ ] 0x100021d0: 9c c e4 37 7e 59 f3 f8 c2 1f 6e a5 01 [.u..<.7~Y....n..]

31 Dlite! 디버거 사용 예 DLite! > cont 수행시간 = 0.000000
sim: ** simulation statistics ** sim_num_insn # total number of instructions executed sim_num_refs # total number of loads and stores executed sim_elapsed_time # total simulation time in seconds sim_inst_rate # simulation speed (in insts/sec) ld_text_base x # program text (code) segment base ld_text_size # program text (code) size in bytes ld_data_base x # program initialized data segment base ld_data_size # program init'ed `.data' and uninit'ed `.bs s' size in bytes ld_stack_base x7fffc000 # program stack segment base (highest addres s in stack) ld_stack_size # program initial stack size ld_prog_entry x # program entry point (initial PC)

32 Dlite! 디버거 사용 예 ld_environ_base x7fff8000 # program environment base address address ld_target_big_endian # target executable endian-ness, non-zero if big endian mem.page_count # total number of pages allocated mem.page_mem k # total size of memory pages allocated mem.ptab_misses # total first level page table misses mem.ptab_accesses # total page table accesses mem.ptab_miss_rate # first level page table miss rate simplesim-3.0]$


Download ppt "Simple Scalar 설치 및 사용법 일반대학원 전산학과 강서일 (2003 ) 손재락 (20047046)"

Similar presentations


Ads by Google