views:

73

answers:

2

I installed mpi into windows. I can use its libraries. The problem is that in windows when i write mpiexec -n 4 proj.exe into command prompt it does not make the proper operations. 4 different processes uses the whole code file seperately. They dont behave like parallel processes that are working only in the MPI_Init and MPI_Finalize rows. How can i fix this problem? Is it impossible to work MPI in Windows.

P.s : I am using Dev c++

+1  A: 

I think you should try to clarify your question. mpiexec should launch instances of the exact same executable. You need to check within your program what the MPI id of your process is.

Dima
+1  A: 

MPI is running correctly by what you said -- instead your assumptions are incorrect. In every MPI implementation (that I have used anyway), the entire program is run from beginning to end on every process. The MPI_Init and MPI_Finalize functions are required to setup and tear-down MPI structures for each process, but they do not specify the beginning and end of parallel execution. The beginning of the parallel section is first instruction in main, and the end is the final return.

A good "template" program for what it seems like you want would be (also answered in http://stackoverflow.com/questions/2156714/how-to-speed-up-this-problem-by-mpi):

int main(int argc, char *argv[]) {
    MPI_Init(&argc, &argv);  
    MPI_Comm_size(MPI_COMM_WORLD,&numprocs);  
    MPI_Comm_rank(MPI_COMM_WORLD,&myid);

    if (myid == 0) { // Do the serial part on a single MPI thread
        printf("Performing serial computation on cpu %d\n", myid);
        PreParallelWork();
    }

    ParallelWork();  // Every MPI thread will run the parallel work

    if (myid == 0) { // Do the final serial part on a single MPI thread
        printf("Performing the final serial computation on cpu %d\n", myid);
        PostParallelWork();
    }

    MPI_Finalize();  
    return 0;  
}  
J Teller
Also, if you actually post some source code, maybe we could help more with how getting your MPI program to run correctly. Just based on your very brief description, you may be trying to use shared-memory to communicate (which doesn't work, by design, in MPI).
J Teller