1 |
francois |
1157 |
//####//------------------------------------------------------------ |
2 |
|
|
//####//------------------------------------------------------------ |
3 |
|
|
//####// MAGiC |
4 |
|
|
//####// Jean Christophe Cuilliere et Vincent FRANCOIS |
5 |
|
|
//####// Departement de Genie Mecanique - UQTR |
6 |
|
|
//####//------------------------------------------------------------ |
7 |
|
|
//####// MAGIC est un projet de recherche de l equipe ERICCA |
8 |
|
|
//####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres |
9 |
|
|
//####// http://www.uqtr.ca/ericca |
10 |
|
|
//####// http://www.uqtr.ca/ |
11 |
|
|
//####//------------------------------------------------------------ |
12 |
|
|
//####//------------------------------------------------------------ |
13 |
|
|
//####// |
14 |
|
|
//####// lanceurparra.cpp |
15 |
|
|
//####// |
16 |
|
|
//####//------------------------------------------------------------ |
17 |
|
|
//####//------------------------------------------------------------ |
18 |
|
|
//####// COPYRIGHT 2000-2024 |
19 |
|
|
//####// jeu 13 jun 2024 11:57:20 EDT |
20 |
|
|
//####//------------------------------------------------------------ |
21 |
|
|
//####//------------------------------------------------------------ |
22 |
francois |
1028 |
#include <stdio.h> |
23 |
|
|
#include <stdlib.h> |
24 |
|
|
#include <string> |
25 |
|
|
#include <omp.h> |
26 |
|
|
#include "ot_parametres.h" |
27 |
|
|
int main(int argc,char **argv) { |
28 |
francois |
1045 |
if(argc < 4) |
29 |
|
|
{ |
30 |
francois |
1071 |
printf("***********************************************\n"); |
31 |
francois |
1045 |
printf("parra.exe nom_lanceur nb_cpu nb_echantillon (nom_fichier_parametre pour polycristaux)\n"); |
32 |
francois |
1071 |
printf("***********************************************\n"); |
33 |
francois |
1045 |
return 0; |
34 |
|
|
|
35 |
|
|
} |
36 |
|
|
|
37 |
francois |
1028 |
std::string executable=argv[1]; |
38 |
|
|
int nbcpu=atoi(argv[2]); |
39 |
|
|
int nbechan=atoi(argv[3]); |
40 |
|
|
|
41 |
couturad |
1029 |
|
42 |
|
|
std::string parametre; |
43 |
|
|
if(argc==5) parametre=argv[4]; |
44 |
|
|
|
45 |
|
|
|
46 |
|
|
enum TYPE_MICROSTRUCTURE{POLYCRISTAUX=0, |
47 |
|
|
PARTICULES=1}; |
48 |
|
|
int type_microstructure=TYPE_MICROSTRUCTURE::POLYCRISTAUX; |
49 |
|
|
if(argc<5) |
50 |
|
|
{ |
51 |
|
|
type_microstructure=TYPE_MICROSTRUCTURE::PARTICULES; |
52 |
|
|
executable="../../"+executable; |
53 |
|
|
} |
54 |
|
|
|
55 |
francois |
1028 |
OT_PARAMETRES param; |
56 |
couturad |
1029 |
std::string nomcumul; |
57 |
|
|
std::string nomcumul1; |
58 |
|
|
std::string nomcumul2; |
59 |
francois |
1071 |
std::string nomaster; |
60 |
couturad |
1029 |
if(type_microstructure==TYPE_MICROSTRUCTURE::POLYCRISTAUX) |
61 |
|
|
{ |
62 |
|
|
param.lire((char*)parametre.c_str()); |
63 |
|
|
nomcumul=param.get_nom("fichiercumul"); |
64 |
francois |
1071 |
nomaster=param.get_nom("paramaster"); |
65 |
couturad |
1029 |
nomcumul1 = nomcumul+".txt"; |
66 |
|
|
nomcumul2 = nomcumul+".gnu"; |
67 |
|
|
} |
68 |
francois |
1028 |
|
69 |
|
|
printf("\033[1;4;32;41m***********************************************\033[0m\n"); |
70 |
|
|
printf("\033[1;4;32;41m******* Lanceur parralléle de code ***********\033[0m\n"); |
71 |
|
|
printf("\033[1;4;32;41m***********************************************\033[0m\n"); |
72 |
couturad |
1030 |
fflush(stdout); |
73 |
francois |
1028 |
int nbthreads, tid; |
74 |
|
|
omp_set_num_threads(nbcpu); |
75 |
|
|
#pragma omp parallel private ( tid ) shared ( nbthreads ) |
76 |
|
|
{ |
77 |
|
|
tid = omp_get_thread_num(); |
78 |
|
|
#pragma omp single |
79 |
|
|
nbthreads = omp_get_num_threads(); |
80 |
|
|
char commande[255]; |
81 |
couturad |
1029 |
sprintf(commande,"mkdir -p cpu%d",tid); |
82 |
francois |
1028 |
system(commande); |
83 |
couturad |
1029 |
if(type_microstructure==TYPE_MICROSTRUCTURE::POLYCRISTAUX) |
84 |
|
|
{ |
85 |
francois |
1071 |
sprintf(commande,"cp vasy vasy_par %s %s %s2 ./cpu%d",nomaster.c_str(),parametre.c_str(),parametre.c_str(),tid); |
86 |
francois |
1028 |
system(commande); |
87 |
francois |
1071 |
sprintf(commande,"./cpu%d/%s",tid,parametre.c_str()); |
88 |
|
|
OT_PARAMETRES paramcpu; |
89 |
|
|
paramcpu.lire(commande); |
90 |
|
|
std::string nomcumulcpu=paramcpu.get_nom("fichiercumul"); |
91 |
|
|
nomcumulcpu="../"+nomcumulcpu; |
92 |
|
|
paramcpu.change_valeur("fichiercumul",nomcumulcpu); |
93 |
|
|
paramcpu.enregistrer(commande); |
94 |
couturad |
1029 |
} |
95 |
|
|
|
96 |
francois |
1028 |
//printf("Hello World! I am thread %d/%d\ n", tid, nbthreads); |
97 |
|
|
#pragma omp for schedule(dynamic) |
98 |
|
|
for (int i=0;i<nbechan;i++) |
99 |
|
|
{ |
100 |
couturad |
1029 |
printf("\033[1;4;32;41mCPU numero %d. Calcul numero %d de %d\033[0m\n",tid,i+1,nbechan); |
101 |
couturad |
1030 |
fflush(stdout); |
102 |
couturad |
1029 |
if(type_microstructure==TYPE_MICROSTRUCTURE::POLYCRISTAUX) |
103 |
|
|
{ |
104 |
|
|
sprintf(commande,"cd cpu%d;%s",tid,executable.c_str()); |
105 |
|
|
system(commande); |
106 |
|
|
} |
107 |
|
|
else if(type_microstructure==TYPE_MICROSTRUCTURE::PARTICULES) |
108 |
|
|
{ |
109 |
|
|
sprintf(commande,"mkdir -p cpu%d/e%d; cd cpu%d/e%d;%s",tid,i,tid,i,executable.c_str()); |
110 |
|
|
system(commande); |
111 |
|
|
} |
112 |
|
|
|
113 |
francois |
1028 |
} |
114 |
|
|
} |
115 |
francois |
1071 |
/*if(type_microstructure==TYPE_MICROSTRUCTURE::POLYCRISTAUX) |
116 |
couturad |
1029 |
{ |
117 |
francois |
1028 |
printf("\n\033[1;4;32;41m***** Rassemblement des résultats *************\033[0m\n\n\n"); |
118 |
couturad |
1030 |
fflush(stdout); |
119 |
francois |
1028 |
char commande[2550]; |
120 |
|
|
char commande2[2550]; |
121 |
|
|
sprintf(commande,"tail -n+1 ./cpu0/%s;",nomcumul1.c_str()); |
122 |
|
|
for (int i=1;i<nbthreads;i++) |
123 |
|
|
sprintf(commande,"%stail -n+2 ./cpu%d/%s; ",commande,i,nomcumul1.c_str()); |
124 |
|
|
sprintf(commande2,"(%s)>%s",commande,nomcumul1.c_str()); |
125 |
|
|
system(commande2); |
126 |
|
|
sprintf(commande,"tail -n+1 ./cpu0/%s>%s",nomcumul2.c_str(),nomcumul2.c_str()); |
127 |
|
|
system(commande); |
128 |
francois |
1071 |
}*/ |
129 |
francois |
1028 |
|
130 |
|
|
|
131 |
|
|
printf("\033[1;4;32;41m***********************************************\033[0m\n"); |
132 |
|
|
printf("\033[1;4;32;41m********************* Fin ********************\033[0m\n"); |
133 |
|
|
printf("\033[1;4;32;41m***********************************************\033[0m\n"); |
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
return EXIT_SUCCESS; |
138 |
couturad |
1029 |
} |