bool LivenessAnalysis::isLiveAtEnd(const std::string& name, CFGBlock* block) { Timer _t("LivenessAnalysis()", 10); if (name[0] != '#') return true; if (block->successors.size() == 0) return false; int idx = getStringIndex(name); if (!result_cache.count(idx)) { std::unordered_map<CFGBlock*, bool>& map = result_cache[idx]; // Approach: // - Find all uses (blocks where the status is USED) // - Trace backwards, marking all blocks as live-at-end // - If we hit a block that is KILLED, stop for (CFGBlock* b : cfg->blocks) { auto status = liveness_cache[b]->nameStatus(idx); if (status != LivenessBBVisitor::USED) continue; std::deque<CFGBlock*> q; for (CFGBlock* pred : b->predecessors) { q.push_back(pred); } while (q.size()) { CFGBlock* thisblock = q.front(); q.pop_front(); if (map[thisblock]) continue; map[thisblock] = true; if (liveness_cache[thisblock]->nameStatus(idx) != LivenessBBVisitor::KILLED) { for (CFGBlock* pred : thisblock->predecessors) { q.push_back(pred); } } } } } // Note: this one gets counted as part of us_compiling_irgen as well: static StatCounter us_liveness("us_compiling_analysis_liveness"); us_liveness.log(_t.end()); return result_cache[idx][block]; }
/** Parse table workspace to a map of Parameters */ void RefinePowderInstrumentParameters2::parseTableWorkspace(TableWorkspace_sptr tablews, map<string, Parameter>& parammap) { // 1. Process Table column names std::vector<std::string> colnames = tablews->getColumnNames(); map<string, size_t> colnamedict; convertToDict(colnames, colnamedict); int iname = getStringIndex(colnamedict, "Name"); int ivalue = getStringIndex(colnamedict, "Value"); int ifit = getStringIndex(colnamedict, "FitOrTie"); int imin = getStringIndex(colnamedict, "Min"); int imax = getStringIndex(colnamedict, "Max"); int istep = getStringIndex(colnamedict, "StepSize"); if (iname < 0 || ivalue < 0 || ifit < 0) throw runtime_error("TableWorkspace does not have column Name, Value and/or Fit."); // 3. Parse size_t numrows = tablews->rowCount(); for (size_t irow = 0; irow < numrows; ++irow) { string parname = tablews->cell<string>(irow, iname); double parvalue = tablews->cell<double>(irow, ivalue); string fitq = tablews->cell<string>(irow, ifit); double minvalue; if (imin >= 0) minvalue = tablews->cell<double>(irow, imin); else minvalue = -DBL_MAX; double maxvalue; if (imax >= 0) maxvalue = tablews->cell<double>(irow, imax); else maxvalue = DBL_MAX; double stepsize; if (istep >= 0) stepsize = tablews->cell<double>(irow, istep); else stepsize = 1.0; Parameter newpar; newpar.name = parname; newpar.value = parvalue; newpar.minvalue = minvalue; newpar.maxvalue = maxvalue; newpar.stepsize = stepsize; // If empty string, fit is default to be false bool fit = false; if (fitq.size() > 0) { if (fitq[0] == 'F' || fitq[0] == 'f') fit = true; } newpar.fit = fit; parammap.insert(make_pair(parname, newpar)); } return; }
bool DRAL_CLIENT_BINARY_0_IMPLEMENTATION_CLASS::SetTag (void * buffer) { char tag_name [9]; UINT32 size; char * buffer2; char * str; UINT64 * value; struct setTagFormat { UINT64 commandCode : 4; UINT64 variant : 2; UINT64 flags : 4; UINT64 reserved : 6; UINT64 n : 16; UINT64 item_id : 32; UINT64 tag_name : 64; } * commandSetTag; UINT32 n; UINT32 item_id; UINT16 variant; UBYTE flags; commandSetTag=(setTagFormat *)buffer; //the values must be saved because '*buffer' may change if full n=commandSetTag->n; item_id=commandSetTag->item_id; variant=commandSetTag->variant; flags=commandSetTag->flags; buffer2 = (char *) ReadBytes(8); // reading the tag name if (buffer2 == NULL) { return false; } memcpy(tag_name,buffer2,8);//copy the tag name, because '*buffer' may change tag_name[8]='\0'; UINT32 tag_idx = getTagIndex(tag_name, strlen(tag_name)); UINT32 str_idx; switch (variant) { case DRAL0_SINGLEVALUE: value = (UINT64 *)ReadBytes(sizeof(*value)); //the value if (value == NULL) { return false; } dralListener->SetTagSingleValue(item_id, tag_idx,*value,flags); break; case DRAL0_STRING: if (n % 8) { size=n+8-(n % 8); } else { size=n; } buffer2 = (char *) ReadBytes (size); // read the string if (buffer2 == NULL) { return false; } str = new char [size+1]; // +1 for the '\0' strncpy(str,buffer2,n); str[n]='\0'; str_idx = getStringIndex(str, strlen(str)); dralListener->SetTagString(item_id, tag_idx, str_idx, flags); delete [] str; break; case DRAL0_SET: value = (UINT64 *) ReadBytes(n*sizeof(UINT64)); //read the set if (value == NULL) { return false; } dralListener->SetTagSet(item_id, tag_idx, n, value, flags); break; default: dralListener->Error( "Unknown SetTag variant\n" "Please report this bug to [email protected] attaching " "input files (if any)" ); return false; } return true; }