Message Boards Message Boards

0
|
9080 Views
|
11 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Slower calculations on a faster machine

Posted 11 years ago
Hello! I run a notebook that calculates values of a user-defined function in a complex plane. One of the lines of the file is calculated approx 1 hour 20 min on a machine with Intel Celeron 1.4 GHz under Windows XP. On another machine, with Intel i3 2.2 GHz under Windows 8, the same calculation takes slightly longer, 1 hour 30 min. Is it natural to expect that the calculation should be faster on a second machine with a faster processor? Is it possible to speed up the calculation on the second machine? By the way, the processor load during this calculation is 100% on the first machine and 10-12% on the second machine.   
POSTED BY: Zhanna F
11 Replies
Partial derivative - if everything else is the same, then one would expect a higher clock speed would give a shorter run time.

There are many other characteristics of the two computers that need to be taken into account.
How much of what sort of memory, details of the busses, how threads are assigned to cpu cores, etc.
POSTED BY: Bruce Miller
Posted 11 years ago
There are no partial derivatives. The RAM memory is 512 MB on the first machine and 4GB on the second. Unfortunately, have no idea about busses and threads. 
POSTED BY: Zhanna F
Sorry.  I was using "Partial derivative" as an analogy.
POSTED BY: Bruce Miller
Posted 11 years ago
Ok, too many variables. But the second machine is better in any other way, not only processor. Why the calculation is so slow? Any ideas?
POSTED BY: Zhanna F
Do you export/import large files? because your cpu and memory should be faster, but importing/exporting could be similar as they can be limited by a hard drive. Could you post some code, or the idea of the code? What kind of operations for you do? Matrix inversions? Image-processing? Parallelized non-parallelized? Without some insight it will be very hard to explain for any of us.
POSTED BY: Sander Huisman
Posted 11 years ago
The relevant lines of code are like this. The last calculation takes 1 hour 20 min.

>LegendreQmy[np_,xp_]:=LegendreP[np,xp]*Log[(xp+1)/(xp-1)]/2-Sum[LegendreP[ksum,xp]*LegendreP[np-ksum-1,xp]/(np-ksum),{ksum,0,np-1}]/;np>1

>IntPP[kp_,lp_,xp_]:=2*Sum[(App[(kp+lp+mp)/2-kp]*App[(kp+lp+mp)/2-lp]*App[(kp+lp+mp)/2-mp]/App[(kp+lp+mp)/2])*((2*mp+1)/(kp+lp+mp+1))*LegendreQmy[mp,xp],{mp,Abs[kp-lp],kp+lp,2}]

>Clear;b[gp_,np_]:=(2*np+1)*(gp^np)

>Clear[zet,etap,phip];zet[etap_,phip_]:=1+(1-etap)*Exp

>Clear[gp,zp,RplusmatrixLeg];RplusmatrixLeg[zp_,gp_]=Table[Sqrt[b[gp,ik-1]*b[gp,jk-1]]*IntPP[ik-1,jk-1,zp],{ik,Nc},{jk,Nc}];

  >g=0.8;etad=0.01;dphi=2*Pi/90;Clear;Rleg=Table[Rini,{ietad,1,101},{iphi,1,46}];Do[Do[Rleg[[ietad,iphi]]=RplusmatrixLeg[zet[etad*(ietad-1),-Pi+dphi*(iphi-1)],g],{iphi,1,46}],{ietad,1,100}];
Do[Rleg[[ietad,1]]=RplusmatrixLeg[zet[etad*(ietad-1),-Pi+0.000001],g],{ietad,1,100}] 
POSTED BY: Zhanna F
Dear Zhanna,

I'm not exactly sure what you try to do, but I see it that the second-last line involves 5 (!!) nested iterations (2x Do, 2x Table, 1 Sum). Is the entire code long? This problem might be able to be sped up by using memoization.

I would like to note that the command Clear; doesn't do anything!
Also I'm not sure if you purposefully used '=' (rather than ':=') for the RplusmatrixLeg definition, is that correct?
Also the line:
zet[etap_, phip_] := 1 + (1 - etap)*Exp
if probably incorrect: Exp should be either Exp[1] or E. (I could be wrong, but I think it makes sense in this case).

Maybe if you post the full code people (including me) can try to optimize this code. Thanks!
POSTED BY: Sander Huisman
Posted 11 years ago
Dear Sander,

The entire code is long, but this is the most time-consuming part.
I use `=` in order to calculate RplusmatrixLeg  in advance.
The Exp in the line sited should be Exp (this was cut during copy/paste)

The code is under development, but probably I can made a shot version and send you in a couple of days. Can I use your e-mail for that?
POSTED BY: Zhanna F
Posted 11 years ago
Exp[i * phip]
POSTED BY: Zhanna F
Dear Zhanna, it is very hard to check what the problem is without having the full code I think. I could have a look at it. How many lines are we talking about? it is best if you could post it here, or post a link to file somewhere on the internet, so that everyone can access it. 
POSTED BY: Sander Huisman
Posted 11 years ago
Ok. 50 lines, may be, but very simple. I will try to post here.
POSTED BY: Zhanna F
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract