#include #include #include #include #include #include #include #include "pvm3.h" #define GRPNAME "gauss" #define DEBUG 0 void matrix_load ( char nom[], double *tab, int me, int N, int NPROC, int tids[]) { FILE *f; int i,j,idx,idxt = 0,dest,src,msgtag = me; const int NBLIGNES = N/NPROC; double * buffer; if ( (buffer = malloc(N*sizeof(double))) == NULL ) { fprintf(stderr,"Cant malloc %d bytes\n", N*sizeof(double)); exit (-1); } if (me == 0){ if ((f = fopen (nom, "r")) == NULL) perror ("matrix_load : fopen "); for (i=0; i(k%NPROC))?0:1); for(i=decalage;i<(N/NPROC);i++) { if ( fabs(buffer[k]) <= 1.0e-11 ) { printf ("ATTENTION: pivot %d presque nul: %g\n", k, buffer[k] ); exit (-1); } pivot = (*(tab + i * N + k)/buffer[k]); for(j=k;j \n", argv[0]); exit (-1); } N = atoi ( argv[1] ); strcpy(nom, argv[2]); if ( (tab=malloc(N*N/NPROC*sizeof(double))) == NULL ) { printf ("Cant malloc %d bytes\n", N*N*sizeof(double)); exit (-1); } if (me == 0) { strcpy(nomf, "pvm3/result"); sprintf ( nomf+strlen(nomf), "%d", N ); sprintf ( nomf+strlen(nomf), ".txt" ); if((f = fopen (nomf, "a")) == NULL) perror ("matrix_save : fopen "); } gettimeofday( &tv1, (struct timezone*)0 ); if(DEBUG) printf("Before load: me %d\n",me); matrix_load ( nom, tab, me, N, NPROC, tids); if(DEBUG) printf("After load: me %d\n",me); gettimeofday( &tv2, (struct timezone*)0 ); duree = (tv2.tv_sec - tv1.tv_sec) * 1000000.0 + tv2.tv_usec - tv1.tv_usec; //if(me == 0) fprintf (f, "nproc %d\tloading time: %10.8f msec.\n", NPROC, duree/1000.0 ); gettimeofday( &tv1, (struct timezone*)0 ); gauss ( me, tab, N, NPROC, tids); gettimeofday( &tv2, (struct timezone*)0 ); duree = (tv2.tv_sec - tv1.tv_sec) * 1000000 + tv2.tv_usec - tv1.tv_usec; if (me == 0) { fprintf (f, "nproc %d\tcommuting time: %10.8f msec.\n", NPROC, duree/1000.0 ); fclose(f); } sprintf ( nom+strlen(nom), ".result" ); gettimeofday( &tv1, (struct timezone*)0 ); if(DEBUG) printf("Before save: me %d\n",me); matrix_save ( nom, tab, me, N, NPROC, tids); if(DEBUG) printf("After save: me %d\n",me); gettimeofday( &tv2, (struct timezone*)0 ); }