📄 mpid_nem_inline.h
字号:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//* * (C) 2006 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. */#ifdef MPID_NEM_DONT_INLINE_FUNCTIONS#undef MPID_NEM_INLINE_DECL#define MPID_NEM_INLINE_DECL#undef _MPID_NEM_INLINE_H /* ok to include again: we're including the non-inline functions in a .c file */#else#define MPID_NEM_INLINE_DECL extern inline#endif#ifndef _MPID_NEM_INLINE_H#define _MPID_NEM_INLINE_H#define MPID_NEM_POLLS_BEFORE_YIELD 1000#include "my_papi_defs.h"extern int MPID_nem_lmt_shm_pending;extern MPID_nem_cell_ptr_t MPID_nem_prefetched_cell;MPID_NEM_INLINE_DECL int MPID_nem_mpich2_send_header (void* buf, int size, MPIDI_VC_t *vc, int *again);MPID_NEM_INLINE_DECL int MPID_nem_mpich2_sendv (struct iovec **iov, int *n_iov, MPIDI_VC_t *vc, int *again);MPID_NEM_INLINE_DECL int MPID_nem_mpich2_dequeue_fastbox (int local_rank);MPID_NEM_INLINE_DECL int MPID_nem_mpich2_enqueue_fastbox (int local_rank);MPID_NEM_INLINE_DECL int MPID_nem_mpich2_sendv_header (struct iovec **iov, int *n_iov, MPIDI_VC_t *vc, int *again);MPID_NEM_INLINE_DECL int MPID_nem_recv_seqno_matches (MPID_nem_queue_ptr_t qhead);MPID_NEM_INLINE_DECL int MPID_nem_mpich2_test_recv (MPID_nem_cell_ptr_t *cell, int *in_fbox);MPID_NEM_INLINE_DECL int MPID_nem_mpich2_blocking_recv (MPID_nem_cell_ptr_t *cell, int *in_fbox);MPID_NEM_INLINE_DECL int MPID_nem_mpich2_test_recv_wait (MPID_nem_cell_ptr_t *cell, int *in_fbox, int timeout);MPID_NEM_INLINE_DECL int MPID_nem_mpich2_release_cell (MPID_nem_cell_ptr_t cell, MPIDI_VC_t *vc);MPID_NEM_INLINE_DECL void MPID_nem_mpich2_send_seg_header (MPID_Segment *segment, MPIDI_msg_sz_t *segment_first, MPIDI_msg_sz_t segment_size, void *header, MPIDI_msg_sz_t header_sz, MPIDI_VC_t *vc, int *again);MPID_NEM_INLINE_DECL void MPID_nem_mpich2_send_seg (MPID_Segment *segment, MPIDI_msg_sz_t *segment_first, MPIDI_msg_sz_t segment_size, MPIDI_VC_t *vc, int *again);/* MPID_nem_mpich2_send_header (void* buf, int size, MPIDI_VC_t *vc) same as above, but sends MPICH2 32 byte header */#undef FUNCNAME#define FUNCNAME MPID_nem_mpich2_send_header#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)MPID_NEM_INLINE_DECL intMPID_nem_mpich2_send_header (void* buf, int size, MPIDI_VC_t *vc, int *again){ int mpi_errno = MPI_SUCCESS; MPID_nem_cell_ptr_t el; int my_rank; MPIDI_CH3I_VC *vc_ch = (MPIDI_CH3I_VC *)vc->channel_private;#ifdef ENABLED_CHECKPOINTING if (MPID_nem_ckpt_sending_markers) { MPID_nem_ckpt_send_markers(); goto return_again; }#endif /*DO_PAPI (PAPI_reset (PAPI_EventSet)); */ MPIU_Assert (size == sizeof(MPIDI_CH3_Pkt_t)); my_rank = MPID_nem_mem_region.rank;#ifdef USE_FASTBOX if (vc_ch->is_local) { MPID_nem_fbox_mpich2_t *pbox = vc_ch->fbox_out; int count = 10; u_int32_t *payload_32 = (u_int32_t *)pbox->cell.pkt.mpich2.payload; u_int32_t *buf_32 = (u_int32_t *)buf;#ifdef BLOCKING_FBOX MPID_nem_waitforlock ((MPID_nem_fbox_common_ptr_t)pbox, 0, count);#else /*BLOCKING_FBOX */ if (MPID_nem_islocked ((MPID_nem_fbox_common_ptr_t)pbox, 0, count)) goto usequeue_l;#endif /*BLOCKING_FBOX */ { pbox->cell.pkt.mpich2.source = MPID_nem_mem_region.local_rank; pbox->cell.pkt.mpich2.datalen = size; pbox->cell.pkt.mpich2.seqno = vc_ch->send_seqno++;#ifdef ENABLED_CHECKPOINTING pbox->cell.pkt.mpich2.datalen = size; pbox->cell.pkt.mpich2.type = MPID_NEM_PKT_MPICH2;#endif /* ENABLED_CHECKPOINTING */ MPIU_DBG_STMT (CH3_CHANNEL, VERBOSE, pbox->cell.pkt.mpich2.type = MPID_NEM_PKT_MPICH2_HEAD); payload_32[0] = buf_32[0]; payload_32[1] = buf_32[1]; payload_32[2] = buf_32[2]; payload_32[3] = buf_32[3]; payload_32[4] = buf_32[4]; payload_32[5] = buf_32[5]; payload_32[6] = buf_32[6]; payload_32[7] = buf_32[7]; if (sizeof(MPIDI_CH3_Pkt_t) == 40) /* This conditional should be optimized out */ { payload_32[8] = buf_32[8]; payload_32[9] = buf_32[9]; } MPID_NEM_WRITE_BARRIER(); pbox->flag.value = 1; MPIU_DBG_MSG (CH3_CHANNEL, VERBOSE, "--> Sent fbox "); MPIU_DBG_STMT (CH3_CHANNEL, VERBOSE, MPID_nem_dbg_dump_cell (&pbox->cell)); goto return_success; } } usequeue_l:#endif /*USE_FASTBOX */ #ifdef PREFETCH_CELL DO_PAPI (PAPI_reset (PAPI_EventSet)); el = MPID_nem_prefetched_cell; if (!el) { if (MPID_nem_queue_empty (MPID_nem_mem_region.my_freeQ)) goto return_again; MPID_nem_queue_dequeue (MPID_nem_mem_region.my_freeQ, &el); } DO_PAPI (PAPI_accum_var (PAPI_EventSet, PAPI_vvalues14));#else /* PREFETCH_CELL */ DO_PAPI (PAPI_reset (PAPI_EventSet)); if (MPID_nem_queue_empty (MPID_nem_mem_region.my_freeQ)) { goto return_again; } DO_PAPI (PAPI_accum_var (PAPI_EventSet, PAPI_vvalues14)); DO_PAPI (PAPI_reset (PAPI_EventSet)); MPID_nem_queue_dequeue (MPID_nem_mem_region.my_freeQ , &el); DO_PAPI (PAPI_accum_var (PAPI_EventSet, PAPI_vvalues10));#endif /* PREFETCH_CELL */ DO_PAPI (PAPI_reset (PAPI_EventSet)); el->pkt.mpich2.source = my_rank; el->pkt.mpich2.dest = vc->lpid; el->pkt.mpich2.datalen = size; el->pkt.mpich2.seqno = vc_ch->send_seqno++;#ifdef ENABLED_CHECKPOINTING el->pkt.mpich2.type = MPID_NEM_PKT_MPICH2;#endif MPIU_DBG_STMT (CH3_CHANNEL, VERBOSE, el->pkt.mpich2.type = MPID_NEM_PKT_MPICH2_HEAD); #if 1 ((u_int32_t *)(el->pkt.mpich2.payload))[0] = ((u_int32_t *)buf)[0]; ((u_int32_t *)(el->pkt.mpich2.payload))[1] = ((u_int32_t *)buf)[1]; ((u_int32_t *)(el->pkt.mpich2.payload))[2] = ((u_int32_t *)buf)[2]; ((u_int32_t *)(el->pkt.mpich2.payload))[3] = ((u_int32_t *)buf)[3]; ((u_int32_t *)(el->pkt.mpich2.payload))[4] = ((u_int32_t *)buf)[4]; ((u_int32_t *)(el->pkt.mpich2.payload))[5] = ((u_int32_t *)buf)[5]; ((u_int32_t *)(el->pkt.mpich2.payload))[6] = ((u_int32_t *)buf)[6]; ((u_int32_t *)(el->pkt.mpich2.payload))[7] = ((u_int32_t *)buf)[7]; if (sizeof(MPIDI_CH3_Pkt_t) == 40) /* This conditional should be optimized out */ { ((u_int32_t *)(el->pkt.mpich2.payload))[8] = ((u_int32_t *)buf)[8]; ((u_int32_t *)(el->pkt.mpich2.payload))[9] = ((u_int32_t *)buf)[9]; }#else /*1 */ MPID_NEM_MEMCPY (el->pkt.mpich2.payload, buf, size);#endif /*1 */ DO_PAPI (PAPI_accum_var (PAPI_EventSet, PAPI_vvalues11)); MPIU_DBG_MSG (CH3_CHANNEL, VERBOSE, "--> Sent queue"); MPIU_DBG_STMT (CH3_CHANNEL, VERBOSE, MPID_nem_dbg_dump_cell (el)); DO_PAPI (PAPI_reset (PAPI_EventSet)); if (vc_ch->is_local) { MPID_nem_queue_enqueue (vc_ch->recv_queue, el); /*MPID_nem_rel_dump_queue( vc_ch->recv_queue ); */ } else { mpi_errno = MPID_nem_net_module_send (vc, el, size); if (mpi_errno) MPIU_ERR_POP (mpi_errno); } DO_PAPI (PAPI_accum_var (PAPI_EventSet, PAPI_vvalues12)); DO_PAPI (PAPI_reset (PAPI_EventSet)); #ifdef PREFETCH_CELL DO_PAPI (PAPI_reset (PAPI_EventSet)); if (!MPID_nem_queue_empty (MPID_nem_mem_region.my_freeQ)) MPID_nem_queue_dequeue (MPID_nem_mem_region.my_freeQ, &MPID_nem_prefetched_cell); else MPID_nem_prefetched_cell = 0; DO_PAPI (PAPI_accum_var (PAPI_EventSet, PAPI_vvalues10));#endif /*PREFETCH_CELL */ /*DO_PAPI (PAPI_accum_var (PAPI_EventSet, PAPI_vvalues14)); */ return_success: *again = 0; goto fn_exit; return_again: *again = 1; goto fn_exit; fn_exit: return mpi_errno; fn_fail: goto fn_exit;}/* int MPID_nem_mpich2_sendv (struct iovec **iov, int *n_iov, MPIDI_VC_t *vc); sends iov to vc Non-blocking if iov specifies more than MPID_NEM_MPICH2_DATA_LEN of data, the iov will be truncated, so that after MPID_nem_mpich2_sendv returns, iov will describe unsent data sets again to 1 if it can't get a free cell, 0 otherwise*/#undef FUNCNAME#define FUNCNAME MPID_nem_mpich2_sendv#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)MPID_NEM_INLINE_DECL intMPID_nem_mpich2_sendv (struct iovec **iov, int *n_iov, MPIDI_VC_t *vc, int *again){ int mpi_errno = MPI_SUCCESS; MPID_nem_cell_ptr_t el; char *cell_buf; MPIDI_msg_sz_t payload_len; int my_rank; MPIDI_CH3I_VC *vc_ch = (MPIDI_CH3I_VC *)vc->channel_private; MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_MPICH2_SENDV); MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_MPICH2_SENDV); MPIU_Assert (*n_iov > 0 && (*iov)->iov_len > 0); #ifdef ENABLED_CHECKPOINTING if (MPID_nem_ckpt_sending_markers) { MPID_nem_ckpt_send_markers(); goto return_again; }#endif DO_PAPI (PAPI_reset (PAPI_EventSet)); my_rank = MPID_nem_mem_region.rank; #ifdef PREFETCH_CELL el = MPID_nem_prefetched_cell; if (!el) { if (MPID_nem_queue_empty (MPID_nem_mem_region.my_freeQ)) { DO_PAPI (PAPI_accum_var (PAPI_EventSet, PAPI_vvalues5)); goto return_again; } MPID_nem_queue_dequeue (MPID_nem_mem_region.my_freeQ, &el); }#else /*PREFETCH_CELL */ if (MPID_nem_queue_empty (MPID_nem_mem_region.my_freeQ)) { DO_PAPI (PAPI_accum_var (PAPI_EventSet, PAPI_vvalues5)); goto return_again; } MPID_nem_queue_dequeue (MPID_nem_mem_region.my_freeQ , &el);#endif /*PREFETCH_CELL */ payload_len = MPID_NEM_MPICH2_DATA_LEN; cell_buf = (char *) el->pkt.mpich2.payload; /* cast away volatile */ while (*n_iov && payload_len >= (*iov)->iov_len) { int _iov_len = (*iov)->iov_len; MPID_NEM_MEMCPY (cell_buf, (*iov)->iov_base, _iov_len); payload_len -= _iov_len; cell_buf += _iov_len; --(*n_iov); ++(*iov); } if (*n_iov && payload_len > 0) { MPID_NEM_MEMCPY (cell_buf, (*iov)->iov_base, payload_len); (*iov)->iov_base = (char *)(*iov)->iov_base + payload_len; (*iov)->iov_len -= payload_len; payload_len = 0; } el->pkt.mpich2.source = my_rank; el->pkt.mpich2.dest = vc->lpid; el->pkt.mpich2.datalen = MPID_NEM_MPICH2_DATA_LEN - payload_len; el->pkt.mpich2.seqno = vc_ch->send_seqno++;#ifdef ENABLED_CHECKPOINTING el->pkt.mpich2.type = MPID_NEM_PKT_MPICH2;#endif MPIU_DBG_STMT (CH3_CHANNEL, VERBOSE, el->pkt.mpich2.type = MPID_NEM_PKT_MPICH2); MPIU_DBG_MSG (CH3_CHANNEL, VERBOSE, "--> Sent queue"); MPIU_DBG_STMT (CH3_CHANNEL, VERBOSE, MPID_nem_dbg_dump_cell (el)); if(vc_ch->is_local) { MPID_nem_queue_enqueue (vc_ch->recv_queue, el); /*MPID_nem_rel_dump_queue( vc_ch->recv_queue ); */ } else { mpi_errno = MPID_nem_net_module_send (vc, el, MPID_NEM_MPICH2_DATA_LEN - payload_len); if (mpi_errno) MPIU_ERR_POP (mpi_errno); }#ifdef PREFETCH_CELL if (!MPID_nem_queue_empty (MPID_nem_mem_region.my_freeQ)) MPID_nem_queue_dequeue (MPID_nem_mem_region.my_freeQ, &MPID_nem_prefetched_cell); else MPID_nem_prefetched_cell = 0;#endif /*PREFETCH_CELL */ DO_PAPI (PAPI_accum_var (PAPI_EventSet, PAPI_vvalues5)); *again = 0; goto fn_exit; return_again: *again = 1; goto fn_exit; fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_MPICH2_SENDV); return mpi_errno; fn_fail: goto fn_exit;}/* MPID_nem_mpich2_sendv_header (struct iovec **iov, int *n_iov, int dest) same as above but first iov element is an MPICH2 32 byte header */#undef FUNCNAME#define FUNCNAME MPID_nem_mpich2_sendv_header#undef FCNAME#define FCNAME MPIDI_QUOTE(FUNCNAME)MPID_NEM_INLINE_DECL intMPID_nem_mpich2_sendv_header (struct iovec **iov, int *n_iov, MPIDI_VC_t *vc, int *again){ int mpi_errno = MPI_SUCCESS; MPID_nem_cell_ptr_t el; char *cell_buf; MPIDI_msg_sz_t payload_len; int my_rank; MPIDI_CH3I_VC *vc_ch = (MPIDI_CH3I_VC *)vc->channel_private; MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_MPICH2_SENDV_HEADER); MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_MPICH2_SENDV_HEADER);#ifdef ENABLED_CHECKPOINTING if (MPID_nem_ckpt_sending_markers) { MPID_nem_ckpt_send_markers(); goto return_again; }#endif DO_PAPI (PAPI_reset (PAPI_EventSet)); MPIU_Assert (*n_iov > 0 && (*iov)->iov_len == sizeof(MPIDI_CH3_Pkt_t)); my_rank = MPID_nem_mem_region.rank;#ifdef USE_FASTBOX if (vc_ch->is_local && (*n_iov == 2 && (*iov)[1].iov_len + sizeof(MPIDI_CH3_Pkt_t) <= MPID_NEM_FBOX_DATALEN)) { MPID_nem_fbox_mpich2_t *pbox = vc_ch->fbox_out; int count = 10; u_int32_t *payload_32 = (u_int32_t *)(pbox->cell.pkt.mpich2.payload ) ; u_int32_t *buf_32 = (u_int32_t *)(*iov)->iov_base;#ifdef BLOCKING_FBOX DO_PAPI3 (PAPI_reset (PAPI_EventSet)); MPID_nem_waitforlock ((MPID_nem_fbox_common_ptr_t)pbox, 0, count);#else /*BLOCKING_FBOX */ if (MPID_nem_islocked ((MPID_nem_fbox_common_ptr_t)pbox, 0, count)) goto usequeue_l;#endif /*BLOCKING_FBOX */ { pbox->cell.pkt.mpich2.source = MPID_nem_mem_region.local_rank; pbox->cell.pkt.mpich2.datalen = (*iov)[1].iov_len + sizeof(MPIDI_CH3_Pkt_t); pbox->cell.pkt.mpich2.seqno = vc_ch->send_seqno++;#ifdef ENABLED_CHECKPOINTING pbox->cell.pkt.mpich2.datalen = (*iov)[1].iov_len + sizeof(MPIDI_CH3_Pkt_t); pbox->cell.pkt.mpich2.type = MPID_NEM_PKT_MPICH2;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -