LAB/GEM5

GEM5 Tutorial 5 - se.py 및 fs.py 구성

RyoTTa 2021. 3. 5. 18:44
반응형

Using se.py and fs.py

se.py와 fs.py에 대해 공통적인 옵션에 대해서만 설명한다. Full System에 대해서는 또다른 섹션이 존재해 나중에 추가 하도록 한다.

 

이번에 소개할 대부분의 옵션은 Options.py에서 확인할 수 있고 addCommonOptions 함수에 등록되어 있다.

 

build/X86/gem5.opt configs/example/se.py --cmd=tests/test-progs/hello/bin/x86/linux/hello

먼저 매개변수 없이 Hello World 프로그램을 실행한다.

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

gem5 version 20.1.0.4
gem5 compiled Mar  5 2021 06:11:38
gem5 started Mar  5 2021 06:32:58
gem5 executing on compasslab3, pid 7447
command line: ./build/X86/gem5.opt ./configs/example/se.py --cmd=tests/test-progs/hello/bin/x86/linux/hello
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address range assigned (512 Mbytes)
0: system.remote_gdb: listening for remote gdb on port 7000
**** REAL SIMULATION ****
info: Entering event queue @ 0.  Starting simulation...
Hello world!
Exiting @ tick 5943000 because exiting with last active thread context

 실행하면 위와같은 결과를 볼 수 있다.

 하지만 기본적으로 gem5는 atomic CPU 와 atomic memory access를 사용하기 때문에 real timing data를 출력해 주지 못한다. 

[system.cpu]
type=AtomicSimpleCPU
children=dtb interrupts isa itb power_state tracer workload
branchPred=Null
checker=Null
clk_domain=system.cpu_clk_domain
cpu_id=0
do_checkpoint_insts=true
do_statistics_insts=true

 m5out/config.ini 결과를 확인해보면 gem5가 atomicCPU를 사용함을 알 수 있다. 따라서 gem5를 Real Timing Mode로 실행하기 위해 CPU의 유형을 수정한다. 이러한 Parmeter들로 L1 Cache의 크기도 지정할 수있다.

build/X86/gem5.opt configs/example/se.py --cmd=tests/test-progs/hello/bin/x86/linux/hello --cpu-type=TimingSimpleCPU --l1d_size=64kB --l1i_size=16kB
gem5 Simulator System.  http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.

gem5 version 20.1.0.4
gem5 compiled Mar  5 2021 06:11:38
gem5 started Mar  5 2021 06:37:00
gem5 executing on compasslab3, pid 7457
command line: build/X86/gem5.opt configs/example/se.py --cmd=tests/test-progs/hello/bin/x86/linux/hello --cpu-type=TimingSimpleCPU --l1d_size=64kB --l1i_size=16kB
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address range assigned (512 Mbytes)
0: system.remote_gdb: listening for remote gdb on port 7000
**** REAL SIMULATION ****
info: Entering event queue @ 0.  Starting simulation...
Hello world!
Exiting @ tick 454646000 because exiting with last active thread context

 위의 명령어를 사용하여 CPU를 timing mode로 설정하고 L1 Cache의 크기를 설정한 후 결과값이다.

[system.cpu]
type=TimingSimpleCPU
children=dtb interrupts isa itb power_state tracer workload
branchPred=Null
checker=Null
clk_domain=system.cpu_clk_domain
cpu_id=0
do_checkpoint_insts=true
do_statistics_insts=true

 또한 이러한 Parameter 설정을 통해 시뮬레이션 시스템에 올바르게 전달되었는지 확인 할 수 있다.

 config.ini에서 cache를 검색하면 캐시가 생성되지 않았음을 알 수있다. 캐시 크기를 지정했지만 시스템에 캐시를 사용한다고 Parmeter를 지정하지 않았으므로 캐시가 생성되지 않았다.

build/X86/gem5.opt configs/example/se.py --cmd=tests/test-progs/hello/bin/x86/linux/hello --cpu-type=TimingSimpleCPU --l1d_size=64kB --l1i_size=16kB --caches

 따라서 위와같은 --caches Parameter를 추가하여 실행하면 Cache가 추가되어 시뮬레이션 시스템이 동작될 것이다.

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

