[3872] | 1 | //----------------------------------------------------------------
|
---|
| 2 | // Projet BAORadio - (C) LAL/IRFU 2008-2010
|
---|
| 3 | // Classes de threads de calcul de visibilites pour BAORadio
|
---|
| 4 | //----------------------------------------------------------------
|
---|
| 5 |
|
---|
| 6 | #include <stdlib.h>
|
---|
| 7 | #include <string.h>
|
---|
| 8 | #include <unistd.h>
|
---|
| 9 | #include <fstream>
|
---|
| 10 | #include <signal.h>
|
---|
| 11 |
|
---|
| 12 | #include "pexceptions.h"
|
---|
| 13 | #include "fioarr.h"
|
---|
[3956] | 14 | #include "fitsarrhand.h"
|
---|
[3872] | 15 | #include "matharr.h"
|
---|
[3956] | 16 | #include "arrctcast.h"
|
---|
[3872] | 17 | #include "timestamp.h"
|
---|
| 18 | #include "ctimer.h"
|
---|
| 19 |
|
---|
| 20 | #include "brviscalc.h"
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | //---------------------------------------------------------------------
|
---|
| 24 | // Classe de traitement - calcul de visibilite pour n fibres
|
---|
| 25 | //---------------------------------------------------------------------
|
---|
| 26 |
|
---|
| 27 | /* --Methode-- */
|
---|
| 28 | BRVisibilityCalculator::BRVisibilityCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean, size_t nthr)
|
---|
| 29 | : BRBaseProcessor(memgr), paralex_(*this, nthr), nparthr_(nthr),
|
---|
[3956] | 30 | outpath_(outpath), nmean_(nmean), nbcalc_(1), calcid_(0),
|
---|
| 31 | vpdata_(2*memgr.NbFibres()), vpdatar_(2*memgr.NbFibres())
|
---|
[3872] | 32 | // , dtfos_(outpath+"visdt.fits", Fits_Create), visdt_(dtfos_, 1024, true);
|
---|
| 33 | {
|
---|
[3956] | 34 | SetFFTData();
|
---|
[3872] | 35 | DefineRank(1,0);
|
---|
[3956] | 36 | SetPPFOutput();
|
---|
[3872] | 37 |
|
---|
| 38 | uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
|
---|
[3909] | 39 | chanids_.SetSize(2*memgr_.NbFibres());
|
---|
| 40 | chanpairnumall_.SetSize(maxnpairs);
|
---|
| 41 | chanpairsall_.SetSize(maxnpairs,2);
|
---|
[3956] | 42 | for(size_t i=0; i<2*memgr_.NbFibres(); i++) {
|
---|
| 43 | vpdata_[i]=NULL; vpdatar_[i]=NULL;
|
---|
| 44 | }
|
---|
[3957] | 45 | // Pas necessaire - appele par DefineRank- SelectPairs();
|
---|
[3872] | 46 |
|
---|
| 47 | // visdt_.AddFloatColumn("mfc");
|
---|
| 48 | visdt_.AddDoubleColumn("mfc");
|
---|
| 49 | visdt_.AddDoubleColumn("mtt");
|
---|
| 50 | visdt_.AddIntegerColumn("jfreq");
|
---|
| 51 | visdt_.AddIntegerColumn("numch");
|
---|
| 52 | visdt_.AddFloatColumn("vre");
|
---|
| 53 | visdt_.AddFloatColumn("vim");
|
---|
[3920] | 54 | ActivateVisDTable();
|
---|
[3872] | 55 |
|
---|
| 56 | if (nmean_ < 1) nmean_=memgr_.NbPaquets();
|
---|
| 57 | if (nmean_ < 1) nmean_=1;
|
---|
| 58 |
|
---|
| 59 | cout << " BRVisibilityCalculator::/Info nmean=" << nmean_ << endl;
|
---|
| 60 |
|
---|
| 61 | totnbpaq_=0;
|
---|
| 62 | numfile_=0;
|
---|
| 63 | nb_flop_=0.;
|
---|
| 64 | moyfc_=moytt_=0.;
|
---|
| 65 |
|
---|
| 66 | fgallfibok=NULL;
|
---|
| 67 | fgcktt_=false;
|
---|
| 68 | setNameId("viscalc", 0);
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | /* --Methode-- */
|
---|
| 72 | BRVisibilityCalculator::~BRVisibilityCalculator()
|
---|
| 73 | {
|
---|
[3876] | 74 | if (totnbpaq_<1) return;
|
---|
[3920] | 75 | if (fgvisdt_) {
|
---|
| 76 | cout << " ~BRVisibilityCalculator - Visibility Datatable : " << endl;
|
---|
| 77 | cout << visdt_;
|
---|
[3876] | 78 |
|
---|
[3920] | 79 | string filename;
|
---|
| 80 | filename = outpath_+"visdt.ppf";
|
---|
| 81 | if (nbcalc_>1) {
|
---|
| 82 | char sbuff[32];
|
---|
| 83 | sprintf(sbuff,"visdt_%d.ppf",(int)calcid_);
|
---|
| 84 | filename = outpath_+sbuff;
|
---|
| 85 | }
|
---|
| 86 | POutPersist po(filename);
|
---|
| 87 | po << visdt_;
|
---|
[3872] | 88 | }
|
---|
[3920] | 89 | if (calcid_ == 0) {
|
---|
[3872] | 90 | if (fgcktt_) {
|
---|
| 91 | cout << " BRVisibilityCalculator - Check TimeTag done: TotNPaqProc= " << totnbpaq_ << endl;
|
---|
| 92 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
| 93 | cout << " BRTTCheck-Fiber[" << fib << "] NBadTT=" << vbadtt_[fib] << " NDiffTT>5="
|
---|
| 94 | << vndiff5tt_[fib] << " NotSameTT=" << vnsamett_[fib] << endl;
|
---|
| 95 | }
|
---|
| 96 | POutPersist pott(outpath_+"ttfcmtx.ppf");
|
---|
| 97 | pott << PPFNameTag("FC") << fcmtx_;
|
---|
| 98 | pott << PPFNameTag("TT") << ttmtx_;
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | /* --Methode-- */
|
---|
[3915] | 104 | void BRVisibilityCalculator::DefineRank(uint_4 nbc, uint_4 cid, uint_4 pair1, uint_4 nbpairs, bool fgpimp)
|
---|
[3872] | 105 | {
|
---|
| 106 | if ((nbc>6)||(cid>=nbc))
|
---|
| 107 | throw ParmError("BRVisibilityCalculator::DefineRank() NbCalc > 6 !");
|
---|
[3915] | 108 | uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
|
---|
| 109 | if ((pair1>=maxnpairs)||(nbpairs<1))
|
---|
| 110 | throw ParmError("BRVisibilityCalculator::DefineRank() (pair1>=maxnpairs)||(nbpairs<1) !");
|
---|
| 111 | maxnpairs-=pair1;
|
---|
| 112 | if (maxnpairs>nbpairs) maxnpairs=nbpairs;
|
---|
| 113 |
|
---|
[3872] | 114 | nbcalc_=nbc;
|
---|
| 115 | calcid_=cid;
|
---|
| 116 | if (nbcalc_>1) {
|
---|
[3915] | 117 | uint_4 npairspth=maxnpairs/nbcalc_; // nb de paires par thread
|
---|
[3872] | 118 | if (calcid_==(nbcalc_-1))
|
---|
[3915] | 119 | SelectPairs(calcid_*npairspth+pair1, maxnpairs-calcid_*npairspth, fgpimp);
|
---|
[3872] | 120 | else
|
---|
[3915] | 121 | SelectPairs(calcid_*npairspth+pair1, npairspth, fgpimp);
|
---|
[3956] | 122 | MemZaction mmzas[10]={MemZA_ProcA,MemZA_ProcB,MemZA_ProcC,MemZA_ProcD,MemZA_ProcE,MemZA_ProcF,
|
---|
| 123 | MemZA_ProcG,MemZA_ProcH,MemZA_ProcI,MemZA_ProcJ};
|
---|
[3872] | 124 | SetMemZAction(mmzas[calcid_]);
|
---|
| 125 | setNameId("viscalc_grp", calcid_);
|
---|
| 126 | }
|
---|
[3915] | 127 | else SelectPairs(pair1,maxnpairs, fgpimp);
|
---|
[3872] | 128 | return ;
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | /* --Methode-- */
|
---|
[3915] | 132 | uint_4 BRVisibilityCalculator::SelectPairs(uint_4 pair1, uint_4 nbpairs, bool fgpimp)
|
---|
[3872] | 133 | {
|
---|
| 134 | BRPaquet paq(memgr_.PaqSize());
|
---|
| 135 | uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
|
---|
| 136 |
|
---|
| 137 | if (pair1 >= maxnpairs) pair1=maxnpairs-1;
|
---|
| 138 | if (nbpairs > maxnpairs-pair1) nbpairs=maxnpairs-pair1;
|
---|
[3915] | 139 |
|
---|
[3872] | 140 | pairst_=pair1;
|
---|
| 141 | nbpairs_=nbpairs;
|
---|
[3915] | 142 | fgpimp_=fgpimp;
|
---|
[3909] | 143 |
|
---|
[3915] | 144 | uint_4 nbvisicomp=0;
|
---|
| 145 | sa_size_t kpair=0;
|
---|
| 146 | for(size_t i=0; i<vpdata_.size(); i++) {
|
---|
| 147 | for(size_t j=i; j<vpdata_.size(); j++) {
|
---|
| 148 | kpair++;
|
---|
| 149 | if (kpair<(pairst_+1)) continue;
|
---|
| 150 | if (kpair>=(pairst_+nbpairs_+1)) break;
|
---|
| 151 | if (fgpimp_&&(i!=j)&&((i+j)%2==0)) continue; // calcul des visib avec numero pair-impair + autocorrel
|
---|
| 152 | nbvisicomp++;
|
---|
| 153 | }
|
---|
| 154 | }
|
---|
[3909] | 155 |
|
---|
[3915] | 156 | vismtx_.SetSize(nbvisicomp, paq.DataSize()/4);
|
---|
| 157 |
|
---|
| 158 | chanpairnum_.SetSize(nbvisicomp);
|
---|
| 159 | chanpairs_.SetSize(nbvisicomp,2);
|
---|
| 160 |
|
---|
| 161 | return nbvisicomp;
|
---|
[3872] | 162 | }
|
---|
| 163 |
|
---|
| 164 | /* --Methode-- */
|
---|
| 165 | int BRVisibilityCalculator::SelectFreqBinning(uint_4 freq1, uint_4 freq2, uint_4 nbfreq)
|
---|
| 166 | {
|
---|
| 167 | jf1_=freq1; jf2_=freq2;
|
---|
| 168 | if ((jf1_<1)||(jf1_>=vismtx_.NCols())) jf1_=1;
|
---|
| 169 | if ((jf2_<1)||(jf2_>=vismtx_.NCols())||(jf2_<jf1_)) jf2_=vismtx_.NCols()-1;
|
---|
[3876] | 170 | if (nbfreq<1) nbfreq=(jf2_-jf1_);
|
---|
[3872] | 171 | djf_=(jf2_-jf1_)/nbfreq;
|
---|
[3876] | 172 | if (djf_<1) djf_=1;
|
---|
[3872] | 173 | cout << " BRVisibilityCalculator::SelectFreqBinning/Info JF1=" << jf1_
|
---|
| 174 | << " JF2=" << jf2_ << " DJF=" << djf_ << endl;
|
---|
| 175 |
|
---|
| 176 | }
|
---|
| 177 |
|
---|
[3909] | 178 | /* --Methode-- */
|
---|
| 179 | void BRVisibilityCalculator::UpdateChanIds()
|
---|
| 180 | {
|
---|
[3872] | 181 |
|
---|
[3909] | 182 | for(size_t i=0; i<memgr_.NbFibres(); i++) {
|
---|
| 183 | chanids_(2*i)=memgr_.FiberId(i)*2-1;
|
---|
| 184 | chanids_(2*i+1)=memgr_.FiberId(i)*2;
|
---|
| 185 | }
|
---|
| 186 | sa_size_t k=0; // numero de ligne dans la matrice des visibilites
|
---|
| 187 | for(size_t i=0; i<vpdata_.size(); i++) {
|
---|
| 188 | for(size_t j=i; j<vpdata_.size(); j++) {
|
---|
| 189 | chanpairnumall_(k)=chanids_(i)*CHANPAIRCONVFAC+chanids_(j);
|
---|
| 190 | chanpairsall_(k,0)=chanids_(i); chanpairsall_(k,1)=chanids_(j); k++;
|
---|
| 191 | }
|
---|
| 192 | }
|
---|
| 193 | sa_size_t kpair=0;
|
---|
| 194 | k=0; // numero de ligne dans la matrice des visibilites
|
---|
| 195 | for(size_t i=0; i<vpdata_.size(); i++) {
|
---|
| 196 | for(size_t j=i; j<vpdata_.size(); j++) {
|
---|
| 197 | kpair++;
|
---|
| 198 | if (kpair<(pairst_+1)) continue;
|
---|
| 199 | if (kpair>=(pairst_+nbpairs_+1)) break;
|
---|
[3915] | 200 | if (fgpimp_&&(i!=j)&&((i+j)%2==0)) continue; // calcul des visib avec numero pair-impair + autocorrel
|
---|
[3909] | 201 | chanpairnum_(k)=chanids_(i)*CHANPAIRCONVFAC+chanids_(j);
|
---|
| 202 | chanpairs_(k,0)=chanids_(i); chanpairs_(k,1)=chanids_(j); k++;
|
---|
| 203 | }
|
---|
| 204 | }
|
---|
| 205 |
|
---|
| 206 | string filename;
|
---|
[3956] | 207 | filename = (outpath_+"chanum.")+OutFileExtension();
|
---|
[3909] | 208 | if (nbcalc_>1) {
|
---|
| 209 | char sbuff[32];
|
---|
[3956] | 210 | sprintf(sbuff,"chanum_%d.%s",(int)calcid_,OutFileExtension());
|
---|
[3909] | 211 | filename = outpath_+sbuff;
|
---|
| 212 | }
|
---|
[3956] | 213 | if (fgfitsout_) { // Ecriture au format FITS
|
---|
| 214 | FitsInOutFile foc(filename, FitsInOutFile::Fits_Create);
|
---|
| 215 | foc.SetNextExtensionName("chanids");
|
---|
| 216 | foc << chanids_;
|
---|
| 217 | foc.SetNextExtensionName("chanpairs");
|
---|
| 218 | foc << chanpairs_;
|
---|
| 219 | foc.SetNextExtensionName("chanpairnum");
|
---|
| 220 | foc << chanpairnum_;
|
---|
| 221 | foc.SetNextExtensionName("chanpairsall");
|
---|
| 222 | foc << chanpairsall_;
|
---|
| 223 | foc.SetNextExtensionName("chanpairnumall");
|
---|
| 224 | foc << chanpairnumall_;
|
---|
| 225 | }
|
---|
| 226 | else { // Format PPF
|
---|
| 227 | POutPersist poc(filename);
|
---|
| 228 | poc << PPFNameTag("chanids") << chanids_;
|
---|
| 229 | poc << PPFNameTag("chanpairs") << chanpairs_;
|
---|
| 230 | poc << PPFNameTag("chanpairnum") << chanpairnum_;
|
---|
| 231 | poc << PPFNameTag("chanpairsall") << chanpairsall_;
|
---|
| 232 | poc << PPFNameTag("chanpairnumall") << chanpairnumall_;
|
---|
| 233 | }
|
---|
| 234 | cout << "BRVisibilityCalculator[" << calcid_ << "]::UpdateChanIds() Channel Ids/Pairs saved to file "
|
---|
[3910] | 235 | << filename << endl;
|
---|
[3915] | 236 | cout << " ... NbVisib=NbChanPairs=" << chanpairs_.NRows() << " ChannelPairs= " ;
|
---|
[3910] | 237 | for(sa_size_t ir=0; ir<chanpairs_.NRows(); ir++) {
|
---|
[3911] | 238 | if (ir%10==0) cout << endl;
|
---|
[3910] | 239 | cout << "(" << chanpairs_(ir,0) << "," << chanpairs_(ir,1) << ") ";
|
---|
| 240 | }
|
---|
| 241 | cout << endl;
|
---|
[3909] | 242 | return;
|
---|
| 243 | }
|
---|
| 244 |
|
---|
[3872] | 245 | /* --Methode-- */
|
---|
| 246 | int BRVisibilityCalculator::ActivateTimeTagCheck(uint_8 maxnpaq)
|
---|
| 247 | {
|
---|
| 248 | mindeltatt_=memgr_.PaqSize()/2;
|
---|
| 249 | if (mindeltatt_<1) mindeltatt_=1;
|
---|
| 250 | fcmtx_.SetSize(memgr_.NbFibres(), maxnpaq);
|
---|
| 251 | ttmtx_.SetSize(memgr_.NbFibres(), maxnpaq);
|
---|
| 252 | vlasttt_.resize(memgr_.NbFibres(), 0);
|
---|
| 253 | vbadtt_.resize(memgr_.NbFibres(), 0);
|
---|
| 254 | vnsamett_.resize(memgr_.NbFibres(), 0);
|
---|
| 255 | vndiff5tt_.resize(memgr_.NbFibres(), 0);
|
---|
| 256 |
|
---|
| 257 | fgcktt_=true;
|
---|
| 258 | cout << " BRVisibilityCalculator::ActivateTimeTagCheck() - TT/Fc matrix NCols=" << maxnpaq
|
---|
| 259 | << " MinDeltaTT=" << mindeltatt_ << endl;
|
---|
| 260 |
|
---|
| 261 | return 0;
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 |
|
---|
| 265 | /* --Methode-- */
|
---|
| 266 | void BRVisibilityCalculator::run()
|
---|
| 267 | {
|
---|
| 268 | cout << " BRVisibilityCalculator[" << calcid_ << "/" << nbcalc_
|
---|
| 269 | << "]::run() - Starting " << " NFibers=" << memgr_.NbFibres()
|
---|
| 270 | << " NChan=" << 2*memgr_.NbFibres() << " NPairs=" << nbpairs_ << " First:" << pairst_ << endl;
|
---|
| 271 |
|
---|
| 272 | if (nparthr_ < 2) return BRBaseProcessor::run();
|
---|
| 273 | // Execution multithread parallele
|
---|
| 274 | setRC(1);
|
---|
| 275 | int rc=0;
|
---|
| 276 | try {
|
---|
| 277 | if ((nmean_%memgr_.NbPaquets())!=0) {
|
---|
| 278 | uint_4 mnmean = (nmean_/memgr_.NbPaquets()+1)*memgr_.NbPaquets();
|
---|
| 279 | cout << " BRVisibilityCalculator::run()/Info changing nmean=" << nmean_ << " to multiple of"
|
---|
| 280 | << " memgr_.NbPaquets() -> " << mnmean << endl;
|
---|
| 281 | nmean_=mnmean;
|
---|
| 282 | }
|
---|
| 283 | paralex_.SetParallelTask(*this);
|
---|
| 284 | cout << " BRVisibilityCalculator::run()/Info : starting ParallelExecutor with nThreads="
|
---|
| 285 | << paralex_.nThreads() << " ... " << endl;
|
---|
| 286 | paralex_.start();
|
---|
| 287 |
|
---|
| 288 | fgallfibok = new bool[memgr_.NbPaquets()];
|
---|
| 289 |
|
---|
| 290 | size_t paqsz=memgr_.PaqSize();
|
---|
[3956] | 291 | size_t procpaqsz=memgr_.ProcPaqSize();
|
---|
[3872] | 292 | bool fgrun=true;
|
---|
| 293 | while (fgrun) {
|
---|
| 294 | if (stop_) break;
|
---|
| 295 | if (memgr_.GetRunState() == MemZR_Stopped) break;
|
---|
| 296 | int mid = memgr_.FindMemZoneId(mmact_); // (MemZA_ProcA);
|
---|
| 297 | // Byte* buffg = memgr_.GetMemZone(mid);
|
---|
| 298 | // if (buffg == NULL) {
|
---|
| 299 | if (mid < 0) {
|
---|
| 300 | cout << "BRVisibilityCalculator[" << calcid_ << "]::run()/ERROR FindMemZoneId("
|
---|
| 301 | << (int)mmact_ << ") ->" << mid << ") -> NULL" << endl;
|
---|
| 302 | setRC(7); fgrun=false;
|
---|
| 303 | break;
|
---|
| 304 | }
|
---|
[3909] | 305 | cts_=memgr_.GetAuxData(mid)->FillTime(); // get associated date/time (DATEOBS)
|
---|
[3910] | 306 | if (totnbpaq_==0) UpdateChanIds(); // Appele ici pour etre sur que le thread de remplissage a mis l'info a jour.
|
---|
[3909] | 307 |
|
---|
[3872] | 308 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
| 309 | fbuff_[fib] = memgr_.GetMemZone(mid,fib);
|
---|
| 310 | if (fbuff_[fib] == NULL) { // cela ne devrait pas arriver
|
---|
| 311 | cout << "BRVisibilityCalculator[" << calcid_ << "]::run()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl;
|
---|
| 312 | setRC(9); fgrun=false;
|
---|
| 313 | break;
|
---|
| 314 | }
|
---|
[3956] | 315 | if ((procpaqsz>0)&&((fprocbuff_[fib]=memgr_.GetProcMemZone(mid,fib))==NULL)) { // cela ne devrait pas arriver non plus
|
---|
| 316 | cout << "BRVisibilityCalculator[" << calcid_ << "]::run()/ERROR memgr.GetProcMemZone("
|
---|
| 317 | << mid << "," << fib << ") -> NULL" << endl;
|
---|
| 318 | setRC(9); fgrun=false;
|
---|
| 319 | break;
|
---|
| 320 | }
|
---|
[3872] | 321 | }
|
---|
| 322 |
|
---|
| 323 | if (totnbpaq_%nmean_ == 0) {
|
---|
| 324 | if (totnbpaq_ > 0) {
|
---|
| 325 | moyfc_/=nmean_;
|
---|
| 326 | moytt_/=nmean_;
|
---|
[3878] | 327 | UpdateVisMtxInfo(); // add/update keywords in the Info DVList
|
---|
[3872] | 328 | // ATTENTION : Matrice visibilites non moyennee
|
---|
| 329 | char nfile[48];
|
---|
| 330 | if (nbcalc_==1)
|
---|
[3956] | 331 | sprintf(nfile,"vismtx%d.%s",numfile_,OutFileExtension());
|
---|
[3872] | 332 | else
|
---|
[3956] | 333 | sprintf(nfile,"vismtx_%d_%d.%s",(int)calcid_,numfile_,OutFileExtension());
|
---|
[3872] | 334 | string flnm=outpath_+nfile;
|
---|
[3956] | 335 | if (fgfitsout_) { // Ecriture au format FITS
|
---|
| 336 | FitsInOutFile fo(flnm, FitsInOutFile::Fits_Create);
|
---|
| 337 | TArray<r_4> arvismtx = ArrCastC2R(vismtx_);
|
---|
| 338 | arvismtx.Info()=vismtx_.Info();
|
---|
| 339 | fo << arvismtx;
|
---|
| 340 | }
|
---|
| 341 | else { // Format PPF
|
---|
| 342 | POutPersist po(flnm);
|
---|
| 343 | po << vismtx_;
|
---|
| 344 | }
|
---|
[3923] | 345 | if ((prtlev_>0)&&(numfile_%prtmodulo_==0)) {
|
---|
| 346 | cout << numfile_ << "-BRVisCalc[" << calcid_ << "/" << nbcalc_ << "]::run() NPaqProc="
|
---|
| 347 | << totnbpaq_ << " TotMegaFLOP=" << (uint_8)TotNbMegaFLOP() << " -> VisibMtx in " << flnm << endl;
|
---|
| 348 | }
|
---|
[3920] | 349 | if (fgvisdt_) FillVisibTable(moyfc_, moytt_);
|
---|
[3872] | 350 | numfile_++;
|
---|
| 351 | }
|
---|
| 352 | vismtx_ = complex<r_4>((r_4)0.,(r_4)0.);
|
---|
| 353 | moyfc_=moytt_=0.;
|
---|
[3909] | 354 | // first_tmstamp_.SetNow(); // Current date and time
|
---|
| 355 | first_tmstamp_=cts_; // Current date and time
|
---|
[3872] | 356 | }
|
---|
| 357 |
|
---|
| 358 | for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) { // boucle sur les paquets d'une zone
|
---|
| 359 | fgallfibok[jp]=fgokallfibers_=true;
|
---|
| 360 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
| 361 | vpaq_[fib].Set(fbuff_[fib]+jp*paqsz);
|
---|
| 362 | vfgok_[fib] = vpchk_[fib].Check(vpaq_[fib],curfc_[fib]);
|
---|
| 363 | if (!vfgok_[fib]) fgallfibok[jp]=fgokallfibers_=false;
|
---|
[3967] | 364 | //Pas utile if (procpaqsz>0) vprocpaq_[fib] = fprocbuff_[fib]+jp*procpaqsz;
|
---|
[3872] | 365 | }
|
---|
| 366 | if (fgokallfibers_) {
|
---|
| 367 | if (totprocnpaq_==0) {
|
---|
| 368 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
| 369 | fcfirst_[fib]=curfc_[fib];
|
---|
| 370 | ttfirst_[fib]=vpaq_[fib].TimeTag();
|
---|
| 371 | }
|
---|
| 372 | }
|
---|
| 373 | totprocnpaq_++;
|
---|
| 374 | moyfc_ += curfc_[0];
|
---|
| 375 | moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]);
|
---|
| 376 | if ((fgcktt_)&&(calcid_==0)) CheckTimeTag();
|
---|
[3895] | 377 | if (totnbpaq_%nmean_ == 0) {
|
---|
| 378 | first_fc_=curfc_[0];
|
---|
| 379 | first_tt_= (vpaq_[0].TimeTag()-ttfirst_[0]);
|
---|
| 380 | }
|
---|
[3872] | 381 | totnbpaq_++;
|
---|
| 382 | }
|
---|
| 383 | } // Fin de boucle sur les paquets
|
---|
[3895] | 384 |
|
---|
[3872] | 385 | // Execution parallele pour calcul des visibilites par bandes de frequence
|
---|
| 386 | int rcpex=paralex_.execute();
|
---|
| 387 | if (rcpex!=0) cout << " BRVisibilityCalculator[" << calcid_ << "]::run() / Error Rc[paralex_.execute()]=" << rcpex << endl;
|
---|
| 388 |
|
---|
| 389 | memgr_.FreeMemZone(mid, mmsta_); // (MemZS_ProcA);
|
---|
| 390 | } // Fin de boucle sur les zones a traiter
|
---|
| 391 | //------------------------------------
|
---|
| 392 | cout << " --------- END BRVisibilityCalculator[" << calcid_ << "]::run() , TotNbProcPaq=" << totprocnpaq_ << endl;
|
---|
| 393 | /*
|
---|
| 394 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) vpchk_[fib].Print();
|
---|
| 395 | cout << " ------------------------------------ " << endl;
|
---|
| 396 | */
|
---|
| 397 | delete[] fgallfibok;
|
---|
| 398 | }
|
---|
| 399 | catch (std::exception& exc) {
|
---|
| 400 | cout << " BRVisibilityCalculator[" << calcid_ << "]::run()/catched std::exception " << exc.what() << endl;
|
---|
| 401 | setRC(98);
|
---|
| 402 | return;
|
---|
| 403 | }
|
---|
| 404 | catch(...) {
|
---|
| 405 | cout << " BRVisibilityCalculator[" << calcid_ << "]::run()/catched unknown ... exception " << endl;
|
---|
| 406 | setRC(99);
|
---|
| 407 | return;
|
---|
| 408 | }
|
---|
| 409 |
|
---|
| 410 | }
|
---|
| 411 |
|
---|
[3967] | 412 |
|
---|
[3872] | 413 | /* --Methode-- */
|
---|
| 414 | int BRVisibilityCalculator::Process()
|
---|
| 415 | {
|
---|
[3910] | 416 | if (totnbpaq_==0) UpdateChanIds(); // Appele ici pour etre sur que le thread de remplissage a mis l'info a jour.
|
---|
[3956] | 417 | if (fgdataraw_) { // Donnees firmware RAW apres TF soft
|
---|
| 418 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
| 419 | vpdatar_[2*fib] = reinterpret_cast< complex<r_4>* > (vprocpaq_[fib]);
|
---|
| 420 | vpdatar_[2*fib+1] = reinterpret_cast< complex<r_4>* >(vprocpaq_[fib]+memgr_.ProcPaqSize()/2) ;
|
---|
| 421 | }
|
---|
| 422 | }
|
---|
| 423 | else { // donnees firmware FFT
|
---|
| 424 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
| 425 | vpdata_[2*fib] = vpaq_[fib].Data1C();
|
---|
| 426 | vpdata_[2*fib+1] = vpaq_[fib].Data2C();
|
---|
| 427 | }
|
---|
[3872] | 428 | }
|
---|
| 429 |
|
---|
| 430 | if (totnbpaq_%nmean_ == 0) {
|
---|
| 431 | if (totnbpaq_ > 0) {
|
---|
| 432 | moyfc_/=nmean_;
|
---|
| 433 | moytt_/=nmean_;
|
---|
[3878] | 434 | UpdateVisMtxInfo(); // add/update keywords in the Info DVList
|
---|
[3872] | 435 | // ATTENTION : Matrice visibilites non moyennee
|
---|
| 436 | char nfile[48];
|
---|
| 437 | if (nbcalc_==1)
|
---|
[3956] | 438 | sprintf(nfile,"vismtx%d.%s",numfile_,OutFileExtension());
|
---|
[3872] | 439 | else
|
---|
[3956] | 440 | sprintf(nfile,"vismtx_%d_%d.%s",(int)calcid_,numfile_,OutFileExtension());
|
---|
[3872] | 441 | string flnm=outpath_+nfile;
|
---|
[3956] | 442 | if (fgfitsout_) { // Ecriture au format FITS
|
---|
| 443 | FitsInOutFile fo(flnm, FitsInOutFile::Fits_Create);
|
---|
| 444 | TArray<r_4> arvismtx = ArrCastC2R(vismtx_);
|
---|
| 445 | arvismtx.Info()=vismtx_.Info();
|
---|
| 446 | fo << arvismtx;
|
---|
| 447 | }
|
---|
| 448 | else { // Format PPF
|
---|
| 449 | POutPersist po(flnm);
|
---|
| 450 | po << vismtx_;
|
---|
| 451 | }
|
---|
[3923] | 452 | if ((prtlev_>0)&&(numfile_%prtmodulo_==0)) {
|
---|
| 453 | cout << numfile_ << "-BRVisCalc[" << calcid_ << "/" << nbcalc_ << "]::Process() NPaqProc="
|
---|
| 454 | << totnbpaq_ << " TotMegaFLOP=" << (uint_8)TotNbMegaFLOP() << " -> VisibMtx in " << flnm << endl;
|
---|
| 455 | }
|
---|
[3920] | 456 | if (fgvisdt_) FillVisibTable(moyfc_, moytt_);
|
---|
[3872] | 457 | numfile_++;
|
---|
| 458 | }
|
---|
| 459 | vismtx_ = complex<r_4>((r_4)0.,(r_4)0.);
|
---|
| 460 | moyfc_=moytt_=0.;
|
---|
[3878] | 461 | first_fc_=curfc_[0];
|
---|
| 462 | first_tt_= (vpaq_[0].TimeTag()-ttfirst_[0]);
|
---|
[3909] | 463 | // first_tmstamp_.SetNow(); // Current date and time
|
---|
| 464 | first_tmstamp_=cts_; // Current date and time
|
---|
[3872] | 465 | }
|
---|
| 466 |
|
---|
[3893] | 467 | // kpair=numero sequentiel de la paire: 0->(0,0), 1->(0,1), 2->(0,2), 3->(0,3), 4->(1,1), 5->(1,2) ...
|
---|
[3895] | 468 | sa_size_t kpair=0;
|
---|
| 469 | sa_size_t k=0; // numero de ligne dans la matrice des visibilites
|
---|
[3872] | 470 | for(size_t i=0; i<vpdata_.size(); i++) {
|
---|
| 471 | for(size_t j=i; j<vpdata_.size(); j++) {
|
---|
[3895] | 472 | kpair++;
|
---|
| 473 | if (kpair<(pairst_+1)) continue;
|
---|
| 474 | if (kpair>=(pairst_+nbpairs_+1)) break;
|
---|
[3915] | 475 | if (fgpimp_&&(i!=j)&&((i+j)%2==0)) continue; // calcul des visib avec numero pair-impair + autocorrel
|
---|
[3922] | 476 | TVector< complex<r_4> > vis = vismtx_.Row(k); k++;
|
---|
[3956] | 477 |
|
---|
| 478 | if (fgdataraw_) { // Donnees firmware RAW apres TF soft
|
---|
| 479 | for(sa_size_t f=1; f<vis.Size(); f++) {
|
---|
[3963] | 480 | vis(f) += vpdatar_[i][f] * conj(vpdatar_[j][f]);
|
---|
[3956] | 481 | }
|
---|
[3872] | 482 | }
|
---|
[3956] | 483 | else { // donnees firmware FFT
|
---|
| 484 | for(sa_size_t f=1; f<vis.Size(); f++) {
|
---|
| 485 | vis(f) += complex<r_4>((r_4)vpdata_[i][f].realB(), (r_4)vpdata_[i][f].imagB()) *
|
---|
| 486 | complex<r_4>((r_4)vpdata_[j][f].realB(), -(r_4)vpdata_[j][f].imagB());
|
---|
| 487 | }
|
---|
| 488 | }
|
---|
[3895] | 489 | nb_flop_ += (8.*(r_8)(vis.Size()-1));
|
---|
[3872] | 490 | }
|
---|
| 491 | }
|
---|
| 492 |
|
---|
| 493 | moyfc_ += curfc_[0];
|
---|
| 494 | moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]);
|
---|
| 495 | if ((fgcktt_)&&(calcid_==0)) CheckTimeTag();
|
---|
| 496 | totnbpaq_++;
|
---|
| 497 | return 0;
|
---|
| 498 | }
|
---|
| 499 |
|
---|
| 500 | /* --Methode-- */
|
---|
[3878] | 501 | void BRVisibilityCalculator::UpdateVisMtxInfo()
|
---|
| 502 | {
|
---|
| 503 | string ikey,ikdesc;
|
---|
| 504 | ikey="DATEOBS"; ikdesc=" Date/Time corresponding to TimeTagFirst";
|
---|
| 505 | vismtx_.Info().SetS(ikey,first_tmstamp_.ToString());
|
---|
| 506 | vismtx_.Info().SetComment(ikey,ikdesc);
|
---|
| 507 | ikey="FirstFC"; ikdesc="First FrameCounter";
|
---|
| 508 | vismtx_.Info().SetI(ikey,first_fc_);
|
---|
| 509 | vismtx_.Info().SetComment(ikey,ikdesc);
|
---|
| 510 | ikey="FirstTT"; ikdesc="First TimeTag";
|
---|
| 511 | vismtx_.Info().SetI(ikey,first_tt_);
|
---|
| 512 | vismtx_.Info().SetComment(ikey,ikdesc);
|
---|
| 513 | ikey="LastFC"; ikdesc="Last FrameCounter";
|
---|
| 514 | vismtx_.Info().SetI(ikey,curfc_[0]);
|
---|
| 515 | vismtx_.Info().SetComment(ikey,ikdesc);
|
---|
| 516 | ikey="LastTT"; ikdesc="Last TimeTag";
|
---|
| 517 | vismtx_.Info().SetI(ikey,vpaq_[0].TimeTag()-ttfirst_[0]);
|
---|
| 518 | vismtx_.Info().SetComment(ikey,ikdesc);
|
---|
| 519 | ikey="MeanFC"; ikdesc="Mean FrameCounter";
|
---|
| 520 | vismtx_.Info().SetD(ikey,moyfc_);
|
---|
| 521 | vismtx_.Info().SetComment(ikey,ikdesc);
|
---|
| 522 | ikey="MeanTT"; ikdesc="Mean TimeTag";
|
---|
| 523 | vismtx_.Info().SetD(ikey,moytt_);
|
---|
| 524 | vismtx_.Info().SetComment(ikey,ikdesc);
|
---|
| 525 | ikey="NPAQSUM"; ikdesc="Number of paquets summed";
|
---|
| 526 | vismtx_.Info().SetI(ikey,nmean_);
|
---|
| 527 | }
|
---|
| 528 |
|
---|
| 529 |
|
---|
| 530 | /* --Methode-- */
|
---|
[3872] | 531 | int BRVisibilityCalculator::execute(int tid)
|
---|
| 532 | {
|
---|
| 533 | vector<TwoByteComplex*> pvpdata(2*memgr_.NbFibres());
|
---|
[3956] | 534 | vector< complex<r_4>* > pvpdatar(2*memgr_.NbFibres());
|
---|
[3872] | 535 | size_t paqsz=memgr_.PaqSize();
|
---|
[3967] | 536 | size_t procpaqsz=memgr_.ProcPaqSize();
|
---|
[3872] | 537 | BRPaquet ppaq(paqsz);
|
---|
| 538 |
|
---|
[3895] | 539 |
|
---|
[3872] | 540 | sa_size_t fdelt = vismtx_.NCols()/nparthr_;
|
---|
| 541 | sa_size_t fdeb = tid*fdelt;
|
---|
| 542 | sa_size_t ffin = (tid+1)*fdelt;
|
---|
| 543 |
|
---|
| 544 | if (fdeb<1) fdeb=1;
|
---|
| 545 | if ((ffin>vismtx_.NCols())||(tid==(nparthr_-1))) ffin=vismtx_.NCols();
|
---|
| 546 |
|
---|
| 547 | for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) { // boucle sur les paquets d'une zone
|
---|
| 548 | if (!fgallfibok[jp]) continue;
|
---|
[3956] | 549 | if (fgdataraw_) { // Donnees firmware RAW apres TF soft
|
---|
| 550 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
[3967] | 551 | Byte* procdatap=fprocbuff_[fib]+jp*procpaqsz;
|
---|
| 552 | pvpdatar[2*fib] = reinterpret_cast< complex<r_4>* > (procdatap);
|
---|
| 553 | pvpdatar[2*fib+1] = reinterpret_cast< complex<r_4>* >(procdatap+procpaqsz/2) ;
|
---|
[3956] | 554 | }
|
---|
| 555 | }
|
---|
| 556 | else { // donnees firmware FFT
|
---|
| 557 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
| 558 | ppaq.Set(fbuff_[fib]+jp*paqsz);
|
---|
| 559 | pvpdata[2*fib] = ppaq.Data1C();
|
---|
| 560 | pvpdata[2*fib+1] = ppaq.Data2C();
|
---|
| 561 | }
|
---|
[3872] | 562 | }
|
---|
[3895] | 563 |
|
---|
| 564 |
|
---|
[3893] | 565 | // kpair=numero sequentiel de la paire: 0->(0,0), 1->(0,1), 2->(0,2), 3->(0,3), 4->(1,1), 5->(1,2) ...
|
---|
[3895] | 566 | sa_size_t kpair=0;
|
---|
| 567 | sa_size_t k=0; // numero de ligne dans la matrice des visibilites
|
---|
[3872] | 568 | for(size_t i=0; i<vpdata_.size(); i++) {
|
---|
| 569 | for(size_t j=i; j<vpdata_.size(); j++) {
|
---|
[3895] | 570 | kpair++;
|
---|
| 571 | if (kpair<(pairst_+1)) continue;
|
---|
| 572 | if (kpair>=(pairst_+nbpairs_+1)) break;
|
---|
[3915] | 573 | if (fgpimp_&&(i!=j)&&((i+j)%2==0)) continue; // calcul des visib avec numero pair-impair + autocorrel
|
---|
[3895] | 574 | TVector< complex<r_4> > vis = vismtx_.Row(k); k++;
|
---|
[3956] | 575 | if (fgdataraw_) { // Donnees firmware RAW apres TF soft
|
---|
| 576 | for(sa_size_t f=fdeb; f<ffin; f++) {
|
---|
[3963] | 577 | vis(f) += pvpdatar[i][f] * conj(pvpdatar[j][f]);
|
---|
[3956] | 578 | }
|
---|
[3872] | 579 | }
|
---|
[3956] | 580 | else { // donnees firmware FFT
|
---|
| 581 | for(sa_size_t f=fdeb; f<ffin; f++) {
|
---|
| 582 | vis(f) += complex<r_4>((r_4)pvpdata[i][f].realB(), (r_4)pvpdata[i][f].imagB()) *
|
---|
| 583 | complex<r_4>((r_4)pvpdata[j][f].realB(), -(r_4)pvpdata[j][f].imagB());
|
---|
| 584 | }
|
---|
| 585 | }
|
---|
[3895] | 586 | nb_flop_ += (8.*(r_8)(ffin-fdeb));
|
---|
[3872] | 587 | }
|
---|
| 588 | }
|
---|
| 589 |
|
---|
| 590 | } // Fin de boucle sur les paquets
|
---|
| 591 |
|
---|
| 592 | return 0;
|
---|
| 593 | }
|
---|
| 594 |
|
---|
| 595 | /* --Methode-- */
|
---|
| 596 | int BRVisibilityCalculator::FillVisibTable(double fcm, double ttm)
|
---|
| 597 | {
|
---|
| 598 | double xnt[10];
|
---|
| 599 | xnt[0]=fcm; xnt[1]=ttm/1.25e8;
|
---|
| 600 |
|
---|
| 601 | if (djf_<2) {
|
---|
| 602 | for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) {
|
---|
| 603 | for(sa_size_t jf=jf1_; jf<jf2_; jf++) {
|
---|
| 604 | xnt[2]=jf;
|
---|
[3909] | 605 | xnt[3]=chanpairnumall_(rv+pairst_);
|
---|
[3872] | 606 | xnt[4]=vismtx_(rv,jf).real()/(r_4)(nmean_);
|
---|
| 607 | xnt[5]=vismtx_(rv,jf).imag()/(r_4)(nmean_);
|
---|
| 608 | visdt_.AddRow(xnt);
|
---|
| 609 | }
|
---|
| 610 | }
|
---|
| 611 | }
|
---|
| 612 | else {
|
---|
| 613 | for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) {
|
---|
| 614 | for(sa_size_t jf=jf1_; jf<jf2_; jf+=djf_) {
|
---|
| 615 | r_4 moyreal=0.;
|
---|
| 616 | r_4 moyimag=0.;
|
---|
| 617 | sa_size_t jjfmx=jf+djf_;
|
---|
| 618 | if (jjfmx > vismtx_.NCols()) jjfmx=vismtx_.NCols();
|
---|
| 619 | for(sa_size_t jjf=jf; jjf<jjfmx; jjf++) {
|
---|
| 620 | moyreal+=vismtx_(rv,jjf).real();
|
---|
| 621 | moyimag+=vismtx_(rv,jjf).imag();
|
---|
| 622 | }
|
---|
| 623 | xnt[2]=jf+djf_/2;
|
---|
[3909] | 624 | xnt[3]=chanpairnumall_(rv+pairst_);
|
---|
[3872] | 625 | xnt[4]=moyreal/(r_4)(nmean_*djf_);
|
---|
| 626 | xnt[5]=moyimag/(r_4)(nmean_*djf_);
|
---|
| 627 | visdt_.AddRow(xnt);
|
---|
| 628 | }
|
---|
| 629 | }
|
---|
| 630 | }
|
---|
| 631 | return 0;
|
---|
| 632 | }
|
---|
| 633 |
|
---|
| 634 | /* --Methode-- */
|
---|
| 635 | int BRVisibilityCalculator::CheckTimeTag()
|
---|
| 636 | {
|
---|
| 637 | if (totnbpaq_==0) {
|
---|
| 638 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
| 639 | vlasttt_[fib]=ttfirst_[fib];
|
---|
| 640 | if (ttmtx_.NCols()>0) {
|
---|
| 641 | fcmtx_(fib,totnbpaq_) = curfc_[fib];
|
---|
| 642 | ttmtx_(fib,totnbpaq_) = vlasttt_[fib];
|
---|
| 643 | }
|
---|
| 644 | }
|
---|
| 645 | return 0;
|
---|
| 646 | }
|
---|
| 647 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
| 648 | int_8 ld = (int_8)vpaq_[fib].TimeTag()-(int_8)vlasttt_[fib];
|
---|
| 649 | int_8 fd = (int_8)vpaq_[fib].TimeTag()-(int_8)ttfirst_[fib]-(int_8)vpaq_[0].TimeTag()+(int_8)ttfirst_[0];
|
---|
| 650 | /* if ( (ld < mindeltatt_) || (fd<-5) || (fd>5)) { vbadtt_[fib]++; vnsamett_[fib]++; }
|
---|
| 651 | else {
|
---|
| 652 | if (fd!=0) vnsamett_[fib]++;
|
---|
| 653 | }
|
---|
| 654 | */
|
---|
| 655 | if (ld < mindeltatt_) vbadtt_[fib]++;
|
---|
| 656 | else {
|
---|
| 657 | if (fd != 0) vnsamett_[fib]++;
|
---|
| 658 | if ((fd<-5)||(fd>5)) vndiff5tt_[fib]++;
|
---|
| 659 | }
|
---|
| 660 | vlasttt_[fib]=vpaq_[fib].TimeTag();
|
---|
| 661 | if (totnbpaq_<ttmtx_.NCols()) {
|
---|
| 662 | fcmtx_(fib,totnbpaq_) = curfc_[fib];
|
---|
| 663 | ttmtx_(fib,totnbpaq_) = vlasttt_[fib];
|
---|
| 664 | }
|
---|
| 665 | }
|
---|
| 666 | return 0;
|
---|
| 667 | }
|
---|
| 668 |
|
---|
| 669 | //-------------------------------------------------------------------------------
|
---|
| 670 | // Classe Groupe (ensemble) de Calculateur de Visibilites, tournant en parallele
|
---|
| 671 | //-------------------------------------------------------------------------------
|
---|
| 672 |
|
---|
| 673 | /* --Methode-- */
|
---|
[3915] | 674 | BRVisCalcGroup::BRVisCalcGroup(size_t nbcalc, RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean,
|
---|
| 675 | uint_4 pair1, uint_4 nbpairs, bool fgpimp, size_t nthr)
|
---|
[3872] | 676 | : tm_(false)
|
---|
| 677 | {
|
---|
| 678 | if ((nbcalc<1)||(nbcalc>6))
|
---|
| 679 | throw ParmError("BRVisCalcGroup::BRVisCalcGroup NbCalc > 6 !");
|
---|
| 680 | for(size_t i=0; i<nbcalc; i++) {
|
---|
| 681 | BRVisibilityCalculator * viscp=new BRVisibilityCalculator(memgr, outpath, nmean, nthr);
|
---|
[3915] | 682 | viscp->DefineRank(nbcalc, i, pair1, nbpairs, fgpimp);
|
---|
[3872] | 683 | viscalcp_.push_back(viscp);
|
---|
| 684 | }
|
---|
| 685 | }
|
---|
| 686 | /* --Methode-- */
|
---|
| 687 | BRVisCalcGroup::~BRVisCalcGroup()
|
---|
| 688 | {
|
---|
| 689 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
| 690 | delete viscalcp_[i];
|
---|
| 691 | }
|
---|
| 692 | /* --Methode-- */
|
---|
[3956] | 693 | MemZStatus BRVisCalcGroup::SetMemZAction(MemZaction mmact)
|
---|
| 694 | {
|
---|
| 695 | MemZaction mmzas[10]={MemZA_ProcA,MemZA_ProcB,MemZA_ProcC,MemZA_ProcD,MemZA_ProcE,MemZA_ProcF,
|
---|
| 696 | MemZA_ProcG,MemZA_ProcH,MemZA_ProcI,MemZA_ProcJ};
|
---|
| 697 | MemZStatus mmzss[10]={MemZS_ProcA,MemZS_ProcB,MemZS_ProcC,MemZS_ProcD,MemZS_ProcE,MemZS_ProcF,
|
---|
| 698 | MemZS_ProcG,MemZS_ProcH,MemZS_ProcI,MemZS_ProcJ};
|
---|
| 699 | size_t ia=9999;
|
---|
| 700 | for(int i=0; i<10; i++) {
|
---|
| 701 | if (mmact==mmzas[i]) { ia=i; break; }
|
---|
| 702 | }
|
---|
| 703 | if (ia>=10)
|
---|
| 704 | throw ParmError("BRVisCalcGroup::SetMemZAction() Bad MemZaction mmact !");
|
---|
| 705 | if ((ia+viscalcp_.size())>10)
|
---|
| 706 | throw ParmError("BRVisCalcGroup::SetMemZAction() MemZaction mmact too high !");
|
---|
| 707 | for(size_t i=0; i<viscalcp_.size(); i++) {
|
---|
| 708 | viscalcp_[i]->SetMemZAction(mmzas[ia]); ia++;
|
---|
| 709 | }
|
---|
| 710 | return mmzss[ia-1];
|
---|
| 711 | }
|
---|
| 712 | /* --Methode-- */
|
---|
[3872] | 713 | int BRVisCalcGroup::SelectFreqBinning(uint_4 freq1, uint_4 freq2, uint_4 nbfreq)
|
---|
| 714 | {
|
---|
| 715 | int rc=0;
|
---|
| 716 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
| 717 | rc=viscalcp_[i]->SelectFreqBinning(freq1, freq2, nbfreq);
|
---|
| 718 | return rc;
|
---|
| 719 | }
|
---|
| 720 | /* --Methode-- */
|
---|
[3920] | 721 | void BRVisCalcGroup::ActivateVisDTable(bool fgfdt)
|
---|
| 722 | {
|
---|
| 723 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
| 724 | viscalcp_[i]->ActivateVisDTable(fgfdt);
|
---|
| 725 | }
|
---|
| 726 | /* --Methode-- */
|
---|
[3956] | 727 | void BRVisCalcGroup::SetFitsOutput()
|
---|
| 728 | {
|
---|
| 729 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
| 730 | viscalcp_[i]->SetFitsOutput();
|
---|
| 731 | }
|
---|
| 732 | /* --Methode-- */
|
---|
| 733 | void BRVisCalcGroup::SetPPFOutput()
|
---|
| 734 | {
|
---|
| 735 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
| 736 | viscalcp_[i]->SetPPFOutput();
|
---|
[3967] | 737 | }
|
---|
[3956] | 738 | /* --Methode-- */
|
---|
[3967] | 739 | void BRVisCalcGroup::SetFFTData()
|
---|
| 740 | {
|
---|
| 741 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
| 742 | viscalcp_[i]->SetFFTData();
|
---|
| 743 | }
|
---|
| 744 | /* --Methode-- */
|
---|
| 745 | void BRVisCalcGroup::SetRawData()
|
---|
| 746 | {
|
---|
| 747 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
| 748 | viscalcp_[i]->SetRawData();
|
---|
| 749 | }
|
---|
| 750 | /* --Methode-- */
|
---|
[3923] | 751 | void BRVisCalcGroup::SetPrintLevel(int lev, uint_8 prtmodulo)
|
---|
| 752 | {
|
---|
| 753 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
| 754 | viscalcp_[i]->SetPrintLevel(lev,prtmodulo);
|
---|
| 755 | }
|
---|
| 756 | /* --Methode-- */
|
---|
[3872] | 757 | void BRVisCalcGroup::start()
|
---|
| 758 | {
|
---|
| 759 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
| 760 | viscalcp_[i]->start();
|
---|
| 761 | tm_.SplitQ();
|
---|
| 762 | }
|
---|
| 763 | /* --Methode-- */
|
---|
| 764 | void BRVisCalcGroup::join()
|
---|
| 765 | {
|
---|
| 766 | r_8 totflop=0.;
|
---|
| 767 | for(size_t i=0; i<viscalcp_.size(); i++) {
|
---|
| 768 | viscalcp_[i]->join();
|
---|
[3895] | 769 | // cout << " BRVisCalcGroup::join()/ VisibCalc[" << i << "]->TotNbMegaFLOP()="
|
---|
| 770 | // << viscalcp_[i]->TotNbFLOP()/1024e3 << endl;
|
---|
[3872] | 771 | totflop += viscalcp_[i]->TotNbFLOP();
|
---|
| 772 | }
|
---|
| 773 | tm_.SplitQ();
|
---|
| 774 | cout << " ----------------------------------------------------------" << endl;
|
---|
[3895] | 775 | cout << " BRVisCalcGroup::join() : Finished " << viscalcp_.size() << " VisibilityCalculator(s)" << endl;
|
---|
| 776 | cout << " ... Elaspsed time: " << tm_.PartialElapsedTimems()
|
---|
| 777 | << " ms (total:" << tm_.TotalElapsedTimems() << ")" << endl;
|
---|
| 778 | double mflopsrate=totflop/(r_8)tm_.PartialElapsedTimems()/(1024.);
|
---|
[3872] | 779 | cout << " ... TotalMegaFLOP= " << totflop/(1024.e3) << " @ "
|
---|
[3895] | 780 | << mflopsrate << " MFLOP/s" << " (=" << mflopsrate/(r_8)viscalcp_.size() << "/VisibCalcObject)" << endl;
|
---|
[3872] | 781 | cout << " ----------------------------------------------------------" << endl;
|
---|
| 782 | return;
|
---|
| 783 | }
|
---|