1
1
openmpi/orte/test/system/radix.c
Ralph Castain f54fda489e This is a first step towards supporting fully-routed OOB communications:
1. remove direct routed module (hooray!)

2. add radix tree routed module (binomial remains default)

3. remove duplicate data storage - orteds were storing nidmap and pidmap data in odls, everyone else in ess

4. add ess APIs to update nidmap, add new pidmap - used only by orteds for MPI-2 support

5. modify code to eliminate multiple calls to orte_routed.update_route that recreated info already in ess pidmap. Add ess API to lookup that info instead. Modify routed modules to utilize that capability

6. setup new ability to shutdown orteds without sending back an "ack" message to mpirun - not utilized yet, will require some changes to plm terminate_orteds functions in managed environments (coming soon)

Initial tests indicating that fully routing comm via defined routing trees may not actually have a significant cost for operations like IB QP setup. More tests required to confirm.

This will require an autogen...

This commit was SVN r19866.
2008-10-31 21:10:00 +00:00

140 строки
3.8 KiB
C

/* -*- C -*-
*
* $HEADER$
*
* The most basic of MPI applications
*/
#include "orte_config.h"
#include <stdio.h>
#include <unistd.h>
#include "opal/util/bit_ops.h"
#include "opal/class/opal_list.h"
#include "opal/class/opal_bitmap.h"
#include "orte/mca/routed/base/base.h"
#include "orte/util/name_fns.h"
#include "orte/runtime/orte_globals.h"
#include "orte/runtime/runtime.h"
static int Radix;
int down_search(int me, int num_procs,
int *num_children, opal_list_t *children, opal_bitmap_t *relatives)
{
int i, peer, Sum, NInLevel, rc;
orte_routed_tree_t *child;
opal_bitmap_t *relations;
/* compute how many procs are at my level */
Sum=1;
NInLevel=1;
while ( Sum < (me+1) ) {
NInLevel *= Radix;
Sum += NInLevel;
}
/* printf("\trank %d inlevel %d\n", me, NInLevel); */
/* our children start at our rank + num_in_level */
peer = me + NInLevel;
for (i = 0; i < Radix; i++) {
if (peer < num_procs) {
child = OBJ_NEW(orte_routed_tree_t);
child->vpid = peer;
if (NULL != children) {
/* printf("\t\tadding child rank %d\n", peer); */
/* this is a direct child - add it to my list */
opal_list_append(children, &child->super);
(*num_children)++;
/* setup the relatives bitmap */
opal_bitmap_init(&child->relatives, num_procs);
/* point to the relatives */
relations = &child->relatives;
} else {
/* printf("\t\tsetting bit for rank %d\n", peer); */
/* we are recording someone's relatives - set the bit */
if (OPAL_SUCCESS != (rc = opal_bitmap_set_bit(relatives, peer))) {
printf("\t\t\tbit not set!\n");
}
/* point to this relations */
relations = relatives;
}
/* printf("\tdownsearching peer %d\n", peer); */
/* search for this child's relatives */
down_search(peer, num_procs, NULL, NULL, relations);
}
peer += NInLevel;
}
}
main(int argc, char **argv)
{
opal_list_t children;
opal_list_item_t *item;
int num_children;
orte_routed_tree_t *child;
int j;
int NProcs;
int Level,Sum,NInLevel,Ii;
int Parent,NInPrevLevel;
if (3 != argc) {
printf("usage: radix r x, where r=radix and x=number of procs\n");
exit(1);
}
orte_init(ORTE_TOOL);
Radix = atoi(argv[1]);
NProcs = atoi(argv[2]);
for(Ii = 0 ; Ii < NProcs ; Ii++) {
OBJ_CONSTRUCT(&children, opal_list_t);
num_children = 0;
Level=0;
Sum=1;
NInLevel=1;
while ( Sum < (Ii+1) ) {
Level++;
NInLevel*=Radix;
Sum+=NInLevel;
}
Sum-=NInLevel;
NInPrevLevel=NInLevel/Radix;
if( 0 == Ii ) {
Parent=-1;
} else {
Parent=(Ii-Sum) % NInPrevLevel;
Parent+=(Sum - NInPrevLevel);
}
fprintf(stderr," I am %d: Parent %d\n",
Ii,Parent);
/* compute children and relatives */
down_search(Ii, NProcs, &num_children, &children, NULL);
while (NULL != (item = opal_list_remove_first(&children))) {
child = (orte_routed_tree_t*)item;
fprintf(stderr, "\tchild %d\n", child->vpid);
for (j=0; j < NProcs; j++) {
if (opal_bitmap_is_set_bit(&child->relatives, j)) {
fprintf(stderr, "\t\trelation %d\n", j);
}
}
OBJ_RELEASE(item);
}
OBJ_DESTRUCT(&children);
}
orte_finalize();
}