Skip to content

Thread safety issue with dgemm and >2 cores #1851

@bbbbbbbbba

Description

@bbbbbbbbba

On my test computer with 8 cores, the following test snippet fails as long as OPENBLAS_NUM_THREADS is set to something >= 3 (or left unset):

import numpy as np
import threading

def do_test(idx):
    for i in range(100 * idx, 100 * idx + 100):
        a = np.ones((1 << 20, 2)) * i
        b = np.eye(2)
        mat_0 = a.dot(b).reshape(-1)
        mat_1 = a.dot(b).reshape(-1)
        if np.any(mat_0 != mat_1):
            indices = np.nonzero(mat_0 != mat_1)[0]
            if len(indices) > 100: print('Error %d %d' % (i, len(indices)))
            else: print('Error %d %s' % (i, [(j, mat_0[j], mat_1[j]) for j in indices]))

for idx in range(8):
    threading.Thread(target=do_test, args=(idx,)).start()

The version of OpenBLAS I am using is libopenblasp-r0-8dca6697.3.0.dev.so (bundled with numpy 1.15.3).

Originally posted by @bbbbbbbbba in #1844 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions