MolSSI-MDI / MDI_Library

A library that enables code interoperability via the MolSSI Driver Interface.
BSD 3-Clause "New" or "Revised" License
31 stars 10 forks source link

Enable Parallel Communication Through MDI #6

Open taylor-a-barnes opened 5 years ago

taylor-a-barnes commented 5 years ago

If possible, provide a means for communicating in parallel between two codes through the MDI interface. This will be a challenging project, and will require considerable planning. One of the main complications is that the data structures for the two codes might be laid out in entirely different ways. One possible solution might be to assign a particular standard data structure layout for MDI. Then, each production code can define a mapping of its data structure onto the MDI data structure for each relevant send or receive command. For example, the production code might define a mapping of the COORD data, which is used whenever it receives the COORD command. Once it knows the mappings, MDI is then responsible for correctly shuttling information between the production code and the driver in the correct way.

taylor-a-barnes commented 4 years ago

One possible approach is described here.

Every message sent through MDI is prefaced with an integer, recv_dist, which is a flag that indicates whether a map is going to be sent before the remainder of the message.

In order for a driver or an engine to communicate in a distributed manner, one or both of them must first call:

MDI_Create_Map(&my_elements, &map_descriptor) MDI_Set_Map(“COMMAND”, &map_descriptor, comm)

When a DRIVER does the above, it sends a special command >MAP command through comm, which provides the engine with its map for that command. When an ENGINE does the above, MDI stores the map, but does not send anything to the driver.

In order to avoid the need for this second MPI_Alltoallw, it might be possible to have an MDI_Update_Maps() function that synchronizes the maps of all of the codes. The engine-side MDI would then need to keep track of whether the driver-side MDI has the most up-to-date map. If not, the engine-side MDI receives the data in a manner consistent with the most recent map sent to the driver, and then does a second MPI_Alltoallw to convert from the old map to the new map.