Intel® MPI Library Developer Guide for Linux* OS

ID 768728
Date 12/16/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

async_progress_sample.c

#define PROGRESS_THREAD_COUNT 4
MPI_Comm comms[PROGRESS_THREAD_COUNT];
MPI_Request requests[PROGRESS_THREAD_COUNT];
MPI_Info info;
int idx;
/* create “per-thread” communicators and assign thread id for each communicator */
for (idx = 0; idx < PROGRESS_THREAD_COUNT; idx++)
{
        MPI_Comm_dup(MPI_COMM_WORLD, &comms[idx]);
        char thread_id_str[256] = { 0 };
        sprintf(thread_id_str, "%d", idx);
        MPI_Info_create(&info);
        MPI_Info_set(info, "thread_id", thread_id_str);
        MPI_Comm_set_info(comms[idx], info);
        MPI_Info_free(&info);
    }
/* distribute MPI operations between communicators – i.e. between progress threads */
for (idx = 0; idx < PROGRESS_THREAD_COUNT; idx++)
{
    MPI_Iallreduce(…, comms[idx], &requests[idx]);
}
MPI_Waitall(PROGRESS_THREAD_COUNT, requests, …)