<commit_before>#include "bigmpi_impl.h"

int bigmpi_comms_defined = 0;

MPI_Comm MPI_GRAPH_WORLD;
MPI_Comm MPI_GRAPH_WORLD_ROOTZERO;

/* TODO: These functions are not thread-safe and need a proper mutex. */

int BigMPI_Initialize_comms(void)
{
    if (bigmpi_comms_defined == 1)
        return MPI_SUCCESS;

    {
    }

    bigmpi_comms_defined = 1;

    return MPI_SUCCESS;
}

int BigMPI_Finalize_comms(void)
{
    if (bigmpi_comms_defined == 1) {
    }
    bigmpi_comms_defined = 0;

    return MPI_SUCCESS;
}

/*
 * Synopsis
 *
 * int BigMPI_Create_graph_comm(MPI_Comm comm_old, int root, MPI_Comm * graph_comm)
 *
 *  Input Parameter
 *
 *   comm_old           MPI communicator from which to create a graph comm
 *   root               integer id of root.  if -1, create fully connected graph,
 *                      which is appropriate for the all___ collectives.
 *
 * Output Parameters
 *
 *   graph_comm         MPI topology communicator associated with input communicator
 *   rc                 returns the rc from the MPI graph comm create function.
 *<commit_msg>implement the WORLD graph comm precomputation<commit_after>#include "bigmpi_impl.h"

int bigmpi_comms_defined = 0;

MPI_Comm MPI_GRAPH_WORLD;
MPI_Comm MPI_GRAPH_WORLD_ROOTZERO;

/* TODO: These functions are not thread-safe and need a proper mutex. */

int BigMPI_Initialize_comms(void)
{
    if (bigmpi_comms_defined == 1)
        return MPI_SUCCESS;

    BigMPI_Create_graph_comm(MPI_COMM_WORLD, -1, &MPI_GRAPH_WORLD);
    BigMPI_Create_graph_comm(MPI_COMM_WORLD,  0, &MPI_GRAPH_WORLD_ROOTZERO);

    bigmpi_comms_defined = 1;

    return MPI_SUCCESS;
}

int BigMPI_Finalize_comms(void)
{
    if (bigmpi_comms_defined == 1) {
        MPI_Comm_free(&MPI_GRAPH_WORLD);
        MPI_Comm_free(&MPI_GRAPH_WORLD_ROOTZERO);
    }
    bigmpi_comms_defined = 0;

    return MPI_SUCCESS;
}

/*
 * Synopsis
 *
 * int BigMPI_Create_graph_comm(MPI_Comm comm_old, int root, MPI_Comm * graph_comm)
 *
 *  Input Parameter
 *
 *   comm_old           MPI communicator from which to create a graph comm
 *   root               integer id of root.  if -1, create fully connected graph,
 *                      which is appropriate for the all___ collectives.
 *
 * Output Parameters
 *
 *   graph_comm         MPI topology communicator associated with input communicator
 *   rc                 returns the rc from the MPI graph comm create function.
 *
{'fraction_non_alphanumeric': 0.06840796019900497, 'fraction_numerical': 0.005804311774461028, 'mean_word_length': 2.9818481848184817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5067240', 'n_tokens_mistral': 868, 'n_tokens_neox': 807, 'n_words': 211}