Changeset 3726 in Sophya for trunk/AddOn/TAcq/brproc.cc
- Timestamp:
- Dec 29, 2009, 10:46:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AddOn/TAcq/brproc.cc
r3724 r3726 76 76 << " JF2=" << jf2_ << " DJF=" << djf_ << endl; 77 77 78 fgallfibok=NULL; 78 79 fgcktt_=false; 79 80 } … … 105 106 void BRVisibilityCalculator::run() 106 107 { 107 if (nparthr_ > 1) { 108 if (nparthr_ < 2) return BRBaseProcessor::run(); 109 // Execution multithread parallele 110 setRC(1); 111 int rc=0; 112 try { 113 cout << " BRVisibilityCalculator::run() - Starting " << " NFibers=" << memgr_.NbFibres() 114 << " NChan=" << 2*memgr_.NbFibres() << endl; 115 if ((nmean_%memgr_.NbPaquets())!=0) { 116 uint_4 mnmean = (nmean_/memgr_.NbPaquets()+1)*memgr_.NbPaquets(); 117 cout << " BRVisibilityCalculator::run()/Info changing nmean=" << nmean_ << " to multiple of" 118 << " memgr_.NbPaquets() -> " << mnmean << endl; 119 nmean_=mnmean; 120 } 108 121 paralex_.SetParallelTask(*this); 109 122 cout << " BRVisibilityCalculator::run()/Info : starting ParallelExecutor with nThreads=" 110 123 << paralex_.nThreads() << " ... " << endl; 111 124 paralex_.start(); 112 } 113 return BRBaseProcessor::run(); 125 126 fgallfibok = new bool[memgr_.NbPaquets()]; 127 128 size_t paqsz=memgr_.PaqSize(); 129 bool fgrun=true; 130 while (fgrun) { 131 if (stop_) break; 132 if (memgr_.GetRunState() == MemZR_Stopped) break; 133 int mid = memgr_.FindMemZoneId(MemZA_ProcA); 134 Byte* buffg = memgr_.GetMemZone(mid); 135 if (buffg == NULL) { 136 cout << "BRVisibilityCalculator::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl; 137 setRC(7); fgrun=false; 138 break; 139 } 140 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) { 141 fbuff_[fib] = memgr_.GetMemZone(mid,fib); 142 if (fbuff_[fib] == NULL) { // cela ne devrait pas arriver 143 cout << "BRBaseProcessor::run()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl; 144 setRC(9); fgrun=false; 145 break; 146 } 147 } 148 149 if (totnbpaq_%nmean_ == 0) { 150 if (totnbpaq_ > 0) { 151 moyfc_/=nmean_; 152 moytt_/=nmean_; 153 vismtx_.Info()["MeanFC"] = moyfc_; 154 vismtx_.Info()["MeanTT"] = moytt_; 155 vismtx_.Info()["NPAQSUM"] = nmean_; 156 157 // ATTENTION : Matrice visibilites non moyennee 158 char nfile[32]; 159 sprintf(nfile,"vismtx%d.ppf",numfile_); 160 string flnm=outpath_+nfile; 161 POutPersist po(flnm); 162 po << vismtx_; 163 cout << numfile_ << "-BRVisibilityCalculator::run() NPaqProc=" 164 << totnbpaq_ << " -> Visibility Matrix in " << flnm << endl; 165 FillVisibTable(moyfc_, moytt_); 166 numfile_++; 167 } 168 vismtx_ = complex<r_4>((r_4)0.,(r_4)0.); 169 moyfc_=moytt_=0.; 170 } 171 172 for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) { // boucle sur les paquets d'une zone 173 fgallfibok[jp]=fgokallfibers_=true; 174 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) { 175 vpaq_[fib].Set(fbuff_[fib]+jp*paqsz); 176 vfgok_[fib] = vpchk_[fib].Check(vpaq_[fib],curfc_[fib]); 177 if (!vfgok_[fib]) fgallfibok[jp]=fgokallfibers_=false; 178 } 179 if (fgokallfibers_) { 180 if (totprocnpaq_==0) { 181 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) { 182 fcfirst_[fib]=curfc_[fib]; 183 ttfirst_[fib]=vpaq_[fib].TimeTag(); 184 } 185 } 186 totprocnpaq_++; 187 moyfc_ += curfc_[0]; 188 moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]); 189 if (fgcktt_) CheckTimeTag(); 190 totnbpaq_++; 191 } 192 } // Fin de boucle sur les paquets 193 194 // Execution parallele pour calcul des visibilites par bandes de frequence 195 int rcpex=paralex_.execute(); 196 if (rcpex!=0) cout << " BRVisibilityCalculator::run() / Error Rc[paralex_.execute()]=" << rcpex << endl; 197 198 memgr_.FreeMemZone(mid, MemZS_ProcA); 199 } // Fin de boucle sur les zones a traiter 200 //------------------------------------ 201 cout << " --------- END BRVisibilityCalculator::run() , TotNbProcPaq=" << totprocnpaq_ << endl; 202 /* 203 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) vpchk_[fib].Print(); 204 cout << " ------------------------------------ " << endl; 205 */ 206 delete[] fgallfibok; 207 } 208 catch (std::exception& exc) { 209 cout << " BRBaseProcessor::run()/catched std::exception " << exc.what() << endl; 210 setRC(98); 211 return; 212 } 213 catch(...) { 214 cout << " BRBaseProcessor::run()/catched unknown ... exception " << endl; 215 setRC(99); 216 return; 217 } 218 114 219 } 115 220 … … 165 270 } 166 271 167 if (nparthr_ > 1) { // Execution parallele 168 int rcpex=paralex_.execute(); 169 if (rcpex!=0) cout << " BRVisibilityCalculator::Process() / Error Rc[paralex_.execute()]=" << rcpex << endl; 170 } 171 else { 172 sa_size_t k=0; 173 for(size_t i=0; i<vpdata_.size(); i++) { 174 for(size_t j=i; j<vpdata_.size(); j++) { 175 TVector< complex<r_4> > vis = vismtx_.Row(k); k++; 176 for(sa_size_t f=1; f<vis.Size(); f++) { 177 vis(f) += complex<r_4>((r_4)vpdata_[i][f].realB(), (r_4)vpdata_[i][f].imagB()) * 178 complex<r_4>((r_4)vpdata_[j][f].realB(), -(r_4)vpdata_[j][f].imagB()); 179 } 180 } 181 } 182 } 272 sa_size_t k=0; 273 for(size_t i=0; i<vpdata_.size(); i++) { 274 for(size_t j=i; j<vpdata_.size(); j++) { 275 TVector< complex<r_4> > vis = vismtx_.Row(k); k++; 276 for(sa_size_t f=1; f<vis.Size(); f++) { 277 vis(f) += complex<r_4>((r_4)vpdata_[i][f].realB(), (r_4)vpdata_[i][f].imagB()) * 278 complex<r_4>((r_4)vpdata_[j][f].realB(), -(r_4)vpdata_[j][f].imagB()); 279 } 280 } 281 } 282 183 283 moyfc_ += curfc_[0]; 184 284 moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]); … … 191 291 int BRVisibilityCalculator::execute(int tid) 192 292 { 293 vector<TwoByteComplex*> pvpdata(2*memgr_.NbFibres()); 294 size_t paqsz=memgr_.PaqSize(); 295 BRPaquet ppaq(paqsz); 296 193 297 sa_size_t fdelt = vismtx_.NCols()/nparthr_; 194 298 sa_size_t fdeb = tid*fdelt; 195 299 sa_size_t ffin = (tid+1)*fdelt; 300 196 301 if (fdeb<1) fdeb=1; 197 302 if ((ffin>vismtx_.NCols())||(tid==(nparthr_-1))) ffin=vismtx_.NCols(); 303 304 for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) { // boucle sur les paquets d'une zone 305 if (!fgallfibok[jp]) continue; 306 for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) { 307 ppaq.Set(fbuff_[fib]+jp*paqsz); 308 pvpdata[2*fib] = ppaq.Data1C(); 309 pvpdata[2*fib+1] = ppaq.Data2C(); 310 } 311 sa_size_t k=0; 312 for(size_t i=0; i<vpdata_.size(); i++) { 313 for(size_t j=i; j<vpdata_.size(); j++) { 314 TVector< complex<r_4> > vis = vismtx_.Row(k); k++; 315 for(sa_size_t f=fdeb; f<ffin; f++) { 316 vis(f) += complex<r_4>((r_4)pvpdata[i][f].realB(), (r_4)pvpdata[i][f].imagB()) * 317 complex<r_4>((r_4)pvpdata[j][f].realB(), -(r_4)pvpdata[j][f].imagB()); 318 } 319 } 320 } 321 322 } // Fin de boucle sur les paquets 198 323 199 sa_size_t k=0;200 for(size_t i=0; i<vpdata_.size(); i++) {201 for(size_t j=i; j<vpdata_.size(); j++) {202 TVector< complex<r_4> > vis = vismtx_.Row(k); k++;203 for(sa_size_t f=fdeb; f<ffin; f++) {204 vis(f) += complex<r_4>((r_4)vpdata_[i][f].realB(), (r_4)vpdata_[i][f].imagB()) *205 complex<r_4>((r_4)vpdata_[j][f].realB(), -(r_4)vpdata_[j][f].imagB());206 }207 }208 }209 324 return 0; 210 325 }
Note:
See TracChangeset
for help on using the changeset viewer.