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
Need MPI_THREAD_MULTIPLE for backward compatibility #947
Comments
What do you mean by that? Do we need to add a preprocessor constant, do we need to initialize MPI in a particular way, or what else do you want us to do? |
By default, if MPI is initialized via MPI_Init, MPI routines can be called only from one of the threads. The alternative routine MPI_Init_thread accepts several "mode" selectors, including MPI_THREAD_MULTIPLE and MPI_THREAD_SERIALIZED. MPI_THREAD_MULTIPLE allows all threads to make MPI calls. Unfortunately, e.g. OpenMPI does not seem to fully support this yet. MPI_THREAD_SERIALIZED also allows all threads to make MPI calls, but requires that the application ensures that the calls are serialized, i.e. that only one thread at a time makes MPI calls. Using this would probably require (maybe global) state changes between "HPX uses MPI" and "application uses MPI". (I just see that MPI_THREAD_SINGLE is the default, which states that the applications is single-threaded. With HPX, you probably should use at least MPI_THREAD_FUNNELED instead.) |
Thanks for the explanations. HPX guarantees that the MPI calls are being made from exactly one thread only, thus If you need to do MPI calls yourself then I don't see any way to synchronize HPX with an external application without creating a global contention point (as |
You could introduce a function that switches HPX between use-MPI and don't-use-MPI mode. This function could be local to a locality. Of course, performance would not be ideal. Since Cactus has defined times at which it performs MPI calls, I would then wrap these calls by first disabling and later re-enabling MPI in HPX. |
That's absolutely possible. Is suggest to introduce something that pauses |
For now I'm going to commit the following change. I switched from The mode used with |
It seems I need either MPI_THREAD_MULTIPLE or MPI_THREAD_SERIALIZED for backward compatibility, to gradually add HPX support to Cactus. I am using the MPI parcelport, and I tried simply calling some MPI functions. This seems to work many times, but I get strange hangs that could be explained by OpenMPI not being thread safe.
The text was updated successfully, but these errors were encountered: