オープンソースGPGPUであるNyuziProcessorの話続き。NyuziProcessorは、ビルドした後のリグレッションテストを自動的に実行することできる環境が用意されている。
こういうハードウェア関係のプロジェクトでリグレッションテストの環境まで提供されているのはなかなか無いし、面白そうなので勉強のためにどのような構成を取っているのか調査した。
図. NyuziProcessorの構成
NyuziProcessorのテストパタンは、ホームディレクトリでmake test
をタイプすると実行される。これは実際には、
test:
cd remote-gdb && $(PYTHON) ./runtest.py
cd core/isa/ && $(PYTHON) ./runtest.py
cd core/cache_control/ && $(PYTHON) ./runtest.py
...
ここでは、core/isa/
のテストパタンの中身を見てみた。cd core/isa/ && python ./runtest.py
が実行される。
./runtest.py
が実行されると、テストパタンの登録がされ、次にテストパタンが次々に実行される。
- tests/core/isa/runtest.py
sys.path.insert(0, '../..')
import test_harness
test_harness.register_generic_assembly_tests([
'int_arithmetic',
'branch',
'compare',
'shuffle',
'load_store',
'atomic',
'float_ops',
'float'
])
test_harness.execute_tests()
これは実際には、tests/test_harness.py
が実行される。まずはテストパタンを登録して、実行するわけだ。_run_generic_assembly_test
というルーチンを呼ぶらしく、これは普通のアセンブリのテストセットを実行するものらしい。
def register_generic_assembly_tests(tests):
...
for name in tests:
register_tests(_run_generic_assembly_test, [name + '_verilator'])
register_tests(_run_generic_assembly_test, [name + '_emulator'])
def _run_generic_assembly_test(name):
underscore = name.rfind('_')
if underscore == -1:
raise TestException(
'Internal error: _run_generic_test did not have type')
environment = name[underscore + 1:]
basename = name[0:underscore]
build_program([basename + '.S'])
result = run_program(environment=environment)
if 'PASS' not in result or 'FAIL' in result:
raise TestException('Test failed ' + result)
_run_generic_assembly_test
では、まずはプログラムのビルド(build_program
)と、次にプログラムの実行(run_program
)が行われる。テストパタンの内容は、それぞれのテストディレクトリに存在するテストパタンを見ればよいのだが、
- tests/core/isa/int_arithmetic.S
# This file auto-generated by ./generate_arithmetic.py. Do not edit.
#include "arithmetic_macros.inc"
.globl _start
_start:
test_sss or, 0x6f7dfdd7, 0x2069e1d7, 0x4f349d96
test_vvs or, result0, voperand1, 0x7285a272
test_vvsm or_mask, result1, 0xdd14, voperand1, 0x9d80748d
test_vvv or, result2, voperand1, voperand2
test_vvvm or_mask, result3, 0x9a44, voperand1, voperand2
test_ssi or, 0x3e9cde49, 0x3e9cde49, 0x1
...
- tests/core/isa/arithmetic_macros.inc
...
.macro test_sss operation, result, operand1, operand2
li s0, \operand1
li s1, \operand2
\operation s2, s0, s1
li s3, \result
cmpeq_i s4, s2, s3
bnz s4, 1f
call fail_test
1:
.endmacro
...
まあこんな感じで、セルフチェックを行うようなテストパタンとなっている。別にシミュレータがあって、それと一致検証をしているわけではなさそうだな。