MPI: mpi_assert

De Wiki de Calcul Québec
Aller à : Navigation, rechercher
Cette page est une traduction de la page MPI : mpi assert et la traduction est complétée à 100 % et à jour.

Autres langues :anglais 100% • ‎français 100%

In C/C++, the assert(<expression>) will stop a software if a specific condition is not met. The assert() function then displays, on the standard error, the expression that caused the failure.

With MPI, when one process is stopped, it must send a signal to all other processes so that they stop as well. This is done using MPI_Abort(). The following macro defines the function mpi_assert(), which does the same as assert, but for an MPI parallel program.

#define mpi_assert(expression)  
do { 
  if (!(expression)) { 
     fprintf(stderr, "Failed assertion at %d in %s",__LINE__, __FILE__); 
     MPI_Abort(MPI_COMM_WORLD, 1); 
} while (0)

Using mpi_assert() is the same as using assert():


If the expression is true, the program will keep running normally.

Outils personnels
Espaces de noms

Ressources de Calcul Québec