Vengineerの戯言

人生は短いけど、長いです。人生を楽しみましょう!

Vortex をビルドしてみた (その1)

はじめに

RISC-VなGPGPUであるVortexを深堀する (まとめ)

vengineer.hatenablog.com

から、実際に Vortex をビルドしてみて、いろいろと実行してみました。

今回は、(その1)で vortex のビルドとQuick Start Scenariosを実行してみます。

vortex のビルド

git clone --recur https://github.com/vortexgpgpu/vortex.git
make

を実行したら、sim の部分でエラーになった。

%Warning-EOFNEWLINE: ../../hw/rtl/fp_cores/VX_fpu_define.vh:14:7: Missing newline at end of file (POSIX 3.206).
                                                                : ... Suggest add newline.
   14 | `endif
      |       ^
%Warning-EOFNEWLINE: ../../hw/dpi/float_dpi.vh:31:7: Missing newline at end of file (POSIX 3.206).
                                                   : ... Suggest add newline.
   31 | `endif
      |       ^
%Error: Exiting due to 90 warning(s)
make[2]: *** [Makefile:88: rtlsim] Error 1
make[2]: Leaving directory '/mnt/c/Users/haray/home/src/vortex/sim/rtlsim'
make[1]: *** [Makefile:3: all] Error 2
make[1]: Leaving directory '/mnt/c/Users/haray/home/src/vortex/sim'
make: *** [Makefile:4: all] Error 2

verilator コマンドはエラーではなく、ワーニングなのに make ではエラーになっています。

%Error: Exiting due to 90 warning(s)

どうやら、%Warning-EOFNEWLINE をディセーブルにするといいみたい?なので、verilator コマンドにて、-Wno-EOFNEWLINE オプションを追加(VL_FLAGSに-Wno-EOFNEWLINEを追加)、して実行したら、ビルドできました。

cd sim/rtlsim
./rtlsim

何も表示されませんので、-h オプションを追加してみました。

./rtlsim -h
Usage: [-r] [-h: help] programs..

プログラムのビルド

プログラムが必要のようです。テストプログラムをビルドしてみます。

どうやら、RISC-V用のクロスコンパイラが無いです。

cd ../../tests
make
make -C runtime
make[1]: Entering directory '/XXX/vortex/tests/runtime'
make -C hello
make[2]: Entering directory '/XXX/vortex/tests/runtime/hello'
/opt/riscv-gnu-toolchain/bin/riscv32-unknown-elf-gcc -march=rv32imf -mabi=ilp32f -O3 -Wstack-usage=1024 -mcmodel=medany -ffreestanding -nostartfiles -fdata-sections -ffunction-sections -I/XXX/vortex/runtime/include -I/XXX/vortex/runtime/../hw main.cpp -lm -Wl,-Bstatic,-T,/XXX/vortex/runtime/linker/vx_link32.ld -Wl,--gc-sections /XXX/vortex/runtime/libvortexrt.a -o hello.elf
make[2]: /opt/riscv-gnu-toolchain/bin/riscv32-unknown-elf-gcc: Command not found
make[2]: *** [Makefile:43: hello.elf] Error 127
make[2]: Leaving directory '/XXX/vortex/tests/runtime/hello'
make[1]: *** [Makefile:2: all] Error 2
make[1]: Leaving directory '/XXX/vortex/tests/runtime'
make: *** [Makefile:4: runtime] Error 2

vortex-toolchain-prebuilt を使って、RISC-V用のクロスコンパイラを準備しました。/opt/riscv-gnu-toolchain にインストールしました。

再度、make コマンドを実行したら、clang コマンドも必要のようです。同じようにしてvortex-toolchain-prebuilt を使って、/opt/llvm-riscv にインストールしました。

cd tests
make
...
make[2]: /opt/llvm-riscv/bin/clang: Command not found
make[2]: *** [Makefile:55: kernel.elf] Error 127
make[2]: Leaving directory '/XXX/vortex/tests/regression/sort'
make[1]: *** [Makefile:9: all] Error 2
make[1]: Leaving directory '/XXX/vortex/tests/regression'
make: *** [Makefile:7: regression] Error 2
 ./ci/toolchain_install.sh -all

でインストールできたようです。

再度、make コマンドを実行しました。

make
cd riscv/benchmarks
ls
dhrystone.riscv.hex  multiply.riscv.hex  qsort.riscv.hex  spmv.riscv.hex    vvadd.riscv.hex
median.riscv.hex     pmp.riscv.hex       rsort.riscv.hex  towers.riscv.hex

トップから make

トップディレクトリに戻って、make -s を実行

make -s

Quick Start Scenarios

Quick Start Scenariosにあるデモを動かしてみた。

  • rtlsim は、RTL Simulation (Verilator)
  • simx は、動作モデルシミュレータ
  • vlsim は、FPGA Interface + RTL Simulator (Verilator)

  • rtlsim にて、-clusters=2 --cores=2 --warps=2 --threads=4 --app=basic

