Newsgroups: comp.programming.threads,comp.parallel.mpi
From: Marcelo Pasin <pasin@imag.fr>
Subject: Problems using IBM MPI + threads
Organization: Institute IMAG, Grenoble, France
Date: Wed, 26 Jun 1996 14:12:59 +0200
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <31D1294B.5150FC2B@imag.fr>

Hello, 

We are expected to upgrade soon to AIX version 4.1. We use
in the current version (AIX 3.2) MPI-F with DCE-threads and we
are supposed to use the new IBM MPI product, with the new
Posix Threads of v4.1.

I compiled a *very* simple program using the new versions
in a SP2 at the CNUSC in Montpellier. It compiled ok, but it
causes a segment violation when it runs. It was compiled with
"mpcc -o test test.c -lpthreads". If you comment out all MPI
calls (and include) and compile with "cc_r -o test test.c",
it works fine.

(The version with the MPI calls were also compiled and run
flawlessly, with no hack, in a SPARC + Solaris 2.5 + MPI-CH
1.0.12).

The program creates two more threads that modify a global 
variable and die. The main thread waits the end of that two 
threads and prints the value of the global variables, as 
follows:

#include <mpi.h>
#include <pthread.h>

int x1 = 0;
int x2 = 0;

void *func1(void *x) {
  x1 = 1;
}

void *func2(void *x) {
  x2 = 2;
}

main (int argc, char **argv) {
  int rank;
  pthread_t t1, t2;
  void *p1, *p2;

  MPI_Init(&argc, &argv);

  pthread_create(&t1, NULL, func1, NULL);
  pthread_create(&t2, NULL, func2, NULL);

  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  printf("hello %d\n", rank);

  pthread_join(t1, &p1);
  pthread_join(t2, &p2);

  printf("x(%d,%d)\n", x1, x2);

  pthread_detach(t1);
  pthread_detach(t2);

  MPI_Finalize();
}

I digged for a while and I found that the cc_r command passes
"-D_THREAD_SAFE -qnoansialias" to the compiler and "/lib/crt0_r.o
-lpthreads -lc_r" to the linker. It signifies that there are
"thread-hacked" versions of the includes, C-library, and startup.

Well, mpcc, at the other side, does almost the same! I mean, there
are "poe-hacked" versions of the C-library *and* the startup,
which are described in /usr/lpp/ppe.poe/lib/poe.cfg...

---------

Can I suppose that the threads can't work with new POE because
there are not "thread-poe-hacked" versions of C-library and
startup? If not, what's the explanation? Anyway, how could we
deal with the problem? We even thought on asking IBM to recompile,
only for us, MPI-F under v4.1... :)

Thanks a lot for any comment,

-- 
Marcelo Pasin

Apache Project, IMAG, France

