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