xref: /aosp_15_r20/external/FP16/configure.py (revision 5f32b7105932ea8520a0e8811c640f936367d707)
1*5f32b710SXin Li#!/usr/bin/env python
2*5f32b710SXin Li
3*5f32b710SXin Li
4*5f32b710SXin Liimport confu
5*5f32b710SXin Liparser = confu.standard_parser("FP16 configuration script")
6*5f32b710SXin Liparser.add_argument("--compare", dest="compare", action="store_true",
7*5f32b710SXin Li    help="Enable performance comparison with other half-precision implementations")
8*5f32b710SXin Li
9*5f32b710SXin Lidef main(args):
10*5f32b710SXin Li    options = parser.parse_args(args)
11*5f32b710SXin Li    build = confu.Build.from_options(options)
12*5f32b710SXin Li
13*5f32b710SXin Li    build.export_cpath("include", ["fp16.h"])
14*5f32b710SXin Li
15*5f32b710SXin Li    with build.options(source_dir="test", extra_include_dirs="test", deps=[build.deps.googletest, build.deps.psimd]):
16*5f32b710SXin Li        fp16_tables = build.cxx("tables.cc")
17*5f32b710SXin Li        build.unittest("ieee-to-fp32-bits",
18*5f32b710SXin Li            [build.cxx("ieee-to-fp32-bits.cc"), fp16_tables])
19*5f32b710SXin Li        build.unittest("ieee-to-fp32-value",
20*5f32b710SXin Li            [build.cxx("ieee-to-fp32-value.cc"), fp16_tables])
21*5f32b710SXin Li        build.unittest("ieee-from-fp32-value",
22*5f32b710SXin Li            [build.cxx("ieee-from-fp32-value.cc"), fp16_tables])
23*5f32b710SXin Li
24*5f32b710SXin Li        build.unittest("alt-to-fp32-bits",
25*5f32b710SXin Li            [build.cxx("alt-to-fp32-bits.cc"), fp16_tables])
26*5f32b710SXin Li        build.unittest("alt-to-fp32-value",
27*5f32b710SXin Li            [build.cxx("alt-to-fp32-value.cc"), fp16_tables])
28*5f32b710SXin Li        build.unittest("alt-from-fp32-value",
29*5f32b710SXin Li            [build.cxx("alt-from-fp32-value.cc"), fp16_tables])
30*5f32b710SXin Li
31*5f32b710SXin Li        if build.target.is_x86_64:
32*5f32b710SXin Li            stubs = build.peachpy("peachpy/stubs.py")
33*5f32b710SXin Li            build.unittest("alt-xmm-to-fp32-ymm-avx", [build.cxx("peachpy/alt-xmm-to-fp32-xmm-avx.cc"), stubs])
34*5f32b710SXin Li            build.unittest("alt-xmm-to-fp32-ymm-avx2", [build.cxx("peachpy/alt-xmm-to-fp32-ymm-avx2.cc"), stubs])
35*5f32b710SXin Li
36*5f32b710SXin Li        if not build.target.is_emscripten:
37*5f32b710SXin Li            build.unittest("ieee-to-fp32-psimd", build.cxx("ieee-to-fp32-psimd.cc"))
38*5f32b710SXin Li            build.unittest("alt-to-fp32-psimd", build.cxx("alt-to-fp32-psimd.cc"))
39*5f32b710SXin Li
40*5f32b710SXin Li            build.unittest("ieee-to-fp32x2-psimd", build.cxx("ieee-to-fp32x2-psimd.cc"))
41*5f32b710SXin Li            build.unittest("alt-to-fp32x2-psimd", build.cxx("alt-to-fp32x2-psimd.cc"))
42*5f32b710SXin Li
43*5f32b710SXin Li        build.unittest("bitcasts", build.cxx("bitcasts.cc"))
44*5f32b710SXin Li
45*5f32b710SXin Li    macros = ["BENCHMARK_HAS_NO_INLINE_ASSEMBLY"]
46*5f32b710SXin Li    if options.compare:
47*5f32b710SXin Li        macros.append("FP16_COMPARATIVE_BENCHMARKS")
48*5f32b710SXin Li    with build.options(source_dir="bench", extra_include_dirs=".", macros=macros,
49*5f32b710SXin Li            deps=[build.deps.googlebenchmark, build.deps.psimd]):
50*5f32b710SXin Li
51*5f32b710SXin Li        build.benchmark("ieee-element-bench", build.cxx("ieee-element.cc"))
52*5f32b710SXin Li        build.benchmark("alt-element-bench", build.cxx("alt-element.cc"))
53*5f32b710SXin Li
54*5f32b710SXin Li        build.benchmark("from-ieee-array-bench", build.cxx("from-ieee-array.cc"))
55*5f32b710SXin Li        build.benchmark("from-alt-array-bench", build.cxx("from-alt-array.cc"))
56*5f32b710SXin Li
57*5f32b710SXin Li        build.benchmark("to-ieee-array-bench", build.cxx("to-ieee-array.cc"))
58*5f32b710SXin Li        build.benchmark("to-alt-array-bench", build.cxx("to-alt-array.cc"))
59*5f32b710SXin Li
60*5f32b710SXin Li    return build
61*5f32b710SXin Li
62*5f32b710SXin Li
63*5f32b710SXin Liif __name__ == "__main__":
64*5f32b710SXin Li    import sys
65*5f32b710SXin Li    main(sys.argv[1:]).generate()
66