Changeset 2386 in Sophya


Ignore:
Timestamp:
May 20, 2003, 12:10:09 PM (22 years ago)
Author:
aubourg
Message:

ring pipes

Location:
trunk/ArchTOIPipe
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/ArchTOIPipe/Kernel/piotoirdr.cc

    r2382 r2386  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: piotoirdr.cc,v 1.5 2003-05-16 13:40:09 aubourg Exp $
     5// $Id: piotoirdr.cc,v 1.6 2003-05-20 10:10:08 aubourg Exp $
    66
    77#include "piotoirdr.h"
     
    110110      }
    111111      flags = new uint_8[nf];
    112       for (int i=0; i<nf; i++) flags[i] = pioflags[i];
     112      for (int i=0; i<nf; i++) flags[i] = (uint_8)pioflags[i];
    113113      PIODeleteFLG(pioflags, pioGroup);
    114114    }
  • trunk/ArchTOIPipe/Kernel/ringpipe.cc

    r2385 r2386  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: ringpipe.cc,v 1.1 2003-05-19 23:31:29 aubourg Exp $
     5// $Id: ringpipe.cc,v 1.2 2003-05-20 10:10:08 aubourg Exp $
    66
    77#include "ringpipe.h"
     
    1515#endif
    1616
    17 RingPipe::RingPipe() {
     17RingPipe::RingPipe(int ws) {
    1818  i0 = -1;
     19  winSize = ws;
    1920  producer = NULL;
    2021  pthread_cond_init(&ringReady, NULL);
     
    3839void RingPipe::putRing(int i, Ring const* ring) {
    3940  lock();
     41  waitForRoom(i);
    4042  if (i0 == -1) {
    4143    data.insert(data.begin(), 1, (Ring const*) NULL);
     
    5052  notify();
    5153  unlock();
     54}
     55
     56void RingPipe::waitForRoom(int j) {
     57  while (j-i0 >= winSize) {
     58    wait();
     59  }
    5260}
    5361
     
    9199    data.erase(data.begin(), data.begin()+(i-i0));
    92100    i0=i;
     101    notify();
    93102  }
    94103  unlock();
  • trunk/ArchTOIPipe/Kernel/ringpipe.h

    r2385 r2386  
    55//                               Christophe Magneville
    66//                               Reza Ansari
    7 // $Id: ringpipe.h,v 1.1 2003-05-19 23:31:29 aubourg Exp $
     7// $Id: ringpipe.h,v 1.2 2003-05-20 10:10:09 aubourg Exp $
    88
    99#ifndef RINGPIPE_H
     
    2121class RingPipe {
    2222public:
    23   RingPipe();
     23  RingPipe(int winSize=100);
    2424  virtual ~RingPipe();
    2525
     
    2828
    2929  virtual void wontNeedRingBefore(int i);
     30  virtual void setWinSize(int n) {winSize = n;}
    3031
    3132protected:
     
    4748  void notify() {pthread_cond_broadcast(&ringReady);}
    4849
     50  int winSize;
    4951  vector<Ring const*> data;
    5052  int i0;
     
    5355
    5456  virtual void waitForRing(int i); // should be locked before
     57  virtual void waitForRoom(int i); // should be locked before
    5558  virtual DataStatus isRingAvail(int i);  // should be locked before
    5659
  • trunk/ArchTOIPipe/Kernel/ringprocessor.cc

    r2385 r2386  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: ringprocessor.cc,v 1.1 2003-05-19 23:31:29 aubourg Exp $
     5// $Id: ringprocessor.cc,v 1.2 2003-05-20 10:10:09 aubourg Exp $
    66
    77#include "ringprocessor.h"
    88#include "ringpipe.h"
     9#include "toimanager.h"
    910
    1011#include <iostream>
     
    3738
    3839  wontNeedRing = -1;
     40  neededRingHistory = 3;
     41  lastAWNR = -1;
     42
     43  TOIManager::getManager()->registerProcessor(this);
    3944}
    4045
     
    5762}
    5863
    59 
     64void RingProcessor::setNeededRingHistory(int nr) {
     65  neededRingHistory = nr;
     66}
    6067
    6168int RingProcessor::declareRingInput(string ring) {
     
    147154}
    148155
     156RingPipe* RingProcessor::getOutRing(string out)
     157{
     158  // recherche du nom de la sortie et verification si le toi existe deja
     159  map<string, int>::iterator i = outRingIx.find(out);
     160  if (i == outRingIx.end()) {
     161    return NULL;
     162  } else {
     163    return outRings[(*i).second];
     164  }
     165}
     166
     167
    149168
    150169Ring const* RingProcessor::getRing(int index, int i) {
     
    169188}
    170189
     190void RingProcessor::autoWontNeedRing(int iCur) {
     191  if (neededRingHistory <=0) return;
     192  if (iCur <= lastAWNR + neededRingHistory/10) return;
     193  lastAWNR = iCur;
     194  wontNeedRingBefore(iCur-neededRingHistory);
     195}
     196
    171197
    172198void RingProcessor::getRingRange(int& min, int&max) {
  • trunk/ArchTOIPipe/Kernel/ringprocessor.h

    r2385 r2386  
    55//                               Christophe Magneville
    66//                               Reza Ansari
    7 // $Id: ringprocessor.h,v 1.1 2003-05-19 23:31:29 aubourg Exp $
     7// $Id: ringprocessor.h,v 1.2 2003-05-20 10:10:09 aubourg Exp $
    88
    99
     
    5252  virtual int getWontNeedBefore() {return wontNeedRing;}
    5353
     54  virtual void setNeededRingHistory(int nrings); // -1 : disable
    5455 
    5556protected:
     
    6061  RingPipe*        getInputRing(int index);
    6162  RingPipe*        getOutputRing(int index);
     63  RingPipe*        getOutRing(string out);
    6264  virtual void wontNeedRingBefore(int i); 
    6365  friend class RingPipe;
     66  friend class TOIManager;
    6467  virtual void getRingRange(int& min, int& max);
    6568
     
    6871  int ringEnd;
    6972  int wontNeedRing;
     73  int neededRingHistory;
     74
     75  void autoWontNeedRing(int iCur);
     76  int lastAWNR;
    7077
    7178  map<string, int> inRingIx;
  • trunk/ArchTOIPipe/Kernel/toimanager.cc

    r2385 r2386  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: toimanager.cc,v 1.21 2003-05-19 23:31:29 aubourg Exp $
     5// $Id: toimanager.cc,v 1.22 2003-05-20 10:10:09 aubourg Exp $
    66
    77#include "toimanager.h"
     
    4242  cout << "Adding processor to TOIManager for group execution" << endl;
    4343  processors.push_back(proc);
     44 
     45}
     46
     47void TOIManager::registerProcessor(RingProcessor* proc) {
     48 
     49  cout << "Adding processor to TOIManager for group execution" << endl;
     50  ringProcessors.push_back(proc);
    4451 
    4552}
     
    8087    cout << "processor started " << endl;
    8188  }
     89
     90  for (vector<RingProcessor*>::iterator i = ringProcessors.begin();
     91       i != ringProcessors.end(); i++) {
     92    RingProcessor* proc = *i;
     93    cout << "**********************" <<  endl;
     94    cout << "starting processor " <<  endl;
     95    proc->start();
     96    cout << "processor started " << endl;
     97  }
    8298  cout << "**********************" << endl;
     99}
     100
     101void TOIManager::checkRingLimits()
     102{
     103  int min=0;
     104  int max = MAXINT;
     105  for (int pass=0; pass<2; pass++) {
     106    for (vector<RingProcessor*>::iterator i = ringProcessors.begin();
     107         i != ringProcessors.end(); i++) {
     108      RingProcessor* proc = *i;
     109      proc->getRingRange(min, max);
     110    }
     111  }
    83112}
    84113
     
    162191}
    163192
     193RingPipe& TOIManager::connect(RingProcessor& pout, string out,
     194                              RingProcessor& pin, string in) {
     195  RingPipe* pipe;
     196  char buff[128];
     197  sprintf(buff, "Ring_[%s-%s]",  in.c_str(), out.c_str());
     198  if ((pipe = pout.getOutRing(out)) == NULL) {
     199    pipe = new RingPipe();
     200    pout.addRingOutput(out, pipe);
     201  }
     202
     203  pin.addRingInput(in, pipe);
     204  return(*pipe);
     205}
     206
    164207// methode connect de cgt simplifiee et corrigee
    165208TOI& TOIManager::connect(TOIProcessor& prout, string out,
     
    169212  if (nom.length() < 1) {
    170213    char buff[128];
    171     sprintf(buff, "TOI%s_[%s-%s]", nom, in, out);
     214    sprintf(buff, "TOI%s_[%s-%s]", nom.c_str(), in.c_str(), out.c_str());
    172215    nom = buff;
    173216  }
     
    230273  int nbmax_dns_print = 2;
    231274
    232   TOIManager* mgr = TOIManager::getManager();
     275  //  TOIManager* mgr = TOIManager::getManager();
    233276 
    234277  //  istart = mgr->getRequestedBegin();
     
    263306      nb_dns_print++;
    264307      fracperc = (double)processed_samples*100./(double)total_sample_count;
    265       fperc = fracperc*100;
     308      fperc = (int)(fracperc*100);
    266309      cout << ">>> " << _msg << ": ProcessedSampleCount()= " << last_sample_count
    267310           << " Frac done = " << (double)fperc/100. << " %" << endl;
     
    271314    else if ((nb_sleep+1)%5 == 0) {
    272315      fracperc = (double)processed_samples*100./(double)total_sample_count;
    273       fperc = fracperc*100;
     316      fperc = (int)(fracperc*100);
    274317      cout << "> " << _msg << ": ProcSamples()= " <<  processed_samples
    275318           << " Done = " << " %" << (double)fperc/100.
  • trunk/ArchTOIPipe/Kernel/toimanager.h

    r2225 r2386  
    55//                               Christophe Magneville
    66//                               Reza Ansari
    7 // $Id: toimanager.h,v 1.17 2002-10-23 21:57:40 aubourg Exp $
     7// $Id: toimanager.h,v 1.18 2003-05-20 10:10:09 aubourg Exp $
    88
    99
     
    1616
    1717#include "toiprocessor.h"
     18#include "ringprocessor.h"
    1819
    1920
    20 // -----------ajout cgt vf 19/08/2002
    21 
    2221#include "toi.h"
     22#include "ringpipe.h"
    2323
    2424#include <typeinfo>
     
    3434
    3535#include <pthread.h>
    36 // ----------fin ajout cgt
     36
    3737
    3838
     
    5151  void startAll();
    5252  bool checkSamplesLimits(int pass);
     53  void checkRingLimits();
    5354
    5455  void waitForAll();
     
    7172  // fin ajout cgt
    7273
    73 
     74  virtual RingPipe& connect(RingProcessor& pout, string out,
     75                            RingProcessor& pint, string in);
    7476
    7577
     
    8789  vector<TOIProcessor*> processors;
    8890  void registerProcessor(TOIProcessor* proc);
     91  vector<RingProcessor*> ringProcessors;
     92  void registerProcessor(RingProcessor* proc);
    8993
    9094  friend class TOIProcessor;
     95  friend class RingProcessor;
    9196
    9297  // ajout cgt vf 19/08/2002
Note: See TracChangeset for help on using the changeset viewer.