Skip to content

fix thread queue allocation on windows - #6132

Merged
martin-frbg merged 1 commit into
OpenMathLib:developfrom
mattip:windows-threading
Oct 17, 2026
Merged

martin-frbg merged 1 commit into
OpenMathLib:developfrom
mattip:windows-threading

Conversation

@mattip

@mattip mattip commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

This was worked through on MacPython/openblas-libs#284 to fix numpy/numpy#27989 and MacPython/openblas-libs#283.

On machines with many cores, there was cross-thread use of the wrong queues. This is solved here.

I used Claude code to identify and fix the problem.

Maybe related to #1404

@mattip

mattip commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

I would add the issue reproducer as a test, but it needs a machine with more cores than is available on CI, especially since the OpenBLAS default is 64 threads on windows (openblas-libs uses 24).

@martin-frbg

Copy link
Copy Markdown
Collaborator

Thanks - would it be possible to attach the reproducer here (though the biggest Windows machine I have myself is only 10 cores/20 threads) ?

Not sure what was up with issue 1404 - I'm pretty sure the Windows support in OpenBLAS was even worse back then and compilers have also improved. Anyway the cpu mentioned there had only 6 cores/12 threads. Guess I'll finally close #1404 as not reproducible anymore (after doing one final build with Haswell rather than CooperLake target)

@mattip

mattip commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Here is the reproducer

import numpy as np
from concurrent.futures import ThreadPoolExecutor

def crash_test(size_a):
    a = np.random.random((size_a,4))
    b = np.random.random((4,4))
    c = np.matmul(a,b)
    return c.mean()
    
num_threads = 4
counts = 128
futures = []
total = 0
size_a = 1024*1024

with ThreadPoolExecutor(max_workers=num_threads) as executor:
    for i in range(counts):
        futures.append(executor.submit(crash_test, size_a))
    for i in range(counts):    
        total += futures[i].result()
print(total)

@martin-frbg martin-frbg added this to the 0.3.35 milestone Oct 17, 2026
@martin-frbg
martin-frbg merged commit fd4bb7e into OpenMathLib:develop Oct 17, 2026
110 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: np.matmul crashes in multi-threaded settings on windows with large matrices

2 participants