Skip to content

Commit 4184c01

Browse files
Merge pull request #2393 from bosilca/topic/no_predefined_ddt_refcount
Don't refcount the predefined datatypes.
2 parents 3895c10 + c2cd717 commit 4184c01

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
@@ -92,7 +92,7 @@ static int ompi_osc_pt2pt_dt_send_complete (ompi_request_t *request)
9292
ompi_datatype_t *datatype = (ompi_datatype_t *) request->req_complete_cb_data;
9393
ompi_osc_pt2pt_module_t *module = NULL;
9494

95-
OBJ_RELEASE(datatype);
95+
OMPI_DATATYPE_RELEASE(datatype);
9696

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

373-
OBJ_RETAIN(target_dt);
373+
OMPI_DATATYPE_RETAIN(target_dt);
374374

375375
ret = ompi_osc_pt2pt_isend_w_cb ((void *) packed_ddt, ddt_len, MPI_BYTE,
376376
target, tag_to_target(tag), module->comm,
@@ -539,7 +539,7 @@ ompi_osc_pt2pt_accumulate_w_req (const void *origin_addr, int origin_count,
539539
/* the datatype does not fit in an eager message. send it seperately */
540540
header->base.flags |= OMPI_OSC_PT2PT_HDR_FLAG_LARGE_DATATYPE;
541541

542-
OBJ_RETAIN(target_dt);
542+
OMPI_DATATYPE_RETAIN(target_dt);
543543

544544
ret = ompi_osc_pt2pt_isend_w_cb ((void *) packed_ddt, ddt_len, MPI_BYTE,
545545
target, tag_to_target(tag), module->comm,
@@ -642,7 +642,7 @@ int ompi_osc_pt2pt_compare_and_swap (const void *origin_addr, const void *compar
642642
request->type = OMPI_OSC_PT2PT_HDR_TYPE_CSWAP;
643643
request->origin_addr = origin_addr;
644644
request->internal = true;
645-
OBJ_RETAIN(dt);
645+
OMPI_DATATYPE_RETAIN(dt);
646646
request->origin_dt = dt;
647647

648648
/* Compute datatype and payload lengths. Note that the datatype description
@@ -797,7 +797,7 @@ static inline int ompi_osc_pt2pt_rget_internal (void *origin_addr, int origin_co
797797
pt2pt_request->type = OMPI_OSC_PT2PT_HDR_TYPE_GET;
798798
pt2pt_request->origin_addr = origin_addr;
799799
pt2pt_request->origin_count = origin_count;
800-
OBJ_RETAIN(origin_dt);
800+
OMPI_DATATYPE_RETAIN(origin_dt);
801801
pt2pt_request->origin_dt = origin_dt;
802802

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

850-
OBJ_RETAIN(target_dt);
850+
OMPI_DATATYPE_RETAIN(target_dt);
851851

852852
ret = ompi_osc_pt2pt_isend_w_cb ((void *) packed_ddt, ddt_len, MPI_BYTE,
853853
target, tag_to_target(tag), module->comm,
@@ -1005,7 +1005,7 @@ int ompi_osc_pt2pt_rget_accumulate_internal (const void *origin_addr, int origin
10051005
pt2pt_request->type = OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC;
10061006
pt2pt_request->origin_addr = origin_addr;
10071007
pt2pt_request->origin_count = origin_count;
1008-
OBJ_RETAIN(origin_datatype);
1008+
OMPI_DATATYPE_RETAIN(origin_datatype);
10091009
pt2pt_request->origin_dt = origin_datatype;
10101010

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

1069-
OBJ_RETAIN(target_datatype);
1069+
OMPI_DATATYPE_RETAIN(target_datatype);
10701070

10711071
ret = ompi_osc_pt2pt_isend_w_cb ((void *) packed_ddt, ddt_len, MPI_BYTE,
10721072
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

@@ -119,7 +119,7 @@ static void osc_pt2pt_pending_acc_destructor (osc_pt2pt_pending_acc_t *pending)
119119
}
120120

121121
if (NULL != pending->datatype) {
122-
OBJ_RELEASE(pending->datatype);
122+
OMPI_DATATYPE_RELEASE(pending->datatype);
123123
}
124124
}
125125

@@ -371,7 +371,7 @@ static inline int process_put(ompi_osc_pt2pt_module_t* module, int source,
371371

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

374-
OBJ_RELEASE(datatype);
374+
OMPI_DATATYPE_RELEASE(datatype);
375375

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

411-
OBJ_RELEASE(datatype);
411+
OMPI_DATATYPE_RELEASE(datatype);
412412

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

536-
OBJ_RELEASE(datatype);
536+
OMPI_DATATYPE_RELEASE(datatype);
537537

538538
return OMPI_SUCCESS == ret ? (int) get_header->len : ret;
539539
}
@@ -635,7 +635,7 @@ static int osc_pt2pt_accumulate_allocate (ompi_osc_pt2pt_module_t *module, int p
635635
acc_data->proc = proc;
636636
acc_data->count = count;
637637
acc_data->datatype = datatype;
638-
OBJ_RETAIN(datatype);
638+
OMPI_DATATYPE_RETAIN(datatype);
639639
acc_data->op = op;
640640
acc_data->request_count = request_count;
641641

@@ -734,7 +734,7 @@ static int ompi_osc_pt2pt_acc_op_queue (ompi_osc_pt2pt_module_t *module, ompi_os
734734

735735
/* save the datatype */
736736
pending_acc->datatype = datatype;
737-
OBJ_RETAIN(datatype);
737+
OMPI_DATATYPE_RETAIN(datatype);
738738

739739
/* save the header */
740740
switch (header->base.type) {
@@ -1175,7 +1175,7 @@ static inline int process_acc (ompi_osc_pt2pt_module_t *module, int source,
11751175
}
11761176

11771177
/* Release datatype & op */
1178-
OBJ_RELEASE(datatype);
1178+
OMPI_DATATYPE_RELEASE(datatype);
11791179

11801180
return (OMPI_SUCCESS == ret) ? (int) acc_header->len : ret;
11811181
}
@@ -1207,7 +1207,7 @@ static inline int process_acc_long (ompi_osc_pt2pt_module_t* module, int source,
12071207
}
12081208

12091209
/* Release datatype & op */
1210-
OBJ_RELEASE(datatype);
1210+
OMPI_DATATYPE_RELEASE(datatype);
12111211

12121212
return (OMPI_SUCCESS == ret) ? (int) acc_header->len : ret;
12131213
}
@@ -1242,7 +1242,7 @@ static inline int process_get_acc(ompi_osc_pt2pt_module_t *module, int source,
12421242
uint32_t primitive_count;
12431243
buffer = malloc (data_len);
12441244
if (OPAL_UNLIKELY(NULL == buffer)) {
1245-
OBJ_RELEASE(datatype);
1245+
OMPI_DATATYPE_RELEASE(datatype);
12461246
return OMPI_ERR_OUT_OF_RESOURCE;
12471247
}
12481248

@@ -1261,7 +1261,7 @@ static inline int process_get_acc(ompi_osc_pt2pt_module_t *module, int source,
12611261
}
12621262

12631263
/* Release datatype & op */
1264-
OBJ_RELEASE(datatype);
1264+
OMPI_DATATYPE_RELEASE(datatype);
12651265

12661266
return (OMPI_SUCCESS == ret) ? (int) acc_header->len : ret;
12671267
}
@@ -1293,7 +1293,7 @@ static inline int process_get_acc_long(ompi_osc_pt2pt_module_t *module, int sour
12931293
}
12941294

12951295
/* Release datatype & op */
1296-
OBJ_RELEASE(datatype);
1296+
OMPI_DATATYPE_RELEASE(datatype);
12971297

12981298
return OMPI_SUCCESS == ret ? (int) acc_header->len : ret;
12991299
}
@@ -1326,7 +1326,7 @@ static inline int process_cswap (ompi_osc_pt2pt_module_t *module, int source,
13261326
}
13271327

13281328
/* Release datatype */
1329-
OBJ_RELEASE(datatype);
1329+
OMPI_DATATYPE_RELEASE(datatype);
13301330

13311331
return (OMPI_SUCCESS == ret) ? (int) cswap_header->len : ret;
13321332
}

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)