Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coll/base/alltoall: fixes send/recv offsets in rbuf for the case of MPI_IN_PLACE #9648

Merged
merged 1 commit into from
Nov 11, 2021

Conversation

mkurnosov
Copy link
Contributor

Fixes send/recv offsets in rbuf for the case of MPI_IN_PLACE

Signed-off-by: Mikhail Kurnosov mkurnosov@gmail.com

Signed-off-by: Mikhail Kurnosov <mkurnosov@gmail.com>
@mkurnosov
Copy link
Contributor Author

Reproducer:

#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <mpi.h>

int main(int argc, char **argv)
{
    int rank, commsize;

    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &commsize);

    int count = 10;
    uint8_t *rbuf = malloc(sizeof(*rbuf) * count * commsize);

    for (int i = 0; i < commsize; i++) {
        for (int j = 0; j < count; j++) {
            rbuf[i * count + j] = rank;
        }
    }

    MPI_Alltoall(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, rbuf, count, MPI_UINT8_T, MPI_COMM_WORLD);

    for (int i = 0; i < commsize; i++) {
        for (int j = 0; j < count; j++) {
            uint8_t val = i;
            if (rbuf[i * count + j] != val) {
                fprintf(stderr, "Error: rank %d: Invalid value [%d/%d] = %d, need %d\n",
                        rank, i, j, rbuf[i * count + j], val);
                break;
            }
        }
    }

    free(rbuf);
    MPI_Finalize();
    return 0;
}

Copy link
Member

@bosilca bosilca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch.

@awlauria
Copy link
Contributor

This may fix #9501

@awlauria awlauria merged commit 234e35c into open-mpi:master Nov 11, 2021
@awlauria
Copy link
Contributor

v5.0.x pr: #9652

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants