Mercurial > hg > octave-lyh
changeset 16941:e6ddaa65a777
Add new function jit_startcnt to control JIT acceleration.
* NEWS: Announce new function.
* doc/interpreter/vectorize.txi: Add verbiage to manual about function.
* libinterp/corefcn/pt-jit.cc(Fjit_startcnt): New function which manages
static variable Vjit_startcnt. Variable is threshold above which JIT
acceleration takes place.
* libinterp/corefcn/pt-jit.cc(Fjit_enable, Fdebug_jit): Update seealso links
in docstring.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 09 Jul 2013 17:37:26 -0700 |
parents | 99122191d3dd |
children | 78a2f43bbc69 |
files | NEWS doc/interpreter/vectorize.txi libinterp/corefcn/pt-jit.cc |
diffstat | 3 files changed, 53 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS +++ b/NEWS @@ -186,22 +186,22 @@ inputdlg msgbox warndlg ** Other new functions added in 3.8.0: - - atan2d erfcinv polyeig - base64_decode erfi readline_re_read_init_file - base64_encode expint readline_read_init_file - betaincinv findfigs rgbplot - built_in_docstrings_file flintmax save_default_options - cmpermute fminsearch shrinkfaces - cmunique gallery splinefit - colorcube gco stemleaf - copyobj hdl2struct strjoin - dawson history_save struct2hdl - dblist imformats tetramesh - debug_jit importdata waterfall - doc_cache_create iscolormap + + atan2d erfcinv lines + base64_decode erfi polyeig + base64_encode expint readline_re_read_init_file + betaincinv findfigs readline_read_init_file + built_in_docstrings_file flintmax rgbplot + cmpermute fminsearch save_default_options + cmunique gallery shrinkfaces + colorcube gco splinefit + copyobj hdl2struct stemleaf + dawson history_save strjoin + dblist imformats struct2hdl + debug_jit importdata tetramesh + doc_cache_create iscolormap waterfall ellipj jit_enable - ellipke lines + ellipke jit_startcnt ** Deprecated functions.
--- a/doc/interpreter/vectorize.txi +++ b/doc/interpreter/vectorize.txi @@ -519,8 +519,8 @@ 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 loop counter is a -large number. Because Octave is an interpreted language every time through a +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. @@ -528,12 +528,16 @@ 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 @code{jit_enable} is used to turn compilation on or off. The function -@code{debug_jit} is not likely to be of use to anyone not working directly on -the implementation of the JIT compiler. +function @code{jit_enable} is used to turn compilation on or off. The +function @code{jit_startcnt} sets the threshold for acceleration. Loops +with iteration counts above @code{jit_startcnt} will be accelerated. The +function @code{debug_jit} is not likely to be of use to anyone not working +directly on the implementation of the JIT compiler. @DOCSTRING(jit_enable) +@DOCSTRING(jit_startcnt) + @DOCSTRING(debug_jit) @node Miscellaneous Techniques
--- a/libinterp/corefcn/pt-jit.cc +++ b/libinterp/corefcn/pt-jit.cc @@ -44,6 +44,8 @@ static bool Vjit_enable = true; +static int Vjit_startcnt = 1000; + #include <llvm/Analysis/CallGraph.h> #include <llvm/Analysis/Passes.h> #include <llvm/Analysis/Verifier.h> @@ -1880,8 +1882,6 @@ bool tree_jit::do_execute (tree_simple_for_command& cmd, const octave_value& bounds) { - const size_t MIN_TRIP_COUNT = 1000; - size_t tc = trip_count (bounds); if (! tc || ! initialize () || ! enabled ()) return false; @@ -1892,7 +1892,7 @@ jit_info *info = cmd.get_info (); if (! info || ! info->match (extra_vars)) { - if (tc < MIN_TRIP_COUNT) + if (tc < static_cast<size_t> (Vjit_startcnt)) return false; delete info; @@ -2293,7 +2293,7 @@ When called from inside a function with the \"local\" option, the variable is\n\ changed locally for the function and any subroutines it calls. The original\n\ variable value is restored when exiting the function.\n\ -@seealso{jit_enable}\n\ +@seealso{jit_enable, jit_startcnt}\n\ @end deftypefn") { #if defined (HAVE_LLVM) @@ -2314,7 +2314,7 @@ When called from inside a function with the \"local\" option, the variable is\n\ changed locally for the function and any subroutines it calls. The original\n\ variable value is restored when exiting the function.\n\ -@seealso{debug_jit}\n\ +@seealso{jit_startcnt, debug_jit}\n\ @end deftypefn") { #if defined (HAVE_LLVM) @@ -2325,3 +2325,27 @@ #endif } +DEFUN (jit_startcnt, args, nargout, + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {@var{val} =} jit_startcnt ()\n\ +@deftypefnx {Built-in Function} {@var{old_val} =} jit_startcnt (@var{new_val})\n\ +@deftypefnx {Built-in Function} {} jit_startcnt (@var{new_val}, \"local\")\n\ +Query or set the internal variable that determines whether JIT compilation\n\ +will take place for a specific loop. Because compilation is a costly\n\ +operation it does not make sense to employ JIT when the loop count is low.\n\ +By default only loops with greater than 1000 iterations will be accelerated.\n\ +\n\ +When called from inside a function with the \"local\" option, the variable is\n\ +changed locally for the function and any subroutines it calls. The original\n\ +variable value is restored when exiting the function.\n\ +@seealso{jit_enable, debug_jit}\n\ +@end deftypefn") +{ +#if defined (HAVE_LLVM) + return SET_INTERNAL_VARIABLE_WITH_LIMITS (jit_startcnt, 1, + std::numeric_limits<int>::max ()); +#else + warning ("jit_enable: JIT compiling not available in this version of Octave"); + return octave_value (); +#endif +}