Question

I am attempting to install PETSc-3.2 on my laptop (MacBook Pro 10.5.8, MPICH2-1.1) and am running into some difficulty when running the tests: it errors out from a system call to getdomainname() which returns a bad address.

[-1]PETSC ERROR: --------------------- Error Message ------------------
[-1]PETSC ERROR: Error in system call!
[-1]PETSC ERROR: getdomainname()!
[-1]PETSC ERROR: ------------------------------------------------------

To investigate, I wrote the following test codes to check the functionality of getdomainname() with and without MPI:

Single processor:

#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
  char *name;
  int namelen = CHAR_MAX;
  name = (char*) calloc (namelen,sizeof(char));
  int err = getdomainname(name,namelen);
  printf("%s\n",strerror(errno));
  printf("Domain name: %s\n",name);
  return err;
} 

Parallel:

/* Headers */
#include "mpi.h"

int main(int argc, char **argv)
{
  MPI_Init(&argc,&argv);

  int myrank;
  char *mpi_name;
  int mpi_namelen = MPI_MAX_PROCESSOR_NAME;
  mpi_name = (char*) calloc (mpi_namelen,sizeof(char));

  MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
  int mpi_err = MPI_Get_processor_name(mpi_name,&mpi_namelen);
  printf("MPI_Get_processor_name [%d]: %s\n",mpi_err,mpi_name);

  char *name;
  int namelen = CHAR_MAX;
  name = (char*) calloc (namelen,sizeof(char));
  int err = getdomainname(name,namelen);
  printf("%s\n",strerror(errno));
  printf("Domain name: %s\n",name);
  return err;

  MPI_Finalize();
}

The single processor code works without issue, and the parallel code gets the correct name for the processors, but returns bad address on the call to getdomainname() even if running with mpirun -np 1.

Has anyone run into a problem like this before? Is there some kind of configuration for mpirun I need to do so that the domain name is set for each process spawned by MPI? Thanks in advance!

Update:

For those running into this problem with PETSc, compile with the option --with-debugging=0. It seems that in some of the PETSc debugging messages etc. they use a call to getdomainname() rather than MPI_Get_processor_name(). Compiling without debugging disables this branch in the library.

Was it helpful?

Solution

Try a more recent version of MPICH2, 1.1 is very old. Current versions shouldn't be adding any -m32/-m64 arguments to mpicc unless you ask it to. (I'm not sure older versions did this either, but it's possible)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top