|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpiimpl.h"
|
|
Packit Service |
c5cf8c |
#include "group.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* style: allow:fprintf:2 sig:0 */
|
|
Packit Service |
c5cf8c |
/* style: PMPIuse:PMPI_Abort:2 sig:0 */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* This file contains routines that are used only to perform testing
|
|
Packit Service |
c5cf8c |
* and debugging of the group routines
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
void MPITEST_Group_create(int, int, MPI_Group *);
|
|
Packit Service |
c5cf8c |
void MPITEST_Group_print(MPI_Group);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* --BEGIN DEBUG-- */
|
|
Packit Service |
c5cf8c |
void MPITEST_Group_create(int nproc, int myrank, MPI_Group * new_group)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPIR_Group *new_group_ptr;
|
|
Packit Service |
c5cf8c |
int i;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
new_group_ptr = (MPIR_Group *) MPIR_Handle_obj_alloc(&MPIR_Group_mem);
|
|
Packit Service |
c5cf8c |
if (!new_group_ptr) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Could not create a new group\n");
|
|
Packit Service |
c5cf8c |
PMPI_Abort(MPI_COMM_WORLD, 1);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPIR_Object_set_ref(new_group_ptr, 1);
|
|
Packit Service |
c5cf8c |
new_group_ptr->lrank_to_lpid =
|
|
Packit Service |
c5cf8c |
(MPII_Group_pmap_t *) MPL_malloc(nproc * sizeof(MPII_Group_pmap_t), MPL_MEM_DEBUG);
|
|
Packit Service |
c5cf8c |
if (!new_group_ptr->lrank_to_lpid) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Could not create lrank map for new group\n");
|
|
Packit Service |
c5cf8c |
PMPI_Abort(MPI_COMM_WORLD, 1);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
new_group_ptr->rank = MPI_UNDEFINED;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < nproc; i++) {
|
|
Packit Service |
c5cf8c |
new_group_ptr->lrank_to_lpid[i].lrank = i;
|
|
Packit Service |
c5cf8c |
new_group_ptr->lrank_to_lpid[i].lpid = i;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
new_group_ptr->size = nproc;
|
|
Packit Service |
c5cf8c |
new_group_ptr->rank = myrank;
|
|
Packit Service |
c5cf8c |
new_group_ptr->idx_of_first_lpid = -1;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
*new_group = new_group_ptr->handle;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
void MPITEST_Group_print(MPI_Group g)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPIR_Group *g_ptr;
|
|
Packit Service |
c5cf8c |
int g_idx, size, i;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_Group_get_ptr(g, g_ptr);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
g_idx = g_ptr->idx_of_first_lpid;
|
|
Packit Service |
c5cf8c |
if (g_idx < 0) {
|
|
Packit Service |
c5cf8c |
MPII_Group_setup_lpid_list(g_ptr);
|
|
Packit Service |
c5cf8c |
g_idx = g_ptr->idx_of_first_lpid;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Loop through these, printing the lpids by rank and in order */
|
|
Packit Service |
c5cf8c |
size = g_ptr->size;
|
|
Packit Service |
c5cf8c |
fprintf(stdout, "Lpids in rank order\n");
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++) {
|
|
Packit Service |
c5cf8c |
fprintf(stdout, "Rank %d has lpid %d\n", i, g_ptr->lrank_to_lpid[i].lpid);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fprintf(stdout, "Ranks in lpid order\n");
|
|
Packit Service |
c5cf8c |
while (g_idx >= 0) {
|
|
Packit Service |
c5cf8c |
fprintf(stdout, "Rank %d has lpid %d\n", g_idx, g_ptr->lrank_to_lpid[g_idx].lpid);
|
|
Packit Service |
c5cf8c |
g_idx = g_ptr->lrank_to_lpid[g_idx].next_lpid;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* --END DEBUG-- */
|