steveneads Posted January 21, 2020 Share Posted January 21, 2020 My application is gradually growing the PPMAC processor loading, and so I'm always trying to ensure that I write my code as efficiently as I can. I use a significant amount of trig function calculations and I want to have some guidance on what methods are most efficient. My code is running in C from script from PLC 0. I used this to do some timing tests evaluating some functions 1000 times. This yielded the following approximate times (microsecs) on a 465 PPMAC: atan2(x,y): 97 atan: 0.12 sqrt(1 + x*x): 57 1/x: 0.1 cos: 0.12 acos: 57 I was staggered to see the differences between atan2 and atan in particular and was also surprised by some of the other differences. I'm almost doubting my own results. Can DeltaTau shed any light on why atan2 and atan are so different in efficiency, and what functions are very costly / efficient? I remember some notes being provided on this years ago with the original PMACs! Link to comment Share on other sites More sharing options...
dro Posted January 21, 2020 Share Posted January 21, 2020 Can you please email me your sample application @ dro.ghazarian@Omron.com and also the firmware. Link to comment Share on other sites More sharing options...
curtwilson Posted January 23, 2020 Share Posted January 23, 2020 Our own benchmarks show that the computational time for atan2 is only 10-15% greater than for atan, on both PowerPC and ARM processors. That is why we need to see your configuration. Link to comment Share on other sites More sharing options...
steveneads Posted January 30, 2020 Author Share Posted January 30, 2020 Hi Curt / Dro Thanks for looking into this. We have done some more investigation here and have found the root cause of my results. It looks like I was being fooled by some sort of compiler optimization which meant that for some of the function tests, the calculation wasn't really being repeated the number of times that I thought is was. However, we have noticed that using the rticplc seems to be significantly slower than using a C from script call from PLC 0 for the same function test. It's particularly bad for sqrt. Is this what you would expect? Thanks Link to comment Share on other sites More sharing options...
Recommended Posts