How to run compiled MPI function

5 vues (au cours des 30 derniers jours)
Yangyang Xu
Yangyang Xu le 2 Fév 2019
Commenté : Richard Hern le 10 Déc 2022
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 commentaires
Amit P
Amit P le 7 Juin 2019
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 le 10 Déc 2022
I ran into the same problem. Has it been solved?@Yangyang Xu@Amit P

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by