/* ** RIOParam is used to open or configure a port. You pass it a PortP, ** which will have a tty struct attached to it. You also pass a command, ** either OPEN or CONFIG. The port's setup is taken from the t_ fields ** of the tty struct inside the PortP, and the port is either opened ** or re-configured. You must also tell RIOParam if the device is a modem ** device or not (i.e. top bit of minor number set or clear - take special ** care when deciding on this!). ** RIOParam neither flushes nor waits for drain, and is NOT preemptive. ** ** RIOParam assumes it will be called at splrio(), and also assumes ** that CookMode is set correctly in the port structure. ** ** NB. for MPX ** tty lock must NOT have been previously acquired. */ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag) { struct tty_struct *TtyP; int retval; struct phb_param __iomem *phb_param_ptr; struct PKT __iomem *PacketP; int res; u8 Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0; u8 TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0; u8 LNext = 0, TxBaud = 0, RxBaud = 0; int retries = 0xff; unsigned long flags; func_enter(); TtyP = PortP->gs.tty; rio_dprintk(RIO_DEBUG_PARAM, "RIOParam: Port:%d cmd:%d Modem:%d SleepFlag:%d Mapped: %d, tty=%p\n", PortP->PortNum, cmd, Modem, SleepFlag, PortP->Mapped, TtyP); if (!TtyP) { rio_dprintk(RIO_DEBUG_PARAM, "Can't call rioparam with null tty.\n"); func_exit(); return RIO_FAIL; } rio_spin_lock_irqsave(&PortP->portSem, flags); if (cmd == RIOC_OPEN) { /* ** If the port is set to store or lock the parameters, and it is ** paramed with OPEN, we want to restore the saved port termio, but ** only if StoredTermio has been saved, i.e. NOT 1st open after reboot. */ } /* ** wait for space */ while (!(res = can_add_transmit(&PacketP, PortP)) || (PortP->InUse != NOT_INUSE)) { if (retries-- <= 0) { break; } if (PortP->InUse != NOT_INUSE) { rio_dprintk(RIO_DEBUG_PARAM, "Port IN_USE for pre-emptive command\n"); } if (!res) { rio_dprintk(RIO_DEBUG_PARAM, "Port has no space on transmit queue\n"); } if (SleepFlag != OK_TO_SLEEP) { rio_spin_unlock_irqrestore(&PortP->portSem, flags); func_exit(); return RIO_FAIL; } rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit\n"); rio_spin_unlock_irqrestore(&PortP->portSem, flags); retval = RIODelay(PortP, HUNDRED_MS); rio_spin_lock_irqsave(&PortP->portSem, flags); if (retval == RIO_FAIL) { rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n"); rio_spin_unlock_irqrestore(&PortP->portSem, flags); func_exit(); return -EINTR; } if (PortP->State & RIO_DELETED) { rio_spin_unlock_irqrestore(&PortP->portSem, flags); func_exit(); return 0; } } if (!res) { rio_spin_unlock_irqrestore(&PortP->portSem, flags); func_exit(); return RIO_FAIL; } rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res); rio_dprintk(RIO_DEBUG_PARAM, "Packet is %p\n", PacketP); phb_param_ptr = (struct phb_param __iomem *) PacketP->data; switch (TtyP->termios->c_cflag & CSIZE) { case CS5: { rio_dprintk(RIO_DEBUG_PARAM, "5 bit data\n"); Cor1 |= RIOC_COR1_5BITS; break; } case CS6: { rio_dprintk(RIO_DEBUG_PARAM, "6 bit data\n"); Cor1 |= RIOC_COR1_6BITS; break; } case CS7: { rio_dprintk(RIO_DEBUG_PARAM, "7 bit data\n"); Cor1 |= RIOC_COR1_7BITS; break; } case CS8: { rio_dprintk(RIO_DEBUG_PARAM, "8 bit data\n"); Cor1 |= RIOC_COR1_8BITS; break; } } if (TtyP->termios->c_cflag & CSTOPB) { rio_dprintk(RIO_DEBUG_PARAM, "2 stop bits\n"); Cor1 |= RIOC_COR1_2STOP; } else { rio_dprintk(RIO_DEBUG_PARAM, "1 stop bit\n"); Cor1 |= RIOC_COR1_1STOP; } if (TtyP->termios->c_cflag & PARENB) { rio_dprintk(RIO_DEBUG_PARAM, "Enable parity\n"); Cor1 |= RIOC_COR1_NORMAL; } else { rio_dprintk(RIO_DEBUG_PARAM, "Disable parity\n"); Cor1 |= RIOC_COR1_NOP; } if (TtyP->termios->c_cflag & PARODD) { rio_dprintk(RIO_DEBUG_PARAM, "Odd parity\n"); Cor1 |= RIOC_COR1_ODD; } else { rio_dprintk(RIO_DEBUG_PARAM, "Even parity\n"); Cor1 |= RIOC_COR1_EVEN; } /* ** COR 2 */ if (TtyP->termios->c_iflag & IXON) { rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop output control\n"); Cor2 |= RIOC_COR2_IXON; } else { if (PortP->Config & RIO_IXON) { rio_dprintk(RIO_DEBUG_PARAM, "Force enable start/stop output control\n"); Cor2 |= RIOC_COR2_IXON; } else rio_dprintk(RIO_DEBUG_PARAM, "IXON has been disabled.\n"); } if (TtyP->termios->c_iflag & IXANY) { if (PortP->Config & RIO_IXANY) { rio_dprintk(RIO_DEBUG_PARAM, "Enable any key to restart output\n"); Cor2 |= RIOC_COR2_IXANY; } else rio_dprintk(RIO_DEBUG_PARAM, "IXANY has been disabled due to sanity reasons.\n"); } if (TtyP->termios->c_iflag & IXOFF) { rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop input control 2\n"); Cor2 |= RIOC_COR2_IXOFF; } if (TtyP->termios->c_cflag & HUPCL) { rio_dprintk(RIO_DEBUG_PARAM, "Hangup on last close\n"); Cor2 |= RIOC_COR2_HUPCL; } if (C_CRTSCTS(TtyP)) { rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control enabled\n"); Cor2 |= RIOC_COR2_CTSFLOW; Cor2 |= RIOC_COR2_RTSFLOW; } else { rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control disabled\n"); Cor2 &= ~RIOC_COR2_CTSFLOW; Cor2 &= ~RIOC_COR2_RTSFLOW; } if (TtyP->termios->c_cflag & CLOCAL) { rio_dprintk(RIO_DEBUG_PARAM, "Local line\n"); } else { rio_dprintk(RIO_DEBUG_PARAM, "Possible Modem line\n"); } /* ** COR 4 (there is no COR 3) */ if (TtyP->termios->c_iflag & IGNBRK) { rio_dprintk(RIO_DEBUG_PARAM, "Ignore break condition\n"); Cor4 |= RIOC_COR4_IGNBRK; } if (!(TtyP->termios->c_iflag & BRKINT)) { rio_dprintk(RIO_DEBUG_PARAM, "Break generates NULL condition\n"); Cor4 |= RIOC_COR4_NBRKINT; } else { rio_dprintk(RIO_DEBUG_PARAM, "Interrupt on break condition\n"); } if (TtyP->termios->c_iflag & INLCR) { rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage return on input\n"); Cor4 |= RIOC_COR4_INLCR; } if (TtyP->termios->c_iflag & IGNCR) { rio_dprintk(RIO_DEBUG_PARAM, "Ignore carriage return on input\n"); Cor4 |= RIOC_COR4_IGNCR; } if (TtyP->termios->c_iflag & ICRNL) { rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on input\n"); Cor4 |= RIOC_COR4_ICRNL; } if (TtyP->termios->c_iflag & IGNPAR) { rio_dprintk(RIO_DEBUG_PARAM, "Ignore characters with parity errors\n"); Cor4 |= RIOC_COR4_IGNPAR; } if (TtyP->termios->c_iflag & PARMRK) { rio_dprintk(RIO_DEBUG_PARAM, "Mark parity errors\n"); Cor4 |= RIOC_COR4_PARMRK; } /* ** Set the RAISEMOD flag to ensure that the modem lines are raised ** on reception of a config packet. ** The download code handles the zero baud condition. */ Cor4 |= RIOC_COR4_RAISEMOD; /* ** COR 5 */ Cor5 = RIOC_COR5_CMOE; /* ** Set to monitor tbusy/tstop (or not). */ if (PortP->MonitorTstate) Cor5 |= RIOC_COR5_TSTATE_ON; else Cor5 |= RIOC_COR5_TSTATE_OFF; /* ** Could set LNE here if you wanted LNext processing. SVR4 will use it. */ if (TtyP->termios->c_iflag & ISTRIP) { rio_dprintk(RIO_DEBUG_PARAM, "Strip input characters\n"); if (!(PortP->State & RIO_TRIAD_MODE)) { Cor5 |= RIOC_COR5_ISTRIP; } } if (TtyP->termios->c_oflag & ONLCR) { rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage-return, newline on output\n"); if (PortP->CookMode == COOK_MEDIUM) Cor5 |= RIOC_COR5_ONLCR; } if (TtyP->termios->c_oflag & OCRNL) { rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on output\n"); if (PortP->CookMode == COOK_MEDIUM) Cor5 |= RIOC_COR5_OCRNL; } if ((TtyP->termios->c_oflag & TABDLY) == TAB3) { rio_dprintk(RIO_DEBUG_PARAM, "Tab delay 3 set\n"); if (PortP->CookMode == COOK_MEDIUM) Cor5 |= RIOC_COR5_TAB3; } /* ** Flow control bytes. */ TxXon = TtyP->termios->c_cc[VSTART]; TxXoff = TtyP->termios->c_cc[VSTOP]; RxXon = TtyP->termios->c_cc[VSTART]; RxXoff = TtyP->termios->c_cc[VSTOP]; /* ** LNEXT byte */ LNext = 0; /* ** Baud rate bytes */ rio_dprintk(RIO_DEBUG_PARAM, "Mapping of rx/tx baud %x (%x)\n", TtyP->termios->c_cflag, CBAUD); switch (TtyP->termios->c_cflag & CBAUD) { #define e(b) case B ## b : RxBaud = TxBaud = RIO_B ## b ;break e(50); e(75); e(110); e(134); e(150); e(200); e(300); e(600); e(1200); e(1800); e(2400); e(4800); e(9600); e(19200); e(38400); e(57600); e(115200); /* e(230400);e(460800); e(921600); */ } rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud); /* ** Leftovers */ if (TtyP->termios->c_cflag & CREAD) rio_dprintk(RIO_DEBUG_PARAM, "Enable receiver\n"); #ifdef RCV1EN if (TtyP->termios->c_cflag & RCV1EN) rio_dprintk(RIO_DEBUG_PARAM, "RCV1EN (?)\n"); #endif #ifdef XMT1EN if (TtyP->termios->c_cflag & XMT1EN) rio_dprintk(RIO_DEBUG_PARAM, "XMT1EN (?)\n"); #endif if (TtyP->termios->c_lflag & ISIG) rio_dprintk(RIO_DEBUG_PARAM, "Input character signal generating enabled\n"); if (TtyP->termios->c_lflag & ICANON) rio_dprintk(RIO_DEBUG_PARAM, "Canonical input: erase and kill enabled\n"); if (TtyP->termios->c_lflag & XCASE) rio_dprintk(RIO_DEBUG_PARAM, "Canonical upper/lower presentation\n"); if (TtyP->termios->c_lflag & ECHO) rio_dprintk(RIO_DEBUG_PARAM, "Enable input echo\n"); if (TtyP->termios->c_lflag & ECHOE) rio_dprintk(RIO_DEBUG_PARAM, "Enable echo erase\n"); if (TtyP->termios->c_lflag & ECHOK) rio_dprintk(RIO_DEBUG_PARAM, "Enable echo kill\n"); if (TtyP->termios->c_lflag & ECHONL) rio_dprintk(RIO_DEBUG_PARAM, "Enable echo newline\n"); if (TtyP->termios->c_lflag & NOFLSH) rio_dprintk(RIO_DEBUG_PARAM, "Disable flush after interrupt or quit\n"); #ifdef TOSTOP if (TtyP->termios->c_lflag & TOSTOP) rio_dprintk(RIO_DEBUG_PARAM, "Send SIGTTOU for background output\n"); #endif #ifdef XCLUDE if (TtyP->termios->c_lflag & XCLUDE) rio_dprintk(RIO_DEBUG_PARAM, "Exclusive use of this line\n"); #endif if (TtyP->termios->c_iflag & IUCLC) rio_dprintk(RIO_DEBUG_PARAM, "Map uppercase to lowercase on input\n"); if (TtyP->termios->c_oflag & OPOST) rio_dprintk(RIO_DEBUG_PARAM, "Enable output post-processing\n"); if (TtyP->termios->c_oflag & OLCUC) rio_dprintk(RIO_DEBUG_PARAM, "Map lowercase to uppercase on output\n"); if (TtyP->termios->c_oflag & ONOCR) rio_dprintk(RIO_DEBUG_PARAM, "No carriage return output at column 0\n"); if (TtyP->termios->c_oflag & ONLRET) rio_dprintk(RIO_DEBUG_PARAM, "Newline performs carriage return function\n"); if (TtyP->termios->c_oflag & OFILL) rio_dprintk(RIO_DEBUG_PARAM, "Use fill characters for delay\n"); if (TtyP->termios->c_oflag & OFDEL) rio_dprintk(RIO_DEBUG_PARAM, "Fill character is DEL\n"); if (TtyP->termios->c_oflag & NLDLY) rio_dprintk(RIO_DEBUG_PARAM, "Newline delay set\n"); if (TtyP->termios->c_oflag & CRDLY) rio_dprintk(RIO_DEBUG_PARAM, "Carriage return delay set\n"); if (TtyP->termios->c_oflag & TABDLY) rio_dprintk(RIO_DEBUG_PARAM, "Tab delay set\n"); /* ** These things are kind of useful in a later life! */ PortP->Cor2Copy = Cor2; if (PortP->State & RIO_DELETED) { rio_spin_unlock_irqrestore(&PortP->portSem, flags); func_exit(); return RIO_FAIL; } /* ** Actually write the info into the packet to be sent */ writeb(cmd, &phb_param_ptr->Cmd); writeb(Cor1, &phb_param_ptr->Cor1); writeb(Cor2, &phb_param_ptr->Cor2); writeb(Cor4, &phb_param_ptr->Cor4); writeb(Cor5, &phb_param_ptr->Cor5); writeb(TxXon, &phb_param_ptr->TxXon); writeb(RxXon, &phb_param_ptr->RxXon); writeb(TxXoff, &phb_param_ptr->TxXoff); writeb(RxXoff, &phb_param_ptr->RxXoff); writeb(LNext, &phb_param_ptr->LNext); writeb(TxBaud, &phb_param_ptr->TxBaud); writeb(RxBaud, &phb_param_ptr->RxBaud); /* ** Set the length/command field */ writeb(12 | PKT_CMD_BIT, &PacketP->len); /* ** The packet is formed - now, whack it off ** to its final destination: */ add_transmit(PortP); /* ** Count characters transmitted for port statistics reporting */ if (PortP->statsGather) PortP->txchars += 12; rio_spin_unlock_irqrestore(&PortP->portSem, flags); rio_dprintk(RIO_DEBUG_PARAM, "add_transmit returned.\n"); /* ** job done. */ func_exit(); return 0; }
int main() { /* Exceptions can jump out of functions. This is their main reason for existing! */ { try { exception_func_int(); } catch (int i) { assert(i == 1); } } /* # std::exception Anything can be thrown, including classes and base types. All stdlib exceptions inherit from `exception`, so it is a good idea to only throw things inherited from it. `std::exception` has limited use since its constructor does not take any arguments, so you cannot describe the error. Some stdlib derived class constructors do however. */ { try { throw std::exception(); } catch (std::exception e) { } } /* Catch blocks work like function overloads and catch by type. */ try { throw 'c'; } catch (int i) { assert(false); } catch (char c) { } /* `...` is the default case */ try { throw 1.0; } catch (int i) { assert(false); } catch (char c) { assert(false); } catch (...) { } /* Derived classes. Just like for function overloading, base classes catch for derived classes. */ { try { throw myexception(); } catch (std::exception& ex) { } /* This compiles, but generates a warning, since the first catch will always catch instead of this one. */ //catch (myexception& ex) {assert(false);} catch (...) {assert(false);} /* this is a more common exception ordering, first derived then base. */ { try { throw myexception(); } catch (myexception& ex) { } catch (std::exception& ex) { assert(false); } catch (...) { assert(false); } } } /* # what Returns a string which contains information about the exception. Many stdlib exceptions simply return the error message given on the constructor. */ { std::string msg = "custom message"; std::ios_base::failure e(msg); // TODO worked in GCC 4.8, failed in GCC 5.1. //assert(e.what() == msg); } /* # uncaught exceptions Uncaught exceptions explose at top level and terminate the program. Check out the error messages generated by each exception. Classes that derive from exception and implement `what()` can print custom messages, which may contain useful debug info. This is a major point in favor of using exception classes instead of base types. */ { //throw 1; //throw 'c'; //throw 1.0; //throw myexception(); } /* # exception specifications Functions can specify which exceptions are catchable with the following syntax. */ { try { exception_func_int_only(true); } catch (int i) { } catch (...) { assert(false); } try { //exception_func_int_only(false); } catch (...) { /* not even ... this can catch non int exceptions thrown by this function */ } try { exception_func_int_exception_only(1); } catch (int i) { } catch (myexception& ex) { } catch (...) { assert(false); } try { //exception_func_none(); } catch (...) { /* no exception thrown by this function is catchable */ } try { //exception_func_none_wrapper(); } catch (...) { /* the same goes if we wrap the function */ } } /* # exception from destructor Never throw an exception from a destructor. Destructors are meant to clean up after exceptions, so if you throw exceptions from them, things get messy. C++ specifies that if this happens during stack unwinding, the program may terminate! What to do to avoid that: <http://stackoverflow.com/questions/130117/throwing-exceptions-out-of-a-destructor> The following code could lead to that. */ if (0) { try { ExceptionDestructor e; } catch (...) { } try { ExceptionDestructorCaller(); } catch (...) { } } #if __cplusplus >= 201103L /* # noexcept Improved version of `throw` for functions. `throw` for functions becomes deprecated in C++11. TODO */ { } #endif }
ExpressionPtr UnaryOpExpression::preOptimize(AnalysisResultConstPtr ar) { Variant value; Variant result; if (m_exp && ar->getPhase() >= AnalysisResult::FirstPreOptimize) { if (m_op == T_UNSET) { if (m_exp->isScalar() || (m_exp->is(KindOfExpressionList) && static_pointer_cast<ExpressionList>(m_exp)->getCount() == 0)) { recomputeEffects(); return CONSTANT("null"); } return ExpressionPtr(); } } if (m_op == T_ISSET && m_exp->is(KindOfExpressionList) && static_pointer_cast<ExpressionList>(m_exp)->getListKind() == ExpressionList::ListKindParam) { auto el = static_pointer_cast<ExpressionList>(m_exp); result = true; int i = 0, n = el->getCount(); for (; i < n; i++) { ExpressionPtr e((*el)[i]); if (!e || !e->isScalar() || !e->getScalarValue(value)) break; if (value.isNull()) { result = false; } } if (i == n) { return replaceValue(makeScalarExpression(ar, result)); } } else if (m_op != T_ARRAY && m_op != T_VEC && m_op != T_DICT && m_op != T_KEYSET && m_exp && m_exp->isScalar() && m_exp->getScalarValue(value) && preCompute(value, result)) { return replaceValue(makeScalarExpression(ar, result)); } else if (m_op == T_BOOL_CAST) { switch (m_exp->getKindOf()) { default: break; case KindOfBinaryOpExpression: { int op = static_pointer_cast<BinaryOpExpression>(m_exp)->getOp(); switch (op) { case T_LOGICAL_OR: case T_BOOLEAN_OR: case T_LOGICAL_AND: case T_BOOLEAN_AND: case T_LOGICAL_XOR: case T_INSTANCEOF: case '<': case T_IS_SMALLER_OR_EQUAL: case '>': case T_IS_GREATER_OR_EQUAL: case T_SPACESHIP: case T_IS_IDENTICAL: case T_IS_NOT_IDENTICAL: case T_IS_EQUAL: case T_IS_NOT_EQUAL: return m_exp; } break; } case KindOfUnaryOpExpression: { int op = static_pointer_cast<UnaryOpExpression>(m_exp)->getOp(); switch (op) { case T_BOOL_CAST: case '!': case T_ISSET: case T_EMPTY: case T_PRINT: return m_exp; } break; } } } return ExpressionPtr(); }
void MainWindow::update() { if(this->actionShowConvexHull->isChecked()){ convex_hull_gi->show(); }else { convex_hull_gi->hide(); } if(this->actionShowMinRectangle->isChecked()){ min_rectangle_gi->show(); }else { min_rectangle_gi->hide(); } if(this->actionShowMinParallelogram->isChecked()){ min_parallelogram_gi->show(); }else { min_parallelogram_gi->hide(); } CGAL::Qt::Converter<K> convert; if(this->actionShowPCenter->isChecked() && convex_hull.size()>=3){ for(std::size_t i=0; i< P; i++){ p_center[i]->setRect(convert(p_center_iso_rectangle[i])); p_center[i]->show(); } } if (mc.is_degenerate() || (! this->actionShowMinCircle->isChecked())){ cgi->hide(); } else { K::Circle_2 c; if (mc.number_of_support_points() == 2) c = K::Circle_2(mc.support_point(0), mc.support_point(1)); else c = K::Circle_2(mc.support_point(0), mc.support_point(1), mc.support_point(2)); cgi->setRect(convert(c.bbox())); cgi->show(); } if (me.is_degenerate() || (! this->actionShowMinEllipse->isChecked()) ){ egi->hide(); } else { if (me.number_of_support_points() == 2) { } else { Ellipse_2<K> e(me); double half_width = sqrt(e.va() * e.va()); double half_height = sqrt(e.vb() * e.vb()); double angle = std::atan2( e.va().y(), e.va().x() ) * 180.0/CGAL_PI; Vector_2 wh(half_width, half_height); Iso_rectangle_2 isor(e.center()+ wh, e.center()-wh); egi->setRect(convert(isor)); // Rotate an item 45 degrees around (x, y). double x = e.center().x(); double y = e.center().y(); egi->setTransform(QTransform().translate(x, y).rotate(angle).translate(-x, -y)); egi->show(); } } }
double addmul_sse() { long long ii; double res; double mul=1.00001; Vec2d a(0.1, 0.2); Vec2d b(0.3, 0.4); Vec2d c(0.5, 0.6); Vec2d d(0.7, 0.8); Vec2d e(2.1, 2.2); Vec2d f(2.3, 2.4); Vec2d g(2.5, 2.6); Vec2d h(2.7, 2.8); Vec2d i(3.1, 3.2); Vec2d j(3.3, 3.4); Vec2d k(3.5, 3.6); Vec2d l(3.7, 3.8); Vec2d m(4.1, 4.2); Vec2d n(4.3, 4.4); Vec2d o(4.5, 4.6); Vec2d p(4.7, 4.8); for(ii=0; ii< max1*max2 ; ii++) { a=a*b; b=b+c; c=c*d; d=d+e; e=e*f; f=f+g; g=g*h; h=h+i; i=i*j; j=j+k; k=k*l; l=l+m; m=m*n; n=n+o; o=o*p; p=p+a; } res= a[0]+a[1]+ b[0]+b[1]+ c[0]+c[1]+ d[0]+d[1]+ e[0]+e[1]+ f[0]+f[1]+ g[0]+g[1]+ h[0]+h[1]+ i[0]+i[1]+ j[0]+j[1]+ k[0]+k[1]+ l[0]+l[1]+ m[0]+m[1]+ n[0]+n[1]+ o[0]+o[1]+ p[0]+p[1] ; return res; }
int main(int argc, char **argv) { const int d = 5; const int da[5] = { 0 }; S4 e(4); S5 g(5); S6 p; int i; int &j = i; #pragma omp target #pragma omp teams distribute parallel for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}} for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate () // expected-error {{expected expression}} for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate (argc) for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate (S1) // expected-error {{'S1' does not refer to a value}} for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate (argv[1]) // expected-error {{expected variable name}} for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate(ba) for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}} for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate(da) for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate(S2::S2s) for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate(S2::S2sc) for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note 2 {{defined as private}} for (i = 0; i < argc; ++i) foo(); // expected-error {{loop iteration variable in the associated loop of 'omp teams distribute parallel for simd' directive may not be private, predetermined as linear}} #pragma omp target #pragma omp teams distribute parallel for simd firstprivate(i) for (j = 0; j < argc; ++j) foo(); #pragma omp target #pragma omp teams distribute parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}} for (i = 0; i < argc; ++i) foo(); // expected-error {{loop iteration variable in the associated loop of 'omp teams distribute parallel for simd' directive may not be firstprivate, predetermined as linear}} #pragma omp target #pragma omp teams distribute parallel for simd firstprivate(j) for (i = 0; i < argc; ++i) foo(); #pragma omp target #pragma omp teams distribute parallel for simd lastprivate(argc), firstprivate(argc) // OK for (i = 0; i < argc; ++i) foo(); return 0; }
// // Assign facets // assign common facets // assign additional facet // void AbstractStringValidator::assignFacet(MemoryManager* const manager) { RefHashTableOf<KVStringPair>* facets = getFacets(); if (!facets) return; XMLCh* key; RefHashTableOfEnumerator<KVStringPair> e(facets, false, manager); while (e.hasMoreElements()) { KVStringPair pair = e.nextElement(); key = pair.getKey(); XMLCh* value = pair.getValue(); if (XMLString::equals(key, SchemaSymbols::fgELT_LENGTH)) { int val; try { val = XMLString::parseInt(value, manager); } catch (NumberFormatException&) { ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_Len, value, manager); } if ( val < 0 ) ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_Len, value, manager); setLength(val); setFacetsDefined(DatatypeValidator::FACET_LENGTH); } else if (XMLString::equals(key, SchemaSymbols::fgELT_MINLENGTH)) { int val; try { val = XMLString::parseInt(value, manager); } catch (NumberFormatException&) { ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_minLen, value, manager); } if ( val < 0 ) ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_minLen, value, manager); setMinLength(val); setFacetsDefined(DatatypeValidator::FACET_MINLENGTH); } else if (XMLString::equals(key, SchemaSymbols::fgELT_MAXLENGTH)) { int val; try { val = XMLString::parseInt(value, manager); } catch (NumberFormatException&) { ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_maxLen, value, manager); } if ( val < 0 ) ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_maxLen, value, manager); setMaxLength(val); setFacetsDefined(DatatypeValidator::FACET_MAXLENGTH); } else if (XMLString::equals(key, SchemaSymbols::fgELT_PATTERN)) { setPattern(value); if (getPattern()) setFacetsDefined(DatatypeValidator::FACET_PATTERN); // do not construct regex until needed } else if (XMLString::equals(key, SchemaSymbols::fgATT_FIXED)) { unsigned int val; bool retStatus; try { retStatus = XMLString::textToBin(value, val, fMemoryManager); } catch (RuntimeException&) { ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed, manager); } if (!retStatus) { ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed, manager); } setFixed(val); //no setFacetsDefined here } // // else if (XMLString::equals(key, SchemaSymbols::fgELT_SPECIAL_TOKEN)) // TODO // // Note: whitespace is taken care of by TraverseSchema. // else { assignAdditionalFacet(key, value, manager); } }//while }//end of assigneFacet()
int main(int argc, char **argv) { const int d = 5; // expected-note 2 {{'d' defined here}} const int da[5] = {0}; // expected-note {{'da' defined here}} int qa[5] = {0}; S4 e(4); S5 g(5); int i; int &j = i; // expected-note 2 {{'j' defined here}} S3 &p = k; // expected-note 2 {{'p' defined here}} const int &r = da[i]; // expected-note {{'r' defined here}} int &q = qa[i]; // expected-note {{'q' defined here}} float fl; #pragma omp target teams distribute parallel for simd reduction // expected-error {{expected '(' after 'reduction'}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target teams distribute parallel for simd' are ignored}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(~ : argc) // expected-error {{expected unqualified-id}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(&& : argc) for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(^ : S1) // expected-error {{'S1' does not refer to a value}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{const-qualified list item cannot be reduction}} expected-error {{'operator+' is a private member of 'S2'}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified list item cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(& : e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{invalid operands to binary expression ('S4' and 'S4')}} expected-error {{calling a private constructor of class 'S5'}} expected-error {{invalid operands to binary expression ('S5' and 'S5')}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(+ : o) // expected-error {{no viable overloaded '='}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} for (int j=0; j<100; j++) foo(); #pragma omp parallel private(k) #pragma omp target teams distribute parallel for simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}} for (int j=0; j<100; j++) foo(); #pragma omp parallel shared(i) #pragma omp parallel reduction(min : i) #pragma omp target teams distribute parallel for simd reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}} for (int j=0; j<100; j++) foo(); #pragma omp target teams distribute parallel for simd reduction(+ : fl) for (int j=0; j<100; j++) foo(); static int m; #pragma omp target teams distribute parallel for simd reduction(+ : m) // OK for (int j=0; j<100; j++) foo(); return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<float>' requested here}} }
/// Compute the conversion (in seconds) at the given time for this object /// (TimeSystemCorrection). The caller must ensure that the input time has the /// appropriate TimeSystem, it will determine the sign of the correction; it is /// such that it should ALWAYS be ADDED to the input time. /// For example, suppose this object is a "GPUT" (GPS=>UTC) correction. Then /// ct(GPS) + Correction(ct) will yield ct(UTC), and /// ct(UTC) + Correction(ct) will yield ct(GPS). /// [That is, Correction(ct) in the two cases differ in sign] /// Throw an Exception if the TimeSystem of the input does not match either of /// the systems in this object. /// @param CommonTime ct, the time at which to compute the correction; the /// TimeSystem of ct will determine the sign of the correction. /// @return the correction (sec) to be added to ct to change its TimeSystem /// @throw if the input TimeSystem matches neither system in this object. double Correction(const CommonTime& ct) const { double corr(0.0), dt; TimeSystem fromTS(ct.getTimeSystem()); GPSWeekSecond gpsws; CommonTime refTime; Exception e("Unable to compute correction - wrong TimeSystem"); Exception eSBAS("TimeSystemCorr SBAS <=> UTC has not been implemented"); switch(type) { case GPUT: if(fromTS != TimeSystem::GPS && fromTS != TimeSystem::UTC) { GPSTK_THROW(e); } // dt = fromTime - refTime gpsws = GPSWeekSecond(refWeek,refSOW); refTime = gpsws.convertToCommonTime(); refTime.setTimeSystem(fromTS); dt = ct - refTime; if(fromTS == TimeSystem::GPS) // GPS => UTC corr = -A0-A1*dt; else // UTC => GPS corr = A0+A1*dt; break; case GAUT: if(fromTS != TimeSystem::GAL && fromTS != TimeSystem::UTC) { GPSTK_THROW(e); } // dt = fromTime - refTime gpsws = GPSWeekSecond(refWeek,refSOW); refTime = gpsws.convertToCommonTime(); refTime.setTimeSystem(fromTS); dt = ct - refTime; if(fromTS == TimeSystem::GAL) // GAL => UTC corr = A0+A1*dt; else // UTC => GAL corr = -A0-A1*dt; break; case SBUT: GPSTK_THROW(eSBAS); break; case GLUT: if(fromTS != TimeSystem::GLO && fromTS != TimeSystem::UTC) { GPSTK_THROW(e); } if(fromTS == TimeSystem::GLO) // GLO => UTC corr = A0; else // UTC => GLO corr = -A0; break; case GPGA: if(fromTS != TimeSystem::GPS && fromTS != TimeSystem::GAL) { GPSTK_THROW(e); } // dt = fromTime - refTime gpsws = GPSWeekSecond(refWeek,refSOW); refTime = gpsws.convertToCommonTime(); refTime.setTimeSystem(fromTS); dt = ct - refTime; if(fromTS == TimeSystem::GPS) // GPS => GAL corr = A0+A1*dt; else // GAL => GPS corr = -A0-A1*dt; break; case GLGP: if(fromTS != TimeSystem::GLO && fromTS != TimeSystem::GPS) { GPSTK_THROW(e); } if(fromTS == TimeSystem::GLO) // GLO => GPS corr = A0; else // GPS => GLO corr = -A0; break; case QZGP: if(fromTS != TimeSystem::QZS && fromTS != TimeSystem::GPS) { GPSTK_THROW(e); } if(fromTS == TimeSystem::QZS) // QZS => GPS corr = 0.0; // TD? else // GPS => QZS corr = 0.0; // TD? break; case QZUT: if(fromTS != TimeSystem::QZS && fromTS != TimeSystem::UTC) { GPSTK_THROW(e); } // dt = fromTime - refTime gpsws = GPSWeekSecond(refWeek,refSOW); refTime = gpsws.convertToCommonTime(); refTime.setTimeSystem(fromTS); dt = ct - refTime; if(fromTS == TimeSystem::QZS) // QZS => UTC corr = A0+A1*dt; else // UTC => QZS corr = -A0-A1*dt; break; case BDUT: if(fromTS != TimeSystem::BDT && fromTS != TimeSystem::UTC) { GPSTK_THROW(e); } // dt = fromTime - refTime gpsws = GPSWeekSecond(refWeek,refSOW); refTime = gpsws.convertToCommonTime(); refTime.setTimeSystem(fromTS); dt = ct - refTime; if(fromTS == TimeSystem::BDT) // BDT => UTC corr = A0+A1*dt; else // UTC => BDT corr = -A0-A1*dt; break; case BDGP: if(fromTS != TimeSystem::BDT && fromTS != TimeSystem::GPS) { GPSTK_THROW(e); } // dt = fromTime - refTime gpsws = GPSWeekSecond(refWeek,refSOW); refTime = gpsws.convertToCommonTime(); refTime.setTimeSystem(fromTS); dt = ct - refTime; if(fromTS == TimeSystem::BDT) // BDT => GPS corr = A0; else // GPS => BDT corr = -A0; break; default: Exception e("TimeSystemCorrection is not defined."); GPSTK_THROW(e); break; } return corr; }
void Bayes::sample_muOmega() { double tau = 10.0; int d0 = p + 2; // matrix_t S0(p, p); ublas::matrix<double> S0(p, p); S0 = d0 * ublas::identity_matrix<double>(p, p)/4.0; std::vector<int> idx; ublas::indirect_array<> irow(p); // projection - want every row for (size_t i=0; i<irow.size(); ++i) irow(i) = i; // size_t rank; ublas::matrix<double> S(p, p); // matrix_t SS(p, p); ublas::matrix<double> SS(p, p); ublas::matrix<double> Omega_inv(p, p); // identity matrix for inverting cholesky factorization ublas::matrix<double> I(p, p); I.assign(ublas::identity_matrix<double> (p, p)); ublas::symmetric_adaptor<ublas::matrix<double>, ublas::upper> SH(I); // triangular matrix for cholesky_decompose ublas::triangular_matrix<double, ublas::lower, ublas::row_major> L(p, p); int df; for (int j=0; j<k; ++j) { idx = find_all(z, j); int n_idx = idx.size(); ublas::matrix<double> xx(p, n_idx); ublas::matrix<double> e(p, n_idx); // ublas::matrix<double> m(p, 1); ublas::vector<double> m(p); ublas::indirect_array<> icol(n_idx); for (size_t i=0; i<idx.size(); ++i) icol(i) = idx[i]; if (n_idx > 0) { double a = tau/(1.0 + n_idx*tau); //! REFACTOR - should be able to do matrix_sum directly on projection rather than make a copy? xx.assign(project(x, irow, icol)); m.assign(ublas::matrix_sum(xx, 1)/n_idx); // e.assign(xx - outer_prod(column(m, 0), ublas::scalar_vector<double>(n_idx, 1))); e.assign(xx - outer_prod(m, ublas::scalar_vector<double>(n_idx, 1))); S.assign(prod(e, trans(e)) + outer_prod(m, m) * n_idx * a/tau); // SS = trans(S) + S0; SS = S + S0; df = d0 + n_idx; // Omega(j).assign(wishart_rnd(df, SS)); Omega(j).assign(wishart_InvA_rnd(df, SS)); SH.assign(Omega(j)); cholesky_decompose(SH, L); Omega_inv.assign(solve(SH, I, ublas::upper_tag())); mu(j).assign(a*n_idx*m + sqrt(a)*prod(Omega_inv, Rmath::rnorm(0, 1, p))); } else { // Omega(j).assign(wishart_rnd(d0, S0)); Omega(j).assign(wishart_InvA_rnd(d0, S0)); SH.assign(Omega(j)); cholesky_decompose(SH, L); Omega_inv.assign(solve(SH, I, ublas::upper_tag())); mu(j).assign(sqrt(tau) * prod(Omega_inv, Rmath::rnorm(0, 1, p))); } } }
void NasmInsnRunner::ParseAndTestLine(const char* filename, const llvm::StringRef& line, int linenum) { SCOPED_TRACE(llvm::format("%s:%d", filename, linenum)); llvm::StringRef insn_in, golden_in; llvm::tie(insn_in, golden_in) = line.split(';'); insn_in = strip(insn_in); golden_in = strip(golden_in); // Handle bits directive if (golden_in.empty() && insn_in.startswith("[bits ")) { int bits = atoi(insn_in.substr(6, 2).str().c_str()); if (bits == 64) m_arch->setMachine("amd64"); else m_arch->setMachine("x86"); m_arch->setVar("mode_bits", bits); return; } if (insn_in.empty() || golden_in.empty()) return; // skip lines that don't have both text and a comment // // parse the golden result // llvm::SmallVector<unsigned char, 64> golden; llvm::StringRef golden_errwarn; for (;;) { // strip whitespace golden_in = strip(golden_in); if (golden_in.empty() || !isxdigit(golden_in[0])) break; unsigned int byte_val = 0x100; llvm::StringRef byte_str; llvm::tie(byte_str, golden_in) = golden_in.split(' '); if (byte_str.size() == 2) // assume hex byte_val = (fromhexdigit(byte_str[0]) << 4) | fromhexdigit(byte_str[1]); else if (byte_str.size() == 3) // assume octal byte_val = (fromoctdigit(byte_str[0]) << 6) | (fromoctdigit(byte_str[1]) << 3) | fromoctdigit(byte_str[2]); ASSERT_LE(byte_val, 0xffU) << "invalid golden value"; golden.push_back(byte_val); } // interpret string in [] as error/warning if (!golden_in.empty() && golden_in[0] == '[') llvm::tie(golden_errwarn, golden_in) = golden_in.substr(1).split(']'); // // parse the instruction // ::testing::StrictMock<MockDiagnosticString> mock_consumer; llvm::IntrusiveRefCntPtr<DiagnosticIDs> diagids(new DiagnosticIDs); DiagnosticsEngine diags(diagids, &mock_consumer, false); FileSystemOptions opts; FileManager fmgr(opts); SourceManager smgr(diags, fmgr); diags.setSourceManager(&smgr); // instruction name is the first thing on the line llvm::StringRef insn_name; llvm::tie(insn_name, insn_in) = insn_in.split(' '); Arch::InsnPrefix insnprefix = m_arch->ParseCheckInsnPrefix(insn_name, SourceLocation(), diags); ASSERT_TRUE(insnprefix.isType(Arch::InsnPrefix::INSN)); std::auto_ptr<Insn> insn = m_arch->CreateInsn(insnprefix.getInsn()); ASSERT_TRUE(insn.get() != 0) << "unrecognized instruction '" << insn_name.str() << "'"; // parse insn arguments unsigned int wsize = m_arch_module->getWordSize(); // strip whitespace from arguments insn_in = strip(insn_in); while (!insn_in.empty()) { llvm::StringRef arg_str; llvm::tie(arg_str, insn_in) = insn_in.split(','); // strip whitespace from arg arg_str = strip(arg_str); unsigned int size = 0; bool strict = false; for (;;) { int next; int nsize = 0; // operand overrides (size and strict) if (arg_str.startswith("byte ")) { nsize = 8; next = 5; } else if (arg_str.startswith("hword ")) { nsize = wsize/2; next = 6; } else if (arg_str.startswith("word ")) { nsize = wsize; next = 5; } else if (arg_str.startswith("dword ")) { nsize = wsize*2; next = 6; } else if (arg_str.startswith("qword ")) { nsize = wsize*4; next = 6; } else if (arg_str.startswith("tword ")) { nsize = 80; next = 6; } else if (arg_str.startswith("dqword ")) { nsize = wsize*8; next = 7; } else if (arg_str.startswith("oword ")) { nsize = wsize*8; next = 6; } else if (arg_str.startswith("yword ")) { nsize = 256; next = 6; } else if (arg_str.startswith("strict ")) { strict = true; next = 7; } else break; if (size == 0) size = nsize; arg_str = arg_str.substr(next); } if (arg_str[0] == '[') { // Very simple int/reg expression parser. Does not handle parens or // order of operations; simply builds expr from left to right. // This means r8*4+r9 will have a different result than r9+r8*4! // Also only handles binary operators * and +. llvm::StringRef estr = arg_str.slice(1, arg_str.find(']')+1); std::auto_ptr<Expr> e(new Expr); char pendingop = '\0'; std::size_t tokstart = 0; for (std::size_t pos = 0; pos < estr.size(); ++pos) { if (estr[pos] == '*' || estr[pos] == '+' || estr[pos] == ']') { // figure out this token llvm::StringRef tok = strip(estr.slice(tokstart, pos)); if (isdigit(estr[tokstart])) e->Append(strtoint(tok)); else { Arch::RegTmod regtmod = m_arch->ParseCheckRegTmod(tok, SourceLocation(), diags); ASSERT_TRUE(regtmod.isType(Arch::RegTmod::REG)) << "cannot handle label '" << tok.str() << "'"; e->Append(*regtmod.getReg()); } // append pending operator if (pendingop == '*') e->AppendOp(Op::MUL, 2); else if (pendingop == '+') e->AppendOp(Op::ADD, 2); // store new operator pendingop = estr[pos]; tokstart = pos+1; } } Operand operand(m_arch->CreateEffAddr(e)); operand.setSize(size); operand.setStrict(strict); insn->AddOperand(operand); continue; } // TODO: split by space to allow target modifiers // Test for registers Arch::RegTmod regtmod = m_arch->ParseCheckRegTmod(arg_str, SourceLocation(), diags); if (const Register* reg = regtmod.getReg()) { Operand operand(reg); operand.setSize(size); operand.setStrict(strict); insn->AddOperand(operand); continue; } else if (const SegmentRegister* segreg = regtmod.getSegReg()) { Operand operand(segreg); operand.setSize(size); operand.setStrict(strict); insn->AddOperand(operand); continue; } else if (regtmod.getTargetMod()) { FAIL() << "cannot handle target modifier"; } else if (regtmod.getRegGroup()) { FAIL() << "cannot handle register group"; } // Can't handle labels ASSERT_TRUE(isdigit(arg_str[0]) || arg_str[0] == '-') << "cannot handle label '" << arg_str.str() << "'"; // Convert to integer expression Operand intop(Expr::Ptr(new Expr(strtoint(arg_str)))); intop.setSize(size); intop.setStrict(strict); insn->AddOperand(intop); } TestInsn(insn.get(), golden.size(), golden.data(), golden_errwarn); }
bool SynPacket::answer(const char *_cmd, vector<string> &args) { string cmd = _cmd; if (cmd == "SYN"){ m_ver = atol(args[0].c_str()); if (m_ver == m_client->getListVer()) return false; ContactList::GroupIterator itg; Group *grp; while ((grp = ++itg) != NULL){ MSNUserData *data; ClientDataIterator it(grp->clientData, m_client); while ((data = (MSNUserData*)(++it)) != NULL){ data->sFlags = data->Flags; data->Flags = 0; } } ContactList::ContactIterator itc; Contact *contact; while ((contact = ++itc) != NULL){ MSNUserData *data; ClientDataIterator it(contact->clientData, m_client); while ((data = (MSNUserData*)(++it)) != NULL){ data->sFlags = data->Flags; data->Flags = 0; } } return true; } if (cmd == "GTC") return true; if (cmd == "BLP") return true; if (cmd == "LSG"){ if (args.size() < 3){ log(L_WARN, "Bad LSG size"); return true; } unsigned id = atol(args[0].c_str()); if (id == 0) return true; Group *grp; string grp_name; grp_name = m_client->unquote(QString::fromUtf8(args[1].c_str())).utf8(); MSNListRequest *lr = m_client->findRequest(id, LR_GROUPxREMOVED); if (lr) return true; MSNUserData *data = m_client->findGroup(id, NULL, grp); if (data){ lr = m_client->findRequest(grp->id(), LR_GROUPxCHANGED); if (lr){ data->sFlags |= MSN_CHECKED; return true; } } data = m_client->findGroup(id, grp_name.c_str(), grp); data->sFlags |= MSN_CHECKED; return true; } if (cmd == "LST"){ if (args.size() < 3){ log(L_WARN, "Bad size for LST"); return true; } string mail; mail = m_client->unquote(QString::fromUtf8(args[0].c_str())).utf8(); string name; name = m_client->unquote(QString::fromUtf8(args[1].c_str())).utf8(); Contact *contact; MSNListRequest *lr = m_client->findRequest(mail.c_str(), LR_CONTACTxREMOVED); if (lr) return true; bool bNew = false; MSNUserData *data = m_client->findContact(mail.c_str(), contact); if (data == NULL){ data = m_client->findContact(mail.c_str(), name.c_str(), contact); bNew = true; }else{ set_str(&data->EMail, mail.c_str()); set_str(&data->ScreenName, name.c_str()); if (name != (const char*)(contact->getName().utf8())){ contact->setName(QString::fromUtf8(name.c_str())); Event e(EventContactChanged, contact); e.process(); } } data->sFlags |= MSN_CHECKED; lr = m_client->findRequest(mail.c_str(), LR_CONTACTxCHANGED); unsigned grp = NO_GROUP; if (args.size() > 3) grp = atol(args[3].c_str()); data->Group = grp; data->Flags |= MSN_FORWARD; Group *group = NULL; if (grp == NO_GROUP){ group = getContacts()->group(0); }else{ m_client->findGroup(grp, NULL, group); } if ((lr == NULL) && group && (group->id() != contact->getGroup())){ unsigned grp = group->id(); if (grp == 0){ void *d; ClientDataIterator it_d(contact->clientData); while ((d = ++it_d) != NULL){ if (d != data) break; } if (d){ grp = contact->getGroup(); m_client->findRequest(data->EMail, LR_CONTACTxCHANGED, true); MSNListRequest lr; lr.Type = LR_CONTACTxCHANGED; lr.Name = data->EMail; m_client->m_requests.push_back(lr); m_client->processRequests(); } } contact->setGroup(grp); Event e(EventContactChanged, contact); e.process(); } return true; } bDone = true; return false; }
int POD<TruthModelType>::pod( mode_set_type& ModeSet, bool is_primal, const wn_type& elements_set, bool use_solutions ) { M_backend = backend_type::build( BACKEND_PETSC ); Eigen::SelfAdjointEigenSolver< matrixN_type > eigen_solver; M_use_solutions = use_solutions; fillPodMatrix( elements_set ); int size = M_pod_matrix.cols(); //store the matrix if ( M_store_pod_matrix ) { std::ofstream matrix_file; LOG(INFO)<<"saving Pod matrix in a file \n"; matrix_file.open( "PodMatrix",std::ios::out ); matrix_file<<M_pod_matrix.rows(); matrix_file<<"\n"; matrix_file<<M_pod_matrix.cols(); matrix_file<<"\n"; for ( int i=0; i<M_pod_matrix.rows(); i++ ) { for ( int j=0; j<M_pod_matrix.cols(); j++ ) { matrix_file<< std::setprecision( 16 ) <<M_pod_matrix( i,j )<<" "; } matrix_file<<"\n"; } LOG(INFO)<<" matrix wrote in file named PodMatrix \n"; } else if ( M_store_pod_matrix_format_octave ) { std::ofstream matrix_file; LOG(INFO)<<"saving Pod matrix in a file \n"; matrix_file.open( "PodMatrixOctave.mat",std::ios::out ); matrix_file<<"# name: A\n"; matrix_file<<"# type: matrix\n"; matrix_file<<"# rows: "<<M_pod_matrix.rows()<<"\n"; matrix_file<<"# columns: "<<M_pod_matrix.cols()<<"\n"; for ( int i=0; i<M_pod_matrix.rows(); i++ ) { for ( int j=0; j<M_pod_matrix.cols(); j++ ) { matrix_file<< std::setprecision( 16 ) <<M_pod_matrix( i,j )<<" "; } matrix_file<<"\n"; } LOG(INFO)<<" matrix wrote in file named PodMatrix \n"; matrix_file.close(); } eigen_solver.compute( M_pod_matrix ); // solve M_pod_matrix psi = lambda psi int number_of_eigenvalues = eigen_solver.eigenvalues().size(); LOG(INFO)<<"Number of eigenvalues : "<<number_of_eigenvalues<<"\n"; //we copy eigenvalues in a std::vector beacause it's easier to manipulate it std::vector<double> eigen_values( number_of_eigenvalues ); int too_small_index = 0; for ( int i=0; i<number_of_eigenvalues; i++ ) { if ( imag( eigen_solver.eigenvalues()[i] )>1e-12 ) { throw std::logic_error( "[POD::pod] ERROR : complex eigenvalues were found" ); } eigen_values[i]=real( eigen_solver.eigenvalues()[i] ); } //tab will contains index of maximum eigenvalues std::vector<int> max_idx; std::vector<double> copy_eigen_values ( eigen_values ); int number_of_good_eigenvectors=0; bool go = true; double min_eigenvalue = option(_name="pod.minimum-eigenvalue").template as<double>(); //for(int maxmode=0; maxmode<M_Nm; maxmode++) auto max = std::max_element( copy_eigen_values.begin(), copy_eigen_values.end() ); double idx = std::distance( copy_eigen_values.begin(), max ); if( *max < min_eigenvalue ) go=false; while( go ) { number_of_good_eigenvectors++; max_idx.push_back( idx ); copy_eigen_values[idx]=0; max = std::max_element( copy_eigen_values.begin(), copy_eigen_values.end() ); idx = std::distance( copy_eigen_values.begin(), max ); if( *max < min_eigenvalue ) go = false; if( number_of_good_eigenvectors == M_Nm ) go = false; if( number_of_good_eigenvectors == number_of_eigenvalues ) go = false; } CHECK( number_of_good_eigenvectors > 0 )<<"The max eigenvalue "<<*max<<" is under the minimum eigenvalue set by the user "<<min_eigenvalue<<" and we have zero eigenvectors !\n"; int position_of_largest_eigenvalue=max_idx[0]; if( M_Nm == -1 ) { //in this case the user doesn't know a priori //what value give to M_Nm //this case appears for when apply-POD-to-WN=true M_Nm = number_of_good_eigenvectors; } if ( M_Nm > number_of_good_eigenvectors && number_of_good_eigenvectors>0 && is_primal ) { //in this case, the user set M_Nm but with respect to //the minimum eigenvalue set, we don't find enough eigenvectors M_Nm = number_of_good_eigenvectors; } for ( int i=0; i<M_Nm; i++ ) { element_ptrtype mode ( new element_type( M_model->functionSpace() ) ); mode->zero(); int index=0; if( M_use_solutions ) { M_bdf->setRestart( true ); for ( M_bdf->restart(); !M_bdf->isFinished(); M_bdf->next() ) { M_bdf->loadCurrent(); double psi_k = real( eigen_solver.eigenvectors().col( position_of_largest_eigenvalue )[index] ); M_bdf->unknown( 0 ).scale( psi_k ); mode->add( 1 , M_bdf->unknown( 0 ) ); index++; } }//if use solutions else { double eigenvalue = eigen_values[ position_of_largest_eigenvalue ]; for(int j=0; j<size; j++) { double psi_k = real( eigen_solver.eigenvectors().col( position_of_largest_eigenvalue )[index] ); mode->add( psi_k , elements_set[j] ); index++; } }//if use elements set //check auto eigenvector = eigen_solver.eigenvectors().col( position_of_largest_eigenvalue ); double eigenvalue = eigen_values[position_of_largest_eigenvalue]; auto Aw = M_pod_matrix*eigenvector; auto lambdaw = eigenvalue*eigenvector; double Awnorm = Aw.norm(); double lambdawnorm = lambdaw.norm(); double eigenvectornorm = eigenvector.norm(); double check_tol = option(_name="pod.check-tol").template as<double>(); CHECK( math::abs(Awnorm - lambdawnorm) < check_tol )<<" A w : "<<Awnorm<<" and lambda w : "<<lambdawnorm<<" so math::abs(A w - lambda w) : "<<math::abs(Awnorm - lambdawnorm)<<" and pod.check-tol : "<<check_tol<<" -- eigenvalue : "<<eigenvalue<<"\n"; if( (i+1) < max_idx.size() ) position_of_largest_eigenvalue=max_idx[i+1]; ModeSet.push_back( *mode ); }// loop on number of modes //check orthogonality if( option(_name="pod.check-orthogonality").template as<bool>() ) { position_of_largest_eigenvalue=max_idx[0]; for(int i=1; i<M_Nm; i++) { auto modei = ModeSet[i-1]; for(int j=i+1; j<M_Nm; j++) { auto modej = ModeSet[j-1]; double prod = M_model->scalarProductForPod( modei , modej ); CHECK( prod < 1e-10 )<<"scalar product between mode "<<i<<" and mode "<<j<<" is not null and is "<<prod<<"\n"; } double eigenvalue = eigen_values[ position_of_largest_eigenvalue ]; double prod = M_model->scalarProductForPod( modei , modei ); { CHECK( (prod - eigenvalue) < 1e-12 )<<"scalar product between mode "<<i<<" and mode "<<i<<" is "<<prod<<" and associated eigenvalue : "<<eigenvalue<<" ( i = "<<i<<") \n"; } if( i < max_idx.size() ) position_of_largest_eigenvalue=max_idx[i]; } } if ( M_store_pod_matrix_format_octave ) { std::cout<<"M_store_pod_matrix_format_octave = "<<M_store_pod_matrix_format_octave<<std::endl; std::ofstream eigenvalue_file; eigenvalue_file.open( "eigen_values.mat",std::ios::out ); eigenvalue_file<<"# name: E\n"; eigenvalue_file<<"# type: matrix\n"; eigenvalue_file<<"# rows: "<<number_of_eigenvalues<<"\n"; eigenvalue_file<<"# columns: 1\n"; for ( int i=0; i<number_of_eigenvalues; i++ ) { eigenvalue_file<<std::setprecision( 16 )<<eigen_values[i]<<"\n"; } eigenvalue_file.close(); std::ofstream eigenvector_file( ( boost::format( "eigen_vectors" ) ).str().c_str() ); for ( int j=0; j<M_pod_matrix.cols(); j++ ) { for ( int i=0; i<number_of_eigenvalues; i++ ) { eigenvector_file<<std::setprecision( 16 )<<eigen_solver.eigenvectors().col( i )[j] <<" "; } eigenvector_file<<"\n"; } eigenvector_file.close(); for ( int i=0; i<M_Nm; i++ ) { std::ofstream mode_file( ( boost::format( "mode_%1%" ) %i ).str().c_str() ); element_type e = ModeSet[i]; for ( size_type j=0; j<e.size(); j++ ) mode_file<<std::setprecision( 16 )<<e( j )<<"\n"; mode_file.close(); } } return M_Nm; }
void BufferedSerialDevice::update(ofEventArgs& args) { if (!isOpen()) return; Poco::Buffer<uint8_t> buffer(UPDATE_BUFFER_SIZE); try { while (available()) { std::size_t nBytes = pSerial->read(buffer.begin(), UPDATE_BUFFER_SIZE); for (std::size_t i = 0; i < nBytes; ++i) { if (buffer[i] == _marker) { // Decode the buffer if needed. //decodeBuffer(); // Send the buffer if there are any bytes. if (buffer.size() > 0) { SerialBufferEventArgs args(_buffer); ofNotifyEvent(events.onSerialBuffer, args, this); } _buffer.reserve(_maxBufferSize); _buffer.clear(); } else { if (_buffer.size() + 1 >= _maxBufferSize) { // Send the overflow; std::stringstream ss; ss << "maxBufferSize exceeded: " << _maxBufferSize; Poco::Exception exception(ss.str()); SerialBufferErrorEventArgs args(exception, _buffer); ofNotifyEvent(events.onSerialError, args, this); _buffer.reserve(_maxBufferSize); _buffer.clear(); } _buffer.writeByte(buffer[i]); } } } } catch (const Poco::Exception& exc) { SerialBufferErrorEventArgs args(exc); ofNotifyEvent(events.onSerialError, args, this); } catch (const std::exception& exc) { Poco::Exception e(exc.what()); SerialBufferErrorEventArgs args(e); ofNotifyEvent(events.onSerialError, args, this); } catch (...) { Poco::Exception exc("Unknown error."); SerialBufferErrorEventArgs args(exc); ofNotifyEvent(events.onSerialError, args, this); } }
int main(int argc, char **argv) { const int d = 5; const int da[5] = {0}; S4 e(4); S5 g(5); S3 m; S6 n(2); int i; int &j = i; #pragma omp parallel #pragma omp single firstprivate // expected-error {{expected '(' after 'firstprivate'}} foo(); #pragma omp parallel #pragma omp single firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} foo(); #pragma omp parallel #pragma omp single firstprivate() // expected-error {{expected expression}} foo(); #pragma omp parallel #pragma omp single firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} foo(); #pragma omp parallel #pragma omp single firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} foo(); #pragma omp parallel #pragma omp single firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} foo(); #pragma omp parallel #pragma omp single firstprivate(argc) foo(); #pragma omp parallel #pragma omp single firstprivate(S1) // expected-error {{'S1' does not refer to a value}} foo(); #pragma omp parallel #pragma omp single firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} foo(); #pragma omp parallel #pragma omp single firstprivate(argv[1]) // expected-error {{expected variable name}} foo(); #pragma omp parallel #pragma omp single firstprivate(2 * 2) // expected-error {{expected variable name}} foo(); #pragma omp parallel #pragma omp single firstprivate(ba) // OK foo(); #pragma omp parallel #pragma omp single firstprivate(ca) // OK foo(); #pragma omp parallel #pragma omp single firstprivate(da) // OK foo(); int xa; #pragma omp parallel #pragma omp single firstprivate(xa) // OK foo(); #pragma omp parallel #pragma omp single firstprivate(S2::S2s) // OK foo(); #pragma omp parallel #pragma omp single firstprivate(S2::S2sc) // OK foo(); #pragma omp parallel #pragma omp single safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp single'}} foo(); #pragma omp parallel #pragma omp single firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} foo(); #pragma omp parallel #pragma omp single firstprivate(m) // OK foo(); #pragma omp parallel #pragma omp single firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}} foo(); #pragma omp parallel #pragma omp single private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}} foo(); #pragma omp parallel shared(xa) #pragma omp single firstprivate(xa) // OK: may be firstprivate foo(); #pragma omp parallel #pragma omp single firstprivate(j) foo(); #pragma omp parallel #pragma omp single firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}} foo(); #pragma omp parallel #pragma omp single firstprivate(n) // OK foo(); #pragma omp parallel { int v = 0; int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp single' directive into a parallel or another task region?}} #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}} foo(); v += i; } #pragma omp parallel private(i) // expected-note {{defined as private}} #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}} foo(); #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}} #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}} foo(); static int t; #pragma omp single firstprivate(t) // OK foo(); return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} }
int main(int argc, char **argv) { const int d = 5; // expected-note {{constant variable is predetermined as shared}} const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}} S4 e(4); S5 g(5); S3 m; S6 n(2); int i; int &j = i; float k; #pragma omp target teams distribute parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate() // expected-error {{expected expression}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(argc) for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(argv[1]) // expected-error {{expected variable name}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(2 * 2) // expected-error {{expected variable name}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(ba) for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(da) // expected-error {{shared variable cannot be lastprivate}} for (i = 0; i < argc; ++i) foo(); int xa; #pragma omp target teams distribute parallel for lastprivate(xa) // OK for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(xa) for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(j) for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for lastprivate(n) firstprivate(n) // OK for (i = 0; i < argc; ++i) foo(); static int si; #pragma omp target teams distribute parallel for lastprivate(si) // OK for (i = 0; i < argc; ++i) si = i + 1; #pragma omp target teams distribute parallel for lastprivate(k) map(k) // expected-error {{lastprivate variable cannot be in a map clause in '#pragma omp target teams distribute parallel for' directive}} expected-note {{defined as lastprivate}} for (i = 0; i < argc; ++i) foo(); return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} }
int foomain(int argc, char **argv) { I e(4); C g(5); int i; int &j = i; #pragma omp parallel #pragma omp single firstprivate // expected-error {{expected '(' after 'firstprivate'}} foo(); #pragma omp parallel #pragma omp single firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} foo(); #pragma omp parallel #pragma omp single firstprivate() // expected-error {{expected expression}} foo(); #pragma omp parallel #pragma omp single firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} foo(); #pragma omp parallel #pragma omp single firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} foo(); #pragma omp parallel #pragma omp single firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} foo(); #pragma omp parallel #pragma omp single firstprivate(argc) foo(); #pragma omp parallel #pragma omp single firstprivate(S1) // expected-error {{'S1' does not refer to a value}} foo(); #pragma omp parallel #pragma omp single firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}} foo(); #pragma omp parallel #pragma omp single firstprivate(argv[1]) // expected-error {{expected variable name}} foo(); #pragma omp parallel #pragma omp single firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} foo(); #pragma omp parallel #pragma omp single firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} foo(); #pragma omp parallel #pragma omp single linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp single'}} foo(); #pragma omp parallel { int v = 0; int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp single' directive into a parallel or another task region?}} #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}} foo(); v += i; } #pragma omp parallel shared(i) #pragma omp parallel private(i) #pragma omp single firstprivate(j) foo(); #pragma omp parallel #pragma omp single firstprivate(i) foo(); #pragma omp parallel #pragma omp single firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}} foo(); #pragma omp parallel private(i) // expected-note {{defined as private}} #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}} foo(); #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}} #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}} foo(); return 0; }
// // Queues an EVT_TOOLBAR_UPDATED command event to notify any // interest parties of an updated toolbar or dock layout // void ToolManager::Updated() { // Queue an update event wxCommandEvent e( EVT_TOOLBAR_UPDATED ); mParent->GetEventHandler()->AddPendingEvent( e ); }
int _tmain(int argc, _TCHAR* argv[]) { //q::IHttp* httpclient = q::create(3); // RefPtr<DownloadController> controller = new DownloadController; // if(0 != downloaders->download( // "http://sq2.newhua.com/down/LeapFTP3.0.1.46_yfy.zip", // "C:\\a.zip", // controller // )) // { // printf("error create download task."); // } //RefPtr<q::IHttpRequest> request; //httpclient->createHttpRequest(&request.ptr_); ////"http://localhost/phpkind/?app=cdmusic&mod=service&inajax=true&action=top100", //if(!request->open( // "http://sq2.newhua.com/down/LeapFTP3.0.1.46_yfy.zip", // q::GET, // new ReadyStateChange, // "D:\\test.wma" // )) //{ // printf("error create download task."); //} //request->send(); //std::streambuf* old = std::cout.rdbuf(); // while(true) { // Sleep(1000); // system("cls"); // std::cout << "downloaded: " << controller->get_download() << " bytes"; // // if(controller->IsCompleted()) { // printf("Download Completed.\r\n"); // break; // } // } // controller->Dump(); // httpclient->release(); // system("pause"); //return 0; // #ifdef USING_TestCode // QUI::Color::doTest(); // #endif // std::cout << "value is A = " << (int)((unsigned char)(value >> 24)) << std::endl; // unsigned long value = 0x01020304; // std::cout << "value is R" << (int)((unsigned char)value) << std::endl; // std::cout << "value is G" << (int)((unsigned char)(value >> 8)) << std::endl; // std::cout << "value is B" << (int)((unsigned char)(value >> 16)) << std::endl; // std::cout << "value is A" << (int)((unsigned char)(value >> 24)) << std::endl; // return 0; // tstring sPath = _T("a/b/c/d/e.htm"); // ZZipFile::ZZipFileTree::PathType path; // ZZipFile::ZZipFileTree::String2Path(sPath, path); // tstring sPathOutput; // ZZipFile::ZZipFileTree::Path2String(path,sPathOutput); bool bRet = true; // TODO: // do something std::cout << "ZZipApp is running" << std::endl; wchar_t WCharString[] = {0xff,0x22,0xad,0x33,0x00}; tstring sString = _T("abcdefghijklmn"); sString.append(1, _T('\0')); sString.append(1, _T('\0')); sString.append(1, _T('\0')); std::cout << wcslen(sString.c_str()) << std::endl; std::cout << sString.size() << std::endl; std::cout << sizeof(ZZipFileItem) << std::endl; ZZipFile zzip; // if(argc <= 1) { return 0; } tstring sZZipFileName = _T("D:/Developing/VCCode/trunk/QUI/Wayixia/res/skin.zzip"); // if(zzip.Open(argv[1])) { if(zzip.Open(sZZipFileName)) { zzip.AddFolder(_T("/"), _T("D:/Developing/VCCode/trunk/QUI/Wayixia/skin")); // zzip.AddFile(_T("/1.txt"), _T("C:\\1.txt")); // zzip.AddFile(_T("/2.txt"), _T("C:\\2.txt")); // zzip.AddFile(_T("/3.txt"), _T("C:\\3.txt")); // zzip.AddFile(_T("/4.gif"), _T("C:\\4.gif")); zzip.Save(); zzip.Close(); } ZZipFile zzip2; if(zzip2.Open(sZZipFileName)) { // 枚举文件 EnumItems e(zzip2, _T("/"), true); // ZZipFile::ZZipFileTree::ValueTravEvent evt; // evt += std::make_pair(&e, &EnumItems::EnumFile); // zzip.EnumItem(_T("/"), evt, false); // evt -= std::make_pair(&e, &EnumItems::EnumFile); // ZZipEnum<EnumItems>(zzip2, _T("/drawables"), false); // // // 读取文件"/4.gif" 保存到 "C:\\tt.gif" // RefPtr<ZZipFileObject> p = zzip.FindFile(_T("/4.gif")); // if(NULL != p) { // std::ofstream of(_T("C:\\tt.gif"), std::ios::out|std::ios::binary); // if(of.good()) { // char buffer[1024] = {0}; // int64 filesize = p->filesize(); // int64 startpos = 0; // int64 fcount = filesize; // while(fcount > 0) { // int64 ReadBytes = zzip.ReadData(p, startpos, (void*)buffer, 1024); // if(ReadBytes > 0) { // fcount -= ReadBytes; // startpos += ReadBytes; // of.write(buffer, ReadBytes); // } else { // break; // } // } // of.close(); // } // } zzip2.Close(); } return 0; }
template<class I, class C> int foomain(I argc, C **argv) { I e(argc); I g(argc); int i; // expected-note {{declared here}} expected-note {{'i' defined here}} // expected-note@+2 {{declared here}} // expected-note@+1 {{reference to 'i' is not a constant expression}} int &j = i; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned // expected-error {{expected '(' after 'aligned'}} for (I k = 0; k < argc; ++k) ++k; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (I k = 0; k < argc; ++k) ++k; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned () // expected-error {{expected expression}} for (I k = 0; k < argc; ++k) ++k; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} for (I k = 0; k < argc; ++k) ++k; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (I k = 0; k < argc; ++k) ++k; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} for (I k = 0; k < argc; ++k) ++k; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned (argc : 5) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}} for (I k = 0; k < argc; ++k) ++k; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned (S1) // expected-error {{'S1' does not refer to a value}} for (I k = 0; k < argc; ++k) ++k; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned (argv[1]) // expected-error {{expected variable name}} for (I k = 0; k < argc; ++k) ++k; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned(e, g) for (I k = 0; k < argc; ++k) ++k; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned(h) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}} for (I k = 0; k < argc; ++k) ++k; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned(i) // expected-error {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} for (I k = 0; k < argc; ++k) ++k; #pragma omp parallel { int *v = 0; I i; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned(v:16) for (I k = 0; k < argc; ++k) { i = k; v += 2; } } float *f; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned(f) for (I k = 0; k < argc; ++k) ++k; int v = 0; #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned(f:j) // expected-note {{initializer of 'j' is not a constant expression}} expected-error {{expression is not an integral constant expression}} for (I k = 0; k < argc; ++k) { ++k; v += j; } #pragma omp target #pragma omp teams #pragma omp distribute parallel for simd aligned(f) for (I k = 0; k < argc; ++k) ++k; return 0; }
void *ICQSearchResult::processEvent(Event *e) { if ((e->type() > EventUser) && m_id && (m_id != SEARCH_FAIL)){ ICQPlugin *plugin = static_cast<ICQPlugin*>(m_client->protocol()->plugin()); if (e->type() == plugin->EventSearch){ SearchResult *result = (SearchResult*)(e->param()); if ((result->id == m_id) && (result->client == m_client)){ new UserTblItem(tblUser, m_client, &result->data); m_nFound++; setStatus(); } } if (e->type() == plugin->EventSearchDone){ SearchResult *result = (SearchResult*)(e->param()); if ((result->id == m_id) && (result->client == m_client)) setRequestId(0); } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->menu_id == static_cast<ICQPlugin*>(m_client->protocol()->plugin())->MenuSearchResult){ Contact *contact; if (cmd->id == static_cast<ICQPlugin*>(m_client->protocol()->plugin())->CmdSendMessage){ contact = createContact(CONTACT_TEMP); if (!contact) return NULL; Message msg(MessageGeneric); msg.setContact(contact->id()); Event e(EventOpenMessage, &msg); e.process(); } if (cmd->id == CmdInfo){ contact = createContact(CONTACT_TEMP); if (!contact) return NULL; m_client->addFullInfoRequest(atol(tblUser->currentItem()->text(0).latin1()), true); Command cmd; cmd->id = CmdInfo; cmd->menu_id = MenuContact; cmd->param = (void*)contact->id(); Event e(EventCommandExec, cmd); e.process(); } return e->param(); } if (cmd->menu_id == static_cast<ICQPlugin*>(m_client->protocol()->plugin())->MenuGroups){ Contact *contact = createContact(0); if (!contact) return NULL; contact->setGroup(cmd->id - 1); Event eContact(EventContactChanged, contact); eContact.process(); return e->param(); } } if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->menu_id == static_cast<ICQPlugin*>(m_client->protocol()->plugin())->MenuGroups) && (cmd->id == static_cast<ICQPlugin*>(m_client->protocol()->plugin())->CmdGroups)){ unsigned n = 1; ContactList::GroupIterator it; while (++it) n++; CommandDef *cmds = new CommandDef[n]; memset(cmds, 0, sizeof(CommandDef) * n); n = 0; it.reset(); Group *grp; while ((grp = ++it) != NULL){ cmds[n].id = grp->id() + 1; cmds[n].text = "_"; QString name = grp->getName(); if (grp->id() == 0) name = i18n("Not in list"); cmds[n].text_wrk = strdup(name.utf8()); n++; } cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; return e->param(); } } return NULL; }
bool mdtSerialPortPosix::checkConfig(mdtSerialPortConfig cfg) { Q_ASSERT(pvFd >= 0); // Get current system config tcgetattr(pvFd, &pvTermios); // Check static coded flags if(!(pvTermios.c_cflag & (CLOCAL | CREAD))){ mdtError e(MDT_UNDEFINED_ERROR, "CLOCAL and CREAD are not set", mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); return false; } if(pvTermios.c_lflag & (ICANON | ECHO | ECHOE | ISIG)){ mdtError e(MDT_UNDEFINED_ERROR, "raw data mode not set", mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); return false; } if(pvTermios.c_oflag & OPOST){ mdtError e(MDT_UNDEFINED_ERROR, "raw data mode not set (OPOST is on)", mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); return false; } // Check parameters given by cfg if(baudRate() != cfg.baudRate()){ mdtError e(MDT_UNDEFINED_ERROR, "baud rate is not set", mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); return false; } if(dataBits() != cfg.dataBitsCount()){ mdtError e(MDT_UNDEFINED_ERROR, "data bits count is not set", mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); return false; } if(stopBits() != cfg.stopBitsCount()){ qDebug() << "stopBits(): " << stopBits() << " , cfg: " << cfg.stopBitsCount(); mdtError e(MDT_UNDEFINED_ERROR, "stop bits count is not set", mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); return false; } if(parity() != cfg.parity()){ mdtError e(MDT_UNDEFINED_ERROR, "parity is not set", mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); return false; } if(flowCtlRtsCtsOn() != cfg.flowCtlRtsCtsEnabled()){ mdtError e(MDT_UNDEFINED_ERROR, "Flow ctl RTS/CTS is not set", mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); return false; } if(flowCtlXonXoffOn() != cfg.flowCtlXonXoffEnabled()){ mdtError e(MDT_UNDEFINED_ERROR, "Flow ctl Xon/Xoff is not set", mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); return false; } if(cfg.flowCtlXonXoffEnabled()){ if(pvTermios.c_cc[VSTART] != cfg.xonChar()){ mdtError e(MDT_UNDEFINED_ERROR, "Xon char is not set", mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); return false; } if(pvTermios.c_cc[VSTOP] != cfg.xoffChar()){ mdtError e(MDT_UNDEFINED_ERROR, "Xoff char is not set", mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); return false; } } return true; }
int main(int argc, const char* argv[]) { // // Set any additional text that should accumpany specific results: // extra_text["msvc-dist-beta-R-quantile"] = "[footnote There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.]"; extra_text["msvc-dist-nbinom-R-quantile"] = "[footnote The R library appears to use a linear-search strategy, that can perform very badly in a small number of pathological cases, but may or may not be more efficient in \"typical\" cases]"; extra_text["gcc-4_3_2-dist-beta-R-quantile"] = "[footnote There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.]"; extra_text["gcc-4_3_2-dist-nbinom-R-quantile"] = "[footnote The R library appears to use a linear-search strategy, that can perform very badly in a small number of pathological cases, but may or may not be more efficient in \"typical\" cases]"; extra_text["msvc-dist-hypergeometric-cdf"] = "[footnote This result is somewhat misleading: for small values of the parameters there is virtually no difference between the two libraries, but for large values the Boost implementation is /much/ slower, albeit with much improved precision.]"; extra_text["msvc-dist-nt-R-quantile"] = "[footnote There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.]"; extra_text["msvc-dist-nchisq-R-quantile"] = "[footnote There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.]"; extra_text["gcc-4_3_2-dist-hypergeometric-cdf"] = "[footnote This result is somewhat misleading: for small values of the parameters there is virtually no difference between the two libraries, but for large values the Boost implementation is /much/ slower, albeit with much improved precision.]"; extra_text["gcc-4_3_2-dist-nt-R-quantile"] = "[footnote There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.]"; extra_text["gcc-4_3_2-dist-nchisq-R-quantile"] = "[footnote There are a small number of our test cases where the R library fails to converge on a result: these tend to dominate the performance result.]"; boost::regex e("^Testing\\s+(\\S+)\\s+(\\S+)"); std::string f; for(int i = 1; i < argc-1; ++i) { std::ifstream is(argv[i]); load_file(f, is); boost::sregex_iterator a(f.begin(), f.end(), e), b; while(a != b) { results[(*a).str(1)] = boost::lexical_cast<double>((*a).str(2)); ++a; } } // // Load quickbook file: // std::ifstream is(argv[argc-1]); std::string bak_file = std::string(argv[argc-1]).append(".bak"); std::ofstream os(bak_file.c_str()); e.assign( "\\[perf\\s+([^\\s.]+)" "(?:" "\\[[^\\]\\[]*" "(?:\\[[^\\]\\[]*\\][^\\]\\[]*)?" "\\]" "|[^\\]]" ")*\\]"); std::string newfile; while(is.good()) { std::getline(is, f); os << f << std::endl; boost::sregex_iterator i(f.begin(), f.end(), e), j; double min = (std::numeric_limits<double>::max)(); while(i != j) { std::cout << (*i).str() << std::endl << (*i).str(1) << std::endl; std::string item = (*i).str(1); if(results.find(item) != results.end()) { double r = results[item]; if(r < min) min = r; } ++i; } // // Now perform the substitutions: // std::string newstr; std::string tail; i = boost::sregex_iterator(f.begin(), f.end(), e); while(i != j) { std::string item = (*i).str(1); newstr.append(i->prefix()); if(results.find(item) != results.end()) { double v = results[item]; double r = v / min; newstr += std::string((*i)[0].first, (*i)[1].second); newstr += "..[para "; if(r < 1.01) newstr += "*"; newstr += (boost::format("%.2f") % r).str(); if(r < 1.01) newstr += "*"; if(extra_text.find(item) != extra_text.end()) { newstr += extra_text[item]; } newstr += "][para ("; newstr += (boost::format("%.3e") % results[item]).str(); newstr += "s)]]"; } else { newstr.append(i->str()); std::cerr << "Item " << item << " not found!!" << std::endl; } tail = i->suffix(); ++i; } if(newstr.size()) newfile.append(newstr).append(tail); else newfile.append(f); newfile.append("\n"); } is.close(); std::ofstream ns(argv[argc-1]); ns << newfile; }
bool mdtSerialPortPosix::open(mdtSerialPortConfig &cfg) { QString strNum; // Close previous opened device this->close(); // Try to open port // O_RDWR : Read/write access // O_NOCTTY: not a terminal // O_NDELAY: ignore DCD signal lockMutex(); // In read only mode, we handle no lock if(cfg.readOnly()){ pvFd = ::open(pvName.toStdString().c_str(), O_RDONLY | O_NOCTTY | O_NONBLOCK); }else{ pvFd = pvPortLock->openLocked(pvName, O_RDWR | O_NOCTTY | O_NONBLOCK); } if(pvFd < 0){ pvPortLock->unlock(); mdtError e(MDT_UNDEFINED_ERROR, "Unable to open port: " + pvName, mdtError::Error); e.setSystemError(errno, strerror(errno)); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); unlockMutex(); return false; } // Get current config and save it to pvOriginalTermios if(tcgetattr(pvFd, &pvOriginalTermios) < 0){ ::close(pvFd); pvFd = -1; pvPortLock->unlock(); mdtError e(MDT_UNDEFINED_ERROR, "tcgetattr() failed, " + pvName + " is not a serial port, or is not available", mdtError::Error); e.setSystemError(errno, strerror(errno)); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); unlockMutex(); return false; } // Get current system config on "work copy" if(tcgetattr(pvFd, &pvTermios) < 0){ ::close(pvFd); pvFd = -1; pvPortLock->unlock(); mdtError e(MDT_UNDEFINED_ERROR, "tcgetattr() failed, " + pvName + " is not a serial port, or is not available", mdtError::Error); e.setSystemError(errno, strerror(errno)); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); unlockMutex(); return false; } // Set baud rate if(!setBaudRate(cfg.baudRate())){ ::close(pvFd); pvFd = -1; pvPortLock->unlock(); strNum.setNum(cfg.baudRate()); mdtError e(MDT_UNDEFINED_ERROR, "unsupported baud rate '" + strNum + "' for port " + pvName, mdtError::Error); e.setSystemError(errno, strerror(errno)); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); unlockMutex(); return false; } // Set local mode and enable the receiver pvTermios.c_cflag |= (CLOCAL | CREAD); // Set data bits if(!setDataBits(cfg.dataBitsCount())){ ::close(pvFd); pvFd = -1; pvPortLock->unlock(); strNum.setNum(cfg.dataBitsCount()); mdtError e(MDT_UNDEFINED_ERROR, "unsupported data bits count '" + strNum + "' for port " + pvName, mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); unlockMutex(); return false; } // Set stop bits if(!setStopBits(cfg.stopBitsCount())){ ::close(pvFd); pvFd = -1; pvPortLock->unlock(); strNum.setNum(cfg.stopBitsCount()); mdtError e(MDT_UNDEFINED_ERROR, "unsupported stop bits count '" + strNum + "' for port " + pvName, mdtError::Error); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); unlockMutex(); return false; } // Set parity setParity(cfg.parity()); // Set flow control setFlowCtlRtsCts(cfg.flowCtlRtsCtsEnabled()); setFlowCtlXonXoff(cfg.flowCtlXonXoffEnabled(), cfg.xonChar(), cfg.xoffChar()); // Set raw data mode pvTermios.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); pvTermios.c_oflag &= ~OPOST; // Apply the setup if(tcsetattr(pvFd, TCSANOW, &pvTermios) < 0){ ::close(pvFd); pvFd = -1; pvPortLock->unlock(); mdtError e(MDT_UNDEFINED_ERROR, "unable to apply configuration for port " + pvName, mdtError::Error); e.setSystemError(errno, strerror(errno)); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); unlockMutex(); return false; } // Check if configuration could really be set if(!checkConfig(cfg)){ ::close(pvFd); pvFd = -1; pvPortLock->unlock(); unlockMutex(); return false; } // Set the read/write timeouts setReadTimeout(cfg.readTimeout()); setWriteTimeout(cfg.writeTimeout()); return mdtAbstractPort::open(cfg); }
double addmul_avx() { long long ii; double res; double mul=1.00001; Vec4d a(0.1, 0.2, 0.3, 0.4); Vec4d b(0.5, 0.6, 0.7, 0.8); Vec4d c(0.9, 1.0, 1.1, 1.2); Vec4d d(1.3, 1.4, 1.5, 1.6); Vec4d e(2.1, 2.2, 2.3, 2.4); Vec4d f(2.5, 2.6, 2.7, 2.8); Vec4d g(2.9, 3.0, 3.1, 3.2); Vec4d h(3.3, 3.4, 3.5, 3.6); Vec4d i(4.1, 4.2, 4.3, 4.4); Vec4d j(4.5, 4.6, 4.7, 4.8); Vec4d k(4.9, 5.0, 5.1, 5.2); Vec4d l(5.3, 5.4, 5.5, 5.6); Vec4d m(6.1, 6.2, 6.3, 6.4); Vec4d n(6.5, 6.6, 6.7, 6.8); Vec4d o(6.9, 7.0, 7.1, 7.2); Vec4d p(7.3, 7.4, 7.5, 7.6); for(ii=0; ii< max1*max2 ; ii++) { a=a*c; b=b+d; c=c*e; d=d+f; e=e*g; f=f+h; g=g*i; h=h+j; i=i*k; j=j+l; k=k*m; l=l+n; m=m*o; n=n+p; o=o*a; p=p+b; } res= a[0]+a[1]+a[2]+a[3] + b[0]+b[1]+b[2]+b[3] + c[0]+c[1]+c[2]+c[3] + d[0]+d[1]+d[2]+d[3] + e[0]+e[1]+e[2]+e[3] + f[0]+f[1]+f[2]+f[3] + g[0]+g[1]+g[2]+g[3] + h[0]+h[1]+h[2]+h[3] + i[0]+i[1]+i[2]+i[3] + j[0]+j[1]+j[2]+j[3] + k[0]+k[1]+k[2]+k[3] + l[0]+l[1]+l[2]+l[3] + m[0]+m[1]+m[2]+m[3] + n[0]+n[1]+n[2]+n[3] + o[0]+o[1]+o[2]+o[3] + p[0]+p[1]+p[2]+p[3] ; return res; }
bool mdtSerialPortPosix::setAttributes(const QString &portName) { struct serial_struct serinfo; // Close previous opened port this->close(); // Clear previous attributes pvAvailableBaudRates.clear(); // Try to open port pvFd = ::open(portName.toStdString().c_str(), O_RDONLY | O_NOCTTY | O_NDELAY); if(pvFd < 0){ mdtError e(MDT_UNDEFINED_ERROR, "can not open port '" + portName + "'", mdtError::Error); e.setSystemError(errno, strerror(errno)); MDT_ERROR_SET_SRC(e, "mdtSerialPortPosix"); e.commit(); pvName = ""; return false; } // Set port name pvName = portName; // Set the UART type if(ioctl(pvFd, TIOCGSERIAL, &serinfo) < 0){ pvUartType = UT_UNKNOW; ::close(pvFd); return false; } // Map the type switch(serinfo.type){ case PORT_8250: pvUartType = UT_8250; case PORT_16450: pvUartType = UT_16450; break; case PORT_16550: pvUartType = UT_16550; break; case PORT_16550A: pvUartType = UT_16550A; break; case PORT_CIRRUS: pvUartType = UT_CIRRUS; break; case PORT_16650: pvUartType = UT_16650; break; case PORT_16650V2: pvUartType = UT_16650V2; break; case PORT_16750: pvUartType = UT_16750; break; case PORT_STARTECH: pvUartType = UT_STARTECH; break; case PORT_16C950: pvUartType = UT_16C950; break; case PORT_16654: pvUartType = UT_16654; break; case PORT_16850: pvUartType = UT_16850; break; case PORT_RSA: pvUartType = UT_RSA; break; default: pvUartType = UT_UNKNOW; ::close(pvFd); return false; } // Get available baud rates list pvAvailableBaudRates << 50; pvAvailableBaudRates << 75; pvAvailableBaudRates << 110; pvAvailableBaudRates << 134; // Note: is 134.5 pvAvailableBaudRates << 150; pvAvailableBaudRates << 200; pvAvailableBaudRates << 300; pvAvailableBaudRates << 600; pvAvailableBaudRates << 1200; pvAvailableBaudRates << 1800; pvAvailableBaudRates << 2400; pvAvailableBaudRates << 4800; pvAvailableBaudRates << 9600; pvAvailableBaudRates << 19200; pvAvailableBaudRates << 38400; #ifdef B57600 pvAvailableBaudRates << 57600; #endif #ifdef B76800 pvAvailableBaudRates << 76800; #endif #ifdef B115200 pvAvailableBaudRates << 115200; #endif #ifdef B230400 pvAvailableBaudRates << 230400; #endif #ifdef B460800 pvAvailableBaudRates << 460800; #endif #ifdef B500000 pvAvailableBaudRates << 500000; #endif #ifdef B576000 pvAvailableBaudRates << 576000; #endif #ifdef B921600 pvAvailableBaudRates << 921600; #endif #ifdef B1000000 pvAvailableBaudRates << 1000000; #endif #ifdef B1152000 pvAvailableBaudRates << 1152000; #endif #ifdef B1500000 pvAvailableBaudRates << 1500000; #endif #ifdef B2000000 pvAvailableBaudRates << 2000000; #endif #ifdef B2500000 pvAvailableBaudRates << 2500000; #endif #ifdef B3000000 pvAvailableBaudRates << 3000000; #endif #ifdef B3500000 pvAvailableBaudRates << 3500000; #endif #ifdef B4000000 pvAvailableBaudRates << 4000000; #endif // End of attributes, close port ::close(pvFd); return true; }
int main(int argc, char **argv) { const int d = 5; const int da[5] = { 0 }; S4 e(4); S5 g(5); int i; int &j = i; #pragma omp target #pragma omp teams distribute parallel for shared // expected-error {{expected '(' after 'shared'}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared () // expected-error {{expected expression}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared (argc) for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared (S1) // expected-error {{'S1' does not refer to a value}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared (a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared (argv[1]) // expected-error {{expected variable name}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared(ba) for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared(ca) for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared(da) for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared(e, g) for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}} for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for private(i) for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared(i) for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for shared(j) for (int j=0; j<100; j++) foo(); #pragma omp target #pragma omp teams distribute parallel for firstprivate(i) for (int j=0; j<100; j++) foo(); return 0; }
void do_test(void) { int r, fd; int s[2]; char buf[1], testroot[PATH_MAX+1], renamebuf[PATH_MAX+1]; subtest = 1; if (socketpair(PF_UNIX, SOCK_STREAM, 0, s) == -1) e(1); if (system("mkdir -p " TEST_PATH) == -1) e(2); if (realpath(".", testroot) == NULL) e(3); r = fork(); if (r == -1) e(4); else if (r == 0) { /* Child */ /* Change child's cwd to TEST_PATH */ if (chdir(TEST_PATH) == -1) e(5); /* Signal parent we're ready for the test */ buf[0] = 'a'; if (write(s[0], buf, sizeof(buf)) != sizeof(buf)) e(6); /* Wait for parent to remove my cwd */ if (read(s[0], buf, sizeof(buf)) != sizeof(buf)) e(7); /* Try to create a file */ if ((fd = open("testfile", O_RDWR | O_CREAT)) != -1) { e(8); /* Uh oh. We created a file?! Try to remove it. */ (void) close(fd); if (unlink("testfile") != 0) { /* This is not good. We created a file, but we can * never access it; we have a spurious inode. */ e(9); printf(INTEGR_MSG); exit(errct); } } if (errno != ENOENT) e(10); /* Try to create a dir */ errno = 0; if (mkdir("testdir", 0777) == 0) { e(11); /* Uh oh. This shouldn't have been possible. Try to undo. */ if (rmdir("testdir") != 0) { /* Not good. */ e(12); printf(INTEGR_MSG); exit(errct); } } if (errno != ENOENT) e(13); /* Try to create a special file */ errno = 0; if (mknod("testnode", 0777 | S_IFIFO, 0) == 0) { e(14); /* Impossible. Try to make it unhappen. */ if (unlink("testnode") != 0) { /* Not good. */ e(15); printf(INTEGR_MSG); exit(errct); } } if (errno != ENOENT) e(16); /* Try to rename a file */ errno = 0; /* First create a file in the test dir */ snprintf(renamebuf, PATH_MAX, "%s/oldname", testroot); if ((fd = open(renamebuf, O_RDWR | O_CREAT)) == -1) e(17); if (close(fd) != 0) e(18); /* Now try to rename that file to an entry in the current, non-existing * working directory. */ if (rename(renamebuf, "testrename") == 0) { e(19); /* This shouldn't have been possible. Revert the name change. */ if (rename("testrename", renamebuf) != 0) { /* Failed */ e(20); printf(INTEGR_MSG); exit(errct); } } /* Try to create a hard link to that file */ errno = 0; if (link(renamebuf, "testhlink") == 0) { e(21); /* Try to undo the hard link to prevent fs corruption. */ if (unlink("testhlink") != 0) { /* Failed. */ e(22); printf(INTEGR_MSG); exit(errct); } } if (errno != ENOENT) e(23); /* Try to create a symlink */ errno = 0; if (symlink(testroot, "testslink") == 0) { e(24); /* Try to remove the symlink to prevent fs corruption. */ if (unlink("testslink") != 0) { /* Failed. */ e(25); printf(INTEGR_MSG); exit(errct); } } if (errno != ENOENT) e(26); exit(errct); } else { /* Parent */ int status; /* Wait for the child to enter the TEST_PATH dir */ if (read(s[1], buf, sizeof(buf)) != sizeof(buf)) e(27); /* Delete TEST_PATH */ if (rmdir(TEST_PATH) != 0) e(28); /* Tell child we removed its cwd */ buf[0] = 'b'; if (write(s[1], buf, sizeof(buf)) != sizeof(buf)) e(29); wait(&status); errct += WEXITSTATUS(status); /* Count errors */ } }
void NewClass::rec_type(int i,int j,int type,QString _tname) { tname=_tname; if(type==1){ ui->pushButton->hide(); ui->pushButton_2->hide(); ui->pushButton_4->hide(); ui->pushButton_5->hide(); ui->pushButton_6->hide(); ui->pushButton_7->hide(); ui->pushButton_8->hide(); } QSqlQuery query,q2,q3,q4,q5; QString subname,teacher,classroom,ttype; int week,time,id; time=i; week=j; sendtype=type; switch(i+1){ case 1:ui->label_3->setText("Monday NO."+QString::number(j+1,10));break; case 2:ui->label_3->setText("Tuesday NO."+QString::number(j+1,10));break; case 3:ui->label_3->setText("Wednesday NO."+QString::number(j+1,10));break; case 4:ui->label_3->setText("Thursday NO."+QString::number(j+1,10));break; case 5:ui->label_3->setText("Friday NO."+QString::number(j+1,10));break; case 6:ui->label_3->setText("Saturday NO."+QString::number(j+1,10));break; case 7:ui->label_3->setText("Sunday NO."+QString::number(j+1,10));break; } query.exec("select name,teacher,id,classroom,type from subject where tname='"+tname+"' and time="+i+" and week="+j); query.first(); if(query.next()) { qDebug() << query.value(0).toString() << query.value(1).toString()<<query.value(2).toString()<<query.value(3).toString(); subname=query.value(0).toString(); teacher=query.value(1).toString(); id=query.value(2).toInt(); classroom=query.value(3).toString(); ttype=query.value(4).toString(); ui->comboBox_2->clear(); ui->comboBox_2->addItem(ttype); ui->comboBox_2->show(); ui->lineEdit_3->setText(subname); ui->lineEdit->setText(teacher); ui->lineEdit_2->setText(classroom); q2.exec("select tutor_id from assist where class_id="+id); q2.first(); do{ q3.exec("select name,tel from tutor where id="+q2.value(0).toInt()); if(q3.first()){ Tutor tr(q3.value(0).toString(),q3.value(1).toString()); tr.setId(q2.value(0).toInt()); tutor->append(tr); ui->comboBox->addItem(tr.getName()); ui->comboBox->show(); q4.exec("select mail from mail where tutor_id="+q2.value(0).toInt()); q4.first(); do { Email e(q4.value(0).toString()); e.setId(q2.value(0).toInt()); mail->append( e); }while(q4.next()); } }while(q2.next()); q5.exec("select title,type,time,text,mail from problem where class_id="+id); q5.first(); do{ Problem p(id,q5.value(0).toString(),q5.value(1).toInt(),q5.value(2).toString(), q5.value(3).toString(),q5.value(4).toString()); ui->comboBox_6->addItem(q5.value(0).toString()); problem->append(p); }while(q5.next()); } }
//! compute the error between two visual features from a subset //! a the possible features vpColVector vpFeatureEllipse::error(const vpBasicFeature &s_star, const unsigned int select) { vpColVector e(0) ; try{ if (vpFeatureEllipse::selectX() & select ) { vpColVector ex(1) ; ex[0] = s[0] - s_star[0] ; e = vpMatrix::stackMatrices(e,ex) ; } if (vpFeatureEllipse::selectY() & select ) { vpColVector ey(1) ; ey[0] = s[1] - s_star[1] ; e = vpMatrix::stackMatrices(e,ey) ; } if (vpFeatureEllipse::selectMu20() & select ) { vpColVector ex(1) ; ex[0] = s[2] - s_star[2] ; e = vpMatrix::stackMatrices(e,ex) ; } if (vpFeatureEllipse::selectMu11() & select ) { vpColVector ey(1) ; ey[0] = s[3] - s_star[3] ; e = vpMatrix::stackMatrices(e,ey) ; } if (vpFeatureEllipse::selectMu02() & select ) { vpColVector ey(1) ; ey[0] = s[4] - s_star[4] ; e = vpMatrix::stackMatrices(e,ey) ; } } catch(vpMatrixException me) { vpERROR_TRACE("caught a Matrix related error") ; std::cout <<std::endl << me << std::endl ; throw(me) ; } catch(vpException me) { vpERROR_TRACE("caught another error") ; std::cout <<std::endl << me << std::endl ; throw(me) ; } return e ; }