LAM/MPI logo

LAM/MPI General User's Mailing List Archives

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

From: fescada (fescada_at_[hidden])
Date: 2006-01-12 21:14:20


Hi all, i write a simple code to teste MPI and Threads, but it don't work and i don't have any ideia why. I
think that my problem is the installation. Regular thread programs work. MPI programs without threads work to.

I'm using LAM/MPI 7.1.1
gcc 3.2.2
Linux Red Hat e kernel 2.4.29
on a Intel PC cluster

My installation:
./configure --with-boot=rsh --with-rsh=ssh
make
make install

mpicc -showme
gcc -I/opt/lam-7.1.1/include -pthread -ldl -lpthread -L/lib -L/opt/lam-7.1.1/lib
 -llammpio -llamf77mpi -lmpi -llam -laio -laio -lutil -lcr -ldl

mpicc mpi_helo_thread.c -o helo_thread
no error or warning reported

My output is:
Master call...
Slave 1.

And stop! I need kill program CTRL+C.
Any suggestion is welcome.
Tank you.

Foguer

My source.

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

void * Hello (void * arg) {
        printf("Hello!\n");
        return 0;
}

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

int MPI_provided;
int my_rank;
pthread_t pt;

        MPI_Init_thread (NULL, NULL, MPI_THREAD_MULTIPLE, &MPI_provided);
        MPI_Comm_rank (MPI_COMM_WORLD, &my_rank);

        if (my_rank == 0) {
                printf("Master call...\n");
        }
        else {
                printf("Slave %d.\n", my_rank);
                pthread_create(&pt, NULL, Hello, NULL);
                pthread_join(pt, NULL);
                fprintf(stderr, "Joined.\n");
        }

        MPI_Barrier(MPI_COMM_WORLD);
        MPI_Finalize();

        return 0;
}