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

make kernel execution thread safe #23

Open
BenjaminW3 opened this issue Dec 30, 2014 · 4 comments
Open

make kernel execution thread safe #23

BenjaminW3 opened this issue Dec 30, 2014 · 4 comments

Comments

@BenjaminW3
Copy link
Member

BenjaminW3 commented Dec 30, 2014

Is it allowed for the host code to be multithreaded itself?
Restricting it is neither useful nor realistically enforceable.
Maybe one thread calculates something using a CUDA device while the other thread uses OpenMP?
This use case requires locking and the removal of some hidden state.

@ax3l
Copy link
Member

ax3l commented Dec 30, 2014

puh, that can generally be useful but as you state it correctly it brings a good amount of requirements and additional checks (locks) for the code that harm performance.

the devices one should have in mind are SoC systems like jetson's K1 and general many-core systems in numa style, e.g. one might want to run a self-contained set of OpenMP threads per MP ("sockel") of a XeonPhi (or vice versa: if I have N MPs with M vector instruction units each: I might want to run 1 OpenMP thread per MP and M OpenMP thread groups with size of N threads each).

@fwyzard
Copy link
Contributor

fwyzard commented Jun 18, 2019

@BenjaminW3 @ax3l is this still an open issue ?

That is, if I understand correctly, it is not possible to launch multiple kernels on the same device from different threads ?

@BenjaminW3
Copy link
Member Author

@fwyzard I can not say for sure because it is not tested but with some restrictions it should be possible to launch multiple tasks on the same device from different threads.

It should be possible to have one queue per thread and enqueue tasks into those queues in parallel.
However, it should also be possible to share a queue across multiple threads and enqueue tasks into this queue in parallel because the queues are designed to be thread-safe.
If something does not work, please report it and we will try to fix it.
There are some natural limitations which we can not changed. For example, CUDA error handling is by design not thread-safe and there is nothing we can do about this. When you get an CUDA error reported from alpaka you can not be sure which kernel or operation produced this error.

@j-stephan
Copy link
Member

Is it allowed for the host code to be multithreaded itself?

The SYCL back-end currently assumes this and I think it would be useful to have this guaranteed for all of alpaka. Implementing this for SYCL was relatively straight forward so I believe this could (and should) be achieved as part of the next alpaka release with not too much effort.

@j-stephan j-stephan added this to To do in Release 1.0 via automation Mar 29, 2022
@j-stephan j-stephan removed this from To do in Release 1.0 Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants