ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/Development/ray/src/rt/RcontribSimulManager.cpp
(Generate patch)

Comparing ray/src/rt/RcontribSimulManager.cpp (file contents):
Revision 2.16 by greg, Thu Oct 23 01:26:48 2025 UTC vs.
Revision 2.21 by greg, Mon Oct 27 18:38:32 2025 UTC

# Line 116 | Line 116 | formstr(int f)
116          return("unknown");
117   }
118  
119 < // Our default data share function
119 > // Standard file data share function
120   RdataShare *
121 < defDataShare(const char *name, RCOutputOp op, size_t siz)
121 > fileDataShare(const char *name, RCOutputOp op, size_t siz)
122   {
123 <        return new RdataShareMap(name, RSDOflags[op], siz);
123 >        if (op == RCOrecover && access(name, R_OK|W_OK) < 0) {
124 >                sprintf(errmsg, "cannot recover from '%s'", name);
125 >                error(SYSTEM, errmsg);
126 >                return NULL;
127 >        }
128 >        RdataShare *    rds = new RdataShareFile(name, RSDOflags[op],
129 >                                                 siz*(op != RCOforce));
130 >                                                
131 >        if (!rds || (op == RCOforce && rds->Resize(siz) < siz)) {
132 >                delete rds;
133 >                sprintf(errmsg, "cannot create %lu byte output file '%s'",
134 >                                        (unsigned long)siz, name);
135 >                error(SYSTEM, errmsg);
136 >                return NULL;
137 >        }
138 >        return rds;
139   }
140  
141 + // Memory-mapped data share function
142 + RdataShare *
143 + mapDataShare(const char *name, RCOutputOp op, size_t siz)
144 + {
145 +        if (op == RCOrecover && access(name, R_OK|W_OK) < 0) {
146 +                sprintf(errmsg, "cannot recover from '%s'", name);
147 +                error(SYSTEM, errmsg);
148 +                return NULL;
149 +        }
150 +        RdataShare *    rds = new RdataShareMap(name, RSDOflags[op],
151 +                                                 siz*(op != RCOforce));
152 +
153 +        if (!rds || (op == RCOforce && rds->Resize(siz) < siz)) {
154 +                delete rds;
155 +                sprintf(errmsg, "cannot create %lu byte output map '%s'",
156 +                                        (unsigned long)siz, name);
157 +                error(SYSTEM, errmsg);
158 +                return NULL;
159 +        }
160 +        return rds;
161 + }
162 +
163   // Set output format ('f', 'd', or 'c')
164   bool
165   RcontribSimulManager::SetDataFormat(int ty)
# Line 380 | Line 417 | RcontribSimulManager::PrepOutput()
417                          if (rd < 0)
418                                  return -1;
419                          if (rd >= op->nRows) {
420 <                                if (remWarnings >= 0) {
420 >                                if (remWarnings > 0) {
421                                          sprintf(errmsg, "recovered output '%s' is complete",
422                                                          op->GetName());
423                                          error(WARNING, --remWarnings ? errmsg : "etc...");
# Line 397 | Line 434 | RcontribSimulManager::PrepOutput()
434          }
435          rowsDone.NewBitMap(outList->nRows);     // create row completion map
436          rowsDone.ClearBits(0, rInPos, true);
437 <        return rInPos;
437 >        return nrDone = rInPos;
438   }
439  
440   // Create header in open write-only channel
# Line 432 | Line 469 | RcontribOutput::NewHeader(const RcontribSimulManager *
469          sprintf(hdr+begData, "%s%d\n", NCOMPSTR, NCSAMP);
470          begData += strlen(hdr+begData);
471          if (NCSAMP > 3) {
472 <                sprintf(hdr+begData, "%s %f %f %f %f\n", WLSPLTSTR,
472 >                sprintf(hdr+begData, "%s %g %g %g %g\n", WLSPLTSTR,
473                                  WLPART[0], WLPART[1], WLPART[2], WLPART[3]);
474                  begData += strlen(hdr+begData);
475          }
# Line 517 | Line 554 | RcontribOutput::CheckHeader(const RcontribSimulManager
554                  return -1;
555          }
556                                                  // check #columns
557 <        if (((cp = findArgs(hdr, "NCOLS=", begData)) && atoi(cp)*esiz != rowBytes) ||
558 <                        !rcp->xres | (rowBytes > esiz)) {
559 <                sprintf(errmsg, "expected NCOLS=%d in '%s'",
523 <                                int(rowBytes/esiz), GetName());
557 >        if ((cp = findArgs(hdr, "NCOLS=", begData)) ? (atoi(cp)*esiz != rowBytes)
558 >                                                    : (!rcp->xres | (rowBytes > esiz))) {
559 >                sprintf(errmsg, "expected NCOLS=%d in '%s'", int(rowBytes/esiz), GetName());
560                  error(USER, errmsg);
561                  return -1;
562          }
# Line 562 | Line 598 | RcontribSimulManager::ResetRow(int r)
598                          return false;
599  
600          rowsDone.ClearBits(r, rInPos-r, false);
601 <        rInPos = r;
601 >        nrDone = rInPos = r;
602          return true;
603   }
604  
# Line 721 | Line 757 | RcontribSimulManager::UpdateRowsDone(int r)
757                  error(WARNING, "redundant call to UpdateRowsDone()");
758                  return false;
759          }
760 <        int     nDone = GetRowFinished();
761 <        if (nDone <= r)
760 >        GetRowFinished();
761 >        if (nrDone <= r)
762                  return true;                    // nothing to update, yet
763          for (RcontribOutput *op = outList; op; op = op->next)
764 <                if (!op->SetRowsDone(nDone))
764 >                if (!op->SetRowsDone(nrDone))
765                          return false;
766          return true;                            // up-to-date
767   }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)