How to run compiled MPI function
3 次查看(过去 30 天)
显示 更早的评论
Hi,
I did a simple MPI code and successfully compiled it by MEX. However, I do not know how to run it in MATLAB.
The name of the compiled file is called testMPI.mexa64, and I simply typed testMPI in MATLAB command window. It reported MPI_Init failed
Anyone can help on this?
#include "mex.h"
#include "math.h"
#include "stdio.h"
#include <mpi.h>
void mexFunction(
int nargout,
mxArray *pargout [ ],
int nargin,
const mxArray *pargin [ ]
) {
int comm_sz;
int my_rank;
int q = 0;
MPI_Init(NULL, NULL);
MPI_Comm_size(MPI_COMM_WORLD, &comm_sz);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
printf("Hello from processor %d\n",my_rank);
MPI_Finalize();
printf("Hello, world!\n");
}
2 个评论
Amit P
2019-6-7
I have the same problem with Matlab crashing every second time I run my Mex program.
I took the Crash Dump from the failed job and found the following:
[1] [0] fatal error
[1] Fatal error in MPI_Init: Other MPI error, error stack:
[1] MPI_Init(argc_p=0x0000000000000000, argv_p=0x0000000000000000) failed
[1] Cannot call MPI_INIT or MPI_INIT_THREAD more than once
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!