Jeff Squyres wrote:
>Arrgh. That's a real bummer. What is mex -- is it a wrapper compiler
>like mpicc?
>
>It looks like mex doesn't want to accept the -pthread switch.
>
>Well, I was really hoping to avoid a manual assembly of flags, but you
>may need to do that. We have automated ways of getting the flags out
>of mpicc (and you could filter out -pthread), but that may or may not
>be sufficient. That is, if the bottom-level compiler does not link in
>the pthreads library, LAM may not link properly.
>
>Specifically, you can run your mpicc command line below and add
>"-showme" to see what mpicc is actually invoking underneath. Try
>simply eliminating -pthread from the underlying command and see if it
>links properly (I suspect that it won't).
>
>Let me know what happens and let's go from there.
>
>
I defined MEX to be:
MEX = mex -L/home/packages/LAM-MPI/intel/lib -llammpio -llamf77mpi -lmpi
-llam -lutil
and
CFLAGS += -I/home/packages/LAM-MPI/intel/include
using info. from mpicc -showme, less -pthread).
This is seems to be working.
But a more serious problem arises. MPI_Init() crashes Matlab.
This is the C code:
int error=0, mp_init=0;
int argc=2, num_proc, my_rank;
char **argv;
MPI_Initialized(&mp_init);
if(mp_init == 1)
printf("***** MPI_Init called.\n");
else {
printf("***** MPI_Init NOT called. Calling ...\n");
MPI_Init(&argc, &argv);
printf("***** Now MPI_Init called.\n");
}
"***** MPI_Init NOT called. Calling ..." is printed out
before crashing.
Is it because I faked argc and argv (this C code is called
from another C code, which is called by Matlab via MEX,
so I don't have any real argc and argv)?
Or is it because of the following (quoted from this group):
-----
3.4.3 Dynamic/Embedded Environments
In LAM/MPI version 7.1.1, some RPI modules may utilize an additional
memory manager mechanism (see Section 3.3.1, page 15 for more details).
This can cause problems when running MPI processes as dynamically
loaded modules. For example, when running a LAM/MPI program as a MEX
function in a Matlab environment, normal Unix linker semantics create
situations where both the default Unix and the memory management
systems are used. This typically results in process failure.
Note that this only occurs when LAM/MPI processes are used in a dynamic
environment and an additional memory manager is included in LAM/MPI.
This appears to occur because of normal Unix semantics; the only way to
avoid it is to use the --with-memory-manager parameter to LAM�s
configure script, specifying either �none� or �external� as its value.
See the LAM/MPI Installation Guide for more details.
-----
Please help!
Thanks,
-Lei
>
>On Aug 5, 2005, at 2:07 PM, Lei_at_ICS wrote:
>
>
>
>>Thanks! This sounds like a simple solution.
>>
>>I tried it and got some errors:
>>
>>/home/packages/LAM-MPI/intel/bin/mpicc -f ../mexopts_linux.sh -V5 -v
>>-D_LINUX_ -I/usr/local/matlab/extern/include -DMATLAB View.o Viewx.o
>>BuildCavityLists.o BuildCombinedLists.o BuildRadMatrixIndexVectors.o
>>ComputeElementGeometryProperties.o CreateParticipatingInternalChbdys.o
>>DetermineViewUpdateMode.o GenerateRadList.o
>>InitRadMatrixCavityPartition.o InternalChbdysInternalGridPtrLookup.o
>>ReorderInternalChbdys.o SetAllUpdateFlags.o UpdateInternalChbdys.o
>>Vfact.o View3d.o ../db_/imdb.a ../DataSet/DataSet.a
>>../EnumDefinitions/EnumDefinitions.a ../dbx_/imdbx.a ../shared/utils.a
>>
>> mex: -pthread not a valid option.
>>
>> Usage:
>> MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
>> [objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
>>
>> or (to build an Ada S-function):
>> MEX [-v] [-g] -ada <sfcn>.ads
>>
>> Use the -help option for more information, or consult the MATLAB
>>External Interfaces Guide.
>>
>>/home/packages/LAM-MPI/intel/bin/mpicc: No such file or directory
>>gmake: *** [View] Error 1
>>~
>>
>>
>>If I setenv LAMCC mex
>>
>>I get:
>>
>>losangeles[24]% mpicc
>>
>> mex: -pthread not a valid option.
>>
>> Usage:
>> MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
>> [objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
>>
>> or (to build an Ada S-function):
>> MEX [-v] [-g] -ada <sfcn>.ads
>>
>> Use the -help option for more information, or consult the MATLAB
>>External Interfaces Guide.
>>
>>mpicc: No such file or directory
>>losangeles[25]%
>>
>>But if I setenv LAMCC gcc
>>I get:
>>
>>losangeles[27]% mpicc
>>/usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crt1.o: In function
>>`_start':
>>/usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crt1.o(.text+0x18):
>>undefined reference to `main'
>>collect2: ld returned 1 exit status
>>mpicc: No such file or directory
>>losangeles[28]%
>>
>>Yes, mex is a script provided by Matlab. But I am not able to
>>modify it yet. Any further suggestions on how to solve it problem?
>>
>>Thanks a lot,
>>
>>-Lei
>>
>>
>>Jeff Squyres wrote:
>>
>>
>>
>>>On Aug 3, 2005, at 9:52 PM, Lei_at_ICS wrote:
>>>
>>>
>>>
>>>
>>>
>>>>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?
>>>>
>>>>
>>>>
>>>>
>>>Is mex another wrapper compiler, similar to mpicc?
>>>
>>>If so, what you might want to do is set mpicc's underlying compiler to
>>>be mex, and then link your application with mpicc (i.e., layer the
>>>wrapper compilers).
>>>
>>>You can do this by setting the environment variable LAMCC to "mex" (or
>>>whatever the executable name is that you use to compile/link Mex
>>>applications).
>>>
>>>
>>>
>>>
>>>
>>_______________________________________________
>>This list is archived at http://www.lam-mpi.org/MailArchives/lam/
>>
>>
>>
>
>
>
|