0

Currently, I have a nice c++ graph algorithm written with custom struct definitions of linked-lists or arrays of linked-lists (I should turn this into a template definition, but it currently is not). This algorithm can easily be distributed, and I would like to test this. However, I do not have much OpenMPI experience other than understanding of some basic MPI examples.

  1. How do I use linked-lists in OpenMPI?
  2. What is the common practise for using linked-lists in MPI? For example, I could transform my linked-lists into arrays when I pass them to other processes and then just convert them back.
  3. Would I need to separately handle each of my linked-list classes? Currently, I have 4 separate linked-list classes. If this is the case I might be better off making a template class definition.

Thanks for the guidance and all the help!

CodeKingPlusPlus
  • 15,383
  • 51
  • 135
  • 216

1 Answers1

2

The bare interface basically provides a way to send a contiguous region of memory to other nodes in various ways, but will not traverse your linked list for you in order to do it.

Thus, you need to decide how you want to transmit and receive data based on what makes sense for your algorithm in order to optimize performance. For example, you could send one message per element, or collect many of them and scatter.

defectivehalt
  • 2,462
  • 3
  • 21
  • 22
  • 1
    This is the correct answer; I just want to add that this isn't exclusively an MPI thing. When you (the OP) want to serialize all or part of the linked list - bundle it up and send it somewhere, whether to another node or to disk - you need to do something like your option 2 (possibly using something like option 3 to avoid code duplication for different sorts of lists). You can't write the data to disk without traversing the structure and marshalling the data; with MPI it's the same issue. – Jonathan Dursi May 09 '14 at 13:08