ch3u_rma_ops.c 17.1 KB
Newer Older
1
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 3 4 5 6 7 8
/*
 *  (C) 2001 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */

#include "mpidrma.h"

9 10
static int enableShortACC=1;

11 12 13
MPIR_T_PVAR_DOUBLE_TIMER_DECL_EXTERN(RMA, rma_rmaqueue_alloc);
MPIR_T_PVAR_DOUBLE_TIMER_DECL_EXTERN(RMA, rma_rmaqueue_set);
extern void MPIDI_CH3_RMA_Init_Pvars(void);
14

15 16 17
#define MPIDI_PASSIVE_TARGET_DONE_TAG  348297
#define MPIDI_PASSIVE_TARGET_RMA_TAG 563924

18 19 20 21 22 23 24 25 26 27 28 29
/* 
 * TODO:
 * Explore use of alternate allocation mechanisms for the RMA queue elements
 * (Because profiling has shown that queue element allocation/deallocation
 * can take a significant amount of time in the RMA operations).
 *    1: Current approach (uses perm memory malloc/free)
 *    2: Preallocate and maintain list (use perm memory malloc, but
 *       free onto window; use first; free on window free)
 *    3: Preallocate and maintain list (use separate memory, but free to
 *       thread/process; free in Finalize handler.  Option to use for
 *       single-threaded to avoid thread overheads)
 * Possible interface
30 31
 *    int MPIDI_RMAListAlloc(MPIDI_RMA_Op_t **a,MPID_Win *win)
 *    int MPIDI_RMAListFree(MPIDI_RMA_Op_t *a, MPID_Win *win)
32 33
 *    return value is error code (e.g., allocation failure).
 */
34 35 36 37 38 39 40

#undef FUNCNAME
#define FUNCNAME MPIDI_Win_free
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_Win_free(MPID_Win **win_ptr)
{
Pavan Balaji's avatar
Pavan Balaji committed
41
    int mpi_errno=MPI_SUCCESS;
42
    int in_use;
43
    MPID_Comm *comm_ptr;
44 45 46
    MPIDI_STATE_DECL(MPID_STATE_MPIDI_WIN_FREE);
        
    MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_WIN_FREE);
James Dinan's avatar
James Dinan committed
47 48 49 50

    MPIU_ERR_CHKANDJUMP((*win_ptr)->epoch_state != MPIDI_EPOCH_NONE,
                        mpi_errno, MPI_ERR_RMA_SYNC, "**rmasync");

51 52
    mpi_errno = MPIDI_CH3I_Wait_for_pt_ops_finish(*win_ptr);
    if(mpi_errno) MPIU_ERR_POP(mpi_errno);
53

54
    comm_ptr = (*win_ptr)->comm_ptr;
55 56
    mpi_errno = MPIR_Comm_free_impl(comm_ptr);
    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
57

58
    MPIU_Free((*win_ptr)->targets);
59
    MPIU_Free((*win_ptr)->base_addrs);
60
    MPIU_Free((*win_ptr)->sizes);
61 62 63
    MPIU_Free((*win_ptr)->disp_units);
    MPIU_Free((*win_ptr)->all_win_handles);
    MPIU_Free((*win_ptr)->pt_rma_puts_accs);
64

65
    /* Free the attached buffer for windows created with MPI_Win_allocate() */
66 67
    if ((*win_ptr)->create_flavor == MPI_WIN_FLAVOR_ALLOCATE || (*win_ptr)->create_flavor == MPI_WIN_FLAVOR_SHARED) {
        if ((*win_ptr)->shm_allocated == FALSE && (*win_ptr)->size > 0) {
68
            MPIU_Free((*win_ptr)->base);
69
        }
70 71
    }

72 73 74
    MPIU_Object_release_ref(*win_ptr, &in_use);
    /* MPI windows don't have reference count semantics, so this should always be true */
    MPIU_Assert(!in_use);
75
    MPIU_Handle_obj_free( &MPID_Win_mem, *win_ptr );
76

77 78 79
 fn_exit:
    MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_WIN_FREE);
    return mpi_errno;
80

