user24399
user24399

Reputation: 31

Segmentation Fault when I use MPI_ALLREDUCE in a simple program

Here is my code:

#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
    int tmpv = 10, tmpvsum;
    MPI_INIT(&argc, &argv);
    printf("begin allreduce.");
    MPI_REDUCE(&tmpv,&tmpvsum,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD);
    printf("tmpv : %4d",tmpvsum);
    MPI_FINALIZE();
    return 0;
}

I successfully compiled it with the following command:

mpiicc -o test_reduce test_reduce.c

But when I run it, I keeps get segmentation fault. I can't see any problems of the code.

Upvotes: 2

Views: 563

Answers (1)

user24399
user24399

Reputation: 31

The problem is:

function "MPI_REDUCE" should be written as "MPI_Reduce".

However, neither 'mpicc' nor 'mpiicc' report this problem in compilation.

Upvotes: 1

Related Questions