Updated ompi_buffer_init so that you can force an initial size of buffer
(used by oob_recvs, that need the memory ptr before posting the actual recv) This commit was SVN r2068.
Этот коммит содержится в:
родитель
69b8be7d8c
Коммит
5185e4f006
@ -91,14 +91,18 @@ static void ompi_buffer_destruct (ompi_buffer_internal_t* buffer)
|
||||
*
|
||||
*/
|
||||
|
||||
int ompi_buffer_init (ompi_buffer_t *buffer)
|
||||
int ompi_buffer_init (ompi_buffer_t *buffer, size_t reqinitsize)
|
||||
{
|
||||
ompi_buffer_internal_t* bptr;
|
||||
size_t isize=getpagesize(); /* we should check the mca params here */
|
||||
size_t defaultinitsize = getpagesize(); /* should check the mca params here */
|
||||
size_t isize = 0;
|
||||
|
||||
/* check that we can return a buffer atall.. */
|
||||
if (!buffer) { return (OMPI_ERROR); }
|
||||
|
||||
/* check the requested initial size */
|
||||
if (reqinitsize<0) { return (OMPI_ERROR); }
|
||||
|
||||
/* create new buffer object */
|
||||
bptr = (ompi_buffer_internal_t *) OBJ_NEW (ompi_buffer_internal_t);
|
||||
|
||||
@ -106,8 +110,16 @@ size_t isize=getpagesize(); /* we should check the mca params here */
|
||||
|
||||
ompi_buffer_cnts++;
|
||||
|
||||
|
||||
/* we have a buffer now, so lets populate it */
|
||||
bptr->base_ptr = (void*) malloc (isize); /* BAD fixed initial size */
|
||||
|
||||
/* allocate initial buffer space */
|
||||
if (!reqinitsize) { isize = defaultinitsize; }
|
||||
else { isize = reqinitsize; }
|
||||
|
||||
/* question, should we round upto a page? */
|
||||
|
||||
bptr->base_ptr = (void*) malloc (isize);
|
||||
|
||||
bptr->data_ptr = bptr->base_ptr; /* set the start of the buffer */
|
||||
/* leave from_ptr NULL so we catch an unpack before pack! */
|
||||
@ -215,9 +227,9 @@ ssize_t mdiff; /* difference in memory */
|
||||
size_t sdiff; /* difference (increase) in space */
|
||||
|
||||
/* calculate size of increase by pushing up page count */
|
||||
pages = (increase / (size_t) getpagesize())+1;
|
||||
pages = ((increase+bptr->size) / (size_t) getpagesize())+1;
|
||||
|
||||
newsize = bptr->size + (pages*(size_t)getpagesize());
|
||||
newsize = (pages*(size_t)getpagesize());
|
||||
|
||||
sdiff = newsize - bptr->size; /* actual increase in space */
|
||||
/* have to use relative change as no absolute without */
|
||||
|
@ -47,15 +47,20 @@ extern "C" {
|
||||
* This function creates a managed buffer
|
||||
* users then pack this buffer as many times as needed
|
||||
* as the buffer is managed, we grow it as needed
|
||||
* if the initial requested buffer size is '0' then the system allocates
|
||||
* what it wants. If a size is given then it attempts to get that space
|
||||
* (useful for when receiving a known in advance data size into the buffer)
|
||||
* (hint, as in the oob wrappers)
|
||||
*
|
||||
* @param pointer to new buffer handle
|
||||
* @param pointer to new buffer handle (OUT)
|
||||
* @param to initial buffer size request (IN)
|
||||
*
|
||||
* @retval OMPI_SUCCESS
|
||||
* @retval OMPI_ERROR
|
||||
*
|
||||
*/
|
||||
|
||||
int ompi_buffer_init (ompi_buffer_t *buffer);
|
||||
int ompi_buffer_init (ompi_buffer_t *buffer, size_t reqinitsize);
|
||||
|
||||
/**
|
||||
* This function gets the size of packed data in a ompi_buffer
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user