Skip to content

Commit 04a3a28

Browse files
committed
Some memchecker cleanup and others.
- Port memchecker call from a1d502c. - Remove unused memcheck macro variables. - Some code readability improvements. - Remove some stray +1's in dynamic comm cleanup. - Re-add OPAL_ENABLE_DEBUG macro to osc header. - Cleanup some printf's, and includes. - Refactor cleanup of dpm_disconnect_objs. Signed-off-by: Austen Lauria <[email protected]>
1 parent e2ad184 commit 04a3a28

18 files changed

+45
-60
lines changed

ompi/dpm/dpm.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,16 @@ int ompi_dpm_finalize(void)
11141114
return OMPI_SUCCESS;
11151115
}
11161116

1117+
static void cleanup_dpm_disconnect_objs(ompi_dpm_disconnect_obj **objs, int count)
1118+
{
1119+
for(int i = 0; i < count; i++) {
1120+
if (NULL != objs[i]->reqs) {
1121+
free(objs[i]->reqs);
1122+
}
1123+
free(objs[i]);
1124+
}
1125+
free(objs);
1126+
}
11171127

11181128
/**********************************************************************/
11191129
/**********************************************************************/
@@ -1127,7 +1137,7 @@ int ompi_dpm_dyn_finalize(void)
11271137
ompi_communicator_t *comm=NULL;
11281138

