unused
This commit was SVN r1851.
Этот коммит содержится в:
родитель
80a9ede98f
Коммит
8efddcdc05
@ -1,40 +0,0 @@
|
||||
# -*- makefile -*-
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
include $(top_srcdir)/config/Makefile.options
|
||||
|
||||
noinst_LTLIBRARIES = libctnetwork.la
|
||||
|
||||
# Source code files
|
||||
|
||||
headers = \
|
||||
ctpeer.h \
|
||||
ctchannel.h \
|
||||
ctcontroller.h \
|
||||
ctmessage.h \
|
||||
ctnode.h
|
||||
|
||||
libctnetwork_la_SOURCES = \
|
||||
$(headers) \
|
||||
ctpeer.c
|
||||
|
||||
bogus = \
|
||||
ctchannel.c \
|
||||
ctchannel.h \
|
||||
ctcontroller.c \
|
||||
ctcontroller.h \
|
||||
ctmessage.c \
|
||||
ctmessage.h \
|
||||
ctnode.c \
|
||||
ctnode.h
|
||||
|
||||
# Conditionally install the header files
|
||||
|
||||
if WANT_INSTALL_HEADERS
|
||||
ompidir = $(includedir)/openmpi/ctnetwork
|
||||
ompi_HEADERS = $(headers)
|
||||
else
|
||||
ompidir = $(includedir)
|
||||
endif
|
@ -1,184 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ctnetwork/ctchannel.h"
|
||||
|
||||
#define CHANNEL_CLS(chnl) \
|
||||
((ompi_ctchannel_class_t *)(((ompi_object_t *) chnl)->obj_class))
|
||||
|
||||
|
||||
static void ompi_cth_construct(ompi_ctchannel_t *channel)
|
||||
{
|
||||
channel->cth_status = CT_CHNL_CLOSED;
|
||||
channel->cth_id = 0;
|
||||
channel->cth_timeout_secs = 0;
|
||||
}
|
||||
|
||||
|
||||
static void ompi_cth_construct(ompi_ctchannel_t *channel)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ompi_ctchannel_class_t ompi_ct_channel_t_class = {
|
||||
{
|
||||
"ompi_ct_channel_t",
|
||||
OBJ_CLASS(ompi_object_t),
|
||||
(ompi_construct_t) ompi_cth_construct,
|
||||
(ompi_destruct_t) ompi_object_destruct
|
||||
},
|
||||
NULL, NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* PURE VIRTUAL functions that must be
|
||||
* implemented by concrete subclasses.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* return: error code args: (channel, data, data length, bytes sent) */
|
||||
uint32_t ompi_cth_send(ompi_ctchannel_t *channel, const uint8_t *data,
|
||||
uint32_t data_len, uint32_t *bytes_sent)
|
||||
{
|
||||
return CHANNEL_CLS(channel)->cth_send(channel, data, data_len,
|
||||
bytes_sent);
|
||||
}
|
||||
|
||||
/* return: error code args: (channel, recv buffer, buffer length, bytes received) */
|
||||
uint32_t ompi_cth_recv(ompi_ctchannel_t *channel, const uint8_t *buffer,
|
||||
uint32_t buff_len, uint32_t *bytes_recvd)
|
||||
{
|
||||
return CHANNEL_CLS(channel)->cth_recv(channel, buffer,
|
||||
buff_len, bytes_recvd);
|
||||
}
|
||||
|
||||
/* return: error code args: (channel, msg ptr) */
|
||||
uint32_t ompi_cth_get_msg(ompi_ctchannel_t *channel, ompi_ctmsg_t **msg)
|
||||
{
|
||||
return CHANNEL_CLS(channel)->cth_get_msg(channel, msg);
|
||||
}
|
||||
|
||||
/* return: error code args: (channel, recv buffer ptr, bytes received) */
|
||||
uint32_t ompi_cth_get_packed_msg(ompi_ctchannel_t *channel,
|
||||
const uint8_t **buffer,
|
||||
uint32_t *bytes_recvd)
|
||||
{
|
||||
return CHANNEL_CLS(channel)->cth_get_packed_msg(channel, buffer,
|
||||
bytes_recvd);
|
||||
}
|
||||
|
||||
/* return: error code args: (channel, msg) */
|
||||
uint32_t ompi_cth_send_msg(ompi_ctchannel_t *channel, ompi_ctmsg_t *msg)
|
||||
{
|
||||
return CHANNEL_CLS(channel)->cth_send_msg(channel, msg);
|
||||
}
|
||||
|
||||
|
||||
/* return: error code args: (channel, msg ptr, msg len) */
|
||||
uint32_t ompi_cth_send_packed_msg(ompi_ctchannel_t *channel,
|
||||
const uint8_t *packed_msg,
|
||||
uint32_t msg_len)
|
||||
{
|
||||
return CHANNEL_CLS(channel)->cth_send_packed_msg(channel, packed_msg,
|
||||
msg_len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* TCP channel class
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
static void ompi_tcpch_construct(ompi_tcp_chnl_t *channel)
|
||||
{
|
||||
channel->tcp_sockfd = 0;
|
||||
memset(&(channel->tcp_addr), 0, sizeof(channel->tcp_addr));
|
||||
channel->tcp_blocking = 0;
|
||||
}
|
||||
|
||||
|
||||
static void ompi_tcpch_destruct(ompi_tcp_chnl_t *channel)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ompi_ctchannel_class_t ompi_tcp_chnl_t_class = {
|
||||
{
|
||||
"ompi_tcp_chnl_t",
|
||||
OBJ_CLASS(ompi_ctchannel_t),
|
||||
(ompi_construct_t) ompi_tcpch_construct,
|
||||
(ompi_destruct_t) ompi_tcpch_destruct
|
||||
},
|
||||
ompi_tcpch_send,
|
||||
ompi_tcpch_recv,
|
||||
ompi_tcpch_get_msg,
|
||||
ompi_tcpch_get_packed_msg,
|
||||
ompi_tcpch_send_msg,
|
||||
ompi_tcpch_send_packed_msg
|
||||
};
|
||||
|
||||
|
||||
uint32_t ompi_tcpch_send(ompi_tcp_chnl_t *channel, const uint8_t *data,
|
||||
uint32_t data_len, uint32_t *bytes_sent)
|
||||
{
|
||||
uint32_t ret = CT_CHNL_ERR_OK;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ompi_tcpch_recv(ompi_tcp_chnl_t *channel, const uint8_t *buffer,
|
||||
uint32_t buff_len, uint32_t *bytes_recvd)
|
||||
{
|
||||
uint32_t ret = CT_CHNL_ERR_OK;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ompi_tcpch_get_msg(ompi_tcp_chnl_t *channel, ompi_ctmsg_t **msg)
|
||||
{
|
||||
uint32_t ret = CT_CHNL_ERR_OK;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ompi_tcpch_get_packed_msg(ompi_tcp_chnl_t *channel,
|
||||
const uint8_t **buffer,
|
||||
uint32_t *bytes_recvd)
|
||||
{
|
||||
uint32_t ret = CT_CHNL_ERR_OK;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ompi_tcpch_send_msg(ompi_tcp_chnl_t *channel, ompi_ctmsg_t *msg)
|
||||
{
|
||||
uint32_t ret = CT_CHNL_ERR_OK;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ompi_tcpch_send_packed_msg(ompi_tcp_chnl_t *channel,
|
||||
const uint8_t *packed_msg,
|
||||
uint32_t msg_len)
|
||||
{
|
||||
uint32_t ret = CT_CHNL_ERR_OK;
|
||||
|
||||
return ret;
|
||||
}
|
@ -1,210 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OMPI_CT_CHANNEL_H
|
||||
#define OMPI_CT_CHANNEL_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "class/ompi_object.h"
|
||||
#include "ctnetwork/ctmessage.h"
|
||||
|
||||
|
||||
/*
|
||||
* Channel error codes
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CT_CHNL_ERR_OK = 0,
|
||||
CT_CHNL_ERR_GENERAL, /* general channel error. */
|
||||
CT_CHNL_ERR_MALLOC, /* unable to alloc mem. */
|
||||
CT_CHNL_ERR_CLOSED, /* channel is not open */
|
||||
CT_CHNL_ERR_CONN_LOST, /* lost connection */
|
||||
CT_CHNL_ERR_INVALID_MSG, /* unable to pack/unpack msg or msg is NULL */
|
||||
CT_CHNL_ERR_TIMED_OUT /* channel operation timed out. */
|
||||
} ompi_ctchnl_error_t;
|
||||
|
||||
|
||||
/*
|
||||
* Channel connection status
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CT_CHNL_CLOSED = 0,
|
||||
CT_CHNL_CONNECTED,
|
||||
CT_CHNL_FAILED
|
||||
} ompi_ctchnl_status_t;
|
||||
|
||||
/*
|
||||
*
|
||||
* Abstract communication channel class
|
||||
* The controllers and clients use these objects to
|
||||
* communicate in the network.
|
||||
*/
|
||||
|
||||
#define CTCHANNEL(obj) (ompi_ctchannel_t *)(obj)
|
||||
|
||||
struct ompi_ctchannel;
|
||||
|
||||
/* return: error code args: (channel, data, data length, bytes sent) */
|
||||
typedef uint32_t (*ompi_cth_send_fn_t)(struct ompi_ctchannel *,
|
||||
const uint8_t *, uint32_t, uint32_t *);
|
||||
|
||||
/* return: error code args: (channel, recv buffer, buffer length, bytes received) */
|
||||
typedef uint32_t (*ompi_cth_recv_fn_t)(struct ompi_ctchannel *,
|
||||
const uint8_t *, uint32_t, uint32_t *);
|
||||
|
||||
/* return: error code args: (channel, msg ptr) */
|
||||
typedef uint32_t (*ompi_cth_get_msg_fn_t)(struct ompi_ctchannel *,
|
||||
ompi_ctmsg_t **);
|
||||
|
||||
/* return: error code args: (channel, recv buffer ptr, bytes received) */
|
||||
typedef uint32_t (*ompi_cth_get_packed_msg_fn_t)(struct ompi_ctchannel *,
|
||||
const uint8_t **, uint32_t *);
|
||||
|
||||
/* return: error code args: (channel, msg) */
|
||||
typedef uint32_t (*ompi_cth_send_msg_fn_t)(struct ompi_ctchannel *,
|
||||
ompi_ctmsg_t *);
|
||||
|
||||
/* return: error code args: (channel, msg ptr, msg len) */
|
||||
typedef uint32_t (*ompi_cth_send_packed_msg_fn_t)(struct ompi_ctchannel *,
|
||||
const uint8_t *, uint32_t);
|
||||
|
||||
typedef struct ompi_ctchannel_class
|
||||
{
|
||||
ompi_class_t super;
|
||||
/* return: error code args: (channel, data, data length, bytes sent) */
|
||||
ompi_cth_send_fn_t *send;
|
||||
|
||||
/* return: error code args: (channel, recv buffer, buffer length, bytes received) */
|
||||
ompi_cth_recv_fn_t *recv;
|
||||
|
||||
/* return: error code args: (channel, msg ptr) */
|
||||
ompi_cth_get_msg_fn_t *get_msg;
|
||||
|
||||
/* return: error code args: (channel, recv buffer ptr, bytes received) */
|
||||
ompi_cth_get_packed_msg_fn_t *get_packed_msg;
|
||||
|
||||
/* return: error code args: (channel, msg) */
|
||||
ompi_cth_send_msg_fn_t *send_msg;
|
||||
|
||||
/* return: error code args: (channel, msg ptr, msg len) */
|
||||
ompi_cth_send_packed_msg_fn_t *send_packed_msg;
|
||||
} ompi_ctchannel_class_t;
|
||||
|
||||
|
||||
extern ompi_ctchannel_class_t ompi_ct_channel_t_class;
|
||||
|
||||
typedef struct ompi_ctchannel
|
||||
{
|
||||
ompi_object_t super;
|
||||
int cth_status;
|
||||
uint32_t cth_id;
|
||||
uint32_t cth_timeout_secs;
|
||||
} ompi_ctchannel_t;
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Accessor functions
|
||||
*
|
||||
*/
|
||||
|
||||
int ompi_cth_is_connected(ompi_ctchannel_t *channel);
|
||||
inline int ompi_cth_is_connected(ompi_ctchannel_t *channel)
|
||||
{
|
||||
return (CT_CHNL_CONNECTED == channel->cth_status);
|
||||
}
|
||||
|
||||
uint32_t ompi_cth_get_id(ompi_ctchannel_t *channel);
|
||||
inline uint32_t ompi_cth_get_id(ompi_ctchannel_t *channel)
|
||||
{
|
||||
return channel->cth_id;
|
||||
}
|
||||
void ompi_cth_set_id(ompi_ctchannel_t *channel, uint32_t cid);
|
||||
inline void ompi_cth_set_id(ompi_ctchannel_t *channel, uint32_t cid)
|
||||
{
|
||||
channel->cth_id = cid;
|
||||
}
|
||||
|
||||
uint32_t ompi_cth_get_timeout(ompi_ctchannel_t *channel);
|
||||
inline uint32_t ompi_cth_get_timeout(ompi_ctchannel_t *channel)
|
||||
{
|
||||
return channel->cth_timeout_secs;
|
||||
}
|
||||
void ompi_cth_set_timeout(ompi_ctchannel_t *channel, uint32_t timeout);
|
||||
inline void ompi_cth_set_timeout(ompi_ctchannel_t *channel, uint32_t timeout)
|
||||
{
|
||||
channel->cth_timeout_secs = timeout;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* PURE VIRTUAL functions that must be
|
||||
* implemented by concrete subclasses.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* return: error code args: (channel, data, data length, bytes sent) */
|
||||
uint32_t ompi_cth_send(ompi_ctchannel_t *channel, const uint8_t *data,
|
||||
uint32_t data_len, uint32_t *bytes_sent);
|
||||
|
||||
/* return: error code args: (channel, recv buffer, buffer length, bytes received) */
|
||||
uint32_t ompi_cth_recv(ompi_ctchannel_t *channel, const uint8_t *buffer,
|
||||
uint32_t buff_len, uint32_t *bytes_recvd);
|
||||
|
||||
/* return: error code args: (channel, msg ptr) */
|
||||
uint32_t ompi_cth_get_msg(ompi_ctchannel_t *channel, ompi_ctmsg_t **msg);
|
||||
|
||||
/* return: error code args: (channel, recv buffer ptr, bytes received) */
|
||||
uint32_t ompi_cth_get_packed_msg(ompi_ctchannel_t *channel, const uint8_t **buffer,
|
||||
uint32_t *bytes_recvd);
|
||||
|
||||
/* return: error code args: (channel, msg) */
|
||||
uint32_t ompi_cth_send_msg(ompi_ctchannel_t *channel, ompi_ctmsg_t *msg);
|
||||
|
||||
/* return: error code args: (channel, msg ptr, msg len) */
|
||||
uint32_t ompi_cth_send_packed_msg(ompi_ctchannel_t *channel, const uint8_t *packed_msg,
|
||||
uint32_t msg_len);
|
||||
|
||||
/*
|
||||
*
|
||||
* TCP channel class
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct ompi_tcp_channel
|
||||
{
|
||||
ompi_ctchannel_t super;
|
||||
int tcp_sockfd;
|
||||
struct sockaddr_in tcp_addr;
|
||||
int tcp_blocking;
|
||||
} ompi_tcp_chnl_t;
|
||||
|
||||
extern ompi_ctchannel_class_t ompi_tcp_chnl_t_class;
|
||||
|
||||
uint32_t ompi_tcpch_send(ompi_tcp_chnl_t *channel, const uint8_t *data,
|
||||
uint32_t data_len, uint32_t *bytes_sent);
|
||||
|
||||
uint32_t ompi_tcpch_recv(ompi_tcp_chnl_t *channel, const uint8_t *buffer,
|
||||
uint32_t buff_len, uint32_t *bytes_recvd);
|
||||
|
||||
uint32_t ompi_tcpch_get_msg(ompi_tcp_chnl_t *channel, ompi_ctmsg_t **msg);
|
||||
|
||||
uint32_t ompi_tcpch_get_packed_msg(ompi_tcp_chnl_t *channel, const uint8_t **buffer,
|
||||
uint32_t *bytes_recvd);
|
||||
|
||||
uint32_t ompi_tcpch_send_msg(ompi_tcp_chnl_t *channel, ompi_ctmsg_t *msg);
|
||||
|
||||
uint32_t ompi_tcpch_send_packed_msg(ompi_tcp_chnl_t *channel,
|
||||
const uint8_t *packed_msg,
|
||||
uint32_t msg_len);
|
||||
|
||||
|
||||
#endif /* OMPI_CT_CHANNEL_H */
|
@ -1,6 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "ctnetwork/ctclient.h"
|
||||
|
@ -1,9 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OMPI_CT_CLIENT_H
|
||||
#define OMPI_CT_CLIENT_H
|
||||
|
||||
#endif /* OMPI_CT_CLIENT_H */
|
||||
|
@ -1,6 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "ctnetwork/ctpeer.h"
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OMPI_CT_CONTROLLER_H
|
||||
#define OMPI_CT_CONTROLLER_H
|
||||
|
||||
#include "class/ompi_object.h"
|
||||
#include "ctnetwork/ctnode.h"
|
||||
|
||||
typedef void (*ompi_ctmsg_recvd_fn)(struct ompi_ctcontroller *,
|
||||
ompi_ctmsg_t *,
|
||||
void *);
|
||||
|
||||
typedef void (*ompi_ctnode_failed_fn)(struct ompi_ctcontroller *,
|
||||
ompi_ctnode_t *,
|
||||
void *);
|
||||
|
||||
typedef struct ompi_ctcontroller
|
||||
{
|
||||
ompi_object_t super;
|
||||
ompi_ctnode_t ctl_node;
|
||||
void *ctl_user_info;
|
||||
ompi_ctmsg_recvd_fn ctl_msg_recvd_callback;
|
||||
ompi_ctnode_failed_fn ctl_node_failed_callback;
|
||||
} ompi_ctctrl_t;
|
||||
|
||||
void ompi_ctl_construct(ompi_ctctrl_t *ctrl);
|
||||
void ompi_ctl_destruct(ompi_ctctrl_t *ctrl);
|
||||
|
||||
inline void ompi_ctl_set_recvd_callback(ompi_ctctrl_t *ctrl, ompi_ctmsg_recvd_fn callback)
|
||||
{
|
||||
ctrl->ctl_msg_recvd_callback = callback;
|
||||
}
|
||||
|
||||
|
||||
inline void ompi_ctl_set_failed_callback(ompi_ctctrl_t *ctrl, ompi_ctnode_failed_fn callback)
|
||||
{
|
||||
ctrl->ctl_node_failed_callback = callback;
|
||||
}
|
||||
|
||||
|
||||
#endif /* OMPI_CT_CONTROLLER_H */
|
@ -1,267 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "ctnetwork/ctmessage.h"
|
||||
|
||||
|
||||
ompi_class_t ompi_ct_ctrl_t_class = {
|
||||
"ompi_ct_ctrl_t",
|
||||
OBJ_CLASS(ompi_object_t),
|
||||
(ompi_construct_t) ompi_ctc_construct,
|
||||
(ompi_destruct_t) ompi_ctc_destruct
|
||||
};
|
||||
|
||||
|
||||
ompi_class_t ompi_ctmsg_t_class = {
|
||||
"ompi_ctmsg_t",
|
||||
OBJ_CLASS(ompi_object_t),
|
||||
(ompi_construct_t) ompi_ctm_construct,
|
||||
(ompi_destruct_t) ompi_ctm_destruct
|
||||
};
|
||||
|
||||
|
||||
static const uint32_t ctrl_alloc_len = sizeof(ompi_ct_ctrl_t) -
|
||||
sizeof(ompi_object_t) - sizeof(ctrl->ctc_info);
|
||||
|
||||
void ompi_ctc_construct(ompi_ct_ctrl_t *ctrl)
|
||||
{
|
||||
ctrl->ctc_is_user_msg = 0;
|
||||
ctrl->ctc_routing_type = OMPI_CT_PT2PT;
|
||||
ctrl->ctc_sender = 0;
|
||||
ctrl->ctc_dest = 0;
|
||||
ctrl->ctc_forwarding = 0;
|
||||
ctrl->ctc_client_tag = 0;
|
||||
ctrl->ctc_info_len = 0;
|
||||
ctrl->ctc_info = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ompi_ctc_destruct(ompi_ct_ctrl_t *ctrl)
|
||||
{
|
||||
ompi_free(ctrl->ctc_info);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ompi_ctc_construct_with(ompi_ct_ctrl_t *ctrl, int routing_type,
|
||||
uint32_t sender, uint32_t dest)
|
||||
{
|
||||
ctrl->ctc_routing_type = routing_type;
|
||||
ctrl->ctc_sender = sender;
|
||||
ctrl->ctc_dest = dest;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ompi_ctc_pack_size(ompi_ct_ctrl_t *ctrl)
|
||||
{
|
||||
return ctrl_alloc_len + ctrl->ctc_info_len;
|
||||
}
|
||||
|
||||
uint8_t *ompi_ctc_pack(ompi_ct_ctrl_t *ctrl, uint32_t *len)
|
||||
{
|
||||
/* ASSERT: packed control struct looks like
|
||||
<ctc_is_user_msg (uint16_t)><ctc_routing_type (uint16_t)>
|
||||
<ctc_sender (uint32_t)><ctc_dest (uint32_t)>
|
||||
<ctc_forwarding (uint32_t)><ctc_client_tag (uint32_t)>
|
||||
<ctc_info_len (uint32_t)><ctc_info (uint8_t *)>
|
||||
*/
|
||||
uint8_t *buffer;
|
||||
|
||||
buffer = (uint8_t *) ompi_malloc(ctrl_alloc_len + ctrl->ctc_info_len);
|
||||
if (0 == buffer) {
|
||||
return 0;
|
||||
}
|
||||
ompi_ctc_pack_buffer(ctrl, buffer, len);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ompi_ct_ctrl_t *ompi_ctc_unpack(uint8_t *buffer)
|
||||
{
|
||||
ompi_ct_ctrl_t *ctrl;
|
||||
|
||||
/* ASSERT: packed control struct looks like
|
||||
<ctc_is_user_msg (uint16_t)><ctc_routing_type (uint16_t)>
|
||||
<ctc_sender (uint32_t)><ctc_dest (uint32_t)>
|
||||
<ctc_forwarding (uint32_t)><ctc_client_tag (uint32_t)>
|
||||
<ctc_info_len (uint32_t)><ctc_info (uint8_t *)>
|
||||
*/
|
||||
ctrl = OBJ_NEW(ompi_ct_ctrl_t);
|
||||
if (0 == ctrl) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(&(ctrl->ctc_is_user_msg), buffer, ctrl_alloc_len);
|
||||
ctrl->ctc_info = (uint8_t *) ompi_malloc(ctrl->ctc_info_len);
|
||||
if (0 == ctrl->ctc_info) {
|
||||
OBJ_RELEASE(ctrl);
|
||||
return 0;
|
||||
}
|
||||
memcpy(ctrl->ctc_info, buffer + ctrl_alloc_len, ctrl->ctc_info_len);
|
||||
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ompi_ctc_pack_buffer(ompi_ct_ctrl_t *ctrl, uint8_t *buffer,
|
||||
uint32_t *len)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
memcpy(buffer, &(ctrl->ctc_is_user_msg), ctrl_alloc_len);
|
||||
memcpy(buffer + ctrl_alloc_len, ctrl->ctc_info);
|
||||
*len = ctrl_alloc_len + ctrl->ctc_info_len;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ompi_ctc_unpack_buffer(ompi_ct_ctrl_t *ctrl, uint8_t *buffer,
|
||||
uint32_t *len)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Functions for accessing data in packed
|
||||
* control struct.
|
||||
*/
|
||||
|
||||
uint16_t ompi_pk_ctc_is_user_msg(uint8_t *buffer)
|
||||
{
|
||||
return *((uint16_t *) buffer);
|
||||
}
|
||||
|
||||
uint16_t ompi_pk_ctc_get_routing_type(uint8_t *buffer)
|
||||
{
|
||||
return *(uint16_t *) (buffer + sizeof(uint16_t));
|
||||
}
|
||||
|
||||
uint32_t ompi_pk_ctc_get_sender(uint8_t *buffer)
|
||||
{
|
||||
return *(uint32_t *) (buffer + 2 * sizeof(uint16_t));
|
||||
}
|
||||
|
||||
uint32_t ompi_pkctc_get_dest(uint8_t *buffer)
|
||||
{
|
||||
return *(uint32_t *) (buffer + 2 * sizeof(uint16_t) +
|
||||
sizeof(uint32_t));
|
||||
}
|
||||
|
||||
uint32_t ompi_pk_ctc_get_forwarding(uint8_t *buffer)
|
||||
{
|
||||
return *(uint32_t *) (buffer + 2 * sizeof(uint16_t)
|
||||
+ 2 * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
void ompi_pk_ctc_set_forwarding(uint8_t *buffer, uint32_t node)
|
||||
{
|
||||
memcpy(buffer + 2 * sizeof(uint16_t) + 2 * sizeof(uint32_t),
|
||||
&node, sizeof(node));
|
||||
}
|
||||
|
||||
uint8_t *ompi_pk_ctc_get_info(uint8_t *buffer, uint32_t *len)
|
||||
{
|
||||
memcpy(len, buffer + ctrl_alloc_len - sizeof(uint32_t),
|
||||
sizeof(uint32_t));
|
||||
return buffer + ctrl_alloc_len;
|
||||
}
|
||||
|
||||
void ompi_pk_ctc_set_info(uint8_t *buffer, uint8_t *info)
|
||||
{
|
||||
uint32_t len;
|
||||
|
||||
memcpy(&len, buffer + ctrl_alloc_len - sizeof(uint32_t),
|
||||
sizeof(uint32_t));
|
||||
memcpy(buffer + ctrl_alloc_len, info, len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Message interface
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
void ompi_ctm_construct(ompi_ctmsg_t *msg)
|
||||
{
|
||||
msg->ctm_ctrl = OBJ_NEW(ompi_ct_ctrl_t);
|
||||
msg->ctm_len = 0;
|
||||
msg->ctm_data = 0;
|
||||
msg->ctm_should_free = 1;
|
||||
}
|
||||
|
||||
void ompi_ctm_destruct(ompi_ctmsg_t *msg)
|
||||
{
|
||||
if (msg->ctm_should_free) {
|
||||
ompi_free(msg->ctm_data);
|
||||
}
|
||||
OBJECT_RELEASE(msg->ctm_ctrl);
|
||||
}
|
||||
|
||||
ompi_ctmsg_t *ompi_ctm_create_with(int is_user_msg, int routing_type,
|
||||
uint32_t sender,
|
||||
uint32_t dest, uint8_t *data,
|
||||
uint32_t data_len, int should_free)
|
||||
{
|
||||
ompi_ctmsg_t *msg;
|
||||
|
||||
msg = OBJ_NEW(ompi_ctmsg_t);
|
||||
if (0 == msg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
OBJ_CONSTRUCT(&msg->ctm_ctrl, ompi_ct_ctrl_t);
|
||||
ompi_ctc_construct_with(&(msg->ctm_ctrl), sender, dest);
|
||||
msg->ctm_should_free = should_free;
|
||||
msg->ctm_data = data;
|
||||
msg->ctm_len = data_len;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
uint8_t *ompi_ctm_pack(ompi_ctmsg_t *msg)
|
||||
{
|
||||
/* packed msg layout
|
||||
<msg len (uint32_t)><packed ctrl><data len (uint32_t)>
|
||||
<data>
|
||||
*/
|
||||
uint32_t len;
|
||||
|
||||
|
||||
}
|
||||
|
||||
ompi_ctmsg_t *ompi_ctm_unpack(uint8_t *buffer)
|
||||
{
|
||||
/* packed msg layout
|
||||
<msg len (uint32_t)><packed ctrl><data len (uint32_t)>
|
||||
<data>
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Functions for accessing data in packed
|
||||
* msg struct.
|
||||
*/
|
||||
|
||||
uint8_t *ompi_pk_ctm_get_control(uint8_t *buffer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint8_t *ompi_pk_ctm_get_data(uint8_t *buffer, uint32_t *len)
|
||||
{
|
||||
|
||||
}
|
@ -1,228 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OMPI_CT_MESSAGE_H
|
||||
#define OMPI_CT_MESSAGE_H
|
||||
|
||||
#include "class/ompi_object.h"
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Available Classes
|
||||
*
|
||||
*/
|
||||
|
||||
extern ompi_class_t ompi_ct_ctrl_t_class;
|
||||
extern ompi_class_t ompi_ctmsg_t_class;
|
||||
|
||||
/*
|
||||
*
|
||||
* CT Message interface
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Message control info for routing msgs.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Message routing type
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
OMPI_CT_BCAST = 1,
|
||||
OMPI_CT_ALLGATHER,
|
||||
OMPI_CT_SCATTER,
|
||||
OMPI_CT_PT2PT
|
||||
};
|
||||
|
||||
/*
|
||||
* Msg control interface to
|
||||
* contain routing information.
|
||||
* Can be reused by multiple msgs
|
||||
* if routing info is the same.
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct ompi_ct_ctrl
|
||||
{
|
||||
ompi_object_t super;
|
||||
uint16_t ctc_is_user_msg; /* 1 -> msg is for user app. */
|
||||
uint16_t ctc_routing_type; /* broadcast, scatter, pt2pt, etc. */
|
||||
uint32_t ctc_sender; /* node that initiated send. */
|
||||
uint32_t ctc_dest; /* destination node. */
|
||||
uint32_t ctc_forwarding; /* node that is relaying msg. */
|
||||
uint32_t ctc_client_tag; /* tag if client sent msg. */
|
||||
uint32_t ctc_info_len;
|
||||
uint8_t *ctc_info;
|
||||
} ompi_ct_ctrl_t;
|
||||
|
||||
|
||||
void ompi_ctc_construct(ompi_ct_ctrl_t *ctrl);
|
||||
void ompi_ctc_destruct(ompi_ct_ctrl_t *ctrl);
|
||||
|
||||
void ompi_ctc_construct_with(ompi_ct_ctrl_t *ctrl, int routing_type,
|
||||
uint32_t sender,
|
||||
uint32_t dest);
|
||||
|
||||
uint32_t ompi_ctc_pack_size(ompi_ct_ctrl_t *ctrl);
|
||||
uint8_t *ompi_ctc_pack(ompi_ct_ctrl_t *ctrl, uint32_t *len);
|
||||
ompi_ct_ctrl_t *ompi_ctc_unpack(uint8_t *buffer);
|
||||
|
||||
int ompi_ctc_pack_buffer(ompi_ct_ctrl_t *ctrl, uint8_t *buffer, uint32_t *len);
|
||||
int ompi_ctc_unpack_buffer(ompi_ct_ctrl_t *ctrl, uint8_t *buffer, uint32_t *len);
|
||||
|
||||
/*
|
||||
* Functions for accessing data in packed
|
||||
* control struct.
|
||||
*/
|
||||
|
||||
uint16_t ompi_pk_ctc_is_user_msg(uint8_t *buffer);
|
||||
|
||||
uint16_t ompi_pk_ctc_get_routing_type(uint8_t *buffer);
|
||||
|
||||
uint32_t ompi_pk_ctc_get_sender(uint8_t *buffer);
|
||||
|
||||
uint32_t ompi_pk_ctc_get_dest(uint8_t *buffer);
|
||||
|
||||
uint32_t ompi_pk_ctc_get_forwarding(uint8_t *buffer);
|
||||
void ompi_pk_ctc_set_forwarding(uint8_t *buffer, uint32_t node);
|
||||
|
||||
uint8_t *ompi_pk_ctc_get_info(uint8_t *buffer, uint32_t *len);
|
||||
void ompi_pk_ctc_set_info(uint8_t *buffer, uint8_t *info);
|
||||
|
||||
/*
|
||||
* Accessor functions
|
||||
*/
|
||||
|
||||
bool ompi_ctc_get_is_user_msg(ompi_ct_ctrl_t *ctrl);
|
||||
inline bool ompi_ctc_get_is_user_msg(ompi_ct_ctrl_t *ctrl)
|
||||
{
|
||||
return ctrl->ctc_is_user_msg;
|
||||
}
|
||||
void ompi_ctc_set_is_user_msg(ompi_ct_ctrl_t *ctrl, bool yn);
|
||||
inline void ompi_ctc_set_is_user_msg(ompi_ct_ctrl_t *ctrl, bool yn)
|
||||
{
|
||||
ctrl->ctc_is_user_msg = yn;
|
||||
}
|
||||
|
||||
uint16_t ompi_ctc_get_routing_type(ompi_ct_ctrl_t *ctrl);
|
||||
inline uint16_t ompi_ctc_get_routing_type(ompi_ct_ctrl_t *ctrl)
|
||||
{
|
||||
return ctrl->ctc_routing_type;
|
||||
}
|
||||
void ompi_ctc_set_routing_type(ompi_ct_ctrl_t *ctrl, int rtype);
|
||||
inline void ompi_ctc_set_routing_type(ompi_ct_ctrl_t *ctrl, int rtype)
|
||||
{
|
||||
ctrl->ctc_routing_type = rtype;
|
||||
}
|
||||
|
||||
uint32_t ompi_ctc_get_sender(ompi_ct_ctrl_t *ctrl);
|
||||
inline uint32_t ompi_ctc_get_sender(ompi_ct_ctrl_t *ctrl)
|
||||
{
|
||||
return ctrl->ctc_sender;
|
||||
}
|
||||
void ompi_ctc_set_sender(ompi_ct_ctrl_t *ctrl, uint32_t sender);
|
||||
inline void ompi_ctc_set_sender(ompi_ct_ctrl_t *ctrl, uint32_t sender)
|
||||
{
|
||||
ctrl->ctc_sender = sender;
|
||||
}
|
||||
|
||||
uint32_t ompi_ctc_get_dest(ompi_ct_ctrl_t *ctrl);
|
||||
inline uint32_t ompi_ctc_get_dest(ompi_ct_ctrl_t *ctrl)
|
||||
{
|
||||
return ctrl->ctc_dest;
|
||||
}
|
||||
void ompi_ctc_set_dest(ompi_ct_ctrl_t *ctrl, uint32_t dest);
|
||||
inline void ompi_ctc_set_dest(ompi_ct_ctrl_t *ctrl, uint32_t dest)
|
||||
{
|
||||
ctrl->ctc_dest = dest;
|
||||
}
|
||||
|
||||
uint32_t ompi_ctc_get_forwarding(ompi_ct_ctrl_t *ctrl);
|
||||
inline uint32_t ompi_ctc_get_forwarding(ompi_ct_ctrl_t *ctrl)
|
||||
{
|
||||
return ctrl->ctc_forwarding;
|
||||
}
|
||||
void ompi_ctc_set_forwarding(ompi_ct_ctrl_t *ctrl, uint32_t node);
|
||||
inline void ompi_ctc_set_forwarding(ompi_ct_ctrl_t *ctrl, uint32_t node)
|
||||
{
|
||||
ctrl->ctc_forwarding = node;
|
||||
}
|
||||
|
||||
uint8_t *ompi_ctc_get_info(ompi_ct_ctrl_t *ctrl, uint32_t *len);
|
||||
inline uint8_t *ompi_ctc_get_info(ompi_ct_ctrl_t *ctrl, uint32_t *len)
|
||||
{
|
||||
*len = ctrl->ctc_info_len;
|
||||
return ctrl->ctc_info;
|
||||
}
|
||||
|
||||
void ompi_ctc_set_info(ompi_ct_ctrl_t *ctrl, uint32_t len, uint8_t *info);
|
||||
inline void ompi_ctc_set_info(ompi_ct_ctrl_t *ctrl, uint32_t len, uint8_t *info)
|
||||
{
|
||||
ctrl->ctc_info_len = len;
|
||||
ctrl->ctc_info = info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Message interface
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
typedef struct ompi_ctmsg
|
||||
{
|
||||
ompi_object_t super;
|
||||
ompi_ct_ctrl_t *ctm_ctrl;
|
||||
uint32_t ctm_len;
|
||||
uint8_t *ctm_data;
|
||||
int ctm_should_free;
|
||||
} ompi_ctmsg_t;
|
||||
|
||||
|
||||
void ompi_ctm_construct(ompi_ctmsg_t *msg);
|
||||
void ompi_ctm_destruct(ompi_ctmsg_t *msg);
|
||||
|
||||
ompi_ctmsg_t *ompi_ctm_create_with(int is_user_msg, int routing_type,
|
||||
uint32_t sender,
|
||||
uint32_t dest, uint8_t *data,
|
||||
uint32_t data_len,
|
||||
int should_free);
|
||||
|
||||
uint8_t *ompi_ctm_pack(ompi_ctmsg_t *msg);
|
||||
ompi_ctmsg_t *ompi_ctm_unpack(uint8_t *buffer);
|
||||
|
||||
/*
|
||||
* Functions for accessing data in packed
|
||||
* msg struct.
|
||||
*/
|
||||
|
||||
uint8_t *ompi_pk_ctm_get_control(uint8_t *buffer);
|
||||
uint8_t *ompi_pk_ctm_get_data(uint8_t *buffer, uint32_t *len);
|
||||
|
||||
/*
|
||||
*
|
||||
* Accessor functions
|
||||
*
|
||||
*/
|
||||
|
||||
ompi_ct_ctrl_t *ompi_ctm_get_control(ompi_ctmsg_t *msg);
|
||||
inline ompi_ct_ctrl_t *ompi_ctm_get_control(ompi_ctmsg_t *msg)
|
||||
{
|
||||
return msg->ctm_ctrl;
|
||||
}
|
||||
void ompi_ctm_set_control(ompi_ctmsg_t *msg, ompi_ct_ctrl_t *ctrl);
|
||||
inline void ompi_ctm_set_control(ompi_ctmsg_t *msg, ompi_ct_ctrl_t *ctrl)
|
||||
{
|
||||
msg->ctm_ctrl = ctrl;
|
||||
}
|
||||
|
||||
|
||||
#endif /* OMPI_CT_MESSAGE_H */
|
@ -1,6 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "ctnetwork/ctnode.h"
|
||||
|
@ -1,157 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OMPI_CT_NODE_H
|
||||
#define OMPI_CT_NODE_H
|
||||
|
||||
#include "class/ompi_object.h"
|
||||
#include "class/hash_table.h"
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Abstract topology node class
|
||||
*
|
||||
*/
|
||||
|
||||
#define CTNODE(obj) (ompi_ctnode_t *)(obj)
|
||||
|
||||
struct ompi_ctnode;
|
||||
|
||||
typedef uint32_t (*ompi_ctl_label_for_link_fn_t)(struct ompi_ctnode *, uint32_t);
|
||||
typedef char *(*ompi_ctl_isa_neighbor_fn_t)(struct ompi_ctnode *, uint32_t);
|
||||
|
||||
typedef struct ompi_ctnode_class
|
||||
{
|
||||
ompi_class_t super;
|
||||
ompi_ctl_label_for_link_fn_t *ctl_label_for_link;
|
||||
ompi_ctl_isa_neighbor_fn_t *ctl_isa_neighbor;
|
||||
} ompi_ctnode_class_t;
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Available concrete topology classes
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
extern ompi_ctnode_class_t hypercube_t_class;
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Abstract topology node interface
|
||||
* every concrete topology should derive from this class.
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct ompi_ctnode
|
||||
{
|
||||
ompi_object_t super;
|
||||
uint32_t ctn_label;
|
||||
uint32_t ctn_num_nodes; /* total # of nodes in network */
|
||||
void *ctn_user_info;
|
||||
ompi_fast_hash_t ctn_neighbors;
|
||||
ompi_fast_hash_t ctn_scatter_cache;
|
||||
ompi_fast_hash_t ctn_bcast_cache;
|
||||
} ompi_ctnode_t;
|
||||
|
||||
|
||||
void ompi_ctn_construct(ompi_ctnode_t *node);
|
||||
void ompi_ctn_destruct(ompi_ctnode_t *node);
|
||||
|
||||
/*
|
||||
*
|
||||
* Functions for managing neighbors
|
||||
*
|
||||
*/
|
||||
|
||||
void *ompi_ctn_get_neighbor(ompi_ctnode_t *node, uint32_t neighbor_label);
|
||||
/*
|
||||
PRE: neighbor_label is the label of the node's neighbor
|
||||
POST: returns a pointer to the node's neighbor
|
||||
*/
|
||||
|
||||
void ompi_ctn_set_neighbor(ompi_ctnode_t *node, uint32_t label, void *neighbor);
|
||||
/*
|
||||
PRE: label represents the label for a valid neighbor.
|
||||
POST: Adds a link to a neighbor with specified label.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Accessor functions
|
||||
*
|
||||
*/
|
||||
|
||||
inline uint32_t ompi_ctn_get_label(ompi_ctnode_t *node) {return node->ctn_label;}
|
||||
inline void ompi_ctn_set_label(ompi_ctnode_t *node, uint32_t label)
|
||||
{node->ctn_label = label;}
|
||||
|
||||
inline uint32_t ompi_ctn_get_num_nodes(ompi_ctnode_t *node) {return node->ctn_num_nodes;}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* "PURE VIRTUAL" functions that must be implemented
|
||||
* by the concrete subclass.
|
||||
*
|
||||
*/
|
||||
|
||||
int ompi_ctn_isa_neighbor(ompi_ctnode_t *node, uint32_t label);
|
||||
/*
|
||||
POST: returns 1 if a node with specified label is a label for
|
||||
a neighbor node. This does not imply that the get_neighbor() function
|
||||
would return non-NULL; it only verifies that the label is a valid label
|
||||
for a neighbor.
|
||||
*/
|
||||
|
||||
|
||||
uint32_t ompi_ctn_label_for_link(ompi_ctnode_t *node, uint32_t link);
|
||||
/*
|
||||
PRE: The graph edges connecting node to its neighbors are oriented
|
||||
so that the links (edges) are numbered starting from 1.
|
||||
POST: Returns the label of neighbor connected to node via given link.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* "PURE VIRTUAL" routing functions that must be implemented
|
||||
* by the concrete subclass.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
char *ompi_ctn_initial_control_data(ompi_ctnode_t *node, uint32_t *ctrl_size);
|
||||
/*
|
||||
POST: Returns pointer to byte array for control data for routing
|
||||
messages. The length of the control array is stored in
|
||||
ctrl_size. Caller must free array.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Hypercube interface
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct ompi_hcube
|
||||
{
|
||||
ompi_ctnode_t super;
|
||||
unsigned int hc_hsize; /* hc_hsize = log2(# nodes in network) */
|
||||
} ompi_hcube_t;
|
||||
|
||||
extern ompi_class_t hcube_t_class;
|
||||
|
||||
#endif /* OMPI_CT_NODE_H */
|
@ -1,6 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "ctnetwork/ctpeer.h"
|
||||
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OMPI_CT_PEER_H
|
||||
#define OMPI_CT_PEER_H
|
||||
|
||||
#include "class/ompi_object.h"
|
||||
|
||||
#endif /* OMPI_CT_PEER_H */
|
Загрузка…
x
Ссылка в новой задаче
Block a user