Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix complex vector dot with more than NPY_CBLAS_CHUNK elements #22384

Merged
merged 1 commit into from Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion numpy/core/src/multiarray/arraytypes.c.src
Expand Up @@ -3581,7 +3581,8 @@ NPY_NO_EXPORT void
CBLAS_INT chunk = n < NPY_CBLAS_CHUNK ? n : NPY_CBLAS_CHUNK;
@type@ tmp[2];

CBLAS_FUNC(cblas_@prefix@dotu_sub)((CBLAS_INT)n, ip1, is1b, ip2, is2b, tmp);
CBLAS_FUNC(cblas_@prefix@dotu_sub)(
(CBLAS_INT)chunk, ip1, is1b, ip2, is2b, tmp);
sum[0] += (double)tmp[0];
sum[1] += (double)tmp[1];
/* use char strides here */
Expand Down
11 changes: 10 additions & 1 deletion numpy/core/tests/test_multiarray.py
Expand Up @@ -29,7 +29,7 @@
assert_allclose, IS_PYPY, IS_PYSTON, HAS_REFCOUNT, assert_array_less,
runstring, temppath, suppress_warnings, break_cycles,
)
from numpy.testing._private.utils import _no_tracing
from numpy.testing._private.utils import requires_memory, _no_tracing
from numpy.core.tests._locales import CommaDecimalPointLocale
from numpy.lib.recfunctions import repack_fields

Expand Down Expand Up @@ -6691,6 +6691,15 @@ def assert_dot_close(A, X, desired):
# Strides in A cols and X
assert_dot_close(A_f_12, X_f_2, desired)

@pytest.mark.slow
@pytest.mark.parametrize("dtype", [np.float64, np.complex128])
@requires_memory(free_bytes=9*10**9) # complex case needs 8GiB+
def test_huge_vectordot(self, dtype):
# Large vector multiplications are chunked with 32bit BLAS
# Test that the chunking does the right thing, see also gh-22262
data = np.ones(2**30+100, dtype=dtype)
res = np.dot(data, data)
assert res == 2**30+100


class MatmulCommon:
Expand Down