11291139
if (1 <ompi_comm_num_dyncomm) {
1130-
objs = (ompi_dpm_disconnect_obj**)malloc((ompi_comm_num_dyncomm+1)*
1140+
objs = (ompi_dpm_disconnect_obj**)malloc(ompi_comm_num_dyncomm *
11311141
sizeof(ompi_dpm_disconnect_obj*));
11321142
if (NULL == objs) {
11331143
return OMPI_ERR_OUT_OF_RESOURCE;
@@ -1138,23 +1148,15 @@ int ompi_dpm_dyn_finalize(void)
11381148
comm = (ompi_communicator_t*)opal_pointer_array_get_item(&ompi_mpi_communicators,i);
11391149
if (NULL != comm && OMPI_COMM_IS_DYNAMIC(comm)) {
11401150
objs[j++] = disconnect_init(comm);
1141-
// printf ("%d/%d = %p\n", j-1, ompi_comm_num_dyncomm + 1, objs[j-1]);
11421151
}
11431152
}
11441153

1145-
if (j != ompi_comm_num_dyncomm+1) {
1146-
for(i=0; i<j; i++) {
1147-
if (NULL != objs[i]->reqs) {
1148-
free(objs[i]->reqs);
1149-
}
1150-
free(objs[i]);
1151-
}
1152-
free(objs);
1154+
if (j != ompi_comm_num_dyncomm) {
1155+
cleanup_dpm_disconnect_objs(objs, j);
11531156
return OMPI_ERROR;
11541157
}
11551158

1156-
disconnect_waitall(ompi_comm_num_dyncomm+1, objs);
1157-
free(objs);
1159+
disconnect_waitall(ompi_comm_num_dyncomm, objs);
11581160
}
11591161

11601162
return OMPI_SUCCESS;
@@ -1181,7 +1183,6 @@ static ompi_dpm_disconnect_obj *disconnect_init(ompi_communicator_t *comm)
11811183
int i;
11821184

11831185
obj = (ompi_dpm_disconnect_obj*)calloc(1,sizeof(ompi_dpm_disconnect_obj));
1184-
// printf("obj = %p\n", obj);
11851186
if (NULL == obj) {
11861187
opal_output(0, "Could not allocate disconnect object");
11871188
return NULL;
@@ -1274,14 +1275,7 @@ static int disconnect_waitall (int count, ompi_dpm_disconnect_obj **objs)
12741275
ret = ompi_request_wait_all(2*totalcount, reqs, MPI_STATUSES_IGNORE);
12751276

12761277
/* Finally, free everything */
1277-
for (i=0; i< count; i++ ) {
1278-
if (NULL != objs[i]->reqs ) {
1279-
free(objs[i]->reqs );
1280-
}
1281-
// printf("%d/%d free %p\n", i, count, objs[i]);
1282-
free(objs[i]);
1283-
}
1284-
1278+
cleanup_dpm_disconnect_objs(objs, count);
12851279
free(reqs);
12861280

12871281
return ret;

ompi/include/ompi/memchecker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static inline int memchecker_call (int (*f)(void *, size_t), const void * addr,
131131
size_t blength = opal_datatype_basicDatatypes[pElem->elem.common.type]->size;
132132
if ((size_t)pElem->elem.extent == blength) {
133133
/* block is made of contiguous basic datatype */
134-
f( (void *)(source_base + pElem->elem.disp), pElem->elem.count*pElem->elem.extent );
134+
f( (void *)(source_base + pElem->elem.disp), pElem->elem.count*blength );
135135
} else {
136136
uint32_t j;
137137
ptrdiff_t offset;

ompi/mca/osc/pt2pt/osc_pt2pt_header.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ typedef struct ompi_osc_pt2pt_header_get_t ompi_osc_pt2pt_header_get_t;
100100

101101
struct ompi_osc_pt2pt_header_complete_t {
102102
ompi_osc_pt2pt_header_base_t base;
103-
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
103+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT || OPAL_ENABLE_DEBUG
104104
uint8_t padding[2];
105105
#endif
106106
int frag_count;
@@ -123,7 +123,7 @@ typedef struct ompi_osc_pt2pt_header_post_t ompi_osc_pt2pt_header_post_t;
123123

124124
struct ompi_osc_pt2pt_header_lock_t {
125125
ompi_osc_pt2pt_header_base_t base;
126-
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
126+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT || OPAL_ENABLE_DEBUG
127127
uint8_t padding[2];
128128
#endif
129129
int32_t lock_type;
@@ -133,7 +133,7 @@ typedef struct ompi_osc_pt2pt_header_lock_t ompi_osc_pt2pt_header_lock_t;
133133

134134
struct ompi_osc_pt2pt_header_lock_ack_t {
135135
ompi_osc_pt2pt_header_base_t base;
136-
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
136+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT || OPAL_ENABLE_DEBUG
137137
uint8_t padding[2];
138138
#endif
139139
uint32_t source;
@@ -143,7 +143,7 @@ typedef struct ompi_osc_pt2pt_header_lock_ack_t ompi_osc_pt2pt_header_lock_ack_t
143143

144144
struct ompi_osc_pt2pt_header_unlock_t {
145145
ompi_osc_pt2pt_header_base_t base;
146-
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
146+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT || OPAL_ENABLE_DEBUG
147147
uint8_t padding[2];
148148
#endif
149149
int32_t lock_type;
@@ -154,7 +154,7 @@ typedef struct ompi_osc_pt2pt_header_unlock_t ompi_osc_pt2pt_header_unlock_t;
154154

155155
struct ompi_osc_pt2pt_header_unlock_ack_t {
156156
ompi_osc_pt2pt_header_base_t base;
157-
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
157+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT || OPAL_ENABLE_DEBUG
158158
uint8_t padding[6];
159159
#endif
160160
uint64_t lock_ptr;
@@ -163,7 +163,7 @@ typedef struct ompi_osc_pt2pt_header_unlock_ack_t ompi_osc_pt2pt_header_unlock_a
163163

164164
struct ompi_osc_pt2pt_header_flush_t {
165165
ompi_osc_pt2pt_header_base_t base;
166-
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
166+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT || OPAL_ENABLE_DEBUG
167167
uint8_t padding[2];
168168
#endif
169169
uint32_t frag_count;
@@ -173,7 +173,7 @@ typedef struct ompi_osc_pt2pt_header_flush_t ompi_osc_pt2pt_header_flush_t;
173173

174174
struct ompi_osc_pt2pt_header_flush_ack_t {
175175
ompi_osc_pt2pt_header_base_t base;
176-
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
176+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT || OPAL_ENABLE_DEBUG
177177
uint8_t padding[6];
178178
#endif
179179
uint64_t lock_ptr;

ompi/mca/pml/ob1/pml_ob1_cuda.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "pml_ob1_recvreq.h"
3737
#include "pml_ob1_sendreq.h"
3838
#include "ompi/mca/bml/base/base.h"
39-
#include "ompi/memchecker.h"
4039

4140
size_t mca_pml_ob1_rdma_cuda_btls(
4241
mca_bml_base_endpoint_t* bml_endpoint,

ompi/mca/pml/ob1/pml_ob1_recvfrag.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include "ompi/communicator/communicator.h"
4141
#include "ompi/mca/pml/pml.h"
4242
#include "ompi/peruse/peruse-internal.h"
43-
#include "ompi/memchecker.h"
4443
#include "ompi/runtime/ompi_spc.h"
4544

4645
#include "pml_ob1.h"

ompi/mca/pml/ob1/pml_ob1_recvreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include "pml_ob1_sendreq.h"
4141
#include "pml_ob1_rdmafrag.h"
4242
#include "ompi/mca/bml/base/base.h"
43-
#include "ompi/memchecker.h"
43+
4444
#if OPAL_CUDA_SUPPORT
4545
#include "opal/datatype/opal_datatype_cuda.h"
4646
#include "opal/mca/common/cuda/common_cuda.h"

ompi/mca/pml/ob1/pml_ob1_sendreq.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "pml_ob1_rdmafrag.h"
4040
#include "pml_ob1_recvreq.h"
4141
#include "ompi/mca/bml/base/base.h"
42-
#include "ompi/memchecker.h"
4342

4443
OBJ_CLASS_INSTANCE(mca_pml_ob1_send_range_t, opal_free_list_item_t,
4544
NULL, NULL);

ompi/mca/pml/ob1/pml_ob1_sendreq.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "pml_ob1_rdma.h"
3434
#include "pml_ob1_rdmafrag.h"
3535
#include "ompi/mca/bml/bml.h"
36+
#include "ompi/memchecker.h"
3637

3738
BEGIN_C_DECLS
3839

@@ -214,6 +215,16 @@ do {
214215

215216
static inline void mca_pml_ob1_send_request_fini (mca_pml_ob1_send_request_t *sendreq)
216217
{
218+
219+
/* make buffer defined when the request is completed,
220+
and before releasing the objects. */
221+
MEMCHECKER(
222+
memchecker_call(&opal_memchecker_base_mem_defined,
223+
sendreq->req_send.req_base.req_addr,
224+
sendreq->req_send.req_base.req_count,
225+
sendreq->req_send.req_base.req_datatype);
226+
);
227+
217228
/* Let the base handle the reference counts */
218229
MCA_PML_BASE_SEND_REQUEST_FINI((&(sendreq)->req_send));
219230
assert( NULL == sendreq->rdma_frag );

ompi/mca/pml/ob1/pml_ob1_start.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "pml_ob1.h"
2727
#include "pml_ob1_recvreq.h"
2828
#include "pml_ob1_sendreq.h"
29-
#include "ompi/memchecker.h"
3029

3130

3231
int mca_pml_ob1_start(size_t count, ompi_request_t** requests)

ompi/mpi/c/exscan.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,10 @@ int MPI_Exscan(const void *sendbuf, void *recvbuf, int count,
5151

5252
MEMCHECKER(
5353
memchecker_datatype(datatype);
54-
if (0 != ompi_comm_rank(comm)) {
55-
if (MPI_IN_PLACE != sendbuf) {
56-
memchecker_call(&opal_memchecker_base_isdefined, sendbuf, count, datatype);
57-
} else {
58-
memchecker_call(&opal_memchecker_base_isdefined, recvbuf, count, datatype);
59-
}
54+
if (MPI_IN_PLACE != sendbuf) {
55+
memchecker_call(&opal_memchecker_base_isdefined, sendbuf, count, datatype);
56+
} else {
57+
memchecker_call(&opal_memchecker_base_isdefined, recvbuf, count, datatype);
6058
}
6159
memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, count, datatype);
6260
memchecker_comm(comm);

0 commit comments

Comments
 (0)