2004-07-15 23:08:54 +04:00
|
|
|
#include "mca/oob/tcp/oob_tcp.h"
|
2004-07-01 18:49:54 +04:00
|
|
|
|
|
|
|
/*
|
2004-07-15 17:51:40 +04:00
|
|
|
* Similiar to unix writev(2).
|
2004-07-01 18:49:54 +04:00
|
|
|
*
|
|
|
|
* @param peer (IN) Opaque name of peer process.
|
|
|
|
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
|
|
|
* @param count (IN) Number of elements in iovec array.
|
|
|
|
* @param flags (IN) Currently unused.
|
|
|
|
* @return OMPI error code (<0) on error number of bytes actually sent.
|
|
|
|
*/
|
|
|
|
|
2004-08-03 01:24:00 +04:00
|
|
|
int mca_oob_tcp_send(
|
2004-08-13 02:41:42 +04:00
|
|
|
ompi_process_name_t* name,
|
|
|
|
struct iovec *iov,
|
2004-08-03 01:24:00 +04:00
|
|
|
int count,
|
|
|
|
int tag,
|
|
|
|
int flags)
|
2004-07-01 18:49:54 +04:00
|
|
|
{
|
2004-07-15 23:08:54 +04:00
|
|
|
mca_oob_tcp_peer_t* peer = mca_oob_tcp_peer_lookup(name, true);
|
2004-07-13 02:46:57 +04:00
|
|
|
mca_oob_tcp_msg_t* msg;
|
2004-08-03 01:24:00 +04:00
|
|
|
int size;
|
|
|
|
int rc;
|
|
|
|
|
2004-07-13 02:46:57 +04:00
|
|
|
if(NULL == peer)
|
|
|
|
return OMPI_ERR_UNREACH;
|
|
|
|
|
|
|
|
MCA_OOB_TCP_MSG_ALLOC(msg, rc);
|
|
|
|
if(NULL == msg)
|
|
|
|
return rc;
|
|
|
|
|
2004-07-15 17:51:40 +04:00
|
|
|
/* calculate the size of the message */
|
2004-08-03 01:24:00 +04:00
|
|
|
size = 0;
|
2004-07-15 17:51:40 +04:00
|
|
|
for(rc = 0; rc < count; rc++) {
|
2004-08-03 01:24:00 +04:00
|
|
|
size += iov[rc].iov_len;
|
2004-07-15 17:51:40 +04:00
|
|
|
}
|
2004-08-03 01:24:00 +04:00
|
|
|
|
2004-07-15 17:51:40 +04:00
|
|
|
/* turn the size to network byte order so there will be no problems */
|
2004-08-03 01:24:00 +04:00
|
|
|
msg->msg_hdr.msg_size = htonl(size);
|
|
|
|
msg->msg_hdr.msg_tag = htonl(tag);
|
|
|
|
|
|
|
|
/* create one additional iovect that will hold the header */
|
|
|
|
msg->msg_type = MCA_OOB_TCP_POSTED;
|
|
|
|
msg->msg_rc = 0;
|
|
|
|
msg->msg_flags = flags;
|
|
|
|
msg->msg_uiov = iov;
|
|
|
|
msg->msg_ucnt = count;
|
|
|
|
msg->msg_rwiov = mca_oob_tcp_msg_iov_alloc(msg, count+1);
|
|
|
|
msg->msg_rwiov[0].iov_base = &msg->msg_hdr;
|
|
|
|
msg->msg_rwiov[0].iov_len = sizeof(msg->msg_hdr);
|
|
|
|
msg->msg_rwptr = msg->msg_rwiov;
|
|
|
|
msg->msg_rwcnt = msg->msg_rwnum = count + 1;
|
|
|
|
memcpy(msg->msg_rwiov+1, msg->msg_uiov, sizeof(struct iovec)*msg->msg_ucnt);
|
|
|
|
msg->msg_rwbuf = NULL;
|
2004-07-13 02:46:57 +04:00
|
|
|
msg->msg_cbfunc = NULL;
|
|
|
|
msg->msg_cbdata = NULL;
|
|
|
|
msg->msg_complete = false;
|
2004-08-03 01:24:00 +04:00
|
|
|
msg->msg_peer = peer->peer_name;
|
2004-07-15 17:51:40 +04:00
|
|
|
|
2004-07-13 02:46:57 +04:00
|
|
|
rc = mca_oob_tcp_peer_send(peer, msg);
|
|
|
|
if(rc != OMPI_SUCCESS) {
|
2004-07-14 01:03:03 +04:00
|
|
|
MCA_OOB_TCP_MSG_RETURN(msg);
|
2004-07-13 02:46:57 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-08-03 01:24:00 +04:00
|
|
|
rc = mca_oob_tcp_msg_wait(msg, &size);
|
|
|
|
MCA_OOB_TCP_MSG_RETURN(msg);
|
2004-07-13 02:46:57 +04:00
|
|
|
if(rc != OMPI_SUCCESS)
|
|
|
|
return rc;
|
2004-08-03 01:24:00 +04:00
|
|
|
size -= sizeof(mca_oob_tcp_hdr_t);
|
|
|
|
return size;
|
2004-07-01 18:49:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Non-blocking version of mca_oob_send().
|
|
|
|
*
|
|
|
|
* @param peer (IN) Opaque name of peer process.
|
|
|
|
* @param msg (IN) Array of iovecs describing user buffers and lengths.
|
|
|
|
* @param count (IN) Number of elements in iovec array.
|
|
|
|
* @param flags (IN) Currently unused.
|
|
|
|
* @param cbfunc (IN) Callback function on send completion.
|
|
|
|
* @param cbdata (IN) User data that is passed to callback function.
|
|
|
|
* @return OMPI error code (<0) on error number of bytes actually sent.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-07-13 02:46:57 +04:00
|
|
|
int mca_oob_tcp_send_nb(
|
2004-08-13 02:41:42 +04:00
|
|
|
ompi_process_name_t* name,
|
|
|
|
struct iovec* iov,
|
2004-07-13 02:46:57 +04:00
|
|
|
int count,
|
2004-08-03 01:24:00 +04:00
|
|
|
int tag,
|
2004-07-13 02:46:57 +04:00
|
|
|
int flags,
|
|
|
|
mca_oob_callback_fn_t cbfunc,
|
|
|
|
void* cbdata)
|
2004-07-01 18:49:54 +04:00
|
|
|
{
|
2004-07-15 23:08:54 +04:00
|
|
|
mca_oob_tcp_peer_t* peer = mca_oob_tcp_peer_lookup(name, true);
|
2004-07-13 02:46:57 +04:00
|
|
|
mca_oob_tcp_msg_t* msg;
|
2004-08-03 01:24:00 +04:00
|
|
|
int size;
|
2004-07-13 02:46:57 +04:00
|
|
|
int rc;
|
2004-08-03 01:24:00 +04:00
|
|
|
|
2004-07-13 02:46:57 +04:00
|
|
|
if(NULL == peer)
|
|
|
|
return OMPI_ERR_UNREACH;
|
|
|
|
|
|
|
|
MCA_OOB_TCP_MSG_ALLOC(msg, rc);
|
|
|
|
if(NULL == msg)
|
|
|
|
return rc;
|
|
|
|
|
2004-07-15 17:51:40 +04:00
|
|
|
/* calculate the size of the message */
|
2004-08-03 01:24:00 +04:00
|
|
|
size = 0;
|
2004-07-15 17:51:40 +04:00
|
|
|
for(rc = 0; rc < count; rc++) {
|
2004-08-03 01:24:00 +04:00
|
|
|
size += iov[rc].iov_len;
|
2004-07-15 17:51:40 +04:00
|
|
|
}
|
|
|
|
/* turn the size to network byte order so there will be no problems */
|
2004-08-03 01:24:00 +04:00
|
|
|
msg->msg_hdr.msg_size = htonl(size);
|
|
|
|
msg->msg_hdr.msg_tag = htonl(tag);
|
2004-07-15 17:51:40 +04:00
|
|
|
|
|
|
|
/* create one additional iovect that will hold the size of the message */
|
2004-08-03 01:24:00 +04:00
|
|
|
msg->msg_type = MCA_OOB_TCP_POSTED;
|
|
|
|
msg->msg_rc = 0;
|
|
|
|
msg->msg_flags = flags;
|
|
|
|
msg->msg_uiov = iov;
|
|
|
|
msg->msg_ucnt = count;
|
|
|
|
msg->msg_rwiov = mca_oob_tcp_msg_iov_alloc(msg,count+1);
|
|
|
|
msg->msg_rwiov[0].iov_base = &msg->msg_hdr;
|
|
|
|
msg->msg_rwiov[0].iov_len = sizeof(msg->msg_hdr);
|
|
|
|
msg->msg_rwptr = msg->msg_rwiov;
|
|
|
|
msg->msg_rwcnt = msg->msg_rwnum = count + 1;
|
|
|
|
memcpy(msg->msg_rwiov+1, msg->msg_uiov, sizeof(struct iovec)*msg->msg_ucnt);
|
|
|
|
msg->msg_rwbuf = NULL;
|
2004-07-13 02:46:57 +04:00
|
|
|
msg->msg_cbfunc = cbfunc;
|
|
|
|
msg->msg_cbdata = cbdata;
|
|
|
|
msg->msg_complete = false;
|
2004-08-03 01:24:00 +04:00
|
|
|
msg->msg_peer = peer->peer_name;
|
2004-07-15 17:51:40 +04:00
|
|
|
|
2004-07-13 02:46:57 +04:00
|
|
|
rc = mca_oob_tcp_peer_send(peer, msg);
|
|
|
|
if(rc != OMPI_SUCCESS) {
|
2004-07-14 01:03:03 +04:00
|
|
|
MCA_OOB_TCP_MSG_RETURN(msg);
|
2004-07-13 02:46:57 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
2004-07-01 18:49:54 +04:00
|
|
|
}
|
|
|
|
|