4

When running MPI program, we use command
mpiexec -hostfile ./conf/machines <my_mpi_program>

My hostfile ./conf/machines

192.168.1.54
192.168.1.55
192.168.1.56
192.168.1.57

And When executing MPI program, i got my processor rank by MPI_Comm_rank.
My question is how to get <rank, hostname> pair of each rank ?
The hostname should be the same with the hostfile i spcecified, and i just want to use ipaddress as the hostname in hostfile.

I tried to use MPI_Get_processor_name but it returned the name of my host teaker-4 , not the name in the specified hostfile.

And also, teaker-4 is 127.0.0.1, and I cannot modify /etc/hosts

pgplus1628
  • 1,294
  • 1
  • 16
  • 22
  • The answers to http://stackoverflow.com/questions/14689707/how-to-know-the-which-core-a-process-is-running-on-in-mpi may assist you. – High Performance Mark Apr 28 '15 at 10:22
  • @HighPerformanceMark , the link tells which CPU core the MPI process is running on, I want to know which machine the given rank(get by MPI_Comm_rank) is running on, it's not the same thing. anyway, thanks a lot. :D – pgplus1628 Apr 28 '15 at 10:44
  • @zorksylar Just to clarify, you want to programatically extract the specific host ip inside the MPI process? Also I believe it is `--hostfile`. Maybe this will help http://stackoverflow.com/questions/22174901/gethostname-function-missing-in-openmpi – Karl Aug 06 '15 at 00:27
  • @Karl thanks for your link. But `MPI_Get_processor_name` will return the hostname in the `/etc/hosts` file. What i want to do is to get the `` pair , and the `hostname` is in the `conf/machines` file, not in `/etc/hosts`. – pgplus1628 Aug 07 '15 at 07:07
  • @zorksylar could you just disseminate the machines file to the children and lookup there. or call `gethostbyname` or something similar along that line of reasoning to extract the ip address? [get ip address of host programatically](http://stackoverflow.com/questions/212528/get-the-ip-address-of-the-machine) – Karl Aug 07 '15 at 15:40

0 Answers0