81
 fn_fail:
82 83
    goto fn_exit;
}
84 85


86 87 88 89 90 91 92 93 94 95 96 97
#undef FUNCNAME
#define FUNCNAME MPIDI_Win_shared_query
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_Win_shared_query(MPID_Win *win_ptr, int target_rank, MPI_Aint *size,
                           int *disp_unit, void *baseptr)
{
    int mpi_errno = MPI_SUCCESS;

    MPIDI_STATE_DECL(MPID_STATE_MPIDI_WIN_SHARED_QUERY);
    MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_WIN_SHARED_QUERY);

98
    *(void**) baseptr = win_ptr->base;
99 100 101 102 103 104 105 106 107 108 109 110 111
    *size             = win_ptr->size;
    *disp_unit        = win_ptr->disp_unit;

 fn_exit:
    MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_WIN_SHARED_QUERY);
    return mpi_errno;
    /* --BEGIN ERROR HANDLING-- */
 fn_fail:
    goto fn_exit;
    /* --END ERROR HANDLING-- */
}


112 113 114 115
#undef FUNCNAME
#define FUNCNAME MPIDI_Put
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
116
int MPIDI_Put(const void *origin_addr, int origin_count, MPI_Datatype
117 118 119 120
            origin_datatype, int target_rank, MPI_Aint target_disp,
            int target_count, MPI_Datatype target_datatype, MPID_Win *win_ptr)
{
    int mpi_errno = MPI_SUCCESS;
121
    int dt_contig ATTRIBUTE((unused)), rank;
122
    MPID_Datatype *dtp;
Pavan Balaji's avatar
Pavan Balaji committed
123
    MPI_Aint dt_true_lb ATTRIBUTE((unused));
124
    MPIDI_msg_sz_t data_sz;
Xin Zhao's avatar
Xin Zhao committed
125
    MPIDI_VC_t *orig_vc, *target_vc;
126 127 128 129
    MPIDI_STATE_DECL(MPID_STATE_MPIDI_PUT);
        
    MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_PUT);

130 131 132 133
    if (target_rank == MPI_PROC_NULL) {
        goto fn_exit;
    }

134
    if (win_ptr->epoch_state == MPIDI_EPOCH_NONE && win_ptr->fence_issued) {
James Dinan's avatar
James Dinan committed
135 136 137 138 139 140
        win_ptr->epoch_state = MPIDI_EPOCH_FENCE;
    }

    MPIU_ERR_CHKANDJUMP(win_ptr->epoch_state == MPIDI_EPOCH_NONE,
                        mpi_errno, MPI_ERR_RMA_SYNC, "**rmasync");

141 142 143
    MPIDI_Datatype_get_info(origin_count, origin_datatype,
			    dt_contig, data_sz, dtp,dt_true_lb); 
    
144
    if (data_sz == 0) {
145 146 147
	goto fn_exit;
    }

148
    rank = win_ptr->comm_ptr->rank;
149
    
Xin Zhao's avatar
Xin Zhao committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163
    if (win_ptr->shm_allocated == TRUE && target_rank != rank && win_ptr->create_flavor != MPI_WIN_FLAVOR_SHARED) {
        /* check if target is local and shared memory is allocated on window,
           if so, we directly perform this operation on shared memory region. */

        /* FIXME: Here we decide whether to perform SHM operations by checking if origin and target are on
           the same node. However, in ch3:sock, even if origin and target are on the same node, they do
           not within the same SHM region. Here we filter out ch3:sock by checking shm_allocated flag first,
           which is only set to TRUE when SHM region is allocated in nemesis.
           In future we need to figure out a way to check if origin and target are in the same "SHM comm".
        */
        MPIDI_Comm_get_vc(win_ptr->comm_ptr, rank, &orig_vc);
        MPIDI_Comm_get_vc(win_ptr->comm_ptr, target_rank, &target_vc);
    }

164
    /* If the put is a local operation, do it here */
Xin Zhao's avatar
Xin Zhao committed
165 166
    if (target_rank == rank || win_ptr->create_flavor == MPI_WIN_FLAVOR_SHARED ||
        (win_ptr->shm_allocated == TRUE && orig_vc->node_id == target_vc->node_id))
