double IdealGas::sd2p(double s, double d) const { if (d < 0 || s < 0) { UniversalError eo("Imaginary pressure"); eo.AddEntry("Density", d); eo.AddEntry("Entropy", s); throw eo; } return s*pow(d,g_); }
double IdealGas::dp2c(double d, double p) const { if (d < 0 || p < 0) { UniversalError eo("Imaginary Cs"); eo.AddEntry("Density", d); eo.AddEntry("Pressure", p); throw eo; } return sqrt(g_*p/d); }
void ComboBox::OnMouseLeftButtonDown(suic::MouseEventArg& e) { __super::OnMouseLeftButtonDown(e); if (_popup->IsValid()) { _popup->Close(); } else { suic::Point point = suic::SystemHelper::CalcScreenElementPoint(this, CoreFlags::eLeftBottom); suic::Size availableSize; int iWid = RenderSize().cx; _list->Measure(availableSize); _popup->SetWidth(iWid); if (_list->GetDesiredSize().cy > _downHeight || _list->GetDesiredSize().cy <= 16) { _popup->SetHeight(_downHeight); } else { int iHei = _list->GetDesiredSize().cy + _list->GetBorderThickness().top + _list->GetBorderThickness().bottom; _popup->SetHeight(iHei); } _popup->SetOwner(this); _popup->SetPopupRoot(_list.get()); DropDownEventArg eo(_popup, _list); OnDropDownOpened(eo); _popup->TrackingPopup(point.x, point.y, false, 0, 0, new ComboListHookPopup(_popup)); suic::ObjectPtr selObj = _list->SelectedItem(); _list->UnselectAllItems(); OnDropDownClosed(eo); } }
int main() { std::string sock = "Patate"; Network::FileSender<std::string, Thread::Mutex> file(sock); Network::FileReceiver rec; Network::Packet packet("Patate", 6, Protocol::RT_TYPE_ROOM, Protocol::RT_TT_MODIFICATION, 0); Network::Packet eo("", 0, Protocol::RT_TYPE_ROOM, Protocol::RT_TT_MODIFICATION, 0); file << "Test.txt"; --file; --file; rec << "Patate.txt"; rec += packet; rec << "TonBoule.txt"; rec += packet; rec += eo; return (0); }
int ORD::find_elim_ordering() { int ws; int wr; char eoname[512]; char eoname_other[512]; // Get size and rank from the communicator MPI_Comm_size(comm, &ws); MPI_Comm_rank(comm, &wr); double xtime = MPI_Wtime(); sprintf(eoname, "%s.order.%d", this->filename.c_str(), ws); sprintf(eoname_other, "%s.order_other.%d", this->filename.c_str(), ws); DEBUG("size: %d, rank %d \n", ws, wr); int n = G->get_num_nodes(); int x = n/ws; int xm = n%ws; int i = 0; DEBUG("n: %d x: %d xm: %d \n", n, x, xm); vector<int> xadj; vector<int> adjncy; vector<int> vtxdist(ws + 1, 0); vector<int> sizes(2*ws,0); vector<int> ordering(x+1, 0); vector<int> recvcnt(ws, 0); vector<int> displ(ws, 0); int numflag = 0; int options[10]; options[0] = 0; vtxdist[0] = 0; for (i = 1; i <= ws; i++) { vtxdist[i] = vtxdist[i - 1] + x; if (i <= xm) vtxdist[i]++; } // prepareing displacement and receive counts to use with MPI_Gatherv for (i = 0; i < ws; i++) { recvcnt[i] = x; if (i < xm) recvcnt[i] ++; if (i > 0) displ[i] += displ[i - 1] + recvcnt[i - 1]; } DEBUG("range: %d, %d\n", vtxdist[wr], vtxdist[wr + 1]); int j = 0; xadj.push_back(0); for (i = vtxdist[wr]; i < vtxdist[wr + 1]; i++) { Graph::Node *no = G->get_node(i); list<int> *l = no->get_nbrs_ptr(); list<int>::iterator it = l->begin(); for (; it != l->end(); ++it) { adjncy.push_back(*it); j++; } xadj.push_back(j); } if (METIS_OK != ParMETIS_V3_NodeND(&vtxdist.front(), &xadj.front(), &adjncy.front(), &numflag, options, &ordering.front(), &sizes.front(), &comm)) { FERROR("error occured while processing parmetis, aborting\n"); MPI_Abort(MPI_COMM_WORLD, -1); } DEBUG("output from ParMETIS\n"); double parmet_time = MPI_Wtime() - xtime; vector<int> recvbuf; n = G->get_num_nodes(); if (wr == 0) { recvbuf = vector<int>(n, 0); } if (MPI_SUCCESS != MPI_Gatherv((void *)&ordering.front(), recvcnt[wr], MPI_INT, (void *)&recvbuf.front(), &recvcnt.front(), &displ.front(), MPI_INT, 0, comm)) { FERROR("MPI error occured at Gatherv, Abort!\n"); MPI_Abort(comm, -1); } vector<int> eo(n, 0); if (wr == 0) { for (int i = 0; i < n; i++) { eo[recvbuf[i]] = i; } FILE *f = fopen(eoname_other, "w"); for (int i = 0; i < n; i++) fprintf(f, "%d\n", eo[i] + 1); fclose(f); DEBUG("ParMetis NodeND elimination ordering is in : %s\n", eoname_other); } ordering.clear(); ordering.resize(recvcnt[wr], 0); if (MPI_SUCCESS != MPI_Scatterv ((void *)&eo.front(), &recvcnt.front(), &displ.front(), MPI_INT, (void *)&ordering.front(), recvcnt[wr], MPI_INT, 0, comm)) { FERROR("MPI error occured at Scatterv, Abort! \n"); MPI_Abort(comm, -1); } DEBUG("Scatterv completed\n"); Graph::GraphCreatorFile gf; Graph::VertexWeightedGraph *wg; Graph::GraphEOUtil eoutil; Graph::GraphProperties prop; list<int>members(ordering.begin(), ordering.end()); wg = gf.create_component(G, &members, false); prop.make_canonical(wg); vector<int> ord(recvcnt[wr], 0); vector<int> ordsend(recvcnt[wr, 0]); double xxtime = MPI_Wtime(); eoutil.find_elimination_ordering(wg, &ord, GD_AMD, false); DEBUG("eo time : %f\n", MPI_Wtime() - xxtime); int sz = recvcnt[wr]; for (int i = 0; i < sz; i++) ordsend[i] = wg->get_node(ord[i])->get_label(); recvbuf.assign(n, -1); if (MPI_SUCCESS != MPI_Gatherv((void *)&ordsend.front(), recvcnt[wr], MPI_INT, (void *)&recvbuf.front(), &recvcnt.front(), &displ.front(), MPI_INT, 0, comm)) { FERROR("MPI error occured at Gatherv, Abort!\n"); MPI_Abort(comm, -1); } double p_amd_time = MPI_Wtime() - xtime; if (wr == 0) { FILE *f = fopen(eoname, "w"); for (int i = 0; i < n && wr == 0; i++) fprintf(f, "%d\n", recvbuf[i]); fclose(f); } DEBUG("ordering is written into %s\n", eoname); DEBUG("%f,%f\n", parmet_time, p_amd_time); return 0; }
forceinline ExecStatus edgefinding(Space& home, int c, TaskViewArray<TaskView>& t) { sort<TaskView,STO_LCT,false>(t); Region r(home); /////////////////////// // Detection int* prec = r.alloc<int>(t.size()); for (int i=t.size(); i--; ) prec[i] = t[i].ect(); OmegaLambdaTree<TaskView> ol(r,c,t); for (int j=0; j<t.size(); j++) { while (!ol.lempty() && (ol.lenv() > static_cast<long long int>(c)*t[j].lct())) { int i = ol.responsible(); prec[i] = std::max(prec[i], t[j].lct()); ol.lremove(i); } ol.shift(j); } /////////////////////// // Propagation // Compute array of unique capacities and a mapping // from the task array to the corresponding entry in // the capacity array int* cap = r.alloc<int>(t.size()); for (int i=t.size(); i--;) cap[i] = i; SortMap<TaskView,StoCap,true> o(t); Support::quicksort(cap, t.size(), o); int* capacities = r.alloc<int>(t.size()); int* capInv = r.alloc<int>(t.size()); for (int i=t.size(); i--;) { capacities[cap[i]] = t[i].c(); capInv[cap[i]] = i; } int n_c = 0; for (int i=0, cur_c=INT_MIN; i<t.size(); i++) { if (capacities[i] != cur_c) capacities[n_c++] = cur_c = capacities[i]; cap[capInv[i]] = n_c-1; } r.free<int>(capInv, t.size()); // Compute update values for each capacity and LCut int* update = r.alloc<int>(t.size()*n_c); for (int i=t.size()*n_c; i--;) update[i] = -Int::Limits::infinity; ExtOmegaTree<TaskView> eo(r,c,ol); for (int i=0; i<n_c; i++) { eo.init(capacities[i]); int u = -Int::Limits::infinity; for (int j=t.size(); j--;) { long long int lctj = static_cast<long long int>(c-capacities[i])*t[j].lct(); long long int eml = plus(eo.env(j), -lctj); long long int diff_l; if (eml == -Limits::llinfinity) diff_l = -Limits::llinfinity; else diff_l = ceil_div_xx(eml, static_cast<long long int>(capacities[i])); int diff = (diff_l <= -Limits::infinity) ? -Limits::infinity : static_cast<int>(diff_l); u = std::max(u,diff); update[i*t.size()+j] = u; } } // Update est by iterating in parallel over the prec array // and the task array, both sorted by lct int* precMap = r.alloc<int>(t.size()); for (int i=t.size(); i--;) precMap[i] = i; PrecOrder po(prec); Support::quicksort(precMap, t.size(), po); int curJ = 0; for (int i=0; i<t.size(); i++) { // discard any curJ with lct > prec[i]: while (curJ < t.size() && t[curJ].lct() > prec[precMap[i]]) curJ++; if (curJ >= t.size()) break; // if lct[curJ] == prec[i], then LCut(T,j) <= i, so update est[i] int locJ = curJ; do { if (t[locJ].lct() != t[precMap[i]].lct()) { GECODE_ME_CHECK(t[precMap[i]].est(home,update[cap[precMap[i]]*t.size()+locJ])); break; } } while (t[locJ].lct() == prec[precMap[i]] && locJ++ < t.size() - 1); } return ES_OK; }