summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2019-08-04 14:46:19 -0500
committerGitHub <noreply@github.com>2019-08-04 14:46:19 -0500
commit57feadb1f8f25b4e34d2085646cf2a78ad3654a8 (patch)
tree7362a1366b228ceabb0accbca0270017fd596a78
parent9f9fa567cfb0536fdae402c50005c22febb163cf (diff)
parent1f99d77b1b822da758ca7163155df110882b60ed (diff)
downloadnumpy-57feadb1f8f25b4e34d2085646cf2a78ad3654a8.tar.gz
Merge pull request #14185 from IntelPython/intel-compiler-binary-search-with-guess
MAINT: Workaround for Intel compiler bug leading to failing test
-rw-r--r--numpy/core/src/multiarray/compiled_base.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c
index dc79bfa09..c38067681 100644
--- a/numpy/core/src/multiarray/compiled_base.c
+++ b/numpy/core/src/multiarray/compiled_base.c
@@ -367,6 +367,18 @@ arr_insert(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwdict)
#define LIKELY_IN_CACHE_SIZE 8
+#ifdef __INTEL_COMPILER
+#pragma intel optimization_level 0
+#endif
+static NPY_INLINE npy_intp
+_linear_search(const npy_double key, const npy_double *arr, const npy_intp len, const npy_intp i0)
+{
+ npy_intp i;
+
+ for (i = i0; i < len && key >= arr[i]; i++);
+ return i - 1;
+}
+
/** @brief find index of a sorted array such that arr[i] <= key < arr[i + 1].
*
* If an starting index guess is in-range, the array values around this
@@ -406,10 +418,7 @@ binary_search_with_guess(const npy_double key, const npy_double *arr,
* From above we know key >= arr[0] when we start.
*/
if (len <= 4) {
- npy_intp i;
-
- for (i = 1; i < len && key >= arr[i]; ++i);
- return i - 1;
+ return _linear_search(key, arr, len, 1);
}
if (guess > len - 3) {