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.15 by greg, Fri Oct 17 17:43:53 2025 UTC vs.
Revision 2.22 by greg, Tue Nov 11 00:19:10 2025 UTC

# Line 58 | Line 58 | static const char      ROW_DONE[] = "ROW FINISHED\n";
58   static RcontribMod *
59   NewRcMod(const char *prms, const char *binexpr, int ncbins)
60   {
61 +        if (binexpr && !*binexpr) binexpr = NULL;
62          if (!prms) prms = "";
63          if ((ncbins > 1) & !binexpr) {
64                  error(USER, "missing bin expression");
# Line 115 | 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 165 | Line 203 | RcontribSimulManager::RctCall(RAY *r, void *cd)
203          if (!mp)
204                  return 0;               // not in our modifier list
205  
206 +        if (rcp->HasFlag(RCcontrib) && sintens(r->rcol) <= FTINY)
207 +                return 0;               // zero contribution
208 +
209          int                     bi = 0; // get bin index
210          if (mp->binv) {
211                  worldfunc(RCCONTEXT, r);
# Line 379 | Line 420 | RcontribSimulManager::PrepOutput()
420                          if (rd < 0)
421                                  return -1;
422                          if (rd >= op->nRows) {
423 <                                if (remWarnings >= 0) {
423 >                                if (remWarnings > 0) {
424                                          sprintf(errmsg, "recovered output '%s' is complete",
425                                                          op->GetName());
426                                          error(WARNING, --remWarnings ? errmsg : "etc...");
# Line 396 | Line 437 | RcontribSimulManager::PrepOutput()
437          }
438          rowsDone.NewBitMap(outList->nRows);     // create row completion map
439          rowsDone.ClearBits(0, rInPos, true);
440 <        return rInPos;
440 >        return nrDone = rInPos;
441   }
442  
443   // Create header in open write-only channel
# Line 431 | Line 472 | RcontribOutput::NewHeader(const RcontribSimulManager *
472          sprintf(hdr+begData, "%s%d\n", NCOMPSTR, NCSAMP);
473          begData += strlen(hdr+begData);
474          if (NCSAMP > 3) {
475 <                sprintf(hdr+begData, "%s %f %f %f %f\n", WLSPLTSTR,
475 >                sprintf(hdr+begData, "%s %g %g %g %g\n", WLSPLTSTR,
476                                  WLPART[0], WLPART[1], WLPART[2], WLPART[3]);
477                  begData += strlen(hdr+begData);
478          }
# Line 516 | Line 557 | RcontribOutput::CheckHeader(const RcontribSimulManager
557                  return -1;
558          }
559                                                  // check #columns
560 <        if (((cp = findArgs(hdr, "NCOLS=", begData)) && atoi(cp)*esiz != rowBytes) ||
561 <                        !rcp->xres | (rowBytes > esiz)) {
562 <                sprintf(errmsg, "expected NCOLS=%d in '%s'",
522 <                                int(rowBytes/esiz), GetName());
560 >        if ((cp = findArgs(hdr, "NCOLS=", begData)) ? (atoi(cp)*esiz != rowBytes)
561 >                                                    : (!rcp->xres | (rowBytes > esiz))) {
562 >                sprintf(errmsg, "expected NCOLS=%d in '%s'", int(rowBytes/esiz), GetName());
563                  error(USER, errmsg);
564                  return -1;
565          }
# Line 561 | Line 601 | RcontribSimulManager::ResetRow(int r)
601                          return false;
602  
603          rowsDone.ClearBits(r, rInPos-r, false);
604 <        rInPos = r;
604 >        nrDone = rInPos = r;
605          return true;
606   }
607  
# Line 720 | Line 760 | RcontribSimulManager::UpdateRowsDone(int r)
760                  error(WARNING, "redundant call to UpdateRowsDone()");
761                  return false;
762          }
763 <        int     nDone = GetRowFinished();
764 <        if (nDone <= r)
763 >        GetRowFinished();
764 >        if (nrDone <= r)
765                  return true;                    // nothing to update, yet
766          for (RcontribOutput *op = outList; op; op = op->next)
767 <                if (!op->SetRowsDone(nDone))
767 >                if (!op->SetRowsDone(nrDone))
768                          return false;
769          return true;                            // up-to-date
770   }

Diff Legend

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