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

Function npy__cpu_validate_baseline

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

Source from the content-addressed store, hash-verified

206}
207
208static int
209npy__cpu_validate_baseline(void)
210{
211#if !defined(NPY_DISABLE_OPTIMIZATION) && NPY_WITH_CPU_BASELINE_N > 0
212 char baseline_failure[sizeof(NPY_WITH_CPU_BASELINE) + 1];
213 char *fptr = &baseline_failure[0];
214
215 #define NPY__CPU_VALIDATE_CB(FEATURE, DUMMY) \
216 if (!npy__cpu_have[NPY_CAT(NPY_CPU_FEATURE_, FEATURE)]) { \
217 const int size = sizeof(NPY_TOSTRING(FEATURE)); \
218 memcpy(fptr, NPY_TOSTRING(FEATURE), size); \
219 fptr[size] = ' '; fptr += size + 1; \
220 }
221 NPY_WITH_CPU_BASELINE_CALL(NPY__CPU_VALIDATE_CB, DUMMY) // extra arg for msvc
222 *fptr = '\0';
223
224 if (baseline_failure[0] != '\0') {
225 *(fptr-1) = '\0'; // trim the last space
226 PyErr_Format(PyExc_RuntimeError,
227 "NumPy was built with baseline optimizations: \n"
228 "(" NPY_WITH_CPU_BASELINE ") but your machine "
229 "doesn't support:\n(%s).",
230 baseline_failure
231 );
232 return -1;
233 }
234#endif
235 return 0;
236}
237
238static int
239npy__cpu_check_env(int disable, const char *env) {

Callers 1

npy_cpu_initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected