LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Prabhanjan Kambadur (pkambadu_at_[hidden])
Date: 2004-01-25 15:01:56


I take my words back. As Neil pointed out, MPI_GET_PROCESSOR_NAME does
allow you to identify a particular piece of hardware. This call
specifically was included to allow MPI implementations which do process
migration to return to the current processor (ref. MPI Standards).
However, this call returns the actual node as opposed to the virtual node
number.

//
// processor_name.c
// This program demonstrates MPI_GET_PROCESSOR_NAME
//

#include <stdio.h>
#include <mpi.h>

int main(int argc, char *argv[]) {

    int rank;
    int length;
    char name[MPI_MAX_PROCESSOR_NAME];

    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Get_processor_name(name, &length);
    printf("Rank %d is running on : %s\n", rank, name);
    MPI_Finalize();

    return 0;
}

#cat bootfile
dilbert
calvin
hobbes

# lamboot -v bootfile
# mpicc processor_name.c -o processor_name
# mpirun C processor_name
Rank 0 is running on : dilbert.cs.indiana.edu
Rank 1 is running on : calvin.cs.indiana.edu
Rank 2 is running on : hobbes.cs.indiana.edu

Hope this helps,
Anju.