I tried to write some hello-world program in MPI:
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#define BUFFER_SIZE (1024 * 1024)
int main(int argc, char* argv[]) {
float data[BUFFER_SIZE];
float base_output[BUFFER_SIZE];
printf("Buffer size is %d\n", BUFFER_SIZE);
printf("Data pointer is %p\n", data);
printf("Output pointer is %p\n", base_output);
MPI_Init(&argc, &argv);
MPI_Finalize();
return 0;
}
but I keep getting the following error:
===================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= PID 26322 RUNNING AT lindeMacBook-Pro.local
= EXIT CODE: 11
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault: 11 (signal 11)
This typically refers to a problem with your application.
Please see the FAQ page for debugging suggestions
Here's how I compile and run the code.
mpicc -o test test.c -O3 -march=native -g -Wall
mpiexec -n 4 ./test
The BUFFER_SIZE seems to affect the result. When it's smaller, e.g. (1000*1024), the program produces the desired result. But when it's larger than 1024*1024, it will crash.