diff --git a/orte/test/system/Makefile b/orte/test/system/Makefile index b6e2854815..28bbf24187 100644 --- a/orte/test/system/Makefile +++ b/orte/test/system/Makefile @@ -1,4 +1,4 @@ -PROGS = no_op sigusr_trap spin orte_nodename orte_spawn orte_loop_spawn orte_loop_child orte_abort get_limits orte_ring spawn_child orte_tool orte_no_op binom oob_stress iof_stress iof_delay radix orte_barrier orte_mcast +PROGS = no_op sigusr_trap spin orte_nodename orte_spawn orte_loop_spawn orte_loop_child orte_abort get_limits orte_ring spawn_child orte_tool orte_no_op binom oob_stress iof_stress iof_delay radix orte_barrier orte_mcast opal_interface all: $(PROGS) diff --git a/orte/test/system/opal_interface.c b/orte/test/system/opal_interface.c new file mode 100644 index 0000000000..a4750abaf6 --- /dev/null +++ b/orte/test/system/opal_interface.c @@ -0,0 +1,53 @@ +/* -*- C -*- + * + * $HEADER$ + * + */ +#include +#include + +#include "opal/dss/dss.h" +#include "opal/event/event.h" +#include "opal/util/if.h" +#include "opal/runtime/opal.h" + +int main(int argc, char* argv[]) +{ + int rc, idx; + uint32_t addr, netmask, netaddr; + struct sockaddr_in inaddr; + + if (0 > (rc = opal_init())) { + fprintf(stderr, "orte_interface: couldn't init opal - error code %d\n", rc); + return rc; + } + + rc = opal_iftupletoaddr(argv[1], &netaddr, &netmask); + + fprintf(stderr, "netaddr %03d.%03d.%03d.%03d netmask %03d.%03d.%03d.%03d rc %d\n", + OPAL_IF_FORMAT_ADDR(netaddr), OPAL_IF_FORMAT_ADDR(netmask), rc); + + /* search for a matching interface - take the first one within the returned scope */ + idx = opal_ifbegin(); + while (0 < idx) { + /* ignore the loopback interface */ + if (opal_ifisloopback(idx)) { + fprintf(stderr, "LOOPBACK IGNORED\n"); + idx = opal_ifnext(idx); + continue; + } + if (0 != (rc = opal_ifindextoaddr(idx, (struct sockaddr*)&inaddr, sizeof(inaddr)))) { + break; + } + addr = ntohl(inaddr.sin_addr.s_addr); + fprintf(stderr, "checking netaddr %03d.%03d.%03d.%03d addr %03d.%03d.%03d.%03d netmask %03d.%03d.%03d.%03d rc %d\n", + OPAL_IF_FORMAT_ADDR(netaddr), OPAL_IF_FORMAT_ADDR(addr), OPAL_IF_FORMAT_ADDR(netmask), rc); + if (netaddr == (addr & netmask)) { + fprintf(stderr, "MATCH FOUND\n"); + } + idx = opal_ifnext(idx); + } + + opal_finalize(); + return 0; +} diff --git a/orte/test/system/orte_mcast.c b/orte/test/system/orte_mcast.c index 60c74e62f0..59f27de4e4 100644 --- a/orte/test/system/orte_mcast.c +++ b/orte/test/system/orte_mcast.c @@ -32,13 +32,13 @@ int main(int argc, char* argv[]) fprintf(stderr, "orte_nodename: couldn't init orte - error code %d\n", rc); return rc; } - + gethostname(hostname, 512); pid = getpid(); - + printf("orte_nodename: Node %s Name %s Pid %ld\n", hostname, ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), (long)pid); - + OBJ_CONSTRUCT(&buf, opal_buffer_t); @@ -46,16 +46,20 @@ int main(int argc, char* argv[]) orte_grpcomm.barrier(); fprintf(stderr, "%d: past barrier\n", (int)ORTE_PROC_MY_NAME->vpid); - if (ORTE_SUCCESS != (rc = orte_rmcast.recv_nb(ORTE_RMCAST_APP_PUBLIC_ADDR, cbfunc, NULL))) { + if (ORTE_SUCCESS != (rc = orte_rmcast.recv_nb(0, ORTE_RMCAST_PERSISTENT, + ORTE_RMCAST_TAG_WILDCARD, + cbfunc, NULL))) { ORTE_ERROR_LOG(rc); } opal_dss.pack(&buf, &i32, 1, OPAL_INT32); - if (ORTE_SUCCESS != (rc = orte_rmcast.send(ORTE_RMCAST_APP_PUBLIC_ADDR, &buf))) { - ORTE_ERROR_LOG(rc); - goto blast; - } + if (ORTE_SUCCESS != (rc = orte_rmcast.send(0, ORTE_RMCAST_TAG_WILDCARD, &buf))) { + ORTE_ERROR_LOG(rc); + goto blast; + } } else { - if (ORTE_SUCCESS != (rc = orte_rmcast.recv_nb(ORTE_RMCAST_APP_PUBLIC_ADDR, cbfunc, NULL))) { + if (ORTE_SUCCESS != (rc = orte_rmcast.recv_nb(0, ORTE_RMCAST_PERSISTENT, + ORTE_RMCAST_TAG_WILDCARD, + cbfunc, NULL))) { ORTE_ERROR_LOG(rc); } orte_grpcomm.barrier(); @@ -71,10 +75,21 @@ blast: return 0; } -static void cbfunc(int channel, opal_buffer_t *buf, void *cbdata) +static void cbfunc(int channel, opal_buffer_t *buffer, void *cbdata) { + opal_buffer_t buf; + int32_t i32=1, rc; + fprintf(stderr, "GOT MESSAGE\n"); fflush(stderr); + if (0 != ORTE_PROC_MY_NAME->vpid) { + OBJ_CONSTRUCT(&buf, opal_buffer_t); + opal_dss.pack(&buf, &i32, 1, OPAL_INT32); + if (ORTE_SUCCESS != (rc = orte_rmcast.send(0, ORTE_RMCAST_TAG_WILDCARD, &buf))) { + ORTE_ERROR_LOG(rc); + } + OBJ_DESTRUCT(&buf); + } orte_finalize(); exit(0); }