Multithreaded assignment in Igor Pro
One keyword spreads a wave assignment across cores, when the expression allows it.
Function ExpensiveMap(WAVE out)
Variable n = numpnts(out)
MultiThread out = SlowKernel(x)
Printf "%d points across %d threads\r", n, ThreadProcessorCount
End
ThreadSafe Function SlowKernel(Variable t)
return exp(-t^2) * besselJ(0, 12 * t)
End
How it works
MultiThreadgoes in front of the assignment.- It pays off on long waves and expensive expressions, not on short ones.
- The expression must not depend on the order points are computed in.
Keywords and builtins used here
EndFunctionMultiThreadPrintfThreadProcessorCountThreadSafeVariableWAVEbesselJexpnumpntsreturn
The run, in numbers
- Lines
- 11
- Characters to type
- 245
- Tokens
- 52
- Three-star pace
- 80 tpm
At the three-star pace of 80 tokens a minute, this run takes about 39 seconds.
Step 4 of 4 in Wave assignment, step 4 of 16 in Waves & analysis.