1
1
openmpi/opal/mca/reachable/base/reachable_base_alloc.c
Gabe Saba 3f8d294191 reachable: Enable weighted component / fix interface
Based on work from usNIC, the best way to use the reachability
information the reachable components return is to build a
connectivity graph between the two peers and run a bipartite
graph solver.  Rather than returning the "best" pairing,
the reachability framework now returns the entire mapping,
allowing a (soon to be added) graph solver to build the
"optimal" connectivity pairing.

Practically, this means changing the return type of the
reachable() function and rewriting the weighted_reachable()
function to return the full mapping.  The netlink_reachable()
function still always returns NULL.

At the same time, fix bit-rot in the weighted component and
enable builds of the component by removing the opal_ignore.
Also, add IPv6 support to the weighted component to support
both use cases in the TCP BTL.

Signed-off-by: Brian Barrett <bbarrett@amazon.com>
2017-09-19 19:42:54 -07:00

67 строки
1.6 KiB
C

/*
* Copyright (c) 2017 Amazon.com, Inc. or its affiliates.
* All Rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include "opal/class/opal_object.h"
#include "opal/mca/reachable/reachable.h"
#include "opal/mca/reachable/base/base.h"
static void opal_reachable_construct(opal_reachable_t *reachable)
{
reachable->weights = NULL;
}
static void opal_reachable_destruct(opal_reachable_t * reachable)
{
if (NULL != reachable->memory) {
free(reachable->memory);
}
}
opal_reachable_t * opal_reachable_allocate(unsigned int num_local,
unsigned int num_remote)
{
char *memory;
unsigned int i;
opal_reachable_t *reachable = OBJ_NEW(opal_reachable_t);
reachable->num_local = num_local;
reachable->num_remote = num_remote;
/* allocate all the pieces of the two dimensional array in one
malloc, rather than a bunch of little allocations */
memory = malloc(sizeof(int*) * num_local +
num_local * (sizeof(int) * num_remote));
if (memory == NULL) return NULL;
reachable->memory = (void*)memory;
reachable->weights = (int**)reachable->memory;
memory += (sizeof(int*) * num_local);
for (i = 0; i < num_local; i++) {
reachable->weights[i] = (int*)memory;
memory += (sizeof(int) * num_remote);
}
return reachable;
}
OBJ_CLASS_INSTANCE(
opal_reachable_t,
opal_object_t,
opal_reachable_construct,
opal_reachable_destruct
);