Jump to content
View in the app

A better way to browse. Learn more.

Next

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

débutant avec mpi

Featured Replies

Bonjour,

En fait je suis débutant en mpi et je l'ai installé sous machine ubuntu 8.10.

Commandes utuilisés : apt-get install mpich-bin mpich-mpd-bin mpich-shmem-bin mpi-doc et

apt-get install libmpich-mpd1.0-dev libmpich-shmem1.0-dev libmpich1.0-dev

Maintenant j'ai essayé de compiler et d'exécuter le simple programme de HelloWorld mais ça marche pas :

Lorsque je fait "mpicc -o hello hello.c" pour compiler ça me donne

helloC.c: In function ‘main’:

helloC.c:12: error: expected declaration specifiers or ‘...’ before ‘&’ token

helloC.c:12: error: expected declaration specifiers or ‘...’ before ‘&’ token

Je ne sais pas où est le pb.

mon code est:

/* C Example */
#include <stdio.h>
#include <mpi.h>


int main (argc, argv)
 int argc;
 char *argv[];
{
 int rank, size, 

 MPI_Init (&argc, &argv);	/* starts MPI */
 //MPI_Comm_rank (MPI_COMM_WORLD, &rank);	/* get current process id */
 //MPI_Comm_size (MPI_COMM_WORLD, &size);	/* get number of processes */
 printf( "Hello world from process"); //%d of %d\n", rank, size );
 MPI_Finalize();
 return 0;
}

Merci de m'aider.

Ca fait des années que je n'ai pas fait de C, mais à vue de nez, ta déclaration de la méthode main est incorrecte. Elle devrait plutôt ressembler à :

int main( int argc, const char* argv[] )
{ 
... 
}

  • Author

Merci pour vos réponses.

EN fait, j'ai fait des modifs et le code devient

/* C Example */
#include <stdio.h>
#include <mpi.h>


int main (int argc,const char* argv)
 //int argc;
 //char *argv[];
{
 //int rank, size;

 MPI_Init (&argc, &argv);	/* starts MPI */
 //MPI_Comm_rank (MPI_COMM_WORLD, &rank);	/* get current process id */
 //MPI_Comm_size (MPI_COMM_WORLD, &size);	/* get number of processes */
 printf( "Hello world from process"); //%d of %d\n", rank, size );
 MPI_Finalize();
 return 0;
}

La compilation donne

"helloC.c: In function ‘main’:

helloC.c:12: warning: passing argument 2 of ‘MPI_Init’ from incompatible pointer type"

Merci encore pour votre aide.

  • Author

voila j'ai reussi à trouver un code qu'est bien compilé.

#include <stdio.h>
#include <mpi.h>

int main(int argc, char ** argv) {

 MPI_Init(&argc, &argv);
 // note that argc and argv are passed by address

 printf("Hello MPI!\n");

 MPI_Finalize(); 
}

Maintenant lors de l'exécution de ce code j'ai reçu ce message d'erreur :

0 - MPI_INIT : MPIRUN chose the wrong device ch_p4; program needs device ch_p4mpd

Segmentation fault

Je ne comprend pas la source de cette erreur.

Je travaille sur ma machine core duo en fait et j'exécute avec la simple commande "mpirun ./hello".

Merci encore.

Ca fait deux ans que je n'ai pas utilisé MPI, mais il ne fallait pas plus d'arguments pour lancer l'executable? Ou une configuration a faire pour MPI quelque part? Le mieux serait de demander à celui qui t'a fourni ce bout de code

bonour,

quelqu modif a faire :

#include <stdio.h>
#include <mpi.h>

int main(int argc, char ** argv) {

 MPI_Init(&argc, &argv);
 // note that argc and argv are passed by address
/* les commentaires en C sont entre /* et */ a moins que tu soit en C99 mais il y a tres peut de compilo c99 */

 printf("Hello MPI!\n");

 MPI_Finalize(); 
/* on retourne une valeur en fin de main */
	return EXIT_SUCCESS;
}

pour la premiere syntaxe de main, ca marche c'est le style Kerniggan&Ritchie (K&R) bon c'est un peu obsolète m'enfin...

Pour le seg fault, si tu dois passer les arguments du main c'est que la fonction d init de MPI a besoin de paramètres pour s'initialiser proprement, donc de loin je dirais que soit tu ne passes pas de parametres, soit des mauvais.

La ce sont ceux que tu passe a ton propre programme qui sont envoyés, il doit falloir que tu appelles ton programme avec les bons arguments.

Archived

This topic is now archived and is closed to further replies.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.