I have a program very basic with just functions and variables and performs some calculations. The build part is fine. there is only cout, adding, multiplying etc very elementary stuff.
On linux, program runs fine on eclipse cdt, (runs in about 3-4 seconds)
When the program runs on windows 7 on visual studio 2010 c++, took 163 seconds when the program runs on windows 7 eclipse c++ with MinGW, alot
What is going on here??!!?!
EDIT: lets not call it c++, its just alot of C functions here, here is the code from the main()
foutput1 = fopen(FILENAME1, "w");
foutput2 = fopen(FILENAME2, "w");
solveSystem();
OutputStepToFile();
iter++;
do
{
temporalExternalChange(tim);
do
{
solveSystem();
iter++;
} while (iter<T_FOUT);
iter = 0;
OutputStepToFile();
tim+=dt*T_FOUT;
if (fmod(tim,T_PRINT)<=0.0){cout << "\nt=" << tim << "ms";};
} while(tim<T_TOTAL);
SolveSystem() is the following (partial) which just functions that do calculations to some variables:
void solveSystem()
{
fsGCcGMPformation(); // !cGMP formation
falp1AdAct_IP3form(); // !Norepinephrine receptor
fIVoCC(); // !Voltage dependent calcium current I_CaL
fIKv(); // !Delayed rectifier current I_K
fIBKCa(); // !Calcium-activated potassium
...
...
...
fVoltageChange();
performODEstep();
}
OutputStepToFile() function is simply using C style file output
void OutputStepToFile()
{
fprintf(foutput1,"%g %g %g %g %g %g %g %g ",V_m, tim, Ca_i, Na_i, K_i, Cl_i, Ca_u, Ca_r); // 1
fprintf(foutput1,"%g %g %g %g %g %g %g ",d_L, f_L, BKCa_a, KvD_a, KvD_i_slow, KvD_i_fast, KCNQ_a); // 8
fprintf(foutput1,"%g %g %g %g ",P_SOC, R_01, R_10, R_11); // 15
fprintf(foutput1,"%g %g %g %g %g %g %g %g %g\n", h_IP3, RS_G, RS_PG, G, IP3, PIP2, DAG, V_cGMP, cGMP); // 22
// Store Ca,K,Cl,Na ion channels
fprintf(foutput2,"%g %g %g %g %g %g %g %g %g ", I_CaL, I_CaT, I_BKCa, I_KvD, I_KCNQ, I_K2P, I_Kir, I_KATP, I_CaCC);
// Store ROCs/SOCs
fprintf(foutput2,"%g %g %g %g %g %g %g ", INa_NSC, IK_NSC, ICa_NSC, I_NSC, I_SOCNa, I_SOCCa, I_SOC);
// store SR dynamic currents, co-transporters, pumps and exchangers
fprintf(foutput2,"%g %g %g %g %g %g %g %g ", I_up, I_tr, I_rel, I_IP3, I_PMCA, I_NaK, I_NCX, I_NaKCl_Cl);
fprintf(foutput2,"%g %g %g %g %g %g\n", I_stim, V_cGMPbar, I_Catotm, I_Natotm, I_Cltotm, I_Ktotm);
}
The only reliable way to find out where your program is spending all that time is to profile it. That would show you the time spent in each method/function and you should be able to track down the delay. If you cannot use a profiler for some reason, you might just try inserting a few timing calls in critical stages of your code to isolate the location of the problem.
That said, my guess would be on the I/O part of your program (cout
, printf
...). The calculations should compile to similar code on both architectures and, unless your are using external libraries, they should not be affected by the porting process. The I/O calls, on the other hand, could be affected by differences in the standard library and in how each OS handles buffering and I/O in general. Conceivably, there might also be some library function that is not well implemented on Windows.
An important piece of information would be how your program is behaving during those 160+ seconds. Is it burning the CPU at 100%, or is it idling waiting for something to happen?