arrayfire / arrayfire/arrayfire-python

Backend choice reset inside of threads

未关闭
#257 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
422
派生
63
PR 合并指标
30 天内没有已合并 PR

描述

Inside a new thread, Arrayfire uses the default backend rather than the backend set by the parent thread:

```python
>>> import arrayfire as af
>>> af.get_available_backends()
('cpu', 'cuda', 'opencl')
>>> af.get_active_backend()
'cuda'
>>> af.set_backend('opencl')
>>> af.get_active_backend()
'opencl'
>>> from threading import Thread
>>> Thread(target=lambda: print(af.get_active_backend())).start()
cuda
```

Is this expected behavior and/or documented anywhere? I would think that the active backend should be process local rather than thread local.

If it matters, here's my version info:
OS: Ubuntu 20.04
arrayfire: 3.9.0 (commit [955152b6](https://github.com/arrayfire/arrayfire/commit/955152b6570c608ae74ebd9e6b31d48351cb8a16))
arrayfire-python: 3.8.10

cuda: 11.4.0-1
ocl-icd-libopencl1: 2.2.11-1
intel-mkl: 2020.0.166-1

贡献指南

这个仓库没有索引到贡献指南

调研方向

Start by reproducing the behavior through the Python threading.Thread entry point and the get_active_backend and set_backend calls shown in the report. Check whether backend selection is documented as thread-local or process-local, and compare the child-thread result with the parent setting. Done means the expected behavior is documented or the reported reset is resolved and covered by a regression test.

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
backend-api-design
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
30/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。