RC1::RC1(QWidget *parent) : QGLWidget(parent) { setAttribute(Qt::WA_AcceptTouchEvents,true); qDebug() << "View() size:" << width() << " " << height(); eventId = 1; nomouse = false; ttl=10000; storage=new Storage(); layout=new LayoutModel(); sender=new SenderOscPuredata(this); // sender=new SenderDebug(); ehand=new EventHandlerRect(); evstat=new EventStat(); layout->calcGeo(width(),height()); nPrePainters=1; prepainters=new IPaint*[nPrePainters]; prepainters[0]=new PaintBgShapes(); nPointPainters=5; pointpainters=new IPointPaint*[nPointPainters]; // pointpainters[0]=new PointPaintSphere(); pointpainters[0]=new PointPaintShape(); pointpainters[1]=new PointPaintShape(); pointpainters[2]=new PointPaintShape(); pointpainters[3]=new PointPaintShape(); pointpainters[4]=new PointPaintShape(); nPostPainters=1; postpainters=new IPaint*[nPostPainters]; postpainters[0]=new PaintStat(); painterOn=new bool[nPrePainters+nPointPainters+nPostPainters]; painterOn[0]=true; painterOn[1]=true; painterOn[2]=false; painterOn[3]=false; painterOn[4]=false; painterOn[5]=false; painterOn[6]=true; oscin = new QOscServer(3333,this); oscin->registerPathObject(this); resetStat(); QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(update())); timer->start(10); fpsT.start(); fcnt=0; }
Sender::Sender(std::map<int, Queue<Packet> *> * pOutQueues) { mpOutQueues = pOutQueues; mpBufs = new SocketBuf *[Const::MAX_NETWORK_FD] (); mpBatchers = new QueueBatcher<Packet> *[Const::MAX_NETWORK_FD] (); for (std::map<int, Queue<Packet> *>::iterator it = mpOutQueues->begin(); it != mpOutQueues->end(); ++it) { mpBufs[it->first] = new SocketBuf(); mpBatchers[it->first] = new QueueBatcher<Packet>(it->second, Const::UTIL_QUEUE_BATCH_SIZE); } mId = 0; mpInQueue = NULL; resetStat(); }
NeighborhoodHandler<NEIGHAND_TEMPLATE_ARGUMENTS>::NeighborhoodHandler(FloatType minx, FloatType miny, FloatType minz, FloatType cellSize, uint32_t objectInitCapacity, const char* precompFile) : helper(minx, miny, minz, cellSize) { #ifdef NEIGHAND_SELECT_METHOD_STAT resetStat(); #endif cellSizeSqInv = FloatType(1.0f) / (cellSize*cellSize); maxWorldDist32 = uint32_t(sqrtf(MaxDQ)*32.f+55.425626f); // Average "sphere" volume for each 1/32th of cell distance // allows quick estimation for which method is fastest volumeSphereTable = typename Allocator::template rebind<FloatType>::other(*this).allocate(maxWorldDist32+1); for (uint32_t i=0; i<=maxWorldDist32; ++i) volumeSphereTable[i] = FloatType(0.f); // The sphere offsets pre-computation depends on wrapping WrapHelper<NEIGHAND_TEMPLATE_ARGUMENTS>::buildDistanceArray(baseDistanceArray, sphereOffsets, shavingComplement, shavingOffsets, maxWorldDist32, volumeSphereTable, precompFile, typename WrapHelper<NEIGHAND_TEMPLATE_ARGUMENTS>::UINT32Allocator(*this)); // allocate the other tables as well weightSphereTable = typename Allocator::template rebind<FloatType>::other(*this).allocate(maxWorldDist32+1); weightSphereTableBase = typename Allocator::template rebind<FloatType>::other(*this).allocate(maxWorldDist32+1); weightSphereTableClosest = typename Allocator::template rebind<FloatType>::other(*this).allocate(256); weightSphereTableClosestBase = typename Allocator::template rebind<FloatType>::other(*this).allocate(256); weightNonEmptyTable = typename Allocator::template rebind<FloatType>::other(*this).allocate(maxWorldDist32+1); weightNonEmptyTableBase = typename Allocator::template rebind<FloatType>::other(*this).allocate(maxWorldDist32+1); weightBruteTable = typename Allocator::template rebind<FloatType>::other(*this).allocate(maxWorldDist32+1); weightBruteTableBase = typename Allocator::template rebind<FloatType>::other(*this).allocate(maxWorldDist32+1); // Initialize so Brute-Force is selected by Auto when there is no object! // the tables are recomputed when objects are inserted for (uint32_t i=0; i<=maxWorldDist32; ++i) weightSphereTable[i] = FloatType(0.f); for (uint32_t i=0; i<=maxWorldDist32; ++i) weightSphereTableBase[i] = FloatType(0.f); for (uint32_t i=0; i<=maxWorldDist32; ++i) weightNonEmptyTable[i] = FloatType(0.f); for (uint32_t i=0; i<=maxWorldDist32; ++i) weightNonEmptyTableBase[i] = FloatType(0.f); for (uint32_t i=0; i<=maxWorldDist32; ++i) weightBruteTable[i] = FloatType(-1.f); for (uint32_t i=0; i<=maxWorldDist32; ++i) weightBruteTableBase[i] = FloatType(-1.f); for (uint32_t i=0; i<256; ++i) weightSphereTableClosest[i] = FloatType(0.f); for (uint32_t i=0; i<256; ++i) weightSphereTableClosestBase[i] = FloatType(0.f); queryMethod = Auto; weightSphere = weightCube = weightNonEmpty = weightBrute = 1.0f; weightCubeWithLoad = 0.0f; updateWeightBaseTablesNeeded = false; // reserve memory to hold the proxies proxyCapacity = objectInitCapacity; numProxies = 0; allProxies = Allocator::allocate(proxyCapacity); // Now, create the object structure cells = typename Allocator::template rebind<CellEntry<UserObject> >::other(*this).allocate(WrapHelper<NEIGHAND_TEMPLATE_ARGUMENTS>::ArraySize); // and the cells object list cache cachedLists = typename Allocator::template rebind<ObjectProxy<UserObject>*>::other(*this).allocate(WrapHelper<NEIGHAND_TEMPLATE_ARGUMENTS>::ArraySize); // prepare array for (uint_fast32_t i=0; i<WrapHelper<NEIGHAND_TEMPLATE_ARGUMENTS>::ArraySize; ++i) { // start empty cells[i].objects = 0; cells[i].nextNonEmpty = 0; // cache is empty too cachedLists[i] = 0; } // Done, array is empty and ready to serve // Cache the real outside cell reference, no need to get from array index each time // The index at 2^(exp2divx+exp2divy+exp2divz) is the dummy cell, it is not a valid main region index // The index just after is the real outside cell // => the dummy index is used to avoid duplicates when the query sphere intersects the outside region // => the dummy index is the "virtual" cell that would be at that position of the sphere outside, but all are mapped to the empty one. // This function has no effect when there is no outside cell, so in that case it doesn't matter that the indice is wrong helper.setOutsideCell(&cells[WrapHelper<NEIGHAND_TEMPLATE_ARGUMENTS>::ArraySize-1]); firstNonEmptyCell = 0; totalNonEmpty = 0; }
void XctionWorker::run() { Packet * xction = NULL; Packet * in = NULL; Packet * out = NULL; QueueBatcher<Packet> inBatcher(mpInQueue, Const::UTIL_QUEUE_BATCH_SIZE); QueueBatcher<Packet> outBatcher(mpOutQueue, Const::UTIL_QUEUE_BATCH_SIZE); // counter int counterQueue = counter.addAvg("xwq"); int counterLatency = counter.addAvg("xwl"); if (Const::MODE_TPCC_TRACE) { initLoad(); } /* populate read request */ for (int i = 0; i < Const::PROCESSOR_XCTION_QUEUE_SIZE; ++i) { if (Const::MODE_TPCC_TRACE) { load(mpXctions[i]); mpXctions[i]->mPid = PID_CLIENT_REQ; } else { Generator::genPacketRand(mpXctions[i], PID_CLIENT_REQ); } // mark when the transaction starts mpXctions[i]->timer.mark(0); mpXctions[i]->mXid = i; out = outBatcher.getWriteSlot(); Packet::getReadReq(out, mpXctions[i]); /*for (int j = 0; j < out->mReadCnt; ++j) { Logger::out(0, "ik %d %d ", out->mReadKeys.get(j)->toInt(), mpXctions[i]->mReadKeys.get(j)->toInt()); } Logger::out(0, "\n"); */ // mark when the packet gets into a queue out->timer.mark(0); outBatcher.putWriteSlot(out); // mpXctions[i]->setStart(); } Logger::out(0, "XctionWorker: populated all read requests\n"); resetStat(); mStat.setStart(); /*time_t prev = clock(); time_t cur = prev; for (int i = 0; i < 6; ++i) { mTypeStat[i].setStart(); }*/ /* start to process */ while (1) { in = inBatcher.getReadSlot(); xction = mpXctions[in->mXid]; // mark the time when the packet gets into the queue in->timer.mark(1); // update queue wait time counter.update(counterQueue, in->timer.lap(1)); if (in->mPid == PID_READ_RSP) { processReadRsp(in, xction); inBatcher.putReadSlot(in); out = outBatcher.getWriteSlot(); Packet::getCommitReq(out, xction); // mark the time when the packet gets into the queue out->timer.mark(0); outBatcher.putWriteSlot(out); } else if (in->mPid == PID_COMMIT_RSP) { /* process commit response */ ++mCommitRspCnt; processCommitRsp(in, xction); inBatcher.putReadSlot(in); // xction->setEnd(); // mStat.latency(xction->getLatency()); /* if (mCommitRspCnt % 100000 == 0) { cur = clock(); Logger::out(0, "%lu|", (cur - prev) / 1000); prev = cur; }*/ // mark when the transaction finishes xction->timer.mark(1); // update latency counter counter.update(counterLatency, xction->timer.lap(1)); // mark when the transaction starts xction->timer.mark(0); /* generate read request */ if (Const::MODE_TPCC_TRACE) { /* update type stat */ mTypeStat[xction->mType].update(xction->mDec); mTypeStat[xction->mType].latency(xction->getLatency()); load(xction); xction->mPid = PID_CLIENT_REQ; } else { Generator::genPacketRand(xction, PID_CLIENT_REQ); } out = outBatcher.getWriteSlot(); Packet::getReadReq(out, xction); // mark the time when the packet gets into the queue out->timer.mark(0); outBatcher.putWriteSlot(out); // xction->setStart(); // Logger::out(0, "commit rsp %d\n", xction->mXid); } else { assert(0); } } }