On Mon, 13 Aug 2018 12:06:21 -0700 Cesar Philippidis wrote: > So in other words, this is safe for fortran. It probably could use a > fortran test, because that functionality wasn't explicitly exercised > in og7/og8. Here's a new version of the patch with a Fortran test case. It's not too easy to write a test that depends on whether gang-local variables actually end up in the right kind of memory, so I wrote one that scans the omplower dump instead. Many other (including execution) tests will already trigger the new behaviour. Tested with offloading to NVPTX. OK? Thanks, Julian 2018-08-10 Julian Brown Chung-Lin Tang gcc/ * config/nvptx/nvptx.c (tree-hash-traits.h): Include. (gangprivate_shared_size): New global variable. (gangprivate_shared_align): Likewise. (gangprivate_shared_sym): Likewise. (gangprivate_shared_hmap): Likewise. (nvptx_option_override): Initialize gangprivate_shared_sym, gangprivate_shared_align. (nvptx_file_end): Output gangprivate_shared_sym. (nvptx_goacc_expand_accel_var): New function. (nvptx_set_current_function): New function. (TARGET_SET_CURRENT_FUNCTION): Define hook. (TARGET_GOACC_EXPAND_ACCEL): Likewise. * doc/tm.texi (TARGET_GOACC_EXPAND_ACCEL_VAR): Document new hook. * doc/tm.texi.in (TARGET_GOACC_EXPAND_ACCEL_VAR): Likewise. * expr.c (expand_expr_real_1): Remap decls marked with the "oacc gangprivate" atttribute. * omp-low.c (omp_context): Add oacc_partitioning_level and oacc_decls fields. (new_omp_context): Initialize oacc_decls in new omp_context. (delete_omp_context): Delete oacc_decls in old omp_context. (lower_oacc_head_tail): Record partitioning-level count in omp context. (oacc_record_private_var_clauses, oacc_record_vars_in_bind) (mark_oacc_gangprivate): New functions. (lower_omp_for): Call oacc_record_private_var_clauses with "for" clauses. Call mark_oacc_gangprivate for gang-partitioned loops. (lower_omp_target): Call oacc_record_private_var_clauses with "target" clauses. Call mark_oacc_gangprivate for offloaded target regions. (lower_omp_1): Call vars_in_bind for GIMPLE_BIND within OMP regions. * target.def (expand_accel_var): New hook. libgomp/ * testsuite/libgomp.oacc-c-c++-common/gang-private-1.c: New test. * testsuite/libgomp.oacc-c-c++-common/loop-gwv-2.c: New test. * testsuite/libgomp.oacc-c/pr85465.c: New test. * testsuite/libgomp.oacc-fortran/gangprivate-attrib-1.f90: New test.