void Router::wakeup() { flit *t_flit; int incoming_port = m_round_robin_start; // This is for round-robin scheduling of incoming ports m_round_robin_start++; if (m_round_robin_start >= m_in_link.size()) { m_round_robin_start = 0; } for(int port = 0; port < m_in_link.size(); port++) { // Round robin scheduling incoming_port++; if(incoming_port >= m_in_link.size()) incoming_port = 0; if(m_in_link[incoming_port]->isReady()) // checking the incoming link { DEBUG_EXPR(NETWORK_COMP, HighPrio, m_id); DEBUG_EXPR(NETWORK_COMP, HighPrio, g_eventQueue_ptr->getTime()); t_flit = m_in_link[incoming_port]->peekLink(); routeCompute(t_flit, incoming_port); m_in_link[incoming_port]->consumeLink(); } } scheduleOutputLinks(); checkReschedule(); // This is for flits lying in the router buffers vc_arbitrate(); check_arbiter_reschedule(); }
BddNodeHandle BddManager::find_or_insert(BddNodeHandle pBddNode) { assert(pBddNode.valid()); if (pBddNode->isTerminal()) return pBddNode; hash_type::iterator it = _hashBddNode.end(); if ((it = try_find(pBddNode)) != _hashBddNode.end()) { return *it; } BddNodeHandle pPos = pBddNode->getPosHandle(); BddNodeHandle pNeg = pBddNode->getNegHandle(); BddNodeHandle pNewPos = find_or_insert(pPos); BddNodeHandle pNewNeg = find_or_insert(pNeg); BddNodeHandle pNew = BddNode::makeBddNode(pBddNode->getCurDecisionLevel(), pNewPos, pNewNeg); if ((it = try_find(pNew)) != _hashBddNode.end()) { return *it; } else { _hashBddNode.insert(pNew); if (verbose) { DEBUG_EXPR(pNew->toString()); DEBUG_EXPR(pNew->hashFunction()); std::cerr << std::endl; } assert(try_find(pNew) != _hashBddNode.end()); return pNew; } }
void luaK_setoneret (FuncState *fs, expdesc *e) { if (e->k == VCALL) { /* expression is an open function call? */ e->k = VNONRELOC; e->u.info = GETARG_A(getcode(fs, e)); DEBUG_EXPR(raviY_printf(fs, "luaK_setoneret (VCALL->VNONRELOC) %e\n", e)); } else if (e->k == VVARARG) { SETARG_B(getcode(fs, e), 2); DEBUG_CODEGEN(raviY_printf(fs, "[%d]* %o ; set B to 2\n", e->u.info, getcode(fs,e))); e->k = VRELOCABLE; /* can relocate its simple result */ DEBUG_EXPR(raviY_printf(fs, "luaK_setoneret (VVARARG->VNONRELOC) %e\n", e)); } }
void luaK_dischargevars (FuncState *fs, expdesc *e) { switch (e->k) { case VLOCAL: { e->k = VNONRELOC; DEBUG_EXPR(raviY_printf(fs, "luaK_dischargevars (VLOCAL->VNONRELOC) %e\n", e)); break; } case VUPVAL: { e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0); e->k = VRELOCABLE; DEBUG_EXPR(raviY_printf(fs, "luaK_dischargevars (VUPVAL->VRELOCABLE) %e\n", e)); break; } case VINDEXED: { OpCode op = OP_GETTABUP; /* assume 't' is in an upvalue */ freereg(fs, e->u.ind.idx); if (e->u.ind.vt == VLOCAL) { /* 't' is in a register? */ freereg(fs, e->u.ind.t); /* TODO we should do this for upvalues too */ /* table access - set specialized op codes if array types are detected */ if (e->ravi_type == RAVI_TARRAYFLT && e->u.ind.key_type == RAVI_TNUMINT) op = OP_RAVI_GETTABLE_AF; else if (e->ravi_type == RAVI_TARRAYINT && e->u.ind.key_type == RAVI_TNUMINT) op = OP_RAVI_GETTABLE_AI; /* Check that we have a short string constant */ else if (e->ravi_type == RAVI_TTABLE && e->u.ind.key_type == RAVI_TSTRING && isshortstr(fs, e->u.ind.idx)) op = OP_RAVI_GETTABLE_S; else if (e->ravi_type == RAVI_TTABLE && e->u.ind.key_type == RAVI_TNUMINT) op = OP_RAVI_GETTABLE_I; else op = OP_GETTABLE; if (e->ravi_type == RAVI_TARRAYFLT || e->ravi_type == RAVI_TARRAYINT) /* set the type of resulting expression */ e->ravi_type = e->ravi_type == RAVI_TARRAYFLT ? RAVI_TNUMFLT : RAVI_TNUMINT; else e->ravi_type = RAVI_TANY; } e->u.info = luaK_codeABC(fs, op, 0, e->u.ind.t, e->u.ind.idx); e->k = VRELOCABLE; DEBUG_EXPR(raviY_printf(fs, "luaK_dischargevars (VINDEXED->VRELOCABLE) %e\n", e)); break; } case VVARARG: case VCALL: { luaK_setoneret(fs, e); break; } default: break; /* there is one value available (somewhere) */ } }
void NewtonEulerR::initialize(Interaction& inter) { DEBUG_BEGIN("NewtonEulerR::initialize(Interaction& inter)\n"); unsigned int ySize = inter.dimension(); unsigned int xSize = inter.getSizeOfDS(); unsigned int qSize = 7 * (xSize / 6); if (!_jachq) _jachq.reset(new SimpleMatrix(ySize, qSize)); else { if (_jachq->size(0) == 0) { // if the matrix dim are null _jachq->resize(ySize, qSize); } else { assert((_jachq->size(1) == qSize && _jachq->size(0) == ySize) || (printf("NewtonEuler::initializeWorkVectorsAndMatrices _jachq->size(1) = %d ,_qsize = %d , _jachq->size(0) = %d ,_ysize =%d \n", _jachq->size(1), qSize, _jachq->size(0), ySize) && false) || ("NewtonEuler::initializeWorkVectorsAndMatrices inconsistent sizes between _jachq matrix and the interaction." && false)); } } DEBUG_EXPR(_jachq->display()); if (! _jachqT) _jachqT.reset(new SimpleMatrix(ySize, xSize)); if (! _T) { _T.reset(new SimpleMatrix(7, 6)); _T->zero(); _T->setValue(0, 0, 1.0); _T->setValue(1, 1, 1.0); _T->setValue(2, 2, 1.0); } DEBUG_EXPR(_jachqT->display()); VectorOfBlockVectors& DSlink = inter.linkToDSVariables(); if (!_contactForce) { _contactForce.reset(new SiconosVector(DSlink[NewtonEulerR::p1]->size())); _contactForce->zero(); } DEBUG_END("NewtonEulerR::initialize(Interaction& inter)\n"); }
void Tester::hitCallback(NodeID proc, SubBlock& data, CacheRequestType type, int thread) { // Mark that we made progress m_last_progress_vector[proc] = g_eventQueue_ptr->getTime(); g_callback_counter++; // This tells us our store has 'completed' or for a load gives us // back the data to make the check DEBUG_EXPR(TESTER_COMP, MedPrio, proc); DEBUG_EXPR(TESTER_COMP, MedPrio, data); Check* check_ptr = m_checkTable.getCheck(data.getAddress()); assert(check_ptr != NULL); check_ptr->performCallback(proc, data); }
/* Calculate whether an assertion is a standard GObject type check. * .e.g. NSPACE_IS_OBJ(x). * * This is complicated by the fact that type checking is done by macros, which * expand to something like: * (((__extension__ ({ * GTypeInstance *__inst = (GTypeInstance *)((x)); * GType __t = ((nspace_obj_get_type())); * gboolean __r; * if (!__inst) * __r = (0); * else if (__inst->g_class && __inst->g_class->g_type == __t) * __r = (!(0)); * else * __r = g_type_check_instance_is_a(__inst, __t); * __r; * })))) * * Insert the ValueDecls of the variables being checked into the provided * unordered_set, and return the number of such insertions (this will be 0 if no * variables are type checked). The returned number may be an over-estimate * of the number of elements in the set, as it doesn’t account for * duplicates. */ static unsigned int _assertion_is_gobject_type_check (Expr& assertion_expr, const ASTContext& context, std::unordered_set<const ValueDecl*>& ret) { DEBUG_EXPR (__func__ << ": ", assertion_expr); switch ((int) assertion_expr.getStmtClass ()) { case Expr::StmtExprClass: { /* Parse all the way through the statement expression, checking * if the first statement is an assignment to the __inst * variable, as in the macro expansion given above. * * This is a particularly shoddy way of checking for a GObject * type check (we should really check for a * g_type_check_instance_is_a() call) but this will do for * now. */ StmtExpr& stmt_expr = cast<StmtExpr> (assertion_expr); CompoundStmt* compound_stmt = stmt_expr.getSubStmt (); const Stmt* first_stmt = *(compound_stmt->body_begin ()); if (first_stmt->getStmtClass () != Expr::DeclStmtClass) return 0; const DeclStmt& decl_stmt = cast<DeclStmt> (*first_stmt); const VarDecl* decl = dyn_cast<VarDecl> (decl_stmt.getSingleDecl ()); if (decl == NULL) return 0; if (decl->getNameAsString () != "__inst") return 0; const Expr* init = decl->getAnyInitializer ()->IgnoreParenCasts (); const DeclRefExpr* decl_expr = dyn_cast<DeclRefExpr> (init); if (decl_expr != NULL) { ret.insert (decl_expr->getDecl ()); return 1; } return 0; } case Expr::IntegerLiteralClass: case Expr::BinaryOperatorClass: case Expr::UnaryOperatorClass: case Expr::ConditionalOperatorClass: case Expr::CallExprClass: case Expr::ImplicitCastExprClass: { /* These can’t be type checks. */ return 0; } case Stmt::StmtClass::NoStmtClass: default: WARN_EXPR (__func__ << "() can’t handle expressions of type " << assertion_expr.getStmtClassName (), assertion_expr); return 0; } }
void NetworkInterface::wakeup() { MsgPtr msg_ptr; //Checking for messages coming from the protocol for (int vnet = 0; vnet < m_virtual_networks; vnet++) // can pick up a message/cycle for each virtual net { while(inNode_ptr[vnet]->isReady()) // Is there a message waiting { msg_ptr = inNode_ptr[vnet]->peekMsgPtr(); if(flitisizeMessage(msg_ptr, vnet)) { inNode_ptr[vnet]->pop(); } else { break; } } } scheduleOutputLink(); checkReschedule(); /*********** Picking messages destined for this NI **********/ if(inNetLink->isReady()) { flit *t_flit = inNetLink->consumeLink(); if(t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) { DEBUG_EXPR(NETWORK_COMP, HighPrio, m_id); DEBUG_MSG(NETWORK_COMP, HighPrio, "Message got delivered"); DEBUG_EXPR(NETWORK_COMP, HighPrio, g_eventQueue_ptr->getTime()); if(!NetworkConfig::isNetworkTesting()) // When we are doing network only testing, the messages do not have to be buffered into the message buffers { outNode_ptr[t_flit->get_vnet()]->enqueue(t_flit->get_msg_ptr(), 1); // enqueueing for protocol buffer. This is not required when doing network only testing } inNetLink->release_vc_link(t_flit->get_vc(), g_eventQueue_ptr->getTime() + 1); // signal the upstream router that this vc can be freed now } delete t_flit; } }
void Check::performCallback(NodeID proc, SubBlock& data) { Address address = data.getAddress(); // assert(getAddress() == address); // This isn't exactly right since we now have multi-byte checks assert(getAddress().getLineAddress() == address.getLineAddress()); DEBUG_MSG(TESTER_COMP, MedPrio, "Callback"); DEBUG_EXPR(TESTER_COMP, MedPrio, *this); if (m_status == TesterStatus_Action_Pending) { DEBUG_MSG(TESTER_COMP, MedPrio, "Action callback"); // Perform store data.setByte(0, m_value+m_store_count); // We store one byte at a time m_store_count++; if (m_store_count == CHECK_SIZE) { m_status = TesterStatus_Ready; } else { m_status = TesterStatus_Idle; } } else if (m_status == TesterStatus_Check_Pending) { DEBUG_MSG(TESTER_COMP, MedPrio, "Check callback"); // Perform load/check for(int byte_number=0; byte_number<CHECK_SIZE; byte_number++) { if (uint8(m_value+byte_number) != data.getByte(byte_number) && (DATA_BLOCK == true)) { WARN_EXPR(proc); WARN_EXPR(address); WARN_EXPR(data); WARN_EXPR(byte_number); WARN_EXPR((int)m_value+byte_number); WARN_EXPR((int)data.getByte(byte_number)); WARN_EXPR(*this); WARN_EXPR(g_eventQueue_ptr->getTime()); ERROR_MSG("Action/check failure"); } } DEBUG_MSG(TESTER_COMP, HighPrio, "Action/check success:"); DEBUG_EXPR(TESTER_COMP, HighPrio, *this); DEBUG_EXPR(TESTER_COMP, MedPrio, data); m_status = TesterStatus_Idle; pickValue(); } else { WARN_EXPR(*this); WARN_EXPR(proc); WARN_EXPR(data); WARN_EXPR(m_status); WARN_EXPR(g_eventQueue_ptr->getTime()); ERROR_MSG("Unexpected TesterStatus"); } DEBUG_EXPR(TESTER_COMP, MedPrio, proc); DEBUG_EXPR(TESTER_COMP, MedPrio, data); DEBUG_EXPR(TESTER_COMP, MedPrio, getAddress().getLineAddress()); DEBUG_MSG(TESTER_COMP, MedPrio, "Callback done"); DEBUG_EXPR(TESTER_COMP, MedPrio, *this); }
void KneeJointR::computeh(double time, BlockVector& q0, SiconosVector& y) { DEBUG_BEGIN("KneeJointR::computeh(double time, BlockVector& q0, SiconosVector& y)\n"); DEBUG_EXPR(q0.display()); double X1 = q0.getValue(0); double Y1 = q0.getValue(1); double Z1 = q0.getValue(2); double q10 = q0.getValue(3); double q11 = q0.getValue(4); double q12 = q0.getValue(5); double q13 = q0.getValue(6); DEBUG_PRINTF("X1 = %12.8e,\t Y1 = %12.8e,\t Z1 = %12.8e,\n",X1,Y1,Z1); DEBUG_PRINTF("q10 = %12.8e,\t q11 = %12.8e,\t q12 = %12.8e,\t q13 = %12.8e,\n",q10,q11,q12,q13); double X2 = 0; double Y2 = 0; double Z2 = 0; double q20 = 1; double q21 = 0; double q22 = 0; double q23 = 0; if(q0.getNumberOfBlocks()>1) { // SP::SiconosVector x2 = _d2->q(); // DEBUG_EXPR( _d2->q()->display();); X2 = q0.getValue(7); Y2 = q0.getValue(8); Z2 = q0.getValue(9); q20 = q0.getValue(10); q21 = q0.getValue(11); q22 = q0.getValue(12); q23 = q0.getValue(13); } y.setValue(0, Hx(X1, Y1, Z1, q10, q11, q12, q13, X2, Y2, Z2, q20, q21, q22, q23)); y.setValue(1, Hy(X1, Y1, Z1, q10, q11, q12, q13, X2, Y2, Z2, q20, q21, q22, q23)); y.setValue(2, Hz(X1, Y1, Z1, q10, q11, q12, q13, X2, Y2, Z2, q20, q21, q22, q23)); DEBUG_EXPR(y.display()); DEBUG_END("KneeJointR::computeh(double time, BlockVector& q0, SiconosVector& y)\n"); }
void RequestGenerator::wakeup() { DEBUG_EXPR(TESTER_COMP, MedPrio, m_node); DEBUG_EXPR(TESTER_COMP, MedPrio, m_status); if (m_status == RequestGeneratorStatus_Thinking) { m_status = RequestGeneratorStatus_Test_Pending; m_last_transition = g_eventQueue_ptr->getTime(); initiateTest(); // Test } else if (m_status == RequestGeneratorStatus_Holding) { m_status = RequestGeneratorStatus_Release_Pending; m_last_transition = g_eventQueue_ptr->getTime(); initiateRelease(); // Release } else if (m_status == RequestGeneratorStatus_Before_Swap) { m_status = RequestGeneratorStatus_Swap_Pending; m_last_transition = g_eventQueue_ptr->getTime(); initiateSwap(); } else { WARN_EXPR(m_status); ERROR_MSG("Invalid status"); } }
void Check::initiateAction() { DEBUG_MSG(TESTER_COMP, MedPrio, "initiating Action"); assert(m_status == TesterStatus_Idle); CacheRequestType type = CacheRequestType_ST; if ((random() & 0x1) == 0) { // 50% chance type = CacheRequestType_ATOMIC; } CacheMsg request(Address(m_address.getAddress()+m_store_count), Address(m_address.getAddress()+m_store_count), type, m_pc, m_access_mode, 1, PrefetchBit_No, 0, Address(0), 0 /* only 1 SMT thread */, 0, false); Sequencer* sequencer_ptr = initiatingSequencer(); if (sequencer_ptr->isReady(request) == false) { DEBUG_MSG(TESTER_COMP, MedPrio, "failed to initiate action - sequencer not ready\n"); } else { DEBUG_MSG(TESTER_COMP, MedPrio, "initiating action - successful\n"); DEBUG_EXPR(TESTER_COMP, MedPrio, m_status); m_status = TesterStatus_Action_Pending; sequencer_ptr->makeRequest(request); } DEBUG_EXPR(TESTER_COMP, MedPrio, m_status); }
BddManager::hash_type::iterator BddManager::try_find(BddNodeHandle pBddNode) { hash_type::iterator it = _hashBddNode.end(); if (verbose) DEBUG_EXPR(_hashBddNode.size()); if ((it = _hashBddNode.find(pBddNode)) != _hashBddNode.end()) { if (verbose) std::cerr << "Try find (OK): " << pBddNode->toString() << std::endl; return it; } if (verbose) std::cerr << "Try find (Fail): " << pBddNode->toString() << std::endl; return _hashBddNode.end(); }
void Check::initiate() { DEBUG_MSG(TESTER_COMP, MedPrio, "initiating"); DEBUG_EXPR(TESTER_COMP, MedPrio, *this); // current CMP protocol doesn't support prefetches if (!Protocol::m_CMP && (random() & 0xf) == 0) { // 1 in 16 chance initiatePrefetch(); // Prefetch from random processor } if(m_status == TesterStatus_Idle) { initiateAction(); } else if(m_status == TesterStatus_Ready) { initiateCheck(); } else { // Pending - do nothing DEBUG_MSG(TESTER_COMP, MedPrio, "initiating action/check - failed: action/check is pending\n"); } }
void BulletDS::updateCollisionObjects() const { for(CollisionObjects::iterator ico = _collisionObjects->begin(); ico != _collisionObjects->end(); ++ ico) { SP::btCollisionObject collisionObject = boost::get<0>((*ico).second); OffSet offset = boost::get<1>((*ico).second); SiconosVector& q = *_q; DEBUG_EXPR(q.display()); /* with 32bits input ... 1e-7 */ assert(fabs(sqrt(pow(q(3), 2) + pow(q(4), 2) + pow(q(5), 2) + pow(q(6), 2)) - 1.) < 1e-7); btQuaternion rbase = btQuaternion(q(4), q(5), q(6), q(3)); btVector3 boffset = btVector3(offset[0], offset[1], offset[2]); btVector3 rboffset = quatRotate(rbase, boffset); collisionObject->getWorldTransform().setOrigin(btVector3(q(0)+rboffset[0], q(1)+rboffset[1], q(2)+rboffset[2])); collisionObject->getWorldTransform().getBasis(). setRotation(rbase * btQuaternion(offset[4], offset[5], offset[6], offset[3])); /* is this needed ? */ collisionObject->setActivationState(ACTIVE_TAG); collisionObject->activate(); //_collisionObject->setContactProcessingThreshold(BT_LARGE_FLOAT); } }
void NetworkLink_CN::wakeup() { //Here I modify the codes //Assume each NetworkLink_CN that connected to the NetworkInterface_CN has multiple link_srcQueues //each link_srcQueue corresponds to one other port in the switch ( excluding the local port ) if (m_dest_intf != NULL && g_eventQueue_ptr->getTime() > DEBUG_START_TIME) { // assert(0 && "m_dest_intf networklink_cn wakeup!!"); DEBUG_EXPR(NETWORK_COMP, MedPrio, g_eventQueue_ptr->getTime()); DEBUG_MSG(NETWORK_COMP, MedPrio, "m_dest_intf: " + int_to_string(m_dest_intf->get_id()) + " executing!"); DEBUG_MSG(NETWORK_COMP, MedPrio, "link_srcQueue.size() = " + int_to_string(link_srcQueue.size())); for(int index = 0; index < link_srcQueue.size(); index++) { if(link_srcQueue[index]->isReady()) { DEBUG_MSG(NETWORK_COMP, MedPrio, "########Debuging inNetLink of NI: " + int_to_string(m_id) + " -------- NetworkLink_CN: link_srcQueue_index: " + int_to_string(index)); DEBUG_EXPR(NETWORK_COMP, MedPrio, *(link_srcQueue[index])); } // DEBUG_MSG(NETWORK_COMP, MedPrio, "########Debuging inNetLink of NI: " + int_to_string(m_id) + " -------- NetworkLink_CN: link_srcQueue_index: " + int_to_string(index)); DEBUG_MSG(NETWORK_COMP, MedPrio, "link_srcQueue[" + int_to_string(index) + "] 's size = " + int_to_string( link_srcQueue[index]->numElements() )); if(m_dest_intf != NULL && m_dest_intf->get_id() == 36 && g_eventQueue_ptr->getTime() > DEBUG_START_TIME) { DEBUG_MSG(NETWORK_COMP, MedPrio, "link_srcQueue[index] 's size = " + int_to_string( link_srcQueue[index]->numElements() )); if( link_srcQueue[index]->numElements() > 0 ) { flit_CN *t_flit = link_srcQueue[index]->peekTopFlit(); DEBUG_EXPR(NETWORK_COMP, MedPrio, t_flit->get_time()); DEBUG_MSG(NETWORK_COMP, MedPrio, g_eventQueue_ptr->getTime()); DEBUG_EXPR(NETWORK_COMP, MedPrio, *(link_srcQueue[index])); } } } } for(int index = 0; index < link_srcQueue.size(); index++) { if(link_srcQueue[index]->isReady()) { if(m_dest_intf != NULL) { // assert(0 && "m_dest_intf != NULL && link_srcQueue is ready!!"); } if(m_dest_intf != NULL && m_dest_intf->get_id() == 36 && g_eventQueue_ptr->getTime() > DEBUG_START_TIME) { DEBUG_MSG(NETWORK_COMP, MedPrio, "#################Debuging inNetLink of NI 36 -------- NetworkLink_CN: link_srcQueue_index: " + int_to_string(index)); DEBUG_EXPR(NETWORK_COMP, MedPrio, *(link_srcQueue[index])); } flit_CN *t_flit = link_srcQueue[index]->getTopFlit(); DEBUG_MSG(NETWORK_COMP, MedPrio, "executing"); DEBUG_EXPR(NETWORK_COMP, MedPrio, t_flit->get_msg_ptr()); t_flit->set_time(g_eventQueue_ptr->getTime() + m_latency); if (m_dest_router != NULL) { if ( m_dest_intf != NULL) { //cerr << "m_dest_router : " << m_dest_router->get_id() << endl; //cerr << "m_dest_intf : " << m_dest_intf->get_id() << endl; } assert(m_dest_intf == NULL); // cerr << "m_dest_router = " << m_dest_router->get_id() << endl; int outport; //cout << "NetworkLink_CN: Before get_num_outports() : " << m_dest_router->get_id() << endl; if (m_dest_router->get_net_ptr()->m_id == 0) { for(outport = 0; outport < m_dest_router->get_num_outports(); outport++) { if(m_dest_router->m_port_connect[outport][m_dest_portNum]) { //cout << "t_flit->m_destID: " << t_flit->m_destID << endl; //cout << "connect_pair.second: " << m_dest_router->m_port_connect_pair[outport][m_dest_portNum].second << endl; //cout << "t_flit->m_srcNetIntfID: " << t_flit->m_srcNetIntfID << endl; //cout << "connect_pair.first: " << m_dest_router->m_port_connect_pair[outport][m_dest_portNum].first << endl; if (t_flit->m_destID == m_dest_router->m_port_connect_pair[outport][m_dest_portNum].second && t_flit->m_srcNetIntfID == m_dest_router->m_port_connect_pair[outport][m_dest_portNum].first) break; } } //cout << "NetworkLink_CN: After get_num_outports() : " << m_dest_router->get_id() << endl; //cout << "NetworkLink_CN: m_port_connect: Outport : " << outport << " , Inport : " << m_dest_portNum << endl; if(outport == m_dest_router->get_num_outports()) { cerr << g_eventQueue_ptr->getTime() << " : " << endl; cerr << "CS_NOC is : " << m_net_ptr->m_id << endl; cerr << "t_flit->m_srcNetIntfID: " << t_flit->m_srcNetIntfID << endl; cerr << "t_flit->m_destID: " << t_flit->m_destID << endl; cerr << "circuit_path status is : " << m_net_ptr->m_circuit_paths[t_flit->m_srcNetIntfID][t_flit->m_destID] << endl; //m_net_ptr->get_gnet_d()->m_setupnet_ptr->printCircuitMap(); m_net_ptr->get_gnet_d()->printCircuitMap(); assert(0 && "flits are scheduled, but circuit has not been built yet"); } } else { outport = m_dest_router->m_routing_unit->routeCompute(t_flit); } t_flit->advance_stage(ST_); t_flit->set_outport(outport); m_dest_router->update_sw_winner(m_dest_portNum, t_flit); } else { assert(m_dest_intf != NULL); //cout << "NetworkLink_CN: before schedule link_consumer : " << m_dest_intf->get_id() << endl; DEBUG_MSG(NETWORK_COMP, MedPrio, "m_dest_intf executing"); DEBUG_EXPR(NETWORK_COMP, MedPrio, "m_dest_intf = " + int_to_string(m_dest_intf->get_id())); DEBUG_EXPR(NETWORK_COMP, MedPrio, t_flit->get_msg_ptr()); t_flit->advance_stage(I_); linkBuffer[index]->insert(t_flit); g_eventQueue_ptr->scheduleEvent(link_consumer, m_latency); //cout << "NetworkLink_CN: after schedule link_consumer : " << m_dest_intf->get_id() << endl; } //linkBuffer->insert(t_flit); //the link_consumer should wake up m_switch //g_eventQueue_ptr->scheduleEvent(link_consumer, m_latency); m_link_utilized++; m_vc_load[t_flit->get_vc()]++; m_num_buffer_reads++; m_num_buffer_writes++; /* * Check whether the response message is one of the following types: * * CoherenceResponseType:BIC_READ_ACK ;; the responsed/read data message from buffer to accelerator * CacheRequestType:BIC_WRITE ;; the request/write data message from accelerator to buffer * * CoherenceRequestType:BIC_INTRANS_DATA ;; the read data moved from cache to buffer * CoherenceRequestType:BIC_OUTTRANS_DATA ;; the data moved from buffer to cache * * CoherenceResponseType:BIC_MEMORY_DATA_COPY ;; read data from memory controller to cache * CoherenceResponseType:BIC_MEMORY_DATA ;; read data from memory controller to buffer * * CoherenceRequestType:BIC_OUTTRANS_DATA ;; the data moved from cache to memory controller * * if the flit belongs to one of the above types, then we consider the flit in stream data * */ MsgPtr msg_ptr = t_flit->get_msg_ptr(); RequestMsg *request_msg_ptr = dynamic_cast<RequestMsg*>(msg_ptr.ref()); ResponseMsg *response_msg_ptr = dynamic_cast<ResponseMsg*>(msg_ptr.ref()); CacheMsg *cache_msg_ptr = dynamic_cast<CacheMsg*>(msg_ptr.ref()); if (request_msg_ptr != NULL) { /* std::cout << "*****************************************" << std::endl; std::cout << g_eventQueue_ptr->getTime() << " : find a request message " << request_msg_ptr->m_Type << " : in NetworkLink_CN.C" << std::endl; std::cout << "*****************************************" << std::endl;*/ assert(response_msg_ptr == NULL); assert(cache_msg_ptr == NULL); if ( request_msg_ptr->m_Type == CoherenceRequestType_BIC_INTRANS_DATA || request_msg_ptr->m_Type == CoherenceRequestType_BIC_OUTTRANS_DATA ) { /* std::cout << "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS" << std::endl; std::cout << "find a stream request message in NetworkLink_CN.C" << std::endl; std::cout << "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS" << std::endl;*/ m_streamlink_utilized++; m_vc_streamload[t_flit->get_vc()]++; } } if (response_msg_ptr != NULL) { /* std::cout << "*****************************************" << std::endl; std::cout << g_eventQueue_ptr->getTime() << " : find a response message " << response_msg_ptr->m_Type << " : in NetworkLink_CN.C" << std::endl; std::cout << "*****************************************" << std::endl;*/ assert(request_msg_ptr == NULL); assert(cache_msg_ptr == NULL); if ( response_msg_ptr->m_Type == CoherenceResponseType_BIC_MEMORY_DATA_COPY || response_msg_ptr->m_Type == CoherenceResponseType_BIC_MEMORY_DATA || response_msg_ptr->m_Type == CoherenceResponseType_BIC_READ_ACK) { /* std::cout << "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS" << std::endl; std::cout << "find a stream response message in NetworkLink_CN.C" << std::endl; std::cout << "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS" << std::endl;*/ m_streamlink_utilized++; m_vc_streamload[t_flit->get_vc()]++; } } if (cache_msg_ptr != NULL) { /* std::cout << "*****************************************" << std::endl; std::cout << g_eventQueue_ptr->getTime() << " : find a cache message " << cache_msg_ptr->m_Type << " : in NetworkLink_CN.C" << std::endl; std::cout << "*****************************************" << std::endl;*/ assert(request_msg_ptr == NULL); assert(response_msg_ptr == NULL); if ( cache_msg_ptr->m_Type == CacheRequestType_BIC_WRITE) { /* std::cout << "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS" << std::endl; std::cout << "find a stream cache message in NetworkLink_CN.C" << std::endl; std::cout << "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS" << std::endl;*/ m_streamlink_utilized++; m_vc_streamload[t_flit->get_vc()]++; } } } } }
void RequestGenerator::performCallback(NodeID proc, SubBlock& data) { Address address = data.getAddress(); assert(proc == m_node); assert(address == m_address); DEBUG_EXPR(TESTER_COMP, LowPrio, proc); DEBUG_EXPR(TESTER_COMP, LowPrio, m_status); DEBUG_EXPR(TESTER_COMP, LowPrio, address); DEBUG_EXPR(TESTER_COMP, LowPrio, data); if (m_status == RequestGeneratorStatus_Test_Pending) { // m_driver.recordTestLatency(g_eventQueue_ptr->getTime() - m_last_transition); if (data.readByte() == LockStatus_Locked) { // Locked - keep spinning m_status = RequestGeneratorStatus_Thinking; m_last_transition = g_eventQueue_ptr->getTime(); g_eventQueue_ptr->scheduleEvent(this, waitTime()); } else { // Unlocked - try the swap m_driver.recordTestLatency(g_eventQueue_ptr->getTime() - m_last_transition); m_status = RequestGeneratorStatus_Before_Swap; m_last_transition = g_eventQueue_ptr->getTime(); g_eventQueue_ptr->scheduleEvent(this, waitTime()); } } else if (m_status == RequestGeneratorStatus_Swap_Pending) { m_driver.recordSwapLatency(g_eventQueue_ptr->getTime() - m_last_transition); if (data.readByte() == LockStatus_Locked) { // We failed to aquire the lock m_status = RequestGeneratorStatus_Thinking; m_last_transition = g_eventQueue_ptr->getTime(); g_eventQueue_ptr->scheduleEvent(this, waitTime()); } else { // We acquired the lock data.writeByte(LockStatus_Locked); m_status = RequestGeneratorStatus_Holding; m_last_transition = g_eventQueue_ptr->getTime(); DEBUG_MSG(TESTER_COMP, HighPrio, "Acquired"); DEBUG_EXPR(TESTER_COMP, HighPrio, proc); DEBUG_EXPR(TESTER_COMP, HighPrio, g_eventQueue_ptr->getTime()); g_eventQueue_ptr->scheduleEvent(this, holdTime()); } } else if (m_status == RequestGeneratorStatus_Release_Pending) { m_driver.recordReleaseLatency(g_eventQueue_ptr->getTime() - m_last_transition); // We're releasing the lock data.writeByte(LockStatus_Unlocked); m_counter++; if (m_counter < g_param_ptr->TESTER_LENGTH()) { m_status = RequestGeneratorStatus_Thinking; m_last_transition = g_eventQueue_ptr->getTime(); pickAddress(); g_eventQueue_ptr->scheduleEvent(this, thinkTime()); } else { m_driver.reportDone(); m_status = RequestGeneratorStatus_Done; m_last_transition = g_eventQueue_ptr->getTime(); } } else { WARN_EXPR(m_status); ERROR_MSG("Invalid status"); } }
static void discharge2reg (FuncState *fs, expdesc *e, int reg) { luaK_dischargevars(fs, e); switch (e->k) { case VNIL: { luaK_nil(fs, reg, 1); break; } case VFALSE: case VTRUE: { luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); break; } case VK: { luaK_codek(fs, reg, e->u.info); break; } case VKFLT: { luaK_codek(fs, reg, luaK_numberK(fs, e->u.nval)); break; } case VKINT: { luaK_codek(fs, reg, luaK_intK(fs, e->u.ival)); break; } case VRELOCABLE: { Instruction *pc = &getcode(fs, e); SETARG_A(*pc, reg); DEBUG_EXPR(raviY_printf(fs, "discharge2reg (VRELOCABLE set arg A) %e\n", e)); DEBUG_CODEGEN(raviY_printf(fs, "[%d]* %o ; set A to %d\n", e->u.info, *pc, reg)); break; } case VNONRELOC: { if (reg != e->u.info) { /* code a MOVEI or MOVEF if the target register is a local typed variable */ int ravi_type = raviY_get_register_typeinfo(fs, reg); switch (ravi_type) { case RAVI_TNUMINT: luaK_codeABC(fs, OP_RAVI_MOVEI, reg, e->u.info, 0); break; case RAVI_TNUMFLT: luaK_codeABC(fs, OP_RAVI_MOVEF, reg, e->u.info, 0); break; case RAVI_TARRAYINT: luaK_codeABC(fs, OP_RAVI_MOVEAI, reg, e->u.info, 0); break; case RAVI_TARRAYFLT: luaK_codeABC(fs, OP_RAVI_MOVEAF, reg, e->u.info, 0); break; default: luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0); break; } } break; } default: { lua_assert(e->k == VVOID || e->k == VJMP); return; /* nothing to do... */ } } e->u.info = reg; e->k = VNONRELOC; }
/* Calculate whether an assertion is a standard non-NULL check. * e.g. (x != NULL), (x), (x != NULL && …) or (x && …). * * Insert the ValueDecls of the variables being checked into the provided * unordered_set, and return the number of such insertions (this will be 0 if no * variables are non-NULL checked). The returned number may be an over-estimate * of the number of elements in the set, as it doesn’t account for * duplicates. */ static unsigned int _assertion_is_explicit_nonnull_check (Expr& assertion_expr, const ASTContext& context, std::unordered_set<const ValueDecl*>& ret) { DEBUG_EXPR (__func__ << ": ", assertion_expr); switch ((int) assertion_expr.getStmtClass ()) { case Expr::BinaryOperatorClass: { BinaryOperator& bin_expr = cast<BinaryOperator> (assertion_expr); BinaryOperatorKind opcode = bin_expr.getOpcode (); if (opcode == BinaryOperatorKind::BO_LAnd) { /* LHS && RHS */ unsigned int lhs_count = AssertionExtracter::assertion_is_nonnull_check (*(bin_expr.getLHS ()), context, ret); unsigned int rhs_count = AssertionExtracter::assertion_is_nonnull_check (*(bin_expr.getRHS ()), context, ret); return lhs_count + rhs_count; } else if (opcode == BinaryOperatorKind::BO_LOr) { /* LHS || RHS */ std::unordered_set<const ValueDecl*> lhs_vars, rhs_vars; unsigned int lhs_count = AssertionExtracter::assertion_is_nonnull_check (*(bin_expr.getLHS ()), context, lhs_vars); unsigned int rhs_count = AssertionExtracter::assertion_is_nonnull_check (*(bin_expr.getRHS ()), context, rhs_vars); std::set_intersection (lhs_vars.begin (), lhs_vars.end (), rhs_vars.begin (), rhs_vars.end (), std::inserter (ret, ret.end ())); return lhs_count + rhs_count; } else if (opcode == BinaryOperatorKind::BO_NE) { /* LHS != RHS */ Expr* rhs = bin_expr.getRHS (); Expr::NullPointerConstantKind k = rhs->isNullPointerConstant (const_cast<ASTContext&> (context), Expr::NullPointerConstantValueDependence::NPC_ValueDependentIsNotNull); if (k != Expr::NullPointerConstantKind::NPCK_NotNull && bin_expr.getLHS ()->IgnoreParenCasts ()->getStmtClass () == Expr::DeclRefExprClass) { DEBUG ("Found non-NULL check."); ret.insert (cast<DeclRefExpr> (bin_expr.getLHS ()->IgnoreParenCasts ())->getDecl ()); return 1; } /* Either not a comparison to NULL, or the expr being * compared is not a DeclRefExpr. */ return 0; } return 0; } case Expr::UnaryOperatorClass: { /* A unary operator. For the moment, assume this isn't a * non-null check. * * FIXME: In the future, define a proper program transformation * to check for non-null checks, since we could have expressions * like: * !(my_var == NULL) * or (more weirdly): * ~(my_var == NULL) */ return 0; } case Expr::ConditionalOperatorClass: { /* A conditional operator. For the moment, assume this isn’t a * non-null check. * * FIXME: In the future, define a proper program transformation * to check for non-null checks, since we could have expressions * like: * (x == NULL) ? TRUE : FALSE */ return 0; } case Expr::CStyleCastExprClass: case Expr::ImplicitCastExprClass: { /* A (explicit or implicit) cast. This can either be: * (void*)0 * or * (bool)my_var */ CastExpr& cast_expr = cast<CastExpr> (assertion_expr); Expr* sub_expr = cast_expr.getSubExpr ()->IgnoreParenCasts (); if (sub_expr->getStmtClass () == Expr::DeclRefExprClass) { DEBUG ("Found non-NULL check."); ret.insert (cast<DeclRefExpr> (sub_expr)->getDecl ()); return 1; } /* Not a cast to NULL, or the expr being casted is not a * DeclRefExpr. */ return 0; } case Expr::DeclRefExprClass: { /* A variable reference, which will implicitly become a non-NULL * check. */ DEBUG ("Found non-NULL check."); DeclRefExpr& decl_ref_expr = cast<DeclRefExpr> (assertion_expr); ret.insert (decl_ref_expr.getDecl ()); return 1; } case Expr::StmtExprClass: /* FIXME: Statement expressions can be nonnull checks, but * detecting them requires a formal program transformation which * has not been implemented yet. */ case Expr::CallExprClass: /* Function calls can’t be nonnull checks. */ case Expr::IntegerLiteralClass: { /* Integer literals can’t be nonnull checks. */ return 0; } case Stmt::StmtClass::NoStmtClass: default: WARN_EXPR (__func__ << "() can’t handle expressions of type " << assertion_expr.getStmtClassName (), assertion_expr); return 0; } }
/* Does the given statement look like: * • g_return_if_fail(…) * • g_return_val_if_fail(…) * • g_assert(…) * • g_assert_*(…) * • assert(…) * This is complicated by the fact that if the gmessages.h header isn’t * available, they’ll present as CallExpr function calls with those names; if it * is available, they’ll be expanded as macros and turn into DoStmts with misc. * rubbish beneath. * * If the statement changes program state at all, return NULL. Otherwise, return * the condition which holds for the assertion to be bypassed (i.e. for the * assertion to succeed). This function is built recursively, building a boolean * expression for the condition based on avoiding branches which call * abort()-like functions. * * This function is based on a transformation of the AST to an augmented boolean * expression, using rules documented in each switch case. In this * documentation, calc(S) refers to the transformation function. The augmented * boolean expressions can be either NULL, or a normal boolean expression * (TRUE, FALSE, ∧, ∨, ¬). NULL is used iff the statement potentially changes * program state, and poisons any boolean expression: * B ∧ NULL ≡ NULL * B ∨ NULL ≡ NULL * ¬NULL ≡ NULL */ Expr* AssertionExtracter::is_assertion_stmt (Stmt& stmt, const ASTContext& context) { DEBUG ("Checking " << stmt.getStmtClassName () << " for assertions."); /* Slow path: walk through the AST, aborting on statements which * potentially mutate program state, and otherwise trying to find a base * function call such as: * • g_return_if_fail_warning() * • g_assertion_message() * • g_assertion_message_*() */ switch ((int) stmt.getStmtClass ()) { case Stmt::StmtClass::CallExprClass: { /* Handle a direct function call. * Transformations: * [g_return_if_fail|assert|…](C) ↦ C * [g_return_if_fail_warning|__assert_fail|…](C) ↦ FALSE * other_funcs(…) ↦ NULL */ CallExpr& call_expr = cast<CallExpr> (stmt); FunctionDecl* func = call_expr.getDirectCallee (); if (func == NULL) return NULL; std::string func_name = func->getNameAsString (); DEBUG ("CallExpr to function " << func_name); if (_is_assertion_name (func_name)) { /* Assertion path where the compiler hasn't seen the * definition of the assertion macro, so still thinks * it's a function. * * Extract the assertion condition as the first function * parameter. * * TODO: May need to fix up the condition for macros * like g_assert_null(). */ return call_expr.getArg (0); } else if (_is_assertion_fail_func_name (func_name)) { /* Assertion path where the assertion macro has been * expanded and we're on the assertion failure branch. * * In this case, the assertion condition has been * grabbed from an if statement already, so negate it * (to avoid the failure condition) and return. */ return new (context) IntegerLiteral (context, context.MakeIntValue (0, context.getLogicalOperationType ()), context.getLogicalOperationType (), SourceLocation ()); } /* Not an assertion path. */ return NULL; } case Stmt::StmtClass::DoStmtClass: { /* Handle a do { … } while (0) block (commonly used to allow * macros to optionally be suffixed by a semicolon). * Transformations: * do { S } while (0) ↦ calc(S) * do { S } while (C) ↦ NULL * Note the second condition is overly-conservative. No * solutions for the halting problem here. */ DoStmt& do_stmt = cast<DoStmt> (stmt); Stmt* body = do_stmt.getBody (); Stmt* cond = do_stmt.getCond (); Expr* expr = dyn_cast<Expr> (cond); llvm::APSInt bool_expr; if (body != NULL && expr != NULL && expr->isIntegerConstantExpr (bool_expr, context) && !bool_expr.getBoolValue ()) { return is_assertion_stmt (*body, context); } return NULL; } case Stmt::StmtClass::IfStmtClass: { /* Handle an if(…) { … } else { … } block. * Transformations: * if (C) { S1 } else { S2 } ↦ * (C ∧ calc(S1)) ∨ (¬C ∧ calc(S2)) * if (C) { S } ↦ (C ∧ calc(S)) ∨ ¬C * i.e. * if (C) { S } ≡ if (C) { S } else {} * where {} is an empty compound statement, below. */ IfStmt& if_stmt = cast<IfStmt> (stmt); assert (if_stmt.getThen () != NULL); Expr* neg_cond = _negation_expr (if_stmt.getCond (), context); Expr* then_assertion = is_assertion_stmt (*(if_stmt.getThen ()), context); if (then_assertion == NULL) return NULL; then_assertion = _conjunction_expr (if_stmt.getCond (), then_assertion, context); if (if_stmt.getElse () == NULL) return _disjunction_expr (then_assertion, neg_cond, context); Expr* else_assertion = is_assertion_stmt (*(if_stmt.getElse ()), context); if (else_assertion == NULL) return NULL; else_assertion = _conjunction_expr (neg_cond, else_assertion, context); return _disjunction_expr (then_assertion, else_assertion, context); } case Stmt::StmtClass::ConditionalOperatorClass: { /* Handle a ternary operator. * Transformations: * C ? S1 : S2 ↦ * (C ∧ calc(S1)) ∨ (¬C ∧ calc(S2)) */ ConditionalOperator& op_expr = cast<ConditionalOperator> (stmt); assert (op_expr.getTrueExpr () != NULL); assert (op_expr.getFalseExpr () != NULL); Expr* neg_cond = _negation_expr (op_expr.getCond (), context); Expr* then_assertion = is_assertion_stmt (*(op_expr.getTrueExpr ()), context); if (then_assertion == NULL) return NULL; then_assertion = _conjunction_expr (op_expr.getCond (), then_assertion, context); Expr* else_assertion = is_assertion_stmt (*(op_expr.getFalseExpr ()), context); if (else_assertion == NULL) return NULL; else_assertion = _conjunction_expr (neg_cond, else_assertion, context); return _disjunction_expr (then_assertion, else_assertion, context); } case Stmt::StmtClass::SwitchStmtClass: { /* Handle a switch statement. * Transformations: * switch (C) { L1: S1; L2: S2; …; Lz: Sz } ↦ NULL * FIXME: This should get a proper transformation sometime. */ return NULL; } case Stmt::StmtClass::AttributedStmtClass: { /* Handle an attributed statement, e.g. G_LIKELY(…). * Transformations: * att S ↦ calc(S) */ AttributedStmt& attr_stmt = cast<AttributedStmt> (stmt); Stmt* sub_stmt = attr_stmt.getSubStmt (); if (sub_stmt == NULL) return NULL; return is_assertion_stmt (*sub_stmt, context); } case Stmt::StmtClass::CompoundStmtClass: { /* Handle a compound statement, e.g. { stmt1; stmt2; }. * Transformations: * S1; S2; …; Sz ↦ calc(S1) ∧ calc(S2) ∧ … ∧ calc(Sz) * {} ↦ TRUE * * This is implemented by starting with a base TRUE case in the * compound_condition, then taking the conjunction with the next * statement’s assertion condition for each statement in the * compound. * * If the compound is empty, the compound_condition will be * TRUE. Otherwise, it will be (TRUE ∧ …), which will be * simplified later. */ CompoundStmt& compound_stmt = cast<CompoundStmt> (stmt); Expr* compound_condition = new (context) IntegerLiteral (context, context.MakeIntValue (1, context.getLogicalOperationType ()), context.getLogicalOperationType (), SourceLocation ()); for (CompoundStmt::const_body_iterator it = compound_stmt.body_begin (), ie = compound_stmt.body_end (); it != ie; ++it) { Stmt* body_stmt = *it; Expr* body_assertion = is_assertion_stmt (*body_stmt, context); if (body_assertion == NULL) { /* Reached a program state mutation. */ return NULL; } /* Update the compound condition. */ compound_condition = _conjunction_expr (compound_condition, body_assertion, context); DEBUG_EXPR ("Compound condition: ", *compound_condition); } return compound_condition; } case Stmt::StmtClass::GotoStmtClass: /* Handle a goto statement. * Transformations: * goto L ↦ FALSE */ case Stmt::StmtClass::ReturnStmtClass: { /* Handle a return statement. * Transformations: * return ↦ FALSE */ return new (context) IntegerLiteral (context, context.MakeIntValue (0, context.getLogicalOperationType ()), context.getLogicalOperationType (), SourceLocation ()); } case Stmt::StmtClass::NullStmtClass: /* Handle a null statement. * Transformations: * ; ↦ TRUE */ case Stmt::StmtClass::DeclRefExprClass: /* Handle a variable reference expression. These don’t modify * program state. * Transformations: * E ↦ TRUE */ case Stmt::StmtClass::DeclStmtClass: { /* Handle a variable declaration statement. These don’t modify * program state; they only introduce new state, so can’t affect * subsequent assertions. (FIXME: For the moment, we ignore the * possibility of the rvalue modifying program state.) * Transformations: * T S1 ↦ TRUE * T S1 = S2 ↦ TRUE */ return new (context) IntegerLiteral (context, context.MakeIntValue (1, context.getLogicalOperationType ()), context.getLogicalOperationType (), SourceLocation ()); } case Stmt::StmtClass::IntegerLiteralClass: { /* Handle an integer literal. This doesn’t modify program state, * and evaluates directly to a boolean. * Transformations: * 0 ↦ FALSE * I ↦ TRUE */ return dyn_cast<Expr> (&stmt); } case Stmt::StmtClass::ParenExprClass: { /* Handle a parenthesised expression. * Transformations: * ( S ) ↦ calc(S) */ ParenExpr& paren_expr = cast<ParenExpr> (stmt); Stmt* sub_expr = paren_expr.getSubExpr (); if (sub_expr == NULL) return NULL; return is_assertion_stmt (*sub_expr, context); } case Stmt::StmtClass::LabelStmtClass: { /* Handle a label statement. * Transformations: * label: S ↦ calc(S) */ LabelStmt& label_stmt = cast<LabelStmt> (stmt); Stmt* sub_stmt = label_stmt.getSubStmt (); if (sub_stmt == NULL) return NULL; return is_assertion_stmt (*sub_stmt, context); } case Stmt::StmtClass::ImplicitCastExprClass: case Stmt::StmtClass::CStyleCastExprClass: { /* Handle an explicit or implicit cast. * Transformations: * (T) S ↦ calc(S) */ CastExpr& cast_expr = cast<CastExpr> (stmt); Stmt* sub_expr = cast_expr.getSubExpr (); if (sub_expr == NULL) return NULL; return is_assertion_stmt (*sub_expr, context); } case Stmt::StmtClass::GCCAsmStmtClass: case Stmt::StmtClass::MSAsmStmtClass: /* Inline assembly. There is no way we are parsing this, so * conservatively assume it modifies program state. * Transformations: * A ↦ NULL */ case Stmt::StmtClass::BinaryOperatorClass: /* Handle a binary operator statement. Since this is being * processed at the top level, it’s most likely an assignment, * so conservatively assume it modifies program state. * Transformations: * S1 op S2 ↦ NULL */ case Stmt::StmtClass::UnaryOperatorClass: /* Handle a unary operator statement. Since this is being * processed at the top level, it’s not very interesting re. * assertions, even though it probably won’t modify program * state (unless it’s a pre- or post-increment or -decrement * operator). Be conservative and assume it does, though. * Transformations: * op S ↦ NULL */ case Stmt::StmtClass::CompoundAssignOperatorClass: /* Handle a compound assignment operator, e.g. x += 5. This * definitely modifies program state, so ignore it. * Transformations: * S1 op S2 ↦ NULL */ case Stmt::StmtClass::ForStmtClass: /* Handle a for statement. We assume these *always* change * program state. * Transformations: * for (…) { … } ↦ NULL */ case Stmt::StmtClass::WhileStmtClass: { /* Handle a while(…) { … } block. Because we don't want to solve * the halting problem, just assume all while statements cannot * be assertion statements. * Transformations: * while (C) { S } ↦ NULL */ return NULL; } case Stmt::StmtClass::NoStmtClass: default: WARN_EXPR (__func__ << "() can’t handle statements of type " << stmt.getStmtClassName (), stmt); return NULL; } }
static void acceptLocalReactionFiltered(FrictionContactProblem *localproblem, SolverOptions *localsolver_options, unsigned int contact, unsigned int iter, double *reaction, double localreaction[3]) { if (isnan(localsolver_options->dparam[1]) || isinf(localsolver_options->dparam[1]) || localsolver_options->dparam[1] > 1.0) { DEBUG_EXPR(frictionContact_display(localproblem)); DEBUG_PRINTF("Discard local reaction for contact %i at iteration %i " "with local_error = %e\n", contact, iter, localsolver_options->dparam[1]); #ifdef FCLIB_OUTPUT /* printf("step counter value = %i\n", localsolver_options->iparam[19]); */ char fname[256]; fccounter ++; sprintf(fname, "./local_problem/localproblem_%i_%i.hdf5", contact, localsolver_options->iparam[19]); if (file_exists(fname)) { /* printf(" %s already dumped\n", fname); */ } else { printf("Dump %s\n", fname); int n = 100; char * title = (char *)malloc(n * sizeof(char)); strcpy(title, "Bad local problem dump in hdf5"); char * description = (char *)malloc(n * sizeof(char)); strcpy(description, "Rewriting in hdf5 from siconos "); strcat(description, fname); strcat(description, " in FCLIB format"); char * mathInfo = (char *)malloc(n * sizeof(char)); strcpy(mathInfo, "unknown"); frictionContact_fclib_write(localproblem, title, description, mathInfo, fname,3); printf("end of dump %s\n", fname); free(title); free(description); free(mathInfo); } #endif if (verbose > 1) printf("Discard local reaction for contact %i at iteration %i " "with local_error = %e\n", contact, iter, localsolver_options->dparam[1]); } else memcpy(&reaction[contact*3], localreaction, sizeof(double)*3); }
int main(int argc, char **argv, char **env) { if (argc != 2) { std::cout << "Usage: " << argv[0] << " <pattern_name>" << std::endl; return 0; } std::ifstream fin(argv[1]); if (!fin.good()) { std::cout << "Error: fail to open file - " << argv[1] << std::endl; return 0; } std::vector<int> vecData; int x; while(fin >> x) { vecData.push_back(x); } Verilated::commandArgs(argc, argv); VCTE* top = new VCTE; // initialize simulation inputs top->clk = 0; top->reset = 1; top->op_mode = 0; top->in_en = 0; top->rgb_in = 0; top->yuv_in= 0; int pos_data = 0; bool three_or_one = true; // for (int i = 0; i < 20; i++) { for (int i = 0;;++i) { #if 0 top->clk = !top->clk; top->eval(); #endif top->reset = (i < 5); if (top->out_valid) { assert(top->busy); // std::cout << "rgb_out : " << top->rgb_out << std::endl; std::cout << top->rgb_out << std::endl; } if (!top->reset) { if (!top->busy) { top->in_en = true; // top->yuv_in = i * 4; if (pos_data == vecData.size()) break; DEBUG_EXPR(vecData[pos_data]); top->yuv_in = vecData[pos_data++]; } else { top->in_en = false; } } #if 0 top->clk = !top->clk; top->eval(); #endif #if 1 for (int clk = 0; clk < 2; clk++) { top->clk = !top->clk; top->eval(); } #endif #if 0 top->clk = 0; top->eval(); top->clk = 1; top->eval(); #endif } return 0; }