Skip to content

Commit c2cd717

Browse files
committed
Don't refcount the predefined datatypes.
Signed-off-by: George Bosilca <[email protected]>
1 parent a49422f commit c2cd717

17 files changed

+117
-71
lines changed

ompi/datatype/ompi_datatype.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include "ompi/constants.h"
3838
#include "opal/datatype/opal_convertor.h"
39+
#include "opal/util/output.h"
3940
#include "mpi.h"
4041

4142
BEGIN_C_DECLS
@@ -374,5 +375,25 @@ OMPI_DECLSPEC int ompi_datatype_unpack_external( const char datarep[], const voi
374375
OMPI_DECLSPEC int ompi_datatype_pack_external_size( const char datarep[], int incount,
375376
ompi_datatype_t *datatype, MPI_Aint *size);
376377

378+
#define OMPI_DATATYPE_RETAIN(ddt) \
379+
{ \
380+
if( !ompi_datatype_is_predefined((ddt)) ) { \
381+
OBJ_RETAIN((ddt)); \
382+
OPAL_OUTPUT_VERBOSE((0, 100, "Datatype %p [%s] refcount %d in file %s:%d\n", \
383+
(void*)(ddt), (ddt)->name, (ddt)->super.super.obj_reference_count, \
384+
__FILE__, __LINE__)); \
385+
} \
386+
}
387+
388+
#define OMPI_DATATYPE_RELEASE(ddt) \
389+
{ \
390+
if( !ompi_datatype_is_predefined((ddt)) ) { \
391+
OPAL_OUTPUT_VERBOSE((0, 100, "Datatype %p [%s] refcount %d in file %s:%d\n", \
392+
(void*)(ddt), (ddt)->name, (ddt)->super.super.obj_reference_count, \
393+
__func__, __LINE__)); \
394+
OBJ_RELEASE((ddt)); \
395+
} \
396+
}
397+
377398
END_C_DECLS
378399
#endif /* OMPI_DATATYPE_H_HAS_BEEN_INCLUDED */

ompi/mca/osc/base/osc_base_obj_convert.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ompi_osc_base_datatype_create(ompi_proc_t *remote_proc, void **payload)
5454
struct ompi_datatype_t *datatype =
5555
ompi_datatype_create_from_packed_description(payload, remote_proc);
5656
if (NULL == datatype) return NULL;
57-
if (ompi_datatype_is_predefined(datatype)) OBJ_RETAIN(datatype);
57+
OMPI_DATATYPE_RETAIN(datatype);
5858
return datatype;
5959
}
6060

ompi/mca/osc/pt2pt/osc_pt2pt_comm.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static int ompi_osc_pt2pt_dt_send_complete (ompi_request_t *request)
9191
ompi_datatype_t *datatype = (ompi_datatype_t *) request->req_complete_cb_data;
9292
ompi_osc_pt2pt_module_t *module = NULL;
9393

94-
OBJ_RELEASE(datatype);
94+
OMPI_DATATYPE_RELEASE(datatype);
9595

