typestar

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

  1. MultiThread goes in front of the assignment.
  2. It pays off on long waves and expensive expressions, not on short ones.
  3. The expression must not depend on the order points are computed in.

Keywords and builtins used here

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.

Type this snippet

Step 4 of 4 in Wave assignment, step 4 of 16 in Waves & analysis.

← Previous Next →