1
1

inline the write to head function.

This commit was SVN r3573.
Этот коммит содержится в:
Rich Graham 2004-11-16 04:21:30 +00:00
родитель 06cfa4ee84
Коммит f00e702a07

Просмотреть файл

@ -495,77 +495,80 @@ static inline int ompi_fifo_write_to_slot_same_base_addr(cb_slot_t *slot,
* @returncode Slot index to which data is written * @returncode Slot index to which data is written
* *
*/ */
/*
static inline int ompi_fifo_write_to_head_same_base_addr(void *data, static inline int ompi_fifo_write_to_head_same_base_addr(void *data,
ompi_fifo_t *fifo, mca_mpool_base_module_t *fifo_allocator) ompi_fifo_t *fifo, mca_mpool_base_module_t *fifo_allocator)
{ */
int error_code=OMPI_SUCCESS; #define ompi_fifo_write_to_head_same_base_addr(data, \
size_t len_to_allocate; fifo, fifo_allocator) \
ompi_cb_fifo_wrapper_t *next_ff; ({ \
bool available; int error_code=OMPI_SUCCESS; \
size_t len_to_allocate; \
/* attempt to write data to head ompi_fifo_cb_fifo_t */ ompi_cb_fifo_wrapper_t *next_ff; \
error_code=ompi_cb_fifo_write_to_head_same_base_addr(data, bool available; \
(ompi_cb_fifo_t *)&(fifo->head->cb_fifo)); \
if( OMPI_CB_ERROR == error_code ) { /* attempt to write data to head ompi_fifo_cb_fifo_t */ \
/* error_code=ompi_cb_fifo_write_to_head_same_base_addr(data, \
* queue is full (ompi_cb_fifo_t *)&(fifo->head->cb_fifo)); \
*/ if( OMPI_CB_ERROR == error_code ) { \
/* \
/* mark queue as overflown */ * queue is full \
fifo->head->cb_overflow=true; */ \
\
/* see if next queue is available - while the next queue /* mark queue as overflown */ \
* has not been emptied, it will be marked as overflowen*/ fifo->head->cb_overflow=true; \
next_ff=(ompi_cb_fifo_wrapper_t *)fifo->head->next_fifo_wrapper; \
available=!(next_ff->cb_overflow); /* see if next queue is available - while the next queue \
* has not been emptied, it will be marked as overflowen*/ \
/* if next queue not available, allocate new queue */ next_ff=(ompi_cb_fifo_wrapper_t *)fifo->head->next_fifo_wrapper; \
if( !available ) { available=!(next_ff->cb_overflow); \
\
/* allocate head ompi_cb_fifo_t structure */ /* if next queue not available, allocate new queue */ \
len_to_allocate=sizeof(ompi_cb_fifo_wrapper_t); if( !available ) { \
next_ff=fifo_allocator->mpool_alloc \
(len_to_allocate,CACHE_LINE_SIZE); /* allocate head ompi_cb_fifo_t structure */ \
if ( NULL == next_ff) { len_to_allocate=sizeof(ompi_cb_fifo_wrapper_t); \
return OMPI_ERR_OUT_OF_RESOURCE; next_ff=fifo_allocator->mpool_alloc \
} (len_to_allocate,CACHE_LINE_SIZE); \
if ( NULL == next_ff) { \
/* initialize the circular buffer fifo head structure */ return OMPI_ERR_OUT_OF_RESOURCE; \
error_code=ompi_cb_fifo_init_same_base_addr( } \
fifo->head->cb_fifo.size, \
fifo->head->cb_fifo.lazy_free_frequency, /* initialize the circular buffer fifo head structure */ \
fifo->head->cb_fifo.fifo_memory_locality_index, error_code=ompi_cb_fifo_init_same_base_addr( \
fifo->head->cb_fifo.head_memory_locality_index, fifo->head->cb_fifo.size, \
fifo->head->cb_fifo.tail_memory_locality_index, fifo->head->cb_fifo.lazy_free_frequency, \
&(next_ff->cb_fifo), fifo->head->cb_fifo.fifo_memory_locality_index, \
fifo_allocator); fifo->head->cb_fifo.head_memory_locality_index, \
if ( OMPI_SUCCESS != error_code ) { fifo->head->cb_fifo.tail_memory_locality_index, \
return error_code; &(next_ff->cb_fifo), \
} fifo_allocator); \
if ( OMPI_SUCCESS != error_code ) { \
return error_code; \
/* finish new element initialization */ } \
next_ff->next_fifo_wrapper=fifo->head->next_fifo_wrapper; /* only one \
element in the /* finish new element initialization */ \
link list */ next_ff->next_fifo_wrapper=fifo->head->next_fifo_wrapper; /* only one \
next_ff->cb_overflow=false; /* no attempt to overflow the queue */ element in the \
} link list */ \
next_ff->cb_overflow=false; /* no attempt to overflow the queue */ \
/* reset head pointer */ } \
fifo->head->next_fifo_wrapper=next_ff; \
fifo->head=next_ff; /* reset head pointer */ \
fifo->head->next_fifo_wrapper=next_ff; \
/* write data to new head structure */ fifo->head=next_ff; \
error_code=ompi_cb_fifo_write_to_head_same_base_addr(data, \
(ompi_cb_fifo_t *)&(fifo->head->cb_fifo)); /* write data to new head structure */ \
if( OMPI_CB_ERROR == error_code ) { error_code=ompi_cb_fifo_write_to_head_same_base_addr(data, \
return error_code; (ompi_cb_fifo_t *)&(fifo->head->cb_fifo)); \
} if( OMPI_CB_ERROR == error_code ) { \
} return error_code; \
} \
/* return */ } \
return error_code; \
} /* return */ \
error_code; \
}) \
/** /**