gem5 version 20.1.0.4
gem5 compiled Mar  5 2021 06:11:38
gem5 started Mar  5 2021 06:41:07
gem5 executing on compasslab3, pid 7463
command line: build/X86/gem5.opt configs/example/se.py --cmd=tests/test-progs/hello/bin/x86/linux/hello --cpu-type=TimingSimpleCPU --l1d_size=64kB --l1i_size=16kB --caches
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address range assigned (512 Mbytes)
0: system.remote_gdb: listening for remote gdb on port 7000
**** REAL SIMULATION ****
info: Entering event queue @ 0.  Starting simulation...
Hello world!
Exiting @ tick 31680000 because exiting with last active thread context

 L1 Cache가 추가된 후의 결과이다. L1 Cache를 추가하지않은 상태 에서는 454646000 tick이 필요했지만 L1 Cache를 추가한 후에는 31680000 tick이 필요하다. 즉 훨신 빠르게 시뮬레이션이 종료된것을 알 수 있다.

[system.cpu.dcache]
type=Cache
children=power_state replacement_policy tags
addr_ranges=0:18446744073709551615
assoc=2
clk_domain=system.cpu_clk_domain
clusivity=mostly_incl
compressor=Null
data_latency=2
demand_mshr_reserve=1
eventq_index=0

 config.ini에서 system.cpu.dcache의 SimObject가 추가된 것을 알 수 있다.

 

아래에는 일반적으로 자주 사용되는 Options을 나열했다.

--cpu-type=CPU_TYPE

실행할 CPU 유형입니다. 이것은 항상 설정해야하는 중요한 매개 변수입니다. 기본값은 atomic이며 타이밍 시뮬레이션을 수행하지 않습니다.
--sys-clock=SYS_CLOCK

시스템 속도로 실행되는 블록에 대한 최상위 클록.
--cpu-clock=CPU_CLOCK

CPU 속도로 실행되는 블록의 시계입니다. 위의 시스템 시계와는 별개입니다.
--mem-type=MEM_TYPE

사용할 메모리 유형입니다. 옵션에는 다양한 DDR 메모리와 루비 메모리 컨트롤러가 포함됩니다.
--caches

클래식 캐시로 시뮬레이션을 수행하십시오.
--l2cache

클래식 캐시를 사용하는 경우 L2 캐시로 시뮬레이션을 수행합니다.
--ruby

캐시 시스템 시뮬레이션으로 클래식 캐시 대신 Ruby를 사용하십시오.
-m TICKS, --abs-max-tick=TICKS

복원 된 체크 포인트의 틱을 포함하여 지정된 절대 시뮬레이션 틱까지 실행합니다. 특정 시간 동안 만 시뮬레이션하려는 경우에 유용합니다.
-I MAXINSTS, --maxinsts=MAXINSTS

시뮬레이션 할 총 명령어 수 (기본값 : 영구 실행). 특정 수의 명령이 실행 된 후 시뮬레이션을 중지하려는 경우 유용합니다.
-c CMD, --cmd=CMD

syscall 에뮬레이션 모드에서 실행할 바이너리입니다.
-o OPTIONS, --options=OPTIONS

바이너리에 전달할 옵션은 전체 문자열에””를 사용합니다. 이것은 옵션을 취하는 명령을 실행할 때 유용합니다. 이 변수를 통해 인수와 옵션 (예 : –whatever)을 모두 전달할 수 있습니다.
--output=OUTPUT

stdout을 파일로 리디렉션합니다. 이는 시뮬레이션 된 응용 프로그램의 출력을 화면에 인쇄하는 대신 파일로 리디렉션하려는 경우 유용합니다. 참고 : gem5 출력을 리디렉션하려면 구성 스크립트 전에 매개 변수를 전달해야합니다.
--errout=ERROUT

stderr을 파일로 리디렉션합니다. 위와 비슷합니다.

 

반응형