Changeset 3724 in Sophya for trunk/AddOn/TAcq/brproc.cc


Ignore:
Timestamp:
Dec 29, 2009, 12:34:19 AM (16 years ago)
Author:
ansari
Message:

Implementation possibilite calcul visibilites avec des threads en parallele, Reza 29/12/2009

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/brproc.cc

    r3710 r3724  
    3232/* --Methode-- */
    3333BRVisibilityCalculator::BRVisibilityCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean,
    34                                                uint_4 freq1, uint_4 freq2, uint_4 nbfreq)
    35   : BRBaseProcessor(memgr), outpath_(outpath), nmean_(nmean), numfreq1_(freq1), numfreq2_(freq2), nbinfreq_(nbfreq),
    36     vpdata_(2*memgr.NbFibres())
     34                                               uint_4 freq1, uint_4 freq2, uint_4 nbfreq, size_t nthr)
     35  : BRBaseProcessor(memgr), paralex_(*this, nthr), nparthr_(nthr), outpath_(outpath), nmean_(nmean),
     36    numfreq1_(freq1), numfreq2_(freq2), nbinfreq_(nbfreq), vpdata_(2*memgr.NbFibres())
    3737    // , dtfos_(outpath+"visdt.fits", Fits_Create), visdt_(dtfos_, 1024, true);
    3838
     
    100100  }
    101101  delete[] xnt_;
     102}
     103
     104/* --Methode-- */
     105void BRVisibilityCalculator::run()
     106{
     107  if (nparthr_ > 1) {
     108    paralex_.SetParallelTask(*this);
     109    cout << " BRVisibilityCalculator::run()/Info : starting ParallelExecutor with nThreads="
     110         << paralex_.nThreads() << " ... " << endl;
     111    paralex_.start();
     112  }
     113  return BRBaseProcessor::run();
    102114}
    103115
     
    152164    moyfc_=moytt_=0.;
    153165  }
     166
     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  }
     183  moyfc_ += curfc_[0];
     184  moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]);
     185  if (fgcktt_)  CheckTimeTag();
     186  totnbpaq_++;
     187  return 0;
     188}
     189
     190/* --Methode-- */
     191int BRVisibilityCalculator::execute(int tid)
     192{
     193  sa_size_t fdelt = vismtx_.NCols()/nparthr_;
     194  sa_size_t fdeb = tid*fdelt;
     195  sa_size_t ffin = (tid+1)*fdelt;
     196  if (fdeb<1) fdeb=1;
     197  if ((ffin>vismtx_.NCols())||(tid==(nparthr_-1))) ffin=vismtx_.NCols();
    154198 
    155199  sa_size_t k=0;
     
    157201    for(size_t j=i; j<vpdata_.size(); j++) {
    158202      TVector< complex<r_4> > vis = vismtx_.Row(k);   k++;
    159       for(sa_size_t f=1; f<vis.Size(); f++) {
     203      for(sa_size_t f=fdeb; f<ffin; f++) {
    160204        vis(f) += complex<r_4>((r_4)vpdata_[i][f].realB(), (r_4)vpdata_[i][f].imagB()) *
    161205          complex<r_4>((r_4)vpdata_[j][f].realB(), -(r_4)vpdata_[j][f].imagB());
     
    163207    }
    164208  }
    165  
    166   moyfc_ += curfc_[0];
    167   moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]);
    168   if (fgcktt_)  CheckTimeTag();
    169   totnbpaq_++;
    170209  return 0;
    171210}
Note: See TracChangeset for help on using the changeset viewer.