2006-08-23 03:32:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2007-06-08 22:59:31 +00:00
|
|
|
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
|
|
|
* Copyright (c) 2007 Cisco, Inc. All rights reserved.
|
2006-08-23 03:32:36 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2005-01-12 20:51:34 +00:00
|
|
|
#ifndef _IOF_BASE_ENDPOINT_
|
|
|
|
#define _IOF_BASE_ENDPOINT_
|
|
|
|
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "orte_config.h"
|
2005-07-03 16:22:16 +00:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-07-03 23:09:55 +00:00
|
|
|
#include "opal/event/event.h"
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "orte/mca/iof/iof.h"
|
|
|
|
#include "orte/mca/iof/base/iof_base_header.h"
|
2005-01-12 20:51:34 +00:00
|
|
|
|
2007-06-08 22:59:31 +00:00
|
|
|
BEGIN_C_DECLS
|
2005-01-12 20:51:34 +00:00
|
|
|
|
2005-11-10 04:49:51 +00:00
|
|
|
/**
|
|
|
|
* Structure store callbacks
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct orte_iof_base_callback_t {
|
|
|
|
opal_list_item_t super;
|
|
|
|
orte_iof_base_callback_fn_t cb_func;
|
|
|
|
void* cb_data;
|
|
|
|
};
|
|
|
|
typedef struct orte_iof_base_callback_t orte_iof_base_callback_t;
|
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
ORTE_DECLSPEC OBJ_CLASS_DECLARATION(orte_iof_base_callback_t);
|
2005-11-10 04:49:51 +00:00
|
|
|
|
2005-01-13 15:27:28 +00:00
|
|
|
/**
|
|
|
|
* Structure that represents a published endpoint.
|
|
|
|
*/
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
struct orte_iof_base_endpoint_t {
|
2007-06-08 22:59:31 +00:00
|
|
|
/** Parent */
|
2005-07-03 16:22:16 +00:00
|
|
|
opal_list_item_t super;
|
2007-06-08 22:59:31 +00:00
|
|
|
/** ORTE_IOF_SOURCE or ORTE_IOF_SINK */
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_mode_t ep_mode;
|
2007-06-08 22:59:31 +00:00
|
|
|
/** The origin process for this endpoint. Will either by myself
|
|
|
|
(i.e., it's an fd that represents a source or a sink in my
|
|
|
|
process) or another process (i.e., this process is acting as a
|
|
|
|
proxy for another process and [typically] has a pipe/fd optn
|
|
|
|
to that process to get their stdin, stdout, or stderr). */
|
|
|
|
orte_process_name_t ep_origin;
|
|
|
|
/** Predefined tags: ORTE_IOF_ANY, ORTE_IOF_STDIN, ORTE_IOF_STDOUT,
|
|
|
|
ORTE_IOF_STDERR */
|
2005-01-12 20:51:34 +00:00
|
|
|
int ep_tag;
|
2007-06-08 22:59:31 +00:00
|
|
|
/** File descriptor to read or write from (or -1 if it has been
|
|
|
|
closed */
|
2005-01-12 20:51:34 +00:00
|
|
|
int ep_fd;
|
2007-06-08 22:59:31 +00:00
|
|
|
/** Rollover byte count of what has been forwarded from the fd to
|
|
|
|
other targets */
|
2005-01-12 20:51:34 +00:00
|
|
|
uint32_t ep_seq;
|
2007-06-08 22:59:31 +00:00
|
|
|
/** Minimum byte count of what has been ACK'ed from all the targets
|
|
|
|
that are listening to this endpoint */
|
2005-01-12 20:51:34 +00:00
|
|
|
uint32_t ep_ack;
|
2007-06-08 22:59:31 +00:00
|
|
|
/** Event library event for this file descriptor */
|
2005-07-03 23:09:55 +00:00
|
|
|
opal_event_t ep_event;
|
2007-06-08 22:59:31 +00:00
|
|
|
/** Special event library event for the case of stdin */
|
2006-02-04 23:26:58 +00:00
|
|
|
opal_event_t ep_stdin_event;
|
2007-06-08 22:59:31 +00:00
|
|
|
/** The list for fragments that are in-flight from a SOURCE
|
|
|
|
endpoint */
|
|
|
|
opal_list_t ep_source_frags;
|
|
|
|
/** The list for fragments that are in-flight from a SINK
|
|
|
|
endpoint */
|
|
|
|
opal_list_t ep_sink_frags;
|
|
|
|
/** List of callbacks for subscriptions */
|
2005-11-10 04:49:51 +00:00
|
|
|
opal_list_t ep_callbacks;
|
2005-01-12 20:51:34 +00:00
|
|
|
};
|
2005-03-14 20:57:21 +00:00
|
|
|
typedef struct orte_iof_base_endpoint_t orte_iof_base_endpoint_t;
|
2005-01-12 20:51:34 +00:00
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
ORTE_DECLSPEC OBJ_CLASS_DECLARATION(orte_iof_base_endpoint_t);
|
2005-01-12 20:51:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Diff between two sequence numbers allowing for rollover
|
|
|
|
*/
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
#define ORTE_IOF_BASE_SEQDIFF(s1,s2) \
|
2005-10-18 14:26:12 +00:00
|
|
|
((s1 >= s2) ? (s1 - s2) : (s1 + (ULONG_MAX - s2)))
|
2005-01-12 20:51:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2005-01-13 15:27:28 +00:00
|
|
|
* Create a local endpoint.
|
|
|
|
*
|
2007-06-08 22:59:31 +00:00
|
|
|
* @param name Origin process name corresponding to endpoint.
|
2005-01-13 15:27:28 +00:00
|
|
|
* @param mode Source or sink of data (exclusive).
|
|
|
|
* @param tag Logical tag for matching.
|
2007-06-08 22:59:31 +00:00
|
|
|
* @param fd Local file descriptor corresponding to endpoint. If the
|
|
|
|
* endpoint originates in this process, it'll be an fd in this
|
|
|
|
* process. If this process is acting as a proxy for another process,
|
|
|
|
* then the fd will be a pipe to that other process (e.g., the origin
|
|
|
|
* process' stdin, stdout, or stderr).
|
2005-01-12 20:51:34 +00:00
|
|
|
*/
|
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
ORTE_DECLSPEC int orte_iof_base_endpoint_create(
|
2005-03-14 20:57:21 +00:00
|
|
|
const orte_process_name_t* name,
|
|
|
|
orte_iof_base_mode_t mode,
|
2005-01-12 20:51:34 +00:00
|
|
|
int tag,
|
|
|
|
int fd);
|
|
|
|
|
2005-11-10 04:49:51 +00:00
|
|
|
/**
|
|
|
|
* Associate a callback on receipt of data.
|
|
|
|
*
|
|
|
|
* @param name Process name corresponding to endpoint.
|
|
|
|
* @param cbfunc Logical tag for matching.
|
|
|
|
* @aram cbdata Local file descriptor corresponding to endpoint.
|
|
|
|
*/
|
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
ORTE_DECLSPEC int orte_iof_base_callback_create(
|
2005-11-10 04:49:51 +00:00
|
|
|
const orte_process_name_t *name,
|
|
|
|
int tag,
|
|
|
|
orte_iof_base_callback_fn_t cbfunc,
|
|
|
|
void* cbdata);
|
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
ORTE_DECLSPEC int orte_iof_base_callback_delete(
|
2005-11-10 04:49:51 +00:00
|
|
|
const orte_process_name_t *name,
|
|
|
|
int tag);
|
|
|
|
|
|
|
|
|
2005-01-12 20:51:34 +00:00
|
|
|
/**
|
2007-06-08 22:59:31 +00:00
|
|
|
* Delete all local endpoints matching the specified origin / mask /
|
|
|
|
* tag parameters.
|
2005-01-12 20:51:34 +00:00
|
|
|
*
|
2007-06-08 22:59:31 +00:00
|
|
|
* @paran name Origin process name corresponding to one or more endpoint(s).
|
2005-01-13 15:27:28 +00:00
|
|
|
* @param mask Mask used for name comparisons.
|
|
|
|
* @param tag Tag for matching endpoints.
|
2005-01-12 20:51:34 +00:00
|
|
|
*/
|
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
ORTE_DECLSPEC int orte_iof_base_endpoint_delete(
|
2005-03-14 20:57:21 +00:00
|
|
|
const orte_process_name_t* name,
|
|
|
|
orte_ns_cmp_bitmask_t mask,
|
2005-01-12 20:51:34 +00:00
|
|
|
int tag);
|
|
|
|
|
2005-01-13 15:27:28 +00:00
|
|
|
/**
|
|
|
|
* Disable forwarding through the specified endpoint.
|
2005-01-12 20:51:34 +00:00
|
|
|
*/
|
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
ORTE_DECLSPEC int orte_iof_base_endpoint_close(
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_endpoint_t* endpoint);
|
2005-01-12 20:51:34 +00:00
|
|
|
|
|
|
|
/**
|
2007-06-08 22:59:31 +00:00
|
|
|
* Attempt to match an endpoint based on the origin process name /
|
|
|
|
* mask / tag.
|
2005-01-12 20:51:34 +00:00
|
|
|
*/
|
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
ORTE_DECLSPEC orte_iof_base_endpoint_t* orte_iof_base_endpoint_match(
|
2007-06-08 22:59:31 +00:00
|
|
|
const orte_process_name_t* target_name,
|
|
|
|
orte_ns_cmp_bitmask_t target_mask,
|
|
|
|
int target_tag);
|
2005-01-12 20:51:34 +00:00
|
|
|
|
|
|
|
/**
|
2005-01-13 15:27:28 +00:00
|
|
|
* Forward the specified message out the endpoint.
|
2005-01-12 20:51:34 +00:00
|
|
|
*/
|
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
ORTE_DECLSPEC int orte_iof_base_endpoint_forward(
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_endpoint_t* endpoint,
|
2007-06-08 22:59:31 +00:00
|
|
|
const orte_process_name_t* origin,
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_msg_header_t* hdr,
|
2005-01-12 20:51:34 +00:00
|
|
|
const unsigned char* data);
|
|
|
|
|
|
|
|
/*
|
2007-06-08 22:59:31 +00:00
|
|
|
* Close the file descriptor associated with an endpoint and perform
|
|
|
|
* any necessary cleanup.
|
2005-01-12 20:51:34 +00:00
|
|
|
*/
|
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
ORTE_DECLSPEC void orte_iof_base_endpoint_closed(
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_endpoint_t* endpoint);
|
2005-01-12 20:51:34 +00:00
|
|
|
|
|
|
|
/**
|
2007-06-08 22:59:31 +00:00
|
|
|
* Callback when the next set of bytes has been acknowledged.
|
2005-01-12 20:51:34 +00:00
|
|
|
*/
|
2005-01-13 15:27:28 +00:00
|
|
|
|
2006-08-23 03:32:36 +00:00
|
|
|
ORTE_DECLSPEC int orte_iof_base_endpoint_ack(
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_iof_base_endpoint_t* endpoint,
|
2005-01-12 20:51:34 +00:00
|
|
|
uint32_t seq);
|
|
|
|
|
2005-01-14 00:11:24 +00:00
|
|
|
/**
|
2007-06-08 22:59:31 +00:00
|
|
|
* Simple check for whether we have any frags "in flight".
|
|
|
|
*
|
|
|
|
* Return "true" for SOURCEs if source_frags is not empty, indicating
|
|
|
|
* that there are frags in-flight via the RML.
|
|
|
|
*
|
|
|
|
* Return "true" for SINKs if sink_frags is not empty, indicating that
|
|
|
|
* there are pending frags for the fd that are either partially
|
|
|
|
* written or have not yet been written (because writing to the fd
|
|
|
|
* would have blocked).
|
2005-01-14 00:11:24 +00:00
|
|
|
*/
|
2007-06-08 22:59:31 +00:00
|
|
|
bool orte_iof_base_endpoint_have_pending_frags(
|
|
|
|
orte_iof_base_endpoint_t* endpoint);
|
2005-01-14 00:11:24 +00:00
|
|
|
|
2007-06-08 22:59:31 +00:00
|
|
|
/**
|
|
|
|
* Simple check for whether we have all the ACKs that we expect.
|
|
|
|
*
|
|
|
|
* Return "true" for SOURCEs if ep_seq == ep_ack.
|
|
|
|
*
|
|
|
|
* Return "true" for SINKs always; SINK endpoints don't receive ACKs.
|
|
|
|
*/
|
|
|
|
bool orte_iof_base_endpoint_have_pending_acks(
|
|
|
|
orte_iof_base_endpoint_t* endpoint);
|
2005-01-14 00:11:24 +00:00
|
|
|
|
2007-06-08 22:59:31 +00:00
|
|
|
END_C_DECLS
|
2006-08-23 03:32:36 +00:00
|
|
|
|
2005-01-12 20:51:34 +00:00
|
|
|
#endif
|
|
|
|
|