MCPcopy Create free account
hub / github.com/numpy/numpy / test_dispatcher

Function test_dispatcher

numpy/core/tests/test_cpu_dispatcher.py:5–43  ·  view source on GitHub ↗

Testing the utilities of the CPU dispatcher

()

Source from the content-addressed store, hash-verified

3from numpy.testing import assert_equal
4
5def 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)

Callers

nothing calls this directly

Calls 2

assert_equalFunction · 0.90
test_dispatchMethod · 0.80

Tested by

no test coverage detected