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

Backend choice reset inside of threads #257

Open
hexane360 opened this issue Jul 7, 2021 · 1 comment
Open

Backend choice reset inside of threads #257

hexane360 opened this issue Jul 7, 2021 · 1 comment

Comments

@hexane360
Copy link

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

>>> 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)
arrayfire-python: 3.8.10

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

@9prady9
Copy link
Member

9prady9 commented Jul 7, 2021

@hexane360 set_device, set_backend these are all per thread states, they are not inherited automatically. So I would say, it is not reset, but rather it is left to default value in another thread, hence you are not seeing the values you are setting on main thread.

@umar456 @syurkevi Can you please redirect me to the location in our docs regarding threads in ArrayFire if we have it - I can't recollect it unfortunately.

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

No branches or pull requests

2 participants