more changes to the tcp oob:
- changed the msg structure so it has a pointer to the process name and not the peer structure. This was done because on the receive side once a message has been read in it is no longer associated with a peer but rather just a process name. - changed the lookup function to include a bool to determine whether to get the main tcp oob lock or not. This is useful if the caller already holds the lock. - first cut of recv functions - documentation updates This commit was SVN r1747.
Этот коммит содержится в:
родитель
97d34f285f
Коммит
02b99c1971
@ -6,15 +6,14 @@
|
||||
/*
|
||||
* Similiar to unix recv(2)
|
||||
*
|
||||
* @param peer (IN) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param types (IN) Parallel array to iovecs describing data type of each iovec element.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to the number of bytes provided in the
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to the number of bytes provided in the
|
||||
* iovec array without removing the message from the queue.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
*/
|
||||
|
||||
int mca_oob_recv(ompi_process_name_t* peer, const struct iovec *msg, int count, int flags)
|
||||
{
|
||||
return(mca_oob.oob_recv(peer, msg, count, flags));
|
||||
@ -23,15 +22,14 @@ int mca_oob_recv(ompi_process_name_t* peer, const struct iovec *msg, int count,
|
||||
/*
|
||||
* Receive data and convert (if required) to host byte order.
|
||||
*
|
||||
* @param peer (IN) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param types (IN) Parallel array to iovecs describing data type of each iovec element.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to the number of bytes provided in the
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to the number of bytes provided in the
|
||||
* iovec array without removing the message from the queue.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
*/
|
||||
|
||||
int mca_oob_recv_ntoh(ompi_process_name_t* peer, const struct iovec *msg,
|
||||
const mca_oob_base_type_t *types, int count, int flags)
|
||||
{
|
||||
|
@ -52,15 +52,14 @@ static void mca_oob_base_recv_cb(int status, const ompi_process_name_t* peer,
|
||||
/*
|
||||
* Non-blocking version of mca_oob_recv_nb().
|
||||
*
|
||||
* @param peer (IN) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param cbfunc (IN) Callback function on recv completion.
|
||||
* @param cbdata (IN) User data that is passed to callback function.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
*/
|
||||
|
||||
int mca_oob_recv_nb(ompi_process_name_t* peer, const struct iovec* msg, int count, int flags,
|
||||
mca_oob_callback_fn_t cbfunc, void* cbdata)
|
||||
{
|
||||
@ -70,11 +69,11 @@ int mca_oob_recv_nb(ompi_process_name_t* peer, const struct iovec* msg, int coun
|
||||
/*
|
||||
* Non-blocking version of mca_oob_recv_ntoh().
|
||||
*
|
||||
* @param peer (IN/OUT) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN/OUT) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param types (IN) Parallel array to iovecs describing data type of each iovec element.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param cbfunc (IN) Callback function on recv completion.
|
||||
* @param cbdata (IN) User data that is passed to callback function.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
|
@ -93,10 +93,10 @@ int mca_oob_send_hton(
|
||||
/**
|
||||
* Similiar to unix readv(2)
|
||||
*
|
||||
* @param peer (IN) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to the number of bytes provided in the
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to the number of bytes provided in the
|
||||
* iovec array without removing the message from the queue.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
*/
|
||||
@ -106,11 +106,11 @@ int mca_oob_recv(ompi_process_name_t* peer, const struct iovec *msg, int count,
|
||||
/**
|
||||
* Receive data and convert (if required) to host byte order.
|
||||
*
|
||||
* @param peer (IN) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param types (IN) Parallel array to iovecs describing data type of each iovec element.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to the number of bytes provided in the
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to the number of bytes provided in the
|
||||
* iovec array without removing the message from the queue.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
*/
|
||||
@ -191,10 +191,10 @@ int mca_oob_send_hton_nb(
|
||||
/**
|
||||
* Non-blocking version of mca_oob_recv().
|
||||
*
|
||||
* @param peer (IN) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param cbfunc (IN) Callback function on recv completion.
|
||||
* @param cbdata (IN) User data that is passed to callback function.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
@ -211,11 +211,11 @@ int mca_oob_recv_nb(
|
||||
/**
|
||||
* Non-blocking version of mca_oob_recv_ntoh().
|
||||
*
|
||||
* @param peer (IN/OUT) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN/OUT) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param types (IN) Parallel array to iovecs describing data type of each iovec element.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param cbfunc (IN) Callback function on recv completion.
|
||||
* @param cbdata (IN) User data that is passed to callback function.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
@ -257,11 +257,11 @@ typedef int (*mca_oob_base_send_fn_t)(
|
||||
/**
|
||||
* Implementation of mca_oob_recv().
|
||||
*
|
||||
* @param peer (IN) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param types (IN) Parallel array to iovecs describing data type of each iovec element.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to the number of bytes provided in the
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to the number of bytes provided in the
|
||||
* iovec array without removing the message from the queue.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
*/
|
||||
@ -296,10 +296,10 @@ typedef int (*mca_oob_base_send_nb_fn_t)(
|
||||
/**
|
||||
* Implementation of mca_oob_recv_nb().
|
||||
*
|
||||
* @param peer (IN) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param cbfunc (IN) Callback function on recv completion.
|
||||
* @param cbdata (IN) User data that is passed to callback function.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
|
@ -49,15 +49,15 @@ int mca_oob_tcp_send(const ompi_process_name_t* peer, const struct iovec *msg, i
|
||||
/**
|
||||
* Similiar to unix readv(2)
|
||||
*
|
||||
* @param peer (IN) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to the number of bytes provided in the
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to the number of bytes provided in the
|
||||
* iovec array without removing the message from the queue.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
*/
|
||||
|
||||
int mca_oob_tcp_recv(ompi_process_name_t* peer, const struct iovec *msg, int count, int flags);
|
||||
int mca_oob_tcp_recv(ompi_process_name_t* peer, const struct iovec *iov, int count, int flags);
|
||||
|
||||
|
||||
/*
|
||||
@ -77,22 +77,22 @@ int mca_oob_tcp_recv(ompi_process_name_t* peer, const struct iovec *msg, int cou
|
||||
*
|
||||
*/
|
||||
|
||||
int mca_oob_tcp_send_nb(const ompi_process_name_t* peer, const struct iovec* msg, int count,
|
||||
int mca_oob_tcp_send_nb(const ompi_process_name_t* peer, const struct iovec* iov, int count,
|
||||
int flags, mca_oob_callback_fn_t cbfunc, void* cbdata);
|
||||
|
||||
/**
|
||||
* Non-blocking version of mca_oob_recv().
|
||||
*
|
||||
* @param peer (IN) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param cbfunc (IN) Callback function on recv completion.
|
||||
* @param cbdata (IN) User data that is passed to callback function.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
*/
|
||||
|
||||
int mca_oob_tcp_recv_nb(ompi_process_name_t* peer, const struct iovec* msg, int count, int flags,
|
||||
int mca_oob_tcp_recv_nb(ompi_process_name_t* peer, const struct iovec* iov, int count, int flags,
|
||||
mca_oob_callback_fn_t cbfunc, void* cbdata);
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "oob_tcp.h"
|
||||
#include "oob_tcp_msg.h"
|
||||
#include "mca/oob/tcp/oob_tcp.h"
|
||||
#include "mca/oob/tcp/oob_tcp_msg.h"
|
||||
|
||||
|
||||
static void mca_oob_tcp_msg_construct(mca_oob_tcp_msg_t*);
|
||||
@ -52,12 +52,12 @@ int mca_oob_tcp_msg_wait(mca_oob_tcp_msg_t* msg, int* size)
|
||||
* @param peer (IN) the peer of the message
|
||||
* @retval OMPI_SUCCESS or error code on failure.
|
||||
*/
|
||||
int mca_oob_tcp_msg_complete(mca_oob_tcp_msg_t* msg, struct mca_oob_tcp_peer_t * peer)
|
||||
int mca_oob_tcp_msg_complete(mca_oob_tcp_msg_t* msg, ompi_process_name_t * peer)
|
||||
{
|
||||
ompi_mutex_lock(&msg->msg_lock);
|
||||
msg->msg_complete = true;
|
||||
if(NULL != msg->msg_cbfunc) {
|
||||
msg->msg_cbfunc(msg->msg_state, &peer->peer_name, msg->msg_iov, msg->msg_count, msg->msg_cbdata);
|
||||
msg->msg_cbfunc(msg->msg_state, peer, msg->msg_iov, msg->msg_count, msg->msg_cbdata);
|
||||
ompi_mutex_unlock(&msg->msg_lock);
|
||||
MCA_OOB_TCP_MSG_RETURN(msg);
|
||||
} else {
|
||||
@ -67,14 +67,14 @@ int mca_oob_tcp_msg_complete(mca_oob_tcp_msg_t* msg, struct mca_oob_tcp_peer_t *
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* The function that actually sends the data!
|
||||
* @param msg a pointer to the message to send
|
||||
* @param peer the peer we are sending to
|
||||
* @retval true if the entire message has been sent
|
||||
* @retval false if the entire message has not been sent
|
||||
*/
|
||||
bool mca_oob_tcp_msg_send_handler(mca_oob_tcp_msg_t* msg, mca_oob_tcp_peer_t * peer)
|
||||
bool mca_oob_tcp_msg_send_handler(mca_oob_tcp_msg_t* msg, struct mca_oob_tcp_peer_t * peer)
|
||||
{
|
||||
int rc;
|
||||
while(1) {
|
||||
@ -102,7 +102,7 @@ bool mca_oob_tcp_msg_send_handler(mca_oob_tcp_msg_t* msg, mca_oob_tcp_peer_t * p
|
||||
(msg->msg_rwptr)++;
|
||||
if(0 == msg->msg_rwcnt) {
|
||||
ompi_list_remove_item(&peer->peer_send_queue, (ompi_list_item_t *) msg);
|
||||
mca_oob_tcp_msg_complete(msg, peer);
|
||||
mca_oob_tcp_msg_complete(msg, &peer->peer_name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -118,9 +118,15 @@ bool mca_oob_tcp_msg_send_handler(mca_oob_tcp_msg_t* msg, mca_oob_tcp_peer_t * p
|
||||
* @retval true if the whole message was recieved
|
||||
* @retval false if the whole message was not recieved
|
||||
*/
|
||||
bool mca_oob_tcp_msg_recv_handler(mca_oob_tcp_msg_t* msg, mca_oob_tcp_peer_t * peer)
|
||||
bool mca_oob_tcp_msg_recv_handler(mca_oob_tcp_msg_t* msg, struct mca_oob_tcp_peer_t * peer)
|
||||
{
|
||||
int rc;
|
||||
/* get the first sizeof(unint32_t) bytes of the message
|
||||
* to either match this with a posted recieve, or to create
|
||||
* message
|
||||
* then use this information to allocate an array of size 2
|
||||
* of iovecs and a buffer for the second part large enough to hold the
|
||||
* whole message */
|
||||
while(1) {
|
||||
rc = readv(peer->peer_sd, msg->msg_rwptr, msg->msg_rwcnt);
|
||||
if(rc <= 0) {
|
||||
@ -145,7 +151,7 @@ bool mca_oob_tcp_msg_recv_handler(mca_oob_tcp_msg_t* msg, mca_oob_tcp_peer_t * p
|
||||
(msg->msg_rwcnt)--;
|
||||
(msg->msg_rwptr)++;
|
||||
if(0 == msg->msg_rwcnt) {
|
||||
mca_oob_tcp_msg_complete(msg, peer);
|
||||
mca_oob_tcp_msg_complete(msg, &peer->peer_name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "mca/oob/tcp/oob_tcp_peer.h"
|
||||
#include "mca/oob/oob.h"
|
||||
#include <errno.h>
|
||||
|
||||
struct mca_oob_tcp_peer_t;
|
||||
/**
|
||||
* describes each message being progressed.
|
||||
*/
|
||||
@ -29,7 +29,7 @@ struct mca_oob_tcp_msg_t {
|
||||
mca_oob_callback_fn_t msg_cbfunc; /**< the callback function for the send/recieve */
|
||||
void *msg_cbdata; /**< the data for the callback fnuction */
|
||||
bool msg_complete; /**< whether the message is done sending or not */
|
||||
struct mca_oob_tcp_peer_t *msg_peer; /**< the peer it belongs to */
|
||||
ompi_process_name_t * msg_peer; /**< the name of the peer */
|
||||
ompi_mutex_t msg_lock; /**< lock for the condition variable */
|
||||
ompi_condition_t msg_condition; /**< the message condition */
|
||||
};
|
||||
@ -56,7 +56,7 @@ OBJ_CLASS_DECLARATION(mca_oob_tcp_msg_t);
|
||||
#define MCA_OOB_TCP_MSG_RETURN(msg) \
|
||||
{ \
|
||||
/* frees the iovec allocated during the send/recieve */ \
|
||||
free(msg->msg_iov); \
|
||||
if(NULL != msg->msg_iov) free(msg->msg_iov); \
|
||||
OMPI_FREE_LIST_RETURN(&mca_oob_tcp_module.tcp_msgs, (ompi_list_item_t*)msg); \
|
||||
}
|
||||
|
||||
@ -72,9 +72,10 @@ int mca_oob_tcp_msg_wait(mca_oob_tcp_msg_t* msg, int* size);
|
||||
* Signal that a message has completed. Wakes up any pending threads (for blocking send)
|
||||
* or invokes callbacks for non-blocking case.
|
||||
* @param msg (IN) Message send/recv that has completed.
|
||||
* @param peer (IN) The peer the send/recieve was from
|
||||
* @retval OMPI_SUCCESS or error code on failure.
|
||||
*/
|
||||
int mca_oob_tcp_msg_complete(mca_oob_tcp_msg_t* msg, struct mca_oob_tcp_peer_t * peer);
|
||||
int mca_oob_tcp_msg_complete(mca_oob_tcp_msg_t* msg, ompi_process_name_t * peer);
|
||||
|
||||
/**
|
||||
* Called asynchronously to progress sending a message from the event library thread.
|
||||
|
@ -125,24 +125,32 @@ int mca_oob_tcp_peer_send(mca_oob_tcp_peer_t* peer, mca_oob_tcp_msg_t* msg)
|
||||
/*
|
||||
* Lookup a peer by name, create one if it doesn't exist.
|
||||
* @param name Peers globally unique identifier.
|
||||
* @param get_lock says whether the function should get the main tcp lock or not.
|
||||
* this should be true unless the caller already owns the lock.
|
||||
* @retval Pointer to the newly created struture or NULL on error.
|
||||
*/
|
||||
mca_oob_tcp_peer_t * mca_oob_tcp_peer_lookup(const ompi_process_name_t* name)
|
||||
mca_oob_tcp_peer_t * mca_oob_tcp_peer_lookup(const ompi_process_name_t* name, bool get_lock)
|
||||
{
|
||||
int rc;
|
||||
mca_oob_tcp_peer_t * peer, * old;
|
||||
|
||||
OMPI_THREAD_LOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
if(get_lock) {
|
||||
OMPI_THREAD_LOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
}
|
||||
peer = (mca_oob_tcp_peer_t*)ompi_rb_tree_find(&mca_oob_tcp_module.tcp_peer_tree,
|
||||
(ompi_process_name_t *) name);
|
||||
if(NULL != peer) {
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
if(get_lock) {
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
}
|
||||
return peer;
|
||||
}
|
||||
|
||||
MCA_OOB_TCP_PEER_ALLOC(peer, rc);
|
||||
if(NULL == peer) {
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
if(get_lock) {
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -155,7 +163,9 @@ mca_oob_tcp_peer_t * mca_oob_tcp_peer_lookup(const ompi_process_name_t* name)
|
||||
if(OMPI_SUCCESS != ompi_rb_tree_insert(&mca_oob_tcp_module.tcp_peer_tree,
|
||||
(ompi_process_name_t *) name, peer)) {
|
||||
MCA_OOB_TCP_PEER_RETURN(peer);
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
if(get_lock) {
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
ompi_list_prepend(&mca_oob_tcp_module.tcp_peer_list, (ompi_list_item_t *) peer);
|
||||
@ -181,7 +191,9 @@ mca_oob_tcp_peer_t * mca_oob_tcp_peer_lookup(const ompi_process_name_t* name)
|
||||
}
|
||||
}
|
||||
}
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
if(get_lock) {
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
}
|
||||
return peer;
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,8 @@
|
||||
#include <netinet/in.h>
|
||||
#include "threads/mutex.h"
|
||||
#include <string.h>
|
||||
#include "oob_tcp.h"
|
||||
#include "oob_tcp_msg.h"
|
||||
|
||||
#include "mca/oob/tcp/oob_tcp.h"
|
||||
#include "mca/oob/tcp/oob_tcp_msg.h"
|
||||
/**
|
||||
* the state of the connection
|
||||
*/
|
||||
@ -76,11 +75,12 @@ extern "C" {
|
||||
* create one and cache it.
|
||||
*
|
||||
* @param peer_name the name of the peer
|
||||
*
|
||||
* @param get_lock get the lock on the tcp struct. This should always be true
|
||||
* unless the caller already owns the lock.
|
||||
* @retval pointer to the peer's (possibly newly created) struture
|
||||
* @retval NULL if there was a problem
|
||||
*/
|
||||
mca_oob_tcp_peer_t *mca_oob_tcp_peer_lookup(const ompi_process_name_t* peer_name);
|
||||
mca_oob_tcp_peer_t *mca_oob_tcp_peer_lookup(const ompi_process_name_t* peer_name, bool get_lock);
|
||||
|
||||
/**
|
||||
* Start sending a message to the specified peer. The routine
|
||||
|
@ -3,33 +3,186 @@
|
||||
/*
|
||||
* Similiar to unix readv(2)
|
||||
*
|
||||
* @param peer (IN) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param types (IN) Parallel array to iovecs describing data type of each iovec element.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to the number of bytes provided in the
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to the number of bytes provided in the
|
||||
* iovec array without removing the message from the queue.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
*/
|
||||
int mca_oob_tcp_recv(ompi_process_name_t* peer, const struct iovec *msg, int count, int flags)
|
||||
int mca_oob_tcp_recv(ompi_process_name_t* peer, const struct iovec *iov, int count, int flags)
|
||||
{
|
||||
return OMPI_ERR_NOT_IMPLEMENTED;
|
||||
mca_oob_tcp_msg_t * msg = (mca_oob_tcp_msg_t *)
|
||||
ompi_list_get_first(&mca_oob_tcp_module.tcp_msg_recv);
|
||||
int i, amount, read, size = 0;
|
||||
char * base;
|
||||
for(i = 0; i < count; i++) {
|
||||
size += iov[i].iov_len;
|
||||
}
|
||||
/* lock the tcp struct */
|
||||
OMPI_THREAD_LOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
/* check to see if a matching recieve is on the list */
|
||||
while(NULL != msg) {
|
||||
if(MCA_OOB_BASE_ANY == peer ||
|
||||
(0 == memcmp(peer, &msg->msg_peer, sizeof(ompi_process_name_t)))) {
|
||||
/* if we are just doing peek, all we need to do is match the peer name,
|
||||
* nothing else. */
|
||||
if(MCA_OOB_PEEK & flags) {
|
||||
base = (char *) msg->msg_iov[1].iov_base;
|
||||
size = msg->msg_iov[i].iov_len;
|
||||
read = 0;
|
||||
for(i = 0; i < count; i++) {
|
||||
amount = ((iov[i].iov_len < size) ? iov[i].iov_len : size);
|
||||
memcpy(iov[i].iov_base, base, amount);
|
||||
size -= amount;
|
||||
base +=amount;
|
||||
read += amount;
|
||||
}
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
return read;
|
||||
}
|
||||
/* what are we going to define as matching? we don't know the number
|
||||
* of iovecs we got off the network, we only know the total size
|
||||
* For now, we wil just use the size == the size we have available */
|
||||
if(size == msg->msg_size) {
|
||||
/* match */
|
||||
base = (char *) msg->msg_iov[1].iov_base;
|
||||
size = msg->msg_iov[i].iov_len;
|
||||
read = 0;
|
||||
for(i = 0; i < count; i++) {
|
||||
memcpy(iov[i].iov_base, base, iov[i].iov_len);
|
||||
base +=amount;
|
||||
read += amount;
|
||||
}
|
||||
ompi_list_remove_item(&mca_oob_tcp_module.tcp_msg_recv,
|
||||
(ompi_list_item_t *) msg);
|
||||
MCA_OOB_TCP_MSG_RETURN(msg);
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
return read;
|
||||
}
|
||||
msg = (mca_oob_tcp_msg_t *) ompi_list_get_next(msg);
|
||||
}
|
||||
}
|
||||
/* the message has not already been recieved. So we add it to the recieve queue */
|
||||
MCA_OOB_TCP_MSG_ALLOC(msg, i);
|
||||
if(NULL == msg) {
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
return i;
|
||||
}
|
||||
/* fill in the struct */
|
||||
msg->msg_state = 0;
|
||||
msg->msg_size = size;
|
||||
msg->msg_user = iov;
|
||||
msg->msg_iov = NULL;
|
||||
msg->msg_rwcnt = msg->msg_count = count;
|
||||
msg->msg_cbfunc = NULL;
|
||||
msg->msg_complete = false;
|
||||
if(0 == memcmp(MCA_OOB_BASE_ANY, peer, sizeof(ompi_process_name_t))) {
|
||||
msg->msg_peer = MCA_OOB_BASE_ANY;
|
||||
} else {
|
||||
mca_oob_tcp_peer_t * other = mca_oob_tcp_peer_lookup(peer, false);
|
||||
msg->msg_peer = &other->peer_name;
|
||||
}
|
||||
/* add to list */
|
||||
ompi_list_append(&mca_oob_tcp_module.tcp_msg_recv, (ompi_list_item_t *) msg);
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
/* wait for the recieve to complete */
|
||||
mca_oob_tcp_msg_wait(msg, &read);
|
||||
return read;
|
||||
}
|
||||
|
||||
/*
|
||||
* Non-blocking version of mca_oob_recv().
|
||||
*
|
||||
* @param peer (IN) Opaque name of peer process or OOB_NAME_ANY for wildcard receive.
|
||||
* @param peer (IN) Opaque name of peer process or MCA_OOB_BASE_ANY for wildcard receive.
|
||||
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
||||
* @param count (IN) Number of elements in iovec array.
|
||||
* @param flags (IN) May be OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param flags (IN) May be MCA_OOB_PEEK to return up to size bytes of msg w/out removing it from the queue,
|
||||
* @param cbfunc (IN) Callback function on recv completion.
|
||||
* @param cbdata (IN) User data that is passed to callback function.
|
||||
* @return OMPI error code (<0) on error or number of bytes actually received.
|
||||
*/
|
||||
int mca_oob_tcp_recv_nb(ompi_process_name_t* peer, const struct iovec* msg, int count, int flags,
|
||||
mca_oob_callback_fn_t cbfunc, void* cbdata)
|
||||
int mca_oob_tcp_recv_nb(ompi_process_name_t* peer, const struct iovec* iov, int count,
|
||||
int flags, mca_oob_callback_fn_t cbfunc, void* cbdata)
|
||||
{
|
||||
return OMPI_ERR_NOT_IMPLEMENTED;
|
||||
mca_oob_tcp_msg_t * msg = (mca_oob_tcp_msg_t *)
|
||||
ompi_list_get_first(&mca_oob_tcp_module.tcp_msg_recv);
|
||||
int i, amount, read, size = 0;
|
||||
char * base;
|
||||
for(i = 0; i < count; i++) {
|
||||
size += iov[i].iov_len;
|
||||
}
|
||||
/* lock the tcp struct */
|
||||
OMPI_THREAD_LOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
/* check to see if a matching recieve is on the list */
|
||||
while(NULL != msg) {
|
||||
if(MCA_OOB_BASE_ANY == peer ||
|
||||
(0 == memcmp(peer, &msg->msg_peer, sizeof(ompi_process_name_t)))) {
|
||||
/* if we are just doing peek, all we need to do is match the peer name,
|
||||
* nothing else. */
|
||||
if(MCA_OOB_PEEK & flags) {
|
||||
base = (char *) msg->msg_iov[1].iov_base;
|
||||
size = msg->msg_iov[i].iov_len;
|
||||
read = 0;
|
||||
for(i = 0; i < count; i++) {
|
||||
amount = ((iov[i].iov_len < size) ? iov[i].iov_len : size);
|
||||
memcpy(iov[i].iov_base, base, amount);
|
||||
size -= amount;
|
||||
base +=amount;
|
||||
read += amount;
|
||||
}
|
||||
cbfunc(read, peer, iov, count, cbdata);
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
return read;
|
||||
}
|
||||
/* what are we going to define as matching? we don't know the number
|
||||
* of iovecs we got off the network, we only know the total size
|
||||
* For now, we wil just use the size == the size we have available */
|
||||
if(size == msg->msg_size) {
|
||||
/* match */
|
||||
base = (char *) msg->msg_iov[1].iov_base;
|
||||
size = msg->msg_iov[i].iov_len;
|
||||
read = 0;
|
||||
for(i = 0; i < count; i++) {
|
||||
memcpy(iov[i].iov_base, base, iov[i].iov_len);
|
||||
base +=amount;
|
||||
read += amount;
|
||||
}
|
||||
ompi_list_remove_item(&mca_oob_tcp_module.tcp_msg_recv,
|
||||
(ompi_list_item_t *) msg);
|
||||
MCA_OOB_TCP_MSG_RETURN(msg);
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
cbfunc(read, peer, iov, count, cbdata);
|
||||
return read;
|
||||
}
|
||||
msg = (mca_oob_tcp_msg_t *) ompi_list_get_next(msg);
|
||||
}
|
||||
}
|
||||
/* the message has not already been recieved. So we add it to the recieve queue */
|
||||
MCA_OOB_TCP_MSG_ALLOC(msg, i);
|
||||
if(NULL == msg) {
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
return i;
|
||||
}
|
||||
/* fill in the struct */
|
||||
msg->msg_state = 0;
|
||||
msg->msg_size = size;
|
||||
msg->msg_user = iov;
|
||||
msg->msg_iov = NULL;
|
||||
msg->msg_rwcnt = msg->msg_count = count;
|
||||
msg->msg_cbfunc = cbfunc;
|
||||
msg->msg_cbdata = cbdata;
|
||||
if(0 == memcmp(MCA_OOB_BASE_ANY, peer, sizeof(ompi_process_name_t))) {
|
||||
msg->msg_peer = MCA_OOB_BASE_ANY;
|
||||
} else {
|
||||
mca_oob_tcp_peer_t * other = mca_oob_tcp_peer_lookup(peer, false);
|
||||
msg->msg_peer = &other->peer_name;
|
||||
}
|
||||
msg->msg_complete = false;
|
||||
/* add to list */
|
||||
ompi_list_append(&mca_oob_tcp_module.tcp_msg_recv, (ompi_list_item_t *) msg);
|
||||
OMPI_THREAD_UNLOCK(&mca_oob_tcp_module.tcp_lock);
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
#include "oob_tcp.h"
|
||||
#include "oob_tcp_msg.h"
|
||||
#include "oob_tcp_peer.h"
|
||||
#include "mca/oob/tcp/oob_tcp.h"
|
||||
|
||||
/*
|
||||
* Similiar to unix writev(2).
|
||||
@ -14,7 +12,7 @@
|
||||
|
||||
int mca_oob_tcp_send(const ompi_process_name_t* name, const struct iovec *iov, int count, int flags)
|
||||
{
|
||||
mca_oob_tcp_peer_t* peer = mca_oob_tcp_peer_lookup(name);
|
||||
mca_oob_tcp_peer_t* peer = mca_oob_tcp_peer_lookup(name, true);
|
||||
mca_oob_tcp_msg_t* msg;
|
||||
int rc, sent;
|
||||
if(NULL == peer)
|
||||
@ -42,7 +40,7 @@ int mca_oob_tcp_send(const ompi_process_name_t* name, const struct iovec *iov, i
|
||||
msg->msg_cbfunc = NULL;
|
||||
msg->msg_cbdata = NULL;
|
||||
msg->msg_complete = false;
|
||||
msg->msg_peer = peer;
|
||||
msg->msg_peer = &peer->peer_name;
|
||||
msg->msg_state = 0;
|
||||
|
||||
rc = mca_oob_tcp_peer_send(peer, msg);
|
||||
@ -78,7 +76,7 @@ int mca_oob_tcp_send_nb(
|
||||
mca_oob_callback_fn_t cbfunc,
|
||||
void* cbdata)
|
||||
{
|
||||
mca_oob_tcp_peer_t* peer = mca_oob_tcp_peer_lookup(name);
|
||||
mca_oob_tcp_peer_t* peer = mca_oob_tcp_peer_lookup(name, true);
|
||||
mca_oob_tcp_msg_t* msg;
|
||||
int rc;
|
||||
if(NULL == peer)
|
||||
@ -107,7 +105,7 @@ int mca_oob_tcp_send_nb(
|
||||
msg->msg_cbfunc = cbfunc;
|
||||
msg->msg_cbdata = cbdata;
|
||||
msg->msg_complete = false;
|
||||
msg->msg_peer = peer;
|
||||
msg->msg_peer = &peer->peer_name;
|
||||
msg->msg_state = 0;
|
||||
|
||||
rc = mca_oob_tcp_peer_send(peer, msg);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user