1
1

usnic: handle NULL endpoints in connectivity map

The connectivity map output routine needs to handle the case where
entries in the endpoints array are NULL (e.g., if one process has 2
endpoints and another process has only 1 endpoint).

Fixes Cisco bug CSCup83649.

cmr=v1.8.2

This commit was SVN r32211.
Этот коммит содержится в:
Jeff Squyres 2014-07-11 00:43:45 +00:00
родитель 2ce11ed5c4
Коммит 7384ee9e44

Просмотреть файл

@ -80,6 +80,12 @@ static int map_compare_endpoints(const void *aa, const void *bb)
ompi_btl_usnic_endpoint_t *a = *((ompi_btl_usnic_endpoint_t**) aa); ompi_btl_usnic_endpoint_t *a = *((ompi_btl_usnic_endpoint_t**) aa);
ompi_btl_usnic_endpoint_t *b = *((ompi_btl_usnic_endpoint_t**) bb); ompi_btl_usnic_endpoint_t *b = *((ompi_btl_usnic_endpoint_t**) bb);
if (NULL == a) {
return 1;
} else if (NULL == b) {
return -1;
}
return strcmp(ibv_get_device_name(a->endpoint_module->device), return strcmp(ibv_get_device_name(a->endpoint_module->device),
ibv_get_device_name(b->endpoint_module->device)); ibv_get_device_name(b->endpoint_module->device));
} }
@ -90,13 +96,17 @@ static int map_compare_endpoints(const void *aa, const void *bb)
static void map_output_endpoints(FILE *fp, ompi_btl_usnic_proc_t *proc) static void map_output_endpoints(FILE *fp, ompi_btl_usnic_proc_t *proc)
{ {
size_t i; size_t i;
size_t num_output;
size_t size; size_t size;
ompi_btl_usnic_endpoint_t **eps; ompi_btl_usnic_endpoint_t **eps;
char ipv4[IPV4STRADDRLEN]; char ipv4[IPV4STRADDRLEN];
char mac[MACSTRLEN]; char mac[MACSTRLEN];
/* First, we must sort the endpoints on this proc by MCW rank so /* First, we must sort the endpoints on this proc by MCW rank so
that they're always output in a repeatable order. */ that they're always output in a repeatable order. There may
also be NULL endpoints (if we didn't match that peer's
endpoint). The sort will put NULLs at the end of the array,
where they can be easily ignored. */
size = proc->proc_endpoint_count * sizeof(ompi_btl_usnic_endpoint_t *); size = proc->proc_endpoint_count * sizeof(ompi_btl_usnic_endpoint_t *);
eps = calloc(1, size); eps = calloc(1, size);
if (NULL == eps) { if (NULL == eps) {
@ -109,9 +119,13 @@ static void map_output_endpoints(FILE *fp, ompi_btl_usnic_proc_t *proc)
sizeof(ompi_btl_usnic_endpoint_t*), sizeof(ompi_btl_usnic_endpoint_t*),
map_compare_endpoints); map_compare_endpoints);
/* Loop over and print the sorted endpoint information */ /* Loop over and print the sorted endpoint information, ignoring
for (i = 0; i < proc->proc_endpoint_count; ++i) { NULLs that might be at the end of the array. */
if (i > 0) { for (num_output = i = 0; i < proc->proc_endpoint_count; ++i) {
if (NULL == eps[i]) {
break;
}
if (num_output > 0) {
fprintf(fp, ","); fprintf(fp, ",");
} }
@ -123,6 +137,7 @@ static void map_output_endpoints(FILE *fp, ompi_btl_usnic_proc_t *proc)
fprintf(fp, "device=%s@peer_ip=%s@peer_mac=%s", fprintf(fp, "device=%s@peer_ip=%s@peer_mac=%s",
ibv_get_device_name(eps[i]->endpoint_module->device), ibv_get_device_name(eps[i]->endpoint_module->device),
ipv4, mac); ipv4, mac);
++num_output;
} }
fprintf(fp, "\n"); fprintf(fp, "\n");