Testing the utilities of the CPU dispatcher
()
| 3 | from numpy.testing import assert_equal |
| 4 | |
| 5 | def test_dispatcher(): |
| 6 | """ |
| 7 | Testing the utilities of the CPU dispatcher |
| 8 | """ |
| 9 | targets = ( |
| 10 | "SSE2", "SSE41", "AVX2", |
| 11 | "VSX", "VSX2", "VSX3", |
| 12 | "NEON", "ASIMD", "ASIMDHP", |
| 13 | "VX", "VXE" |
| 14 | ) |
| 15 | highest_sfx = "" # no suffix for the baseline |
| 16 | all_sfx = [] |
| 17 | for feature in reversed(targets): |
| 18 | # skip baseline features, by the default `CCompilerOpt` do not generate separated objects |
| 19 | # for the baseline, just one object combined all of them via 'baseline' option |
| 20 | # within the configuration statements. |
| 21 | if feature in __cpu_baseline__: |
| 22 | continue |
| 23 | # check compiler and running machine support |
| 24 | if feature not in __cpu_dispatch__ or not __cpu_features__[feature]: |
| 25 | continue |
| 26 | |
| 27 | if not highest_sfx: |
| 28 | highest_sfx = "_" + feature |
| 29 | all_sfx.append("func" + "_" + feature) |
| 30 | |
| 31 | test = _umath_tests.test_dispatch() |
| 32 | assert_equal(test["func"], "func" + highest_sfx) |
| 33 | assert_equal(test["var"], "var" + highest_sfx) |
| 34 | |
| 35 | if highest_sfx: |
| 36 | assert_equal(test["func_xb"], "func" + highest_sfx) |
| 37 | assert_equal(test["var_xb"], "var" + highest_sfx) |
| 38 | else: |
| 39 | assert_equal(test["func_xb"], "nobase") |
| 40 | assert_equal(test["var_xb"], "nobase") |
| 41 | |
| 42 | all_sfx.append("func") # add the baseline |
| 43 | assert_equal(test["all"], all_sfx) |
nothing calls this directly
no test coverage detected