extern "C" void cfn_(const fint *N, const fint *M, const freal *X, freal *F, const fint *LC, freal *C) { cfn(N, M, X, F, LC, C); }
ERRORCODE CDCache::cache_font(LPCSTR name) { ERRORCODE error; /* If we don't have a database, we don't have anything. */ if (m_database == NULL) { return ERRORCODE_NotInitialized; } TRY { m_database->set_maximum_size(m_cache_size = GET_PMWAPP()->get_workspace_size()); } CATCH_ALL(e) { } END_CATCH_ALL CompositeFileName cfn(name); /* Store the file in the database (if not already there). */ AfxGetApp()->BeginWaitCursor(); error = m_database->add_file(cfn.get_dynamic_name(TRUE), CACHE_FILE_TYPE_Font); AfxGetApp()->EndWaitCursor(); return error; }
ERRORCODE CDCache::prep_font_file(LPCSTR name, StorageFilePtr file) { /* If we don't have a database, we don't have anything. */ if (m_database == NULL) { return ERRORCODE_NotInitialized; } CompositeFileName cfn(name); /* Let the database prep the file. */ return m_database->prep_file(cfn.get_dynamic_name(TRUE), CACHE_FILE_TYPE_Font, file); }
void CallGraph::LogFn(wxString s) { return; // (log disabled) FileLogger::Get()->AddLogLine(wxString("> ") + s, FileLogger::Dbg); // on-demand log file creation if (nil == m_LogFile) { wxFileName cfn(wxGetenv("HOME"), "callgraph.log"); wxASSERT(cfn.IsOk()); m_LogFile = new wxFileOutputStream(cfn.GetFullPath()); } wxTextOutputStream tos(*m_LogFile); tos << s << "\n"; // cerr ends up in ~/xsesssion-errors ??? // cout goes nowhere? // std::cout << s << "\n"; ::wxPrintf("%s\n", s); }
static void CVBBDDQJac(CVBBDPrecData pdata, realtype t, N_Vector y, N_Vector gy, N_Vector ytemp, N_Vector gtemp) { CVodeMem cv_mem; realtype gnorm, minInc, inc, inc_inv; long int group, i, j, width, ngroups, i1, i2; realtype *y_data, *ewt_data, *gy_data, *gtemp_data, *ytemp_data, *col_j; cv_mem = (CVodeMem) pdata->cvode_mem; /* Load ytemp with y = predicted solution vector */ N_VScale(ONE, y, ytemp); /* Call cfn and gloc to get base value of g(t,y) */ if (cfn != NULL) cfn (Nlocal, t, y, f_data); gloc(Nlocal, t, ytemp, gy, f_data); /* Obtain pointers to the data for various vectors */ y_data = N_VGetArrayPointer(y); gy_data = N_VGetArrayPointer(gy); ewt_data = N_VGetArrayPointer(ewt); ytemp_data = N_VGetArrayPointer(ytemp); gtemp_data = N_VGetArrayPointer(gtemp); /* Set minimum increment based on uround and norm of g */ gnorm = N_VWrmsNorm(gy, ewt); minInc = (gnorm != ZERO) ? (MIN_INC_MULT * ABS(h) * uround * Nlocal * gnorm) : ONE; /* Set bandwidth and number of column groups for band differencing */ width = mldq + mudq + 1; ngroups = MIN(width, Nlocal); /* Loop over groups */ for (group=1; group <= ngroups; group++) { /* Increment all y_j in group */ for(j=group-1; j < Nlocal; j+=width) { inc = MAX(dqrely*ABS(y_data[j]), minInc/ewt_data[j]); ytemp_data[j] += inc; } /* Evaluate g with incremented y */ gloc(Nlocal, t, ytemp, gtemp, f_data); /* Restore ytemp, then form and load difference quotients */ for (j=group-1; j < Nlocal; j+=width) { ytemp_data[j] = y_data[j]; col_j = BAND_COL(savedJ,j); inc = MAX(dqrely*ABS(y_data[j]), minInc/ewt_data[j]); inc_inv = ONE/inc; i1 = MAX(0, j-mukeep); i2 = MIN(j+mlkeep, Nlocal-1); for (i=i1; i <= i2; i++) BAND_COL_ELEM(col_j,i,j) = inc_inv * (gtemp_data[i] - gy_data[i]); } } }
static int cpBBDDQJacImpl(CPBBDPrecData pdata, realtype t, realtype gamma, N_Vector y, N_Vector yp, N_Vector gref, N_Vector ytemp, N_Vector yptemp, N_Vector gtemp) { CPodeMem cp_mem; realtype inc, inc_inv; int retval; int group, i, j, width, ngroups, i1, i2; realtype *ydata, *ypdata, *ytempdata, *yptempdata, *grefdata, *gtempdata; realtype *ewtdata; realtype *col_j, yj, ypj, ewtj; cp_mem = (CPodeMem) pdata->cpode_mem; /* Initialize ytemp and yptemp. */ N_VScale(ONE, y, ytemp); N_VScale(ONE, yp, yptemp); /* Obtain pointers as required to the data array of vectors. */ ydata = N_VGetArrayPointer(y); ypdata = N_VGetArrayPointer(yp); gtempdata = N_VGetArrayPointer(gtemp); ewtdata = N_VGetArrayPointer(ewt); ytempdata = N_VGetArrayPointer(ytemp); yptempdata= N_VGetArrayPointer(yptemp); grefdata = N_VGetArrayPointer(gref); /* Call cfn and glocI to get base value of G(t,y,y'). */ if (cfn != NULL) { retval = cfn(Nlocal, t, y, yp, f_data); if (retval != 0) return(retval); } retval = glocI(Nlocal, t, y, yp, gref, f_data); nge++; if (retval != 0) return(retval); /* Set bandwidth and number of column groups for band differencing. */ width = mldq + mudq + 1; ngroups = MIN(width, Nlocal); /* Loop over groups. */ for(group = 1; group <= ngroups; group++) { /* Loop over the components in this group. */ for(j = group-1; j < Nlocal; j += width) { yj = ydata[j]; ypj = ypdata[j]; ewtj = ewtdata[j]; /* Set increment inc to yj based on rel_yy*abs(yj), with adjustments using ypj and ewtj if this is small, and a further adjustment to give it the same sign as hh*ypj. */ inc = dqrely*MAX(ABS(yj), MAX( ABS(h*ypj), ONE/ewtj)); if (h*ypj < ZERO) inc = -inc; inc = (yj + inc) - yj; /* Increment yj and ypj. */ ytempdata[j] += gamma*inc; yptempdata[j] += inc; } /* Evaluate G with incremented y and yp arguments. */ retval = glocI(Nlocal, t, ytemp, yptemp, gtemp, f_data); nge++; if (retval != 0) return(retval); /* Loop over components of the group again; restore ytemp and yptemp. */ for(j = group-1; j < Nlocal; j += width) { yj = ytempdata[j] = ydata[j]; ypj = yptempdata[j] = ypdata[j]; ewtj = ewtdata[j]; /* Set increment inc as before .*/ inc = dqrely*MAX(ABS(yj), MAX( ABS(h*ypj), ONE/ewtj)); if (h*ypj < ZERO) inc = -inc; inc = (yj + inc) - yj; /* Form difference quotients and load into savedP. */ inc_inv = ONE/inc; col_j = BAND_COL(savedP,j); i1 = MAX(0, j-mukeep); i2 = MIN(j+mlkeep, Nlocal-1); for(i = i1; i <= i2; i++) BAND_COL_ELEM(col_j,i,j) = inc_inv * (gtempdata[i] - grefdata[i]); } } return(0); }
void CallGraph::OnShowCallGraph(wxCommandEvent& event) { // myLog("wxThread::IsMain(%d)", (int)wxThread::IsMain()); IConfigTool *config_tool = m_mgr->GetConfigTool(); config_tool->ReadObject(wxT("CallGraph"), &confData); if (!wxFileExists(GetGprofPath()) || !wxFileExists(GetDotPath())) return MessageBox(_T("Failed to locate required tools (gprof, dot). Please check the plugin settings."), wxICON_ERROR); Workspace *ws = m_mgr->GetWorkspace(); if (!ws) return MessageBox(_("Unable to get opened workspace."), wxICON_ERROR); wxFileName ws_cfn = ws->GetWorkspaceFileName(); wxString projectName = ws->GetActiveProjectName(); BuildMatrixPtr mtx = ws->GetBuildMatrix(); if (!mtx) return MessageBox(_("Unable to get current build matrix."), wxICON_ERROR); wxString build_config_name = mtx->GetSelectedConfigurationName(); BuildConfigPtr bldConf = ws->GetProjBuildConf(projectName, build_config_name); if (!bldConf) return MessageBox(_("Unable to get opened workspace."), wxICON_ERROR); wxString projOutputFn = bldConf->GetOutputFileName(); wxString projWorkingDir = bldConf->GetWorkingDirectory(); /* myLog("WorkspaceFileName = \"%s\"", ws_cfn.GetFullPath()); myLog("projectName \"%s\"", projectName); myLog("build_config_name = \"%s\"", build_config_name); myLog("projOutputFn = \"%s\"", projOutputFn); myLog("projWorkingDir = \"%s\"", projWorkingDir); */ wxFileName cfn(ws_cfn.GetPath(), projOutputFn); cfn.Normalize(); // base path const wxString base_path = ws_cfn.GetPath(); // check source binary exists wxString bin_fpath = cfn.GetFullPath(); if (!cfn.Exists()) { bin_fpath = wxFileSelector("Please select the binary to analyze", base_path, "", ""); if (bin_fpath.IsEmpty()) return MessageBox("selected binary was canceled", wxICON_ERROR); cfn.Assign(bin_fpath, wxPATH_NATIVE); } if (!cfn.IsFileExecutable()) return MessageBox("bin/exe isn't executable", wxICON_ERROR); // check 'gmon.out' file exists wxFileName gmon_cfn(base_path, GMON_FILENAME_OUT); if (!gmon_cfn.Exists()) gmon_cfn.Normalize(); wxString gmonfn = gmon_cfn.GetFullPath(); if (!gmon_cfn.Exists()) { gmonfn = wxFileSelector("Please select the gprof file", gmon_cfn.GetPath(), "gmon", "out"); if (gmonfn.IsEmpty()) return MessageBox("selected gprof was canceled", wxICON_ERROR); gmon_cfn.Assign(gmonfn, wxPATH_NATIVE); } wxString bin, arg1, arg2; bin = GetGprofPath(); arg1 = bin_fpath; arg2 = gmonfn; wxString cmdgprof = wxString::Format("%s %s %s", bin, arg1, arg2); // myLog("about to wxExecute(\"%s\")", cmdgprof); wxProcess *proc = new wxProcess(wxPROCESS_REDIRECT); // wxStopWatch sw; const int err = ::wxExecute(cmdgprof, wxEXEC_SYNC, proc); // on sync returns 0 (success), -1 (failure / "couldn't be started") // myLog("wxExecute() returned err %d, had pid %d", err, (int)proc->GetPid()); wxInputStream *process_is = proc->GetInputStream(); if (!process_is || !process_is->CanRead()) return MessageBox(_("wxProcess::GetInputStream() can't be opened, aborting"), wxICON_ERROR); // start parsing and writing to dot language file GprofParser pgp; pgp.GprofParserStream(process_is); // myLog("gprof done (read %d lines)", (int) pgp.lines.GetCount()); delete proc; ConfCallGraph conf; config_tool->ReadObject(wxT("CallGraph"), &conf); DotWriter dotWriter; // DotWriter dotWriter.SetLineParser(&(pgp.lines)); int suggestedThreshold = pgp.GetSuggestedNodeThreshold(); if (suggestedThreshold <= conf.GetTresholdNode()) { suggestedThreshold = conf.GetTresholdNode(); dotWriter.SetDotWriterFromDialogSettings(m_mgr); } else { dotWriter.SetDotWriterFromDetails(conf.GetColorsNode(), conf.GetColorsEdge(), suggestedThreshold, conf.GetTresholdEdge(), conf.GetHideParams(), conf.GetStripParams(), conf.GetHideNamespaces()); wxString suggest_msg = wxString::Format(_("The CallGraph plugin has suggested node threshold %d to speed-up the call graph creation. You can alter it on the call graph panel."), suggestedThreshold); MessageBox(suggest_msg, wxICON_INFORMATION); } dotWriter.WriteToDotLanguage(); // build output dir cfn.Assign(base_path, ""); cfn.AppendDir(CALLGRAPH_DIR); cfn.Normalize(); if (!cfn.DirExists()) cfn.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); cfn.SetFullName(DOT_FILENAME_TXT); wxString dot_fn = cfn.GetFullPath(); dotWriter.SendToDotAppOutputDirectory(dot_fn); cfn.SetFullName(DOT_FILENAME_PNG); wxString output_png_fn = cfn.GetFullPath(); // delete any existing PNG if (wxFileExists(output_png_fn)) wxRemoveFile(output_png_fn); wxString cmddot_ln; cmddot_ln << GetDotPath() << " -Tpng -o" << output_png_fn << " " << dot_fn; // myLog("wxExecute(\"%s\")", cmddot_ln); wxExecute(cmddot_ln, wxEXEC_SYNC); // myLog("dot done"); if (!wxFileExists(output_png_fn)) return MessageBox(_("Failed to open file CallGraph.png. Please check the project settings, rebuild the project and try again."), wxICON_INFORMATION); // show image and create table in the editor tab page uicallgraphpanel *panel = new uicallgraphpanel(m_mgr->GetEditorPaneNotebook(), m_mgr, output_png_fn, base_path, suggestedThreshold, &(pgp.lines)); wxString tstamp = wxDateTime::Now().Format(wxT(" %Y-%m-%d %H:%M:%S")); wxString title = wxT("Call graph for \"") + output_png_fn + wxT("\" " + tstamp); m_mgr->AddEditorPage(panel, title); }
void Directory::GetFileList(StringVector& arr, bool listOnlyFiles) { CollectFileNames cfn(arr); Scan(&cfn, listOnlyFiles ? "*.*" : StringUtils::Null, false); }