Added prototypes and headers so people can coding around the msgbuffer interface
This commit was SVN r1282.
Этот коммит содержится в:
родитель
119e15d22d
Коммит
4488a1d8a4
@ -13,7 +13,9 @@ noinst_LTLIBRARIES = libmca_base.la
|
|||||||
headers = \
|
headers = \
|
||||||
base.h \
|
base.h \
|
||||||
mca_base_module_exchange.h \
|
mca_base_module_exchange.h \
|
||||||
mca_base_param.h
|
mca_base_param.h \
|
||||||
|
mca_base_msgbuf.h \
|
||||||
|
mca_base_msgbuf_internal.h
|
||||||
|
|
||||||
# Library
|
# Library
|
||||||
|
|
||||||
@ -29,7 +31,8 @@ libmca_base_la_SOURCES = \
|
|||||||
mca_base_modules_open.c \
|
mca_base_modules_open.c \
|
||||||
mca_base_modules_close.c \
|
mca_base_modules_close.c \
|
||||||
mca_base_open.c \
|
mca_base_open.c \
|
||||||
mca_base_param.c
|
mca_base_param.c \
|
||||||
|
mca_base_msgbuf.c
|
||||||
|
|
||||||
|
|
||||||
# Conditionally install the header files
|
# Conditionally install the header files
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "mca/base/mca_base_param.h"
|
#include "mca/base/mca_base_param.h"
|
||||||
#include "mca/base/mca_base_module_exchange.h"
|
#include "mca/base/mca_base_module_exchange.h"
|
||||||
|
#include "mca/base/mca_base_msgbuf.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
73
src/mca/base/mca_base_msgbuf.c
Обычный файл
73
src/mca/base/mca_base_msgbuf.c
Обычный файл
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* $HEADER$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ompi_config.h"
|
||||||
|
|
||||||
|
#include "util/output.h"
|
||||||
|
#include "mca/mca.h"
|
||||||
|
#include "mca/base/base.h"
|
||||||
|
|
||||||
|
#include "mca/base/mca_base_msgbuf_internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* blank prototypes for now that return unimplemented */
|
||||||
|
|
||||||
|
|
||||||
|
/* get/create a free buffer */
|
||||||
|
/* if reqsize = MCA_BASE_MSGBUF_GETBUF, then the system gives an unlimited buffer. */
|
||||||
|
/* Giving a req size just makes it more memory efficient. */
|
||||||
|
mca_base_msgbuf_t mca_base_msgbuf_new (size_t reqsize)
|
||||||
|
{
|
||||||
|
return ((mca_base_msgbuf_t)OMPI_ERR_NOT_SUPPORTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* make a copy of an existing buffer */
|
||||||
|
/* this is usefull for the registry and is needed as unpack is */
|
||||||
|
/* destructive */
|
||||||
|
mca_base_msgbuf_t mca_base_msgbuf_copy (mca_base_msgbuf_t* copybufid,
|
||||||
|
mca_base_msgbuf_t orgbufid)
|
||||||
|
{
|
||||||
|
return ((mca_base_msgbuf_t)OMPI_ERR_NOT_SUPPORTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set a buffer. As base_pack send/recv handles buffer you might not want */
|
||||||
|
/* to pack a buffer but do a send from memory directly */
|
||||||
|
/* a free on this special buffer just frees its structure not the memory */
|
||||||
|
mca_base_msgbuf_t mca_base_msgbuf_construct (void* ptr, size_t datasize)
|
||||||
|
{
|
||||||
|
return ((mca_base_msgbuf_t)OMPI_ERR_NOT_SUPPORTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* explicit free of a buffer when not auto freeing them */
|
||||||
|
int mca_base_msgbuf_free (mca_base_msgbuf_t bufid)
|
||||||
|
{
|
||||||
|
return OMPI_ERR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* pack and unpack non-string typed data */
|
||||||
|
int mca_base_msgbuf_pack (mca_base_msgbuf_t bufid, void* ptr, size_t num_items,
|
||||||
|
mca_base_msgbuf_data_t datatype)
|
||||||
|
{
|
||||||
|
return OMPI_ERR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mca_base_msgbuf_unpack (mca_base_msgbuf_t bufid, void* ptr,
|
||||||
|
size_t num_items, mca_base_msgbuf_data_t datatype)
|
||||||
|
{
|
||||||
|
return OMPI_ERR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* handles strings */
|
||||||
|
/* note this takes NULL terminated strings and returns null terminated strings */
|
||||||
|
int mca_base_msgbuf_pack_string (mca_base_msgbuf_t bufid, char* strptr)
|
||||||
|
{
|
||||||
|
return OMPI_ERR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mca_base_msgbuf_unpack_string (mca_base_msgbuf_t bufid, char* strptr,
|
||||||
|
size_t maxlen)
|
||||||
|
{
|
||||||
|
return OMPI_ERR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
96
src/mca/base/mca_base_msgbuf.h
Обычный файл
96
src/mca/base/mca_base_msgbuf.h
Обычный файл
@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* $HEADER$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
*
|
||||||
|
* Run-time MCA message buffer interface for packing/unpacking messages
|
||||||
|
* these routines are used by both the OOB and the registry.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OMPI_MCA_BASE_MSGBUF_H
|
||||||
|
#define OMPI_MCA_BASE_MSGBUF_H
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* packed message buffer interface, moved to mca_base so that all MCA modules can
|
||||||
|
* access it
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* exposed interface to the packed message buffer system */
|
||||||
|
typedef enum {
|
||||||
|
MCA_BASE_MSGBUF_BYTE,
|
||||||
|
MCA_BASE_MSGBUF_INT32, MCA_BASE_MSGBUF_INT64, MCA_BASE_MSGBUF_INT128,
|
||||||
|
MCA_BASE_MSGBUF_REAL32, MCA_BASE_MSGBUF_REAL64,
|
||||||
|
MCA_BASE_MSGBUF_PACKED,
|
||||||
|
MCA_BASE_MSGBUF_BYTE_BY_REF
|
||||||
|
} mca_base_msgbuf_data_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The data types are simple and are required for each pack/unpack
|
||||||
|
* The user is expected to unpack the data in the same order as they packed.
|
||||||
|
* The system may or maynot type the message.
|
||||||
|
*
|
||||||
|
* Special types
|
||||||
|
* MCA_BASE_MSGBUF_BYTE does not get converted.
|
||||||
|
* MCA_BASE_MSGBUF_PACKED packs a packed buffer into another buffer.
|
||||||
|
* MCA_BASE_MSGBUF_PACKED should be unpacked into a new buffer (returned in 'ptr').
|
||||||
|
* MCA_BASE_MSGBUF_BYTE_BY_REF only has real meaning during packing. The system would
|
||||||
|
* avoid copying this memory if possible.
|
||||||
|
* The receiver would need to unpack by using either MCA_BASE_MSGBUF_BYTE/_BY_REF.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* the definition of the msgbuf is opaque completely
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct mca_base_msgbuffer_s* mca_base_msgbuf_t;
|
||||||
|
|
||||||
|
|
||||||
|
/* get/create a free buffer */
|
||||||
|
/* if reqsize = MCA_BASE_MSGBUF_GETBUF, then the system gives an unlimited buffer. */
|
||||||
|
/* Giving a req size just makes it more memory efficient. */
|
||||||
|
mca_base_msgbuf_t mca_base_msgbuf_new (size_t reqsize);
|
||||||
|
|
||||||
|
/* make a copy of an existing buffer */
|
||||||
|
/* this is usefull for the registry and is needed as unpack is */
|
||||||
|
/* destructive */
|
||||||
|
mca_base_msgbuf_t mca_base_msgbuf_copy (mca_base_msgbuf_t* copybufid, mca_base_msgbuf_t orgbufid);
|
||||||
|
|
||||||
|
/* set a buffer. As base_pack send/recv handles buffer you might not want */
|
||||||
|
/* to pack a buffer but do a send from memory directly */
|
||||||
|
/* a free on this special buffer just frees its structure not the memory */
|
||||||
|
mca_base_msgbuf_t mca_base_msgbuf_construct (void* ptr, size_t datasize);
|
||||||
|
|
||||||
|
/* explicit free of a buffer when not auto freeing them */
|
||||||
|
int mca_base_msgbuf_free (mca_base_msgbuf_t bufid);
|
||||||
|
|
||||||
|
/* pack and unpack non-string typed data */
|
||||||
|
int mca_base_msgbuf_pack (mca_base_msgbuf_t bufid, void* ptr, size_t num_items, mca_base_msgbuf_data_t datatype);
|
||||||
|
int mca_base_msgbuf_unpack (mca_base_msgbuf_t bufid, void* ptr, size_t num_items, mca_base_msgbuf_data_t datatype);
|
||||||
|
|
||||||
|
/* handles strings */
|
||||||
|
/* note this takes NULL terminated strings and returns null terminated strings */
|
||||||
|
int mca_base_msgbuf_pack_string (mca_base_msgbuf_t bufid, char* strptr);
|
||||||
|
int mca_base_msgbuf_unpack_string (mca_base_msgbuf_t bufid, char* strptr, size_t maxlen);
|
||||||
|
|
||||||
|
|
||||||
|
/* constants */
|
||||||
|
#define MCA_BASE_MSGBUF_NULL_BUFID -1 /* default buffer ID returned when freeing */
|
||||||
|
#define MCA_BASE_MSGBUF_GETBUF -2000 /* default system give me a buffer const */
|
||||||
|
|
||||||
|
/* error codes */
|
||||||
|
#define MCA_BASE_MSGBUF_SUCCESS 0;
|
||||||
|
|
||||||
|
/* buffer error codes */
|
||||||
|
#define MCA_BASE_MSGBUF_BADBUFFER -2010 /* bad buffer id */
|
||||||
|
#define MCA_BASE_MSGBUF_OUTOFBUFFERS -2011 /* no free msg buffers free */
|
||||||
|
#define MCA_BASE_MSGBUF_OUTOFMEMORY -2012 /* cannot allocate any more memory for message buffers */
|
||||||
|
#define MCA_BASE_MSGBUF_BADPARM -2014 /* other parameters are bad/invalid pointers */
|
||||||
|
#define MCA_BASE_MSGBUF_BADDATA -2015 /* to/from data addr is bad (null etc) */
|
||||||
|
|
||||||
|
#endif /* OMPI_MCA_BASE_MSGBUF_H */
|
51
src/mca/base/mca_base_msgbuf_internal.h
Обычный файл
51
src/mca/base/mca_base_msgbuf_internal.h
Обычный файл
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* $HEADER$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
*
|
||||||
|
* Run-time MCA message buffer interface for packing/unpacking messages
|
||||||
|
* these routines are used by both the OOB and the registry.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OMPI_MCA_BASE_MSGBUF_INTERNAL_H
|
||||||
|
#define OMPI_MCA_BASE_MSGBUF_INTERNAL_H
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This contains the internal definitions of the MCA message buffer
|
||||||
|
* data structures
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* this struct is changing to be a ompi_object with a ompi_list inside! */
|
||||||
|
/* and a few locks */
|
||||||
|
struct mca_base_msgbuffer_s {
|
||||||
|
int msg_buff_id; /* internal ID of this buffer */
|
||||||
|
int contiguous; /* if this is a single message buffer */
|
||||||
|
int in_use; /* zero if free, else 1 */
|
||||||
|
int resizable; /* whether we are allowed to remalloc if needed */
|
||||||
|
|
||||||
|
void* base_ptr; /* start of my memory */
|
||||||
|
void* data_ptr; /* location of where next data will go */
|
||||||
|
void* from_ptr; /* location of where to get the next data from */
|
||||||
|
|
||||||
|
/* counters */
|
||||||
|
size_t size; /* total size of this buffer */
|
||||||
|
size_t len; /* total amount already packed */
|
||||||
|
size_t space; /* how much space we have left */
|
||||||
|
/* yep, size=len+space */
|
||||||
|
|
||||||
|
size_t toend; /* how many bytes till the end when unpacking :) */
|
||||||
|
|
||||||
|
#ifdef MCA_BASE_MSGBUF_PROFILING
|
||||||
|
/* specialised counters */
|
||||||
|
long times_sent; /* inc each time we send with it, not used? */
|
||||||
|
long times_freed; /* how many times has this buffer been freed */
|
||||||
|
long times_resized; /* how many times has this buffer been resized */
|
||||||
|
#endif /* used for debugging */
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* OMPI_MCA_BASE_MSGBUF_INTERNAL_H */
|
Загрузка…
x
Ссылка в новой задаче
Block a user