Changeset 1743 in Sophya


Ignore:
Timestamp:
Nov 10, 2001, 12:14:28 AM (24 years ago)
Author:
aubourg
Message:

optim lecture/ecriture en bloc

Location:
trunk/ArchTOIPipe/Kernel
Files:
4 edited

Legend:

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

    r1742 r1743  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: toiprocessor.cc,v 1.15 2001-11-09 23:13:15 aubourg Exp $
     5// $Id: toiprocessor.cc,v 1.16 2001-11-09 23:14:28 aubourg Exp $
    66
    77#include "toiprocessor.h"
     
    394394
    395395void TOIProcessor::putData(int toiIndex, int i, int n, double const* val,
    396                            uint_8 const* flg=0) {
     396                           uint_8 const* flg) {
    397397  TOI* toi = getOutputTOI(toiIndex);
    398398  toi->putData(i, n, val, flg);
  • trunk/ArchTOIPipe/Kernel/toiprocessor.h

    r1738 r1743  
    55//                               Christophe Magneville
    66//                               Reza Ansari
    7 // $Id: toiprocessor.h,v 1.10 2001-11-08 15:47:46 aubourg Exp $
     7// $Id: toiprocessor.h,v 1.11 2001-11-09 23:13:15 aubourg Exp $
    88
    99
     
    6262  double        getData(int toiIndex, int i);
    6363  void          getData(int toiIndex, int i, double &data, uint_8 &flag);
     64
     65  void          getData(int toiIndex, int i, int n, double* d);
     66  void          getData(int toiIndex, int i, int n, double* d, uint_8* f);
    6467 
    6568  //RZCMV  double        getError(int toiIndex, int i);
     
    7376  //RZCMV  void          putDataError(int toiIndex, int i, double value,
    7477  //RZCMV                            double error, int_4 flag=0);
     78
     79  void          putData(int toiIndex, int i, int n, double const* val,
     80                        uint_8 const* flg=0);
    7581
    7682  // Gestion des bornes pour les transformations de TOIs...
  • trunk/ArchTOIPipe/Kernel/toisegment.cc

    r1740 r1743  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: toisegment.cc,v 1.15 2001-11-08 23:23:58 aubourg Exp $
     5// $Id: toisegment.cc,v 1.16 2001-11-09 23:13:15 aubourg Exp $
    66
    77#include "toisegment.h"
     
    6767}
    6868
     69void TOISegmented::getData(int i, int n, double* data, uint_8* flg) { /* reader thread */
     70  master->getData(i, n, data, flg);
     71}
     72
    6973void TOISegmented::putData(int i, double value, uint_8 flag) { /* writer thread */
    7074  master->putData(i, value, flag);
     75}
     76
     77void TOISegmented::putData(int i, int n, double const* val, uint_8 const* flg) { /* writer thread */
     78  master->putData(i, n, val, flg);
    7179}
    7280
     
    152160  delete[] flags;
    153161  pthread_mutex_destroy(&refcount_mutex);
     162}
     163
     164void TOISegmented::BufferSegment::getData(int sn, int n, double* d, uint_8* f) {
     165  checkCommitted();
     166  checkInRange(sn);
     167  checkInRange(sn+n-1);
     168  memcpy(d, data+(sn-sn0), n*sizeof(double));
     169  if (f != NULL) {
     170    memcpy(f, flags+(sn-sn0), n*sizeof(uint_8));
     171  }
    154172}
    155173
     
    166184  data[sn-sn0] = d;
    167185  flags[sn-sn0] = f;
     186}
     187
     188void TOISegmented::BufferSegment::putData(int sn, int n, double const* d, uint_8 const* f) {
     189  checkCommitted();
     190  checkInRange(sn);
     191  checkInRange(sn+n-1);
     192  memcpy(data+(sn-sn0), d, n*sizeof(double));
     193  if (f != NULL) {
     194    memcpy(flags+(sn-sn0), f, n*sizeof(uint_8));
     195  } else {
     196    memset(flags+(sn-sn0), 0, n*sizeof(uint_8));
     197  }
    168198}
    169199
     
    215245  int seg = (sn-sn0)/segmentSize;
    216246  return segments[seg]->getFlag(sn);
     247}
     248
     249void TOISegmented::BufferView::getData(int sn, int n, double* dat, uint_8* flg) { /* Single-thread, reader thread */
     250  ensure(sn);
     251  ensure(sn+n-1);
     252 
     253  int  sn1  = sn;
     254  int  nsam = n;
     255  double* pdat = dat;
     256  uint_8* pflg = flg;
     257
     258  while (true) {
     259    int seg = (sn1-sn0)/segmentSize;
     260    BufferSegment* s = segments[seg];
     261    int snmax = s->sn0 + s->bufferSize - 1;
     262    int sn2 = snmax > (sn1+nsam-1) ? (sn1+nsam-1) : snmax;
     263    int nget = sn2-sn1+1;
     264    s->getData(sn1, nget, pdat, pflg);
     265    pdat += nget;
     266    if (pflg != NULL) pflg += nget;
     267    nsam -= nget;
     268    sn1  += nget;
     269    if (nsam <= 0) break;
     270  }
    217271}
    218272
     
    324378}
    325379
     380void TOISegmented::MasterView::putData(int sn, int n, double const* data, uint_8 const* flags) { /* writer thread */
     381  if (sn0<0) {
     382    LOG(cout << "***MasterView::putData sn0<0" << endl);
     383    sn0=sn;
     384  }
     385  double const*  pdat = data;
     386  uint_8 const*  pflg = flags;
     387  int     nsam  = n;
     388  int     sn1   = sn;
     389  while (true) {
     390    // maximum that current segment can take
     391    int snmax = -1;
     392    if (currentSegment != NULL) {
     393      snmax = currentSegment->sn0 + currentSegment->bufferSize-1;
     394    }
     395    int sn2 = snmax > (sn1+nsam-1) ? (sn1+nsam-1) : snmax;
     396    if (snmax>0) {
     397      int nput = sn2-sn1+1;
     398      currentSegment->putData(sn1, nput, pdat, pflg);
     399      pdat += nput;
     400      if (pflg != NULL) pflg += nput;
     401      nsam -= nput;
     402      sn1  += nput;
     403    }
     404    if (nsam <= 0) break;
     405    nextSegment();
     406    currentSegment->putData(sn1, 0, 0); // dummy, to initialize sn0 in segment : add method ?
     407  }
     408}
     409
    326410double TOISegmented::MasterView::getData(int sn) { /* reader thread */
    327411  return getView()->getData(sn); /* thread-specific */
     
    330414uint_8 TOISegmented::MasterView::getFlag(int sn) { /* reader thread */
    331415  return getView()->getFlag(sn);
     416}
     417
     418void TOISegmented::MasterView::getData(int sn, int n, double* dat, uint_8* flg) { /* reader thread */
     419  getView()->getData(sn, n, dat, flg);
    332420}
    333421
  • trunk/ArchTOIPipe/Kernel/toisegment.h

    r1738 r1743  
    55//                               Christophe Magneville
    66//                               Reza Ansari
    7 // $Id: toisegment.h,v 1.10 2001-11-08 15:47:46 aubourg Exp $
     7// $Id: toisegment.h,v 1.11 2001-11-09 23:13:15 aubourg Exp $
    88
    99#ifndef TOISEGMENT_H
     
    3232  virtual double        getData(int i);
    3333  virtual void          getData(int i, double& data,  uint_8& flag);
     34  virtual void          getData(int i, int n, double* data, uint_8* flg=0);
    3435  virtual void          putData(int i, double  value, uint_8  flag=0);
     36  virtual void          putData(int i, int n, double const* val, uint_8 const* flg=0);
    3537  virtual void          wontNeedBefore(int i);
    3638  virtual void          putDone();
     
    7274   
    7375    void putData(int sn, double data, uint_8 flag);
     76    void putData(int sn, int n, double const* data, uint_8 const* flag);
    7477    inline double getData(int sn);
    7578    inline uint_8 getFlag(int sn);
     79    void getData(int sn, int n, double* data, uint_8* flag);
    7680
    7781    bool isPastEnd(int sn) {
     
    114118    double getData(int sn);
    115119    uint_8 getFlag(int sn);
     120    void   getData(int i, int n, double* data, uint_8* flg);
     121    void   putData(int i, int n, double const* val, uint_8 const* flg);
    116122    BufferView* getView(); // thread-specific
    117123    void putDone();
     
    162168    double getData(int sn);
    163169    uint_8 getFlag(int sn);   
     170    void   getData(int i, int n, double* data, uint_8* flg);
    164171
    165172    void wontNeedBefore(int sn);
Note: See TracChangeset for help on using the changeset viewer.