|
From: Anton P. <po...@un...> - 2012-11-07 14:51:24
|
Hi,
Valgrind is great, and I've no problems using it under Linux.
However, I also must work on a Mac (running Mac OS Lion), and there I do
have couple of problems:
#----------------------------------------------------------------------------------------
1) Native gcc compiler on Mac OS is very old (version 4.2).
BUT if I try to compile Valgrind with newer version (e.g. plain gcc
compiler installed via macports)
it, of course, cannot recognize -arch x86_64 flag, which is native
only for Apple's gcc.
QUESTIONS:
- Is it possible to replace this flag with standard -m64 on Mac OS,
like it's done on Linux?
- Is plain gcc compiler appropriate at all for compiling Valgrind on
Mac OS?
- Is it OK if I use plain gcc compiler for my applications, together
with Valgrind built with Apple's native gcc?
#----------------------------------------------------------------------------------------
2) With native gcc compiler, the MPI wrappers are built without problems
whatsoever.
I configure like this: ./configure --prefix=/opt/valgrind
--enable-only64bit --with-mpicc=mpicc
Valgrind-clean debug version of MPICH2 (see Appendix A) is used for
MPI implementation, and the resulting
wrapper library libmpiwrap-amd64-darwin.so is indeed placed here:
/opt/valgrind/lib/valgrind
The documentation only describes how to use MPI wrappers on Linux,
I've figured out how it must be done on Mac OS (there is no
LD_PRELOAD for example):
Compile like this:
mpicc -g -O0 mpi_prog.c
Run like this:
DYLD_INSERT_LIBRARIES=/opt/valgrind/lib/valgrind/libmpiwrap-amd64-darwin.so
\
DYLD_FORCE_FLAT_NAMESPACE=1 \
MPIWRAP_DEBUG=quiet \
mpirun -n 4 valgrind --dsymutil=yes --tool=memcheck
--log-file=valgrind.log.%p ./a.out
BUT whatever I do I CANNOT get wrappers activated on Mac OS.
Installation/compilation/linking/running is OK, but the
characteristic message:
valgrind MPI wrappers xxxxx: Active for pid xxxxx
valgrind MPI wrappers xxxxx: Try MPIWRAP_DEBUG=help for possible
options
is NEVER get printed to standard output.
I even tried linking wrappers directly against my application like this:
mpicc -g -O0 mpi_prog.c -L/opt/valgrind/lib/valgrind
-lmpiwrap-amd64-darwin
It successfully compiles, links, and after properly setting
DYLD_LIBRARY_PATH, even runs
without complaining, but, but, but with the same result: wrappers
are never activated.
QUESTIONS:
- Why libmpiwrap-amd64-darwin has a non-standard .so, but not
.dylib, extension on Darwin?
- Can wrappers fail because MPI library on Darwin also has .dylib
extension, but not .so,
which is somehow hardcoded in libmpiwrap.c?
- Can wrappers fail, because MPI library is supposed to be an ELF
shared object, which
obviously cannot be the case on Mac OS, since it uses proprietary
Mach-O format?
The wikipedia page http://en.wikipedia.org/wiki/Mach-O says in the
section "Mach-O future"
that since Mac OS 10.6 "Mach-O file has undergone a significant
modification that
causes binaries compiled on a 10.6 computer to be by default only
able to run on a 10.6 computer"
So, it has probably diverged even further from ELF format.
Sorry for the long message, but it's not actually covered by documentation.
Any information/explanation/advice is highly appreciated.
I hope that the following appendices will be useful for those who use
MPI with Valgrind on Mac OS.
Anton
#----------------------------------------------------------------------------------------
Appendix A:
#----------------------------------------------------------------------------------------
"Valgrind-clean" debug version of MPICH2 with shared libraries,
and C, C++, and FORTRAN language support for Mac OS
"Proper" FORTRAN compiler is taken here:
http://cran.r-project.org/bin/macosx/tools/gfortran-4.2.3.dmg
By default it builds 32-bit code, hence -arch x86_64 flags are added to
FORTRAN binding.
Don't forget to add /opt/mpich2-debug to PATH
./configure \
CC=gcc \
CXX=g++ \
F77=gfortran \
FC=gfortran \
FFLAGS="-arch x86_64" \
FCFLAGS="-arch x86_64" \
CPPFLAGS='-I/opt/valgrind/include/valgrind' \
--prefix=/opt/mpich2-debug \
--enable-f77 \
--enable-fc \
--enable-cxx \
--enable-threads=runtime \
--enable-g=dbg,mem,meminit \
--enable-debuginfo \
--enable-shared \
--enable-sharedlibs="osx-gcc" \
--enable-fast=none
#----------------------------------------------------------------------------------------
Appendix B:
#----------------------------------------------------------------------------------------
INSTALL VALKYRIE (GUI FOR VALGRIND)
1) Install macports:
http://www.macports.org/install.php
Use Mac OS X Package (.pkg) Installer
sudo port -v selfupdate
2) Install qt4
sudo port install qt4-mac
3) Install valkyrie
unpack sources
qmake
make
4) Copy valkyrie.app from ./bin/ to Applications directory
Make desktop shortcut (optionally)
#----------------------------------------------------------------------------------------
|