c++ - pthread multithreading in Mac OS vs windows multithreaing -


i've developed multi platform program (using fltk toolkit) , implement multithreading background intensive tasks.

i have followed fltk tutorials/examples on multithreading involve using pthread on mac, ie function pthread_create , windows threading on windows ie _beginthread

what have noticed performance higher on windows ie 3 4 times faster in these background threads (in time execute them).

why might be? threading libraries i'm using? surely there shouldn't such difference? or runtime libraries underneath all?

here machine details

mac:

intel(r) core(tm) i7-3820qm cpu @ 2.70ghz

16 gb ddr3 1600 mhz

model macbookpro9,1

os: mac osx 10.8.5

windows:

intel(r) core(tm) i7-3520m cpu @ 2.90ghz

16 gb ddr3 1600 mhz

model: dell latitude e5530

os: windows 7 service pack 1

edit

to basic speed comparison compiled on both machines running command line

int main(int agrc, char **argv) {      time_t t = time(null);     tm* tt=localtime(&t);     std::stringstream s;     s<< std::setfill('0')<<std::setw(2)<<tt->tm_mday<<"/"<<std::setw(2)<<tt->tm_mon+1<<"/"<< std::setw(4)<<tt->tm_year+1900<<" "<< std::setw(2)<<tt->tm_hour<<":"<<std::setw(2)<<tt->tm_min<<":"<<std::setw(2)<<tt->tm_sec;            std::cout<<"1: "<<s.str()<<std::endl;      double sum=0;      (int i=0;i<100000000;i++){         double ii=i*0.123456789;         sum=sum+sin(ii)*cos(ii);     }       t = time(null);     tt=localtime(&t);     s.str("");     s<< std::setfill('0')<<std::setw(2)<<tt->tm_mday<<"/"<<std::setw(2)<<tt->tm_mon+1<<"/"<< std::setw(4)<<tt->tm_year+1900<<" "<< std::setw(2)<<tt->tm_hour<<":"<<std::setw(2)<<tt->tm_min<<":"<<std::setw(2)<<tt->tm_sec;      std::cout<<"2: "<<s.str()<<std::endl;   } 

windows takes less second. mac takes 4/5 seconds. ideas?

on mac i'm compiling g++, visual studio 2013 on windows.

second edit

if change line

std::cout<<"2: "<<s.str()<<std::endl; 

to

std::cout<<"2: "<<s.str()<<" "<<sum<<std::endl; 

then of sudden windows takes little bit longer...

this makes me think whole thing might compiler optimisation. question g++ (4.2 version have) worse @ optimisation or need provide additional flags?

third(!) , final edit

i can report achieve comparable performance ensuring g++ optimisation flags -o provided @ compile time. 1 of annoying things happens often

a: im tearing hair out on problem x

b: sure you're not doing y?

a: works, why information not plastered on place , in every tutorial on problem x on web?

b: did read manual?

a: no, if read manual every single bit of code/program used never round doing anything...

meh.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -