[1738] | 1 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
| 2 | // Eric Aubourg
|
---|
| 3 | // Christophe Magneville
|
---|
| 4 | // Reza Ansari
|
---|
| 5 | // $Id: mesovh.cc,v 1.4 2001-11-08 15:47:45 aubourg Exp $
|
---|
[1487] | 6 | /* mesure de performance de l'architecture
|
---|
| 7 |
|
---|
| 8 | ---------------- Exemple d'appel ---------------------
|
---|
| 9 | csh> mesovh -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 "array.h"
|
---|
| 18 | #include <unistd.h>
|
---|
| 19 | #include <stdexcept>
|
---|
| 20 | #include "toi.h"
|
---|
| 21 | #include "toiprocessor.h"
|
---|
| 22 | #include "fitstoirdr.h"
|
---|
| 23 | #include "fitstoiwtr.h"
|
---|
| 24 | #include "toimanager.h"
|
---|
| 25 | #include "nooppr.h"
|
---|
| 26 | #include "toiseqbuff.h"
|
---|
| 27 | #include "timing.h"
|
---|
| 28 | // #include "sambainit.h"
|
---|
| 29 |
|
---|
| 30 | void Usage(bool fgerr)
|
---|
| 31 | {
|
---|
| 32 | cout << endl;
|
---|
| 33 | if (fgerr) {
|
---|
| 34 | cout << " mesovh : Argument Error ! mesovh -h for usage " << endl;
|
---|
| 35 | exit(1);
|
---|
| 36 | }
|
---|
| 37 | else {
|
---|
| 38 | cout << "\n Usage : mesovh [-dbg] [-start snb] [-end sne] \n"
|
---|
[1488] | 39 | << " [-intoi name] [-wtoi sz] [-wnoop sz] [-bipro] \n"
|
---|
| 40 | << " [-intoi2 name] inFitsName \n"
|
---|
[1487] | 41 | << " -dbg : sets TOISeqBuffered debug level to 1 \n"
|
---|
| 42 | << " -start snb : sets the start sample num \n"
|
---|
| 43 | << " -end sne : sets the end sample num \n"
|
---|
| 44 | << " -intoi toiName : select input TOI name (def boloMuV_27)\n"
|
---|
| 45 | << " -wtoi sz : sets TOISeqBuff buffer size (def= 8192)\n"
|
---|
| 46 | << " -wnoop sz : sets NoOpProcessor window size \n"
|
---|
| 47 | << " -bipro : chain 2 processors \n"
|
---|
[1488] | 48 | << " -intoi2 toiName : chaine 2 procs with toi2->in2\n"
|
---|
[1487] | 49 | << endl;
|
---|
| 50 | exit(0);
|
---|
| 51 | }
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | int main(int narg, char** arg) {
|
---|
| 55 |
|
---|
| 56 | if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
|
---|
| 57 |
|
---|
| 58 | cout << "mesovh starting - Decoding arguments " << " narg=" << narg << endl;
|
---|
| 59 |
|
---|
| 60 | bool fgdbg = false;
|
---|
| 61 | bool fgbipro = false;
|
---|
| 62 | bool fgsetstart = false;
|
---|
| 63 | int wtoi = 8192;
|
---|
| 64 | int wnoop = 0;
|
---|
| 65 | int keepfft = 0;
|
---|
| 66 | int nmax = 10;
|
---|
| 67 | int istart = 0;
|
---|
| 68 | int iend = 0;
|
---|
| 69 | string infile;
|
---|
| 70 | string outfile;
|
---|
| 71 | string outppfname;
|
---|
| 72 | string intoi = "boloMuV_27";
|
---|
[1488] | 73 | bool fgtoi2 = false;
|
---|
| 74 | string intoi2;
|
---|
[1487] | 75 |
|
---|
| 76 | if (narg < 4) Usage(true);
|
---|
| 77 | int ko=1;
|
---|
| 78 | // decoding arguments
|
---|
| 79 | for(int ia=1; ia<narg; ia++) {
|
---|
| 80 | if (strcmp(arg[ia],"-start") == 0) {
|
---|
| 81 | if (ia == narg-1) Usage(true); // -start est suivi d'un argument
|
---|
| 82 | istart = atoi(arg[ia+1]); ia++;
|
---|
| 83 | fgsetstart = true;
|
---|
| 84 | }
|
---|
| 85 | else if (strcmp(arg[ia],"-end") == 0) {
|
---|
| 86 | if (ia == narg-1) Usage(true);
|
---|
| 87 | iend = atoi(arg[ia+1]); ia++;
|
---|
| 88 | }
|
---|
| 89 | else if (strcmp(arg[ia],"-wtoi") == 0) {
|
---|
| 90 | if (ia == narg-1) Usage(true);
|
---|
| 91 | wtoi = atoi(arg[ia+1]); ia++;
|
---|
| 92 | }
|
---|
| 93 | else if (strcmp(arg[ia],"-wnoop") == 0) {
|
---|
| 94 | if (ia == narg-1) Usage(true);
|
---|
| 95 | wnoop = atoi(arg[ia+1]); ia++;
|
---|
| 96 | }
|
---|
| 97 | else if (strcmp(arg[ia],"-intoi") == 0) {
|
---|
| 98 | if (ia == narg-1) Usage(true);
|
---|
| 99 | intoi = arg[ia+1]; ia++;
|
---|
| 100 | }
|
---|
[1488] | 101 | else if (strcmp(arg[ia],"-intoi2") == 0) {
|
---|
| 102 | if (ia == narg-1) Usage(true);
|
---|
| 103 | fgbipro = fgtoi2 = true;
|
---|
| 104 | intoi2 = arg[ia+1]; ia++;
|
---|
| 105 | }
|
---|
[1487] | 106 | else if (strcmp(arg[ia],"-bipro") == 0) fgbipro = true;
|
---|
| 107 | else if (strcmp(arg[ia],"-dbg") == 0) fgdbg = true;
|
---|
| 108 |
|
---|
| 109 | else { ko = ia; break; } // Debut des noms
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | if (iend < istart) iend = istart+wtoi*(nmax+5);
|
---|
| 113 | if ((narg-ko) < 1) Usage(true);
|
---|
| 114 | infile = arg[ko];
|
---|
| 115 | // outfile = arg[ko+1];
|
---|
| 116 | // outppfname = arg[ko+2];
|
---|
| 117 |
|
---|
| 118 | // cout << " Initializing SOPHYA ... " << endl;
|
---|
| 119 | // SophyaInit();
|
---|
| 120 | InitTim();
|
---|
| 121 |
|
---|
| 122 | cout << ">>>> mesovh: Infile= " << infile << " outFile="
|
---|
| 123 | << outfile << endl;
|
---|
| 124 | cout << ">>>> Window Size WTOI= " << wtoi << " WNOOP= " << wnoop
|
---|
| 125 | << " iStart= " << istart << " iEnd= " << iend << endl;
|
---|
| 126 | cout << ">>>> InTOIName= " << intoi << endl;
|
---|
| 127 |
|
---|
| 128 | try {
|
---|
| 129 | TOIManager* mgr = TOIManager::getManager();
|
---|
| 130 |
|
---|
| 131 | // mgr->setRequestedSample(11680920,11710584);
|
---|
| 132 | // mgr->setRequestedSample(104121000, 104946120);
|
---|
| 133 | if (fgsetstart)
|
---|
| 134 | mgr->setRequestedSample(istart, iend);
|
---|
| 135 |
|
---|
| 136 | // FITSTOIReader r("/data/Archeops/bolo11.fits);
|
---|
| 137 | FITSTOIReader r(infile);
|
---|
| 138 | cout << "reader created" << endl;
|
---|
| 139 | // FITSTOIWriter w("/data/Archeops/rz.fits");
|
---|
| 140 | // FITSTOIWriter w(outfile);
|
---|
| 141 | // cout << "fits writer created" << endl;
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 | int w1 = wtoi;
|
---|
| 145 | TOISeqBuffered * toiin = new TOISeqBuffered("f2in", w1);
|
---|
| 146 | if (fgdbg) toiin->setDebugLevel(1);
|
---|
| 147 | // TOISeqBuffered * toiout = new TOISeqBuffered("out", w1);
|
---|
| 148 | // if (fgdbg) toiout->setDebugLevel(1);
|
---|
| 149 | // TOISeqBuffered * toiincopie = new TOISeqBuffered("incopie", w1);
|
---|
| 150 | // if (fgdbg) toiincopie->setDebugLevel(1);
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 | cout << " Connecting to FitsReader ... " << endl;
|
---|
| 154 | r.addOutput(intoi, toiin);
|
---|
| 155 |
|
---|
[1488] | 156 | TOISeqBuffered * toi2 = NULL;
|
---|
| 157 | if (fgtoi2) {
|
---|
| 158 | int w2 = (wnoop > 0) ? w1+wnoop : w1;
|
---|
| 159 | toi2 = new TOISeqBuffered("toi2", w2);
|
---|
| 160 | r.addOutput(intoi2, toi2);
|
---|
| 161 | }
|
---|
| 162 |
|
---|
[1487] | 163 | NoOpProcessor noop(wnoop);
|
---|
| 164 | NoOpProcessor noop2(wnoop);
|
---|
| 165 | cout << " Connecting NoOpProcessor ... " << endl;
|
---|
| 166 | noop.addInput("in",toiin);
|
---|
| 167 |
|
---|
[1488] | 168 | TOISeqBuffered * toi3 = NULL;
|
---|
[1487] | 169 | if (fgbipro) {
|
---|
[1488] | 170 | toi3 = new TOISeqBuffered("toi3", w1);
|
---|
| 171 | noop.addOutput("out", toi3);
|
---|
| 172 | noop2.addInput("in",toi3);
|
---|
| 173 | if (fgtoi2) {
|
---|
| 174 | noop2.addInput("in2",toi2);
|
---|
| 175 | }
|
---|
[1487] | 176 | }
|
---|
| 177 |
|
---|
| 178 | PrtTim("starting threads");
|
---|
| 179 | r.start();
|
---|
| 180 | noop.start();
|
---|
| 181 | if (fgbipro) noop2.start();
|
---|
| 182 | /*
|
---|
| 183 | for(int jj=0; jj<3; jj++) {
|
---|
| 184 | cout << *toiin;
|
---|
| 185 | cout << *toiout;
|
---|
| 186 | cout << *toiincopie;
|
---|
| 187 | sleep(1);
|
---|
| 188 | }
|
---|
| 189 | */
|
---|
| 190 |
|
---|
| 191 |
|
---|
| 192 |
|
---|
| 193 | mgr->joinAll();
|
---|
| 194 | PrtTim("End threads");
|
---|
| 195 |
|
---|
| 196 | // cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
|
---|
| 197 | // r.PrintStatus(cout);
|
---|
| 198 | // cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
|
---|
| 199 | // w.PrintStatus(cout);
|
---|
| 200 |
|
---|
[1488] | 201 | cout << " ------ toiin, toi2 and toi3 Status information ------- " << endl;
|
---|
[1487] | 202 | cout << *toiin;
|
---|
[1488] | 203 | if (toi2) cout << *toi2;
|
---|
| 204 | if (toi3) cout << *toi3;
|
---|
[1487] | 205 | cout << noop ;
|
---|
| 206 | if (fgbipro) cout << noop2 ;
|
---|
| 207 | }
|
---|
| 208 | catch (PThrowable & exc) {
|
---|
| 209 | cerr << "\n mesovh: Catched Exception \n" << (string)typeid(exc).name()
|
---|
| 210 | << " - Msg= " << exc.Msg() << endl;
|
---|
| 211 | }
|
---|
| 212 | catch (const std::exception & sex) {
|
---|
| 213 | cerr << "\n mesovh: Catched std::exception \n"
|
---|
| 214 | << (string)typeid(sex).name() << endl;
|
---|
| 215 | }
|
---|
| 216 | catch (...) {
|
---|
| 217 | cerr << "\n mesovh: some other exception was caught ! " << endl;
|
---|
| 218 | }
|
---|
| 219 |
|
---|
| 220 | return(0);
|
---|
| 221 | }
|
---|