Gem 5の基礎知識(1)
17272 ワード
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
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
--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
-s STANDARD_SWITCH, --standard-switch=STANDARD_SWITCH
switch from timing to Detailed CPU after warmup period
of
-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
int main(){
printf("hello world!
");
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です.