9696
OPAL_THREAD_LOCK(&mca_osc_pt2pt_component.lock);
9797
(void) opal_hash_table_get_value_uint32(&mca_osc_pt2pt_component.modules,
@@ -360,7 +360,7 @@ static inline int ompi_osc_pt2pt_put_w_req (const void *origin_addr, int origin_
360360
/* the datatype does not fit in an eager message. send it seperately */
361361
header->base.flags |= OMPI_OSC_PT2PT_HDR_FLAG_LARGE_DATATYPE;
362362

363-
OBJ_RETAIN(target_dt);
363+
OMPI_DATATYPE_RETAIN(target_dt);
364364

365365
ret = ompi_osc_pt2pt_isend_w_cb ((void *) packed_ddt, ddt_len, MPI_BYTE,
366366
target, tag_to_target(tag), module->comm,
@@ -516,7 +516,7 @@ ompi_osc_pt2pt_accumulate_w_req (const void *origin_addr, int origin_count,
516516
/* the datatype does not fit in an eager message. send it seperately */
517517
header->base.flags |= OMPI_OSC_PT2PT_HDR_FLAG_LARGE_DATATYPE;
518518

519-
OBJ_RETAIN(target_dt);
519+
OMPI_DATATYPE_RETAIN(target_dt);
520520

521521
ret = ompi_osc_pt2pt_isend_w_cb ((void *) packed_ddt, ddt_len, MPI_BYTE,
522522
target, tag_to_target(tag), module->comm,
@@ -620,7 +620,7 @@ int ompi_osc_pt2pt_compare_and_swap (const void *origin_addr, const void *compar
620620
request->type = OMPI_OSC_PT2PT_HDR_TYPE_CSWAP;
621621
request->origin_addr = origin_addr;
622622
request->internal = true;
623-
OBJ_RETAIN(dt);
623+
OMPI_DATATYPE_RETAIN(dt);
624624
request->origin_dt = dt;
625625

626626
/* Compute datatype and payload lengths. Note that the datatype description
@@ -775,7 +775,7 @@ static inline int ompi_osc_pt2pt_rget_internal (void *origin_addr, int origin_co
775775
pt2pt_request->type = OMPI_OSC_PT2PT_HDR_TYPE_GET;
776776
pt2pt_request->origin_addr = origin_addr;
777777
pt2pt_request->origin_count = origin_count;
778-
OBJ_RETAIN(origin_dt);
778+
OMPI_DATATYPE_RETAIN(origin_dt);
779779
pt2pt_request->origin_dt = origin_dt;
780780

781781
/* Compute datatype length. Note that the datatype description
@@ -825,7 +825,7 @@ static inline int ompi_osc_pt2pt_rget_internal (void *origin_addr, int origin_co
825825
/* the datatype does not fit in an eager message. send it seperately */
826826
header->base.flags |= OMPI_OSC_PT2PT_HDR_FLAG_LARGE_DATATYPE;
827827

828-
OBJ_RETAIN(target_dt);
828+
OMPI_DATATYPE_RETAIN(target_dt);
829829

830830
ret = ompi_osc_pt2pt_isend_w_cb ((void *) packed_ddt, ddt_len, MPI_BYTE,
831831
target, tag_to_target(tag), module->comm,
@@ -983,7 +983,7 @@ int ompi_osc_pt2pt_rget_accumulate_internal (const void *origin_addr, int origin
983983
pt2pt_request->type = OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC;
984984
pt2pt_request->origin_addr = origin_addr;
985985
pt2pt_request->origin_count = origin_count;
986-
OBJ_RETAIN(origin_datatype);
986+
OMPI_DATATYPE_RETAIN(origin_datatype);
987987
pt2pt_request->origin_dt = origin_datatype;
988988

989989
/* Compute datatype and payload lengths. Note that the datatype description
@@ -1044,7 +1044,7 @@ int ompi_osc_pt2pt_rget_accumulate_internal (const void *origin_addr, int origin
10441044
/* the datatype does not fit in an eager message. send it seperately */
10451045
header->base.flags |= OMPI_OSC_PT2PT_HDR_FLAG_LARGE_DATATYPE;
10461046

1047-
OBJ_RETAIN(target_datatype);
1047+
OMPI_DATATYPE_RETAIN(target_datatype);
10481048

10491049
ret = ompi_osc_pt2pt_isend_w_cb ((void *) packed_ddt, ddt_len, MPI_BYTE,
10501050
target_rank, tag_to_target(tag), module->comm,

ompi/mca/osc/pt2pt/osc_pt2pt_data_move.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void osc_pt2pt_accumulate_data_destructor (osc_pt2pt_accumulate_data_t *a
7575
}
7676

7777
if (acc_data->datatype) {
78-
OBJ_RELEASE(acc_data->datatype);
78+
OMPI_DATATYPE_RELEASE(acc_data->datatype);
7979
}
8080
}
8181

@@ -118,7 +118,7 @@ static void osc_pt2pt_pending_acc_destructor (osc_pt2pt_pending_acc_t *pending)
118118
}
119119

120120
if (NULL != pending->datatype) {
121-
OBJ_RELEASE(pending->datatype);
121+
OMPI_DATATYPE_RELEASE(pending->datatype);
122122
}
123123
}
124124

@@ -370,7 +370,7 @@ static inline int process_put(ompi_osc_pt2pt_module_t* module, int source,
370370

371371
osc_pt2pt_copy_on_recv (target, data, data_len, proc, put_header->count, datatype);
372372

373-
OBJ_RELEASE(datatype);
373+
OMPI_DATATYPE_RELEASE(datatype);
374374

375375
return put_header->len;
376376
}
@@ -407,7 +407,7 @@ static inline int process_put_long(ompi_osc_pt2pt_module_t* module, int source,
407407
return OMPI_ERROR;
408408
}
409409

410-
OBJ_RELEASE(datatype);
410+
OMPI_DATATYPE_RELEASE(datatype);
411411

412412
return put_header->len;
413413
}
@@ -532,7 +532,7 @@ static inline int process_get (ompi_osc_pt2pt_module_t* module, int target,
532532
ret = osc_pt2pt_get_post_send (module, source, get_header->count, datatype,
533533
target, tag_to_origin(get_header->tag));
534534

535-
OBJ_RELEASE(datatype);
535+
OMPI_DATATYPE_RELEASE(datatype);
536536

537537
return OMPI_SUCCESS == ret ? (int) get_header->len : ret;
538538
}
@@ -634,7 +634,7 @@ static int osc_pt2pt_accumulate_allocate (ompi_osc_pt2pt_module_t *module, int p
634634
acc_data->proc = proc;
635635
acc_data->count = count;
636636
acc_data->datatype = datatype;
637-
OBJ_RETAIN(datatype);
637+
OMPI_DATATYPE_RETAIN(datatype);
638638
acc_data->op = op;
639639
acc_data->request_count = request_count;
640640

@@ -728,7 +728,7 @@ static int ompi_osc_pt2pt_acc_op_queue (ompi_osc_pt2pt_module_t *module, ompi_os
728728

729729
/* save the datatype */
730730
pending_acc->datatype = datatype;
731-
OBJ_RETAIN(datatype);
731+
OMPI_DATATYPE_RETAIN(datatype);
732732

733733
/* save the header */
734734
switch (header->base.type) {
@@ -1166,7 +1166,7 @@ static inline int process_acc (ompi_osc_pt2pt_module_t *module, int source,
11661166
}
11671167

11681168
/* Release datatype & op */
1169-
OBJ_RELEASE(datatype);
1169+
OMPI_DATATYPE_RELEASE(datatype);
11701170

11711171
return (OMPI_SUCCESS == ret) ? (int) acc_header->len : ret;
11721172
}
@@ -1197,7 +1197,7 @@ static inline int process_acc_long (ompi_osc_pt2pt_module_t* module, int source,
11971197
}
11981198

11991199
/* Release datatype & op */
1200-
OBJ_RELEASE(datatype);
1200+
OMPI_DATATYPE_RELEASE(datatype);
12011201

12021202
return (OMPI_SUCCESS == ret) ? (int) acc_header->len : ret;
12031203
}
@@ -1231,7 +1231,7 @@ static inline int process_get_acc(ompi_osc_pt2pt_module_t *module, int source,
12311231
uint32_t primitive_count;
12321232
buffer = malloc (data_len);
12331233
if (OPAL_UNLIKELY(NULL == buffer)) {
1234-
OBJ_RELEASE(datatype);
1234+
OMPI_DATATYPE_RELEASE(datatype);
12351235
return OMPI_ERR_OUT_OF_RESOURCE;
12361236
}
12371237

@@ -1250,7 +1250,7 @@ static inline int process_get_acc(ompi_osc_pt2pt_module_t *module, int source,
12501250
}
12511251

12521252
/* Release datatype & op */
1253-
OBJ_RELEASE(datatype);
1253+
OMPI_DATATYPE_RELEASE(datatype);
12541254

12551255
return (OMPI_SUCCESS == ret) ? (int) acc_header->len : ret;
12561256
}
@@ -1281,7 +1281,7 @@ static inline int process_get_acc_long(ompi_osc_pt2pt_module_t *module, int sour
12811281
}
12821282

12831283
/* Release datatype & op */
1284-
OBJ_RELEASE(datatype);
1284+
OMPI_DATATYPE_RELEASE(datatype);
12851285

12861286
return OMPI_SUCCESS == ret ? (int) acc_header->len : ret;
12871287
}
@@ -1313,7 +1313,7 @@ static inline int process_cswap (ompi_osc_pt2pt_module_t *module, int source,
13131313
}
13141314

13151315
/* Release datatype */
1316-
OBJ_RELEASE(datatype);
1316+
OMPI_DATATYPE_RELEASE(datatype);
13171317

13181318
return (OMPI_SUCCESS == ret) ? (int) cswap_header->len : ret;
13191319
}

ompi/mca/pml/base/pml_base_recvreq.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_pml_base_recv_request_t);
6767
{ \
6868
/* increment reference count on communicator */ \
6969
OBJ_RETAIN(comm); \
70-
OBJ_RETAIN(datatype); \
70+
OMPI_DATATYPE_RETAIN(datatype); \
7171
\
7272
OMPI_REQUEST_INIT(&(request)->req_base.req_ompi, persistent); \
7373
(request)->req_base.req_ompi.req_mpi_object.comm = comm; \
@@ -117,7 +117,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_pml_base_recv_request_t);
117117
do { \
118118
OMPI_REQUEST_FINI(&(request)->req_base.req_ompi); \
119119
OBJ_RELEASE( (request)->req_base.req_comm); \
120-
OBJ_RELEASE( (request)->req_base.req_datatype ); \
120+
OMPI_DATATYPE_RELEASE( (request)->req_base.req_datatype ); \
121121
opal_convertor_cleanup( &((request)->req_base.req_convertor) ); \
122122
} while (0)
123123

ompi/mca/pml/base/pml_base_sendreq.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION( mca_pml_base_send_request_t );
9898
\
9999
/* initialize datatype convertor for this request */ \
100100
if( count > 0 ) { \
101-
OBJ_RETAIN(datatype); \
101+
OMPI_DATATYPE_RETAIN(datatype); \
102102
/* We will create a convertor specialized for the */ \
103103
/* remote architecture and prepared with the datatype. */ \
104104
opal_convertor_copy_and_prepare_for_send( \
@@ -145,7 +145,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION( mca_pml_base_send_request_t );
145145
OMPI_REQUEST_FINI(&(request)->req_base.req_ompi); \
146146
OBJ_RELEASE((request)->req_base.req_comm); \
147147
if( 0 != (request)->req_base.req_count ) \
148-
OBJ_RELEASE((request)->req_base.req_datatype); \
148+
OMPI_DATATYPE_RELEASE((request)->req_base.req_datatype); \
149149
opal_convertor_cleanup( &((request)->req_base.req_convertor) ); \
150150
} while (0)
151151

ompi/mca/pml/cm/pml_cm_recvreq.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ do { \
101101
request->req_base.req_comm = comm; \
102102
request->req_base.req_datatype = datatype; \
103103
OBJ_RETAIN(comm); \
104-
OBJ_RETAIN(datatype); \
104+
OMPI_DATATYPE_RETAIN(datatype); \
105105
\
106106
if( MPI_ANY_SOURCE == src ) { \
107107
ompi_proc = ompi_proc_local_proc; \
@@ -132,7 +132,7 @@ do { \
132132
request->req_base.req_comm = comm; \
133133
request->req_base.req_datatype = datatype; \
134134
OBJ_RETAIN(comm); \
135-
OBJ_RETAIN(datatype); \
135+
OMPI_DATATYPE_RETAIN(datatype); \
136136
\
137137
opal_convertor_copy_and_prepare_for_recv( \
138138
ompi_mpi_local_convertor, \
@@ -166,7 +166,7 @@ do { \
166166
request->req_addr = addr; \
167167
request->req_count = count; \
168168
OBJ_RETAIN(comm); \
169-
OBJ_RETAIN(datatype); \
169+
OMPI_DATATYPE_RETAIN(datatype); \
170170
\
171171
if( MPI_ANY_SOURCE == src ) { \
172172
ompi_proc = ompi_proc_local_proc; \
@@ -203,7 +203,7 @@ do { \
203203
request->req_addr = addr; \
204204
request->req_count = count; \
205205
OBJ_RETAIN(comm); \
206-
OBJ_RETAIN(datatype); \
206+
OMPI_DATATYPE_RETAIN(datatype); \
207207
\
208208
opal_convertor_copy_and_prepare_for_recv( \
209209
ompi_mpi_local_convertor, \
@@ -349,7 +349,7 @@ do { \
349349
#define MCA_PML_CM_HVY_RECV_REQUEST_RETURN(recvreq) \
350350
{ \
351351
OBJ_RELEASE((recvreq)->req_base.req_comm); \
352-
OBJ_RELEASE((recvreq)->req_base.req_datatype); \
352+
OMPI_DATATYPE_RELEASE((recvreq)->req_base.req_datatype); \
353353
OMPI_REQUEST_FINI(&(recvreq)->req_base.req_ompi); \
354354
opal_convertor_cleanup( &((recvreq)->req_base.req_convertor) ); \
355355
opal_free_list_return ( &mca_pml_base_recv_requests, \
@@ -362,7 +362,7 @@ do { \
362362
#define MCA_PML_CM_THIN_RECV_REQUEST_RETURN(recvreq) \
363363
{ \
364364
OBJ_RELEASE((recvreq)->req_base.req_comm); \
365-
OBJ_RELEASE((recvreq)->req_base.req_datatype); \
365+
OMPI_DATATYPE_RELEASE((recvreq)->req_base.req_datatype); \
366366
OMPI_REQUEST_FINI(&(recvreq)->req_base.req_ompi); \
367367
opal_convertor_cleanup( &((recvreq)->req_base.req_convertor) ); \
368368
opal_free_list_return ( &mca_pml_base_recv_requests, \

0 commit comments

Comments
 (0)