{"action":"created","issue":{"url":"https://api.github.com/repos/cython/cython/issues/2316","repository_url":"https://api.github.com/repos/cython/cython","labels_url":"https://api.github.com/repos/cython/cython/issues/2316/labels{/name}","comments_url":"https://api.github.com/repos/cython/cython/issues/2316/comments","events_url":"https://api.github.com/repos/cython/cython/issues/2316/events","html_url":"https://github.com/cython/cython/issues/2316","id":330710152,"node_id":"MDU6SXNzdWUzMzA3MTAxNTI=","number":2316,"title":"parallel.prange loops producing random results","user":{"login":"ngoldbaum","id":3126246,"node_id":"MDQ6VXNlcjMxMjYyNDY=","avatar_url":"https://avatars2.githubusercontent.com/u/3126246?v=4","gravatar_id":"","url":"https://api.github.com/users/ngoldbaum","html_url":"https://github.com/ngoldbaum","followers_url":"https://api.github.com/users/ngoldbaum/followers","following_url":"https://api.github.com/users/ngoldbaum/following{/other_user}","gists_url":"https://api.github.com/users/ngoldbaum/gists{/gist_id}","starred_url":"https://api.github.com/users/ngoldbaum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngoldbaum/subscriptions","organizations_url":"https://api.github.com/users/ngoldbaum/orgs","repos_url":"https://api.github.com/users/ngoldbaum/repos","events_url":"https://api.github.com/users/ngoldbaum/events{/privacy}","received_events_url":"https://api.github.com/users/ngoldbaum/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-08T15:45:41Z","updated_at":"2018-06-08T16:31:08Z","closed_at":null,"author_association":"NONE","body":"This was originally found by @AshKelly in the context of his GSOC project with yt.\r\n\r\nTake a look at this repo: https://github.com/ngoldbaum/cython-issue\r\n\r\nYou can build the .pyx file with `pip install -e .`\r\n\r\nIf you're on a machine with OpenMP support (e.g. on Linux, not MacOS), you'll see that `fun_sum` returns random results while `fun_sum_scalar` returns consistent results. For reference, here's what `fun_sum` looks like:\r\n\r\n```cython\r\ncimport numpy as np\r\nimport numpy as np\r\ncimport cython\r\nfrom cython.parallel import prange\r\n\r\ndef fun_sum():\r\n\r\n    cdef np.float64_t[:] result = np.zeros(1)\r\n    cdef int j\r\n    cdef np.float64_t a = 3.0\r\n\r\n    with nogil:\r\n        for j in prange(0, 10000):\r\n            result[0] += a + j\r\n\r\n    return np.array(result)\r\n```"},"comment":{"url":"https://api.github.com/repos/cython/cython/issues/comments/395815639","html_url":"https://github.com/cython/cython/issues/2316#issuecomment-395815639","issue_url":"https://api.github.com/repos/cython/cython/issues/2316","id":395815639,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTgxNTYzOQ==","user":{"login":"ngoldbaum","id":3126246,"node_id":"MDQ6VXNlcjMxMjYyNDY=","avatar_url":"https://avatars2.githubusercontent.com/u/3126246?v=4","gravatar_id":"","url":"https://api.github.com/users/ngoldbaum","html_url":"https://github.com/ngoldbaum","followers_url":"https://api.github.com/users/ngoldbaum/followers","following_url":"https://api.github.com/users/ngoldbaum/following{/other_user}","gists_url":"https://api.github.com/users/ngoldbaum/gists{/gist_id}","starred_url":"https://api.github.com/users/ngoldbaum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngoldbaum/subscriptions","organizations_url":"https://api.github.com/users/ngoldbaum/orgs","repos_url":"https://api.github.com/users/ngoldbaum/repos","events_url":"https://api.github.com/users/ngoldbaum/events{/privacy}","received_events_url":"https://api.github.com/users/ngoldbaum/received_events","type":"User","site_admin":false},"created_at":"2018-06-08T16:31:08Z","updated_at":"2018-06-08T16:31:08Z","author_association":"NONE","body":"Yes, in the real example where this was originally found we're compositing data in parallel onto a 2D image array. We found we could trigger it with an array of shape `(1,)`, so we figured that was simplest for the bug report."}}
{"actor":{"display_login":"ngoldbaum"}}