Hi,

The attached test code pass with MPICH well, but has problems with OpenMPI.

There are three tests in the code, the first passes, the second one hangs,
and the third one results in seg. fault and core dump.

The hanging seemed caused by the handle in the function
ompi_coll_libnbc_ialltoallw in mca/coll/libnbc/nbc_ialltoallw.c, where it
is not set correctly for the request, based on the input parameters.

The the seg fault is caused by ompi_datatype_type_size(sendtypes[me],
&sendtype_size); //*sendtypes[me] = NULL.*

any suggestion?

Dahai
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
 * This programs evidence the issue described in #4506
 * This program should be ran on one node using the coll/basic module
 * and on 1, 2, 5 and 8 tasks :
 *
 * mpirun -np <nb_tasks> -host localhost --mca coll_basic_priority 100 ./test_4506
 * The output should be :
 * No Errors
 *
 * This test makes sure that zero counts with non-zero-sized types on the
 * send (recv) side match and don't cause a problem with non-zero counts and
 * zero-sized types on the recv (send) side when using MPI_Alltoallw and
 * MPI_Alltoallv.
 *
 *  (C) 2009 by Argonne National Laboratory.
 * Copyright (c) 2014      Research Organization for Information Science
 *                         and Technology (RIST). All rights reserved.
 * Based on a test case contributed by Michael Hofmann.
 *
 * This program is highly inspired from coll/alltoallw_zeros.c which is
 * part of the mpich2 testsuite and can be downloaded at
 * http://ftp.mcs.anl.gov/pub/mpi/mpi-test/mpich2-testsuite-1.2.tar.gz
 */

/* TODO test intercommunicators as well */


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

#include <mpi.h>

//#include "ompitest_error.h"

int main(int argc, char *argv[])
{
    int sendbuf, recvbuf;
    int *sendcounts;
    int *recvcounts;
    int *sdispls;
    int *rdispls;
    MPI_Datatype sendtype;
    MPI_Datatype *sendtypes;
    MPI_Datatype *recvtypes;
    int rank = -1;
    int size = -1;
    int i;
    MPI_Request req;

    /* This test is known to fail with OMPI <=1.8.2, and won't be
       fixed */
    //ompitest_check_ompiver(1, 8, 1, OMPI_VER_GREATER);

    MPI_Init(&argc, &argv);

    MPI_Comm_size(MPI_COMM_WORLD, &size);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);


  printf(" --- irank = %d\n", rank); 

    sendtypes  = malloc(size * sizeof(MPI_Datatype));
    recvtypes  = malloc(size * sizeof(MPI_Datatype));
    sendcounts = malloc(size * sizeof(int));
    recvcounts = malloc(size * sizeof(int));
    sdispls    = malloc(size * sizeof(int));
    rdispls    = malloc(size * sizeof(int));
    // if (!sendtypes  || !recvtypes ||
    //     !sendcounts || !recvcounts ||
    //     !sdispls    || !rdispls)
    // {
    //     ompitest_error(__FILE__, __LINE__,
    //                    "error, unable to allocate memory\n");
    //     /* Does not return */
    // }

    MPI_Type_contiguous(0, MPI_INT, &sendtype);
    MPI_Type_commit(&sendtype);

    for (i = 0; i < size; ++i) {
        sendtypes[i] = sendtype;
        sendcounts[i] = 1;
        sdispls[i] = 0;

        recvtypes[i] = MPI_INT;
        recvcounts[i] = 0;
        rdispls[i] = 0;
    }

    // test 1
    /* try zero-counts on both the send and recv side in case only one
       direction is broken for some reason */
    //printf(" --- test 1 ..\n"); 
    // MPI_Ialltoallw(&sendbuf, sendcounts, sdispls, sendtypes,
    //                &recvbuf, recvcounts, rdispls, recvtypes, MPI_COMM_WORLD, &req);
    // MPI_Wait(&req, MPI_STATUS_IGNORE);

    // test 2
    printf(" --- test 2 ..\n"); 
    MPI_Ialltoallw(&sendbuf, recvcounts, rdispls, recvtypes,
                   &recvbuf, sendcounts, sdispls, sendtypes, MPI_COMM_WORLD, &req);
    MPI_Wait(&req, MPI_STATUS_IGNORE);

    // test 3
    /* pass MPI_IN_PLACE and different but compatible types rank is
       even/odd */
    // printf(" --- test 3 ..\n"); 
    // if (rank % 2) {
    //     MPI_Ialltoallw(MPI_IN_PLACE, NULL, NULL, NULL,
    //                    &recvbuf, recvcounts, rdispls, recvtypes, MPI_COMM_WORLD, &req);
    // } else {
    //     MPI_Ialltoallw(MPI_IN_PLACE, NULL, NULL, NULL,
    //                   &recvbuf, sendcounts, sdispls, sendtypes, MPI_COMM_WORLD, &req);
    // }
    //MPI_Wait(&req, MPI_STATUS_IGNORE);

    MPI_Type_free(&sendtype);

    if (rdispls)    free(rdispls);
    if (sdispls)    free(sdispls);
    if (recvcounts) free(recvcounts);
    if (sendcounts) free(sendcounts);
    if (recvtypes)  free(recvtypes);
    if (sendtypes)  free(sendtypes);

    MPI_Finalize();

    return 0;
}

_______________________________________________
devel mailing list
devel@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/devel

Reply via email to