Gem5的基础知识(1)

1、通过下面的命令可以查看se模式和fs模式下的各种可用选项(se和fs的输出内容基本一致)

se:

./build/X86/gem5.opt ./configs/example/se.py -h

fs:

./build/X86/gem5.opt ./configs/example/fs.py -h

输出内容:

gem5 Simulator System.  http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.

gem5 compiled Mar  2 2016 15:22:55
gem5 started Jul 15 2016 10:09:52
gem5 executing on cyh-Lenovo
command line: ./build/X86/gem5.opt ./configs/example/se.py -h
Usage: se.py [options]

Options:
  -h, --help            show this help message and exit
  --list-cpu-types      List available CPU types
  --cpu-type=CPU_TYPE   type of cpu to run with
  --checker             
  -n NUM_CPUS, --num-cpus=NUM_CPUS
  --sys-voltage=SYS_VOLTAGE
                        Top-level voltage for blocks running at system
                        power supply
  --sys-clock=SYS_CLOCK
                        Top-level clock for blocks running at system
                        speed
  --cpu-clock=CPU_CLOCK
                        Clock for blocks running at CPU speed
  --smt                                        Only used if multiple programs
                        are specified. If true,                       then the
                        number of threads per cpu is same as the
                        number of programs.
  --list-mem-types      List available memory types
  --mem-type=MEM_TYPE   type of memory to use
  --mem-channels=MEM_CHANNELS
                        number of memory channels
  --mem-size=MEM_SIZE   Specify the physical memory size (single memory)
  --caches              
  --l2cache             
  --fastmem             
  --num-dirs=NUM_DIRS   
  --num-l2caches=NUM_L2CACHES
  --num-l3caches=NUM_L3CACHES
  --l1d_size=L1D_SIZE   
  --l1i_size=L1I_SIZE   
  --l2_size=L2_SIZE     
  --l3_size=L3_SIZE     
  --l1d_assoc=L1D_ASSOC
  --l1i_assoc=L1I_ASSOC
  --l2_assoc=L2_ASSOC   
  --l3_assoc=L3_ASSOC   
  --cacheline_size=CACHELINE_SIZE
  --ruby                
  -m TICKS, --abs-max-tick=TICKS
                        Run to absolute simulated tick specified including
                        ticks from a restored checkpoint
  --rel-max-tick=TICKS  Simulate for specified number of ticks relative to the
                        simulation start tick (e.g. if restoring a checkpoint)
  --maxtime=MAXTIME     Run to the specified absolute simulated time in
                        seconds
  -I MAXINSTS, --maxinsts=MAXINSTS
                        Total number of instructions to
                        simulate (default: run forever)
  --work-item-id=WORK_ITEM_ID
                        the specific work id for exit & checkpointing
  --work-begin-cpu-id-exit=WORK_BEGIN_CPU_ID_EXIT
                        exit when work starts on the specified cpu
  --work-end-exit-count=WORK_END_EXIT_COUNT
                        exit at specified work end count
  --work-begin-exit-count=WORK_BEGIN_EXIT_COUNT
                        exit at specified work begin count
  --init-param=INIT_PARAM
                        Parameter available in simulation with m5
                        initparam
  --simpoint-profile    Enable basic block profiling for SimPoints
  --simpoint-interval=SIMPOINT_INTERVAL
                        SimPoint interval in num of instructions
  --take-checkpoints=TAKE_CHECKPOINTS
                        <M,N> take checkpoints at tick M and every N ticks
                        thereafter
  --max-checkpoints=MAX_CHECKPOINTS
                        the maximum number of checkpoints to drop
  --checkpoint-dir=CHECKPOINT_DIR
                        Place all checkpoints in this absolute directory
  -r CHECKPOINT_RESTORE, --checkpoint-restore=CHECKPOINT_RESTORE
                        restore from checkpoint <N>
  --checkpoint-at-end   take a checkpoint at end of run
  --work-begin-checkpoint-count=WORK_BEGIN_CHECKPOINT_COUNT
                        checkpoint at specified work begin count
  --work-end-checkpoint-count=WORK_END_CHECKPOINT_COUNT
                        checkpoint at specified work end count
  --work-cpus-checkpoint-count=WORK_CPUS_CHECKPOINT_COUNT
                        checkpoint and exit when active cpu count is reached
  --restore-with-cpu=RESTORE_WITH_CPU
                        cpu type for restoring from a checkpoint
  --repeat-switch=REPEAT_SWITCH
                        switch back and forth between CPUs with period <N>
  -s STANDARD_SWITCH, --standard-switch=STANDARD_SWITCH
                        switch from timing to Detailed CPU after warmup period
                        of <N>
  -p PROG_INTERVAL, --prog-interval=PROG_INTERVAL
                        CPU Progress Interval
  -W WARMUP_INSTS, --warmup-insts=WARMUP_INSTS
                        Warmup period in total instructions (requires
                        --standard-switch)
  --bench=BENCH         base names for --take-checkpoint and --checkpoint-
                        restore
  -F FAST_FORWARD, --fast-forward=FAST_FORWARD
                        Number of instructions to fast forward before
                        switching
  -S, --simpoint        Use workload simpoints as an instruction offset for
                        --checkpoint-restore or --take-checkpoint.
  --at-instruction      Treat value of --checkpoint-restore or --take-
                        checkpoint as a                 number of
                        instructions.
  -c CMD, --cmd=CMD     The binary to run in syscall emulation mode.
  -o OPTIONS, --options=OPTIONS
                        The options to pass to the binary, use " "
                        around the entire string
  -i INPUT, --input=INPUT
                        Read stdin from a file.
  --output=OUTPUT       Redirect stdout to a file.
  --errout=ERROUT       Redirect stderr to a file.

2、在se模式下,执行自己写的程序

#include <stdio.h>

int main(){
    printf("hello world!\n");
    return 0;
}

编译:./build/X86/gem5.opt ./configs/example/se.py -c ./gem5_test/helloworld

注意:模拟器只能运行静态编译的程序,不能是动态编译,所以在编译的时候加上-static

运行helloworld

./build/X86/gem5.opt ./configs/example/se.py -c ./gem5_test/helloworld

输出结果:

Global frequency set at 1000000000000 ticks per second
0: system.remote_gdb.listener: listening for remote gdb #0 on port 7000
**** REAL SIMULATION ****
info: Entering event queue @ 0.  Starting simulation...
hello world!
hack: be nice to actually delete the event here
Exiting @ tick 5461500 because target called exit()

3、指定CPU的个数

 ./build/X86/gem5.opt ./configs/example/se.py --cmd=./gem5_test/fft --num-cpus=4

输出结果:

gem5 Simulator System.  http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.

gem5 compiled Mar  2 2016 15:22:55
gem5 started Jul 15 2016 15:23:34
gem5 executing on cyh-Lenovo
command line: ./build/X86/gem5.opt ./configs/example/se.py --cmd=./gem5_test/fft --num-cpus=4
Global frequency set at 1000000000000 ticks per second
0: system.remote_gdb.listener: listening for remote gdb #0 on port 7000
0: system.remote_gdb.listener: listening for remote gdb #1 on port 7001
0: system.remote_gdb.listener: listening for remote gdb #2 on port 7002
0: system.remote_gdb.listener: listening for remote gdb #3 on port 7003
**** REAL SIMULATION ****
info: Entering event queue @ 0.  Starting simulation...
fatal: syscall set_tid_address (#218) unimplemented.
 @ cycle 1085000
[unimplementedFunc:build/X86/sim/syscall_emul.cc, line 83]
Memory Usage: 636228 KBytes

注意:这里的fft是parsec benchmark中的一个benchmark。

  • 2
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值