[1995] | 1 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
| 2 | // Eric Aubourg
|
---|
| 3 | // Christophe Magneville
|
---|
| 4 | // Reza Ansari
|
---|
[2037] | 5 | // $Id: mesovh2.cc,v 1.4 2002-05-31 08:10:58 ansari Exp $
|
---|
[1995] | 6 | /* mesure de performance de l'architecture
|
---|
| 7 |
|
---|
| 8 | ---------------- Exemple d'appel ---------------------
|
---|
| 9 | csh> mesovh2 -start 104385384 -end 104399964
|
---|
| 10 | -intoi boloMuV_27 -wtoi 8192 -wnoop 4096 inputbolo.fits
|
---|
| 11 | */
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | #include "machdefs.h"
|
---|
| 16 | #include <math.h>
|
---|
| 17 | #include <unistd.h>
|
---|
| 18 | #include "cgt.h"
|
---|
| 19 | #include "fitstoirdr.h"
|
---|
| 20 | #include "toimanager.h"
|
---|
| 21 | #include "nooppr.h"
|
---|
| 22 | #include "timing.h"
|
---|
| 23 | #include <stdexcept>
|
---|
| 24 |
|
---|
| 25 | void Usage(bool fgerr)
|
---|
| 26 | {
|
---|
| 27 | cout << endl;
|
---|
| 28 | if (fgerr) {
|
---|
| 29 | cout << " mesovh2 : Argument Error ! mesovh2 -h for usage " << endl;
|
---|
| 30 | exit(1);
|
---|
| 31 | }
|
---|
| 32 | else {
|
---|
| 33 | cout << "\n Usage : mesovh2 [-dbg] [-start snb] [-end sne] \n"
|
---|
[2037] | 34 | << " [-intoi name] [-wtoi sz] [-wnoop sz] [-delay2] \n"
|
---|
[2033] | 35 | << " [-bipro sz2] [-tripro sz2,sz3] [-quadpro sz2,sz3,sz4] \n"
|
---|
| 36 | << " [-pentapro sz2,sz3,sz4,sz5] [-hexapro sz2,sz3,sz4,sz5,sz6] \n"
|
---|
[1995] | 37 | << " [-intoi2 name] [-prstat] [-useseqbuff] inFitsName \n"
|
---|
| 38 | << " -dbg : sets CGT class debug level to 1 \n"
|
---|
| 39 | << " -dbg2 : sets CGT class debug level to 2 \n"
|
---|
| 40 | << " -start snb : sets the start sample num \n"
|
---|
| 41 | << " -end sne : sets the end sample num \n"
|
---|
| 42 | << " -intoi toiName : select input TOI name (def bolo)\n"
|
---|
| 43 | << " -wtoi sz : sets TOISeqBuff/TOISegmented buffer size (def= 1024)\n"
|
---|
| 44 | << " -wnoop sz : sets NoOpProcessor window size \n"
|
---|
[2037] | 45 | << " -delay2 : Delay NoOpProcessor in2 --> out2 \n"
|
---|
[2033] | 46 | << " -bipro sz2: chain 2 processors sz2= NoOpProcessor 2 window size\n"
|
---|
| 47 | << " -tripro -quadpro -pentapro -hexapro ... chain 3-6 processors \n"
|
---|
[1995] | 48 | << " -intoi2 toiName : chaine 2 procs with toi2->in2\n"
|
---|
| 49 | << " -prstat : PrintStat with ProcSampleCounter \n"
|
---|
[2000] | 50 | << " -useseqbuff : Use TOISeqBuffered TOI's (default: TOISegmented) \n"
|
---|
[1995] | 51 | << endl;
|
---|
| 52 | exit(0);
|
---|
| 53 | }
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | int main(int narg, char** arg) {
|
---|
| 57 |
|
---|
| 58 | if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
|
---|
| 59 |
|
---|
| 60 | cout << "mesovh2 starting - Decoding arguments " << " narg=" << narg << endl;
|
---|
| 61 |
|
---|
| 62 | // --------- Decoding command line parameters
|
---|
[2033] | 63 | int nb_procs = 1;
|
---|
| 64 | int proc_wsz[6] = {0,0,0,0,0,0};
|
---|
[1995] | 65 | bool fgsetstart = false;
|
---|
| 66 | bool fgprstat = false;
|
---|
| 67 | bool fgsegmented = true;
|
---|
| 68 | int dbglev = 0;
|
---|
| 69 | int wtoi = 1024;
|
---|
| 70 | int wnoop = 0;
|
---|
[2037] | 71 | bool fgdelay2 = false;
|
---|
[1995] | 72 | int keepfft = 0;
|
---|
| 73 | int nmax = 10;
|
---|
| 74 | int istart = 0;
|
---|
| 75 | int iend = 0;
|
---|
| 76 | string infile;
|
---|
| 77 | string intoi = "bolo";
|
---|
| 78 | bool fgtoi2 = false;
|
---|
| 79 | string intoi2;
|
---|
| 80 |
|
---|
| 81 | if (narg < 4) Usage(true);
|
---|
| 82 | int ko=1;
|
---|
| 83 | // decoding arguments
|
---|
| 84 | for(int ia=1; ia<narg; ia++) {
|
---|
| 85 | if (strcmp(arg[ia],"-start") == 0) {
|
---|
| 86 | if (ia == narg-1) Usage(true); // -start est suivi d'un argument
|
---|
| 87 | istart = atoi(arg[ia+1]); ia++;
|
---|
| 88 | fgsetstart = true;
|
---|
| 89 | }
|
---|
| 90 | else if (strcmp(arg[ia],"-end") == 0) {
|
---|
| 91 | if (ia == narg-1) Usage(true);
|
---|
| 92 | iend = atoi(arg[ia+1]); ia++;
|
---|
| 93 | }
|
---|
| 94 | else if (strcmp(arg[ia],"-wtoi") == 0) {
|
---|
| 95 | if (ia == narg-1) Usage(true);
|
---|
| 96 | wtoi = atoi(arg[ia+1]); ia++;
|
---|
| 97 | }
|
---|
| 98 | else if (strcmp(arg[ia],"-wnoop") == 0) {
|
---|
| 99 | if (ia == narg-1) Usage(true);
|
---|
| 100 | wnoop = atoi(arg[ia+1]); ia++;
|
---|
| 101 | }
|
---|
[2033] | 102 | else if (strcmp(arg[ia],"-bipro") == 0) {
|
---|
| 103 | if (ia == narg-1) Usage(true);
|
---|
| 104 | nb_procs = 2;
|
---|
| 105 | sscanf(arg[ia+1],"%d",proc_wsz+1); ia++;
|
---|
| 106 | }
|
---|
| 107 | else if (strcmp(arg[ia],"-tripro") == 0) {
|
---|
| 108 | if (ia == narg-1) Usage(true);
|
---|
| 109 | nb_procs = 3;
|
---|
| 110 | sscanf(arg[ia+1],"%d,%d",proc_wsz+1,proc_wsz+2 ); ia++;
|
---|
| 111 | }
|
---|
| 112 | else if (strcmp(arg[ia],"-quadpro") == 0) {
|
---|
| 113 | if (ia == narg-1) Usage(true);
|
---|
| 114 | nb_procs = 4;
|
---|
| 115 | sscanf(arg[ia+1],"%d,%d,%d",proc_wsz+1,proc_wsz+2,proc_wsz+3 ); ia++;
|
---|
| 116 | }
|
---|
| 117 | else if (strcmp(arg[ia],"-pentapro") == 0) {
|
---|
| 118 | if (ia == narg-1) Usage(true);
|
---|
| 119 | nb_procs = 5;
|
---|
| 120 | sscanf(arg[ia+1],"%d,%d,%d,%d",proc_wsz+1,proc_wsz+2,
|
---|
| 121 | proc_wsz+3,proc_wsz+4); ia++;
|
---|
| 122 | }
|
---|
| 123 | else if (strcmp(arg[ia],"-pentapro") == 0) {
|
---|
| 124 | if (ia == narg-1) Usage(true);
|
---|
| 125 | nb_procs = 6;
|
---|
| 126 | sscanf(arg[ia+1],"%d,%d,%d,%d,%d",proc_wsz+1,proc_wsz+2,
|
---|
| 127 | proc_wsz+3,proc_wsz+4,proc_wsz+5 ); ia++;
|
---|
| 128 | }
|
---|
[1995] | 129 | else if (strcmp(arg[ia],"-intoi") == 0) {
|
---|
| 130 | if (ia == narg-1) Usage(true);
|
---|
| 131 | intoi = arg[ia+1]; ia++;
|
---|
| 132 | }
|
---|
| 133 | else if (strcmp(arg[ia],"-intoi2") == 0) {
|
---|
| 134 | if (ia == narg-1) Usage(true);
|
---|
[2033] | 135 | fgtoi2 = true;
|
---|
[1995] | 136 | intoi2 = arg[ia+1]; ia++;
|
---|
| 137 | }
|
---|
[2037] | 138 | else if (strcmp(arg[ia],"-delay2") == 0) fgdelay2 = true;
|
---|
[1995] | 139 | else if (strcmp(arg[ia],"-dbg") == 0) dbglev = 1;
|
---|
| 140 | else if (strcmp(arg[ia],"-dbg2") == 0) dbglev = 2;
|
---|
| 141 | else if (strcmp(arg[ia],"-prstat") == 0) fgprstat = true;
|
---|
| 142 | else if (strcmp(arg[ia],"-useseqbuff") == 0) fgsegmented = false;
|
---|
| 143 |
|
---|
| 144 | else { ko = ia; break; } // Debut des noms
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | if (iend < istart) iend = istart+wtoi*(nmax+5);
|
---|
| 148 | if ((narg-ko) < 1) Usage(true);
|
---|
| 149 | infile = arg[ko];
|
---|
| 150 |
|
---|
| 151 | InitTim();
|
---|
| 152 |
|
---|
| 153 | cout << ">>>> mesovh2: Infile= " << infile << " outFile=" << endl;
|
---|
| 154 | cout << ">>>> Window Size WTOI= " << wtoi << " WNOOP= " << wnoop
|
---|
| 155 | << " iStart= " << istart << " iEnd= " << iend << endl;
|
---|
| 156 | cout << ">>>> InTOIName= " << intoi << endl;
|
---|
| 157 |
|
---|
| 158 | try {
|
---|
| 159 | // --------- Setting up the pipe
|
---|
| 160 | TOIManager* mgr = TOIManager::getManager();
|
---|
| 161 | if (fgsetstart)
|
---|
| 162 | mgr->setRequestedSample(istart, iend);
|
---|
| 163 |
|
---|
| 164 | CGT plombier(fgsegmented, wtoi);
|
---|
| 165 | plombier.SetDebugLevel(dbglev);
|
---|
| 166 |
|
---|
| 167 | FITSTOIReader r(infile);
|
---|
[2033] | 168 | cout << "> FITSTOIReader reader created File=" << infile << endl;
|
---|
| 169 | proc_wsz[0] = wnoop;
|
---|
| 170 | NoOpProcessor noop[6];
|
---|
| 171 | int k;
|
---|
| 172 | for(k=0; k<nb_procs; k++) {
|
---|
| 173 | noop[k].SetWSize(proc_wsz[k]);
|
---|
| 174 | cout << "> NoOpProcessor noop[" << k << "] created WSz=" << proc_wsz[k] << endl;
|
---|
[2037] | 175 | if (fgdelay2) {
|
---|
| 176 | cout << " Setting noop[" << k << "].SetDelay2( true ) " << endl;
|
---|
| 177 | noop[k].SetDelay2( true );
|
---|
| 178 | }
|
---|
[2033] | 179 | }
|
---|
[1995] | 180 |
|
---|
| 181 | cout << "> Connecting to Processors through plombier ... " << endl;
|
---|
| 182 | string inname = "in";
|
---|
[2033] | 183 | plombier.Connect(r, intoi, noop[0], inname);
|
---|
[1995] | 184 |
|
---|
| 185 | if (fgtoi2) {
|
---|
| 186 | int w2 = (wnoop > 0) ? wtoi+wnoop : wtoi;
|
---|
| 187 | inname = "in2";
|
---|
[2033] | 188 | plombier.Connect(r, intoi2, noop[0], inname, "", w2);
|
---|
[1995] | 189 | }
|
---|
[2033] | 190 | for(k=1; k<nb_procs; k++) {
|
---|
| 191 | plombier.Connect(noop[k-1], "out", noop[k], "in");
|
---|
| 192 | if (fgtoi2) plombier.Connect(noop[k-1], "out2", noop[k], "in2");
|
---|
[1995] | 193 | }
|
---|
| 194 |
|
---|
| 195 | cout << "> Plombier status before start" << endl;
|
---|
| 196 | cout << plombier ;
|
---|
| 197 |
|
---|
| 198 | PrtTim("starting processors");
|
---|
| 199 | plombier.Start();
|
---|
| 200 |
|
---|
| 201 | if (fgprstat) {
|
---|
| 202 | // --------------- Impression continu de stat -------------------
|
---|
[2033] | 203 | ProcSampleCounter<NoOpProcessor> stats(noop[0]);
|
---|
[1995] | 204 | stats.InfoMessage() = "mesovh2/Info";
|
---|
| 205 | stats.PrintStats();
|
---|
| 206 | // --------------------------------------------------------------
|
---|
| 207 | }
|
---|
| 208 |
|
---|
[2037] | 209 | plombier.ListTOIs(cout, 1);
|
---|
[1995] | 210 |
|
---|
| 211 | mgr->joinAll();
|
---|
| 212 | PrtTim("End threads");
|
---|
| 213 |
|
---|
[2033] | 214 | cout << noop[0] ;
|
---|
| 215 | if (nb_procs > 1) cout << noop[nb_procs-1] ;
|
---|
[1995] | 216 | }
|
---|
| 217 | catch (PThrowable & exc) {
|
---|
| 218 | cerr << "\n mesovh2: Catched Exception \n" << (string)typeid(exc).name()
|
---|
| 219 | << " - Msg= " << exc.Msg() << endl;
|
---|
| 220 | }
|
---|
| 221 | catch (const std::exception & sex) {
|
---|
| 222 | cerr << "\n mesovh2: Catched std::exception \n"
|
---|
| 223 | << (string)typeid(sex).name() << endl;
|
---|
| 224 | }
|
---|
| 225 | catch (...) {
|
---|
| 226 | cerr << "\n mesovh2: some other exception was caught ! " << endl;
|
---|
| 227 | }
|
---|
| 228 |
|
---|
| 229 | return(0);
|
---|
| 230 | }
|
---|