SimpleScalar 설치 및 사용법 순천향대학교 정보기술공학부 이상정
SimpleScalar 설치 설치 내용 simulator 3.0 : 시뮬레이터 gcc-2.6.3 : C 컴파일러 gnu binutils-2.5.2 : GNU utilities 순천향대학교 정보기술공학부 이 상 정 2
simulator 3.0 설치 cd /edu gzip -d simplesim3.0b.tar.gz tar -xvf simplesim3.0b.tar make config-pisa pisa => Portable ISA make cd /edu/simplesim-3.0 ./sim-safe 순천향대학교 정보기술공학부 이 상 정 3
gnu binutils-2.5.2 설치 cd /edu tar -zxvf simpleutils.tar.gz cd binutils-2.5.2 ./configure -host=i386-*-gnu/linux -target=sslittle-na-sstrix -with-gnu-as -with-gnu-ld -prefix=/edu make make install 순천향대학교 정보기술공학부 이 상 정 4
gcc-2.6.3 설치 cd /edu tar -zxvf simpletools.tar,gz cd gcc-2.6.3 ./configure -host=i586-*-gnu/linux -target=sslittle-na-sstrix -with-gnu-as -with-gnu-ld -prefix=/edu make install => error cd /edu/gcc-2.6.3/bin ./sslittle-na-sstrix-gcc -o test.ss test.c ./sslittle-na-sstrix-gcc -S test.c => test.s /edu/simplesim-3.0/sim-safe test.ss 순천향대학교 정보기술공학부 이 상 정 5
gcc-2.6.3 설치 에러내용 예 gcc-2.6.3/cccp.c: line 191 : declaration of sys_errlist not correct -> #if changed to: #if …. || defined (__linux__) gcc-2.6.3/sdbout.c: line 58 : no syms.h -> use gsysms.h gcc-2.6.3/gcc.c : line 172 : sys_errlist : conflicting types, cft. cccp.c -> #if changed to: #if … || defined (__linux__) gcc-2.6.3/cp/g++.c line 88: sys_errlist, I -> #if changed to: #if …. || defined (__linux__) 순천향대학교 정보기술공학부 이 상 정 6
예제 프로그램 test.c #include <stdio.h> int a=3, b; main() { int x,y; x = a; y = 4; b = x + y; printf("%d\n", b); } 순천향대학교 정보기술공학부 이 상 정 7
컴파일 예 ./sslittle-na-sstrix-gcc -o test.ss test.c ./sslittle-na-sstrix-gcc -S test.c test.s .file "test.c" gcc2_compiled.: __gnu_compiled_c: .globl a .sdata .align 2 # 22 = 4 a: # a = 3 .word 3 .align 2 순천향대학교 정보기술공학부 이 상 정 8
컴파일 예 $LC0: .ascii "%d\n\000" .text .align 2 .globl main .comm b,4 # b .loc 1 4 .ent main main: .frame $fp,32,$31 # frame register(r30),frame size,return register .mask 0xc0000000,-4 # bitmask for register save .fmask 0x00000000,0 # bitmask for fp register save 순천향대학교 정보기술공학부 이 상 정 9
컴파일 예 subu $sp,$sp,32 # $sp(r29), stack push for next frame sw $31,28($sp) # save return register sw $fp,24($sp) # save frame register move $fp,$sp # set current frame register jal __main lw $2,a # x = a; sw $2,16($fp) li $2,0x00000004 # y = 4 sw $2,20($fp) lw $2,16($fp) # b = x + y lw $3,20($fp) addu $2,$2,$3 sw $2,b la $4,$LC0 # printf(“%d\n”,b); lw $5,b jal printf 순천향대학교 정보기술공학부 이 상 정 10
컴파일 예 Gas 매뉴얼 http://www.gnu.org/manual/gas-2.9.1/as.html $L1: move $sp,$fp lw $31,28($sp) # restore return address lw $fp,24($sp) # restore frame register addu $sp,$sp,32 # stack pop j $31 # return .end main Gas 매뉴얼 http://www.gnu.org/manual/gas-2.9.1/as.html 순천향대학교 정보기술공학부 이 상 정 11
sim-safe 수행 예 /edu/simplesim-3.0/sim-safe test.ss sim-safe: SimpleScalar/PISA Tool Set version 3.0 of November, 2000. Copyright (c) 1994-2000 by Todd M. Austin. All Rights Reserved. ………………. # -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 1 # 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 0 # simulator scheduling priority -max:inst 0 # maximum number of inst's to execute sim: ** starting functional simulation ** 7 순천향대학교 정보기술공학부 이 상 정 12
sim-safe 수행 예 sim: ** simulation statistics ** sim_num_insn 6827 # total number of instructions executed sim_num_refs 3871 # total number of loads and stores executed sim_elapsed_time 1 # total simulation time in seconds sim_inst_rate 6827.0000 # simulation speed (in insts/sec) ld_text_base 0x00400000 # program text (code) segment base ld_text_size 70176 # program text (code) size in bytes ld_data_base 0x10000000 # program initialized data segment base ld_data_size 8192 # program init'ed `.data' and uninit'ed `.bss' size in bytes ld_stack_base 0x7fffc000 # program stack segment base (highest address in stack) ld_stack_size 16384 # program initial stack size ld_prog_entry 0x00400140 # program entry point (initial PC) ld_environ_base 0x7fff8000 # program environment base address address ld_target_big_endian 0 # target executable endian-ness, non-zero if big endian mem.page_count 26 # total number of pages allocated mem.page_mem 104k # total size of memory pages allocated mem.ptab_misses 26 # total first level page table misses mem.ptab_accesses 469920 # total page table accesses mem.ptab_miss_rate 0.0001 # first level page table miss rate 순천향대학교 정보기술공학부 이 상 정 13
sim-outorder 수행 예 /edu/simplesim-3.0/sim-outorder test.ss sim-outorder: SimpleScalar/PISA Tool Set version 3.0 of November, 2000. ………. # -ptrace <null> # generate pipetrace, i.e., <fname|stdout|stderr> <range> -fetch:ifqsize 4 # instruction fetch queue size (in insts) ………… -bpred bimod # branch predictor type {nottaken|taken|perfect|bimod|2lev|comb} -bpred:bimod 2048 # bimodal predictor config (<table size>) ………………. -decode:width 4 # instruction decode B/W (insts/cycle) -issue:width 4 # instruction issue B/W (insts/cycle) ……….. -ruu:size 16 # register update unit (RUU) size -lsq:size 8 # load/store queue (LSQ) size -cache:dl1 dl1:128:32:4:l # l1 data cache config, i.e., {<config>|none} -cache:dl1lat 1 # l1 data cache hit latency (in cycles) ……………….. sim: ** starting performance simulation ** 7 순천향대학교 정보기술공학부 이 상 정 14
sim-outorder 수행 예 sim: ** simulation statistics ** sim_num_insn 6827 # total number of instructions committed sim_num_refs 3871 # total number of loads and stores committed ………………… sim_total_insn 7574 # total number of instructions executed sim_total_refs 4032 # total number of loads and stores executed …………………. sim_cycle 13659 # total simulation time in cycles sim_IPC 0.4998 # instructions per cycle sim_CPI 2.0007 # cycles per instruction …………. bpred_bimod.bpred_dir_rate 0.8403 # branch direction-prediction rate (i.e., all-hits/updates) ………….. il1.miss_rate 0.0680 # miss rate (i.e., misses/ref) ………. dl1.miss_rate 0.1111 # miss rate (i.e., misses/ref) ……………….. ul2.miss_rate 0.5077 # miss rate (i.e., misses/ref) ld_text_base 0x00400000 # program text (code) segment base …………………….. 순천향대학교 정보기술공학부 이 상 정 15
Dlite! 디버거 사용 예 $ /edu/simplesim-3.0/sim-safe -i test.ss sim: ** starting functional simulation ** …….. [ 0] 0x00400140: lw r16,0(r29) DLite! > dis main 0x004001f0: addiu r29,r29,-32 # stack push 0x004001f8: sw r31,28(r29) # return register save 0x00400200: sw r30,24(r29) # frame register save 0x00400208: addu r30,r0,r29 # $fp = $sp 0x00400210: jal 0x400448 # jal __main 0x00400218: lw r2,-32768(r28) # x = a; 0x00400220: sw r2,16(r30) 0x00400228: addiu r2,r0,4 # y = 4; 0x00400230: sw r2,20(r30) 0x00400238: lw r2,16(r30) # b = x + y; 0x00400240: lw r3,20(r30) 순천향대학교 정보기술공학부 이 상 정 16
Dlite! 디버거 사용 예 0x00400248: addu r2,r2,r3 0x00400250: sw r2,-32416(r28) 0x00400258: addiu r4,r28,-32764 # printf() 0x00400260: lw r5,-32416(r28) 0x00400268: jal 0x400670 DLite! > break 0x400218 breakpoint #1 set @ @0x00400218:@0x00400219, class: exec DLite! > cont Stopping at code breakpoint #1 @ 0x00400218... [ 181] 0x00400218: lw r2,-32768(r28) DLite! > iregs PC: 0x00400490 NPC: 0x00400218 HI: 0x00000000 LO: 0x00000000 FCC: 0x00000000 순천향대학교 정보기술공학부 이 상 정 17
Dlite! 디버거 사용 예 $r0: 0/0x00000000 $r1: 0/0x00000000 $r4: 268440008/0x100011c8 $r5: 2147450884/0x7fff8004 ………… DLite! > step [ 182] 0x00400220: sw r2,16(r30) DLite! > iregs $r2: 3/0x00000003 $r3: 2/0x00000002 ……………… DLite! > break 0x400248 breakpoint #2 set @ @0x00400248:@0x00400249, class: exec 순천향대학교 정보기술공학부 이 상 정 18
Dlite! 디버거 사용 예 DLite! > cont Stopping at code breakpoint #3 @ 0x00400248... [ 187] 0x00400248: addu r2,r2,r3 DLite! > step [ 188] 0x00400250: sw r2,-32416(r28) DLite! > iregs PC: 0x00400248 NPC: 0x00400250 HI: 0x00000000 LO: 0x00000000 FCC: 0x00000000 $r0: 0/0x00000000 $r1: 0/0x00000000 $r2: 7/0x00000007 $r3: 4/0x00000004 $r4: 268440008/0x100011c8 $r5: 2147450884/0x7fff8004 $r6: 2147450892/0x7fff800c $r7: 268440000/0x100011c0 순천향대학교 정보기술공학부 이 상 정 19
Dlite! 디버거 사용 예 …………… $r28: 268473664/0x10009540 $r29: 2147450824/0x7fff7fc8 ……………. DLite! > step [ 189] 0x00400258: addiu r4,r28,-32764 DLite! > dump $r28-32416 0x100016a0: 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [................] 0x100016b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [................] 0x100016c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [................] 0x100016d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [................] DLite! > cont 7 순천향대학교 정보기술공학부 이 상 정 20
Dlite! 디버거 사용 예 sim: ** simulation statistics ** sim_num_insn 7300 # total number of instructions executed sim_num_refs 4060 # total number of loads and stores executed sim_elapsed_time 329 # total simulation time in seconds sim_inst_rate 22.1884 # simulation speed (in insts/sec) $ 순천향대학교 정보기술공학부 이 상 정 21
과제 간단한 테스트 C 프로그램을 작성하여 컴파일하여 어셈블리 언어를 생성하고 Dlite! 디버거를 사용하여 실행하여라. 발표자료 파워포인트 작성 제출 순천향대학교 정보기술공학부 이 상 정 22