./ci/blackbox.sh --driver=rtlsim --clusters=2 --cores=2 --warps=2 --threads=4 --app=basic
CONFIGS=-DNUM_CLUSTERS=2 -DNUM_CORES=2 -DNUM_WARPS=2 -DNUM_THREADS=4 -DL2_ENABLE=0 -DL3_ENABLE=0
driver initialization...
running: CONFIGS=-DNUM_CLUSTERS=2 -DNUM_CORES=2 -DNUM_WARPS=2 -DNUM_THREADS=4 -DL2_ENABLE=0 -DL3_ENABLE=0  make -C ./ci/../driver/rtlsim
make: Entering directory '/XXXX/vortex/driver/rtlsim'
make: 'all' is up to date.
make: Leaving directory '/XXXX/vortex/driver/rtlsim'
running application...
running: make -C ./ci/../tests/regression/basic run-rtlsim
make: Entering directory '/XXXX/vortex/tests/regression/basic'
LD_LIBRARY_PATH=XXXX  ./basic -n256
open device connection
number of points: 256
buffer size: 1024 bytes
dev_src=0
dev_dst=400
allocate shared memory
run memcopy test
write source buffer to local memory
read destination buffer from local memory
verify result
upload time: 0 ms
download time: 0 ms
Total elapsed time: 0 ms
upload program
upload kernel argument
run kernel test
upload source buffer
clear destination buffer
start execution
read destination buffer from local memory
verify result
upload time: 0 ms
execute time: 4529 ms
download time: 0 ms
Total elapsed time: 4529 ms
cleanup
PERF: instrs=2284, cycles=13231, IPC=0.172625
Test PASSED
make: Leaving directory '/mnt/c/Users/haray/home/src/vortex/vortex/tests/regression/basic'
  • simx にて、-clusters=2 --cores=2 --warps=2 --threads=4 --app=basic
./ci/blackbox.sh --driver=simx --clusters=2 --cores=2 --warps=2 --threads=4 --app=basic
CONFIGS=-DNUM_CLUSTERS=2 -DNUM_CORES=2 -DNUM_WARPS=2 -DNUM_THREADS=4 -DL2_ENABLE=0 -DL3_ENABLE=0
driver initialization...
running: CONFIGS=-DNUM_CLUSTERS=2 -DNUM_CORES=2 -DNUM_WARPS=2 -DNUM_THREADS=4 -DL2_ENABLE=0 -DL3_ENABLE=0  make -C ./ci/../driver/simx
make: Entering directory '/XXXX/vortex/driver/simx'
make: Nothing to be done for 'all'.
make: Leaving directory '/XXXX/vortex/driver/simx'
running application...
running: make -C ./ci/../tests/regression/basic run-simx
make: Entering directory '/XXXX/vortex/tests/regression/basic'
./basic -n256
open device connection
number of points: 256
buffer size: 1024 bytes
dev_src=0
dev_dst=400
allocate shared memory
run memcopy test
write source buffer to local memory
read destination buffer from local memory
verify result
upload time: 0 ms
download time: 0 ms
Total elapsed time: 0 ms
upload program
upload kernel argument
run kernel test
upload source buffer
clear destination buffer
start execution
read destination buffer from local memory
verify result
upload time: 0 ms
execute time: 26 ms
download time: 0 ms
Total elapsed time: 26 ms
cleanup
PERF: core0: instrs=1885, cycles=9628, IPC=0.195783
PERF: core1: instrs=1885, cycles=9634, IPC=0.195661
PERF: core2: instrs=1885, cycles=9631, IPC=0.195722
PERF: core3: instrs=1885, cycles=9637, IPC=0.195600
PERF: instrs=7540, cycles=9637, IPC=0.782401
Test PASSED
make: Leaving directory '/XXXX/vortex/tests/regression/basic'

--clusters=2 --cores=2 なので、4コアにて実行しています。

PERF: core0: instrs=1885, cycles=9628, IPC=0.195783
PERF: core1: instrs=1885, cycles=9634, IPC=0.195661
PERF: core2: instrs=1885, cycles=9631, IPC=0.195722
PERF: core3: instrs=1885, cycles=9637, IPC=0.195600
PERF: instrs=7540, cycles=9637, IPC=0.782401
  • vlsimx にて、-clusters=2 --cores=2 --warps=2 --threads=4 --app=basic
make: Leaving directory '/XXXX/vortex/driver/vlsim'
LD_LIBRARY_PATH=XXXXXX ./basic -n256
running application...
running: make -C ./ci/../tests/regression/basic run-vlsim
make: Entering directory '/XXXX/vortex/tests/regression/basic'
open device connection
number of points: 256
buffer size: 1024 bytes
dev_src=0
dev_dst=400
allocate shared memory
run memcopy test
write source buffer to local memory
read destination buffer from local memory
verify result
upload time: 123 ms
download time: 30 ms
Total elapsed time: 153 ms
upload program
upload kernel argument
run kernel test
upload source buffer
clear destination buffer
start execution
read destination buffer from local memory
verify result
upload time: 39 ms
execute time: 747 ms
download time: 118 ms
Total elapsed time: 1158 ms
cleanup
PERF: core0: instrs=1886, cycles=10381, IPC=0.181678
PERF: core1: instrs=1886, cycles=10387, IPC=0.181573
PERF: core2: instrs=1886, cycles=10384, IPC=0.181626
PERF: core3: instrs=1886, cycles=10390, IPC=0.181521
PERF: instrs=7544, cycles=10390, IPC=0.726083
Test PASSED
make: Leaving directory '/XXXX/vortex/tests/regression/basic'

--clusters=2 --cores=2 なので、4コアにて実行しています。

PERF: core0: instrs=1886, cycles=10381, IPC=0.181678
PERF: core1: instrs=1886, cycles=10387, IPC=0.181573
PERF: core2: instrs=1886, cycles=10384, IPC=0.181626
PERF: core3: instrs=1886, cycles=10390, IPC=0.181521
PERF: instrs=7544, cycles=10390, IPC=0.726083

おわりに

./ci/blackbox.sh --driver=rtlsim --clusters=2 --cores=2 --warps=2 --threads=4 --app=basic

で実行している、--app=basic の部分のアプリケーションの中をみてみます。