static void walk_exp_non_tail(FILE* oc, std::string dest, Exp* exp) { // 末尾でなかったら計算結果をdestにセット if (dynamic_cast<Nop*> (exp)) { } else if (auto e_ = dynamic_cast<Set*> (exp)) { fprintf(oc, "\tmovl\t$%d, %s\n", e_->v, dest.c_str()); } else if (auto e_ = dynamic_cast<SetL*> (exp)) { fprintf(oc, "\tmovl\t$%s, %s\n", e_->l.c_str(), dest.c_str()); } else if (auto e_ = dynamic_cast<Mov*> (exp)) { if (dest != e_->id) fprintf(oc, "\tmovl\t%s, %s\n", e_->id.c_str(), dest.c_str()); } else if (auto e_ = dynamic_cast<Neg*> (exp)) { if (dest != e_->id) fprintf(oc, "\tmovl\t%s, %s\n", e_->id.c_str(), dest.c_str()); fprintf(oc, "\tnegl\t%s\n", dest.c_str()); } else if (auto e_ = dynamic_cast<Add*> (exp)) { if (auto v = dynamic_cast<V*> (e_->imm.get())) { if (v->v == dest) { fprintf(oc, "\taddl\t%s, %s\n", e_->id.c_str(), dest.c_str()); return; } } if (dest != e_->id) fprintf(oc, "\tmovl\t%s, %s\n", e_->id.c_str(), dest.c_str()); fprintf(oc, "\taddl\t%s, %s\n", pp_id_or_imm(e_->imm.get()).c_str(), dest.c_str()); } else if (auto e_ = dynamic_cast<Sub*> (exp)) { if (auto v = dynamic_cast<V*> (e_->imm.get())) { if (v->v == dest) { fprintf(oc, "\tsubl\t%s, %s\n", e_->id.c_str(), dest.c_str()); fprintf(oc, "\tnegl\t%s\n", dest.c_str()); return; } } if (dest != e_->id) fprintf(oc, "\tmovl\t%s, %s\n", e_->id.c_str(), dest.c_str()); fprintf(oc, "\tsubl\t%s, %s\n", pp_id_or_imm(e_->imm.get()).c_str(), dest.c_str()); } else if (auto e_ = dynamic_cast<Ld*> (exp)) { if (auto v = dynamic_cast<V*> (e_->imm.get())) { fprintf(oc, "\tmovl\t(%s,%s,%d), %s\n", e_->id.c_str(), v->v.c_str(), e_->i, dest.c_str()); return; } if (auto c = dynamic_cast<C*> (e_->imm.get())) { fprintf(oc, "\tmovl\t%d(%s), %s\n", c->i * e_->i, e_->id.c_str(), dest.c_str()); return; } assert(false); } else if (auto e_ = dynamic_cast<St*> (exp)) { if (auto v = dynamic_cast<V*> (e_->imm.get())) { fprintf(oc, "\tmovl\t%s, (%s,%s,%d)\n", e_->id.c_str(), e_->id2.c_str(), v->v.c_str(), e_->i); return; } if (auto c = dynamic_cast<C*> (e_->imm.get())) { fprintf(oc, "\tmovl\t%s, %d(%s)\n", e_->id.c_str(), c->i * e_->i, e_->id2.c_str()); return; } assert(false); } else // 退避の仮想命令の実装 if (auto e_ = dynamic_cast<Save*> (exp)) { if (allregs.find(e_->id) != allregs.end() && stackset.find(e_->id2) == stackset.end()) { save(e_->id2); fprintf(oc, "\tmovl\t%s, %d(%s)\n", e_->id.c_str(), offset(e_->id2), reg_sp); return; } assert(stackset.find(e_->id2) != stackset.end()); } else if (auto e_ = dynamic_cast<Restore*> (exp)) { // 復帰の仮想命令の実装 fprintf(oc, "\tmovl\t%d(%s), %s\n", offset(e_->id), reg_sp, dest.c_str()); } else if (auto e_ = dynamic_cast<IfEq*> (exp)) { fprintf(oc, "\tcmpl\t%s, %s\n", pp_id_or_imm(e_->imm.get()).c_str(), e_->id.c_str()); walk_exp_non_tail_if(oc, dest, e_->e1.get(), e_->e2.get(), "je", "jne"); } else if (auto e_ = dynamic_cast<IfLE*> (exp)) { fprintf(oc, "\tcmpl\t%s, %s\n", pp_id_or_imm(e_->imm.get()).c_str(), e_->id.c_str()); walk_exp_non_tail_if(oc, dest, e_->e1.get(), e_->e2.get(), "jle", "jg"); } else if (auto e_ = dynamic_cast<IfGE*> (exp)) { fprintf(oc, "\tcmpl\t%s, %s\n", pp_id_or_imm(e_->imm.get()).c_str(), e_->id.c_str()); walk_exp_non_tail_if(oc, dest, e_->e1.get(), e_->e2.get(), "jge", "jl"); } else if (auto e_ = dynamic_cast<Call*> (exp)) { walk_exp_args(oc, std::vector<std::pair < std::string, std::string >> (), e_->ids); auto ss = stacksize(); if (ss > 0) fprintf(oc, "\taddl\t$%d, %s\n", ss, reg_sp); fprintf(oc, "\tcall\t%s\n", e_->id.c_str()); if (ss > 0) fprintf(oc, "\tsubl\t$%d, %s\n", ss, reg_sp); if (allregs.find(dest) != allregs.end() && dest != regs[0]) fprintf(oc, "\tmovl\t%s, %s\n", regs[0].c_str(), dest.c_str()); } else { assert(false); } }
void RestartableDataIO::deserializeRestartableData(const std::map<std::string, RestartableDataValue *> & restartable_data, std::istream & stream, const std::set<std::string> & recoverable_data) { bool recovering = _fe_problem.getMooseApp().isRecovering(); std::vector<std::string> ignored_data; // number of data unsigned int n_data = 0; stream.read((char *) &n_data, sizeof(n_data)); // data names std::vector<std::string> data_names(n_data); for (unsigned int i=0; i < n_data; i++) { std::string data_name; char ch = 0; do { stream.read(&ch, 1); if (ch != '\0') data_name += ch; } while (ch != '\0'); data_names[i] = data_name; } // Grab this processor's block size unsigned int data_blk_size = 0; stream.read((char *) &data_blk_size, sizeof(data_blk_size)); for (unsigned int i=0; i < n_data; i++) { std::string current_name = data_names[i]; unsigned int data_size = 0; stream.read((char *) &data_size, sizeof(data_size)); // Determine if the current data is recoverable bool is_data_restartable = restartable_data.find(current_name) != restartable_data.end(); bool is_data_recoverable = recoverable_data.find(current_name) != recoverable_data.end(); if (is_data_restartable // Only restore values if they're currently being used && (recovering || !is_data_recoverable)) // Only read this value if we're either recovering or this hasn't been specified to be recovery only data { // Moose::out<<"Loading "<<current_name<<std::endl; try { RestartableDataValue * current_data = restartable_data.at(current_name); current_data->load(stream); } catch(...) { mooseError("restartable_data missing " << current_name << std::endl); } } else { // Skip this piece of data and do not report if restarting and recoverable data is not used stream.seekg(data_size, std::ios_base::cur); if (recovering && !is_data_recoverable) ignored_data.push_back(current_name); } } // Produce a warning if restarting and restart data is being skipped // Do not produce the warning with recovery b/c in cases the parent defines a something as recoverable, // but only certain child classes use the value in recovery (i.e., FileOutput::_num_files is needed by Exodus but not Checkpoint) if (ignored_data.size() && !recovering) { std::ostringstream names; for (unsigned int i=0; i<ignored_data.size(); i++) names << ignored_data[i] << "\n"; mooseWarning("The following RestartableData was found in restart file but is being ignored:\n" << names.str()); } }
int check_for_mics( uint32_t& num_engines) { uint32_t i = 0; #ifdef NUMA_SUPPORT /* does this node board have mics configured? */ if (node_boards[numa_index].mic_end_index < 0) return(PBSE_NONE); #endif if (COIEngineGetCount(COI_ISA_MIC, &num_engines) != COI_SUCCESS) { log_err(-1, __func__, "Mics are present but apparently not configured correctly - can't get count"); return(PBSE_SYSTEM); } #ifdef NUMA_SUPPORT if (num_engines < node_boards[numa_index].mic_end_index) { snprintf(log_buffer, sizeof(log_buffer), "node board %d is supposed to have mic range %d-%d but there are only %d mics", numa_index, node_boards[numa_index].mic_start_index, node_boards[numa_index].mic_end_index, num_engines); log_err(-1, __func__, log_buffer); return(PBSE_SYSTEM); } for (i = node_boards[numa_index].mic_start_index; i <= node_boards[numa_index].mic_end_index; i++) #else for (i = 0; i < num_engines; i++) #endif { int rc; COIENGINE engine; struct COI_ENGINE_INFO mic_stat; std::set<int>::iterator it; memset(&engine, 0, sizeof(engine)); memset(&mic_stat, 0, sizeof(mic_stat)); rc = COIEngineGetHandle(COI_ISA_MIC, i, &engine); if (rc != COI_SUCCESS) { it = down_mics.find(i); if (it == down_mics.end()) { snprintf(log_buffer, sizeof(log_buffer), "Can't get handle for mic index %d", (int)i); log_event(PBSEVENT_SYSTEM,PBS_EVENTCLASS_SERVER, __func__, log_buffer); down_mics.insert(i); } continue; } else { it = down_mics.find(i); if (it != down_mics.end()) { /* if we made it here we have the mic again. remove it from the down_mics set */ snprintf(log_buffer, sizeof(log_buffer), "handle for mic index %d is back online", (int)i); log_event(PBSEVENT_SYSTEM,PBS_EVENTCLASS_SERVER, __func__, log_buffer); down_mics.erase(it); } } } return(PBSE_NONE); }
void Output(const Mode mode, const char *file, const int line, const char *prefix, const char *delim, const char *name, const string &str) { if (initialized && str.length()) { string m = message(prefix,delim,name,str); // TODO - optional Regal source line numbers. #if 1 UNUSED_PARAMETER(file); UNUSED_PARAMETER(line); #else m = print_string(file,":",line," ",m); #endif #if REGAL_LOG_ONCE if (once) switch (mode) { case LOG_WARNING: if (uniqueWarnings.find(m)!=uniqueWarnings.end()) return; uniqueWarnings.insert(m); break; case LOG_ERROR: if (uniqueErrors.find(m)!=uniqueErrors.end()) return; uniqueErrors.insert(m); break; default: break; } #endif RegalContext *rCtx = NULL; #if !REGAL_SYS_WGL && !REGAL_NO_TLS if (Thread::currentContextKey && pthread_getspecific(Thread::currentContextKey)) rCtx = REGAL_GET_CONTEXT(); #else rCtx = REGAL_GET_CONTEXT(); #endif #if REGAL_LOG_CALLBACK if (callback && rCtx && rCtx->logCallback) rCtx->logCallback(GL_LOG_INFO_REGAL, (GLsizei) m.length(), m.c_str(), reinterpret_cast<void *>(rCtx->sysCtx)); #endif #if REGAL_SYS_WGL OutputDebugStringA(m.c_str()); #elif REGAL_SYS_ANDROID // ANDROID_LOG_INFO // ANDROID_LOG_WARN // ANDROID_LOG_ERROR __android_log_print(ANDROID_LOG_INFO, REGAL_LOG_TAG, m.c_str()); #endif #if REGAL_LOG_JSON if (json && jsonOutput) { string m = jsonObject(prefix,name,str); fwrite(m.c_str(),m.length(),1,jsonOutput); } #endif #if REGAL_LOG if (log && logOutput) { #if REGAL_SYS_WGL OutputDebugStringA(m.c_str()); fprintf(logOutput, "%s", m.c_str()); fflush(logOutput); #elif REGAL_SYS_ANDROID #else fprintf(logOutput, "%s", m.c_str()); fflush(logOutput); #endif } #endif append(m); } }
void FilterList::convert(const std::vector<std::string> & ruleList, const std::set<std::string> & disabled_list, std::vector<RegExpFilter *> & regexpList, std::vector<ElemHideSelector *> & elemHideFilter) { static const char * ELEMHIDE_PATTERN = "^([^\\/\\*\\|\\@\"]*?)#(?:([\\w\\-]+|\\*)((?:\\([\\w\\-]+(?:[$^*]?=[^\\(\\)\"]*)?\\))*)|#([^{}]+))$"; static const char * REGEXPR_PATTERN = "^\\/(.*)\\/$"; static const char * OPTIONS_PATTERN = "\\$(~?[\\w\\-]+(?:=[^,\\s]+)?(?:,~?[\\w\\-]+(?:=[^,\\s]+)?)*)$"; for ( auto iter = ruleList.begin(); iter != ruleList.end(); iter++ ) { std::string rule( * iter ); if ( disabled_list.find(rule) != disabled_list.end() ) { // 被禁用的规则,不做任何处理 continue; } auto pos = knownFilters.find(rule); if ( pos != knownFilters.end() ) { Filter * p = pos->second; if ( p ) { RegExpFilter * regexpFilter = dynamic_cast<RegExpFilter *>(p); if ( regexpFilter ) { regexpList.push_back(regexpFilter); // 加引用计数, 以免被释放 regexpFilter->AddRef(); } else { ElemHideSelector * selector = dynamic_cast<ElemHideSelector *>(p); if ( selector ) { elemHideFilter.push_back(selector); // 加引用计数, 以免被释放 selector->AddRef(); } else { // 不应该走到这里, 但是如果真到这里了, 把 p 从 map 里面去掉 knownFilters.erase(pos); p->Release(); } } continue; } } // 元素隐藏规则 std::string results[4]; if ( regexpr_match(ELEMHIDE_PATTERN, rule.c_str(), FALSE, results, 4) ) { const std::string & domain = results[0]; const std::string & tagName = results[1]; const std::string & attrRules = results[2]; const std::string & selector = results[3]; if ( ElemHideSelector * filter = ElemHideSelector::fromText(domain, tagName, attrRules, selector) ) { elemHideFilter.push_back(filter); knownFilters[rule] = filter; } } else { std::string re_rule(rule); // 访问过滤规则 std::string options_str; if ( regexpr_match(OPTIONS_PATTERN, re_rule.c_str(), FALSE, &options_str, 1) ) { // 把参数部分去掉 regexpr_replace(OPTIONS_PATTERN, re_rule.c_str(), "", re_rule); } if ( regexpr_match(REGEXPR_PATTERN, re_rule.c_str(), FALSE, results, 1) ) { re_rule = results[0]; } else { // 将 adblockplus 规则转换成正则表达式规则 regexpr_replace("\\*+", re_rule.c_str(), "*", re_rule, TRUE); regexpr_replace("\\^\\|$", re_rule.c_str(), "^", re_rule, FALSE); regexpr_replace("(\\W)", re_rule.c_str(), "\r\\1", re_rule, TRUE); string_replace(re_rule, "\r", "\\"); regexpr_replace("\\\\\\*", re_rule.c_str(), ".*", re_rule, TRUE); regexpr_replace("\\\\\\^", re_rule.c_str(), "(?:[^\rw\r-.%\ru0080-\ruFFFF]|$)", re_rule, TRUE); regexpr_replace("^\\\\\\|\\\\\\|", re_rule.c_str(), "^[\rw\r-]+:\r/+(?!\r/)(?:[^\r/]+\r.)?", re_rule, FALSE); string_replace(re_rule, "\r", "\\"); regexpr_replace("^\\\\\\|", re_rule.c_str(), "^", re_rule, FALSE); regexpr_replace("\\\\\\|$", re_rule.c_str(), "$", re_rule, FALSE); regexpr_replace("^(\\.\\*)", re_rule.c_str(), "", re_rule, FALSE); regexpr_replace("(\\.\\*)$", re_rule.c_str(), "", re_rule, FALSE); } if ( RegExpFilter * filter = RegExpFilter::fromText(re_rule, options_str) ) { regexpList.push_back(filter); knownFilters[rule] = filter; } } } }
bool China::IbImpl::isBusinessDay(const Date& date) const { static const Date working_weekends[] = { // 2005 Date(5, February, 2005), Date(6, February, 2005), Date(30, April, 2005), Date(8, May, 2005), Date(8, October, 2005), Date(9, October, 2005), Date(31, December, 2005), //2006 Date(28, January, 2006), Date(29, April, 2006), Date(30, April, 2006), Date(30, September, 2006), Date(30, December, 2006), Date(31, December, 2006), // 2007 Date(17, February, 2007), Date(25, February, 2007), Date(28, April, 2007), Date(29, April, 2007), Date(29, September, 2007), Date(30, September, 2007), Date(29, December, 2007), // 2008 Date(2, February, 2008), Date(3, February, 2008), Date(4, May, 2008), Date(27, September, 2008), Date(28, September, 2008), // 2009 Date(4, January, 2009), Date(24, January, 2009), Date(1, February, 2009), Date(31, May, 2009), Date(27, September, 2009), Date(10, October, 2009), // 2010 Date(20, February, 2010), Date(21, February, 2010), Date(12, June, 2010), Date(13, June, 2010), Date(19, September, 2010), Date(25, September, 2010), Date(26, September, 2010), Date(9, October, 2010), // 2011 Date(30, January, 2011), Date(12, February, 2011), Date(2, April, 2011), Date(8, October, 2011), Date(9, October, 2011), Date(31, December, 2011), // 2012 Date(21, January, 2012), Date(29, January, 2012), Date(31, March, 2012), Date(1, April, 2012), Date(28, April, 2012), Date(29, September, 2012), // 2013 Date(5,January,2013), Date(6,January,2013), Date(16,February,2013), Date(17,February,2013), Date(7,April,2013), Date(27,April,2013), Date(28,April,2013), Date(8,June,2013), Date(9,June,2013), Date(22,September,2013), Date(29,September,2013), Date(12,October,2013), // 2014 Date(26,January,2014), Date(8,February,2014), Date(4,May,2014), Date(28,September,2014), Date(11,October,2014), // 2015 Date(4,January,2015), Date(15,February,2015), Date(28,February,2015), Date(6,September,2015), Date(10,October,2015), // 2016 Date(6,February,2016), Date(14,February,2016), Date(12,June,2016), Date(18,September,2016), Date(8,October,2016), Date(9,October,2016) }; static const Size n = sizeof(working_weekends)/sizeof(working_weekends[0]); static const std::set<Date> workingWeekends(working_weekends+0, working_weekends+n); // If it is already a SSE business day, it must be a IB business day return sseImpl->isBusinessDay(date) || (workingWeekends.find(date) != workingWeekends.end()); }
void Check(){ for (auto& it : mFileMonitorThread){ if (it.HasChangedFiles()){ std::set<std::string> changedFiles; it.GetChangedFiles(changedFiles); mChangedFiles.insert(changedFiles.begin(), changedFiles.end()); } } if (gpTimer->GetTickCount() - mLastCheckedTime > 500) { for (auto it = mChangedFiles.begin(); it != mChangedFiles.end();) { std::string filepath = it->c_str(); auto strs = Split(filepath, "~"); if (strs.size() >= 2) { filepath = strs[0]; } const char* extension = FileSystem::GetExtension(filepath.c_str()); bool shader = _stricmp(extension, "hlsl") == 0 || _stricmp(extension, "h") == 0; bool material = _stricmp(extension, "material") == 0; bool texture = _stricmp(extension, "png") == 0 || _stricmp(extension, "dds") == 0; bool particle = _stricmp(extension, "particle") == 0; bool xml = _stricmp(extension, "xml") == 0; bool hasExtension = strlen(extension) != 0; bool sdfFile = _stricmp(extension, "sdf") == 0; bool canOpen = true; bool throwAway = false; auto ignoreIt = mIgnoreFileChanges.find(filepath); if (ignoreIt != mIgnoreFileChanges.end()){ mIgnoreFileChanges.erase(ignoreIt); throwAway = true; } if (!hasExtension || sdfFile || throwAway) { auto nextit = it; ++nextit; mChangedFiles.erase(it); it = nextit; continue; } FILE* file = 0; errno_t err = fopen_s(&file, filepath.c_str(), "r"); if (!err && file) { fclose(file); err = fopen_s(&file, filepath.c_str(), "a+"); if (err) canOpen = false; else if (file) fclose(file); } if (canOpen) { int startEnum = shader || material || texture || particle || xml ? IFileChangeObserver::FileChange_Engine : IFileChangeObserver::FileChange_Game; for (int i = startEnum; i < 2; ++i){ auto& observers = mSelf->mObservers_[i]; //FileChange_Engine and FileChange_Game for (auto oit = observers.begin(); oit != observers.end(); /**/){ auto observer = oit->lock(); if (!observer){ oit = observers.erase(oit); continue; } ++oit; observer->OnFileChanged(filepath.c_str()); } } /*if (shader) IShader::ReloadShader(filepath.c_str()); else if (material) IMaterial::ReloadMaterial(filepath.c_str()); else if (texture) ITexture::ReloadTexture(filepath.c_str()); else if (particle) ParticleManager::GetParticleManager().ReloadParticle(filepath.c_str()); else if (xml && gFBEnv->pRenderer) mRenderer->ReloadTextureAtlas(filepath.c_str());*/ auto nextit = it; ++nextit; mChangedFiles.erase(it); it = nextit; } else { ++it; } } } }
void ProjectCollector::extract_files() { static const std::string configuration_name = m_configuration_name + "|Win32"; static const path extension_list[] = { ".c", ".cpp", ".cxx", ".cc", ".h", ".hpp", ".hxx", ".hh", ".inl" }; static size_t size = sizeof(extension_list) / sizeof(path); static const std::set<path> extensions( extension_list, extension_list + size ); // extract files static const boost::regex file_regex ( "(?x)" "<File \\s+" " RelativePath=\" ( [^\"]+ ) \" \\s+ > " //$1, file relative path " ( .*? ) \\s+ " //$2, configurations "</File>" ); boost::sregex_iterator it( m_str.begin(), m_str.end(), file_regex ); boost::sregex_iterator end; for ( ; it != end; ++it ) { path source_file_relative_path = it->str(1); std::string configurations = it->str(2); bool is_excluded = false; if ( false == configurations.empty() ) { static const boost::regex file_configuration_regex ( "(?x)" "<FileConfiguration \\s+" " Name= \" ( .+? ) \" \\s+" //$1, Name " ExcludedFromBuild= \" ( .+? ) \" \\s+ " //$2, ExcludedFromBuild ">" ); boost::sregex_iterator it( configurations.begin(), configurations.end(), file_configuration_regex ); boost::sregex_iterator end; for ( ; it != end; ++it ) { std::string file_configuration_name = it->str(1); std::string excluded_form_build = it->str(2); if ( file_configuration_name == configuration_name ) { if ( "true" == excluded_form_build ) { is_excluded = true; } break; } } } if ( false == is_excluded ) { path p = boost::filesystem::system_complete( m_current_path / source_file_relative_path ); if ( extensions.find( p.extension() ) != extensions.end() ) { //std::cout << p.string() << std::endl; m_files.push_back( p ); } } } }
bool is_ignored(int i) { static std::set<int> ignore = {}; return ignore.find(i) != ignore.end(); }
/** * Checks whether epsilon is present in the given set. * @param first -> The set being checked for epsilon * @return the result of the test */ bool Parser::hasEpsilon(const std::set<char> first) { return first.find(EPSILON[0]) != first.end(); }
//***************************************************************************** // void MASTERSERVER_ParseCommands( BYTESTREAM_s *pByteStream ) { long lCommand; NETADDRESS_s AddressFrom; AddressFrom = NETWORK_GetFromAddress( ); // [RC] If this IP is in our flood queue, ignore it completely. if ( g_floodProtectionIPQueue.addressInQueue( AddressFrom ) || g_ShortFloodQueue.addressInQueue( AddressFrom )) { while ( NETWORK_ReadByte( pByteStream ) != -1 ) // [RC] Is this really necessary? ; return; } // Is this IP banned? Send the user an explanation, and ignore the IP for 30 seconds. if ( !g_BannedIPExemptions.isIPInList( AddressFrom ) && g_BannedIPs.isIPInList( AddressFrom )) { NETWORK_ClearBuffer( &g_MessageBuffer ); NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_IPISBANNED ); NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); printf( "* Received challenge from banned IP (%s). Ignoring for 10 seconds.\n", NETWORK_AddressToString( AddressFrom )); g_queryIPQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr ); return; } lCommand = NETWORK_ReadLong( pByteStream ); switch ( lCommand ) { // Server is telling master server of its existence. case SERVER_MASTER_CHALLENGE: { // Certain IPs can be blocked from just hosting. if ( !g_BannedIPExemptions.isIPInList( AddressFrom ) && g_BlockedIPs.isIPInList( AddressFrom )) { NETWORK_ClearBuffer( &g_MessageBuffer ); NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_IPISBANNED ); NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); printf( "* Received server challenge from blocked IP (%s). Ignoring for 10 seconds.\n", NETWORK_AddressToString( AddressFrom )); g_queryIPQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr ); return; } SERVER_s newServer; newServer.Address = AddressFrom; // [BB] If no verification string was send, NETWORK_ReadString just returns an empty string. // Thus, this is still compatible with older servers that don't send the string. newServer.MasterBanlistVerificationString = NETWORK_ReadString( pByteStream ); // [BB] If no value was send, NETWORK_ReadByte just returns -1. // Thus, this is still compatible with older servers that don't tell us whether they enforce our bans // and gives them the benefit of the doubt, i.e. it assumes that they enforce our bans. const int temp = NETWORK_ReadByte( pByteStream ); newServer.bEnforcesBanList = ( temp != 0 ); newServer.bNewFormatServer = ( temp != -1 ); newServer.iServerRevision = NETWORK_ReadShort( pByteStream ); std::set<SERVER_s, SERVERCompFunc>::iterator currentServer = g_Servers.find ( newServer ); // This is a new server; add it to the list. if ( currentServer == g_Servers.end() ) { unsigned int iNumOtherServers = 0; // First count the number of servers from this IP. for( std::set<SERVER_s, SERVERCompFunc>::const_iterator it = g_Servers.begin(); it != g_Servers.end(); ++it ) { if ( NETWORK_CompareAddress( it->Address, AddressFrom, true )) iNumOtherServers++; } if ( iNumOtherServers >= 10 && !g_MultiServerExceptions.isIPInList( AddressFrom )) printf( "* More than 10 servers received from %s. Ignoring request...\n", NETWORK_AddressToString( AddressFrom )); else { if ( newServer.bNewFormatServer ) { std::set<SERVER_s, SERVERCompFunc>::iterator currentUnverifiedServer = g_UnverifiedServers.find ( newServer ); // [BB] This is a new server, but we still need to verify it. if ( currentUnverifiedServer == g_UnverifiedServers.end() ) { srand ( time(NULL) ); newServer.ServerVerificationInt = rand() + rand() * rand() + rand() * rand() * rand(); // [BB] We don't send the ban list to unverified servers, so just pretent the server already has the list. newServer.bHasLatestBanList = true; MASTERSERVER_RequestServerVerification ( newServer ); MASTERSERVER_AddServer( newServer, g_UnverifiedServers ); } } else { printf( "* Received server challenge from old server (%s). Ignoring IP for 10 seconds.\n", NETWORK_AddressToString( newServer.Address )); g_queryIPQueue.addAddress( newServer.Address, g_lCurrentTime, &std::cerr ); } } } // Command is from a server already on the list. It's just sending us a heartbeat. else { // [BB] Only if the verification string matches. if ( stricmp ( currentServer->MasterBanlistVerificationString.c_str(), newServer.MasterBanlistVerificationString.c_str() ) == 0 ) { currentServer->lLastReceived = g_lCurrentTime; // [BB] The server possibly changed the ban setting, so update it. currentServer->bEnforcesBanList = newServer.bEnforcesBanList; } } // Ignore IP for 10 seconds. // if ( !g_MultiServerExceptions.isIPInList( Address ) ) // g_floodProtectionIPQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr ); return; } case SERVER_MASTER_VERIFICATION: { SERVER_s newServer; newServer.Address = AddressFrom; newServer.MasterBanlistVerificationString = NETWORK_ReadString( pByteStream ); newServer.ServerVerificationInt = NETWORK_ReadLong( pByteStream ); std::set<SERVER_s, SERVERCompFunc>::iterator currentServer = g_UnverifiedServers.find ( newServer ); // [BB] Apparently, we didn't request any verification from this server, so ignore it. if ( currentServer == g_UnverifiedServers.end() ) return; if ( ( stricmp ( newServer.MasterBanlistVerificationString.c_str(), currentServer->MasterBanlistVerificationString.c_str() ) == 0 ) && ( newServer.ServerVerificationInt == currentServer->ServerVerificationInt ) ) { MASTERSERVER_AddServer( *currentServer, g_Servers ); g_UnverifiedServers.erase ( currentServer ); } return; } case SERVER_MASTER_BANLIST_RECEIPT: { SERVER_s server; server.Address = AddressFrom; server.MasterBanlistVerificationString = NETWORK_ReadString( pByteStream ); std::set<SERVER_s, SERVERCompFunc>::iterator currentServer = g_Servers.find ( server ); // [BB] We don't know the server. Just ignore it. if ( currentServer == g_Servers.end() ) return; if ( stricmp ( server.MasterBanlistVerificationString.c_str(), currentServer->MasterBanlistVerificationString.c_str() ) == 0 ) { currentServer->bVerifiedLatestBanList = true; std::cerr << NETWORK_AddressToString ( AddressFrom ) << " acknowledged receipt of the banlist.\n"; } } return; // Launcher is asking master server for server list. case LAUNCHER_SERVER_CHALLENGE: case LAUNCHER_MASTER_CHALLENGE: { NETWORK_ClearBuffer( &g_MessageBuffer ); // Did this IP query us recently? If so, send it an explanation, and ignore it completely for 3 seconds. if ( g_queryIPQueue.addressInQueue( AddressFrom )) { NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_REQUESTIGNORED ); NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); printf( "* Extra launcher challenge from %s. Ignoring for 3 seconds.\n", NETWORK_AddressToString( AddressFrom )); g_ShortFloodQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr ); return; } // [BB] The launcher only sends the protocol version with LAUNCHER_MASTER_CHALLENGE. if ( lCommand == LAUNCHER_MASTER_CHALLENGE ) { // [BB] Check if the requested version of the protocol matches ours. const unsigned short usVersion = NETWORK_ReadShort( pByteStream ); if ( usVersion != MASTER_SERVER_VERSION ) { NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_WRONGVERSION ); NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); return; } } printf( "-> Sending server list to %s.\n", NETWORK_AddressToString( AddressFrom )); // Wait 10 seconds before sending this IP the server list again. g_queryIPQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr ); switch ( lCommand ) { case LAUNCHER_SERVER_CHALLENGE: // Send the list of servers. NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_BEGINSERVERLIST ); for( std::set<SERVER_s, SERVERCompFunc>::const_iterator it = g_Servers.begin(); it != g_Servers.end(); ++it ) { // [BB] Possibly omit servers that don't enforce our ban list. if ( ( it->bEnforcesBanList == true ) || ( g_bHideBanIgnoringServers == false ) ) MASTERSERVER_SendServerIPToLauncher ( it->Address, &g_MessageBuffer.ByteStream ); } // Tell the launcher that we're done sending servers. NETWORK_WriteByte( &g_MessageBuffer.ByteStream, MSC_ENDSERVERLIST ); // Send the launcher our packet. NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); return; case LAUNCHER_MASTER_CHALLENGE: const unsigned long ulMaxPacketSize = 1024; unsigned long ulPacketNum = 0; std::set<SERVER_s, SERVERCompFunc>::const_iterator it = g_Servers.begin(); NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_BEGINSERVERLISTPART ); NETWORK_WriteByte( &g_MessageBuffer.ByteStream, ulPacketNum ); NETWORK_WriteByte( &g_MessageBuffer.ByteStream, MSC_SERVERBLOCK ); unsigned long ulSizeOfPacket = 6; // 4 (MSC_BEGINSERVERLISTPART) + 1 (0) + 1 (MSC_SERVERBLOCK) while ( it != g_Servers.end() ) { NETADDRESS_s serverAddress = it->Address; std::vector<USHORT> serverPortList; do { // [BB] Possibly omit servers that don't enforce our ban list. if ( ( it->bEnforcesBanList == true ) || ( g_bHideBanIgnoringServers == false ) ) serverPortList.push_back ( it->Address.usPort ); ++it; } while ( ( it != g_Servers.end() ) && NETWORK_CompareAddress( it->Address, serverAddress, true ) ); // [BB] All servers on this IP ignore the list, nothing to send. if ( serverPortList.size() == 0 ) continue; const unsigned long ulServerBlockNetSize = MASTERSERVER_CalcServerIPBlockNetSize( serverAddress, serverPortList ); // [BB] If sending this block would cause the current packet to exceed ulMaxPacketSize ... if ( ulSizeOfPacket + ulServerBlockNetSize > ulMaxPacketSize - 1 ) { // [BB] ... close the current packet and start a new one. NETWORK_WriteByte( &g_MessageBuffer.ByteStream, 0 ); // [BB] Terminate MSC_SERVERBLOCK by sending 0 ports. NETWORK_WriteByte( &g_MessageBuffer.ByteStream, MSC_ENDSERVERLISTPART ); NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); NETWORK_ClearBuffer( &g_MessageBuffer ); ++ulPacketNum; ulSizeOfPacket = 5; NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_BEGINSERVERLISTPART ); NETWORK_WriteByte( &g_MessageBuffer.ByteStream, ulPacketNum ); NETWORK_WriteByte( &g_MessageBuffer.ByteStream, MSC_SERVERBLOCK ); } ulSizeOfPacket += ulServerBlockNetSize; MASTERSERVER_SendServerIPBlockToLauncher ( serverAddress, serverPortList, &g_MessageBuffer.ByteStream ); } NETWORK_WriteByte( &g_MessageBuffer.ByteStream, 0 ); // [BB] Terminate MSC_SERVERBLOCK by sending 0 ports. NETWORK_WriteByte( &g_MessageBuffer.ByteStream, MSC_ENDSERVERLIST ); NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); return; } } } printf( "* Received unknown challenge (%d) from %s. Ignoring for 10 seconds...\n", lCommand, NETWORK_AddressToString( AddressFrom )); g_floodProtectionIPQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr ); }
static bool is_electric(const wcstring &key) { return env_electric.find(key) != env_electric.end(); }
static bool is_read_only(const wcstring &key) { return env_read_only.find(key) != env_read_only.end(); }
void remove_function_pointerst::remove_function_pointer( goto_programt &goto_program, goto_programt::targett target) { const code_function_callt &code= to_code_function_call(target->code); const exprt &function=code.function(); // this better have the right type code_typet call_type=to_code_type(function.type()); // refine the type in case the forward declaration was incomplete if(call_type.has_ellipsis() && call_type.parameters().empty()) { call_type.remove_ellipsis(); forall_expr(it, code.arguments()) call_type.parameters().push_back( code_typet::parametert(it->type())); } assert(function.id()==ID_dereference); assert(function.operands().size()==1); const exprt &pointer=function.op0(); // Is this simple? if(pointer.id()==ID_address_of && to_address_of_expr(pointer).object().id()==ID_symbol) { to_code_function_call(target->code).function()= to_address_of_expr(pointer).object(); return; } typedef std::list<exprt> functionst; functionst functions; bool return_value_used=code.lhs().is_not_nil(); // get all type-compatible functions // whose address is ever taken for(type_mapt::const_iterator f_it= type_map.begin(); f_it!=type_map.end(); f_it++) { // address taken? if(address_taken.find(f_it->first)==address_taken.end()) continue; // type-compatible? if(!is_type_compatible(return_value_used, call_type, f_it->second)) continue; if(f_it->first=="pthread_mutex_cleanup") continue; symbol_exprt expr; expr.type()=f_it->second; expr.set_identifier(f_it->first); functions.push_back(expr); } // the final target is a skip goto_programt final_skip; goto_programt::targett t_final=final_skip.add_instruction(); t_final->make_skip(); // build the calls and gotos goto_programt new_code_calls; goto_programt new_code_gotos; for(functionst::const_iterator it=functions.begin(); it!=functions.end(); it++) { // call function goto_programt::targett t1=new_code_calls.add_instruction(); t1->make_function_call(code); to_code_function_call(t1->code).function()=*it; // the signature of the function might not match precisely fix_argument_types(to_code_function_call(t1->code)); fix_return_type(to_code_function_call(t1->code), new_code_calls); // goto final goto_programt::targett t3=new_code_calls.add_instruction(); t3->make_goto(t_final, true_exprt()); // goto to call address_of_exprt address_of; address_of.object()=*it; address_of.type()=pointer_typet(); address_of.type().subtype()=it->type(); if(address_of.type()!=pointer.type()) address_of.make_typecast(pointer.type()); goto_programt::targett t4=new_code_gotos.add_instruction(); t4->make_goto(t1, equal_exprt(pointer, address_of)); } // fall-through if(add_safety_assertion) { goto_programt::targett t=new_code_gotos.add_instruction(); t->make_assertion(false_exprt()); t->source_location.set_property_class("pointer dereference"); t->source_location.set_comment("invalid function pointer"); } goto_programt new_code; // patch them all together new_code.destructive_append(new_code_gotos); new_code.destructive_append(new_code_calls); new_code.destructive_append(final_skip); // set locations Forall_goto_program_instructions(it, new_code) { irep_idt property_class=it->source_location.get_property_class(); irep_idt comment=it->source_location.get_comment(); it->source_location=target->source_location; it->function=target->function; if(!property_class.empty()) it->source_location.set_property_class(property_class); if(!comment.empty()) it->source_location.set_comment(comment); }
// This function meshes the top surface of a QuadToTri extrusion. It returns 0 if it is given a // non-quadToTri extrusion or if it fails. // Args: // 'GFace *to' is the top surface to mesh, 'from' is the source surface, 'pos' is a std::set // of vertex positions for the top surface. int MeshQuadToTriTopSurface( GFace *from, GFace *to, std::set<MVertex*, MVertexLessThanLexicographic> &pos ) { if( !to->meshAttributes.extrude || !to->meshAttributes.extrude->mesh.QuadToTri ) return 0; // if the source is all triangles, then just let this function is not needed. Return 1. if( from->triangles.size() && !from->quadrangles.size() ) return 1; // in weird case of NO quads and NO tri if( !from->triangles.size() && !from->quadrangles.size() ) return 0; ExtrudeParams *ep = to->meshAttributes.extrude; if( !ep || !ep->mesh.ExtrudeMesh || !(ep->geo.Mode == COPIED_ENTITY) ){ Msg::Error("In MeshQuadToTriTopSurface(), incomplete or no " "extrude information for top face %d.", to->tag() ); return 0; } // is this a quadtri extrusion with added vertices? bool is_addverts = false; if( ep && (ep->mesh.QuadToTri == QUADTRI_ADDVERTS_1 || ep->mesh.QuadToTri == QUADTRI_ADDVERTS_1_RECOMB) ) is_addverts = true; // execute this section if // IF this is a 'no new vertices' quadToTri, mesh the surfaces according to this modified // least point value method: if a 3 boundary point quad, draw diagonals from middle corner toward // interior. If a a 2- or 1- point boundary quad, draw toward lowest pointer number NOT on boundary. // All interior quad, draw diagonal to vertex with lowest pointer number. if( !is_addverts ){ std::set<MVertex*, MVertexLessThanLexicographic> pos_src_edge; QuadToTriInsertFaceEdgeVertices(from, pos_src_edge); std::set<MVertex*, MVertexLessThanLexicographic>::iterator itp; // loop through each element source quadrangle and extrude for(unsigned int i = 0; i < from->quadrangles.size(); i++){ std::vector<MVertex*> verts; for(int j = 0; j < from->quadrangles[i]->getNumVertices(); j++){ MVertex *v = from->quadrangles[i]->getVertex(j); MVertex tmp(v->x(), v->y(), v->z(), 0, -1); ExtrudeParams *ep = to->meshAttributes.extrude; ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1], tmp.x(), tmp.y(), tmp.z()); itp = pos.find(&tmp); if(itp == pos.end()){ // FIXME: workaround Msg::Info("Linear search for (%.16g, %.16g, %.16g)", tmp.x(), tmp.y(), tmp.z()); itp = tmp.linearSearch(pos); } if(itp == pos.end()) { Msg::Error("In MeshQuadToTriTopSurface(), Could not find " "extruded vertex (%.16g, %.16g, %.16g) in surface %d", tmp.x(), tmp.y(), tmp.z(), to->tag()); to->triangles.reserve(to->triangles.size()+1); return 0; } verts.push_back(*itp); } if( verts.size() != 4 ){ Msg::Error("During mesh of QuadToTri surface %d, %d vertices found " "in quad of source surface %d.", to->tag(), verts.size(), from->tag() ); return 0; } // make the element MElement *element = from->quadrangles[i]; // count vertices that are on a boundary edge int edge_verts_count = 0; //int skip_index = 0; int bnd_indices[4]; for( int p = 0; p < element->getNumVertices(); p++ ){ if( pos_src_edge.find( element->getVertex(p) ) != pos_src_edge.end() ){ edge_verts_count++; bnd_indices[p] = 1; } else{ //skip_index = p; bnd_indices[p] = 0; } } // Apply modified lowest vertex pointer diagonalization int low_index = -1; if( edge_verts_count == 3 || edge_verts_count == 2 || edge_verts_count == 1 ){ for( int p = 0; p < 4; p++ ){ if( !bnd_indices[p] && verts[p] != element->getVertex(p) ){ if( low_index < 0 ) low_index = p; else if( verts[p] < verts[low_index] ) low_index = p; } } if( low_index < 0 ) // what if they are all degenerate? Avoid the out-of-bounds error. low_index = 0; } // lowest possible vertex pointer, regardless of if on edge or not else if( edge_verts_count == 4 || edge_verts_count == 0 ) low_index = getIndexForLowestVertexPointer(verts); addTriangle( verts[low_index],verts[(low_index+1)%verts.size()], verts[(low_index+2)%verts.size()],to); addTriangle( verts[low_index],verts[(low_index+2)%verts.size()], verts[(low_index+3)%verts.size()],to); } return 1; } // AFTER THIS POINT IN FUNCTION, CODE IS ALL FOR 'ADD INTERNAL VERTEX' EXTRUSIONS (Less restrictive). // if source face is unstructured, can try to make the top mesh a little neater GFace *root_source = findRootSourceFaceForFace( from ); ExtrudeParams *ep_src = root_source->meshAttributes.extrude; bool struct_root = false; if( root_source && ( (ep_src && ep_src->mesh.ExtrudeMesh && ep_src->geo.Mode == EXTRUDED_ENTITY) || root_source->meshAttributes.method == MESH_TRANSFINITE ) ) struct_root = true; if( !struct_root && MeshQuadToTriTopUnstructured(from, to, pos) ) return 1; // And top surface for the 'added internal vertex' method can be meshed quite easily else{ std::set<MVertex *, MVertexLessThanLexicographic >::iterator itp; // loop through each element source quadrangle and extrude for(unsigned int i = 0; i < from->quadrangles.size(); i++){ std::vector<MVertex*> verts; for(int j = 0; j < from->quadrangles[i]->getNumVertices(); j++){ MVertex *v = from->quadrangles[i]->getVertex(j); MVertex tmp(v->x(), v->y(), v->z(), 0, -1); ExtrudeParams *ep = to->meshAttributes.extrude; ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1], tmp.x(), tmp.y(), tmp.z()); itp = pos.find(&tmp); if(itp == pos.end()){ // FIXME: workaround Msg::Info("Linear search for (%.16g, %.16g, %.16g)", tmp.x(), tmp.y(), tmp.z()); itp = tmp.linearSearch(pos); } if(itp == pos.end()) { Msg::Error("In MeshQuadToTriTopSurface(), Could not find " "extruded vertex (%.16g, %.16g, %.16g) in surface %d", tmp.x(), tmp.y(), tmp.z(), to->tag()); to->triangles.reserve(to->triangles.size()+1); return 0; } verts.push_back(*itp); } if( verts.size() != 4 ){ Msg::Error("During mesh of QuadToTri surface %d, %d vertices found " "in quad of source surface %d.", to->tag(), verts.size(), from->tag() ); return 0; } // make the elements addTriangle( verts[0],verts[2], verts[3],to); addTriangle( verts[0],verts[1], verts[2],to); } return 1; } return 0; }
// Simple function taht helps with cutting down repetition bool inline inSet(const std::set<std::string>& a, const std::string& b) { return a.end() != a.find(b); }
void remove_function_pointerst::remove_function_pointer( goto_programt &goto_program, goto_programt::targett target) { const code_function_callt &code= to_code_function_call(target->code); const exprt &function=code.function(); // this better have the right type const code_typet &call_type=to_code_type(function.type()); assert(function.id()==ID_dereference); assert(function.operands().size()==1); const exprt &pointer=function.op0(); typedef std::list<exprt> functionst; functionst functions; // get all type-compatible functions // whose address is ever taken for(type_mapt::const_iterator f_it= type_map.begin(); f_it!=type_map.end(); f_it++) { // address taken? if(address_taken.find(f_it->first)==address_taken.end()) continue; // type-compatible? if(!is_type_compatible(call_type, f_it->second)) continue; symbol_exprt expr; expr.type()=f_it->second; expr.set_identifier(f_it->first); functions.push_back(expr); } // the final target is a skip goto_programt final_skip; goto_programt::targett t_final=final_skip.add_instruction(); t_final->make_skip(); // build the calls and gotos goto_programt new_code_calls; goto_programt new_code_gotos; for(functionst::const_iterator it=functions.begin(); it!=functions.end(); it++) { // call function goto_programt::targett t1=new_code_calls.add_instruction(); t1->make_function_call(code); to_code_function_call(t1->code).function()=*it; // the signature of the function might not match precisely fix_argument_types(to_code_function_call(t1->code)); fix_return_type(to_code_function_call(t1->code), new_code_calls); // goto final goto_programt::targett t3=new_code_calls.add_instruction(); t3->make_goto(t_final, true_exprt()); // goto to call address_of_exprt address_of; address_of.object()=*it; address_of.type()=pointer_typet(); address_of.type().subtype()=it->type(); if(address_of.type()!=pointer.type()) address_of.make_typecast(pointer.type()); goto_programt::targett t4=new_code_gotos.add_instruction(); t4->make_goto(t1, equal_exprt(pointer, address_of)); } // fall-through if(add_safety_assertion) { goto_programt::targett t=new_code_gotos.add_instruction(); t->make_assertion(false_exprt()); t->location.set(ID_property, "pointer dereference"); t->location.set(ID_comment, "invalid function pointer"); } goto_programt new_code; // patch them all together new_code.destructive_append(new_code_gotos); new_code.destructive_append(new_code_calls); new_code.destructive_append(final_skip); // set locations Forall_goto_program_instructions(it, new_code) { irep_idt property=it->location.get_property(); irep_idt comment=it->location.get_comment(); it->location=target->location; it->function=target->function; if(!property.empty()) it->location.set_property(property); if(!comment.empty()) it->location.set_comment(comment); }
bool find_sql_updates() { printf("+ finding new sql updates on HEAD\n"); // add all updates from HEAD snprintf(cmd, MAX_CMD, "git show HEAD:%s", sql_update_dir); if( (cmd_pipe = popen( cmd, "r" )) == NULL ) return false; // skip first two lines if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } sql_update_info info; while(fgets(buffer, MAX_BUF, cmd_pipe)) { buffer[strlen(buffer) - 1] = '\0'; if(!get_sql_update_info(buffer, info)) continue; if(info.db_idx == NUM_DATABASES) { if(info.rev > 0) printf("WARNING: incorrect database name for sql update %s\n", buffer); continue; } new_sql_updates.insert(buffer); } pclose(cmd_pipe); // remove updates from the last commit also found on origin snprintf(cmd, MAX_CMD, "git show %s:%s", origin_hash, sql_update_dir); if( (cmd_pipe = popen( cmd, "r" )) == NULL ) return false; // skip first two lines if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } while(fgets(buffer, MAX_BUF, cmd_pipe)) { buffer[strlen(buffer) - 1] = '\0'; if(!get_sql_update_info(buffer, info)) continue; // find the old update with the highest rev for each database // (will be the required version for the new update) std::set<std::string>::iterator itr = new_sql_updates.find(buffer); if(itr != new_sql_updates.end() ) { if(info.rev > 0 && (info.rev > last_sql_rev[info.db_idx] || (info.rev == last_sql_rev[info.db_idx] && info.nr > last_sql_nr[info.db_idx]))) { last_sql_rev[info.db_idx] = info.rev; last_sql_nr[info.db_idx] = info.nr; if(db_sql_rev_parent[info.db_idx]) snprintf(last_sql_update[info.db_idx], MAX_PATH, "%s_%0*d_%s%s%s", info.parentRev, 2, info.nr, info.db, info.has_table ? "_" : "", info.table); else sscanf(buffer, "%[^.]", last_sql_update[info.db_idx]); } new_sql_updates.erase(itr); } } pclose(cmd_pipe); if(!new_sql_updates.empty()) { for(std::set<std::string>::iterator itr = new_sql_updates.begin(); itr != new_sql_updates.end(); ++itr) printf("%s\n", itr->c_str()); } else printf("WARNING: no new sql updates found.\n"); return true; }
~Wall() { walls.erase(walls.find(this)); }
bool generate_sql_makefile() { if(new_sql_updates.empty()) return true; // find all files in the update dir snprintf(cmd, MAX_CMD, "git show HEAD:%s", sql_update_dir); if( (cmd_pipe = popen( cmd, "r" )) == NULL ) return false; // skip first two lines if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } char newname[MAX_PATH]; std::set<std::string> file_list; sql_update_info info; while(fgets(buffer, MAX_BUF, cmd_pipe)) { buffer[strlen(buffer) - 1] = '\0'; if(buffer[strlen(buffer) - 1] != '/' && strncmp(buffer, "Makefile.am", MAX_BUF) != 0) { if(new_sql_updates.find(buffer) != new_sql_updates.end()) { if(!get_sql_update_info(buffer, info)) return false; snprintf(newname, MAX_PATH, REV_PRINT "_%s_%0*d_%s%s%s.sql", rev, info.parentRev, 2, info.nr, info.db, info.has_table ? "_" : "", info.table); file_list.insert(newname); } else file_list.insert(buffer); } } pclose(cmd_pipe); // write the makefile char file_name[MAX_PATH]; snprintf(file_name, MAX_PATH, "%s%s/Makefile.am", path_prefix, sql_update_dir); FILE *fout = fopen(file_name, "w"); if(!fout) { pclose(cmd_pipe); return false; } fprintf(fout, "# Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>\n" "#\n" "# This program is free software; you can redistribute it and/or modify\n" "# it under the terms of the GNU General Public License as published by\n" "# the Free Software Foundation; either version 2 of the License, or\n" "# (at your option) any later version.\n" "#\n" "# This program is distributed in the hope that it will be useful,\n" "# but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "# GNU General Public License for more details.\n" "#\n" "# You should have received a copy of the GNU General Public License\n" "# along with this program; if not, write to the Free Software\n" "# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n" "\n" "## Process this file with automake to produce Makefile.in\n" "\n" "## Sub-directories to parse\n" "SUBDIRS = before_upgrade_to_0.13\n" "\n" "## Change installation location\n" "# datadir = mangos/%s\n" "pkgdatadir = $(datadir)/mangos/%s\n" "\n" "## Files to be installed\n" "# Install basic SQL files to datadir\n" "pkgdata_DATA = \\\n", sql_update_dir, sql_update_dir ); for(std::set<std::string>::iterator itr = file_list.begin(), next; itr != file_list.end(); ++itr) { next = itr; ++next; fprintf(fout, "\t%s%s\n", itr->c_str(), next == file_list.end() ? "" : " \\"); } fprintf(fout, "\n## Additional files to include when running 'make dist'\n" "# SQL update files, to upgrade database schema from older revisions\n" "EXTRA_DIST = \\\n" ); for(std::set<std::string>::iterator itr = file_list.begin(), next; itr != file_list.end(); ++itr) { next = itr; ++next; fprintf(fout, "\t%s%s\n", itr->c_str(), next == file_list.end() ? "" : " \\"); } fclose(fout); snprintf(cmd, MAX_CMD, "git add %s%s/Makefile.am", path_prefix, sql_update_dir); system_switch_index(cmd); return true; }
void ResumeMonitoringOnFile(const char* filepath){ auto it = mIgnoreFileChanges.find(filepath); if (it != mIgnoreFileChanges.end()) mIgnoreFileChanges.erase(it); }
bool is_member(T& element, std::set<T>& Set) { return (Set.find(element) != Set.end()); }
void ColorSpaceTransformOp::findConversion( const InputColorSpace &inputColorSpace, const OutputColorSpace &outputColorSpace, std::set< Conversion > &visitedConversions, std::vector< ConversionInfo > ¤tConversion, std::vector< ConversionInfo > &bestConversion ) { Conversion conversion( inputColorSpace, outputColorSpace ); /// Only proceed if we've not found a conversion yet, or if the conversion we're working on is likely to yield a better one than the best conversion found so far if ( ( bestConversion.size() > 0 ) && currentConversion.size() >= bestConversion.size() ) { return; } /// Prevent cycles and back-tracking if ( visitedConversions.find( conversion ) != visitedConversions.end() || visitedConversions.find( Conversion( outputColorSpace, inputColorSpace ) ) != visitedConversions.end()) { return; } /// Mark conversion as visited so we don't try it again visitedConversions.insert( conversion ); /// Find all converters which take our input color space ConvertersMap::const_iterator it = converters().find( inputColorSpace ); if ( it == converters().end() ) { return; } ConvertersMap::const_iterator end = converters().upper_bound( inputColorSpace ); /// For each of these converters, either see if we can directly convert to the output color space, or recurse to find a sub-chain which can convert to it, /// keeping track of the best conversion found so far (shorter chains are better). for (; it != end; ++it ) { ConversionInfo info = it->second; currentConversion.push_back( info ); if ( it->second.get<2>() == outputColorSpace ) { /// Termination condition bestConversion = currentConversion; currentConversion.pop_back(); return; } /// Recurse ConverterTypesMap::const_iterator cIt = converterTypes().find( it->second.get<0>() ); assert( cIt != converterTypes().end() ); findConversion( cIt->second.second, outputColorSpace, visitedConversions, currentConversion, bestConversion ); currentConversion.pop_back(); } }
void RubberBandStretcher::Impl::ChannelData::construct(const std::set<size_t> &windowSizes, size_t initialWindowSize, size_t outbufSize) { size_t maxSize = initialWindowSize; if (!windowSizes.empty()) { // std::set is ordered by value std::set<size_t>::const_iterator i = windowSizes.end(); maxSize = *--i; } if (windowSizes.find(initialWindowSize) == windowSizes.end()) { if (initialWindowSize > maxSize) maxSize = initialWindowSize; } // max size of the real "half" of freq data size_t realSize = (maxSize * oversample)/2 + 1; // std::cerr << "ChannelData::construct([" << windowSizes.size() << "], " << maxSize << ", " << outbufSize << ")" << std::endl; if (outbufSize < maxSize) outbufSize = maxSize; inbuf = new RingBuffer<float>(maxSize); outbuf = new RingBuffer<float>(outbufSize); mag = allocDouble(realSize); phase = allocDouble(realSize); prevPhase = allocDouble(realSize); prevError = allocDouble(realSize); unwrappedPhase = allocDouble(realSize); envelope = allocDouble(realSize); freqPeak = new size_t[realSize]; fltbuf = allocFloat(maxSize); accumulator = allocFloat(maxSize); windowAccumulator = allocFloat(maxSize); for (std::set<size_t>::const_iterator i = windowSizes.begin(); i != windowSizes.end(); ++i) { ffts[*i] = new FFT(*i * oversample); ffts[*i]->initDouble(); } if (windowSizes.find(initialWindowSize) == windowSizes.end()) { ffts[initialWindowSize] = new FFT(initialWindowSize * oversample); ffts[initialWindowSize]->initDouble(); } fft = ffts[initialWindowSize]; dblbuf = fft->getDoubleTimeBuffer(); resampler = 0; resamplebuf = 0; resamplebufSize = 0; reset(); for (size_t i = 0; i < realSize; ++i) { freqPeak[i] = 0; } for (size_t i = 0; i < initialWindowSize * oversample; ++i) { dblbuf[i] = 0.0; } for (size_t i = 0; i < maxSize; ++i) { accumulator[i] = 0.f; windowAccumulator[i] = 0.f; } // Avoid dividing opening sample (which will be discarded anyway) by zero windowAccumulator[0] = 1.f; }
void UserObjectWarehouse::updateDependObjects(const std::set<std::string> & depend_uo) { // Bin the user objects into either Pre or Post AuxKernel bins for (std::map<SubdomainID, std::vector<ElementUserObject *> >::iterator it1 = _block_element_user_objects.begin(); it1 != _block_element_user_objects.end(); ++it1) { _pre_element_user_objects[it1->first].clear(); _post_element_user_objects[it1->first].clear(); for (std::vector<ElementUserObject *>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { if (depend_uo.find((*it2)->name()) != depend_uo.end()) _pre_element_user_objects[it1->first].push_back(*it2); else _post_element_user_objects[it1->first].push_back(*it2); } } for (std::map<BoundaryID, std::vector<SideUserObject *> >::iterator it1 = _boundary_side_user_objects.begin(); it1 != _boundary_side_user_objects.end(); ++it1) { _pre_side_user_objects[it1->first].clear(); _post_side_user_objects[it1->first].clear(); for (std::vector<SideUserObject *>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { if (depend_uo.find((*it2)->name()) != depend_uo.end()) _pre_side_user_objects[it1->first].push_back(*it2); else _post_side_user_objects[it1->first].push_back(*it2); } } _pre_internal_side_user_objects.clear(); _post_internal_side_user_objects.clear(); for (std::map<SubdomainID, std::vector<InternalSideUserObject *> >::iterator it1 = _block_internal_side_user_objects.begin(); it1 != _block_internal_side_user_objects.end(); ++it1) { _pre_internal_side_user_objects[it1->first].clear(); _post_internal_side_user_objects[it1->first].clear(); for (std::vector<InternalSideUserObject *>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { if (depend_uo.find((*it2)->name()) != depend_uo.end()) _pre_internal_side_user_objects[it1->first].push_back(*it2); else _post_internal_side_user_objects[it1->first].push_back(*it2); } } for (std::map<BoundaryID, std::vector<NodalUserObject *> >::iterator it1 = _boundary_nodal_user_objects.begin(); it1 != _boundary_nodal_user_objects.end(); ++it1) { _pre_nodal_user_objects[it1->first].clear(); _post_nodal_user_objects[it1->first].clear(); for (std::vector<NodalUserObject *>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { if (depend_uo.find((*it2)->name()) != depend_uo.end()) _pre_nodal_user_objects[it1->first].push_back(*it2); else _post_nodal_user_objects[it1->first].push_back(*it2); } } for (std::map<SubdomainID, std::vector<NodalUserObject *> >::iterator it1 = _block_nodal_user_objects.begin(); it1 != _block_nodal_user_objects.end(); ++it1) { _pre_block_nodal_user_objects[it1->first].clear(); _post_block_nodal_user_objects[it1->first].clear(); for (std::vector<NodalUserObject *>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { if (depend_uo.find((*it2)->name()) != depend_uo.end()) _pre_block_nodal_user_objects[it1->first].push_back(*it2); else _post_block_nodal_user_objects[it1->first].push_back(*it2); } } // Sort the General UserObjects sortUserObjects(_all_generic_user_objects); _pre_generic_user_objects.clear(); _post_generic_user_objects.clear(); for (std::vector<GeneralUserObject *>::iterator it2 = _all_generic_user_objects.begin(); it2 != _all_generic_user_objects.end(); ++it2) { if (depend_uo.find((*it2)->name()) != depend_uo.end()) _pre_generic_user_objects.push_back(*it2); else _post_generic_user_objects.push_back(*it2); } }
BOOL LLWindowManager::isWindowValid(LLWindow *window) { return sWindowList.find(window) != sWindowList.end(); }
std::vector<ClassManager::ClassConnection> ClassManager::GetConnections(const string& type, const string& namespaceId, const std::set<string>& ids, EProtectionLevel protLevel, bool Virtual) const { std::vector<ClassConnection> result; ClassConnection connection; connection.Virtual = Virtual; connection.protectionLevel = protLevel; switch (protLevel) { case PRIVATE: connection.connectionCode = _T("private "); break; case PROTECTED: connection.connectionCode = _T("protected "); break; case PUBLIC: connection.connectionCode = _T("public "); break; } if (Virtual) { connection.connectionCode = _T("virtual "); } connection.connectionCode += type; const std::size_t templateDelimiter = type.find_first_of(_T('<')); string directType = (templateDelimiter == string::npos) ? type : type.substr(0, templateDelimiter); string indirectTypes = (templateDelimiter == string::npos) ? string() : type.substr(templateDelimiter + 1); connection.type = DIRECT_INHERITANCE; for (const auto& defItem: split(directType, _T(" \t&*"))) { if (ids.find(defItem) != ids.end()) { connection.targetId = defItem; result.push_back(connection); } else { string namespaceStr = namespaceId; while(!namespaceStr.empty()) { if (ids.find(namespaceStr + _T("::") + defItem) != ids.end()) { connection.targetId = namespaceStr + _T("::") + defItem; result.push_back(connection); break; } const std::size_t pos = namespaceStr.rfind(_T("::")); if (pos == string::npos) break; namespaceStr = namespaceStr.substr(0, pos); } } } connection.type = INDIRECT_INHERITANCE; for (const auto& defItem: split(indirectTypes, _T(",<> \t&*"))) { if (ids.find(defItem) != ids.end()) { connection.targetId = defItem; result.push_back(connection); } else { string namespaceStr = namespaceId; while(!namespaceStr.empty()) { if (ids.find(namespaceStr + _T("::") + defItem) != ids.end()) { connection.targetId = namespaceStr + _T("::") + defItem; result.push_back(connection); break; } const std::size_t pos = namespaceStr.rfind(_T("::")); if (pos == string::npos) break; namespaceStr = namespaceStr.substr(0, pos); } } } return result; }
// this function specifically meshes a quadToTri top in an unstructured way // return 1 if success, return 0 if failed. // Added 2010-12-20 static int MeshQuadToTriTopUnstructured(GFace *from, GFace *to, std::set<MVertex*, MVertexLessThanLexicographic> &pos) { // if the source is all triangles, then just return 1. if( from->triangles.size() && !from->quadrangles.size() ) return 1; if( !to->meshAttributes.extrude || !to->meshAttributes.extrude->mesh.QuadToTri ) return 0; // in weird case of NO quads and NO tri if( !from->triangles.size() && !from->quadrangles.size() ) return 0; // make set of source edge vertices std::set<MVertex*, MVertexLessThanLexicographic> pos_src_edge; QuadToTriInsertFaceEdgeVertices(from, pos_src_edge); // Loop through all the quads and make the triangles with diagonals running // in a selected direction. to->triangles.reserve(to->triangles.size()+from->quadrangles.size()*2); std::set<MVertex*, MVertexLessThanLexicographic>::iterator itp; for(unsigned int i = 0; i < from->quadrangles.size(); i++){ std::vector<MVertex*> verts; for(int j = 0; j < from->quadrangles[i]->getNumVertices(); j++){ MVertex *v = from->quadrangles[i]->getVertex(j); MVertex tmp(v->x(), v->y(), v->z(), 0, -1); ExtrudeParams *ep = to->meshAttributes.extrude; ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1], tmp.x(), tmp.y(), tmp.z()); itp = pos.find(&tmp); if(itp == pos.end()){ // FIXME: workaround Msg::Info("Linear search for (%.16g, %.16g, %.16g)", tmp.x(), tmp.y(), tmp.z()); itp = tmp.linearSearch(pos); } if(itp == pos.end()) { Msg::Error("Could not find extruded vertex (%.16g, %.16g, %.16g) in surface %d", tmp.x(), tmp.y(), tmp.z(), to->tag()); to->triangles.reserve(to->triangles.size()+1); return 0; } verts.push_back(*itp); } if( verts.size() != 4 ){ Msg::Error("During mesh of QuadToTri surface %d, %d vertices found " "in quad of source surface %d.", to->tag(), verts.size(), from->tag() ); return 0; } // draw other diagonals to minimize difference in average edge length with diagonal length, in quadrature double mag_sq_ave = 0.0; for( int p = 0; p < 4; p++ ){ int d_leg = verts[p]->distance(verts[(p+1)%4]); mag_sq_ave += d_leg*d_leg; } mag_sq_ave /= 4; double d1 = verts[0]->distance(verts[2]); double d2 = verts[1]->distance(verts[3]); if(fabs(d1*d1-mag_sq_ave) <= fabs(d2*d2-mag_sq_ave) ){ addTriangle(verts[0],verts[1],verts[2],to); addTriangle(verts[0],verts[2],verts[3],to); } else{ addTriangle(verts[1],verts[2],verts[3],to); addTriangle(verts[1],verts[3],verts[0],to); } } return 1; }
int add_mic_status( std::vector<std::string> &status) { uint32_t num_engines = 0; uint32_t i = 0; #ifdef NUMA_SUPPORT /* does this node board have mics configured? */ if (node_boards[numa_index].mic_end_index < 0) return(PBSE_NONE); #endif if (COIEngineGetCount(COI_ISA_MIC, &num_engines) != COI_SUCCESS) { log_err(-1, __func__, "Mics are present but apparently not configured correctly - can't get count"); return(PBSE_SYSTEM); } status.push_back(START_MIC_STATUS); #ifdef NUMA_SUPPORT if (num_engines < node_boards[numa_index].mic_end_index) { snprintf(log_buffer, sizeof(log_buffer), "node board %d is supposed to have mic range %d-%d but there are only %d mics", numa_index, node_boards[numa_index].mic_start_index, node_boards[numa_index].mic_end_index, num_engines); log_err(-1, __func__, log_buffer); return(PBSE_SYSTEM); } for (i = node_boards[numa_index].mic_start_index; i <= node_boards[numa_index].mic_end_index; i++) #else for (i = 0; i < num_engines; i++) #endif { COIENGINE engine; struct COI_ENGINE_INFO mic_stat; memset(&engine, 0, sizeof(engine)); memset(&mic_stat, 0, sizeof(mic_stat)); if (COIEngineGetHandle(COI_ISA_MIC, i, &engine) != COI_SUCCESS) { if (down_mics.find(i) == down_mics.end()) { snprintf(log_buffer, sizeof(log_buffer), "Can't get handle for mic index %d", (int)i); log_event(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, __func__, log_buffer); down_mics.insert(i); } continue; } if (COIEngineGetInfo(engine, sizeof(struct COI_ENGINE_INFO), &mic_stat) != COI_SUCCESS) { snprintf(log_buffer, sizeof(log_buffer), "Can't get information for mic index %d", (int)i); log_err(-1, __func__, log_buffer); continue; } add_single_mic_info(status, &mic_stat); } status.push_back(END_MIC_STATUS); return(PBSE_NONE); } /* END add_mic_status() */
void DoCommands(const ConfigParameters& config, const shared_ptr<MPIWrapper>& mpi) { ConfigArray command = config(L"command", "train"); if (Globals::ShouldForceDeterministicAlgorithms()) ForceDeterministicAlgorithmsOnCPU(); else { // Setting specified number of threads. int numCPUThreads = config(L"numCPUThreads", "0"); numCPUThreads = CPUMatrix<ElemType>::SetNumThreads(numCPUThreads); if (numCPUThreads > 0) { LOGPRINTF(stderr, "Using %d CPU threads.\n", numCPUThreads); } } bool progressTracing = config(L"progressTracing", false); // temporary hack to prevent users from failing due to a small breaking change related to the "truncated" flag (will be redone bigger and better some day) DisableLegacyUsage(config, command); // summarize command info upfront in the log and stdout size_t fullTotalMaxEpochs = 0; for (int i = 0; i < command.size(); i++) { // get the configuration parameters that match the command ConfigParameters commandParams(config(command[i])); ConfigArray action = commandParams("action", "train"); // determine the action to perform, and do it for (int j = 0; j < action.size(); j++) { if (action[j] == "train" || action[j] == "trainRNN") { wstring modelPath = commandParams("modelPath"); size_t maxEpochs = GetMaxEpochs(commandParams); if (progressTracing) { LOGPRINTF(stderr, "CNTKModelPath: %ls\n", modelPath.c_str()); LOGPRINTF(stderr, "CNTKCommandTrainInfo: %s : %d\n", command[i].c_str(), (int)maxEpochs); } fullTotalMaxEpochs += maxEpochs; } } } if (progressTracing) { LOGPRINTF(stderr, "CNTKCommandTrainInfo: CNTKNoMoreCommands_Total : %d\n", (int)fullTotalMaxEpochs); } // set up progress tracing for compute cluster management if (progressTracing && (!mpi || mpi->IsMainNode())) { ProgressTracing::SetTracingFlag(); ProgressTracing::TraceTotalNumberOfSteps(fullTotalMaxEpochs); // enable tracing, using this as the total number of epochs } size_t fullEpochsOffset = 0; // execute the commands for (int i = 0; i < command.size(); i++) { // get the configuration parameters that match the command const string thisCommand = command[i]; ConfigParameters commandParams(config(thisCommand)); ConfigArray action = commandParams("action", "train"); int traceLevel = commandParams("traceLevel", "0"); if (progressTracing && ((mpi == nullptr) || mpi->IsMainNode())) { ProgressTracing::SetStepOffset(fullEpochsOffset); // this is the epoch number that SGD will log relative to } // determine the action to perform, and do it for (int j = 0; j < action.size(); j++) { const string thisAction = action[j]; // print a banner to visually separate each action in the log const char* delim = "##############################################################################"; string showActionAs = thisCommand + " command (" + thisAction + " action)"; fprintf(stderr, "\n"); LOGPRINTF(stderr, "%s\n", delim); LOGPRINTF(stderr, "#%*s#\n", (int)(strlen(delim) - 2), ""); LOGPRINTF(stderr, "# %s%*s #\n", showActionAs.c_str(), (int)(strlen(delim) - showActionAs.size() - 4), ""); LOGPRINTF(stderr, "#%*s#\n", (int)(strlen(delim) - 2), ""); LOGPRINTF(stderr, "%s\n\n", delim); if ((mpi == nullptr) || (commandstoRunOnAllRanks.find(thisAction) != commandstoRunOnAllRanks.end()) || mpi->IsMainNode()) { if (thisAction == "train" || thisAction == "trainRNN") { if (progressTracing) { LOGPRINTF(stderr, "CNTKCommandTrainBegin: %s\n", command[i].c_str()); } DoTrain<ConfigParameters, ElemType>(commandParams); if (progressTracing) { LOGPRINTF(stderr, "CNTKCommandTrainEnd: %s\n", command[i].c_str()); } fullEpochsOffset += GetMaxEpochs(commandParams); } else if (thisAction == "bnstat") { DoBatchNormalizationStat<ElemType>(commandParams); } else if (thisAction == "adapt") { DoAdapt<ElemType>(commandParams); } else if (thisAction == "test" || thisAction == "eval") { DoEval<ElemType>(commandParams); } else if (thisAction == "edit") { DoEdit<ElemType>(commandParams); } else if (thisAction == "cv") { DoCrossValidate<ElemType>(commandParams); } else if (thisAction == "write") { DoWriteOutput<ElemType>(commandParams); } else if (thisAction == "devtest") { TestCn<ElemType>(config); // for "devtest" action pass the root config instead } else if (thisAction == "dumpNodes" /*deprecated:*/ || thisAction == "dumpNode" || thisAction == "dumpnode") { DoDumpNodes<ElemType>(commandParams); } else if (thisAction == "convertdbn") { DoConvertFromDbn<ElemType>(commandParams); } else if (thisAction == "exportdbn") { DoExportToDbn<ElemType>(commandParams); } else if (thisAction == "createLabelMap") { DoCreateLabelMap<ElemType>(commandParams); } else if (thisAction == "writeWordAndClass") { DoWriteWordAndClassInfo<ElemType>(commandParams); } else if (thisAction == "plot") { DoTopologyPlot<ElemType>(commandParams); } else if (thisAction == "SVD") { DoParameterSVD<ElemType>(commandParams); } else { RuntimeError("unknown action: %s in command set: %s", thisAction.c_str(), command[i].c_str()); } } fprintf(stderr, "\n"); if (traceLevel > 0) { LOGPRINTF(stderr, "Action \"%s\" complete.\n\n", thisAction.c_str()); } NDLScript<ElemType> ndlScript; ndlScript.ClearGlobal(); // clear global macros between commands // Synchronize all ranks before proceeding to next action/command if (mpi) mpi->WaitAll(); } } }