mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-15 23:40:33 +01:00
nir: Generate unit tests for nir_opt_algebraic
This catches a number of bugs in the current NIR algebraic optimizations or opcodes implementations (as fixed in this series, or documented in the XFAIL tests), and should prevent many future bugs from landing. This required bumping the test timeout, because s390x is very slow to emulate in CI. Closes: #3338 Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39076>
This commit is contained in:
parent
df215cc3cd
commit
4c30c44b75
2 changed files with 113 additions and 49 deletions
|
|
@ -41,13 +41,16 @@ nir_opcodes_c = custom_target(
|
|||
depend_files : nir_depends,
|
||||
)
|
||||
|
||||
nir_opt_algebraic_c = custom_target(
|
||||
'nir_opt_algebraic.c',
|
||||
nir_opt_algebraic = custom_target(
|
||||
'nir_opt_algebraic',
|
||||
input : 'nir_opt_algebraic.py',
|
||||
output : 'nir_opt_algebraic.c',
|
||||
command : [prog_python, '@INPUT@', '--out', '@OUTPUT@'],
|
||||
output : ['nir_opt_algebraic.c', 'nir_opt_algebraic_pattern_test.cpp'],
|
||||
command : [prog_python, '@INPUT@', '--out', '@OUTPUT0@', '--out-tests', '@OUTPUT1@'] +
|
||||
(with_tests ? ['--build-tests'] : []),
|
||||
depend_files : nir_algebraic_depends,
|
||||
)
|
||||
nir_opt_algebraic_c = nir_opt_algebraic[0]
|
||||
nir_opt_algebraic_pattern_test_cpp = nir_opt_algebraic[1]
|
||||
|
||||
nir_intrinsics_h = custom_target(
|
||||
'nir_intrinsics.h',
|
||||
|
|
@ -406,50 +409,71 @@ if with_tests
|
|||
msvc_bigobj = '/bigobj'
|
||||
endif
|
||||
|
||||
# Split the compile of nir_opt_algebraic_pattern_tests into multiple compilation
|
||||
# units, as it takes about of minute of compile time all together.
|
||||
nir_opt_algebraic_pattern_tests = []
|
||||
foreach i : range(8)
|
||||
nir_opt_algebraic_pattern_tests += static_library(
|
||||
'nir_opt_algebraic_pattern_test_@0@'.format(i),
|
||||
nir_opt_algebraic_pattern_test_cpp,
|
||||
cpp_args : [cpp_msvc_compat_args, msvc_bigobj],
|
||||
override_options: [msvc_designated_initializer],
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
cpp_args : '-DSUBSET=@0@'.format(i),
|
||||
include_directories : [inc_include, inc_src],
|
||||
dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
|
||||
)
|
||||
endforeach
|
||||
|
||||
test(
|
||||
'nir_tests',
|
||||
executable(
|
||||
'nir_tests',
|
||||
files(
|
||||
'tests/algebraic_tests.cpp',
|
||||
'tests/builder_tests.cpp',
|
||||
'tests/comparison_pre_tests.cpp',
|
||||
'tests/control_flow_tests.cpp',
|
||||
'tests/core_tests.cpp',
|
||||
'tests/dce_tests.cpp',
|
||||
'tests/format_convert_tests.cpp',
|
||||
'tests/load_store_vectorizer_tests.cpp',
|
||||
'tests/loop_analyze_tests.cpp',
|
||||
'tests/loop_unroll_tests.cpp',
|
||||
'tests/lower_alu_width_tests.cpp',
|
||||
'tests/lower_discard_if_tests.cpp',
|
||||
'tests/minimize_call_live_states_test.cpp',
|
||||
'tests/mod_analysis_tests.cpp',
|
||||
'tests/negative_equal_tests.cpp',
|
||||
'tests/opt_if_tests.cpp',
|
||||
'tests/opt_loop_tests.cpp',
|
||||
'tests/opt_peephole_select.cpp',
|
||||
'tests/opt_shrink_vectors_tests.cpp',
|
||||
'tests/opt_varyings_tests_bicm_binary_alu.cpp',
|
||||
'tests/opt_varyings_tests_dead_input.cpp',
|
||||
'tests/opt_varyings_tests_dead_output.cpp',
|
||||
'tests/opt_varyings_tests_dedup.cpp',
|
||||
'tests/opt_varyings_tests_prop_const.cpp',
|
||||
'tests/opt_varyings_tests_prop_ubo.cpp',
|
||||
'tests/opt_varyings_tests_prop_uniform.cpp',
|
||||
'tests/opt_varyings_tests_prop_uniform_expr.cpp',
|
||||
'tests/serialize_tests.cpp',
|
||||
'tests/range_analysis_tests.cpp',
|
||||
'tests/vars_tests.cpp',
|
||||
),
|
||||
[
|
||||
files(
|
||||
'tests/algebraic_tests.cpp',
|
||||
'tests/builder_tests.cpp',
|
||||
'tests/comparison_pre_tests.cpp',
|
||||
'tests/control_flow_tests.cpp',
|
||||
'tests/core_tests.cpp',
|
||||
'tests/dce_tests.cpp',
|
||||
'tests/format_convert_tests.cpp',
|
||||
'tests/load_store_vectorizer_tests.cpp',
|
||||
'tests/loop_analyze_tests.cpp',
|
||||
'tests/loop_unroll_tests.cpp',
|
||||
'tests/lower_alu_width_tests.cpp',
|
||||
'tests/lower_discard_if_tests.cpp',
|
||||
'tests/minimize_call_live_states_test.cpp',
|
||||
'tests/mod_analysis_tests.cpp',
|
||||
'tests/negative_equal_tests.cpp',
|
||||
'tests/nir_algebraic_pattern_test.cpp',
|
||||
'tests/opt_if_tests.cpp',
|
||||
'tests/opt_loop_tests.cpp',
|
||||
'tests/opt_peephole_select.cpp',
|
||||
'tests/opt_shrink_vectors_tests.cpp',
|
||||
'tests/opt_varyings_tests_bicm_binary_alu.cpp',
|
||||
'tests/opt_varyings_tests_dead_input.cpp',
|
||||
'tests/opt_varyings_tests_dead_output.cpp',
|
||||
'tests/opt_varyings_tests_dedup.cpp',
|
||||
'tests/opt_varyings_tests_prop_const.cpp',
|
||||
'tests/opt_varyings_tests_prop_ubo.cpp',
|
||||
'tests/opt_varyings_tests_prop_uniform.cpp',
|
||||
'tests/opt_varyings_tests_prop_uniform_expr.cpp',
|
||||
'tests/serialize_tests.cpp',
|
||||
'tests/range_analysis_tests.cpp',
|
||||
'tests/vars_tests.cpp',
|
||||
),
|
||||
],
|
||||
cpp_args : [cpp_msvc_compat_args, msvc_bigobj],
|
||||
override_options: [msvc_designated_initializer],
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
include_directories : [inc_include, inc_src],
|
||||
link_whole: nir_opt_algebraic_pattern_tests,
|
||||
dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
|
||||
),
|
||||
suite : ['compiler', 'nir'],
|
||||
protocol : 'gtest',
|
||||
timeout : 60,
|
||||
)
|
||||
|
||||
test(
|
||||
|
|
|
|||
|
|
@ -4282,19 +4282,59 @@ for s in [8, 16]:
|
|||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--out', required=True)
|
||||
parser.add_argument('--out-tests', required=True)
|
||||
parser.add_argument('--build-tests', action='store_true')
|
||||
args = parser.parse_args()
|
||||
|
||||
passes = []
|
||||
|
||||
passes.append(nir_algebraic.AlgebraicPass(
|
||||
"nir_opt_algebraic",
|
||||
optimizations,
|
||||
build_tests=args.build_tests
|
||||
))
|
||||
|
||||
passes.append(nir_algebraic.AlgebraicPass(
|
||||
"nir_opt_algebraic_before_ffma",
|
||||
before_ffma_optimizations,
|
||||
build_tests=args.build_tests
|
||||
))
|
||||
|
||||
passes.append(nir_algebraic.AlgebraicPass(
|
||||
"nir_opt_algebraic_before_lower_int64",
|
||||
before_lower_int64_optimizations,
|
||||
build_tests=args.build_tests
|
||||
))
|
||||
|
||||
passes.append(nir_algebraic.AlgebraicPass(
|
||||
"nir_opt_algebraic_late",
|
||||
late_optimizations,
|
||||
build_tests=args.build_tests
|
||||
))
|
||||
|
||||
passes.append(nir_algebraic.AlgebraicPass(
|
||||
"nir_opt_algebraic_distribute_src_mods",
|
||||
distribute_src_mods,
|
||||
build_tests=args.build_tests
|
||||
))
|
||||
|
||||
passes.append(nir_algebraic.AlgebraicPass(
|
||||
"nir_opt_algebraic_integer_promotion",
|
||||
integer_promotion_optimizations,
|
||||
build_tests=args.build_tests
|
||||
))
|
||||
|
||||
passes.append(nir_algebraic.AlgebraicPass(
|
||||
"nir_opt_reassociate_matrix_mul",
|
||||
mat_mul_optimizations,
|
||||
build_tests=args.build_tests
|
||||
))
|
||||
|
||||
if args.build_tests:
|
||||
with open(args.out_tests, "w", encoding='utf-8') as f:
|
||||
for p in passes:
|
||||
f.write(p.render_tests())
|
||||
|
||||
with open(args.out, "w", encoding='utf-8') as f:
|
||||
f.write(nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render())
|
||||
f.write(nir_algebraic.AlgebraicPass("nir_opt_algebraic_before_ffma",
|
||||
before_ffma_optimizations).render())
|
||||
f.write(nir_algebraic.AlgebraicPass("nir_opt_algebraic_before_lower_int64",
|
||||
before_lower_int64_optimizations).render())
|
||||
f.write(nir_algebraic.AlgebraicPass("nir_opt_algebraic_late",
|
||||
late_optimizations).render())
|
||||
f.write(nir_algebraic.AlgebraicPass("nir_opt_algebraic_distribute_src_mods",
|
||||
distribute_src_mods).render())
|
||||
f.write(nir_algebraic.AlgebraicPass("nir_opt_algebraic_integer_promotion",
|
||||
integer_promotion_optimizations).render())
|
||||
f.write(nir_algebraic.AlgebraicPass("nir_opt_reassociate_matrix_mul",
|
||||
mat_mul_optimizations).render())
|
||||
for p in passes:
|
||||
f.write(p.render())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue