Memcheck: a memory error detector
MPI-1.1
structured
types
are
supported,
and
walked
exactly.
The
currently
supported
combin-
ers
are
MPI_COMBINER_NAMED
,
MPI_COMBINER_CONTIGUOUS
,
MPI_COMBINER_VECTOR
,
MPI_COMBINER_HVECTOR MPI_COMBINER_INDEXED
,
MPI_COMBINER_HINDEXED
and
MPI_COMBINER_STRUCT
.
This should cover all MPI-1.1 types.
The mechanism (function
walk_type
) should extend easily to cover MPI2
combiners.
MPI defines some named structured types (
MPI_FLOAT_INT
,
MPI_DOUBLE_INT
,
MPI_LONG_INT
,
MPI_2INT
,
MPI_SHORT_INT
,
MPI_LONG_DOUBLE_INT
) which are pairs of some basic type and a C
int
. Unfortunately the
MPI specification makes it impossible to look inside these types and see where the fields are.
Therefore these
wrappers assume the types are laid out as
struct { float val; int loc; }
(for
MPI_FLOAT_INT
), etc,
and act accordingly. This appears to be correct at least for Open MPI 1.0.2 and for Quadrics MPI.
If
strict
is an option specified in
MPIWRAP_DEBUG
, the application will abort if an unhandled type is encountered.
Otherwise, the application will print a warning message and continue.
Some effort is made to mark/check memory ranges corresponding to arrays of values in a single pass.
This is
important for performance since asking Valgrind to mark/check any range, no matter how small, carries quite a large
constant cost. This optimisation is applied to arrays of primitive types (
double
,
float
,
int
,
long
,
long long
,
short
,
char
, and
long double
on platforms where
sizeof(long double) == 8
). For arrays of all other
types, the wrappers handle each element individually and so there can be a very large performance cost.
4.9.6. Writing new wrappers
For the most part the wrappers are straightforward. The only significant complexity arises with nonblocking receives.
The issue is that
MPI_Irecv
states the recv buffer and returns immediately, giving a handle (
MPI_Request
)
for the transaction. Later the user will have to poll for completion with
MPI_Wait
etc, and when the transaction
completes successfully, the wrappers have to paint the recv buffer.
But the recv buffer details are not presented to
MPI_Wait
-- only the handle is.
The library therefore maintains a shadow table which associates uncompleted
MPI_Request
s with the corresponding buffer address/count/type.
When an operation completes, the table is
searched for the associated address/count/type info, and memory is marked accordingly.
Access to the table is guarded by a (POSIX pthreads) lock, so as to make the library thread-safe.
The table is allocated with
malloc
and never
free
d, so it will show up in leak checks.
Writing new wrappers should be fairly easy. The source file is
mpi/libmpiwrap.c
. If possible, find an existing
wrapper for a function of similar behaviour to the one you want to wrap, and use it as a starting point. The wrappers
are organised in sections in the same order as the MPI 1.1 spec, to aid navigation. When adding a wrapper, remember
to comment out the definition of the default wrapper in the long list of defaults at the bottom of the file (do not remove
it, just comment it out).
4.9.7. What to expect when using the wrappers
The wrappers should reduce Memcheck’s false-error rate on MPI applications. Because the wrapping is done at the
MPI interface, there will still potentially be a large number of errors reported in the MPI implementation below the
interface. The best you can do is try to suppress them.
You may also find that the input-side (buffer length/definedness) checks find errors in your MPI use, for example
passing too short a buffer to
MPI_Recv
.
Functions which are not wrapped may increase the false error rate. A possible approach is to run with
MPI_DEBUG
containing
warn
. This will show you functions which lack proper wrappers but which are nevertheless used. You
can then write wrappers for them.
75
Содержание BBV
Страница 176: ...Valgrind FAQ Release 3 8 0 10 August 2012 Copyright 2000 2012 Valgrind Developers Email valgrind valgrind org ...
Страница 177: ...Valgrind FAQ Table of Contents Valgrind Frequently Asked Questions 1 ii ...
Страница 302: ...README mips based on newer GCC versions if possible 95 ...
Страница 303: ...GNU Licenses ...
Страница 304: ...GNU Licenses Table of Contents 1 The GNU General Public License 1 2 The GNU Free Documentation License 8 ii ...