How to run compiled MPI function

조회 수: 5 (최근 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