[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Glib and MPI



Hi Gerber,

I have some information; I am Cc'ing the list on this reply in case
anybody else is interested however I think further discussion about
the details of your problem should probably be done off-list until we
figure out if it is a Debian packaging bug or not.  It is not obvious
to me where exactly the problem lies although I guess it relates to
dynamic linking.

1) I was able to compile but not link the program using a command
based on the ones you gave:
 mpicc `pkg-config --cflags glib-2.0` -I/usr/include/glib-2.0 -Wall
-DENABLE_MPI -g -O2   -o simple simple.c
/tmp/ccI5Hf82.o: In function `main':
/home/cilibrar/tmp/mpi/simple.c:31: undefined reference to `g_log'
collect2: ld returned 1 exit status

So it seems somehow your compilation/link environment is being
permissive in some way; this happens to me when I compile dynamic
libraries with typos in symbol names because the compiler cannot
reliably detect undefined references before runtime in the context of
complex dynamic linking and erroneous header files for example.

2) I had to use the following one-step compile and link command instead:

mpicc `pkg-config --cflags glib-2.0` -I/usr/include/glib-2.0 -Wall
-DENABLE_MPI -g -O2   -o simple simple.c `pkg-config --libs glib-2.0`

Then, if I just use mpirun ./simple
it works both with and without the g_message.  It prints some warnings though.

I can only guess how come your version segfaults.  Perhaps the symbol
g_message is not resolved but the link failure is not being detected
until runtime when dynamink linking fails to resolve the symbol for
some reason?  This has happened to me before in some other more
complicated build (compilation/link) environments.  Another problem I
have found in the past is that it is necessary to call g_type_init
before using any of the gobject (glib custom object types) functions
in glib, or else it can cause a segfault.  But this also requires
using the pkg-config --libs gobject-2.0 and pkg-config --cflags
gobject-2.0 options as well.

I hope this helps you resolve the problem.  Best regards,

Rudi

On Tue, Jun 17, 2008 at 6:11 AM, Gerber van der Graaf
<gerber.vdgraaf@gmail.com> wrote:
> Hi,
> I am working on an application I'd like to parallellize with MPI. For
> the momement only with liblam. The application already makes extensive
> use of libglib. It seems that the program crashes when using libglib.
> Does anybody have a suggestion how to use properly mpi and libglib?
>
> I am using the current versions of libglib-2.0 and liblam on
> Debian/Unstable.
>
> Below a short example that works fine when using the printf() statement,
> but crashes when g_message() is enabled.
>
> Thanks,
> Gerber
>
>
>
> simple.c:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <glib-2.0/glib.h>
> #include <mpi.h>
>
> /*-----------------------------------------------------------------------------
>  * Simple testing program for MPI and libglib
>  * Build with:
> mpicc `pkg-config --cflags glib-2.0` -I/usr/include/glib-2.0 \
> -DENABLE_MPI -g -O2 -c -o simple.o simple.c
>
> mpicc -Wall   -DENABLE_MPI -g -O2   -o simple  simple.o -lglib-2.0 -lmpi
>
>  * Run with (after invoking lamboot):
> mpirun -np 3 ./simple
>  */
>
> int main(int argc, char *argv[])
> {
>  int me = 0, nprocs;
>  int namelen;
>  char processor_name[MPI_MAX_PROCESSOR_NAME];
>
>
>  MPI_Init(&argc, &argv);
>  MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
>  MPI_Comm_rank(MPI_COMM_WORLD, &me);
>  MPI_Get_processor_name(processor_name, &namelen);
>
> /*   g_message("Process %d of %d at %s\n", me, nprocs, processor_name);
> */
>  printf("Process %d of %d at %s\n", me, nprocs, processor_name);
>
>
>  printf("%d: Calling MPI_Finalize()\n", me);
>  MPI_Finalize();
>  exit(0);
> }
>
>
> --
> developer of Gpiv: software for Particle Image Velocimetry
> URL: http:/gpiv.sourceforge.net
>
> GnuPG fingerprint:
> BF0A BBFE 5623 9761 C9E1 7C82 8B08 F586 D39A 2B64
>
>



-- 
Git, Hg (Mercurial), and Subversion (svn) hosting over SSH
http://sshcontrol.com/


Reply to: