Igor Pro 8 runs loops slower than 7
Variable i, j, timer
timer = StartMSTimer
//less than 1 sec
For (i=0; i<10000000; i+=1)
j = sin(i)
EndFor
print "Escaped Seconds:", StopMSTimer(timer)/1000000
End
Hi,
I am running both 64-bit Igor 7.08 and 8.04.
Benchmark results show 8 is faster for most tests, except for overhead test, which I posted below.
Taking an example, if you run the code I posted, igor 8 runs generally more than 10% slower than 7.
I also attached my brief sys info.
Anyboday has similar issue?
Thanks.
**** test on Windows 10 Education6.3.18363 using 7.08 and 50 passes; Dual 2 GHz PowerPC G5 Mac Pro
us timer overhead time: 61.85ns, relative speed= 2.36
fctn Overhead time: 72.25ns, relative speed= 4.01
Fit Fctn Overhead time: 249.47ns, relative speed= 8.04
Do Loop Overhead time: 55.09ns, relative speed= 4.67
For Loop Overhead time: 63.67ns, relative speed= 3.34
Local var assignment time: 10.41ns, relative speed= 5.23
Double wave assignment time: 136.21ns, relative speed= 4.47
Single wave assignment time: 140.92ns, relative speed= 4.05
Double wave[] read time: 835.91ps, relative speed= 214.15
Double wave read time: 10.95ns, relative speed= 6.24
Single wave[] read time: 26.06ns, relative speed= 39.72
Single wave read time: 16.84ns, relative speed= 7.62
Add const time: 8.55ns, relative speed= 4.94
Mult loc var time: 7.58ns, relative speed= 4.71
Mult const time: 8.24ns, relative speed= 5.10
MatrixOp overhead time: 40.61µs, relative speed= 0.45
**** done ****
total test time= 2.77966
**** test on Windows 10 Education6.3.18363 using 8.04 and 50 passes; Dual 2 GHz PowerPC G5 Mac Pro
us timer overhead time: 100.00ns, relative speed= 1.46
fctn Overhead time: 60.51ns, relative speed= 4.78
Fit Fctn Overhead time: 256.00ns, relative speed= 7.84
Do Loop Overhead time: 52.30ns, relative speed= 4.91
For Loop Overhead time: 47.35ns, relative speed= 4.50
Local var assignment time: 11.83ns, relative speed= 4.60
Double wave assignment time: 163.11ns, relative speed= 3.73
Single wave assignment time: 173.96ns, relative speed= 3.28
Double wave[] read time: 144.14ps, relative speed= 1241.94
Double wave read time: 13.98ns, relative speed= 4.89
Single wave[] read time: 24.10ns, relative speed= 42.96
Single wave read time: 18.68ns, relative speed= 6.87
Add const time: 9.11ns, relative speed= 4.64
Mult loc var time: 7.97ns, relative speed= 4.48
Mult const time: 8.76ns, relative speed= 4.80
MatrixOp overhead time: 44.57µs, relative speed= 0.41
**** done ****
total test time= 3.0686
System Information:
i5-6200U 2.3GHz, 8GB Ram, 256GB PCIE SSD
IGORVERS:8.04
BUILD:34722
IGORKIND:pro64
FREEMEM:140732354666496
PHYSMEM:8480653312
USEDPHYSMEM:158289920
NSCREENS:1
SCREEN1:DEPTH=32,RECT=0,0,1920,1080
OS:Windows 10 Education
OSVERSION:6.3.18363
LOCALE:US
IGORFILEVERSION:8.0.4.2
Default Igor graphics technology: 3
Screen Resolution: 144
Screen scale factor: 1
Graphics Rendering: GeForce 940MX/PCIe/SSE2
Qt version (runtime): 5.9.6
Qt version (compiled): 5.9.6
XOPs: HDF5-64;PeakFunctions2-64;
IGORVERS:7.08
BUILD:31118
IGORKIND:pro64
FREEMEM:140732587094016
PHYSMEM:8480653312
USEDPHYSMEM:135188480
NSCREENS:1
SCREEN1:DEPTH=32,RECT=0,0,1920,1080
OS:Windows 10 Education
OSVERSION:6.3.18363
LOCALE:US
IGORFILEVERSION:7.0.8.1
Default Igor graphics technology: 3
Screen Resolution: 144
Screen scale factor: 1
Graphics Rendering: GeForce 940MX/PCIe/SSE2
Qt version (runtime): 5.6.3
Qt version (compiled): 5.6.3
I get similar differences between IP7 and IP8 on Windows. However, on Macintosh, it's the opposite. IP7 takes 0.834 s, and IP8 takes 0.694 s. This is for the function you posted, with 7.08 and 8.04 on both platforms.
I used a sampling profiler on Windows to look at the code execution with IP7 and IP9 (which in this respect gives about the same performance as IP8). The underlying source code for Igor's sin function hasn't changed since IP7, and the majority of the time is spent in that function. We are simply calling the standard sin() function. With Igor 7, that sin() function comes from math.h. With Igor 8 and later, it comes from cmath. It seems that the implementation of sin in cmath happens to be a bit slower than the math.h implementation. I don't know why that is.
In any case, there are much faster ways to do the same computation:
Variable timer
timer = StartMSTimer
Make/O/N=(10000000)/FREE ddd
MultiThread ddd=sin(p)
print "Escaped Seconds:", StopMSTimer(timer)/1000000
End
Function TestRunTime3()
Variable timer
timer = StartMSTimer
Make/O/N=(10000000)/FREE ddd
MultiThread ddd=p
WaveTransform/O sin ddd
print "Escaped Seconds:", StopMSTimer(timer)/1000000
End
Either of those will be substantially faster, and have roughly equivalent performance with IP 7, 8, or 9 (on my machine at least).
November 21, 2019 at 08:56 am - Permalink
In reply to I get similar differences… by aclight
Thank you for your comments.
Of course there are much better and faster ways to do the calculation as you posted.
Actually I didn't expect the issue comes from sin(x).
Originally, I was impressed a slower IP8 by other complex codes which run multiple loops.
Another example, if you run a loop calculating simply j = i^2 instead of sin(i), you will find IP8 is still slower than IP7, especially when you increase the loop number with longer time but smaller err bar.
BTW, for TestRunTime3, IP8 in my laptop is faster than IP7, however, when it comes to TestRunTime2, IP8 is two times slower than 7, why?
(for IP7, run time for TestRunTime2 and 3 has little difference)
Thanks.
November 21, 2019 at 08:43 pm - Permalink
I don't see a consistent difference between IP7 and IP8 if I replace j=sin(i) with j=i^2. This is true even if I add 2 zeros to the number of cycles to do in the for statement.
The overhead of a loop in Igor is typically relatively small compared to whatever is being done in the loop. If that's not the case, it's likely that there is a better way to write your code so that it executes faster. For example using a wave assignment statement instead of a loop, using multiple threads, and/or using WaveTransform when possible.
BTW, for TestRunTime3, IP8 in my laptop is faster than IP7, however, when it comes to TestRunTime2, IP8 is two times slower than 7, why?
I don't know, and since I don't have your laptop to run tests on, we will probably never know. TestRunTime2 uses threads, so if your CPU us in use by other applications that would impact the performance of TestRunTime2. TestRunTime3 uses optimized vector code from mkl to do the calculations. I'm not sure if that uses threads or not, but if it does the threading would be done very differently from how it's done with a MultiThread wave assignment statement like in TestRunTime2.
If you have actual performance issues with your code, we can discuss those and differences you see between Igor 7 and Igor 8. Feel free to use Help->Contact Support to get in touch with us directly in that case.
November 22, 2019 at 09:27 am - Permalink