167
    {
168 169 170
        mpi_errno = MPIDI_CH3I_Shm_put_op(origin_addr, origin_count, origin_datatype, target_rank,
                                          target_disp, target_count, target_datatype, win_ptr);
        if (mpi_errno) MPIU_ERR_POP(mpi_errno);
171 172 173
    }
    else
    {
174
        MPIDI_RMA_Ops_list_t *ops_list = MPIDI_CH3I_RMA_Get_ops_list(win_ptr, target_rank);
175
        MPIDI_RMA_Op_t *new_ptr = NULL;
176

177
	/* queue it up */
178
        MPIR_T_PVAR_TIMER_START(RMA, rma_rmaqueue_alloc);
179
        mpi_errno = MPIDI_CH3I_RMA_Ops_alloc_tail(ops_list, &new_ptr);
180
        MPIR_T_PVAR_TIMER_END(RMA, rma_rmaqueue_alloc);
181
        if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
182

183
	MPIR_T_PVAR_TIMER_START(RMA, rma_rmaqueue_set);
184
	/* FIXME: For contig and very short operations, use a streamlined op */
185
	new_ptr->type = MPIDI_RMA_PUT;
186
        /* Cast away const'ness for the origin address, as the
187
         * MPIDI_RMA_Op_t structure is used for both PUT and GET like
188 189
         * operations */
	new_ptr->origin_addr = (void *) origin_addr;
190 191 192 193 194 195
	new_ptr->origin_count = origin_count;
	new_ptr->origin_datatype = origin_datatype;
	new_ptr->target_rank = target_rank;
	new_ptr->target_disp = target_disp;
	new_ptr->target_count = target_count;
	new_ptr->target_datatype = target_datatype;
196
	MPIR_T_PVAR_TIMER_END(RMA, rma_rmaqueue_set);
197

198 199
	/* if source or target datatypes are derived, increment their
	   reference counts */
200
	if (!MPIR_DATATYPE_IS_PREDEFINED(origin_datatype))
201 202 203 204
	{
	    MPID_Datatype_get_ptr(origin_datatype, dtp);
	    MPID_Datatype_add_ref(dtp);
	}
205
	if (!MPIR_DATATYPE_IS_PREDEFINED(target_datatype))
206 207 208 209
	{
	    MPID_Datatype_get_ptr(target_datatype, dtp);
	    MPID_Datatype_add_ref(dtp);
	}
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
    }

  fn_exit:
    MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_PUT);    
    return mpi_errno;

    /* --BEGIN ERROR HANDLING-- */
  fn_fail:
    goto fn_exit;
    /* --END ERROR HANDLING-- */
}



#undef FUNCNAME
#define FUNCNAME MPIDI_Get
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_Get(void *origin_addr, int origin_count, MPI_Datatype
            origin_datatype, int target_rank, MPI_Aint target_disp,
            int target_count, MPI_Datatype target_datatype, MPID_Win *win_ptr)
{
    int mpi_errno = MPI_SUCCESS;
    MPIDI_msg_sz_t data_sz;
234
    int dt_contig ATTRIBUTE((unused)), rank;
Pavan Balaji's avatar
Pavan Balaji committed
235
    MPI_Aint dt_true_lb ATTRIBUTE((unused));
236
    MPID_Datatype *dtp;
Xin Zhao's avatar
Xin Zhao committed
237
    MPIDI_VC_t *orig_vc, *target_vc;
238 239 240 241
    MPIDI_STATE_DECL(MPID_STATE_MPIDI_GET);
        
    MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_GET);

242 243 244 245
    if (target_rank == MPI_PROC_NULL) {
        goto fn_exit;
    }

246
    if (win_ptr->epoch_state == MPIDI_EPOCH_NONE && win_ptr->fence_issued) {
James Dinan's avatar
James Dinan committed
247 248 249 250 251 252
        win_ptr->epoch_state = MPIDI_EPOCH_FENCE;
    }

    MPIU_ERR_CHKANDJUMP(win_ptr->epoch_state == MPIDI_EPOCH_NONE,
                        mpi_errno, MPI_ERR_RMA_SYNC, "**rmasync");

