Changeset 1743 in Sophya
- Timestamp:
- Nov 10, 2001, 12:14:28 AM (24 years ago)
- Location:
- trunk/ArchTOIPipe/Kernel
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/Kernel/toiprocessor.cc
r1742 r1743 3 3 // Christophe Magneville 4 4 // Reza Ansari 5 // $Id: toiprocessor.cc,v 1.1 5 2001-11-09 23:13:15aubourg Exp $5 // $Id: toiprocessor.cc,v 1.16 2001-11-09 23:14:28 aubourg Exp $ 6 6 7 7 #include "toiprocessor.h" … … 394 394 395 395 void TOIProcessor::putData(int toiIndex, int i, int n, double const* val, 396 uint_8 const* flg =0) {396 uint_8 const* flg) { 397 397 TOI* toi = getOutputTOI(toiIndex); 398 398 toi->putData(i, n, val, flg); -
trunk/ArchTOIPipe/Kernel/toiprocessor.h
r1738 r1743 5 5 // Christophe Magneville 6 6 // Reza Ansari 7 // $Id: toiprocessor.h,v 1.1 0 2001-11-08 15:47:46aubourg Exp $7 // $Id: toiprocessor.h,v 1.11 2001-11-09 23:13:15 aubourg Exp $ 8 8 9 9 … … 62 62 double getData(int toiIndex, int i); 63 63 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); 64 67 65 68 //RZCMV double getError(int toiIndex, int i); … … 73 76 //RZCMV void putDataError(int toiIndex, int i, double value, 74 77 //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); 75 81 76 82 // Gestion des bornes pour les transformations de TOIs... -
trunk/ArchTOIPipe/Kernel/toisegment.cc
r1740 r1743 3 3 // Christophe Magneville 4 4 // Reza Ansari 5 // $Id: toisegment.cc,v 1.1 5 2001-11-08 23:23:58aubourg Exp $5 // $Id: toisegment.cc,v 1.16 2001-11-09 23:13:15 aubourg Exp $ 6 6 7 7 #include "toisegment.h" … … 67 67 } 68 68 69 void TOISegmented::getData(int i, int n, double* data, uint_8* flg) { /* reader thread */ 70 master->getData(i, n, data, flg); 71 } 72 69 73 void TOISegmented::putData(int i, double value, uint_8 flag) { /* writer thread */ 70 74 master->putData(i, value, flag); 75 } 76 77 void TOISegmented::putData(int i, int n, double const* val, uint_8 const* flg) { /* writer thread */ 78 master->putData(i, n, val, flg); 71 79 } 72 80 … … 152 160 delete[] flags; 153 161 pthread_mutex_destroy(&refcount_mutex); 162 } 163 164 void 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 } 154 172 } 155 173 … … 166 184 data[sn-sn0] = d; 167 185 flags[sn-sn0] = f; 186 } 187 188 void 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 } 168 198 } 169 199 … … 215 245 int seg = (sn-sn0)/segmentSize; 216 246 return segments[seg]->getFlag(sn); 247 } 248 249 void 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 } 217 271 } 218 272 … … 324 378 } 325 379 380 void 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 326 410 double TOISegmented::MasterView::getData(int sn) { /* reader thread */ 327 411 return getView()->getData(sn); /* thread-specific */ … … 330 414 uint_8 TOISegmented::MasterView::getFlag(int sn) { /* reader thread */ 331 415 return getView()->getFlag(sn); 416 } 417 418 void TOISegmented::MasterView::getData(int sn, int n, double* dat, uint_8* flg) { /* reader thread */ 419 getView()->getData(sn, n, dat, flg); 332 420 } 333 421 -
trunk/ArchTOIPipe/Kernel/toisegment.h
r1738 r1743 5 5 // Christophe Magneville 6 6 // Reza Ansari 7 // $Id: toisegment.h,v 1.1 0 2001-11-08 15:47:46aubourg Exp $7 // $Id: toisegment.h,v 1.11 2001-11-09 23:13:15 aubourg Exp $ 8 8 9 9 #ifndef TOISEGMENT_H … … 32 32 virtual double getData(int i); 33 33 virtual void getData(int i, double& data, uint_8& flag); 34 virtual void getData(int i, int n, double* data, uint_8* flg=0); 34 35 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); 35 37 virtual void wontNeedBefore(int i); 36 38 virtual void putDone(); … … 72 74 73 75 void putData(int sn, double data, uint_8 flag); 76 void putData(int sn, int n, double const* data, uint_8 const* flag); 74 77 inline double getData(int sn); 75 78 inline uint_8 getFlag(int sn); 79 void getData(int sn, int n, double* data, uint_8* flag); 76 80 77 81 bool isPastEnd(int sn) { … … 114 118 double getData(int sn); 115 119 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); 116 122 BufferView* getView(); // thread-specific 117 123 void putDone(); … … 162 168 double getData(int sn); 163 169 uint_8 getFlag(int sn); 170 void getData(int i, int n, double* data, uint_8* flg); 164 171 165 172 void wontNeedBefore(int sn);
Note:
See TracChangeset
for help on using the changeset viewer.