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

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

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