math efficiency?

Beta Testing discussion on mikroPascal PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

math efficiency?

#1 Post by jpc » 25 Apr 2011 08:18

in the process of checking performances between PIC family's i noticed that the math-efficiency on the dsPIC compiler is rather poor, in fact a modern P18 on 64 mHz can outperform a 80 mHz clocked P33 in simple divisions/multiplications of real variables which seems not correct to me.

Code: Select all

program MyProject;
// comparison of simple math efficiency, score's are in cpu-cycles

var r_a,r_b,r_c : real;

begin                         //  P18         P33         P32MX

  r_a := 1.23456;             //  10          15          3
  r_b := 98765.4321* tmr2;    //  116         229         55
  r_c := r_a / r_b;           //  50          400         36
  r_c := r_a * r_b;           //  48          128         35
  r_c := tan(r_a);            //  10932       9208        3195
  
end.
Au royaume des aveugles, les borgnes sont rois.

kjm
Posts: 70
Joined: 06 Jul 2006 22:17

Re: math efficiency?

#2 Post by kjm » 29 Apr 2011 20:32

jpc wrote:in the process of checking performances between PIC family's i noticed that the math-efficiency on the dsPIC compiler is rather poor, in fact a modern P18 on 64 mHz can outperform a 80 mHz clocked P33 in simple divisions/multiplications of real variables which seems not correct to me.

Code: Select all

program MyProject;
// comparison of simple math efficiency, score's are in cpu-cycles

var r_a,r_b,r_c : real;

begin                         //  P18         P33         P32MX

  r_a := 1.23456;             //  10          15          3
  r_b := 98765.4321* tmr2;    //  116         229         55
  r_c := r_a / r_b;           //  50          400         36
  r_c := r_a * r_b;           //  48          128         35
  r_c := tan(r_a);            //  10932       9208        3195
  
end.

Any comment from ME about this compare test??

sasa72
Posts: 89
Joined: 21 Apr 2011 05:21

Re: math efficiency?

#3 Post by sasa72 » 01 May 2011 19:03

dsPIC version seems to use native IEEE-754 for 32-bit floating point, meaning sign bit is in front 8-bits exponent, which assume constant shifting and masking and accordingly can be expected some speed decreasing, however not 4x efficiency drop. Compensation using 16-bit CPU also should be significant, thus obviously is some overlook or bug during code optimization.

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: math efficiency?

#4 Post by zristic » 03 May 2011 09:47

Yes, soon. We are testing it.

User avatar
mileta.miletic
mikroElektronika team
Posts: 493
Joined: 05 Jun 2009 14:46
Location: Belgrade, Serbia
Contact:

Re: math efficiency?

#5 Post by mileta.miletic » 10 May 2011 11:45

Hi,

There is bug in conversion to float routine in dsPIC and it will be fixed for the incoming release. If you check the above example in the simulator, the tmr is 0 on start, and r_b variable is zero, and you have early exit on multiplying and division by 0. Due the bug in conversion in dsPIC that was not the case, r_b variable wasn't 0, and that is why you had such big difference.
For good performance testing, random numbers should be used in measurement in order to cover all possible branches in floating point routines.
Regards,
Mileta

sasa72
Posts: 89
Joined: 21 Apr 2011 05:21

Re: math efficiency?

#6 Post by sasa72 » 01 Jun 2011 07:09

Mileta,

I suppose you refer on bug in conversion to standard IEEE-754. Otherwise, testing with sqrt(2.) instead tmr the problem with efficiency persist.

User avatar
mileta.miletic
mikroElektronika team
Posts: 493
Joined: 05 Jun 2009 14:46
Location: Belgrade, Serbia
Contact:

Re: math efficiency?

#7 Post by mileta.miletic » 01 Jun 2011 11:43

sasa72 wrote:Mileta,

I suppose you refer on bug in conversion to standard IEEE-754. Otherwise, testing with sqrt(2.) instead tmr the problem with efficiency persist.
It was problem in preparing arguments before conversion. For good performance testing of floating point arithmetics, a large set of random input numbers should be used.
Regards,
Mileta

Post Reply

Return to “mikroPascal PRO for dsPIC30/33 and PIC24 Beta Testing”