- Instead of calling RUNNING_ON_VALGRIND,
implement specific function, thereby removing bogus requirement on valgrind/valgrind.h dough... - Call specific function runindebugger() before doing expensive checks on each component of struct. - Get rid of void* warnings.. This commit was SVN r17438.
Этот коммит содержится в:
родитель
280bf75b5f
Коммит
9cd2c6f48b
@ -22,14 +22,9 @@
|
||||
#include "opal/mca/memchecker/base/base.h"
|
||||
|
||||
#if OMPI_WANT_MEMCHECKER
|
||||
/* JMS why is this here? Seems like an abstraction violation... */
|
||||
#include "valgrind/valgrind.h"
|
||||
|
||||
# define MEMCHECKER(x) do { \
|
||||
if(RUNNING_ON_VALGRIND){ \
|
||||
x; \
|
||||
} \
|
||||
} while(0)
|
||||
} while(0)
|
||||
#else
|
||||
# define MEMCHECKER(x)
|
||||
#endif /* OMPI_WANT_MEMCHECKER */
|
||||
@ -204,10 +199,14 @@ static inline int memchecker_call (int (*f)(void *, size_t), void * p, size_t co
|
||||
#ifdef OMPI_WANT_MEMCHECKER_MPI_OBJECTS
|
||||
static inline int memchecker_comm(MPI_Comm comm)
|
||||
{
|
||||
/*
|
||||
* We should not check unterlying objects in this way -- either another opal/include/memchecker.h
|
||||
* However, let us assume, that underlying objects are initialized correctly
|
||||
*/
|
||||
if (!opal_memchecker_base_runindebugger()) {
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* We should not check unterlying objects in this way -- either another opal/include/memchecker.h
|
||||
* However, let us assume, that underlying objects are initialized correctly
|
||||
*/
|
||||
#if 0
|
||||
/* c_base */
|
||||
opal_memchecker_base_isdefined (&comm->c_base.obj_class, sizeof(opal_class_t *));
|
||||
@ -304,6 +303,10 @@ static inline int memchecker_comm(MPI_Comm comm)
|
||||
#ifdef OMPI_WANT_MEMCHECKER_MPI_OBJECTS
|
||||
static inline int memchecker_request(MPI_Request *request)
|
||||
{
|
||||
if (!opal_memchecker_base_runindebugger()) {
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
#if 0
|
||||
opal_memchecker_base_isdefined (&(*request)->super.super.super.obj_class, sizeof(opal_class_t *));
|
||||
opal_memchecker_base_isdefined ((void*)&(*request)->super.super.super.obj_reference_count, sizeof(volatile int32_t));
|
||||
@ -358,6 +361,10 @@ static inline int memchecker_request(MPI_Request *request)
|
||||
#ifdef OMPI_WANT_MEMCHECKER_MPI_OBJECTS
|
||||
static inline int memchecker_status(MPI_Status *status)
|
||||
{
|
||||
if (!opal_memchecker_base_runindebugger()) {
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
opal_memchecker_base_isdefined (&status->MPI_SOURCE, sizeof(int));
|
||||
opal_memchecker_base_isdefined (&status->MPI_TAG, sizeof(int));
|
||||
opal_memchecker_base_isdefined (&status->MPI_ERROR, sizeof(int));
|
||||
@ -377,6 +384,10 @@ static inline int memchecker_status(MPI_Status *status)
|
||||
#ifdef OMPI_WANT_MEMCHECKER_MPI_OBJECTS
|
||||
static inline int memchecker_datatype(MPI_Datatype type)
|
||||
{
|
||||
if (!opal_memchecker_base_runindebugger()) {
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
/* the data description.*/
|
||||
opal_memchecker_base_isdefined (&type->size, sizeof(size_t));
|
||||
opal_memchecker_base_isdefined (&type->align, sizeof(uint32_t));
|
||||
|
@ -49,7 +49,7 @@ int MPI_Alltoallv(void *sendbuf, int *sendcounts, int *sdispls,
|
||||
memchecker_datatype(recvtype);
|
||||
|
||||
for ( i = 0; i < size; i++ ) {
|
||||
memchecker_call(&opal_memchecker_base_isdefined, sendbuf+sdispls[i], sendcounts[i], sendtype);
|
||||
memchecker_call(&opal_memchecker_base_isdefined, (char*)sendbuf+sdispls[i], sendcounts[i], sendtype);
|
||||
memchecker_comm(comm);
|
||||
}
|
||||
);
|
||||
|
@ -47,7 +47,7 @@ int MPI_Alltoallw(void *sendbuf, int *sendcounts, int *sdispls,
|
||||
for ( i = 0; i < size; i++ ) {
|
||||
memchecker_datatype(sendtypes[i]);
|
||||
memchecker_datatype(recvtypes[i]);
|
||||
memchecker_call(&opal_memchecker_base_isdefined, sendbuf+sdispls[i], sendcounts[i], sendtypes[i]);
|
||||
memchecker_call(&opal_memchecker_base_isdefined, (char*)sendbuf+sdispls[i], sendcounts[i], sendtypes[i]);
|
||||
memchecker_comm(comm);
|
||||
}
|
||||
);
|
||||
|
@ -98,6 +98,18 @@ OPAL_DECLSPEC extern const opal_memchecker_base_module_1_0_0_t
|
||||
*/
|
||||
extern int opal_memchecker_base_output;
|
||||
|
||||
/**
|
||||
* Check if we are running under the memory debugger.
|
||||
*
|
||||
* @retval 0 if not running under memory debugger
|
||||
* !=0 if running under memory debugger
|
||||
*
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_memchecker_base_runindebugger(void);
|
||||
#if OMPI_WANT_MEMCHECKER == 0
|
||||
#define opal_memchecker_base_runindebugger()
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Check if a memory region is valid to address
|
||||
|
@ -18,6 +18,11 @@
|
||||
#include "opal/mca/memchecker/memchecker.h"
|
||||
#include "opal/mca/memchecker/base/base.h"
|
||||
|
||||
int opal_memchecker_base_runindebugger(void)
|
||||
{
|
||||
return opal_memchecker_base_module->runindebugger();
|
||||
}
|
||||
|
||||
int opal_memchecker_base_isaddressible(void * p, size_t len)
|
||||
{
|
||||
return opal_memchecker_base_module->isaddressible(p, len);
|
||||
|
@ -52,6 +52,12 @@ typedef const struct opal_memchecker_base_module_1_0_0_t *
|
||||
*/
|
||||
typedef int (*opal_memchecker_base_module_init_1_0_0_fn_t)(void);
|
||||
|
||||
/**
|
||||
* Module function to query, whether we're under the memory
|
||||
* checking program, like valgrind
|
||||
*/
|
||||
typedef int (*opal_memchecker_base_module_runindebugger_fn_t)(void);
|
||||
|
||||
/**
|
||||
* Module function to check, whether memory region is addressible
|
||||
*/
|
||||
@ -136,6 +142,9 @@ struct opal_memchecker_base_module_1_0_0_t {
|
||||
/** Module initialization function */
|
||||
opal_memchecker_base_module_init_1_0_0_fn_t init;
|
||||
|
||||
/** Module function to check, whether we are executed by memory debugger */
|
||||
opal_memchecker_base_module_runindebugger_fn_t runindebugger;
|
||||
|
||||
/** Module function to check, whether memory region is addressible */
|
||||
opal_memchecker_base_module_isaddressible_fn_t isaddressible;
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
* Local functions
|
||||
*/
|
||||
static int valgrind_module_init(void);
|
||||
static int valgrind_module_runindebugger(void);
|
||||
static int valgrind_module_isaddressible(void * p, size_t len);
|
||||
static int valgrind_module_isdefined(void * p, size_t len);
|
||||
static int valgrind_module_mem_noaccess(void * p, size_t len);
|
||||
@ -40,8 +41,11 @@ static int valgrind_module_mem_defined_if_addressible(void * p, size_t len);
|
||||
static int valgrind_module_create_block(void * p, size_t len, char * description);
|
||||
static int valgrind_module_discard_block(void * p); /* Here, we need to do some mapping for valgrind */
|
||||
static int valgrind_module_leakcheck(void);
|
||||
#if 0
|
||||
static int valgrind_module_get_vbits(void * p, char * vbits, size_t len);
|
||||
static int valgrind_module_set_vbits(void * p, char * vbits, size_t len);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Valgrind memchecker module
|
||||
*/
|
||||
@ -52,6 +56,7 @@ static const opal_memchecker_base_module_1_0_0_t module = {
|
||||
valgrind_module_init,
|
||||
|
||||
/* Module function pointers */
|
||||
valgrind_module_runindebugger,
|
||||
valgrind_module_isaddressible,
|
||||
valgrind_module_isdefined,
|
||||
valgrind_module_mem_noaccess,
|
||||
@ -84,6 +89,12 @@ static int valgrind_module_init(void)
|
||||
}
|
||||
|
||||
|
||||
static int valgrind_module_runindebugger(void)
|
||||
{
|
||||
return RUNNING_ON_VALGRIND;
|
||||
}
|
||||
|
||||
|
||||
static int valgrind_module_isaddressible(void * p, size_t len)
|
||||
{
|
||||
if (len > 0) {
|
||||
@ -173,6 +184,7 @@ static int valgrind_module_leakcheck(void)
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static int valgrind_module_get_vbits(void * p, char * vbits, size_t len)
|
||||
{
|
||||
if (len > 0) {
|
||||
@ -191,3 +203,5 @@ static int valgrind_module_set_vbits(void * p, char * vbits, size_t len)
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user