253 254 255
    MPIDI_Datatype_get_info(origin_count, origin_datatype,
			    dt_contig, data_sz, dtp, dt_true_lb); 

256
    if (data_sz == 0) {
257 258 259
	goto fn_exit;
    }

260
    rank = win_ptr->comm_ptr->rank;
Xin Zhao's avatar
Xin Zhao committed
261 262 263 264 265 266 267 268 269 270 271 272 273 274

    if (win_ptr->shm_allocated == TRUE && target_rank != rank && win_ptr->create_flavor != MPI_WIN_FLAVOR_SHARED) {
        /* check if target is local and shared memory is allocated on window,
           if so, we directly perform this operation on shared memory region. */

        /* FIXME: Here we decide whether to perform SHM operations by checking if origin and target are on
           the same node. However, in ch3:sock, even if origin and target are on the same node, they do
           not within the same SHM region. Here we filter out ch3:sock by checking shm_allocated flag first,
           which is only set to TRUE when SHM region is allocated in nemesis.
           In future we need to figure out a way to check if origin and target are in the same "SHM comm".
        */
        MPIDI_Comm_get_vc(win_ptr->comm_ptr, rank, &orig_vc);
        MPIDI_Comm_get_vc(win_ptr->comm_ptr, target_rank, &target_vc);
    }
275 276
    
    /* If the get is a local operation, do it here */
Xin Zhao's avatar
Xin Zhao committed
277 278
    if (target_rank == rank || win_ptr->create_flavor == MPI_WIN_FLAVOR_SHARED ||
        (win_ptr->shm_allocated == TRUE && orig_vc->node_id == target_vc->node_id))
279
    {
280 281 282
        mpi_errno = MPIDI_CH3I_Shm_get_op(origin_addr, origin_count, origin_datatype, target_rank,
                                          target_disp, target_count, target_datatype, win_ptr);
        if (mpi_errno) MPIU_ERR_POP(mpi_errno);
283 284 285
    }
    else
    {
286
        MPIDI_RMA_Ops_list_t *ops_list = MPIDI_CH3I_RMA_Get_ops_list(win_ptr, target_rank);
287
        MPIDI_RMA_Op_t *new_ptr = NULL;
288

289
	/* queue it up */
290
        MPIR_T_PVAR_TIMER_START(RMA, rma_rmaqueue_alloc);
291
        mpi_errno = MPIDI_CH3I_RMA_Ops_alloc_tail(ops_list, &new_ptr);
292
        MPIR_T_PVAR_TIMER_END(RMA, rma_rmaqueue_alloc);
293 294
        if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }

295
	MPIR_T_PVAR_TIMER_START(RMA, rma_rmaqueue_set);
296
	/* FIXME: For contig and very short operations, use a streamlined op */
297 298 299 300 301 302 303 304
	new_ptr->type = MPIDI_RMA_GET;
	new_ptr->origin_addr = origin_addr;
	new_ptr->origin_count = origin_count;
	new_ptr->origin_datatype = origin_datatype;
	new_ptr->target_rank = target_rank;
	new_ptr->target_disp = target_disp;
	new_ptr->target_count = target_count;
	new_ptr->target_datatype = target_datatype;
305
	MPIR_T_PVAR_TIMER_END(RMA, rma_rmaqueue_set);
306
	
307 308
	/* if source or target datatypes are derived, increment their
	   reference counts */
309
	if (!MPIR_DATATYPE_IS_PREDEFINED(origin_datatype))
310 311 312 313
	{
	    MPID_Datatype_get_ptr(origin_datatype, dtp);
	    MPID_Datatype_add_ref(dtp);
	}
314
	if (!MPIR_DATATYPE_IS_PREDEFINED(target_datatype))
315 316 317 318
	{
	    MPID_Datatype_get_ptr(target_datatype, dtp);
	    MPID_Datatype_add_ref(dtp);
	}
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
    }

  fn_exit:
    MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_GET);
    return mpi_errno;

    /* --BEGIN ERROR HANDLING-- */
  fn_fail:
    goto fn_exit;
    /* --END ERROR HANDLING-- */
}



