Mercurial > hg > octave-nkf
diff src/pt-loop.h @ 13245:027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
* octave.gperf (octave_kw_id): New keyword ids, parfor_kw and
end_parfor_kw.
(octave_kw): Add parfor and end_parfor to the struct.
* lex.ll (is_keyword_token): Handle parfor and end_parfor.
* token.h (token::parfor_end): New end_tok_type enum value.
* oct-parse.yy (PARFOR): New token.
(loop_command): Handle PARFOR statements.
(make_for_command): New args tok_id and maxproc. Handle PARFOR loops.
* pt-loop.h (tree_simple_for_command::parallel,
tree_simple_for_command:maxproc): New data members.
(tree_simple_for_command::tree_simple_for_command): New args
parallel_arg and maxproc_arg. Initialize new data members.
(tree_simple_for_command::parallel): New function.
(tree_simple_for_command::maxproc_expr): New function.
* pt-loop.cc (tree_simple_for_command::~tree_simple_for_command):
Delete maxproc.
(tree_simple_for_command::dup): Pass parallel and maxproc to
constructor for duplicate object.
* pt-pr-code.cc (tree_print_code::visit_simple_for_command):
Handle parallel form.
* pt-check.cc (tree_checker::visit_simple_for_command): Likewise.
* pt-eval.cc (tree_evaluator::visit_simple_for_command): Note that
this is where parallel loops need to be handled.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 29 Sep 2011 02:50:53 -0400 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
line wrap: on
line diff
--- a/src/pt-loop.h +++ b/src/pt-loop.h @@ -145,23 +145,30 @@ public: tree_simple_for_command (int l = -1, int c = -1) - : tree_command (l, c), lhs (0), expr (0), list (0), lead_comm (0), - trail_comm (0) { } + : tree_command (l, c), parallel (false), lhs (0), expr (0), + maxproc (0), list (0), lead_comm (0), trail_comm (0) { } - tree_simple_for_command (tree_expression *le, tree_expression *re, + tree_simple_for_command (bool parallel_arg, tree_expression *le, + tree_expression *re, + tree_expression *maxproc_arg, tree_statement_list *lst, octave_comment_list *lc = 0, octave_comment_list *tc = 0, int l = -1, int c = -1) - : tree_command (l, c), lhs (le), expr (re), list (lst), + : tree_command (l, c), parallel (parallel_arg), lhs (le), + expr (re), maxproc (maxproc_arg), list (lst), lead_comm (lc), trail_comm (tc) { } ~tree_simple_for_command (void); + bool in_parallel (void) { return parallel; } + tree_expression *left_hand_side (void) { return lhs; } tree_expression *control_expr (void) { return expr; } + tree_expression *maxproc_expr (void) { return maxproc; } + tree_statement_list *body (void) { return list; } octave_comment_list *leading_comment (void) { return lead_comm; } @@ -175,12 +182,20 @@ private: + // TRUE means operate in parallel (subject to the value of the + // maxproc expression). + bool parallel; + // Expression to modify. tree_expression *lhs; // Expression to evaluate. tree_expression *expr; + // Expression to tell how many processors should be used (only valid + // if parallel is TRUE). + tree_expression *maxproc; + // List of commands to execute. tree_statement_list *list;