File: ring_neighbor_alltoall.c

package info (click to toggle)
mpich 4.3.0%2Breally4.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 419,120 kB
  • sloc: ansic: 1,215,557; cpp: 74,755; javascript: 40,763; f90: 20,649; sh: 18,463; xml: 14,418; python: 14,397; perl: 13,772; makefile: 9,279; fortran: 8,063; java: 4,553; asm: 324; ruby: 176; lisp: 19; php: 8; sed: 4
file content (46 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright (C) by Argonne National Laboratory
 *     See COPYRIGHT in top-level directory
 */
/* This test borrows some ideas from a test provided by Rolf
 * Rabenseifner (HLRS), but is a rewrite of the primary logic to make
 * it more suitable for the MPICH test suite. */

#include <stdio.h>
#include <mpi.h>
#include "mpitest.h"

int main(int argc, char *argv[])
{
    MTest_Init(&argc, &argv);

    int size;
    MPI_Comm_size(MPI_COMM_WORLD, &size);
    if (size > 2) {
        fprintf(stderr, "run this test with 1 or 2 processes\n");
        MPI_Abort(MPI_COMM_WORLD, 1);
    }

    int dims[1] = { size };
    int periods[1] = { 1 };
    int reorder = 1;

    MPI_Comm newcomm;
    MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periods, reorder, &newcomm);

    int sbuf[2], rbuf[2] = { 0 };
    sbuf[0] = -1;
    sbuf[1] = 1;
    MPI_Neighbor_alltoall(sbuf, 1, MPI_INT, rbuf, 1, MPI_INT, newcomm);

    MPI_Comm_free(&newcomm);

    int errs = 0;
    if (rbuf[0] != 1 || rbuf[1] != -1) {
        printf("expected rbuf to be (1,-1), but found (%d,%d)\n", rbuf[0], rbuf[1]);
        errs++;
    }

    MTest_Finalize(errs);
    return MTestReturnValue(errs);
}