#undef FUNCNAME
#define FUNCNAME MPIDI_Accumulate
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
337
int MPIDI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype
338 339 340 341 342 343
                    origin_datatype, int target_rank, MPI_Aint target_disp,
                    int target_count, MPI_Datatype target_datatype, MPI_Op op,
                    MPID_Win *win_ptr)
{
    int mpi_errno=MPI_SUCCESS;
    MPIDI_msg_sz_t data_sz;
344
    int dt_contig ATTRIBUTE((unused)), rank;
Pavan Balaji's avatar
Pavan Balaji committed
345
    MPI_Aint dt_true_lb ATTRIBUTE((unused));
346
    MPID_Datatype *dtp;
Xin Zhao's avatar
Xin Zhao committed
347
    MPIDI_VC_t *orig_vc, *target_vc;
348 349 350 351
    MPIDI_STATE_DECL(MPID_STATE_MPIDI_ACCUMULATE);
    
    MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_ACCUMULATE);

352 353 354 355
    if (target_rank == MPI_PROC_NULL) {
        goto fn_exit;
    }

356
    if (win_ptr->epoch_state == MPIDI_EPOCH_NONE && win_ptr->fence_issued) {
James Dinan's avatar
James Dinan committed
357 358 359 360 361 362
        win_ptr->epoch_state = MPIDI_EPOCH_FENCE;
    }

    MPIU_ERR_CHKANDJUMP(win_ptr->epoch_state == MPIDI_EPOCH_NONE,
                        mpi_errno, MPI_ERR_RMA_SYNC, "**rmasync");

363 364 365
    MPIDI_Datatype_get_info(origin_count, origin_datatype,
			    dt_contig, data_sz, dtp, dt_true_lb);  
    
366
    if (data_sz == 0) {
367 368
	goto fn_exit;
    }
369

370
    rank = win_ptr->comm_ptr->rank;
371
    
Xin Zhao's avatar
Xin Zhao committed
372 373 374 375 376 377 378 379 380 381 382 383 384 385
    if (win_ptr->shm_allocated == TRUE && target_rank != rank && win_ptr->create_flavor != MPI_WIN_FLAVOR_SHARED) {
        /* check if target is local and shared memory is allocated on window,
           if so, we directly perform this operation on shared memory region. */

        /* FIXME: Here we decide whether to perform SHM operations by checking if origin and target are on
           the same node. However, in ch3:sock, even if origin and target are on the same node, they do
           not within the same SHM region. Here we filter out ch3:sock by checking shm_allocated flag first,
           which is only set to TRUE when SHM region is allocated in nemesis.
           In future we need to figure out a way to check if origin and target are in the same "SHM comm".
        */
        MPIDI_Comm_get_vc(win_ptr->comm_ptr, rank, &orig_vc);
        MPIDI_Comm_get_vc(win_ptr->comm_ptr, target_rank, &target_vc);
    }

386
    /* Do =! rank first (most likely branch?) */
Xin Zhao's avatar
Xin Zhao committed
387 388
    if (target_rank == rank || win_ptr->create_flavor == MPI_WIN_FLAVOR_SHARED ||
        (win_ptr->shm_allocated == TRUE && orig_vc->node_id == target_vc->node_id))
