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

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

Ajout NoOpProcessor (processeur qui ne fait rien) pour mesure perfo systeme - Reza 6/5/2001

File size: 5.6 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 << " [-wtoi sz] [-wnoop sz] [-bipro] inFitsName \n"
35 << " -dbg : sets TOISeqBuffered debug level to 1 \n"
36 << " -start snb : sets the start sample num \n"
37 << " -end sne : sets the end sample num \n"
38 << " -intoi toiName : select input TOI name (def boloMuV_27)\n"
39 << " -wtoi sz : sets TOISeqBuff buffer size (def= 8192)\n"
40 << " -wnoop sz : sets NoOpProcessor window size \n"
41 << " -bipro : chain 2 processors \n"
42 << endl;
43 exit(0);
44 }
45}
46
47int main(int narg, char** arg) {
48
49 if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
50
51 cout << "mesovh starting - Decoding arguments " << " narg=" << narg << endl;
52
53 bool fgdbg = false;
54 bool fgbipro = false;
55 bool fgsetstart = false;
56 int wtoi = 8192;
57 int wnoop = 0;
58 int keepfft = 0;
59 int nmax = 10;
60 int istart = 0;
61 int iend = 0;
62 string infile;
63 string outfile;
64 string outppfname;
65 string intoi = "boloMuV_27";
66
67 if (narg < 4) Usage(true);
68 int ko=1;
69 // decoding arguments
70 for(int ia=1; ia<narg; ia++) {
71 if (strcmp(arg[ia],"-start") == 0) {
72 if (ia == narg-1) Usage(true); // -start est suivi d'un argument
73 istart = atoi(arg[ia+1]); ia++;
74 fgsetstart = true;
75 }
76 else if (strcmp(arg[ia],"-end") == 0) {
77 if (ia == narg-1) Usage(true);
78 iend = atoi(arg[ia+1]); ia++;
79 }
80 else if (strcmp(arg[ia],"-wtoi") == 0) {
81 if (ia == narg-1) Usage(true);
82 wtoi = atoi(arg[ia+1]); ia++;
83 }
84 else if (strcmp(arg[ia],"-wnoop") == 0) {
85 if (ia == narg-1) Usage(true);
86 wnoop = atoi(arg[ia+1]); ia++;
87 }
88 else if (strcmp(arg[ia],"-keepfft") == 0) {
89 if (ia == narg-1) Usage(true);
90 keepfft = 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],"-bipro") == 0) fgbipro = true;
97 else if (strcmp(arg[ia],"-dbg") == 0) fgdbg = true;
98
99 else { ko = ia; break; } // Debut des noms
100 }
101
102 if (iend < istart) iend = istart+wtoi*(nmax+5);
103 if ((narg-ko) < 1) Usage(true);
104 infile = arg[ko];
105 // outfile = arg[ko+1];
106 // outppfname = arg[ko+2];
107
108 // cout << " Initializing SOPHYA ... " << endl;
109 // SophyaInit();
110 InitTim();
111
112 cout << ">>>> mesovh: Infile= " << infile << " outFile="
113 << outfile << endl;
114 cout << ">>>> Window Size WTOI= " << wtoi << " WNOOP= " << wnoop
115 << " iStart= " << istart << " iEnd= " << iend << endl;
116 cout << ">>>> InTOIName= " << intoi << endl;
117
118 try {
119 TOIManager* mgr = TOIManager::getManager();
120
121 // mgr->setRequestedSample(11680920,11710584);
122 // mgr->setRequestedSample(104121000, 104946120);
123 if (fgsetstart)
124 mgr->setRequestedSample(istart, iend);
125
126 // FITSTOIReader r("/data/Archeops/bolo11.fits);
127 FITSTOIReader r(infile);
128 cout << "reader created" << endl;
129 // FITSTOIWriter w("/data/Archeops/rz.fits");
130 // FITSTOIWriter w(outfile);
131 // cout << "fits writer created" << endl;
132
133
134 int w1 = wtoi;
135 TOISeqBuffered * toiin = new TOISeqBuffered("f2in", w1);
136 if (fgdbg) toiin->setDebugLevel(1);
137 // TOISeqBuffered * toiout = new TOISeqBuffered("out", w1);
138 // if (fgdbg) toiout->setDebugLevel(1);
139 // TOISeqBuffered * toiincopie = new TOISeqBuffered("incopie", w1);
140 // if (fgdbg) toiincopie->setDebugLevel(1);
141
142
143 cout << " Connecting to FitsReader ... " << endl;
144 r.addOutput(intoi, toiin);
145
146 NoOpProcessor noop(wnoop);
147 NoOpProcessor noop2(wnoop);
148 cout << " Connecting NoOpProcessor ... " << endl;
149 noop.addInput("in",toiin);
150
151 TOISeqBuffered * toi2 = NULL;
152 if (fgbipro) {
153 toi2 = new TOISeqBuffered("toi2", w1);
154 noop.addOutput("out", toi2);
155 noop2.addInput("in",toi2);
156 }
157
158 PrtTim("starting threads");
159 r.start();
160 noop.start();
161 if (fgbipro) noop2.start();
162 /*
163 for(int jj=0; jj<3; jj++) {
164 cout << *toiin;
165 cout << *toiout;
166 cout << *toiincopie;
167 sleep(1);
168 }
169 */
170
171
172
173 mgr->joinAll();
174 PrtTim("End threads");
175
176 // cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
177 // r.PrintStatus(cout);
178 // cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
179 // w.PrintStatus(cout);
180
181 cout << " ------ toiin, toiout and toiincopie Status information ------- " << endl;
182 cout << *toiin;
183 if (fgbipro) cout << *toi2;
184 cout << noop ;
185 if (fgbipro) cout << noop2 ;
186 }
187 catch (PThrowable & exc) {
188 cerr << "\n mesovh: Catched Exception \n" << (string)typeid(exc).name()
189 << " - Msg= " << exc.Msg() << endl;
190 }
191 catch (const std::exception & sex) {
192 cerr << "\n mesovh: Catched std::exception \n"
193 << (string)typeid(sex).name() << endl;
194 }
195 catch (...) {
196 cerr << "\n mesovh: some other exception was caught ! " << endl;
197 }
198
199 return(0);
200}
Note: See TracBrowser for help on using the repository browser.