How to run compiled MPI function

6 次查看(过去 30 天)
Yangyang Xu
Yangyang Xu 2019-2-2
评论: Richard Hern 2022-12-10
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
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
Richard Hern
Richard Hern 2022-12-10
I ran into the same problem. Has it been solved?@Yangyang Xu@Amit P

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by