389
    {
390 391 392 393
	mpi_errno = MPIDI_CH3I_Shm_acc_op(origin_addr, origin_count, origin_datatype,
					  target_rank, target_disp, target_count, target_datatype,
					  op, win_ptr);
	if (mpi_errno) MPIU_ERR_POP(mpi_errno);
394 395 396
    }
    else
    {
397
        MPIDI_RMA_Ops_list_t *ops_list = MPIDI_CH3I_RMA_Get_ops_list(win_ptr, target_rank);
398
        MPIDI_RMA_Op_t *new_ptr = NULL;
399

400
	/* queue it up */
401
        MPIR_T_PVAR_TIMER_START(RMA, rma_rmaqueue_alloc);
402
        mpi_errno = MPIDI_CH3I_RMA_Ops_alloc_tail(ops_list, &new_ptr);
403
        MPIR_T_PVAR_TIMER_END(RMA, rma_rmaqueue_alloc);
404
        if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
405 406

	/* If predefined and contiguous, use a simplified element */
407 408
	if (MPIR_DATATYPE_IS_PREDEFINED(origin_datatype) &&
            MPIR_DATATYPE_IS_PREDEFINED(target_datatype) && enableShortACC) {
409
	    MPIR_T_PVAR_TIMER_START(RMA, rma_rmaqueue_set);
410 411
	    new_ptr->type = MPIDI_RMA_ACC_CONTIG;
	    /* Only the information needed for the contig/predefined acc */
412
            /* Cast away const'ness for origin_address as
413
             * MPIDI_RMA_Op_t contain both PUT and GET like ops */
414
	    new_ptr->origin_addr = (void *) origin_addr;
415 416 417 418 419 420 421
	    new_ptr->origin_count = origin_count;
	    new_ptr->origin_datatype = origin_datatype;
	    new_ptr->target_rank = target_rank;
	    new_ptr->target_disp = target_disp;
	    new_ptr->target_count = target_count;
	    new_ptr->target_datatype = target_datatype;
	    new_ptr->op = op;
422
	    MPIR_T_PVAR_TIMER_END(RMA, rma_rmaqueue_set);
423
	    goto fn_exit;
424
	}
425

426
	MPIR_T_PVAR_TIMER_START(RMA, rma_rmaqueue_set);
427
	new_ptr->type = MPIDI_RMA_ACCUMULATE;
428
        /* Cast away const'ness for origin_address as MPIDI_RMA_Op_t
429 430
         * contain both PUT and GET like ops */
	new_ptr->origin_addr = (void *) origin_addr;
431 432 433 434 435 436 437
	new_ptr->origin_count = origin_count;
	new_ptr->origin_datatype = origin_datatype;
	new_ptr->target_rank = target_rank;
	new_ptr->target_disp = target_disp;
	new_ptr->target_count = target_count;
	new_ptr->target_datatype = target_datatype;
	new_ptr->op = op;
438
	MPIR_T_PVAR_TIMER_END(RMA, rma_rmaqueue_set);
439
	
440 441
	/* if source or target datatypes are derived, increment their
	   reference counts */
442
	if (!MPIR_DATATYPE_IS_PREDEFINED(origin_datatype))
443 444 445 446
	{
	    MPID_Datatype_get_ptr(origin_datatype, dtp);
	    MPID_Datatype_add_ref(dtp);
	}
447
	if (!MPIR_DATATYPE_IS_PREDEFINED(target_datatype))
448 449 450 451
	{
	    MPID_Datatype_get_ptr(target_datatype, dtp);
	    MPID_Datatype_add_ref(dtp);
	}
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
    }

 fn_exit:
    MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_ACCUMULATE);
    return mpi_errno;

    /* --BEGIN ERROR HANDLING-- */
  fn_fail:
    goto fn_exit;
    /* --END ERROR HANDLING-- */
}


#undef FUNCNAME
#define FUNCNAME MPIDI_Alloc_mem
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
void *MPIDI_Alloc_mem( size_t size, MPID_Info *info_ptr )
{
    void *ap;
    MPIDI_STATE_DECL(MPID_STATE_MPIDI_ALLOC_MEM);

    MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_ALLOC_MEM);

    ap = MPIU_Malloc(size);
    
    MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_ALLOC_MEM);
    return ap;
}


#undef FUNCNAME
#define FUNCNAME MPIDI_Free_mem
#undef FCNAME
#define FCNAME MPIDI_QUOTE(FUNCNAME)
int MPIDI_Free_mem( void *ptr )
{
    int mpi_errno = MPI_SUCCESS;
    MPIDI_STATE_DECL(MPID_STATE_MPIDI_FREE_MEM);

    MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_FREE_MEM);

    MPIU_Free(ptr);
    
    MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_FREE_MEM);
    return mpi_errno;
}