1
1

Remove the French and strip the tests down to essentials (no need for

buffer attaching/detaching, for example).

This commit was SVN r14216.
Этот коммит содержится в:
Jeff Squyres 2007-04-04 15:38:23 +00:00
родитель a8918fe3d5
Коммит 2cbcb4abf1
2 изменённых файлов: 37 добавлений и 88 удалений

Просмотреть файл

@ -1,55 +1,30 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> /* pour sleep() */ #include <unistd.h>
#include <pthread.h> #include <pthread.h>
#include <semaphore.h> #include <semaphore.h>
#include "mpi.h" #include "mpi.h"
int main( int argc, char **argv ) {
/*1)pour communiaction MPI*/ int main( int argc, char **argv )
MPI_Comm lCommunicateur; /*communicateur du process*/ {
MPI_Comm CommParent; /*Communiacteur parent àépér*/ MPI_Comm parent;
int lRank; /*rang du communicateur du process*/ MPI_Comm merged;
int lRangMain; /*rang du séenceur si lancén mode normal*/ int rank;
int lTailleCommunicateur; /*taille du communicateur;*/ int size;
long *lpBufferMpi; /*buffer pour message*/
int lBufferSize; /*taille du buffer*/ MPI_Init(&argc, &argv);
printf("Child: launch\n");
MPI_Comm_get_parent(&parent);
lCommunicateur = (MPI_Comm)-1; MPI_Intercomm_merge(parent, 1, &merged);
int erreur = MPI_Init( &argc, &argv ); MPI_Comm_rank(merged, &rank);
MPI_Comm_size(merged, &size);
if (erreur!=0){ printf("Child merged rank = %d, size = %d\n", rank, size);
printf("erreur\n");
free( lpBufferMpi );
return -1;
}
/*2) Attachement àn buffer pour le message*/
lBufferSize=10000 * sizeof(long);
lpBufferMpi = calloc( 10000, sizeof(long));
erreur = MPI_Buffer_attach( (void*)lpBufferMpi, lBufferSize );
if (erreur!=0){
printf("erreur\n");
free( lpBufferMpi );
return -1;
}
printf( "Exe : Lance \n" );
MPI_Comm_get_parent(&CommParent);
MPI_Intercomm_merge( CommParent, 1, &lCommunicateur );
MPI_Comm_rank( lCommunicateur, &lRank );
MPI_Comm_size( lCommunicateur, &lTailleCommunicateur );
lRangMain =1-lRank;
printf( "Exe: lRankExe = %d lRankMain = %d\n", lRank , lRangMain);
sleep(1); sleep(1);
MPI_Buffer_detach( (void*)lpBufferMpi, &lBufferSize ); MPI_Comm_free(&merged);
MPI_Comm_free( &lCommunicateur ); MPI_Finalize();
MPI_Finalize( ); printf("Child: exiting\n");
free( lpBufferMpi );
printf( "Exe: Fin.\n\n\n" );
return 0; return 0;
} }

Просмотреть файл

@ -10,59 +10,33 @@
#define EXE_TEST "./loop_child" #define EXE_TEST "./loop_child"
int main(int argc, char **argv)
int main( int argc, char **argv ) { {
int iter, err, rank, size;
long *lpBufferMpi; MPI_Comm comm, merged;
MPI_Comm lIntercom;
int lErrcode;
MPI_Comm lCommunicateur;
int lRangMain,lRangExe,lMessageEnvoi,lIter,lTailleBuffer;
int *lpMessageEnvoi=&lMessageEnvoi;
MPI_Status lStatus; /*status de reception*/
lIter=0;
/* MPI environnement */ /* MPI environnement */
printf("main*******************************\n"); printf("parent*******************************\n");
printf("main : Lancement MPI*\n"); printf("parent: Launching MPI*\n");
MPI_Init( &argc, &argv); MPI_Init( &argc, &argv);
lpBufferMpi = calloc( 10000, sizeof(long));
MPI_Buffer_attach( (void*)lpBufferMpi, 10000 * sizeof(long) );
while (lIter<1000){ for (iter = 0; iter < 1000; ++iter) {
lIter ++; MPI_Comm_spawn(EXE_TEST, NULL, 1, MPI_INFO_NULL,
lIntercom=(MPI_Comm)-1 ; 0, MPI_COMM_WORLD, &comm, &err);
printf("parent: MPI_Comm_spawn #%d return : %d\n", iter, err);
MPI_Comm_spawn( EXE_TEST, NULL, 1, MPI_INFO_NULL, MPI_Intercomm_merge(comm, 0, &merged);
0, MPI_COMM_WORLD, &lIntercom, &lErrcode ); MPI_Comm_rank(merged, &rank);
printf( "%i main***MPI_Comm_spawn return : %d\n",lIter, lErrcode ); MPI_Comm_size(merged, &size);
printf("parent: MPI_Comm_spawn #%d rank %d, size %d\n",
if(lIntercom == (MPI_Comm)-1 ){ iter, rank, size);
printf("%i Intercom null\n",lIter);
return 0;
}
MPI_Intercomm_merge(lIntercom, 0,&lCommunicateur );
MPI_Comm_rank( lCommunicateur, &lRangMain);
lRangExe=1-lRangMain;
printf("%i main***Rang main : %i Rang exe : %i \n",lIter,(int)lRangMain,(int)lRangExe);
// sleep(2); // sleep(2);
MPI_Comm_free(&merged);
} }
MPI_Finalize();
/* Arret de l'environnement MPI */ printf("parent: End .\n" );
lTailleBuffer=10000* sizeof(long);
MPI_Buffer_detach( (void*)lpBufferMpi, &lTailleBuffer );
MPI_Comm_free( &lCommunicateur );
MPI_Finalize( );
free( lpBufferMpi );
printf( "Main = End .\n" );
return 0; return 0;
} }