int main(int argc, char **argv) { int i, nThread = 0; char *tmp; int type = 0; int clients; type = PROCESS; dp.fname = NULL; dp.verbose = 0; int serveur = 1; char *host; host = NULL; clients = 0; for (i = 1; i < argc; i++) { if (!strcmp("-n", argv[i])) { if (!(tmp = nextArg(argc, argv, &i))) usage(); nThread = atoi(tmp); continue; } if (!strcmp("-f", argv[i])) { if (!(dp.fname = nextArg(argc, argv, &i))) usage(); continue; } if (!strcmp("-v", argv[i])) { dp.verbose = TRUE; continue; } if (!strcmp("-c", argv[i])) { if (!(clients = atoi(nextArg(argc, argv, &i)))) usage(); continue; } if (!strcmp("--server", argv[i])) { if (!(host = nextArg(argc, argv, &i))) usage(); serveur = 0; continue; } /* Option inconnue */ printf("Ignoring unknown option: %s\n", argv[i]); } if (serveur) { if (!(dp.fname && nThread)) usage(); if (clients > 0) { configureServeur(clients); setupClients(type, dp.fname, nThread); } } else { configureClient(host); dp.fname = malloc(512); memset(dp.fname, 0, 512); getConfiguration(&type, dp.fname, &nThread); } if (dp.verbose) printf("By process.\n"); load = loadProcess; eType = "process"; terminer = terminerProcess; LISTE_RESULTATS = LISTE_RESULTATS_PROCESS; initialise(nThread); if (serveur) { maitre(); } else { maitreClient(); free(dp.fname); } clean(); return 0; }
int main(int argc,char ** argv){ struct donneesPub dp; int i, nThread=0; char *tmp; int type=0; type=PROCESS; dp.fname=NULL; dp.verbose=0; for(i=1;i<argc;i++){ if(!strcmp("-n",argv[i])){ if(!(tmp=nextArg(argc, argv,&i))) usage(); nThread=atoi(tmp); continue; } if(!strcmp("-f",argv[i])){ if(!(dp.fname=nextArg(argc, argv,&i))) usage(); continue; } if(!strcmp("-T",argv[i])){ type=THREAD; continue; } if(!strcmp("-v",argv[i])){ dp.verbose=TRUE; continue; } /* Option inconnue */ printf("Ignoring unknown option: %s\n", argv[i]); } if(!(dp.fname && nThread)) usage(); if(type==THREAD){ if(dp.verbose) printf("By thread\n"); load=loadThread; terminer=terminerThread; eType="thread"; LISTE_RESULTATS=LISTE_RESULTATS_TREADS; }else{ if(dp.verbose) printf("By process. Use -T to test with multithreading\n"); load=loadProcess; eType="process"; terminer=terminerProcess; LISTE_RESULTATS=LISTE_RESULTATS_PROCESS; } initialise(nThread,&dp); maitre(&dp); return 0; }
int main (int argc, char ** argv) { int rang; MPI_Status statut; int messageIn[TAILLE_ENTETE]; int * message; unsigned int i,j, count; int tailleMessage; complexe_t x; int c; int offset; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD,&rang); MPI_Comm_size(MPI_COMM_WORLD,&nbProc); if (rang == 0) // maitre { //maitre(argc, argv); printf("nbProc = %d\n", nbProc); maitre(argc, argv); //paralNewton(); } else { // esclave while (1) { printf("Je suis no %d\n",rang); MPI_Recv(messageIn, TAILLE_ENTETE, MPI_INT, 0, etiquette, MPI_COMM_WORLD, &statut); // [idProc][xMin][xMax][yMin][yMax][nbDonnees][dimX][dimY][donnees] tailleMessage = (messageIn[2] - messageIn[1]) * (messageIn[4] - messageIn[3]); message = (int *) malloc(sizeof(int)*(TAILLE_ENTETE+tailleMessage)); count =TAILLE_ENTETE; printf("messageIN :"); // entete du message for (i=0; i<TAILLE_ENTETE; i++) { message[i] = messageIn[i]; } message[5] = tailleMessage; dimx = messageIn[6]; dimy = messageIn[7]; printf("maitre : dimx=%d, dimy=%d\n",dimx,dimy); // calculs for (i=messageIn[1]; i<messageIn[2]; i++) { for ( j=messageIn[3]; j<messageIn[4]; j++) { x.re = (double)XMIN + ((double)i*(XMAX-XMIN))/((double)dimx); x.im = (double)YMAX - ((double)j*(YMAX-YMIN))/((double)dimy); // indice de couleur 0, 1 ou 2 c = couleur3(x, 0, 1, 2); /*printf("c = %d - x.re = %lf - x.im = %lf | i=%d & j=%d\n", c, x.re, x.im, i, j);*/ message[count++] = c; } } printf("\n count: %d | taille message %d\n",count, tailleMessage); /* for (i=0; i<(tailleMessage+6); i++) { printf("%d | ",message[i]); } puts(""); */ // 6+tailleMessage -> si suppression, marche // sizeof(int)*(6+tailleMessage) MPI_Send(message, TAILLE_ENTETE+tailleMessage, MPI_INT, 0, etiquette, MPI_COMM_WORLD); puts("FILS: message sent"); free(message); } } MPI_Finalize(); return 0; }