Changeset 3089 in Sophya for trunk/SophyaProg/Tests


Ignore:
Timestamp:
Oct 11, 2006, 12:58:10 PM (19 years ago)
Author:
ansari
Message:

prog tests: ajout test perfo multi-fft (tfft.cc) et amelioration test SwFits (tswfits.cc), Reza 11/10/2006

Location:
trunk/SophyaProg/Tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaProg/Tests/tfft.cc

    r3077 r3089  
    1111#include "fftpserver.h"
    1212#include "fftmserver.h"
     13#include "fftmayer.h"
    1314#include "fftwserver.h"
    1415#include "ntoolsinit.h"
     
    4849static  int prtlev = 0;
    4950
     51//-------------------------------------------------
    5052template <class T>
    5153void TestFFTPack(T seuil, sa_size_t num)
     
    106108}
    107109
     110//-------------------------------------------------
    108111template <class T>
    109112int TestFFTS(T seuil, FFTServerInterface & ffts, sa_size_t num)
     
    197200}
    198201
    199 
    200 
    201 
    202 
     202inline void MayerFFTForw(r_4* d, int sz) {
     203  fht_r4(d, sz);
     204}
     205inline void MayerFFTForw(r_8* d, int sz) {
     206  fht_r8(d, sz);
     207}
     208
     209//-------------------------------------------------
     210template <class T>
     211int MultiFFTTest(T t, sa_size_t sz, int nloop, bool fgp)
     212{
     213  cout <<" ===> MultiFFTTest<T=r_" << sizeof(T) << "> NLoop= " << nloop << " ArrSz= " << sz << endl; 
     214  TVector< T > in(sz), incopie(sz);
     215
     216  incopie = in = RandomSequence();
     217  FFTPackServer fftp(false);
     218  TVector< complex<T> > outc;
     219   
     220  PrtTim("MultiFFT-LoopStart");
     221
     222  if (fgp) {
     223    cout << " --- Test effectue avec FFTPack " << endl;
     224    for(int kk=0; kk<nloop; kk++) {
     225      in = incopie;
     226      //      fftp.FFTForward(in, outc);
     227      fftp.fftf(sz, in.Data());
     228    }
     229  }
     230  else {
     231    cout << " --- Test effectue avec FFTMayer " << endl;
     232    for(int kk=0; kk<nloop; kk++) {
     233      in = incopie;
     234      //      in += 0.01;
     235      MayerFFTForw(in.Data(), sz);
     236    }
     237  }
     238  PrtTim("MultiFFT-LoopEnd");
     239  cout << " ----- End ---- MultiFFTTest<T> ----" << endl;
     240  return 0;
     241}
     242
     243
     244
     245//-------------------------------------------------
     246//-------------------------------------------------
     247//-------------------------------------------------
    203248int main(int narg, char* arg[])
    204249{
     
    209254  if (narg < 3) {
    210255    cout << "tfft/ args error - \n  Usage tfft size p/P/M/W [f/d/F/D  PrtLev=0 MaxNPrt=50 diffthr] \n"
     256         << "    OR  tfft size P/M FL/DL/FZ/DZ  [NFFT=10]  \n"
    211257         << " 1D real/complex-FFT test (FFTServer) \n"
    212258         << " size: input vector length \n "
    213259         << " p=FFTPackTest  P=FFTPack, M=FFTMayer, W= FFTWServer \n "
    214260         << " F/f:float, D/d:double F/D:random in_vector (default=D) \n"
    215          << " diffthr : Threshold for diff checks (=10^-6/10^-4 double/float)" << endl;
     261         << "  FL/DL : perform NFFT on a serie of float[size] or double[size] "
     262         << "  FZ/DZ : perform NFFT on a series of complex<float>[size] or complex<double>[size] "
     263         << " diffthr : Threshold for diff checks (=10^-6/10^-4 double/float)"
     264         << endl;
    216265    return(1);
    217266  }
     
    239288  dtyp = toupper(dtyp);
    240289
     290
    241291  FFTServerInterface * ffts;
    242292  if (*arg[2] == 'M')  ffts = fftm.Clone();
    243293  else if (*arg[2] == 'W')  ffts = fftw.Clone();
    244294  else ffts = fftp.Clone();
     295
     296  int nloop = 0;
     297  bool fgpack = true;
     298  if (arg[3][1] == 'L') {  // MultiFFT test
     299    nloop = 10;
     300    if (narg > 4) nloop = atoi(arg[4]);
     301    if (*arg[2] == 'M')  fgpack = false;
     302  }
     303
    245304
    246305  cout << "\n ============================================= \n"
     
    255314      cout << "   ------ Testing FFTServer for double (r_8)----- " << endl;
    256315      if (*arg[2] == 'p') TestFFTPack(ds, sz);
     316      else if (nloop > 0) rc = MultiFFTTest(ds, sz, nloop, fgpack);
    257317      else rc = TestFFTS(ds, *ffts, sz);
    258318    }
     
    260320      cout << "   ------ Testing FFTServer for float (r_4)----- " << endl;
    261321      if (*arg[2] == 'p') TestFFTPack(fs, sz);
     322      else if (nloop > 0) rc = MultiFFTTest(fs, sz, nloop, fgpack);
    262323      else rc = TestFFTS(fs, *ffts, sz);
    263324    }
  • trunk/SophyaProg/Tests/tswfits.cc

    r2890 r3089  
    1111#include "swfitsdtable.h"
    1212
     13#include "datatable.h"
     14#include "fitshdtable.h"
     15
    1316void test_fdtable() ;
     17static long NROW = 64;
     18static long NPRT = 10;
    1419
    1520int main(int narg, char *arg[])
     
    1722  SophyaInit();
    1823  FitsIOServerInit();
     24  if (narg < 3) {
     25    cout << "Erreur arg/Usage: tswfits NRowTable NPRT" << endl;
     26    return 1;
     27  }
     28  NROW = atoi(arg[1]);
     29  NPRT = atoi(arg[2]);
    1930  try {
    20     /*
    21     if (*arg[1] == 'd')  test_dvl();
    22     else if (*arg[1] == 'n')  test_ntuple();
    23     //    else if (*arg[1] == 'x')  test_xntuple();
    24     else if (*arg[1] == 'X')  test_Xntuple();
    25     */
    2631    test_fdtable();
    2732  }
     
    3540    cerr << "tswfits-main() , Catched ... ! " << endl;
    3641  }
     42 
    3743}
    3844
     
    4046void test_fdtable()
    4147{
    42   cout << "======= test_fdtable:  simple DataTable+FITS test ======= " << endl;
     48  cout << "======= test_fdtable:  simple SwapOnFits test ======= " << endl;
    4349    int SWSEGSZ = 4;
    4450    vector<int_8> tags;
    4551    {
    46       cout << " Creation FITSDataSwapper<double> swout(so) avec swseg.fits " << endl;
     52      cout << "1/ Creation FITSDataSwapper<double> swout(so) avec swseg.fits " << endl;
    4753      vector<string> ttype, tform, tunit;
    4854      ttype.push_back("D-Col1");
     
    7480    }
    7581    {
    76       cout << "6/ Creation PPFDataSwapper<float> avec lecture depuis swseg.ppf " << endl;
     82      cout << "2/ Creation FITSDataSwapper<double> avec lecture depuis swseg.fits" << endl;
    7783      FitsInOutFile si("swseg.fits", FitsInOutFile::Fits_RO);
    7884      si.MoveAbsToHDU(2);
    7985      FITSDataSwapper<double> swin(si, 1);
    8086      SwSegDataBlock<double> swsd(swin, tags, SWSEGSZ);
    81       cout <<"7/ Recopie ds SegDataBlock<float> depuis SwSegDataBlock<float> et print" << endl;
     87      cout <<"2.b/ Recopie ds SegDataBlock<double> depuis SwSegDataBlock<double> et print" << endl;
    8288      SegDataBlock<double> segd;
    8389      segd = swsd;
     
    8692
    8793    {
    88       cout << "8/ Creation SwFitsDataTable sur myswtable.fits " << endl;
     94      cout << " ------------------------------------------------ " << endl;
     95      cout << "3/ Creation SwFitsDataTable sur myswtable.fits " << endl;
    8996      FitsInOutFile so("!myswtable.fits", FitsInOutFile::Fits_Create);
    90       SwFitsDataTable dt(so, 16);
     97      SwFitsDataTable dt(so, 45);
    9198      // define table columns
    9299      dt.AddFloatColumn("X0_f");
    93100      dt.AddFloatColumn("X1_f");
    94101      dt.AddDoubleColumn("X0X0pX1X1_d");
    95       cout << "8.b/ start fill " << endl;
     102      cout << "3.b/ start fill " << endl;
    96103      // Fill the table
    97104      r_8 x[5];
    98       for(int i=0; i<63; i++) {
    99         if (i < 5)  cout << " DBG - i= " << i << endl;
     105      int pmod = NROW/50;
     106      if (pmod < 10) pmod = 10;
     107      for(int i=0; i<NROW; i++) {
     108        //      if (i%pmod == 0)  cout << " DBG - i= " << i << endl;
    100109        x[0] = (i%9)-4.;  x[1] = (i/9)-3.;  x[2] = x[0]*x[0]+x[1]*x[1];
    101110        dt.AddLine(x);
    102111      }
    103       cout << "8.c/ End fill " << endl;
     112      cout << "3.c/ End fill " << endl;
    104113     
    105114      // Printing table info
    106115      cout << dt ;
     116      for(int k = 0; k<NPRT; k++)
     117        cout << "Line[" << k << "] " << dt.LineToString(k) << endl ;
     118     
    107119    }
     120    {
     121      cout << " ------------------------------------------------ " << endl;
     122      cout << "4/ Lecture SwFitsDataTable depuis myswtable.fits " << endl;
     123      FitsInOutFile si("myswtable.fits", FitsInOutFile::Fits_RO);
     124      si.SkipEmptyFirstHDU();
     125      SwFitsDataTable dt(si,40,false);
     126      //      si >> dt;
     127      // Printing table info
     128      cout << dt ;
     129      for(int k = 0; k<NPRT; k++)
     130        cout << "Line[" << k << "] " << dt.LineToString(k) << endl ;
     131    }
     132
    108133  cout << "============ FIN  test_fdtable ======== ======= " << endl; 
    109134}
Note: See TracChangeset for help on using the changeset viewer.