From: NaN <dylanal@earthlink.net>
Newsgroups: comp.parallel.mpi
Subject: HELP: MPICH + static int* = hang?
Date: Fri, 23 Apr 1999 15:42:20 -0700
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
Organization: EarthLink Network, Inc.
Mime-Version: 1.0
Message-Id: <3720F74C.9F665E7C@earthlink.net>
Xref: ukc comp.parallel.mpi:4974


I am trying to use a static int* in one of my MPI programs, however
in the simplest case it hangs, and in my actual code I get a SIGSEGV.

Is MPI = statics a 'bad thing' has anyone else seen this?  I am running
IRIX 6.4 with MPICH 1.1.0 with the latest patches.  Below is some code
that runs fine with mpirun -np 1 but hangs if num processes is > 1

#include <stdio.h>
#include <stdlib.h>

#include "mpi.h"

static int *foobar;

int bar( int **foo )
  {
    int i_count;

    if((foobar = (int*) malloc(10 * sizeof(int))) == NULL )
      exit(-1);
 
    for(i_count = 0; i_count < 10; i_count++ )
      foobar[i_count] = i_count * i_count;
    fprintf(stderr, "die here\n");
    fflush(stderr);
    *foo = foobar;
    fprintf(stderr, "i won't get printed\n");
    fflush(stderr);
    return i_count;
  }

int main( int argc, char** argv )
  { 
    int rank, size;
    int *foo = NULL;
    int i_count, max;
    
    /* Start up MPI */
    MPI_Init( &argc, &argv );
    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
    MPI_Comm_size( MPI_COMM_WORLD, &size );
    
    
    fprintf(stderr, "rank: %d size: %d\n", rank, size);
    fflush(stderr);
    
    max = bar( &foo );
    fprintf(stderr, "max: %d\n", max);
    fflush(stderr);
    
    for(i_count = 0; i_count < max; i_count++ )
      { 
        printf( "i: %d *i: %d\n", i_count, foo[i_count] );
      }
    
    MPI_Finalize();
    
    return 0;
  }

					thanks -DAL-
--
dylanal-AT-earthlink-DOT-net

