//Guanzhou added for parallel int DM04_PF::sendSelf(int commitTag, Channel &theChannel) { int dataTag = this->getDbTag(); static ID idData(24); idData.Zero(); idData(0) = e0_which; idData(12) = index_e0; idData(1) = e_r_which; idData(13) = index_e_r; idData(2) = lambda_c_which; idData(14) = index_lambda_c; idData(3) = xi_which; idData(15) = index_xi; idData(4) = Pat_which; idData(16) = index_Pat; idData(5) = m_which; idData(17) = index_m; idData(6) = M_cal_which; idData(18) = index_M_cal; idData(7) = cc_which; idData(19) = index_cc; idData(8) = A0_which; idData(20) = index_A0; idData(9) = nd_which; idData(21) = index_nd; idData(10) = alpha_which; idData(22) = index_alpha; idData(11) = z_which; idData(23) = index_z; if (theChannel.sendID(dataTag, commitTag, idData) < 0) { opserr << "DM04_PF::sendSelf -- failed to send ID\n"; return -1; } return 0; }
//Guanzhou added for parallel int DM04_PF::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { int dataTag = this->getDbTag(); static ID idData(24); idData.Zero(); if (theChannel.recvID(dataTag, commitTag, idData) < 0) { opserr << "DM04_PF::recvSelf -- failed to recv ID\n"; return -1; } e0_which = idData(0); index_e0 = idData(12); e_r_which = idData(1); index_e_r = idData(13); lambda_c_which = idData(2); index_lambda_c= idData(14); xi_which = idData(3); index_xi = idData(15); Pat_which = idData(4); index_Pat = idData(16); m_which = idData(5); index_m = idData(17); M_cal_which = idData(6); index_M_cal = idData(18); cc_which = idData(7); index_cc = idData(19); A0_which = idData(8); index_A0 = idData(20); nd_which = idData(9); index_nd = idData(21); alpha_which = idData(10); index_alpha = idData(22); z_which = idData(11); index_z = idData(23); return 0; }
int PetscSOE::addA(const Matrix &m, const ID &id, double fact) { isFactored = 0; // check for a quick return if (fact == 0.0) return 0; // check that m and id are of similar size int idSize = id.Size(); if (idSize != m.noRows() && idSize != m.noCols()) { opserr << "PetscSOE::addA() - Matrix and ID not of similar sizes\n"; return -1; } int n = id.Size(); int row; int col; double value; for (int i=0; i<n; i++) { row = id(i); if (row >= 0) { for (int j=0; j<n; j++) { col = id(j); if (col >= 0) { value = m(i,j)*fact; int ierr = MatSetValues(A,1,&row,1,&col,&value,ADD_VALUES); CHKERRA(ierr); } } } } return 0; }
//Guanzhou added for parallel int SANISAND_alpha_Eij::sendSelf(int commitTag, Channel &theChannel) { int dataTag = this->getDbTag(); static ID idData(13); idData.Zero(); idData(0) = e0_index; idData(1) = e_r_index; idData(2) = lambda_index; idData(3) = xi_index; idData(4) = Pat_index; idData(5) = alpha_cc_index; idData(6) = c_index; idData(7) = nb_index; idData(8) = h0_index; idData(9) = ch_index; idData(10) = G0_index; idData(11) = m_index; idData(12) = alpha_index; if (theChannel.sendID(dataTag, commitTag, idData) < 0) { opserr << "SANISAND_alpha_Eij::sendSelf -- failed to send ID\n"; return -1; } return 0; }
void AccountMap::Find( const ID& id, const class Account* account ) { SkipListNode* node = Next(ninf); size_t i = id.find_first_of("?*"); string id_key; bool key_not_used = true; if (i == string::npos) { id_key = id; key_not_used = false; if(!Find(id_key, node)) node = Next(node); } else if (i > 0) { id_key = id.substr(0, i); key_not_used = false; if(!Find(id_key, node)) node = Next(node); } bool comma = false; while (node->data_id.front() != '{' && (key_not_used || \ node->data_id.compare(0, i, id_key) == 0)) { if (match_recursion(id, node->data_id, 0, 0) && \ account != node->data_account) { if (comma) { cout << ','; } cout << node->data_id; comma = true; } node = Next(node); } }
//Guanzhou added for parallel int SANISAND_alpha_Eij::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { int dataTag = this->getDbTag(); static ID idData(13); idData.Zero(); if (theChannel.recvID(dataTag, commitTag, idData) < 0) { opserr << "SANISAND_alpha_Eij::recvSelf -- failed to recv ID\n"; return -1; } e0_index = idData(0); e_r_index = idData(1); lambda_index = idData(2); xi_index = idData(3); Pat_index = idData(4); alpha_cc_index = idData(5); c_index = idData(6); nb_index = idData(7); h0_index = idData(8); ch_index = idData(9); G0_index = idData(10); m_index = idData(11); alpha_index = idData(12); return 0; }
int PetscSOE::addB(const Vector &v, const ID &id, double fact) { // check for a quick return if (fact == 0.0) return 0; // check that m and id are of similar size int idSize = id.Size(); if (idSize != v.Size() ) { opserr << "PetscSOE::addB() - Vector and ID not of similar sizes\n"; return -1; } int n = id.Size(); int row; double value; for (int i=0; i<n; i++) { row = id(i); if (row >= 0) { value = v(i) * fact; int ierr = VecSetValues(b,1,&row,&value,ADD_VALUES); CHKERRA(ierr); } } return 0; }
void AccountMap::Existing( const ID& id ) { vector<ID*> list_id(10); vector<int> list_score(10); int target_score = 1; int num_compare = id.size() - 1; int score_temp; int size = 0; SkipListNode* front; SkipListNode* back; // Set the iteratro go to front and back Find(id, front); back = Next(front); // Stop when get enough data, or two iterator are at the end while ((front->data_id.front() != '!' || back->data_id.front() != '{') && \ (size != 10 || list_score[10] > target_score) ) { // First move front iteratro while (front->data_id.front() != '!' && \ (num_compare == 0 || id.compare(0, num_compare, front->data_id, 0, num_compare) == 0) ) { score_temp = calculate_score(id, front->data_id); if (size < 10 || score_temp <= list_score.back()) { insert_id_to_vector(list_id, list_score, 0, front->data_id, score_temp, size); } front = Previous(front); } // If get enough data, stop if (size == 10 && list_score[10] <= target_score) break; // If data is not enough, move back iterator while (back->data_id.front() != '{' && \ (num_compare == 0 || id.compare(0, num_compare, back->data_id, 0, num_compare) == 0) ) { score_temp = calculate_score(id, back->data_id); if (size < 10 || score_temp < list_score.back()) { insert_id_to_vector(list_id, list_score, 1, back->data_id, score_temp, size); } back = Next(back); } // Add the tolerent to score, adjust the number of string to compare target_score += 1; if (num_compare > 0) num_compare -= 1; } // Print the result bool comma = false; for (int i = 0; i < (int)list_score.size(); ++i) { if (comma) { cout << ','; } cout << *(list_id[i]); comma = true; } }
/** * Try to read data from file into newly allocated array and pass * to ID * pre! old and new ID have the same data size (uncorrupted) * and same endianness */ int FileChannel::recvID(int dbTag, int commitTag, ID &theID, ChannelAddress *theAddress) { int nleft,size,i; size = theID.Size(); int *data = new int[size]; void * gMsg = (void *)data;; nleft = theID.Size() * sizeof(int); if( theFile ) { i = fread( gMsg, nleft, 1, theFile); if ( i == 1 ) { theID.setData( data, size ); return 0; } opserr << "FileChannel::recvID, error reading from open file\n"; } else opserr << "FileChannel::recvID, error reading, NULL file handle\n"; return -1; }
int main(void) { loading loads; loads.load(); IF instructionFetch; ID instructionDecode; EX aluExecution; DM dataMemoryAccess; WB writeBack; result results; hazard hazardDetect; fstream outputs, errors; outputs.open("snapshot.rpt", ios::out | ios::binary ); errors.open("error_dump.rpt", ios::out | ios::binary ); while(1){ results.output(outputs); writeBack.exe(); results.errorDetect(errors); dataMemoryAccess.exe(); results.errorDetect(errors); aluExecution.exe(); results.errorDetect(errors); if( declaration::halt >= 5 ) break; instructionDecode.exe(); instructionFetch.exe(); hazardDetect.exe(); if( declaration::halt >= 5 ) break; } outputs.close(); return 0; }
XC::DriftRecorder::DriftRecorder(const ID &nI,const ID &nJ, int df,int dirn, Domain &theDom, DataOutputHandler &theDataOutputHandler, bool timeFlag) :HandlerRecorder(RECORDER_TAGS_DriftRecorder,theDom,theDataOutputHandler,timeFlag), ndI(nullptr), ndJ(nullptr), theNodes(0), dof(df), perpDirn(dirn), oneOverL(), data(), numNodes(0) { assert(nI.Size()==nJ.Size()); set_ndIJ(nI,nJ); }
Features::Features() { assert(_all.empty()); if (parameter::use_item_features()) { const FeaturePtrs& l = (FeaturePtrs&)ItemFeatures::instance()->all(); _all.insert(_all.end(), l.begin(), l.end()); } if (parameter::use_length_features()) { const FeaturePtrs& l = (FeaturePtrs&)LengthFeatures::instance()->all(); _all.insert(_all.end(), l.begin(), l.end()); } if (parameter::use_quant_features()) { const FeaturePtrs& l = (FeaturePtrs&)QuantFeatures::instance()->all(); _all.insert(_all.end(), l.begin(), l.end()); } if (parameter::use_exists_features()) { const FeaturePtrs& l = (FeaturePtrs&)ExistsFeatures::instance()->all(); _all.insert(_all.end(), l.begin(), l.end()); } if (parameter::use_exists_terminal_features()) { const FeaturePtrs& l = (FeaturePtrs&)ExistsTerminalFeatures::instance()->all(); _all.insert(_all.end(), l.begin(), l.end()); } if (parameter::use_item_child_features()) { const FeaturePtrs& l = (FeaturePtrs&)ItemChildFeatures::instance()->all(); _all.insert(_all.end(), l.begin(), l.end()); } if (parameter::use_range_features()) { const FeaturePtrs& l = (FeaturePtrs&)RangeFeatures::instance()->all(); _all.insert(_all.end(), l.begin(), l.end()); } if (parameter::use_terminal_item_features()) { const FeaturePtrs& l = (FeaturePtrs&)TerminalItemFeatures::instance()->all(); _all.insert(_all.end(), l.begin(), l.end()); } for (FeaturePtrs::const_iterator f = _all.begin(); f != _all.end(); f++) { _id_to_ptr[(*f)->id()] = *f; } _id_to_ptr.lock(); // Lock against subsequent writes. assert(_all.size() == _id_to_ptr.size()); this->create_string_map(); Debug::log(2) << "Features::Features() built " << _all.size() << " features\n"; EMPTY_FEATURE_ID.create(); assert(!EMPTY_FEATURE_ID.empty()); }
///////////////////////////////////// // // C O P Y - C O N S T R U C T O R // ///////////////////////////////////// // Pre-Condition: object of type ID passed as value parameter. // Post-Condition: return value is a value of class ID ID::ID( const ID& origID ) { // pass original as a vlaue paraeter // initializes a new object from an existing object. // copies the values in the data members from the origID // uses new to allocate a new name_ char array pointer by origID name_ = new char[ 10 ]; // char *tempPtr = origID->GetName(); this->SetName( origID.GetName() ); this->SetAge( origID.GetAge() ); }
Matrix Matrix::operator()(const ID &rows, const ID & cols) const { int nRows, nCols; nRows = rows.Size(); nCols = cols.Size(); Matrix result(nRows,nCols); double *dataPtr = result.data; for (int i=0; i<nCols; i++) for (int j=0; j<nRows; j++) *dataPtr++ = (*this)(rows(j),cols(i)); return result; }
// Score function int calculate_score( const ID& a, const ID& b ) { int len_a = a.size(); int len_b = b.size(); int s = 0; int L = (len_a < len_b) ? len_a:len_b; int dL = abs(len_a - len_b); s = dL * (dL + 1) / 2; for (int i = L-1; i >= 0; --i) { s += ((a[i] == b[i]) ? 0:(L-i)); } return s; }
int DistributedSparseGenColLinSOE::addB(const Vector &v, const ID &id, double fact) { // check for a quick return if (fact == 0.0) return 0; int idSize = id.Size(); // check that m and id are of similar size if (idSize != v.Size() ) { opserr << "SparseGenColLinSOE::addB() "; opserr << " - Vector and ID not of similar sizes\n"; return -1; } if (fact == 1.0) { // do not need to multiply if fact == 1.0 for (int i=0; i<idSize; i++) { int pos = id(i); if (pos <size && pos >= 0) myB[pos] += v(i); } } else if (fact == -1.0) { // do not need to multiply if fact == -1.0 for (int i=0; i<idSize; i++) { int pos = id(i); if (pos <size && pos >= 0) myB[pos] -= v(i); } } else { for (int i=0; i<idSize; i++) { int pos = id(i); if (pos <size && pos >= 0) myB[pos] += v(i) * fact; } } return 0; }
void Mesh::addEleNodes(const ID& tags) { for (int i=0; i<tags.Size(); ++i) { elenodes.insert(tags(i)); } }
//Guanzhou added for parallel int Linear_Eeq::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { int dataTag = this->getDbTag(); static ID idData(1); idData.Zero(); if (theChannel.recvID(dataTag, commitTag, idData) < 0) { opserr << "Linear_Eeq::recvSelf -- failed to recv ID\n"; return -1; } LinearFactor_index = idData(0); return 0; }
//Guanzhou added for parallel int Linear_Eeq::sendSelf(int commitTag, Channel &theChannel) { int dataTag = this->getDbTag(); static ID idData(1); idData.Zero(); idData(0) = LinearFactor_index; if (theChannel.sendID(dataTag, commitTag, idData) < 0) { opserr << "Linear_Eeq::sendSelf -- failed to send ID\n"; return -1; } return 0; }
int NodeLocations::addPartition(int partition) { if (nodePartitions.insert(partition) != 1) numPartitions++; return 0; }
int IncrementalIntegrator::getLastResponse(Vector &result, const ID &id) { if (theSOE == 0) { opserr << "WARNING IncrementalIntegrator::getLastResponse() -"; opserr << "no LineaerSOE object associated with this object\n"; return -1; } int res = 0; int size = theSOE->getNumEqn() -1; const Vector &X = theSOE->getX(); for (int i=0; i<id.Size(); i++) { int loc = id(i); if (loc < 0 ) result(i) = 0.0; else if (loc <= size) { result(i) = X(loc); } else { opserr << "WARNING IncrementalIntegrator::getLastResponse() -"; opserr << "location " << loc << "in ID outside bounds "; opserr << size << "\n"; res = -2; } } return res; }
int ItpackLinSOE::addA(const Matrix &m, const ID &id, double fact) { // check for a quick return if (fact == 0.0) return 0; int idSize = id.Size(); // check that m and id are of similar size if (idSize != m.noRows() && idSize != m.noCols()) { opserr << "ItpackLinSOE::addA() "; opserr << " - Matrix and ID not of similar sizes\n"; return -1; } if (fact == 1.0) { // do not need to multiply for (int i=0; i<idSize; i++) { int row = id(i); if (row < size && row >= 0) { int startRowLoc = rowStartA[row]; int endRowLoc = rowStartA[row+1]; for (int j=0; j<idSize; j++) { int col = id(j); if (col <size && col >= 0) { // find place in A using colA for (int k=startRowLoc; k<endRowLoc; k++) if (colA[k] == col) { A[k] += m(i,j); k = endRowLoc; } } } // for j } } // for i } else { for (int i=0; i<idSize; i++) { int row = id(i); if (row < size && row >= 0) { int startRowLoc = rowStartA[row]; int endRowLoc = rowStartA[row+1]; for (int j=0; j<idSize; j++) { int col = id(j); if (col <size && col >= 0) { // find place in A using colA for (int k=startRowLoc; k<endRowLoc; k++) if (colA[k] == col) { A[k] += fact * m(i,j); k = endRowLoc; } } } // for j } } // for i } return 0; }
MaxNodeDispRecorder::MaxNodeDispRecorder(int theDof, const ID &nodes, Domain &theDom) :Recorder(RECORDER_TAGS_MaxNodeDispRecorder), theNodes(nodes), maxDisp(nodes.Size()), dof(theDof), theDomain(&theDom) { if (dof < 0) dof = 0; }
std::map< std::string, MB::StrVector > Resources::ResourceLists() { sf::Lock(this->mutex); std::map<std::string,MB::StrVector> ResourceList; std::list<MB::Content::ID*>::iterator typeItr; for (typeItr = this->types.begin(); typeItr != this->types.end(); typeItr++) { ID* resource = (*typeItr); resource->Type(); std::pair<std::string,MB::StrVector> insertPair(resource->Type(),resource->List()); ResourceList.insert(insertPair); } return ResourceList; }
//Guanzhou added for parallel int AF_Eij::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { int dataTag = this->getDbTag(); static ID idData(3); idData.Zero(); if (theChannel.recvID(dataTag, commitTag, idData) < 0) { opserr << "AF_Eij::recvSelf -- failed to recv ID\n"; return -1; } ha_index = idData(0); Cr_index = idData(1); alpha_index = idData(2); return 0; }
//Guanzhou added for parallel int AF_Eij::sendSelf(int commitTag, Channel &theChannel) { int dataTag = this->getDbTag(); static ID idData(3); idData.Zero(); idData(0) = ha_index; idData(1) = Cr_index; idData(2) = alpha_index; if (theChannel.sendID(dataTag, commitTag, idData) < 0) { opserr << "AF_Eij::sendSelf -- failed to send ID\n"; return -1; } return 0; }
virtual void retrieve(const Query& q, Answer& a) throw (dlvhex::PluginError) { #if 0 // get inputs assert(q.input.size() == 2); ID pred = q.input[0]; ID cmp = q.input[1]; LOG(INFO,"calculating above extatom for predicate " << pred << " and symbol " << cmp); const Term& cmpt = registry->terms.getByID(cmp); // get query assert(q.pattern.size() == 1); ID out = q.pattern.front(); // build set of found targets assert(q.interpretation != 0); dlvhex::OrdinaryAtomTable::PredicateIterator it, it_end; assert(registry != 0); for(boost::tie(it, it_end) = registry->ogatoms.getRangeByPredicateID(pred); it != it_end; ++it) { const dlvhex::OrdinaryAtom& oatom = *it; // skip ogatoms not present in interpretation if( !q.interpretation->getFact(registry->ogatoms.getIDByStorage(oatom).address) ) continue; // the edge predicate must be unary assert(oatom.tuple.size() == 2); const Term& t = registry->terms.getByID(oatom.tuple[1]); if( t.symbol >= cmpt.symbol ) { if( (out.isTerm() && out.isVariableTerm()) || (out == oatom.tuple[1]) ) { Tuple t; t.push_back(oatom.tuple[1]); a.get().push_back(t); } } } #endif throw std::runtime_error("todo implement SenseNotArmed1PluginAtom::retrieve"); }
void AccountMap::Unused( const ID& id ) { int target_score = 1; int len = id.size(); int min_len = len - 1; int max_len = (len+1 < 100) ? (len+1):100; int output = 0; bool comma = false; SkipListNode* temp; string test; if (min_len == 0) { test = "0"; } else { test = id.substr(0, min_len); } while (output < 10) { if (calculate_score(test, id) == target_score && !Find(test, temp)) { if (comma) { cout << ','; } cout << test; comma = true; output += 1; } if (!next_string(test, min_len, max_len)) { target_score += 1; min_len = (min_len == 0) ? 0:(min_len-1); if (max_len != 100 && (max_len+1-len+1)*(max_len+1-len)/2 <= target_score) { max_len += 1; } if (min_len == 0) { test = "0"; } else { test = id.substr(0, min_len); } } } }
// Return whether two char* is matching, a may have wildcard bool match_recursion( const ID& a, const ID& b, int pa, int pb ) { if (pa == (int)a.size() && pb == (int)b.size()) { return true; } if (a[pa] == '?' || a[pa] == b[pb]) { return match_recursion(a, b, pa+1, pb+1); } if (a[pa] == '*' && pa+1 != (int)a.size() && pb == (int)b.size()) { return false; } if (a[pa] == '*') { return match_recursion(a, b, pa+1, pb) || match_recursion(a, b, pa, pb+1); } return false; }
//================================================================================ //Guanzhou added for parallel int VM_YF::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { int dataTag = this->getDbTag(); static ID idData(4); idData.Zero(); if (theChannel.recvID(dataTag, commitTag, idData) < 0) { opserr << "VM_YF::recvSelf -- failed to recv ID\n"; return -1; } k_which = idData(0); index_k = idData(1); alpha_which = idData(2); index_alpha = idData(3); return 0; }