performance - My C-Code runs slowly in Mac comparing to Ubuntu -


i have written scientific code in c. compile code in ubuntu using gcc 4.7.2, , in mbp using gcc 4.2. makefile looks this:

cc = gcc cflags = -c -fpic -wall -o3 -lpthread -g basedir = /users/admin/ libname = libttvs.so include = -i$(basedir)umfpack/include -i$(basedir)amd/include -i$(basedir)suitesparse_config lib = -l$(basedir)umfpack/lib -l$(basedir)amd/lib -l$(basedir)suitesparse_config -l$(basedir)gotoblas2 addfiles = -lumfpack -lamd -lsuitesparseconfig -lgoto2 staticlibs = $(basedir)umfpack/lib/libumfpack.a $(basedir)amd/lib/libamd.a $(basedir)suitesparse_config/libsuitesparseconfig.a $(basedir)gotoblas2/libgoto2.a all: algebrafuncs.o qsp.o updatealgvars.o algvarsjac.o extraroutines.o solvemultistepsolverc.o ttvs.o ttvs.h         $(cc) $(include) $(lib) $(addfiles) -shared -lpthread -o $(libname) $^ -lm -g $(staticlibs)  algebrafuncs.o: algebrafuncs.c ttvs.h         $(cc) $(include) $(cflags) $^  qsp.o: qsp.c ttvs.h         $(cc) $(include) $(cflags) $^  updatealgvars.o: updatealgvars.c ttvs.h         $(cc) $(include) $(cflags) $^  algvarsjac.o: algvarsjac.c ttvs.h         $(cc) $(cflags) $^  extraroutines.o: extraroutines.c ttvs.h         $(cc) $(cflags) $^  solvemultistepsolverc.o: solvemultistepsolverc.c ttvs.h         $(cc) $(include) $(cflags) $^  ttvs.o: ttvs.c ttvs.h         $(cc) $(include) $(cflags) $^ 

as can see, use -o3 compile source code.

the problem compiled code slow in mac. in ubuntu, code executed in 0.89sec, while in mbp, takes 7.8sec. have implemented code in matlab , here results: ubuntu: 4sec, mbp: 5.5sec. can see, c-code runs slower matlab not make sense. although gcc version not same in 2 platforms, expect @ least close. main problem not start work around problem or should check.

here specs of 2 machines: ubuntu: core i7 2600 @3.4ghz, quad-core, 8gb ram mbp: core i5 @2.5ghz, 8gb ram

i know ubuntu has more powerful cpu, considering matlab results, cannot see why c-code faster in ubuntu. should faster, not 8 times !!

thanks in advance

you're using old compiler not have optimization support instructions cpu supports. try using clang instead, apple stopped supporting gcc time ago , switched compiler in new versions of xcode.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -