Hi,
If my singleton is a C program, then obviously I compile it using mpicc.
Now my singleton is a C func, View3d, called by another C func, View,
which is called through MEX from Matlab.
That is, in View.c
void mexFunction( int nlhs, mxArray* plhs[],
int nrhs, const mxArray* prhs[])
{
...
View3d();
...
}
In View3d.c
int View3d()
{
...
MPI_Init(..., ...);
MPI_Comm_size(MPI_COMM_WORLD, &num_proc);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
...
}
I compiled View3d.c using mpicc -c View3d.c,
I then compiled View.c and linked the entire thing
using mex. When it executes, I got an error:
??? Invalid MEX-file '/home/pan/IMOS/delivery/View.mexglx':
/home/pan/IMOS/delivery/View.mexglx: undefined symbol: MPI_Init.
This is obvious, because I did not link with the MPI libraries.
So my question is: How do I modify mex to work with MPI,
or how do I modify mpicc to work with mex? Is there another
option?
If anybody has done this before, could you please post your
modified mpicc or mex scripts?
Thanks a lot in advance!
-Lei
Jeffrey Squyres wrote:
> So, once you have a LAM universe, you can launch MPI jobs in one of
>
>three ways:
>
>1. "Singleton", where you just "./a.out" (where a.out invokes
>MPI_Init). This will make a.out be an MPI process, and it will have an
>MPI_COMM_WORLD size of 1.
>
>2. With mpirun.
>
>3. With MPI_Comm_spawn[_multiple].
>
>So what I was suggesting with that design is that you will probably
>lamboot before you run matlab (or you can make your mex script smart
>enough to run lamboot itself), and then have a mex interface that calls
>MPI_Init. This will give you a singleton MPI process, where you can
>look for published names, etc. Then you can spawn a master or connect
>to the existing master... etc.
>
>
>
|