프로젝트/GCN Accelerator

[GEM5] gem5 environment setting

아이스얼그레이 2022. 10. 10. 15:32
본 게시글은 GEM5 환경설정 및 설치 과정을 정리한 글입니다.

 

이번 GNN(정확히는 GCN) accelerator 설계의 최종 목표는 DAC이라는 conference에 논문을 쓰는 것입니다!!

 

논문을 쓰는 과정에서 architecture level simulation을 할 필요가 있습니다. 저희가 제안한 architecture을 cycle-driven or event-driven으로 simulation 해서 저희가 의도한 대로 동작하는지 확인해야 합니다.

 

Computer architecture 분야 논문에서 주로 GEM5와 Ramulator가 사용되는데, 본 게시글에서는 GEM5에 대한 환경설정 과정을 다뤄보겠습니다.

 

https://www.gem5.org/getting_started/

 

gem5: Getting Started with gem5

Getting Started with gem5 Getting Started with gem5 First steps The gem5 simulator is most useful for research when you build new models and new features on top of the current codebase. Thus, the most common way to use gem5 is to download the source and bu

www.gem5.org

https://www.gem5.org/documentation/general_docs/building

 

gem5: Building gem5

last edited: 2022-09-27 19:05:47 +0000 Building gem5 Supported operating systems and environments gem5 has been designed with a Linux environment in mind. We test regularly on Ubuntu 18.04 and Ubuntu 20.04 to ensure gem5 functions well in these environment

www.gem5.org

 

위 두 문서를 참고해서 작성했습니다.

 

1. Ubuntu 환경 및 필요한 program 설치

gem5는 Ubuntu 20.04 혹은 Ubuntu 18.04에서 compile 할 수 있습니다.

 

저는 VM에서 Ubuntu 18.04를 사용하기 때문에 이를 기준으로 설명하겠습니다. Ubuntu 20.04에 대한 내용은 링크의 문서를 참고해주세요.

sudo apt install build-essential git m4 scons zlib1g zlib1g-dev \
    libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev \
    python3-dev python libboost-all-dev pkg-config

위 명령어를 통해 몇 가지 프로그램을 설치해줍니다. 이미 설치되어있다면 명령어 처리하면서 무시하기 때문에 복붙 하시면 됩니다.

 

GEM5 build 과정에서 python3를 사용하기 때문에 3.6 version 이상의 python을 설치해줍시다.

 

필요한 program을 설치하지 않으면 build 과정에서 error를 만나기 때문에 깔끔하게 클리어하고 갑시다!

 

2. Git clone

git에 저장되어있는 파일을 clone 해줍시다.

git clone https://gem5.googlesource.com/public/gem5

편하게 작업 폴더에서 git clone 하시면 gem5라는 폴더가 생성됩니다.

저는 unix 문법에서 tab 자동완성을 아주 좋아해서 폴더명을 02-gem으로 변경해줬습니다.

이 과정에서 약 3분 정도 소요됩니다.

 

3. Building with scons

scosn는 python으로 구현된 open source build system입니다. 자세한 내용은 잘 모르겠으며, 이걸 활용해서 build 한다고 이해하시면 됩니다.

scons build/{ISA}/gem5.{variant} -j {cpus}

위 명령어 rule을 따라서 build 하시면 되는데 { }의 의미는 다음과 같습니다.

 

ISA : architecture의 taregt ISA를 써줍니다. ARM, MIPS, RISCV, SPARC, X86가 지원됩니다.

         추후에 RISCV 설계에 이용되지 않을까 싶습니다!

         ISA 입력하실 때 대문자로 입력하셔야 합니다. 처음에 x86로 명령어를 썼는데 오류가 떴었습니다.

 

variant : compilation setting을 기술해줍니다. 옵션으로 debug, opt, fasat가 있고 주로 opt를 사용한다고 합니다.

 

-j : -j flag는 compilation parallelization을 가능하게 해주는 flag입니다.

 

cpu : -j와 함께 쓰이는데, 몇 개의 thread로 병렬화할지 정해줍니다.

 

이런 명령어 set들이 나오면서 build가 진행됩니다. 꽤 오래 걸릴 것 같은데 아직 안 끝나서 정확한 시간은 모르겠네요. 1시간 정도 걸리지 않을까요?

 

환경설정은 여기까지고, build가 끝나면 architecture level simulation을 해보겠습니다.