octave: JIT Compiler

 
 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.
 
  -- : VAL = jit_enable ()
  -- : OLD_VAL = jit_enable (NEW_VAL)
  -- : 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.
 
DONTPRINTYET       See also: Seejit_startcnt XREFjit_startcnt, *notedebug_jit:
DONTPRINTYET       See also: Seejit_startcnt XREFjit_startcnt, Seedebug_jit

      XREFdebug_jit.
 
  -- : VAL = jit_startcnt ()
  -- : OLD_VAL = jit_startcnt (NEW_VAL)
  -- : 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.
 
DONTPRINTYET       See also: Seejit_enable XREFjit_enable, *notejit_failcnt:
DONTPRINTYET       See also: Seejit_enable XREFjit_enable, Seejit_failcnt

      XREFjit_failcnt, Seedebug_jit XREFdebug_jit.
 
  -- : VAL = jit_failcnt ()
  -- : OLD_VAL = jit_failcnt (NEW_VAL)
  -- : 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.
 
DONTPRINTYET       See also: Seejit_enable XREFjit_enable, *notejit_startcnt:
DONTPRINTYET       See also: Seejit_enable XREFjit_enable, Seejit_startcnt

      XREFjit_startcnt, Seedebug_jit XREFdebug_jit.
 
  -- : VAL = debug_jit ()
  -- : OLD_VAL = debug_jit (NEW_VAL)
  -- : 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.
 
DONTPRINTYET       See also: Seejit_enable XREFjit_enable, *notejit_startcnt:
DONTPRINTYET       See also: Seejit_enable XREFjit_enable, Seejit_startcnt

      XREFjit_startcnt.