2005-08-02 17:20:50 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2015-01-09 02:50:05 +03:00
|
|
|
* Copyright (c) 2004-2015 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2014-12-13 09:59:55 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2005-08-02 17:20:50 +04:00
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2008-11-05 21:45:42 +03:00
|
|
|
* Copyright (c) 2007-2008 Sun Microsystems, Inc. All rights reserved.
|
2014-01-08 19:12:50 +04:00
|
|
|
* Copyright (c) 2013 Cisco Systems, Inc. All rights reserved.
|
|
|
|
* Copyright (c) 2014 Intel, Inc. All rights reserved.
|
2015-01-08 09:40:16 +03:00
|
|
|
* Copyright (c) 2015 Research Organization for Information Science
|
|
|
|
* and Technology (RIST). All rights reserved.
|
2005-08-02 17:20:50 +04:00
|
|
|
* $COPYRIGHT$
|
2014-12-13 09:59:55 +03:00
|
|
|
*
|
2005-08-02 17:20:50 +04:00
|
|
|
* Additional copyrights may follow
|
2014-12-13 09:59:55 +03:00
|
|
|
*
|
2005-08-02 17:20:50 +04:00
|
|
|
* $HEADER$
|
2006-03-11 06:09:24 +03:00
|
|
|
*
|
2005-08-02 17:20:50 +04:00
|
|
|
*/
|
|
|
|
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
#include "opal_config.h"
|
2006-03-11 06:09:24 +03:00
|
|
|
|
2005-08-02 17:20:50 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2006-08-15 00:14:44 +04:00
|
|
|
#include "opal/opal_socket_errno.h"
|
2005-08-02 17:20:50 +04:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_FCNTL_H
|
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NETINET_TCP_H
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_ARPA_INET_H
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#endif
|
2005-12-11 01:04:28 +03:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
2005-08-02 17:20:50 +04:00
|
|
|
#include <sys/time.h>
|
2005-12-11 01:04:28 +03:00
|
|
|
#endif /* HAVE_SYS_TIME_H */
|
2005-08-02 17:20:50 +04:00
|
|
|
#include <time.h>
|
2006-03-11 06:09:24 +03:00
|
|
|
|
Update libevent to the 2.0 series, currently at 2.0.7rc. We will update to their final release when it becomes available. Currently known errors exist in unused portions of the libevent code. This revision passes the IBM test suite on a Linux machine and on a standalone Mac.
This is a fairly intrusive change, but outside of the moving of opal/event to opal/mca/event, the only changes involved (a) changing all calls to opal_event functions to reflect the new framework instead, and (b) ensuring that all opal_event_t objects are properly constructed since they are now true opal_objects.
Note: Shiqing has just returned from vacation and has not yet had a chance to complete the Windows integration. Thus, this commit almost certainly breaks Windows support on the trunk. However, I want this to have a chance to soak for as long as possible before I become less available a week from today (going to be at a class for 5 days, and thus will only be sparingly available) so we can find and fix any problems.
Biggest change is moving the libevent code from opal/event to a new opal/mca/event framework. This was done to make it much easier to update libevent in the future. New versions can be inserted as a new component and tested in parallel with the current version until validated, then we can remove the earlier version if we so choose. This is a statically built framework ala installdirs, so only one component will build at a time. There is no selection logic - the sole compiled component simply loads its function pointers into the opal_event struct.
I have gone thru the code base and converted all the libevent calls I could find. However, I cannot compile nor test every environment. It is therefore quite likely that errors remain in the system. Please keep an eye open for two things:
1. compile-time errors: these will be obvious as calls to the old functions (e.g., opal_evtimer_new) must be replaced by the new framework APIs (e.g., opal_event.evtimer_new)
2. run-time errors: these will likely show up as segfaults due to missing constructors on opal_event_t objects. It appears that it became a typical practice for people to "init" an opal_event_t by simply using memset to zero it out. This will no longer work - you must either OBJ_NEW or OBJ_CONSTRUCT an opal_event_t. I tried to catch these cases, but may have missed some. Believe me, you'll know when you hit it.
There is also the issue of the new libevent "no recursion" behavior. As I described on a recent email, we will have to discuss this and figure out what, if anything, we need to do.
This commit was SVN r23925.
2010-10-24 22:35:54 +04:00
|
|
|
#include "opal/mca/event/event.h"
|
2013-02-02 05:19:03 +04:00
|
|
|
#include "opal/util/net.h"
|
2013-02-13 01:10:11 +04:00
|
|
|
#include "opal/util/show_help.h"
|
2014-10-04 01:19:48 +04:00
|
|
|
#include "opal/util/proc.h"
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
#include "opal/mca/btl/base/btl_base_error.h"
|
2007-05-17 05:17:59 +04:00
|
|
|
|
2005-08-02 17:20:50 +04:00
|
|
|
#include "btl_tcp.h"
|
2014-12-13 09:59:55 +03:00
|
|
|
#include "btl_tcp_endpoint.h"
|
2005-08-02 17:20:50 +04:00
|
|
|
#include "btl_tcp_proc.h"
|
|
|
|
#include "btl_tcp_frag.h"
|
|
|
|
#include "btl_tcp_addr.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize state of the endpoint instance.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void mca_btl_tcp_endpoint_construct(mca_btl_tcp_endpoint_t* endpoint)
|
|
|
|
{
|
|
|
|
endpoint->endpoint_btl = NULL;
|
|
|
|
endpoint->endpoint_proc = NULL;
|
|
|
|
endpoint->endpoint_addr = NULL;
|
|
|
|
endpoint->endpoint_sd = -1;
|
2014-12-16 04:27:32 +03:00
|
|
|
endpoint->endpoint_sd_next = -1;
|
2005-08-02 17:20:50 +04:00
|
|
|
endpoint->endpoint_send_frag = 0;
|
|
|
|
endpoint->endpoint_recv_frag = 0;
|
|
|
|
endpoint->endpoint_state = MCA_BTL_TCP_CLOSED;
|
|
|
|
endpoint->endpoint_retries = 0;
|
|
|
|
endpoint->endpoint_nbo = false;
|
2005-12-07 03:12:59 +03:00
|
|
|
#if MCA_BTL_TCP_ENDPOINT_CACHE
|
|
|
|
endpoint->endpoint_cache = NULL;
|
2006-01-14 23:21:44 +03:00
|
|
|
endpoint->endpoint_cache_pos = NULL;
|
2005-12-07 03:12:59 +03:00
|
|
|
endpoint->endpoint_cache_length = 0;
|
|
|
|
#endif /* MCA_BTL_TCP_ENDPOINT_CACHE */
|
2005-08-02 17:20:50 +04:00
|
|
|
OBJ_CONSTRUCT(&endpoint->endpoint_frags, opal_list_t);
|
|
|
|
OBJ_CONSTRUCT(&endpoint->endpoint_send_lock, opal_mutex_t);
|
|
|
|
OBJ_CONSTRUCT(&endpoint->endpoint_recv_lock, opal_mutex_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Destroy a endpoint
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void mca_btl_tcp_endpoint_destruct(mca_btl_tcp_endpoint_t* endpoint)
|
|
|
|
{
|
|
|
|
mca_btl_tcp_endpoint_close(endpoint);
|
2014-12-16 04:27:32 +03:00
|
|
|
mca_btl_tcp_proc_remove(endpoint->endpoint_proc, endpoint);
|
2005-08-02 17:20:50 +04:00
|
|
|
OBJ_DESTRUCT(&endpoint->endpoint_frags);
|
|
|
|
OBJ_DESTRUCT(&endpoint->endpoint_send_lock);
|
|
|
|
OBJ_DESTRUCT(&endpoint->endpoint_recv_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(
|
2014-12-13 09:59:55 +03:00
|
|
|
mca_btl_tcp_endpoint_t,
|
|
|
|
opal_list_item_t,
|
|
|
|
mca_btl_tcp_endpoint_construct,
|
2005-08-02 17:20:50 +04:00
|
|
|
mca_btl_tcp_endpoint_destruct);
|
|
|
|
|
|
|
|
|
|
|
|
static void mca_btl_tcp_endpoint_construct(mca_btl_base_endpoint_t* btl_endpoint);
|
|
|
|
static void mca_btl_tcp_endpoint_destruct(mca_btl_base_endpoint_t* btl_endpoint);
|
|
|
|
static int mca_btl_tcp_endpoint_start_connect(mca_btl_base_endpoint_t*);
|
|
|
|
static void mca_btl_tcp_endpoint_connected(mca_btl_base_endpoint_t*);
|
|
|
|
static void mca_btl_tcp_endpoint_recv_handler(int sd, short flags, void* user);
|
|
|
|
static void mca_btl_tcp_endpoint_send_handler(int sd, short flags, void* user);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Diagnostics: change this to "1" to enable the function
|
|
|
|
* mca_btl_tcp_endpoint_dump(), below
|
|
|
|
*/
|
2015-01-09 02:50:49 +03:00
|
|
|
#define WANT_PEER_DUMP 0
|
2005-08-02 17:20:50 +04:00
|
|
|
/*
|
|
|
|
* diagnostics
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if WANT_PEER_DUMP
|
2015-01-09 02:50:05 +03:00
|
|
|
|
|
|
|
#define DEBUG_LENGTH 1024
|
2014-12-13 09:59:55 +03:00
|
|
|
/**
|
|
|
|
* The lack of protection in the mca_btl_tcp_endpoint_dump function is voluntary
|
|
|
|
* so that it can be called regardless of the state of the mutexes. As a result,
|
|
|
|
* when multiple threads work on the same endpoint not only the information
|
|
|
|
* displayed might be inacurate, but when we manipulate the pending fragments we
|
|
|
|
* might access freed memory. Thus, the caller should lock the endpoint prior
|
|
|
|
* to the call.
|
|
|
|
*/
|
|
|
|
static void
|
2014-12-16 04:27:32 +03:00
|
|
|
mca_btl_tcp_endpoint_dump(int level,
|
|
|
|
const char* fname,
|
|
|
|
int lineno,
|
|
|
|
const char* funcname,
|
|
|
|
mca_btl_base_endpoint_t* btl_endpoint,
|
2014-12-13 09:59:55 +03:00
|
|
|
bool full_info,
|
|
|
|
const char* msg)
|
2005-08-02 17:20:50 +04:00
|
|
|
{
|
2015-01-09 02:50:05 +03:00
|
|
|
char outmsg[DEBUG_LENGTH];
|
2014-12-13 09:59:55 +03:00
|
|
|
int sndbuf, rcvbuf, nodelay, flags, used = 0;
|
As per the RFC, bring in the ORTE async progress code and the rewrite of OOB:
*** THIS RFC INCLUDES A MINOR CHANGE TO THE MPI-RTE INTERFACE ***
Note: during the course of this work, it was necessary to completely separate the MPI and RTE progress engines. There were multiple places in the MPI layer where ORTE_WAIT_FOR_COMPLETION was being used. A new OMPI_WAIT_FOR_COMPLETION macro was created (defined in ompi/mca/rte/rte.h) that simply cycles across opal_progress until the provided flag becomes false. Places where the MPI layer blocked waiting for RTE to complete an event have been modified to use this macro.
***************************************************************************************
I am reissuing this RFC because of the time that has passed since its original release. Since its initial release and review, I have debugged it further to ensure it fully supports tests like loop_spawn. It therefore seems ready for merge back to the trunk. Given its prior review, I have set the timeout for one week.
The code is in https://bitbucket.org/rhc/ompi-oob2
WHAT: Rewrite of ORTE OOB
WHY: Support asynchronous progress and a host of other features
WHEN: Wed, August 21
SYNOPSIS:
The current OOB has served us well, but a number of limitations have been identified over the years. Specifically:
* it is only progressed when called via opal_progress, which can lead to hangs or recursive calls into libevent (which is not supported by that code)
* we've had issues when multiple NICs are available as the code doesn't "shift" messages between transports - thus, all nodes had to be available via the same TCP interface.
* the OOB "unloads" incoming opal_buffer_t objects during the transmission, thus preventing use of OBJ_RETAIN in the code when repeatedly sending the same message to multiple recipients
* there is no failover mechanism across NICs - if the selected NIC (or its attached switch) fails, we are forced to abort
* only one transport (i.e., component) can be "active"
The revised OOB resolves these problems:
* async progress is used for all application processes, with the progress thread blocking in the event library
* each available TCP NIC is supported by its own TCP module. The ability to asynchronously progress each module independently is provided, but not enabled by default (a runtime MCA parameter turns it "on")
* multi-address TCP NICs (e.g., a NIC with both an IPv4 and IPv6 address, or with virtual interfaces) are supported - reachability is determined by comparing the contact info for a peer against all addresses within the range covered by the address/mask pairs for the NIC.
* a message that arrives on one TCP NIC is automatically shifted to whatever NIC that is connected to the next "hop" if that peer cannot be reached by the incoming NIC. If no TCP module will reach the peer, then the OOB attempts to send the message via all other available components - if none can reach the peer, then an "error" is reported back to the RML, which then calls the errmgr for instructions.
* opal_buffer_t now conforms to standard object rules re OBJ_RETAIN as we no longer "unload" the incoming object
* NIC failure is reported to the TCP component, which then tries to resend the message across any other available TCP NIC. If that doesn't work, then the message is given back to the OOB base to try using other components. If all that fails, then the error is reported to the RML, which reports to the errmgr for instructions
* obviously from the above, multiple OOB components (e.g., TCP and UD) can be active in parallel
* the matching code has been moved to the RML (and out of the OOB/TCP component) so it is independent of transport
* routing is done by the individual OOB modules (as opposed to the RML). Thus, both routed and non-routed transports can simultaneously be active
* all blocking send/recv APIs have been removed. Everything operates asynchronously.
KNOWN LIMITATIONS:
* although provision is made for component failover as described above, the code for doing so has not been fully implemented yet. At the moment, if all connections for a given peer fail, the errmgr is notified of a "lost connection", which by default results in termination of the job if it was a lifeline
* the IPv6 code is present and compiles, but is not complete. Since the current IPv6 support in the OOB doesn't work anyway, I don't consider this a blocker
* routing is performed at the individual module level, yet the active routed component is selected on a global basis. We probably should update that to reflect that different transports may need/choose to route in different ways
* obviously, not every error path has been tested nor necessarily covered
* determining abnormal termination is more challenging than in the old code as we now potentially have multiple ways of connecting to a process. Ideally, we would declare "connection failed" when *all* transports can no longer reach the process, but that requires some additional (possibly complex) code. For now, the code replicates the old behavior only somewhat modified - i.e., if a module sees its connection fail, it checks to see if it is a lifeline. If so, it notifies the errmgr that the lifeline is lost - otherwise, it notifies the errmgr that a non-lifeline connection was lost.
* reachability is determined solely on the basis of a shared subnet address/mask - more sophisticated algorithms (e.g., the one used in the tcp btl) are required to handle routing via gateways
* the RML needs to assign sequence numbers to each message on a per-peer basis. The receiving RML will then deliver messages in order, thus preventing out-of-order messaging in the case where messages travel across different transports or a message needs to be redirected/resent due to failure of a NIC
This commit was SVN r29058.
2013-08-22 20:37:40 +04:00
|
|
|
#if OPAL_ENABLE_IPV6
|
2007-04-25 05:55:40 +04:00
|
|
|
struct sockaddr_storage inaddr;
|
|
|
|
#else
|
2005-08-02 17:20:50 +04:00
|
|
|
struct sockaddr_in inaddr;
|
2007-04-25 05:55:40 +04:00
|
|
|
#endif
|
2006-09-15 01:29:51 +04:00
|
|
|
opal_socklen_t obtlen;
|
2007-04-25 05:55:40 +04:00
|
|
|
opal_socklen_t addrlen = sizeof(inaddr);
|
2014-12-13 09:59:55 +03:00
|
|
|
mca_btl_tcp_frag_t* item;
|
2014-12-16 04:27:32 +03:00
|
|
|
mca_btl_tcp_proc_t* this_proc = mca_btl_tcp_proc_local();
|
2005-08-02 17:20:50 +04:00
|
|
|
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, "%s: ", msg);
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
|
|
|
|
2005-08-02 17:20:50 +04:00
|
|
|
getsockname(btl_endpoint->endpoint_sd, (struct sockaddr*)&inaddr, &addrlen);
|
As per the RFC, bring in the ORTE async progress code and the rewrite of OOB:
*** THIS RFC INCLUDES A MINOR CHANGE TO THE MPI-RTE INTERFACE ***
Note: during the course of this work, it was necessary to completely separate the MPI and RTE progress engines. There were multiple places in the MPI layer where ORTE_WAIT_FOR_COMPLETION was being used. A new OMPI_WAIT_FOR_COMPLETION macro was created (defined in ompi/mca/rte/rte.h) that simply cycles across opal_progress until the provided flag becomes false. Places where the MPI layer blocked waiting for RTE to complete an event have been modified to use this macro.
***************************************************************************************
I am reissuing this RFC because of the time that has passed since its original release. Since its initial release and review, I have debugged it further to ensure it fully supports tests like loop_spawn. It therefore seems ready for merge back to the trunk. Given its prior review, I have set the timeout for one week.
The code is in https://bitbucket.org/rhc/ompi-oob2
WHAT: Rewrite of ORTE OOB
WHY: Support asynchronous progress and a host of other features
WHEN: Wed, August 21
SYNOPSIS:
The current OOB has served us well, but a number of limitations have been identified over the years. Specifically:
* it is only progressed when called via opal_progress, which can lead to hangs or recursive calls into libevent (which is not supported by that code)
* we've had issues when multiple NICs are available as the code doesn't "shift" messages between transports - thus, all nodes had to be available via the same TCP interface.
* the OOB "unloads" incoming opal_buffer_t objects during the transmission, thus preventing use of OBJ_RETAIN in the code when repeatedly sending the same message to multiple recipients
* there is no failover mechanism across NICs - if the selected NIC (or its attached switch) fails, we are forced to abort
* only one transport (i.e., component) can be "active"
The revised OOB resolves these problems:
* async progress is used for all application processes, with the progress thread blocking in the event library
* each available TCP NIC is supported by its own TCP module. The ability to asynchronously progress each module independently is provided, but not enabled by default (a runtime MCA parameter turns it "on")
* multi-address TCP NICs (e.g., a NIC with both an IPv4 and IPv6 address, or with virtual interfaces) are supported - reachability is determined by comparing the contact info for a peer against all addresses within the range covered by the address/mask pairs for the NIC.
* a message that arrives on one TCP NIC is automatically shifted to whatever NIC that is connected to the next "hop" if that peer cannot be reached by the incoming NIC. If no TCP module will reach the peer, then the OOB attempts to send the message via all other available components - if none can reach the peer, then an "error" is reported back to the RML, which then calls the errmgr for instructions.
* opal_buffer_t now conforms to standard object rules re OBJ_RETAIN as we no longer "unload" the incoming object
* NIC failure is reported to the TCP component, which then tries to resend the message across any other available TCP NIC. If that doesn't work, then the message is given back to the OOB base to try using other components. If all that fails, then the error is reported to the RML, which reports to the errmgr for instructions
* obviously from the above, multiple OOB components (e.g., TCP and UD) can be active in parallel
* the matching code has been moved to the RML (and out of the OOB/TCP component) so it is independent of transport
* routing is done by the individual OOB modules (as opposed to the RML). Thus, both routed and non-routed transports can simultaneously be active
* all blocking send/recv APIs have been removed. Everything operates asynchronously.
KNOWN LIMITATIONS:
* although provision is made for component failover as described above, the code for doing so has not been fully implemented yet. At the moment, if all connections for a given peer fail, the errmgr is notified of a "lost connection", which by default results in termination of the job if it was a lifeline
* the IPv6 code is present and compiles, but is not complete. Since the current IPv6 support in the OOB doesn't work anyway, I don't consider this a blocker
* routing is performed at the individual module level, yet the active routed component is selected on a global basis. We probably should update that to reflect that different transports may need/choose to route in different ways
* obviously, not every error path has been tested nor necessarily covered
* determining abnormal termination is more challenging than in the old code as we now potentially have multiple ways of connecting to a process. Ideally, we would declare "connection failed" when *all* transports can no longer reach the process, but that requires some additional (possibly complex) code. For now, the code replicates the old behavior only somewhat modified - i.e., if a module sees its connection fail, it checks to see if it is a lifeline. If so, it notifies the errmgr that the lifeline is lost - otherwise, it notifies the errmgr that a non-lifeline connection was lost.
* reachability is determined solely on the basis of a shared subnet address/mask - more sophisticated algorithms (e.g., the one used in the tcp btl) are required to handle routing via gateways
* the RML needs to assign sequence numbers to each message on a per-peer basis. The receiving RML will then deliver messages in order, thus preventing out-of-order messaging in the case where messages travel across different transports or a message needs to be redirected/resent due to failure of a NIC
This commit was SVN r29058.
2013-08-22 20:37:40 +04:00
|
|
|
#if OPAL_ENABLE_IPV6
|
2007-04-25 05:55:40 +04:00
|
|
|
{
|
|
|
|
char *address;
|
2008-04-15 23:23:47 +04:00
|
|
|
address = (char *) opal_net_get_hostname((struct sockaddr*) &inaddr);
|
2007-04-25 05:55:40 +04:00
|
|
|
if (NULL != address) {
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, "%s -", address);
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2007-04-25 05:55:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, "%s -", inet_ntoa(inaddr.sin_addr));
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2007-04-25 05:55:40 +04:00
|
|
|
#endif
|
2005-08-02 17:20:50 +04:00
|
|
|
getpeername(btl_endpoint->endpoint_sd, (struct sockaddr*)&inaddr, &addrlen);
|
As per the RFC, bring in the ORTE async progress code and the rewrite of OOB:
*** THIS RFC INCLUDES A MINOR CHANGE TO THE MPI-RTE INTERFACE ***
Note: during the course of this work, it was necessary to completely separate the MPI and RTE progress engines. There were multiple places in the MPI layer where ORTE_WAIT_FOR_COMPLETION was being used. A new OMPI_WAIT_FOR_COMPLETION macro was created (defined in ompi/mca/rte/rte.h) that simply cycles across opal_progress until the provided flag becomes false. Places where the MPI layer blocked waiting for RTE to complete an event have been modified to use this macro.
***************************************************************************************
I am reissuing this RFC because of the time that has passed since its original release. Since its initial release and review, I have debugged it further to ensure it fully supports tests like loop_spawn. It therefore seems ready for merge back to the trunk. Given its prior review, I have set the timeout for one week.
The code is in https://bitbucket.org/rhc/ompi-oob2
WHAT: Rewrite of ORTE OOB
WHY: Support asynchronous progress and a host of other features
WHEN: Wed, August 21
SYNOPSIS:
The current OOB has served us well, but a number of limitations have been identified over the years. Specifically:
* it is only progressed when called via opal_progress, which can lead to hangs or recursive calls into libevent (which is not supported by that code)
* we've had issues when multiple NICs are available as the code doesn't "shift" messages between transports - thus, all nodes had to be available via the same TCP interface.
* the OOB "unloads" incoming opal_buffer_t objects during the transmission, thus preventing use of OBJ_RETAIN in the code when repeatedly sending the same message to multiple recipients
* there is no failover mechanism across NICs - if the selected NIC (or its attached switch) fails, we are forced to abort
* only one transport (i.e., component) can be "active"
The revised OOB resolves these problems:
* async progress is used for all application processes, with the progress thread blocking in the event library
* each available TCP NIC is supported by its own TCP module. The ability to asynchronously progress each module independently is provided, but not enabled by default (a runtime MCA parameter turns it "on")
* multi-address TCP NICs (e.g., a NIC with both an IPv4 and IPv6 address, or with virtual interfaces) are supported - reachability is determined by comparing the contact info for a peer against all addresses within the range covered by the address/mask pairs for the NIC.
* a message that arrives on one TCP NIC is automatically shifted to whatever NIC that is connected to the next "hop" if that peer cannot be reached by the incoming NIC. If no TCP module will reach the peer, then the OOB attempts to send the message via all other available components - if none can reach the peer, then an "error" is reported back to the RML, which then calls the errmgr for instructions.
* opal_buffer_t now conforms to standard object rules re OBJ_RETAIN as we no longer "unload" the incoming object
* NIC failure is reported to the TCP component, which then tries to resend the message across any other available TCP NIC. If that doesn't work, then the message is given back to the OOB base to try using other components. If all that fails, then the error is reported to the RML, which reports to the errmgr for instructions
* obviously from the above, multiple OOB components (e.g., TCP and UD) can be active in parallel
* the matching code has been moved to the RML (and out of the OOB/TCP component) so it is independent of transport
* routing is done by the individual OOB modules (as opposed to the RML). Thus, both routed and non-routed transports can simultaneously be active
* all blocking send/recv APIs have been removed. Everything operates asynchronously.
KNOWN LIMITATIONS:
* although provision is made for component failover as described above, the code for doing so has not been fully implemented yet. At the moment, if all connections for a given peer fail, the errmgr is notified of a "lost connection", which by default results in termination of the job if it was a lifeline
* the IPv6 code is present and compiles, but is not complete. Since the current IPv6 support in the OOB doesn't work anyway, I don't consider this a blocker
* routing is performed at the individual module level, yet the active routed component is selected on a global basis. We probably should update that to reflect that different transports may need/choose to route in different ways
* obviously, not every error path has been tested nor necessarily covered
* determining abnormal termination is more challenging than in the old code as we now potentially have multiple ways of connecting to a process. Ideally, we would declare "connection failed" when *all* transports can no longer reach the process, but that requires some additional (possibly complex) code. For now, the code replicates the old behavior only somewhat modified - i.e., if a module sees its connection fail, it checks to see if it is a lifeline. If so, it notifies the errmgr that the lifeline is lost - otherwise, it notifies the errmgr that a non-lifeline connection was lost.
* reachability is determined solely on the basis of a shared subnet address/mask - more sophisticated algorithms (e.g., the one used in the tcp btl) are required to handle routing via gateways
* the RML needs to assign sequence numbers to each message on a per-peer basis. The receiving RML will then deliver messages in order, thus preventing out-of-order messaging in the case where messages travel across different transports or a message needs to be redirected/resent due to failure of a NIC
This commit was SVN r29058.
2013-08-22 20:37:40 +04:00
|
|
|
#if OPAL_ENABLE_IPV6
|
2007-04-25 05:55:40 +04:00
|
|
|
{
|
|
|
|
char *address;
|
2008-04-15 23:23:47 +04:00
|
|
|
address = (char *) opal_net_get_hostname ((struct sockaddr*) &inaddr);
|
2007-04-25 05:55:40 +04:00
|
|
|
if (NULL != address) {
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, " %s", address);
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2007-04-25 05:55:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, " %s", inet_ntoa(inaddr.sin_addr));
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2007-04-25 05:55:40 +04:00
|
|
|
#endif
|
2005-08-02 17:20:50 +04:00
|
|
|
|
2015-01-09 02:50:05 +03:00
|
|
|
used = snprintf(outmsg, DEBUG_LENGTH, "[%d", btl_endpoint->endpoint_sd);
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
switch(btl_endpoint->endpoint_state) {
|
|
|
|
case MCA_BTL_TCP_CONNECTING:
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, ":%s]", "connecting");
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
break;
|
|
|
|
case MCA_BTL_TCP_CONNECT_ACK:
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, ":%s]", "ack");
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
break;
|
|
|
|
case MCA_BTL_TCP_CLOSED:
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, ":%s]", "close");
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
break;
|
|
|
|
case MCA_BTL_TCP_FAILED:
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, ":%s]", "failed");
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
break;
|
|
|
|
case MCA_BTL_TCP_CONNECTED:
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, ":%s]", "connected");
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
break;
|
|
|
|
default:
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, ":%s]", "unknown");
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
break;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
|
2014-12-13 09:59:55 +03:00
|
|
|
if( full_info ) {
|
|
|
|
if((flags = fcntl(btl_endpoint->endpoint_sd, F_GETFL, 0)) < 0) {
|
|
|
|
BTL_ERROR(("fcntl(F_GETFL) failed: %s (%d)",
|
|
|
|
strerror(opal_socket_errno), opal_socket_errno));
|
|
|
|
}
|
|
|
|
|
2005-08-02 17:20:50 +04:00
|
|
|
#if defined(SO_SNDBUF)
|
2014-12-13 09:59:55 +03:00
|
|
|
obtlen = sizeof(sndbuf);
|
|
|
|
if(getsockopt(btl_endpoint->endpoint_sd, SOL_SOCKET, SO_SNDBUF, (char *)&sndbuf, &obtlen) < 0) {
|
|
|
|
BTL_ERROR(("SO_SNDBUF option: %s (%d)",
|
|
|
|
strerror(opal_socket_errno), opal_socket_errno));
|
|
|
|
}
|
2005-08-02 17:20:50 +04:00
|
|
|
#else
|
2014-12-13 09:59:55 +03:00
|
|
|
sndbuf = -1;
|
2005-08-02 17:20:50 +04:00
|
|
|
#endif
|
|
|
|
#if defined(SO_RCVBUF)
|
2014-12-13 09:59:55 +03:00
|
|
|
obtlen = sizeof(rcvbuf);
|
|
|
|
if(getsockopt(btl_endpoint->endpoint_sd, SOL_SOCKET, SO_RCVBUF, (char *)&rcvbuf, &obtlen) < 0) {
|
|
|
|
BTL_ERROR(("SO_RCVBUF option: %s (%d)",
|
|
|
|
strerror(opal_socket_errno), opal_socket_errno));
|
|
|
|
}
|
2005-08-02 17:20:50 +04:00
|
|
|
#else
|
2014-12-13 09:59:55 +03:00
|
|
|
rcvbuf = -1;
|
2005-08-02 17:20:50 +04:00
|
|
|
#endif
|
|
|
|
#if defined(TCP_NODELAY)
|
2014-12-13 09:59:55 +03:00
|
|
|
obtlen = sizeof(nodelay);
|
|
|
|
if(getsockopt(btl_endpoint->endpoint_sd, IPPROTO_TCP, TCP_NODELAY, (char *)&nodelay, &obtlen) < 0) {
|
|
|
|
BTL_ERROR(("TCP_NODELAY option: %s (%d)",
|
|
|
|
strerror(opal_socket_errno), opal_socket_errno));
|
|
|
|
}
|
2005-08-02 17:20:50 +04:00
|
|
|
#else
|
2014-12-13 09:59:55 +03:00
|
|
|
nodelay = 0;
|
2005-08-02 17:20:50 +04:00
|
|
|
#endif
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, " nodelay %d sndbuf %d rcvbuf %d flags %08x",
|
2014-12-13 09:59:55 +03:00
|
|
|
nodelay, sndbuf, rcvbuf, flags);
|
2015-01-09 02:50:05 +03:00
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
#if MCA_BTL_TCP_ENDPOINT_CACHE
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, "\n\t[cache %p used %lu/%lu]",
|
2014-12-13 09:59:55 +03:00
|
|
|
btl_endpoint->endpoint_cache, btl_endpoint->endpoint_cache_pos - btl_endpoint->endpoint_cache,
|
|
|
|
btl_endpoint->endpoint_cache_length);
|
2015-01-09 02:50:05 +03:00
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
#endif /* MCA_BTL_TCP_ENDPOINT_CACHE */
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, "{%s - retries %d}",
|
2014-12-13 09:59:55 +03:00
|
|
|
(btl_endpoint->endpoint_nbo ? "NBO" : ""), (int)btl_endpoint->endpoint_retries);
|
2015-01-09 02:50:05 +03:00
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
}
|
2015-01-09 02:50:05 +03:00
|
|
|
used += snprintf(&outmsg[used], DEBUG_LENGTH - used, "\n");
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2005-08-02 17:20:50 +04:00
|
|
|
|
2014-12-13 09:59:55 +03:00
|
|
|
if( NULL != btl_endpoint->endpoint_recv_frag )
|
|
|
|
used += mca_btl_tcp_frag_dump(btl_endpoint->endpoint_recv_frag, "active recv",
|
2015-01-09 02:50:05 +03:00
|
|
|
&outmsg[used], DEBUG_LENGTH - used);
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
|
|
|
|
if( NULL != btl_endpoint->endpoint_send_frag )
|
|
|
|
used += mca_btl_tcp_frag_dump(btl_endpoint->endpoint_send_frag, "active send (inaccurate iov)",
|
2015-01-09 02:50:05 +03:00
|
|
|
&outmsg[used], DEBUG_LENGTH - used);
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
OPAL_LIST_FOREACH(item, &btl_endpoint->endpoint_frags, mca_btl_tcp_frag_t) {
|
2015-01-09 02:50:05 +03:00
|
|
|
used += mca_btl_tcp_frag_dump(item, "pending send", &outmsg[used], DEBUG_LENGTH - used);
|
|
|
|
if (used >= DEBUG_LENGTH) goto out;
|
2014-12-13 09:59:55 +03:00
|
|
|
}
|
2015-01-08 09:40:16 +03:00
|
|
|
out:
|
2015-01-09 02:50:05 +03:00
|
|
|
outmsg[ used >= DEBUG_LENGTH ? (DEBUG_LENGTH-1) : used ] = '\0';
|
2014-12-16 04:27:32 +03:00
|
|
|
opal_output_verbose(level, opal_btl_base_framework.framework_output,
|
|
|
|
"[%s:%d:%s][%s -> %s] %s",
|
|
|
|
fname, lineno, funcname,
|
|
|
|
(NULL != this_proc ? OPAL_NAME_PRINT(mca_btl_tcp_proc_local()->proc_opal->proc_name) : "unknown"),
|
|
|
|
(NULL != btl_endpoint->endpoint_proc ? OPAL_NAME_PRINT(btl_endpoint->endpoint_proc->proc_opal->proc_name) : "unknown remote"),
|
|
|
|
outmsg);
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
2014-12-13 09:59:55 +03:00
|
|
|
#endif /* WANT_PEER_DUMP */
|
|
|
|
|
|
|
|
#if OPAL_ENABLE_DEBUG && WANT_PEER_DUMP
|
2014-12-16 04:27:32 +03:00
|
|
|
#define MCA_BTL_TCP_ENDPOINT_DUMP(LEVEL, ENDPOINT, INFO, MSG) mca_btl_tcp_endpoint_dump((LEVEL), __FILE__, __LINE__, __func__, (ENDPOINT), (INFO), (MSG))
|
2014-12-13 09:59:55 +03:00
|
|
|
#else
|
2014-12-16 04:27:32 +03:00
|
|
|
#define MCA_BTL_TCP_ENDPOINT_DUMP(LEVEL, ENDPOINT, INFO, MSG)
|
2014-12-13 09:59:55 +03:00
|
|
|
#endif /* OPAL_ENABLE_DEBUG && WANT_PEER_DUMP */
|
2005-08-02 17:20:50 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize events to be used by the endpoint instance for TCP select/poll callbacks.
|
|
|
|
*/
|
|
|
|
|
2008-03-18 05:42:16 +03:00
|
|
|
static inline void mca_btl_tcp_endpoint_event_init(mca_btl_base_endpoint_t* btl_endpoint)
|
2005-08-02 17:20:50 +04:00
|
|
|
{
|
2005-12-07 03:12:59 +03:00
|
|
|
#if MCA_BTL_TCP_ENDPOINT_CACHE
|
2014-12-13 09:45:00 +03:00
|
|
|
assert(NULL == btl_endpoint->endpoint_cache);
|
2006-01-14 23:21:44 +03:00
|
|
|
btl_endpoint->endpoint_cache = (char*)malloc(mca_btl_tcp_component.tcp_endpoint_cache);
|
|
|
|
btl_endpoint->endpoint_cache_pos = btl_endpoint->endpoint_cache;
|
2005-12-07 03:12:59 +03:00
|
|
|
#endif /* MCA_BTL_TCP_ENDPOINT_CACHE */
|
|
|
|
|
2014-12-13 09:59:55 +03:00
|
|
|
opal_event_set(opal_event_base, &btl_endpoint->endpoint_recv_event,
|
|
|
|
btl_endpoint->endpoint_sd,
|
|
|
|
OPAL_EV_READ|OPAL_EV_PERSIST,
|
2008-03-18 05:42:16 +03:00
|
|
|
mca_btl_tcp_endpoint_recv_handler,
|
|
|
|
btl_endpoint );
|
|
|
|
/**
|
|
|
|
* The send event should be non persistent until the endpoint is
|
|
|
|
* completely connected. This means, when the event is created it
|
2014-12-13 09:59:55 +03:00
|
|
|
* will be fired only once, and when the endpoint is marked as
|
2008-03-18 05:42:16 +03:00
|
|
|
* CONNECTED the event should be recreated with the correct flags.
|
|
|
|
*/
|
2014-12-13 09:59:55 +03:00
|
|
|
opal_event_set(opal_event_base, &btl_endpoint->endpoint_send_event,
|
|
|
|
btl_endpoint->endpoint_sd,
|
|
|
|
OPAL_EV_WRITE,
|
2008-03-18 05:42:16 +03:00
|
|
|
mca_btl_tcp_endpoint_send_handler,
|
|
|
|
btl_endpoint);
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attempt to send a fragment using a given endpoint. If the endpoint is not connected,
|
|
|
|
* queue the fragment and start the connection as required.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int mca_btl_tcp_endpoint_send(mca_btl_base_endpoint_t* btl_endpoint, mca_btl_tcp_frag_t* frag)
|
|
|
|
{
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
int rc = OPAL_SUCCESS;
|
2007-04-28 23:13:47 +04:00
|
|
|
|
2005-08-02 17:20:50 +04:00
|
|
|
OPAL_THREAD_LOCK(&btl_endpoint->endpoint_send_lock);
|
|
|
|
switch(btl_endpoint->endpoint_state) {
|
|
|
|
case MCA_BTL_TCP_CONNECTING:
|
|
|
|
case MCA_BTL_TCP_CONNECT_ACK:
|
|
|
|
case MCA_BTL_TCP_CLOSED:
|
|
|
|
opal_list_append(&btl_endpoint->endpoint_frags, (opal_list_item_t*)frag);
|
2008-05-30 07:58:39 +04:00
|
|
|
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
|
2005-08-02 17:20:50 +04:00
|
|
|
if(btl_endpoint->endpoint_state == MCA_BTL_TCP_CLOSED)
|
|
|
|
rc = mca_btl_tcp_endpoint_start_connect(btl_endpoint);
|
|
|
|
break;
|
|
|
|
case MCA_BTL_TCP_FAILED:
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
rc = OPAL_ERR_UNREACH;
|
2005-08-02 17:20:50 +04:00
|
|
|
break;
|
|
|
|
case MCA_BTL_TCP_CONNECTED:
|
2014-12-13 09:45:00 +03:00
|
|
|
if (NULL == btl_endpoint->endpoint_send_frag) {
|
2005-08-10 18:32:10 +04:00
|
|
|
if(frag->base.des_flags & MCA_BTL_DES_FLAGS_PRIORITY &&
|
|
|
|
mca_btl_tcp_frag_send(frag, btl_endpoint->endpoint_sd)) {
|
2008-02-18 20:39:30 +03:00
|
|
|
int btl_ownership = (frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP);
|
|
|
|
|
2005-08-02 17:20:50 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_send_lock);
|
2008-05-30 07:58:39 +04:00
|
|
|
if( frag->base.des_flags & MCA_BTL_DES_SEND_ALWAYS_CALLBACK ) {
|
|
|
|
frag->base.des_cbfunc(&frag->btl->super, frag->endpoint, &frag->base, frag->rc);
|
|
|
|
}
|
2008-02-18 20:39:30 +03:00
|
|
|
if( btl_ownership ) {
|
|
|
|
MCA_BTL_TCP_FRAG_RETURN(frag);
|
|
|
|
}
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(50, btl_endpoint, true, "complete send fragment [endpoint_send]");
|
2008-05-30 07:58:39 +04:00
|
|
|
return 1;
|
2005-08-02 17:20:50 +04:00
|
|
|
} else {
|
|
|
|
btl_endpoint->endpoint_send_frag = frag;
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(10, btl_endpoint, true, "event_add(send) [endpoint_send]");
|
2010-10-28 19:22:46 +04:00
|
|
|
opal_event_add(&btl_endpoint->endpoint_send_event, 0);
|
2008-05-30 07:58:39 +04:00
|
|
|
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
2005-08-10 18:32:10 +04:00
|
|
|
} else {
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(10, btl_endpoint, true, "send fragment enqueued [endpoint_send]");
|
2008-05-30 07:58:39 +04:00
|
|
|
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
|
2005-08-10 18:32:10 +04:00
|
|
|
opal_list_append(&btl_endpoint->endpoint_frags, (opal_list_item_t*)frag);
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_send_lock);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A blocking send on a non-blocking socket. Used to send the small amount of connection
|
|
|
|
* information that identifies the endpoints endpoint.
|
|
|
|
*/
|
2014-12-15 23:42:08 +03:00
|
|
|
static int
|
|
|
|
mca_btl_tcp_endpoint_send_blocking(mca_btl_base_endpoint_t* btl_endpoint,
|
|
|
|
void* data, size_t size)
|
2005-08-02 17:20:50 +04:00
|
|
|
{
|
|
|
|
unsigned char* ptr = (unsigned char*)data;
|
|
|
|
size_t cnt = 0;
|
|
|
|
while(cnt < size) {
|
|
|
|
int retval = send(btl_endpoint->endpoint_sd, (const char *)ptr+cnt, size-cnt, 0);
|
|
|
|
if(retval < 0) {
|
2006-08-15 00:14:44 +04:00
|
|
|
if(opal_socket_errno != EINTR && opal_socket_errno != EAGAIN && opal_socket_errno != EWOULDBLOCK) {
|
2014-12-16 04:27:32 +03:00
|
|
|
BTL_ERROR(("send(%d, %p, %lu/%lu) failed: %s (%d)",
|
|
|
|
btl_endpoint->endpoint_sd, data, cnt, size,
|
2007-03-20 14:50:17 +03:00
|
|
|
strerror(opal_socket_errno), opal_socket_errno));
|
2013-01-21 15:41:08 +04:00
|
|
|
btl_endpoint->endpoint_state = MCA_BTL_TCP_FAILED;
|
2005-08-02 17:20:50 +04:00
|
|
|
mca_btl_tcp_endpoint_close(btl_endpoint);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
cnt += retval;
|
|
|
|
}
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-12-13 09:59:55 +03:00
|
|
|
* Send the globally unique identifier for this process to a endpoint on
|
2005-08-02 17:20:50 +04:00
|
|
|
* a newly connected socket.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int mca_btl_tcp_endpoint_send_connect_ack(mca_btl_base_endpoint_t* btl_endpoint)
|
|
|
|
{
|
|
|
|
/* send process identifier to remote endpoint */
|
|
|
|
mca_btl_tcp_proc_t* btl_proc = mca_btl_tcp_proc_local();
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
opal_process_name_t guid = btl_proc->proc_opal->proc_name;
|
2006-02-26 03:45:54 +03:00
|
|
|
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
OPAL_PROCESS_NAME_HTON(guid);
|
2014-12-13 09:59:55 +03:00
|
|
|
if(mca_btl_tcp_endpoint_send_blocking(btl_endpoint, &guid, sizeof(guid)) !=
|
2006-02-26 03:45:54 +03:00
|
|
|
sizeof(guid)) {
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
return OPAL_ERR_UNREACH;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
return OPAL_SUCCESS;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
|
2014-12-16 04:27:32 +03:00
|
|
|
static void *mca_btl_tcp_endpoint_complete_accept(int fd, int flags, void *context)
|
2005-08-02 17:20:50 +04:00
|
|
|
{
|
2014-12-16 04:27:32 +03:00
|
|
|
mca_btl_base_endpoint_t* btl_endpoint = (mca_btl_base_endpoint_t*)context;
|
2005-08-02 17:20:50 +04:00
|
|
|
mca_btl_tcp_proc_t* this_proc = mca_btl_tcp_proc_local();
|
2014-12-16 04:27:32 +03:00
|
|
|
struct timeval now = {0, 0};
|
2005-08-02 17:20:50 +04:00
|
|
|
int cmpval;
|
|
|
|
|
2014-12-16 04:27:32 +03:00
|
|
|
if( OPAL_THREAD_TRYLOCK(&btl_endpoint->endpoint_recv_lock) ) {
|
|
|
|
opal_event_add(&btl_endpoint->endpoint_accept_event, &now);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if( OPAL_THREAD_TRYLOCK(&btl_endpoint->endpoint_send_lock) ) {
|
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock);
|
|
|
|
opal_event_add(&btl_endpoint->endpoint_accept_event, &now);
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-04-25 05:55:40 +04:00
|
|
|
|
2009-05-05 17:42:28 +04:00
|
|
|
if(NULL == btl_endpoint->endpoint_addr) {
|
2014-12-16 04:27:32 +03:00
|
|
|
CLOSE_THE_SOCKET(btl_endpoint->endpoint_sd_next); /* No further use of this socket. Close it */
|
|
|
|
btl_endpoint->endpoint_sd_next = -1;
|
2007-04-25 05:55:40 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_send_lock);
|
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock);
|
2014-12-16 04:27:32 +03:00
|
|
|
if( NULL != btl_endpoint->endpoint_btl->tcp_error_cb ) {
|
|
|
|
btl_endpoint->endpoint_btl->tcp_error_cb(
|
|
|
|
&btl_endpoint->endpoint_btl->super, MCA_BTL_ERROR_FLAGS_NONFATAL,
|
|
|
|
btl_endpoint->endpoint_proc->proc_opal,
|
|
|
|
"The endpoint addr is set to NULL (unsettling)");
|
|
|
|
}
|
|
|
|
return NULL;
|
2007-04-25 05:55:40 +04:00
|
|
|
}
|
|
|
|
|
2014-12-16 04:27:32 +03:00
|
|
|
cmpval = opal_compare_proc(btl_endpoint->endpoint_proc->proc_opal->proc_name,
|
|
|
|
this_proc->proc_opal->proc_name);
|
2007-04-28 23:13:47 +04:00
|
|
|
if((btl_endpoint->endpoint_sd < 0) ||
|
|
|
|
(btl_endpoint->endpoint_state != MCA_BTL_TCP_CONNECTED &&
|
|
|
|
cmpval < 0)) {
|
|
|
|
mca_btl_tcp_endpoint_close(btl_endpoint);
|
2014-12-16 04:27:32 +03:00
|
|
|
btl_endpoint->endpoint_sd = btl_endpoint->endpoint_sd_next;
|
|
|
|
btl_endpoint->endpoint_sd_next = -1;
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
if(mca_btl_tcp_endpoint_send_connect_ack(btl_endpoint) != OPAL_SUCCESS) {
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(1, btl_endpoint, true, " [endpoint_accept]");
|
2013-01-21 15:41:08 +04:00
|
|
|
btl_endpoint->endpoint_state = MCA_BTL_TCP_FAILED;
|
2005-08-02 17:20:50 +04:00
|
|
|
mca_btl_tcp_endpoint_close(btl_endpoint);
|
2014-12-16 04:27:32 +03:00
|
|
|
goto unlock_and_return;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
2008-03-18 05:42:16 +03:00
|
|
|
mca_btl_tcp_endpoint_event_init(btl_endpoint);
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(10, btl_endpoint, true, "event_add(recv) [endpoint_accept]");
|
2010-10-28 19:22:46 +04:00
|
|
|
opal_event_add(&btl_endpoint->endpoint_recv_event, 0);
|
2007-04-28 23:13:47 +04:00
|
|
|
mca_btl_tcp_endpoint_connected(btl_endpoint);
|
2014-12-13 09:59:55 +03:00
|
|
|
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(10, btl_endpoint, true, "accepted");
|
|
|
|
goto unlock_and_return;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
2014-12-16 04:27:32 +03:00
|
|
|
CLOSE_THE_SOCKET(btl_endpoint->endpoint_sd_next); /* No further use of this socket. Close it */
|
|
|
|
btl_endpoint->endpoint_sd_next = -1;
|
|
|
|
unlock_and_return:
|
2005-08-02 17:20:50 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_send_lock);
|
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock);
|
2014-12-16 04:27:32 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check the state of this endpoint. If the incoming connection request matches
|
|
|
|
* our endpoints address, check the state of our connection:
|
|
|
|
* (1) if a connection has not been attempted, accept the connection
|
|
|
|
* (2) if a connection has not been established, and the endpoints process identifier
|
|
|
|
* is less than the local process, accept the connection
|
|
|
|
* otherwise, reject the connection and continue with the current connection
|
|
|
|
*/
|
|
|
|
|
|
|
|
void mca_btl_tcp_endpoint_accept(mca_btl_base_endpoint_t* btl_endpoint,
|
|
|
|
struct sockaddr* addr, int sd)
|
|
|
|
{
|
|
|
|
struct timeval now = {0, 0};
|
|
|
|
|
|
|
|
assert(btl_endpoint->endpoint_sd_next == -1);
|
|
|
|
btl_endpoint->endpoint_sd_next = sd;
|
|
|
|
|
|
|
|
opal_event_evtimer_set(opal_event_base, &btl_endpoint->endpoint_accept_event,
|
|
|
|
mca_btl_tcp_endpoint_complete_accept, btl_endpoint);
|
|
|
|
opal_event_add(&btl_endpoint->endpoint_accept_event, &now);
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove any event registrations associated with the socket
|
|
|
|
* and update the endpoint state to reflect the connection has
|
|
|
|
* been closed.
|
|
|
|
*/
|
|
|
|
void mca_btl_tcp_endpoint_close(mca_btl_base_endpoint_t* btl_endpoint)
|
|
|
|
{
|
2008-03-18 05:42:16 +03:00
|
|
|
if(btl_endpoint->endpoint_sd < 0)
|
|
|
|
return;
|
2005-08-02 17:20:50 +04:00
|
|
|
btl_endpoint->endpoint_retries++;
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(1, btl_endpoint, false, "event_del(recv) [close]");
|
2010-10-28 19:22:46 +04:00
|
|
|
opal_event_del(&btl_endpoint->endpoint_recv_event);
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(1, btl_endpoint, false, "event_del(send) [close]");
|
2010-10-28 19:22:46 +04:00
|
|
|
opal_event_del(&btl_endpoint->endpoint_send_event);
|
2008-03-18 05:42:16 +03:00
|
|
|
CLOSE_THE_SOCKET(btl_endpoint->endpoint_sd);
|
|
|
|
btl_endpoint->endpoint_sd = -1;
|
|
|
|
#if MCA_BTL_TCP_ENDPOINT_CACHE
|
|
|
|
free( btl_endpoint->endpoint_cache );
|
|
|
|
btl_endpoint->endpoint_cache = NULL;
|
|
|
|
btl_endpoint->endpoint_cache_pos = NULL;
|
|
|
|
btl_endpoint->endpoint_cache_length = 0;
|
|
|
|
#endif /* MCA_BTL_TCP_ENDPOINT_CACHE */
|
2013-01-21 15:41:08 +04:00
|
|
|
/**
|
|
|
|
* If we keep failing to connect to the peer let the caller know about
|
|
|
|
* this situation by triggering all the pending fragments callback and
|
|
|
|
* reporting the error.
|
|
|
|
*/
|
|
|
|
if( MCA_BTL_TCP_FAILED == btl_endpoint->endpoint_state ) {
|
|
|
|
mca_btl_tcp_frag_t* frag = btl_endpoint->endpoint_send_frag;
|
2014-12-13 09:59:55 +03:00
|
|
|
if( NULL == frag )
|
2013-01-21 15:41:08 +04:00
|
|
|
frag = (mca_btl_tcp_frag_t*)opal_list_remove_first(&btl_endpoint->endpoint_frags);
|
|
|
|
while(NULL != frag) {
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
frag->base.des_cbfunc(&frag->btl->super, frag->endpoint, &frag->base, OPAL_ERR_UNREACH);
|
2013-01-21 15:41:08 +04:00
|
|
|
|
|
|
|
frag = (mca_btl_tcp_frag_t*)opal_list_remove_first(&btl_endpoint->endpoint_frags);
|
|
|
|
}
|
|
|
|
}
|
2014-12-17 00:07:42 +03:00
|
|
|
btl_endpoint->endpoint_state = MCA_BTL_TCP_CLOSED;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup endpoint state to reflect that connection has been established,
|
2008-03-18 05:42:16 +03:00
|
|
|
* and start any pending sends. This function should be called with the
|
|
|
|
* send lock locked.
|
2005-08-02 17:20:50 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void mca_btl_tcp_endpoint_connected(mca_btl_base_endpoint_t* btl_endpoint)
|
|
|
|
{
|
|
|
|
/* setup socket options */
|
2014-12-17 00:07:42 +03:00
|
|
|
assert( MCA_BTL_TCP_CONNECTED != btl_endpoint->endpoint_state );
|
2005-08-02 17:20:50 +04:00
|
|
|
btl_endpoint->endpoint_state = MCA_BTL_TCP_CONNECTED;
|
|
|
|
btl_endpoint->endpoint_retries = 0;
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(1, btl_endpoint, true, "READY [endpoint_connected]");
|
2008-03-18 05:42:16 +03:00
|
|
|
|
|
|
|
/* Create the send event in a persistent manner. */
|
2014-12-13 09:59:55 +03:00
|
|
|
opal_event_set(opal_event_base, &btl_endpoint->endpoint_send_event,
|
|
|
|
btl_endpoint->endpoint_sd,
|
2008-03-27 21:36:08 +03:00
|
|
|
OPAL_EV_WRITE | OPAL_EV_PERSIST,
|
|
|
|
mca_btl_tcp_endpoint_send_handler,
|
|
|
|
btl_endpoint );
|
2008-03-18 05:42:16 +03:00
|
|
|
|
2005-08-02 17:20:50 +04:00
|
|
|
if(opal_list_get_size(&btl_endpoint->endpoint_frags) > 0) {
|
|
|
|
if(NULL == btl_endpoint->endpoint_send_frag)
|
|
|
|
btl_endpoint->endpoint_send_frag = (mca_btl_tcp_frag_t*)
|
|
|
|
opal_list_remove_first(&btl_endpoint->endpoint_frags);
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(10, btl_endpoint, true, "event_add(send) [endpoint_connected]");
|
2010-10-28 19:22:46 +04:00
|
|
|
opal_event_add(&btl_endpoint->endpoint_send_event, 0);
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-12-16 04:27:32 +03:00
|
|
|
* A blocking recv on a non-blocking socket. Used to receive the small
|
|
|
|
* amount of connection information that identifies the remote endpoint (guid).
|
2005-08-02 17:20:50 +04:00
|
|
|
*/
|
|
|
|
static int mca_btl_tcp_endpoint_recv_blocking(mca_btl_base_endpoint_t* btl_endpoint, void* data, size_t size)
|
|
|
|
{
|
|
|
|
unsigned char* ptr = (unsigned char*)data;
|
|
|
|
size_t cnt = 0;
|
|
|
|
while(cnt < size) {
|
|
|
|
int retval = recv(btl_endpoint->endpoint_sd, (char *)ptr+cnt, size-cnt, 0);
|
|
|
|
|
|
|
|
/* remote closed connection */
|
|
|
|
if(retval == 0) {
|
|
|
|
mca_btl_tcp_endpoint_close(btl_endpoint);
|
2013-02-02 05:19:03 +04:00
|
|
|
return cnt;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* socket is non-blocking so handle errors */
|
|
|
|
if(retval < 0) {
|
2006-08-15 00:14:44 +04:00
|
|
|
if(opal_socket_errno != EINTR && opal_socket_errno != EAGAIN && opal_socket_errno != EWOULDBLOCK) {
|
2014-12-16 04:27:32 +03:00
|
|
|
BTL_ERROR(("recv(%d, %lu/%lu) failed: %s (%d)",
|
|
|
|
btl_endpoint->endpoint_sd, cnt, size, strerror(opal_socket_errno), opal_socket_errno));
|
2013-01-21 15:41:08 +04:00
|
|
|
btl_endpoint->endpoint_state = MCA_BTL_TCP_FAILED;
|
2005-08-02 17:20:50 +04:00
|
|
|
mca_btl_tcp_endpoint_close(btl_endpoint);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
cnt += retval;
|
|
|
|
}
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Receive the endpoints globally unique process identification from a newly
|
|
|
|
* connected socket and verify the expected response. If so, move the
|
|
|
|
* socket to a connected state.
|
|
|
|
*/
|
|
|
|
static int mca_btl_tcp_endpoint_recv_connect_ack(mca_btl_base_endpoint_t* btl_endpoint)
|
|
|
|
{
|
2013-02-02 05:19:03 +04:00
|
|
|
size_t s;
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
opal_process_name_t guid;
|
2005-08-02 17:20:50 +04:00
|
|
|
mca_btl_tcp_proc_t* btl_proc = btl_endpoint->endpoint_proc;
|
|
|
|
|
2013-02-02 05:19:03 +04:00
|
|
|
s = mca_btl_tcp_endpoint_recv_blocking(btl_endpoint,
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
&guid, sizeof(opal_process_name_t));
|
|
|
|
if (s != sizeof(opal_process_name_t)) {
|
2013-02-02 05:19:03 +04:00
|
|
|
if (0 == s) {
|
|
|
|
/* If we get zero bytes, the peer closed the socket. This
|
|
|
|
can happen when the two peers started the connection
|
|
|
|
protocol simultaneously. Just report the problem
|
|
|
|
upstream. */
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
return OPAL_ERROR;
|
2013-02-02 05:19:03 +04:00
|
|
|
}
|
2013-02-13 01:10:11 +04:00
|
|
|
opal_show_help("help-mpi-btl-tcp.txt", "client handshake fail",
|
2014-10-04 01:19:48 +04:00
|
|
|
true, opal_process_info.nodename,
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
getpid(),
|
2013-02-02 05:19:03 +04:00
|
|
|
"did not receive entire connect ACK from peer");
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
return OPAL_ERR_UNREACH;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
OPAL_PROCESS_NAME_NTOH(guid);
|
2005-08-02 17:20:50 +04:00
|
|
|
/* compare this to the expected values */
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
/* TODO: this deserve a little bit more thinking as we are not supposed
|
|
|
|
* to be able to exchange the opal_process_name_t over the network.
|
|
|
|
*/
|
|
|
|
if (0 != opal_compare_proc(btl_proc->proc_opal->proc_name, guid)) {
|
2014-12-13 09:59:55 +03:00
|
|
|
BTL_ERROR(("received unexpected process identifier %s",
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
OPAL_NAME_PRINT(guid)));
|
2005-08-02 17:20:50 +04:00
|
|
|
mca_btl_tcp_endpoint_close(btl_endpoint);
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
return OPAL_ERR_UNREACH;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
return OPAL_SUCCESS;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mca_btl_tcp_set_socket_options(int sd)
|
|
|
|
{
|
|
|
|
#if defined(TCP_NODELAY)
|
2014-01-08 19:12:50 +04:00
|
|
|
int optval;
|
|
|
|
optval = !mca_btl_tcp_component.tcp_not_use_nodelay;
|
2005-08-02 17:20:50 +04:00
|
|
|
if(setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char *)&optval, sizeof(optval)) < 0) {
|
2014-12-13 09:59:55 +03:00
|
|
|
BTL_ERROR(("setsockopt(TCP_NODELAY) failed: %s (%d)",
|
2007-03-20 14:50:17 +03:00
|
|
|
strerror(opal_socket_errno), opal_socket_errno));
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if defined(SO_SNDBUF)
|
|
|
|
if(mca_btl_tcp_component.tcp_sndbuf > 0 &&
|
|
|
|
setsockopt(sd, SOL_SOCKET, SO_SNDBUF, (char *)&mca_btl_tcp_component.tcp_sndbuf, sizeof(int)) < 0) {
|
2014-12-13 09:59:55 +03:00
|
|
|
BTL_ERROR(("setsockopt(SO_SNDBUF) failed: %s (%d)",
|
2007-03-20 14:50:17 +03:00
|
|
|
strerror(opal_socket_errno), opal_socket_errno));
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if defined(SO_RCVBUF)
|
|
|
|
if(mca_btl_tcp_component.tcp_rcvbuf > 0 &&
|
|
|
|
setsockopt(sd, SOL_SOCKET, SO_RCVBUF, (char *)&mca_btl_tcp_component.tcp_rcvbuf, sizeof(int)) < 0) {
|
2014-12-13 09:59:55 +03:00
|
|
|
BTL_ERROR(("setsockopt(SO_RCVBUF) failed: %s (%d)",
|
2007-03-20 14:50:17 +03:00
|
|
|
strerror(opal_socket_errno), opal_socket_errno));
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start a connection to the endpoint. This will likely not complete,
|
|
|
|
* as the socket is set to non-blocking, so register for event
|
|
|
|
* notification of connect completion. On connection we send
|
|
|
|
* our globally unique process identifier to the endpoint and wait for
|
|
|
|
* the endpoints response.
|
|
|
|
*/
|
|
|
|
static int mca_btl_tcp_endpoint_start_connect(mca_btl_base_endpoint_t* btl_endpoint)
|
|
|
|
{
|
|
|
|
int rc,flags;
|
2007-04-25 05:55:40 +04:00
|
|
|
struct sockaddr_storage endpoint_addr;
|
2007-04-28 23:13:47 +04:00
|
|
|
/* By default consider a IPv4 connection */
|
|
|
|
uint16_t af_family = AF_INET;
|
|
|
|
opal_socklen_t addrlen = sizeof(struct sockaddr_in);
|
2014-12-13 09:59:55 +03:00
|
|
|
|
As per the RFC, bring in the ORTE async progress code and the rewrite of OOB:
*** THIS RFC INCLUDES A MINOR CHANGE TO THE MPI-RTE INTERFACE ***
Note: during the course of this work, it was necessary to completely separate the MPI and RTE progress engines. There were multiple places in the MPI layer where ORTE_WAIT_FOR_COMPLETION was being used. A new OMPI_WAIT_FOR_COMPLETION macro was created (defined in ompi/mca/rte/rte.h) that simply cycles across opal_progress until the provided flag becomes false. Places where the MPI layer blocked waiting for RTE to complete an event have been modified to use this macro.
***************************************************************************************
I am reissuing this RFC because of the time that has passed since its original release. Since its initial release and review, I have debugged it further to ensure it fully supports tests like loop_spawn. It therefore seems ready for merge back to the trunk. Given its prior review, I have set the timeout for one week.
The code is in https://bitbucket.org/rhc/ompi-oob2
WHAT: Rewrite of ORTE OOB
WHY: Support asynchronous progress and a host of other features
WHEN: Wed, August 21
SYNOPSIS:
The current OOB has served us well, but a number of limitations have been identified over the years. Specifically:
* it is only progressed when called via opal_progress, which can lead to hangs or recursive calls into libevent (which is not supported by that code)
* we've had issues when multiple NICs are available as the code doesn't "shift" messages between transports - thus, all nodes had to be available via the same TCP interface.
* the OOB "unloads" incoming opal_buffer_t objects during the transmission, thus preventing use of OBJ_RETAIN in the code when repeatedly sending the same message to multiple recipients
* there is no failover mechanism across NICs - if the selected NIC (or its attached switch) fails, we are forced to abort
* only one transport (i.e., component) can be "active"
The revised OOB resolves these problems:
* async progress is used for all application processes, with the progress thread blocking in the event library
* each available TCP NIC is supported by its own TCP module. The ability to asynchronously progress each module independently is provided, but not enabled by default (a runtime MCA parameter turns it "on")
* multi-address TCP NICs (e.g., a NIC with both an IPv4 and IPv6 address, or with virtual interfaces) are supported - reachability is determined by comparing the contact info for a peer against all addresses within the range covered by the address/mask pairs for the NIC.
* a message that arrives on one TCP NIC is automatically shifted to whatever NIC that is connected to the next "hop" if that peer cannot be reached by the incoming NIC. If no TCP module will reach the peer, then the OOB attempts to send the message via all other available components - if none can reach the peer, then an "error" is reported back to the RML, which then calls the errmgr for instructions.
* opal_buffer_t now conforms to standard object rules re OBJ_RETAIN as we no longer "unload" the incoming object
* NIC failure is reported to the TCP component, which then tries to resend the message across any other available TCP NIC. If that doesn't work, then the message is given back to the OOB base to try using other components. If all that fails, then the error is reported to the RML, which reports to the errmgr for instructions
* obviously from the above, multiple OOB components (e.g., TCP and UD) can be active in parallel
* the matching code has been moved to the RML (and out of the OOB/TCP component) so it is independent of transport
* routing is done by the individual OOB modules (as opposed to the RML). Thus, both routed and non-routed transports can simultaneously be active
* all blocking send/recv APIs have been removed. Everything operates asynchronously.
KNOWN LIMITATIONS:
* although provision is made for component failover as described above, the code for doing so has not been fully implemented yet. At the moment, if all connections for a given peer fail, the errmgr is notified of a "lost connection", which by default results in termination of the job if it was a lifeline
* the IPv6 code is present and compiles, but is not complete. Since the current IPv6 support in the OOB doesn't work anyway, I don't consider this a blocker
* routing is performed at the individual module level, yet the active routed component is selected on a global basis. We probably should update that to reflect that different transports may need/choose to route in different ways
* obviously, not every error path has been tested nor necessarily covered
* determining abnormal termination is more challenging than in the old code as we now potentially have multiple ways of connecting to a process. Ideally, we would declare "connection failed" when *all* transports can no longer reach the process, but that requires some additional (possibly complex) code. For now, the code replicates the old behavior only somewhat modified - i.e., if a module sees its connection fail, it checks to see if it is a lifeline. If so, it notifies the errmgr that the lifeline is lost - otherwise, it notifies the errmgr that a non-lifeline connection was lost.
* reachability is determined solely on the basis of a shared subnet address/mask - more sophisticated algorithms (e.g., the one used in the tcp btl) are required to handle routing via gateways
* the RML needs to assign sequence numbers to each message on a per-peer basis. The receiving RML will then deliver messages in order, thus preventing out-of-order messaging in the case where messages travel across different transports or a message needs to be redirected/resent due to failure of a NIC
This commit was SVN r29058.
2013-08-22 20:37:40 +04:00
|
|
|
#if OPAL_ENABLE_IPV6
|
2007-04-25 05:55:40 +04:00
|
|
|
if (AF_INET6 == btl_endpoint->endpoint_addr->addr_family) {
|
|
|
|
af_family = AF_INET6;
|
|
|
|
addrlen = sizeof (struct sockaddr_in6);
|
|
|
|
}
|
|
|
|
#endif
|
2014-12-13 09:45:00 +03:00
|
|
|
assert( btl_endpoint->endpoint_sd < 0 );
|
2007-04-25 05:55:40 +04:00
|
|
|
btl_endpoint->endpoint_sd = socket(af_family, SOCK_STREAM, 0);
|
2005-08-02 17:20:50 +04:00
|
|
|
if (btl_endpoint->endpoint_sd < 0) {
|
|
|
|
btl_endpoint->endpoint_retries++;
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
return OPAL_ERR_UNREACH;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
2007-03-21 00:28:28 +03:00
|
|
|
|
2005-08-02 17:20:50 +04:00
|
|
|
/* setup socket buffer sizes */
|
|
|
|
mca_btl_tcp_set_socket_options(btl_endpoint->endpoint_sd);
|
|
|
|
|
|
|
|
/* setup event callbacks */
|
2008-03-18 05:42:16 +03:00
|
|
|
mca_btl_tcp_endpoint_event_init(btl_endpoint);
|
2005-08-02 17:20:50 +04:00
|
|
|
|
|
|
|
/* setup the socket as non-blocking */
|
|
|
|
if((flags = fcntl(btl_endpoint->endpoint_sd, F_GETFL, 0)) < 0) {
|
2014-12-13 09:59:55 +03:00
|
|
|
BTL_ERROR(("fcntl(F_GETFL) failed: %s (%d)",
|
2007-03-20 14:50:17 +03:00
|
|
|
strerror(opal_socket_errno), opal_socket_errno));
|
2005-08-02 17:20:50 +04:00
|
|
|
} else {
|
|
|
|
flags |= O_NONBLOCK;
|
|
|
|
if(fcntl(btl_endpoint->endpoint_sd, F_SETFL, flags) < 0)
|
2014-12-13 09:59:55 +03:00
|
|
|
BTL_ERROR(("fcntl(F_SETFL) failed: %s (%d)",
|
2007-03-20 14:50:17 +03:00
|
|
|
strerror(opal_socket_errno), opal_socket_errno));
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
2005-12-07 03:12:59 +03:00
|
|
|
|
2005-08-02 17:20:50 +04:00
|
|
|
/* start the connect - will likely fail with EINPROGRESS */
|
2007-04-25 05:55:40 +04:00
|
|
|
mca_btl_tcp_proc_tosocks(btl_endpoint->endpoint_addr, &endpoint_addr);
|
2008-11-05 21:45:42 +03:00
|
|
|
|
2014-12-13 09:59:55 +03:00
|
|
|
opal_output_verbose(20, opal_btl_base_framework.framework_output,
|
2011-03-16 23:20:14 +03:00
|
|
|
"btl: tcp: attempting to connect() to %s address %s on port %d",
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
OPAL_NAME_PRINT(btl_endpoint->endpoint_proc->proc_opal->proc_name),
|
2008-11-05 21:45:42 +03:00
|
|
|
opal_net_get_hostname((struct sockaddr*) &endpoint_addr),
|
2011-03-16 23:20:14 +03:00
|
|
|
ntohs(btl_endpoint->endpoint_addr->addr_port));
|
2008-11-05 21:45:42 +03:00
|
|
|
|
2014-12-15 23:42:08 +03:00
|
|
|
if(0 == connect(btl_endpoint->endpoint_sd, (struct sockaddr*)&endpoint_addr, addrlen)) {
|
|
|
|
/* send our globally unique process identifier to the endpoint */
|
|
|
|
if((rc = mca_btl_tcp_endpoint_send_connect_ack(btl_endpoint)) == OPAL_SUCCESS) {
|
|
|
|
btl_endpoint->endpoint_state = MCA_BTL_TCP_CONNECT_ACK;
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(10, btl_endpoint, true, "event_add(recv) [start_connect]");
|
2014-12-15 23:42:08 +03:00
|
|
|
opal_event_add(&btl_endpoint->endpoint_recv_event, 0);
|
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
2014-12-16 04:27:32 +03:00
|
|
|
/* We connected to the peer, but he close the socket before we got a chance to send our guid */
|
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(1, btl_endpoint, true, "dropped connection [start_connect]");
|
2014-12-15 23:42:08 +03:00
|
|
|
} else {
|
2005-08-02 17:20:50 +04:00
|
|
|
/* non-blocking so wait for completion */
|
2006-08-15 00:14:44 +04:00
|
|
|
if(opal_socket_errno == EINPROGRESS || opal_socket_errno == EWOULDBLOCK) {
|
2005-08-02 17:20:50 +04:00
|
|
|
btl_endpoint->endpoint_state = MCA_BTL_TCP_CONNECTING;
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(10, btl_endpoint, true, "event_add(send) [start_connect]");
|
2010-10-28 19:22:46 +04:00
|
|
|
opal_event_add(&btl_endpoint->endpoint_send_event, 0);
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
return OPAL_SUCCESS;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
}
|
2015-05-15 07:14:28 +03:00
|
|
|
|
2014-12-15 23:42:08 +03:00
|
|
|
{
|
|
|
|
char *address;
|
|
|
|
address = opal_net_get_hostname((struct sockaddr*) &endpoint_addr);
|
|
|
|
BTL_PEER_ERROR( btl_endpoint->endpoint_proc->proc_opal,
|
|
|
|
( "Unable to connect to the peer %s on port %d: %s\n",
|
|
|
|
address,
|
2015-05-15 07:14:28 +03:00
|
|
|
ntohs(btl_endpoint->endpoint_addr->addr_port), strerror(opal_socket_errno) ) );
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
2014-12-13 09:59:55 +03:00
|
|
|
btl_endpoint->endpoint_state = MCA_BTL_TCP_FAILED;
|
|
|
|
mca_btl_tcp_endpoint_close(btl_endpoint);
|
2014-12-15 23:42:08 +03:00
|
|
|
return OPAL_ERR_UNREACH;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check the status of the connection. If the connection failed, will retry
|
2014-12-13 09:59:55 +03:00
|
|
|
* later. Otherwise, send this processes identifier to the endpoint on the
|
2005-08-02 17:20:50 +04:00
|
|
|
* newly connected socket.
|
|
|
|
*/
|
|
|
|
static void mca_btl_tcp_endpoint_complete_connect(mca_btl_base_endpoint_t* btl_endpoint)
|
|
|
|
{
|
|
|
|
int so_error = 0;
|
2006-09-15 01:29:51 +04:00
|
|
|
opal_socklen_t so_length = sizeof(so_error);
|
2009-05-07 18:09:35 +04:00
|
|
|
struct sockaddr_storage endpoint_addr;
|
|
|
|
|
|
|
|
mca_btl_tcp_proc_tosocks(btl_endpoint->endpoint_addr, &endpoint_addr);
|
2005-08-02 17:20:50 +04:00
|
|
|
|
|
|
|
/* check connect completion status */
|
|
|
|
if(getsockopt(btl_endpoint->endpoint_sd, SOL_SOCKET, SO_ERROR, (char *)&so_error, &so_length) < 0) {
|
2014-12-13 09:59:55 +03:00
|
|
|
BTL_ERROR(("getsockopt() to %s failed: %s (%d)",
|
2009-05-07 18:09:35 +04:00
|
|
|
opal_net_get_hostname((struct sockaddr*) &endpoint_addr),
|
|
|
|
strerror(opal_socket_errno), opal_socket_errno));
|
2005-08-02 17:20:50 +04:00
|
|
|
mca_btl_tcp_endpoint_close(btl_endpoint);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(so_error == EINPROGRESS || so_error == EWOULDBLOCK) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(so_error != 0) {
|
2014-12-13 09:59:55 +03:00
|
|
|
BTL_ERROR(("connect() to %s failed: %s (%d)",
|
2009-05-07 18:09:35 +04:00
|
|
|
opal_net_get_hostname((struct sockaddr*) &endpoint_addr),
|
|
|
|
strerror(so_error), so_error));
|
2005-08-02 17:20:50 +04:00
|
|
|
mca_btl_tcp_endpoint_close(btl_endpoint);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-13 09:45:00 +03:00
|
|
|
/* Do not unregister from receiving send event notifications, instead
|
|
|
|
* leave the event to trigger once more, and then it will get automatically
|
|
|
|
* deleted as no send fragments are available.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(mca_btl_tcp_endpoint_send_connect_ack(btl_endpoint) == OPAL_SUCCESS) {
|
2005-08-02 17:20:50 +04:00
|
|
|
btl_endpoint->endpoint_state = MCA_BTL_TCP_CONNECT_ACK;
|
2010-10-28 19:22:46 +04:00
|
|
|
opal_event_add(&btl_endpoint->endpoint_recv_event, 0);
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(10, btl_endpoint, false, "event_add(recv) [complete_connect]");
|
2014-12-15 23:42:08 +03:00
|
|
|
return;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(1, btl_endpoint, false, " [complete_connect]");
|
2014-12-15 23:42:08 +03:00
|
|
|
btl_endpoint->endpoint_state = MCA_BTL_TCP_FAILED;
|
|
|
|
mca_btl_tcp_endpoint_close(btl_endpoint);
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-12-13 09:59:55 +03:00
|
|
|
* A file descriptor is available/ready for recv. Check the state
|
2005-08-02 17:20:50 +04:00
|
|
|
* of the socket and take the appropriate action.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void mca_btl_tcp_endpoint_recv_handler(int sd, short flags, void* user)
|
|
|
|
{
|
|
|
|
mca_btl_base_endpoint_t* btl_endpoint = (mca_btl_base_endpoint_t *)user;
|
2008-02-20 21:17:58 +03:00
|
|
|
|
2008-03-27 21:36:08 +03:00
|
|
|
/* Make sure we don't have a race between a thread that remove the
|
|
|
|
* recv event, and one event already scheduled.
|
|
|
|
*/
|
2008-03-18 05:42:16 +03:00
|
|
|
if( sd != btl_endpoint->endpoint_sd )
|
|
|
|
return;
|
2008-03-27 21:36:08 +03:00
|
|
|
|
2014-12-13 09:45:00 +03:00
|
|
|
/**
|
|
|
|
* There is an extremely rare race condition here, that can only be
|
|
|
|
* triggered during the initialization. If the two processes start their
|
|
|
|
* connection in same time, one of the processes will have to close it's
|
|
|
|
* previous endpoint (the one opened from the local send). As a result it
|
|
|
|
* might go in btl_endpoint_close and try to delete the recv_event. This
|
|
|
|
* call will go back in the libevent, and in a multithreaded case will try
|
|
|
|
* to lock the event. If another thread noticed the active event (and this
|
|
|
|
* is possible as during the initialization there will be 2 sockets), one
|
|
|
|
* thread might get stuck trying to lock the endpoint_recv_lock (while
|
|
|
|
* holding the event_base lock) while the other thread will try to lock the
|
|
|
|
* event_base lock (while holding the endpoint_recv lock).
|
|
|
|
*
|
|
|
|
* If we can't lock this mutex, it is OK to cancel the receive operation, it
|
|
|
|
* will be eventually triggered again shorthly.
|
|
|
|
*/
|
|
|
|
if( OPAL_THREAD_TRYLOCK(&btl_endpoint->endpoint_recv_lock) )
|
|
|
|
return;
|
|
|
|
|
2005-08-02 17:20:50 +04:00
|
|
|
switch(btl_endpoint->endpoint_state) {
|
|
|
|
case MCA_BTL_TCP_CONNECT_ACK:
|
|
|
|
{
|
2014-12-16 05:59:20 +03:00
|
|
|
int rc = mca_btl_tcp_endpoint_recv_connect_ack(btl_endpoint);
|
George did the work and deserves all the credit for it. Ralph did the merge, and deserves whatever blame results from errors in it :-)
WHAT: Open our low-level communication infrastructure by moving all necessary components (btl/rcache/allocator/mpool) down in OPAL
All the components required for inter-process communications are currently deeply integrated in the OMPI layer. Several groups/institutions have express interest in having a more generic communication infrastructure, without all the OMPI layer dependencies. This communication layer should be made available at a different software level, available to all layers in the Open MPI software stack. As an example, our ORTE layer could replace the current OOB and instead use the BTL directly, gaining access to more reactive network interfaces than TCP. Similarly, external software libraries could take advantage of our highly optimized AM (active message) communication layer for their own purpose. UTK with support from Sandia, developped a version of Open MPI where the entire communication infrastucture has been moved down to OPAL (btl/rcache/allocator/mpool). Most of the moved components have been updated to match the new schema, with few exceptions (mainly BTLs where I have no way of compiling/testing them). Thus, the completion of this RFC is tied to being able to completing this move for all BTLs. For this we need help from the rest of the Open MPI community, especially those supporting some of the BTLs. A non-exhaustive list of BTLs that qualify here is: mx, portals4, scif, udapl, ugni, usnic.
This commit was SVN r32317.
2014-07-26 04:47:28 +04:00
|
|
|
if( OPAL_SUCCESS == rc ) {
|
2008-02-20 21:17:58 +03:00
|
|
|
/* we are now connected. Start sending the data */
|
|
|
|
OPAL_THREAD_LOCK(&btl_endpoint->endpoint_send_lock);
|
|
|
|
mca_btl_tcp_endpoint_connected(btl_endpoint);
|
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_send_lock);
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(10, btl_endpoint, true, "connected");
|
2008-02-20 21:17:58 +03:00
|
|
|
}
|
2008-03-27 21:36:08 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock);
|
|
|
|
return;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
case MCA_BTL_TCP_CONNECTED:
|
|
|
|
{
|
2005-12-07 03:12:59 +03:00
|
|
|
mca_btl_tcp_frag_t* frag;
|
|
|
|
|
|
|
|
frag = btl_endpoint->endpoint_recv_frag;
|
2005-08-02 17:20:50 +04:00
|
|
|
if(NULL == frag) {
|
2014-12-13 09:59:55 +03:00
|
|
|
if(mca_btl_tcp_module.super.btl_max_send_size >
|
|
|
|
mca_btl_tcp_module.super.btl_eager_limit) {
|
2013-07-04 12:34:37 +04:00
|
|
|
MCA_BTL_TCP_FRAG_ALLOC_MAX(frag);
|
2014-12-13 09:59:55 +03:00
|
|
|
} else {
|
2013-07-04 12:34:37 +04:00
|
|
|
MCA_BTL_TCP_FRAG_ALLOC_EAGER(frag);
|
2006-05-25 20:57:14 +04:00
|
|
|
}
|
2014-12-13 09:59:55 +03:00
|
|
|
|
2005-12-07 03:12:59 +03:00
|
|
|
if(NULL == frag) {
|
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MCA_BTL_TCP_FRAG_INIT_DST(frag, btl_endpoint);
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
|
2005-12-09 08:16:50 +03:00
|
|
|
#if MCA_BTL_TCP_ENDPOINT_CACHE
|
2006-01-14 23:21:44 +03:00
|
|
|
assert( 0 == btl_endpoint->endpoint_cache_length );
|
2005-12-09 08:16:50 +03:00
|
|
|
data_still_pending_on_endpoint:
|
|
|
|
#endif /* MCA_BTL_TCP_ENDPOINT_CACHE */
|
2005-12-07 03:12:59 +03:00
|
|
|
/* check for completion of non-blocking recv on the current fragment */
|
2008-03-18 05:42:16 +03:00
|
|
|
if(mca_btl_tcp_frag_recv(frag, btl_endpoint->endpoint_sd) == false) {
|
2005-12-07 03:12:59 +03:00
|
|
|
btl_endpoint->endpoint_recv_frag = frag;
|
|
|
|
} else {
|
|
|
|
btl_endpoint->endpoint_recv_frag = NULL;
|
2008-01-15 08:32:53 +03:00
|
|
|
if( MCA_BTL_TCP_HDR_TYPE_SEND == frag->hdr.type ) {
|
|
|
|
mca_btl_active_message_callback_t* reg;
|
|
|
|
reg = mca_btl_base_active_message_trigger + frag->hdr.base.tag;
|
|
|
|
reg->cbfunc(&frag->btl->super, frag->hdr.base.tag, &frag->base, reg->cbdata);
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
2005-12-07 03:12:59 +03:00
|
|
|
#if MCA_BTL_TCP_ENDPOINT_CACHE
|
2005-12-09 08:16:50 +03:00
|
|
|
if( 0 != btl_endpoint->endpoint_cache_length ) {
|
2008-01-15 08:32:53 +03:00
|
|
|
/* If the cache still contain some data we can reuse the same fragment
|
|
|
|
* until we flush it completly.
|
|
|
|
*/
|
2005-12-09 08:16:50 +03:00
|
|
|
MCA_BTL_TCP_FRAG_INIT_DST(frag, btl_endpoint);
|
2005-12-07 03:12:59 +03:00
|
|
|
goto data_still_pending_on_endpoint;
|
2005-12-09 08:16:50 +03:00
|
|
|
}
|
2005-12-07 03:12:59 +03:00
|
|
|
#endif /* MCA_BTL_TCP_ENDPOINT_CACHE */
|
2006-05-25 20:57:14 +04:00
|
|
|
MCA_BTL_TCP_FRAG_RETURN(frag);
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
2006-01-15 00:10:09 +03:00
|
|
|
#if MCA_BTL_TCP_ENDPOINT_CACHE
|
2006-01-14 23:21:44 +03:00
|
|
|
assert( 0 == btl_endpoint->endpoint_cache_length );
|
2006-01-15 00:10:09 +03:00
|
|
|
#endif /* MCA_BTL_TCP_ENDPOINT_CACHE */
|
2007-10-09 22:00:01 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock);
|
2005-12-07 03:12:59 +03:00
|
|
|
break;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
2008-03-18 05:42:16 +03:00
|
|
|
case MCA_BTL_TCP_CLOSED:
|
|
|
|
/* This is a thread-safety issue. As multiple threads are allowed
|
|
|
|
* to generate events (in the lib event) we endup with several
|
|
|
|
* threads executing the receive callback, when we reach the end
|
|
|
|
* of the MPI_Finalize. The first one will close the connections,
|
|
|
|
* and all others will complain.
|
|
|
|
*/
|
2006-01-14 23:21:44 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock);
|
|
|
|
break;
|
2005-08-02 17:20:50 +04:00
|
|
|
default:
|
2006-01-14 23:21:44 +03:00
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_recv_lock);
|
|
|
|
BTL_ERROR(("invalid socket state(%d)", btl_endpoint->endpoint_state));
|
2013-01-21 15:41:08 +04:00
|
|
|
btl_endpoint->endpoint_state = MCA_BTL_TCP_FAILED;
|
2006-01-14 23:21:44 +03:00
|
|
|
mca_btl_tcp_endpoint_close(btl_endpoint);
|
|
|
|
break;
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2006-01-14 23:21:44 +03:00
|
|
|
* A file descriptor is available/ready for send. Check the state
|
2005-08-02 17:20:50 +04:00
|
|
|
* of the socket and take the appropriate action.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void mca_btl_tcp_endpoint_send_handler(int sd, short flags, void* user)
|
|
|
|
{
|
|
|
|
mca_btl_tcp_endpoint_t* btl_endpoint = (mca_btl_tcp_endpoint_t *)user;
|
2014-12-13 09:45:00 +03:00
|
|
|
|
|
|
|
/* if another thread is already here, give up */
|
|
|
|
if( OPAL_THREAD_TRYLOCK(&btl_endpoint->endpoint_send_lock) )
|
|
|
|
return;
|
|
|
|
|
2005-08-02 17:20:50 +04:00
|
|
|
switch(btl_endpoint->endpoint_state) {
|
|
|
|
case MCA_BTL_TCP_CONNECTING:
|
|
|
|
mca_btl_tcp_endpoint_complete_connect(btl_endpoint);
|
|
|
|
break;
|
2006-01-14 23:21:44 +03:00
|
|
|
case MCA_BTL_TCP_CONNECTED:
|
2005-08-02 17:20:50 +04:00
|
|
|
/* complete the current send */
|
2007-08-27 03:40:02 +04:00
|
|
|
while (NULL != btl_endpoint->endpoint_send_frag) {
|
2005-08-02 17:20:50 +04:00
|
|
|
mca_btl_tcp_frag_t* frag = btl_endpoint->endpoint_send_frag;
|
2008-02-18 20:39:30 +03:00
|
|
|
int btl_ownership = (frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP);
|
|
|
|
|
2005-08-02 17:20:50 +04:00
|
|
|
if(mca_btl_tcp_frag_send(frag, btl_endpoint->endpoint_sd) == false) {
|
|
|
|
break;
|
|
|
|
}
|
2005-10-27 05:39:39 +04:00
|
|
|
/* progress any pending sends */
|
|
|
|
btl_endpoint->endpoint_send_frag = (mca_btl_tcp_frag_t*)
|
|
|
|
opal_list_remove_first(&btl_endpoint->endpoint_frags);
|
2005-08-02 17:20:50 +04:00
|
|
|
|
|
|
|
/* if required - update request status and release fragment */
|
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_send_lock);
|
2008-05-30 07:58:39 +04:00
|
|
|
assert( frag->base.des_flags & MCA_BTL_DES_SEND_ALWAYS_CALLBACK );
|
2005-08-02 17:20:50 +04:00
|
|
|
frag->base.des_cbfunc(&frag->btl->super, frag->endpoint, &frag->base, frag->rc);
|
2008-02-18 20:39:30 +03:00
|
|
|
if( btl_ownership ) {
|
|
|
|
MCA_BTL_TCP_FRAG_RETURN(frag);
|
|
|
|
}
|
2014-12-13 09:45:00 +03:00
|
|
|
/* if we fail to take the lock simply return. In the worst case the
|
|
|
|
* send_handler will be triggered once more, and as there will be
|
|
|
|
* nothing to send the handler will be deleted.
|
|
|
|
*/
|
|
|
|
if( OPAL_THREAD_TRYLOCK(&btl_endpoint->endpoint_send_lock) )
|
|
|
|
return;
|
2007-08-27 03:40:02 +04:00
|
|
|
}
|
2005-08-02 17:20:50 +04:00
|
|
|
|
|
|
|
/* if nothing else to do unregister for send event notifications */
|
|
|
|
if(NULL == btl_endpoint->endpoint_send_frag) {
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(10, btl_endpoint, false, "event_del(send) [endpoint_send_handler]");
|
2010-10-28 19:22:46 +04:00
|
|
|
opal_event_del(&btl_endpoint->endpoint_send_event);
|
2005-08-02 17:20:50 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2007-03-20 14:50:17 +03:00
|
|
|
BTL_ERROR(("invalid connection state (%d)", btl_endpoint->endpoint_state));
|
2014-12-16 04:27:32 +03:00
|
|
|
MCA_BTL_TCP_ENDPOINT_DUMP(1, btl_endpoint, true, "event_del(send) [endpoint_send_handler:error]");
|
2010-10-28 19:22:46 +04:00
|
|
|
opal_event_del(&btl_endpoint->endpoint_send_event);
|
2005-08-02 17:20:50 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
OPAL_THREAD_UNLOCK(&btl_endpoint->endpoint_send_lock);
|
|
|
|
}
|