source: Sophya/trunk/ArchTOIPipe/TestPipes/mesovh.cc@ 1710

Last change on this file since 1710 was 1490, checked in by ansari, 24 years ago

correction bug/protection ds TOIProcessor - Reza 6/5/2001

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