[ create a new paste ] login | about

Link: http://codepad.org/URczlAEl    [ raw code | fork ]

C, pasted on Apr 26:
#include <stdio.h>
#include <stdlib.h>
#include "mpi.h"

#define maxvar 11
#define maxfun 2
#define archive_size 200

int nondomCtr;

typedef struct {
    double var[maxvar];
    double pvar[maxvar];
    double fit[maxfun];
    double pfit[maxfun];
    double velocity[maxvar];
}
Particle;

typedef struct {
    double var[maxvar];
    double fit[maxfun];
}
Archive;

/*....*/

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

    int i;
    int rank, size, npart;

    Particle* pop;
    Particle* allpop;
    Archive* archive;
    double* crowdDist;

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

    if (argc < 2) {
        fprintf( stderr, "Usage: %s n\n", argv[0] );
        MPI_Abort( MPI_COMM_WORLD, 1 );
    }

    npart = atoi(argv[1]) / size;

    /* dynamic allocation */
    pop = (Particle*) malloc(npart*sizeof(Particle));
    allpop = (Particle*) malloc((npart*size)*sizeof(Particle));
    archive = (Archive*) malloc(archive_size*sizeof(Archive));
    crowdDist = (double*) malloc(archive_size*sizeof(double));

    int blockcounts[5] = {maxvar,maxvar,maxfun,maxfun,maxvar};
    MPI_Datatype types[5];
    MPI_Aint displs[5];
    MPI_Aint displacements[5];
    MPI_Datatype cmdtype;

    /* use pop to create the new type */
    MPI_Address( &(pop->var), &displs[0]);
    MPI_Address( &(pop->pvar), &displs[1]);
    MPI_Address( &(pop->fit), &displs[2]);
    MPI_Address( &(pop->pfit), &displs[3]);
    MPI_Address( &(pop->velocity), &displs[4]);
    for(i=0; i<5;i++) {
    	displacements[i] = displs[i] - displs[0];
        types[i] = MPI_DOUBLE;
    }

    MPI_Type_struct(5, blockcounts, displacements, types, &cmdtype);
    MPI_Type_commit(&cmdtype);

    /* this is line 479 */
    MPI_Allgather(pop, npart, cmdtype, allpop, npart*size, cmdtype, MPI_COMM_WORLD);

    /* dealloc */
    free(crowdDist);
    free(pop);
    free(allpop);
    free(archive);

    MPI_Type_free(&cmdtype);
    MPI_Finalize();

    return 0;
}

Core was generated by `/lustre/scratch/c119470/mopsocd_MPI2/./Debug/mopsocd_MPI2 200'.
Program terminated with signal 11, Segmentation fault.
[New process 16130]
#0  0x000000341df71873 in memcpy () from /lib64/tls/libc.so.6
(gdb) backtrace
#0  0x000000341df71873 in memcpy () from /lib64/tls/libc.so.6
#1  0x0000002a9577b0b2 in hpmp_dtcpy () from /opt/hpmpi/lib/linux_amd64/libmpi.so.1
#2  0x0000002a9577ae8f in hpmp_dtsendrecv () from /opt/hpmpi/lib/linux_amd64/libmpi.so.1
#3  0x0000002a957529c9 in hpmp_sbuf2rbuf () from /opt/hpmpi/lib/linux_amd64/libmpi.so.1
#4  0x0000002a95753436 in hpmp_allgatherv () from /opt/hpmpi/lib/linux_amd64/libmpi.so.1
#5  0x0000002a9574b41a in VMPI_Allgather () from /opt/hpmpi/lib/linux_amd64/libmpi.so.1
#6  0x0000000000403a56 in main (argc=2, argv=0x7fbfffe048) at /lustre/scratch/c119470/mopsocd_MPI2/mopso.c:479
(gdb)


Create a new paste based on this one


Comments: