Can LAM be used with multi-threaded user code?
Yes, but LAM is not thread safe. And unfortunately, it may take a while to make LAM thread safe. To do so will require a major redesign and overhaul of the LAM implementation. We’re working on it, but it will take a long time before it is ready. But LAM can be used in multi-threaded applications. The general rule of thumb in using a non-thread safe library in a multi-threaded application is to restrict all calls to the library in a single thread. That is, create an “MPI thread” that is the only thread that interacts with LAM. This approach has shown to work adequately well; it can be implemented with incoming and outgoing queues for the MPI thread — other threads can place messages on (and remove messages from) these queues while the MPI thread performs the actual message passing “in the background.” An alternative approach is to have a “global MPI mutex”. Have a single mutex that locks access to LAM; any thread that wishes to access LAM/MPI must first obtain this lock. This ensures t