Add a test for the new opal if.c functions. Modify the multicast test
This commit was SVN r22081.
Этот коммит содержится в:
родитель
c58a30ea10
Коммит
b7a0125bb7
@ -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)
|
all: $(PROGS)
|
||||||
|
|
||||||
|
53
orte/test/system/opal_interface.c
Обычный файл
53
orte/test/system/opal_interface.c
Обычный файл
@ -0,0 +1,53 @@
|
|||||||
|
/* -*- C -*-
|
||||||
|
*
|
||||||
|
* $HEADER$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
@ -32,13 +32,13 @@ int main(int argc, char* argv[])
|
|||||||
fprintf(stderr, "orte_nodename: couldn't init orte - error code %d\n", rc);
|
fprintf(stderr, "orte_nodename: couldn't init orte - error code %d\n", rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
gethostname(hostname, 512);
|
gethostname(hostname, 512);
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
|
|
||||||
printf("orte_nodename: Node %s Name %s Pid %ld\n",
|
printf("orte_nodename: Node %s Name %s Pid %ld\n",
|
||||||
hostname, ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), (long)pid);
|
hostname, ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), (long)pid);
|
||||||
|
|
||||||
|
|
||||||
OBJ_CONSTRUCT(&buf, opal_buffer_t);
|
OBJ_CONSTRUCT(&buf, opal_buffer_t);
|
||||||
|
|
||||||
@ -46,16 +46,20 @@ int main(int argc, char* argv[])
|
|||||||
orte_grpcomm.barrier();
|
orte_grpcomm.barrier();
|
||||||
fprintf(stderr, "%d: past barrier\n", (int)ORTE_PROC_MY_NAME->vpid);
|
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);
|
ORTE_ERROR_LOG(rc);
|
||||||
}
|
}
|
||||||
opal_dss.pack(&buf, &i32, 1, OPAL_INT32);
|
opal_dss.pack(&buf, &i32, 1, OPAL_INT32);
|
||||||
if (ORTE_SUCCESS != (rc = orte_rmcast.send(ORTE_RMCAST_APP_PUBLIC_ADDR, &buf))) {
|
if (ORTE_SUCCESS != (rc = orte_rmcast.send(0, ORTE_RMCAST_TAG_WILDCARD, &buf))) {
|
||||||
ORTE_ERROR_LOG(rc);
|
ORTE_ERROR_LOG(rc);
|
||||||
goto blast;
|
goto blast;
|
||||||
}
|
}
|
||||||
} else {
|
} 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_ERROR_LOG(rc);
|
||||||
}
|
}
|
||||||
orte_grpcomm.barrier();
|
orte_grpcomm.barrier();
|
||||||
@ -71,10 +75,21 @@ blast:
|
|||||||
return 0;
|
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");
|
fprintf(stderr, "GOT MESSAGE\n");
|
||||||
fflush(stderr);
|
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();
|
orte_finalize();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user