1

If I'm running the same binary (which implies the same architecture) on multiple nodes of a Beowulf cluster in an MPI configuration, is it safe to pass function pointers via MPI as a way of telling another node to call a function? Under what circumstances, if any, can the same function in the same binary have different virtual addresses on different machines or different instances?

dsimcha
  • 67,514
  • 53
  • 213
  • 334

2 Answers2

4

Passing any kind of pointers other than the one shared file pointer per collective MPI_FILE_OPEN (which MPI maintains) to other processes is meaningless. Separate address spaces mean that the pointer value is useless in any process other than the one that generated it.

On the other hand, you could pass around the information about which function you want each process to call, or make each one decide individually. That depends on what your code is doing, of course.

Michael Foukarakis
  • 39,737
  • 6
  • 87
  • 123
  • [This answer](https://stackoverflow.com/a/22772214/1804173) suggests that sending function pointers is possible by disabling ASLR. – bluenote10 Jul 09 '17 at 10:45
4

Simply create array of functions filled with known order and pass functions's ID.

Evgeny Gavrin
  • 7,627
  • 1
  • 22
  • 27