Next: , Previous: , Up: Vectorization and Faster Code Execution   [Contents][Index]


19.5 JIT Compiler

Vectorization is the preferred technique for eliminating loops and speeding up code. Nevertheless, it is not always possible to replace every loop. In such situations it may be worth trying Octave’s experimental Just-In-Time (JIT) compiler.

A JIT compiler works by analyzing the body of a loop, translating the Octave statements into another language, compiling the new code segment into an executable, and then running the executable and collecting any results. The process is not simple and there is a significant amount of work to perform for each step. It can still make sense, however, if the number of loop iterations is large. Because Octave is an interpreted language every time through a loop Octave must parse the statements in the loop body before executing them. With a JIT compiler this is done just once when the body is translated to another language.

The JIT compiler is a very new feature in Octave and not all valid Octave statements can currently be accelerated. However, if no other technique is available it may be worth benchmarking the code with JIT enabled. The function jit_enable is used to turn compilation on or off. The function jit_startcnt sets the threshold for acceleration. Loops with iteration counts above jit_startcnt will be accelerated. The functions jit_failcnt and debug_jit are not likely to be of use to anyone not working directly on the implementation of the JIT compiler.

Built-in Function: val = jit_enable ()
Built-in Function: old_val = jit_enable (new_val)
Built-in Function: jit_enable (new_val, "local")

Query or set the internal variable that enables Octave’s JIT compiler.

When called from inside a function with the "local" option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

See also: jit_startcnt, debug_jit.

Built-in Function: val = jit_startcnt ()
Built-in Function: old_val = jit_startcnt (new_val)
Built-in Function: jit_startcnt (new_val, "local")

Query or set the internal variable that determines whether JIT compilation will take place for a specific loop.

Because compilation is a costly operation it does not make sense to employ JIT when the loop count is low. By default only loops with greater than 1000 iterations will be accelerated.

When called from inside a function with the "local" option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

See also: jit_enable, jit_failcnt, debug_jit.

Built-in Function: val = jit_failcnt ()
Built-in Function: old_val = jit_failcnt (new_val)
Built-in Function: jit_failcnt (new_val, "local")

Query or set the internal variable that counts the number of JIT fail exceptions for Octave’s JIT compiler.

When called from inside a function with the "local" option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

See also: jit_enable, jit_startcnt, debug_jit.

Built-in Function: val = debug_jit ()
Built-in Function: old_val = debug_jit (new_val)
Built-in Function: debug_jit (new_val, "local")

Query or set the internal variable that determines whether debugging/tracing is enabled for Octave’s JIT compiler.

When called from inside a function with the "local" option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

See also: jit_enable, jit_startcnt.


Next: , Previous: , Up: Vectorization and Faster Code Execution   [Contents][Index]