This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi Jason, Please see my responses below. I have also attached a fixed patch and the Changelog entries are cut and pasted below. > -----Original Message----- > From: Jason Merrill [mailto:jason@redhat.com] > Sent: Thursday, November 21, 2013 1:59 PM > To: Iyer, Balaji V; gcc-patches@gcc.gnu.org > Cc: Jeff Law > Subject: Re: _Cilk_spawn and _Cilk_sync for C++ > > On 11/17/2013 10:19 PM, Iyer, Balaji V wrote: > > cp/cp-cilkplus.o \ > > - cp/cp-gimplify.o cp/cp-array-notation.o cp/lambda.o \ > > + cp/cp-gimplify.o cp/cp-array-notation.o cp/lambda.o cp/cp-cilk.o \ > > It seems unnecessary to have both cp-cilk.c and cp-cilkplus.c. Please > combine them. Fixed. I removed cp-cilk.c and moved my work to cp-cilkplus.c. This will change my _Cilk_for for C++ work also, since I used cp-cilk.c to store all my routines. I will send out a fixed patch soon. > > > + extern tree do_begin_catch (void); > > + extern tree do_end_catch (tree); > > If you want to use these, they need to be declared in cp-tree.h, not within > another function. Or better yet, factor out this code: > Fixed. I created a new function called cilk_create_try_catch () in cp/except.c > > + append_to_statement_list (do_begin_catch (), &catch_list); > > + append_to_statement_list (build_throw (NULL_TREE), &catch_list); > > + tree catch_tf_expr = build_stmt (EXPR_LOCATION (body), > TRY_FINALLY_EXPR, > > + catch_list, do_end_catch (NULL_TREE)); > > + catch_list = build2 (CATCH_EXPR, void_type_node, NULL_TREE, > > + catch_tf_expr); > > + tree try_catch_expr = build_stmt (EXPR_LOCATION (body), > TRY_CATCH_EXPR, > > + body, catch_list); > > ...into a function in cp/except.c. > Yep, this is what I did. > > + tree try_finally_expr = build_stmt (EXPR_LOCATION (body), > > + TRY_FINALLY_EXPR, > > + try_catch_expr, dtor); > > + append_to_statement_list (try_finally_expr, &list); > > + } > > + else > > + append_to_statement_list (build_stmt (EXPR_LOCATION (body), > > + TRY_FINALLY_EXPR, body, dtor), > &list); > > This bit could be shared between the two branches. Fixed. > > > + /* When Cilk Plus is enabled, the lambda function need to be stored to > > + a variable because if the function is spawned, then we need some kind > > + of a handle. */ > > + if (flag_enable_cilkplus && cxx_dialect >= cxx0x > > + && TREE_CODE (fn) != VAR_DECL && TREE_CODE (fn) != OVERLOAD > > + && TREE_CODE (fn) != FUNCTION_DECL) > > + fn = cilk_create_lambda_fn_tmp_var (fn); > > I don't like making this change here. What do you need a handle for? > Why can't build_cilk_spawn deal with it? > The reason is that, when you have something like this: _Cilk_spawn [=] { <body> } (); I need to capture the function call (which in this case is the whole function) and throw it into a nested function. The nested function implementation is shared with C. If the function is stored in a variable then I can just send that out to the nested function. I have added another constraint to make sure the function is a spawning function, this way we can reduce more cases were they are stored to a variable. The reason why I added this check in finish_call_expr is that it seemed to be most straight-forward for me and only place where I could do with least disruption (code-changes). > > + case CILK_SPAWN_STMT: > > + if (!potential_constant_expression_1 (CILK_SPAWN_FN (t), true, > flags)) > > + return false; > > + return true; > > Isn't Cilk spawn itself is non-constant, so you can just return false? > Fixed. Here are the ChangeLog entries: gcc/cp/ChangeLog 2013-11-21 Balaji V. Iyer <balaji.v.iyer@intel.com> * cp-tree.h (cilk_valid_spawn): New prototype. (gimplify_cilk_spawn): Likewise. (cp_cilk_install_body_wframe_cleanup): Likewise. (cilk_create_lambda_fn_tmp_var): Likewise. (create_cilk_try_catch): Likewise. * decl.c (finish_function): Insert Cilk function-calls when a _Cilk_spawn is used in a function. * parser.c (cp_parser_postfix_expression): Added RID_CILK_SPAWN and RID_CILK_SYNC cases. * cp-cilkplus.c (set_cilk_except_flag): New function. (set_cilk_except_data): Likewise. (cp_cilk_install_body_wframe_cleanup): Likewise. (cilk_create_lambda_fn_tmp_var): Likewise. * except.c (create_cilk_try_catch): Likewise. * parser.h (IN_CILK_SPAWN): New #define. * cp-objcp-common.h (LANG_HOOKS_CILKPLUS_GIMPLIFY_SPAWN): Likewise. (LANG_HOOKS_CILKPLUS_DETECT_SPAWN_AND_UNWRAP): Likewise. (LANG_HOOKS_CILKPLUS_FRAME_CLEANUP): Likewise. * pt.c (tsubst_expr): Added CILK_SPAWN_STMT and CILK_SYNC_STMT cases. * semantics.c (potential_constant_expression_1): Likewise. (finish_call_expr): Stored the lambda function to a variable when Cilk Plus is enabled and if the function contains a spawn. * typeck.c (cp_build_compound_expr): Reject a spawned function in a compound expression. (check_return_expr): Reject a spawned function in a return expression. gcc/testsuite/ChangeLog 2013-11-21 Balaji V. Iyer <balaji.v.iyer@intel.com> * g++.dg/cilk-plus/CK/catch_exc.cc: New test case. * g++.dg/cilk-plus/CK/const_spawn.cc: Likewise. * g++.dg/cilk-plus/CK/fib-opr-overload.cc: Likewise. * g++.dg/cilk-plus/CK/fib-tplt.cc: Likewise. * g++.dg/cilk-plus/CK/lambda_spawns.cc: Likewise. * g++.dg/cilk-plus/CK/lambda_spawns_tplt.cc: Likewise. * g++.dg/cilk-plus/cilk-plus.exp: Added support to run Cilk Keywords test stored in c-c++-common. Also, added the Cilk runtime's library to the ld_library_path. Thanks, Balaji V. Iyer. > Jason
Attachment:
diff.txt
Description: diff.txt
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |