int main(int argc, const char * argv[]) { //Proper input style: <command>, <kmer size>, <BWT file>, <reverse BWT file> string command = argv[0]; //If 4 arguments were not supplied: if (argc != 5) { return usage(command); } //If the user called "count", run the program if possible if (argv[1] != string("count")) { return usage(command); } else { ifstream ifs; //Retrieve kmer size ifs.open(argv[2]); if (ifs.is_open() == false) { cerr << "ERROR, the kmer size could not be understood" << endl; ifs.close(); return usage(command); } else { while (!ifs.eof()) { ifs >> k; } } ifs.close(); //Retrieve forward BWT ifs.open(argv[3]); if (ifs.is_open() == false) { cerr << "ERROR, the input file could not be read" << endl; ifs.close(); return usage(command); } else { while (!ifs.eof()) { ifs >> BWT; } } ifs.close(); //Retrieve reverse BWT ifs.open(argv[4]); if (ifs.is_open() == false) { cerr << "ERROR, the reverse BWT could not be read" << endl; ifs.close(); return usage(command); } else { while (!ifs.eof()) { ifs >> reverseBWT; } ifs.close(); } //Make sure BWT and reverseBWT are the same length if(BWT.size() != reverseBWT.size()) { cerr << "BWT's are different sizes." << endl; return usage(command); } //Build the occ table using the BWT occ.build(BWT, 1); // cout << "Count called with k-mer size " << k << endl; //Initialize the K-mer counts using the BWT const long long NUMBER_OF_RELEVANT_LEAF_NODES = BWT.size() - (k - 1); const long long OFFSET_DUE_TO_$ = 1; kmerCounts = NUMBER_OF_RELEVANT_LEAF_NODES - OFFSET_DUE_TO_$; //the final kmerCount will also include a value representing the sum over all the internal nodes of (1 - # of children at each node) //Determine number of available threads nThreads = std::thread::hardware_concurrency(); //K-mer counting: threadedCount(occ); cout << "The result of the kmer counting program is that there are:" << endl; cout << kmerCounts << endl; cout << "unique kmers in the sequence string" << endl; } return 0; //eventually we will also allow people to input their own C array and occ table, but not now. }
//Sends the user selected power limit to the master OCC errlHndl_t sendOccUserPowerCap() { errlHndl_t err = NULL; Target* sys = NULL; bool active = false; uint16_t limit = 0; uint16_t min = 0; uint16_t max = 0; targetService().getTopLevelTarget(sys); assert(sys != NULL); do { #ifdef CONFIG_BMC_IPMI err = SENSOR::getUserPowerLimit(limit, active); if (err) { TMGT_ERR("sendOccUserPowerCap: Error getting user " "power limit"); break; } #endif TMGT_INF("SENSOR::getUserPowerLimit returned %d, active = %d", limit, active); if (active) { //Make sure this value is between the min & max allowed min = sys->getAttr<ATTR_OPEN_POWER_MIN_POWER_CAP_WATTS>(); max = sys-> getAttr<ATTR_OPEN_POWER_N_PLUS_ONE_BULK_POWER_LIMIT_WATTS>(); if ((limit != 0) && (limit < min)) { TMGT_INF("sendOccUserPowerCap: User power cap %d is below" " the minimum of %d, clipping value", limit, min); limit = min; } else if (limit > max) { TMGT_INF("sendOccUserPowerCap: User power cap %d is above" " the maximum of %d, clipping value", limit, min); limit = max; } } else { //The OCC knows cap isn't active by getting a value of 0. limit = 0; } Occ* occ = occMgr::instance().getMasterOcc(); if (occ) { uint8_t data[2]; data[0] = limit >> 8; data[1] = limit & 0xFF; TMGT_INF("sendOccUserPowerCap: Sending power cap %d to OCC %d", limit, occ->getInstance()); if (limit > 0) { TMGT_CONSOLE("User power limit has been set to %dW", limit); } OccCmd cmd(occ, OCC_CMD_SET_POWER_CAP, 2, data); err = cmd.sendOccCmd(); if (err) { TMGT_ERR("sendOccUserPowerCap: Failed sending command " "to OCC %d with rc = 0x%04X", occ->getInstance(), err->reasonCode()); break; } } else { //Other code deals with a missing master TMGT_ERR("sendOccUserPowerCap: No Master OCC found"); } } while (0);
void CircuitBuilder::build(Design * const design, const size_t &f) { delete cir_; cir_ = new Circuit; cir_->setFrame(f); cir_->setOccRoot(design->getOcc()); cir_->setModRoot(design->getTop()); map<string,Gate*> FFMap; // flip-flop map, used to connecte PPI & PPO // create PI // ignore CK, test_si, and test_so for (size_t i = 0; i < design->getTop()->nModTerms(); ++i) { ModTerm *term = design->getTop()->getModTerm(i); if (term->getType() != ModTerm::INPUT || strcmp(term->getName(),"test_si") == 0 || strcmp(term->getName(),"test_se") == 0 || strcmp(term->getName(),"CK") == 0 ) continue; Gate *g = new PiGate; g->setOcc(design->getOcc()); cir_->addPi(g); } // create PPI for (size_t i = 0; i < design->getOcc()->nChildren(); ++i) { Occ *occ = design->getOcc()->getChild(i); string modName(occ->getModInst()->getModName()); if (modName.size() < 4 || modName.substr(0,4) != "SDFF") continue; Gate *g = new PpiGate; g->setOcc(occ); cir_->addPpi(g); cir_->setOccToGate(occ, g); FFMap[occ->getModInst()->getName()] = g; } // create combinational gates for (size_t i = 0; i < design->getOcc()->nChildren(); ++i) { Occ *occ = design->getOcc()->getChild(i); string modName(occ->getModInst()->getModName()); if (modName.size() > 3 && modName.substr(0,4) == "SDFF") continue; Gate *g = createGate(occ); g->setOcc(occ); cir_->addComb(g); cir_->setOccToGate(occ, g); } // create PO for (size_t i = 0; i < design->getTop()->nModTerms(); ++i) { ModTerm *term = design->getTop()->getModTerm(i); if (term->getType() != ModTerm::OUTPUT) continue; Gate *g = new PoGate; g->setOcc(design->getOcc()); cir_->addPo(g); } // create PPO for (size_t i = 0; i < design->getOcc()->nChildren(); ++i) { Occ *occ = design->getOcc()->getChild(i); string modName(occ->getModInst()->getModName()); if (modName.size() < 4 || modName.substr(0,4) != "SDFF") continue; Gate *g = new PpoGate; g->setOcc(occ); cir_->addPpo(g); FFMap[occ->getModInst()->getName()]->addFi(g); } // connect gates for (size_t i = cir_->nPis() + cir_->nSeqs(); i < cir_->nGates(); ++i) { Gate *g = cir_->getGate(i); Occ *occ = g->getOcc(); size_t nTerm = 0; if (g->getType() == Gate::PO || g->getType() == Gate::PPO) nTerm = 1; else nTerm = occ->getModInst()->nModInstTerms() - 1; for (size_t j = 0; j < nTerm; ++j) { ModTerm *term = NULL; ModInstTerm *instTerm = NULL; ModNet *net = NULL; if (g->getType() == Gate::PO) { // because we ignore 3 inputs(CK,test_si,test_so) // we have to add 3 in idx to match id in ModTerm size_t id = i - cir_->nCombs() - cir_->nSeqs() + 3; term = design->getTop()->getModTerm(id); net = term->getModNet(); } else if (g->getType() == Gate::PPO) { instTerm = occ->getModInst()->getModInstTerm("D"); net = instTerm->getModNet(); } else { instTerm = occ->getModInst()->getModInstTerm(j); net = instTerm->getModNet(); } // find fanin Gate *fi = NULL; for (size_t k = 0; k < net->nModTerms(); ++k) { if (net->getModTerm(k) == term || net->getModTerm(k)->getType() == ModTerm::OUTPUT) continue; // because we ignore 3 inputs(CK,test_si,test_so) // we have to minus 3 in idx to match id in ModTerm size_t id = net->getModTerm(k)->getPos()-3; fi = cir_->getGate(id); break; } if (!fi) { for (size_t k = 0; k < net->nModInstTerms(); ++k) { ModInst *inst = net->getModInstTerm(k)->getModInst(); if (net->getModInstTerm(k) == instTerm || inst->getModule()->getModTerm(net->getModInstTerm(k)->getName())->getType() == ModTerm::INPUT) continue; const char *name = net->getModInstTerm(k)->getModInst()->getName(); fi = cir_->getGate(design->getOcc()->getChild(name)); break; } } // connect gates g->addFi(fi); fi->addFo(g); } } levelize(); setTimeFrame(f); }
// Send a poll command to all OCCs errlHndl_t sendOccPoll(const bool i_flushAllErrors) { errlHndl_t l_err = NULL; uint8_t * l_poll_rsp = NULL; // Loop through all functional OCCs std::vector<Occ*> occList = occMgr::instance().getOccArray(); for (std::vector<Occ*>::iterator itr = occList.begin(); (itr < occList.end()) && (NULL == l_err); ++itr) { Occ * occ = (*itr); const uint8_t occInstance = occ->getInstance(); bool continuePolling = false; do { // create 1 byte buffer for poll command data const uint8_t l_cmdData[1] = { 0x10 /*version*/ }; OccCmd cmd(occ, OCC_CMD_POLL, sizeof(l_cmdData), l_cmdData); l_err = cmd.sendOccCmd(); if (l_err != NULL) { // Poll failed TMGT_ERR("sendOccPoll: OCC%d poll failed with rc=0x%04X", occInstance, l_err->reasonCode()); } else { // Poll succeeded, check response uint32_t l_poll_rsp_size = cmd.getResponseData(l_poll_rsp); if (l_poll_rsp_size >= OCC_POLL_DATA_MIN_SIZE) { if (i_flushAllErrors) { const occPollRspStruct_t *currentPollRsp = (occPollRspStruct_t *) l_poll_rsp; if (currentPollRsp->errorId != 0) { // An error was returned, keep polling OCC continuePolling = true; } else { continuePolling = false; } } occ->pollRspHandler(l_poll_rsp, l_poll_rsp_size); } else { TMGT_ERR("sendOccPoll: OCC%d poll command response " "failed with invalid data length %d", occInstance, l_poll_rsp_size); /*@ * @errortype * @reasoncode HTMGT_RC_INVALID_LENGTH * @moduleid HTMGT_MOD_OCC_POLL * @userdata1 OCC instance * @devdesc Invalid POLL response length */ bldErrLog(l_err, HTMGT_MOD_OCC_POLL, HTMGT_RC_INVALID_LENGTH, occInstance, 0, 0, 0, ERRORLOG::ERRL_SEV_INFORMATIONAL); } } } while (continuePolling); } // for each OCC return l_err; } // end sendOccPoll()