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

Function npy_cpu_init

numpy/core/src/common/npy_cpu_features.c:41–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41NPY_VISIBILITY_HIDDEN int
42npy_cpu_init(void)
43{
44 npy__cpu_init_features();
45 if (npy__cpu_validate_baseline() < 0) {
46 return -1;
47 }
48 char *enable_env = getenv("NPY_ENABLE_CPU_FEATURES");
49 char *disable_env = getenv("NPY_DISABLE_CPU_FEATURES");
50 int is_enable = enable_env && enable_env[0];
51 int is_disable = disable_env && disable_env[0];
52 if (is_enable & is_disable) {
53 PyErr_Format(PyExc_ImportError,
54 "Both NPY_DISABLE_CPU_FEATURES and NPY_ENABLE_CPU_FEATURES "
55 "environment variables cannot be set simultaneously."
56 );
57 return -1;
58 }
59 if (is_enable | is_disable) {
60 if (npy__cpu_check_env(is_disable, is_disable ? disable_env : enable_env) < 0) {
61 return -1;
62 }
63 }
64 return 0;
65}
66
67static struct {
68 enum npy_cpu_features feature;

Callers 2

PyInit__multiarray_umathFunction · 0.85
PyInit__simdFunction · 0.85

Calls 2

npy__cpu_init_featuresFunction · 0.85

Tested by

no test coverage detected