Commit Graph

398 Commits

Author SHA1 Message Date
Michael Matz fe37c7afd1 tree.h (TYPE_ALIGN, DECL_ALIGN): Return shifted amount.
* tree.h (TYPE_ALIGN, DECL_ALIGN): Return shifted amount.
	(SET_TYPE_ALIGN, SET_DECL_ALIGN): New.
	* tree-core.h (tree_type_common.align): Use bit-field.
	(tree_type_common.spare): New.
	(tree_decl_common.off_align): Make smaller.
	(tree_decl_common.align): Use bit-field.

	* expr.c (expand_expr_addr_expr_1): Use SET_TYPE_ALIGN.
	* omp-low.c (install_var_field): Use SET_DECL_ALIGN.
	(scan_sharing_clauses): Ditto.
	(finish_taskreg_scan): Use SET_DECL_ALIGN and SET_TYPE_ALIGN.
	(omp_finish_file): Ditto.
	* stor-layout.c (do_type_align): Use SET_DECL_ALIGN.
	(layout_decl): Ditto.
	(relayout_decl): Ditto.
	(finalize_record_size): Use SET_TYPE_ALIGN.
	(finalize_type_size): Ditto.
	(finish_builtin_struct): Ditto.
	(layout_type): Ditto.
	(initialize_sizetypes): Ditto.
	* targhooks.c (std_gimplify_va_arg_expr): Use SET_TYPE_ALIGN.
	* tree-nested.c (insert_field_into_struct): Use SET_TYPE_ALIGN.
	(lookup_field_for_decl): Use SET_DECL_ALIGN.
	(get_chain_field): Ditto.
	(get_trampoline_type): Ditto.
	(get_nl_goto_field): Ditto.
	* tree-streamer-in.c (unpack_ts_decl_common_value_fields): Use
	SET_DECL_ALIGN.
	(unpack_ts_type_common_value_fields): Use SET_TYPE_ALIGN.
	* gimple-expr.c (copy_var_decl): Use SET_DECL_ALIGN.
	* tree.c (make_node_stat): Use SET_DECL_ALIGN and SET_TYPE_ALIGN.
	(build_qualified_type): Use SET_TYPE_ALIGN.
	(build_aligned_type, build_range_type_1): Ditto.
	(build_atomic_base): Ditto.
	(build_common_tree_nodes): Ditto.
	* cfgexpand.c (align_local_variable): Use SET_DECL_ALIGN.
	(expand_one_stack_var_at): Ditto.
	* coverage.c (build_var): Use SET_DECL_ALIGN.
	* except.c (init_eh): Ditto.
	* function.c (assign_parm_setup_block): Ditto.
	* symtab.c (increase_alignment_1): Ditto.
	* tree-ssa-ccp.c (fold_builtin_alloca_with_align): Ditto.
	* tree-vect-stmts.c (ensure_base_align): Ditto.
	* varasm.c (align_variable): Ditto.
	(assemble_variable): Ditto.
	(build_constant_desc): Ditto.
	(output_constant_def_contents): Ditto.

	* config/arm/arm.c (arm_relayout_function): Use SET_DECL_ALIGN.
	* config/avr/avr.c (avr_adjust_type_node): Use SET_TYPE_ALIGN.
	* config/mips/mips.c (mips_std_gimplify_va_arg_expr): Ditto.
	* config/msp430/msp430.c (msp430_gimplify_va_arg_expr): Ditto.
	* config/spu/spu.c (spu_build_builtin_va_list): Use SET_DECL_ALIGN.

ada/
	* gcc-interface/decl.c (gnat_to_gnu_entity): Use SET_TYPE_ALIGN.
	(gnat_to_gnu_field): Ditto.
	(components_to_record): Ditto.
	(create_variant_part_from): Ditto.
	(copy_and_substitute_in_size): Ditto.
	(substitute_in_type): Ditto.
	* gcc-interface/utils.c (make_aligning_type): Use SET_TYPE_ALIGN.
	(make_packable_type): Ditto.
	(maybe_pad_type): Ditto.
	(finish_fat_pointer_type): Ditto.
	(finish_record_type): Ditto and use SET_DECL_ALIGN.
	(rest_of_record_type_compilation): Use SET_TYPE_ALIGN.
	(create_field_decl): Use SET_DECL_ALIGN.

c-family/
	* c-common.c (handle_aligned_attribute): Use SET_TYPE_ALIGN
	and SET_DECL_ALIGN.

c/
	* c-decl.c (merge_decls): Use SET_DECL_ALIGN and SET_TYPE_ALIGN.
	(grokdeclarator, parser_xref_tag, finish_enum): Use SET_TYPE_ALIGN.

cp/
	* class.c (build_vtable): Use SET_DECL_ALIGN and SET_TYPE_ALIGN.
	(layout_class_type): Ditto.
	(build_base_field): Use SET_DECL_ALIGN.
	(fixup_attribute_variants): Use SET_TYPE_ALIGN.
	* decl.c (duplicate_decls): Use SET_DECL_ALIGN.
	(record_unknown_type): Use SET_TYPE_ALIGN.
	(cxx_init_decl_processing): Ditto.
	(copy_type_enum): Ditto.
	(grokfndecl): Use SET_DECL_ALIGN.
	(copy_type_enum): Use SET_TYPE_ALIGN.
	* pt.c (instantiate_class_template_1): Use SET_TYPE_ALIGN.
	(tsubst): Ditto.
	* tree.c (cp_build_qualified_type_real): Use SET_TYPE_ALIGN.
	* lambda.c (maybe_add_lambda_conv_op): Use SET_DECL_ALIGN.
	* method.c (implicitly_declare_fn): Use SET_DECL_ALIGN.
	* rtti.c (emit_tinfo_decl): Ditto.

fortran/
	* trans-io.c (gfc_build_io_library_fndecls): Use SET_TYPE_ALIGN.
	* trans-common.c (build_common_decl): Use SET_DECL_ALIGN.
	* trans-types.c (gfc_add_field_to_struct): Use SET_DECL_ALIGN.

go/
	* go-gcc.cc (Gcc_backend::implicit_variable): Use SET_DECL_ALIGN.

java/
	* class.c (add_method_1): Use SET_DECL_ALIGN.
	(make_class_data): Ditto.
	(emit_register_classes_in_jcr_section): Ditto.
	* typeck.c (build_java_array_type): Ditto.

objc/
	* objc-act.c (objc_build_struct): Use SET_DECL_ALIGN.

libcc1/
	* plugin.cc (plugin_finish_record_or_union): Use SET_TYPE_ALIGN.

From-SVN: r235172
2016-04-18 20:36:27 +00:00
Thomas Schwinge 60cbb67477 Split out OMP constructs' SIMD clone supporting code
gcc/
	* omp-low.c (simd_clone_struct_alloc, simd_clone_struct_copy)
	(simd_clone_vector_of_formal_parm_types)
	(simd_clone_clauses_extract, simd_clone_compute_base_data_type)
	(simd_clone_mangle, simd_clone_create)
	(simd_clone_adjust_return_type, create_tmp_simd_array)
	(simd_clone_adjust_argument_types, simd_clone_init_simd_arrays)
	(struct modify_stmt_info, ipa_simd_modify_stmt_ops)
	(ipa_simd_modify_function_body, simd_clone_linear_addend)
	(simd_clone_adjust, expand_simd_clones, ipa_omp_simd_clone)
	(pass_data_omp_simd_clone, class pass_omp_simd_clone)
	(pass_omp_simd_clone::gate, make_pass_omp_simd_clone): Move
	into...
	* omp-simd-clone.c: ... this new file.
	(simd_clone_vector_of_formal_parm_types): Make it static.
	* Makefile.in (OBJS): Add omp-simd-clone.o.

From-SVN: r235017
2016-04-15 13:49:39 +02:00
Cesar Philippidis e387fc6494 re PR middle-end/70643 (broken openacc reduction inside a fortran module)
PR middle-end/70643

	gcc/
	* omp-low.c (lower_oacc_reductions): Check for TREE_CONSTANT
	when building a mem ref for the incoming reduction variable.

	libgomp/
	* testsuite/libgomp.oacc-fortran/pr70643.f90: New test.

From-SVN: r234973
2016-04-14 06:44:17 -07:00
Jakub Jelinek 21f3a2369b omp-low.c (lower_omp_target): Use GOMP_MAP_FIRSTPRIVATE_INT regardless whether there are depend clauses or not.
* omp-low.c (lower_omp_target): Use GOMP_MAP_FIRSTPRIVATE_INT
	regardless whether there are depend clauses or not.

	* libgomp.h (struct gomp_target_task): Remove firstprivate_copies
	field.
	* target.c (gomp_target_fallback_firstprivate,
	gomp_target_unshare_firstprivate): Removed.
	(GOMP_target_ext): Copy firstprivate vars into gomp_allocaed memory
	before waiting for dependencies.
	(gomp_target_task_fn): Don't copy firstprivate vars here.
	* task.c (GOMP_PLUGIN_target_task_completion): Don't free
	firstprivate_copies here.
	(gomp_create_target_task): Don't initialize firstprivate_copies field.
	* testsuite/libgomp.c/target-25.c (main): Use map (to:) instead of
	explicit/implicit firstprivate.

From-SVN: r234894
2016-04-12 09:05:29 +02:00
Cesar Philippidis c42cfb5ca3 re PR lto/70289 ([openacc] ICE in input_varpool_node)
gcc/
	PR lto/70289
	PR ipa/70348
	PR tree-optimization/70373
	PR middle-end/70533
	PR middle-end/70534
	PR middle-end/70535
	* gimplify.c (gimplify_adjust_omp_clauses): Add or adjust data
	clauses for acc parallel reductions as necessary.  Error on those
	that are private.
	* omp-low.c (scan_sharing_clauses): Don't install variables which
	are used in acc parallel reductions.
	(lower_rec_input_clauses): Remove dead code.
	(lower_oacc_reductions): Add support for reference reductions.
	(lower_reduction_clauses): Remove dead code.
	(lower_omp_target): Don't remap variables appearing in acc parallel
	reductions.
	* tree.h (OMP_CLAUSE_MAP_IN_REDUCTION): New macro.

	gcc/testsuite/
	* c-c++-common/goacc/reduction-5.c: New test.
	* c-c++-common/goacc/reduction-promotions.c: New test.
	* gfortran.dg/goacc/reduction-3.f95: New test.
	* gfortran.dg/goacc/reduction-promotions.f90: New test.

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/loop-reduction-gang-np-1.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/loop-reduction-gw-np-1.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/loop-reduction-gwv-np-1.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/loop-reduction-gwv-np-2.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/loop-reduction-gwv-np-3.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/loop-reduction-gwv-np-4.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/loop-reduction-vector-p-1.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/loop-reduction-vector-p-2.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/loop-reduction-worker-p-1.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/loop-reduction-wv-p-1.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/loop-reduction-wv-p-2.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/loop-reduction-wv-p-3.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-1.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-3.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-4.c: New
	test.
	* testsuite/libgomp.oacc-c-c++-common/par-reduction-1.c: Add test
	coverage.
	* testsuite/libgomp.oacc-c-c++-common/par-reduction-2.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/parallel-reduction.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/pr70289.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/pr70373.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/reduction-1.c: Add test
	coverage.
	* testsuite/libgomp.oacc-c-c++-common/reduction-2.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/reduction-3.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/reduction-4.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/reduction-5.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/reduction-6.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/reduction.h: New test.
	* testsuite/libgomp.oacc-fortran/parallel-reduction.f90: New test.
	* testsuite/libgomp.oacc-fortran/pr70289.f90: New test.
	* testsuite/libgomp.oacc-fortran/reduction-1.f90: Add test coverage.
	* testsuite/libgomp.oacc-fortran/reduction-2.f90: Likewise.
	* testsuite/libgomp.oacc-fortran/reduction-3.f90: Likewise.
	* testsuite/libgomp.oacc-fortran/reduction-4.f90: Likewise.
	* testsuite/libgomp.oacc-fortran/reduction-5.f90: Likewise.
	* testsuite/libgomp.oacc-fortran/reduction-6.f90: Likewise.
	* testsuite/libgomp.oacc-fortran/reduction-7.f90: New test.

From-SVN: r234840
2016-04-08 14:09:47 -07:00
Tom de Vries 9f1b833bc3 Remove incorrect warning for parallel implicit firstprivate clause
2016-04-08  Tom de Vries  <tom@codesourcery.com>

	* omp-low.c (lower_omp_target): Set TREE_NO_WARNING for oacc
	implicit firstprivate clause.

	* c-c++-common/goacc/uninit-firstprivate-clause.c: New test.
	* gfortran.dg/goacc/uninit-firstprivate-clause.f95: New test.

From-SVN: r234826
2016-04-08 09:41:16 +00:00
Jakub Jelinek 5f490f9f7a cgraph.h (struct cgraph_simd_clone): Add mask_mode field.
* cgraph.h (struct cgraph_simd_clone): Add mask_mode field.
	* omp-low.c (simd_clone_init_simd_arrays, simd_clone_adjust): Handle
	node->simdclone->mask_mode != VOIDmode masks.
	(simd_clone_adjust_argument_types): Likewise.  Move sc var definition
	earlier, use it instead of node->simdclone.
	* config/i386/i386.c (ix86_simd_clone_compute_vecsize_and_simdlen):
	Set clonei->mask_mode.

	* c-c++-common/attr-simd.c: Add scan-assembler* directives for AVX512F
	clones.
	* c-c++-common/attr-simd-2.c: Likewise.
	* c-c++-common/attr-simd-4.c: Likewise.
	* gcc.dg/gomp/simd-clones-2.c: Likewise.
	* gcc.dg/gomp/simd-clones-3.c: Likewise.

From-SVN: r234816
2016-04-07 23:32:05 +02:00
Patrick Palka 6b37bdaff1 Fix new -Wparentheses warnings encountered during bootstrap
gcc/ChangeLog:

	PR c/70436
	* gimplify.c (gimplify_omp_ordered): Add explicit braces to
	resolve a future -Wparentheses warning.
	* omp-low.c (scan_sharing_clauses): Likewise.
	* tree-parloops.c (eliminate_local_variables): Likewise.

gcc/cp/ChangeLog:

	PR c/70436
	* cp-tree.h (FOR_EACH_CLONE): Restructure macro to avoid
	potentially generating a future -Wparentheses warning in its
	callers.

gcc/fortran/ChangeLog:

	PR c/70436
	* openmp.c (gfc_find_omp_udr): Add explicit braces to resolve a
	future -Wparentheses warning.

gcc/testsuite/ChangeLog:

	PR c/70436
	* g++.dg/plugin/pragma_plugin.c (handle_pragma_sayhello): Add
	explicit braces to resolve a future -Wparentheses warning.

From-SVN: r234801
2016-04-06 23:07:21 +00:00
Jakub Jelinek ec35ea455c re PR middle-end/70550 (-Wuninitialized false positives in OpenMP code)
PR middle-end/70550
	* tree.h (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT): Define.
	* gimplify.c (gimplify_adjust_omp_clauses_1): Set it for implicit
	firstprivate clauses.
	* omp-low.c (lower_send_clauses): Set TREE_NO_WARNING for
	OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT !by_ref vars in task contexts.
	(lower_omp_target): Set TREE_NO_WARNING for
	non-addressable possibly uninitialized vars which are copied into
	addressable temporaries or copied for GOMP_MAP_FIRSTPRIVATE_INT.

	* c-c++-common/gomp/pr70550-1.c: New test.
	* c-c++-common/gomp/pr70550-2.c: New test.

From-SVN: r234779
2016-04-06 14:42:24 +02:00
Thomas Schwinge 91106e8435 Rename GOMP_MAP_FORCE_DEALLOC to GOMP_MAP_DELETE
Also rename the Fortran OMP_MAP_FORCE_DEALLOC to OMP_MAP_DELETE.

	include/
	* gomp-constants.h (enum gomp_map_kind): Rename
	GOMP_MAP_FORCE_DEALLOC to GOMP_MAP_DELETE.  Adjust all users.

	gcc/fortran/
	* gfortran.h (enum gfc_omp_map_op): Rename OMP_MAP_FORCE_DEALLOC
	to OMP_MAP_DELETE.  Adjust all users.

From-SVN: r234294
2016-03-17 16:07:54 +01:00
Nathan Sidwell 4ae13300cd re PR middle-end/69916 ([openacc] ICE in single_succ_edge called from oacc_loop_xform_loop)
gcc/
	PR middle-end/69916
	* omp-low.c (struct oacc_loop): Add ifns.
	(new_oacc_loop_raw): Initialize it.
	(finish_oacc_loop): Clear mask & flags if no ifns.
	(oacc_loop_discover_walk): Count IFN_GOACC_LOOP calls.
	(oacc_loop_xform_loop): Add ifns arg & adjust.
	(oacc_loop_process): Adjust oacc_loop_xform_loop call.

	gcc/testsuite/
	PR middle-end/69916
	* c-c-++-common/goacc/pr69916.c: New.

From-SVN: r234026
2016-03-07 13:22:07 +00:00
Tom de Vries 640b7e7439 Handle oacc region in oacc routine
2016-03-05  Tom de Vries  <tom@codesourcery.com>

	* omp-low.c (check_omp_nesting_restrictions): Check for non-oacc
	construct in oacc routine.  Check for oacc region in oacc routine.

	* c-c++-common/goacc/nesting-fail-1.c (f_acc_routine): New function.
	* c-c++-common/goacc-gomp/nesting-fail-1.c (f_acc_routine): New
	function.

From-SVN: r233998
2016-03-05 02:48:30 +00:00
Jakub Jelinek da3d46cba8 re PR libgomp/69555 (libgomp.c++/target-6.C fails because of undefined behaviour)
PR libgomp/69555
	* gimplify.c (gimplify_decl_expr): For decls with REFERENCE_TYPE, also
	gimplify_type_sizes the type they refer to.
	(omp_notice_variable): Handle reference vars to VLAs.
	* omp-low.c (lower_omp_target): Emit setup of OMP_CLAUSE_PRIVATE reference
	to VLA decls in the second pass instead of first pass.

	* testsuite/libgomp.c++/pr69555-1.C: New test.
	* testsuite/libgomp.c++/pr69555-2.C: New test.

From-SVN: r233913
2016-03-02 20:16:14 +01:00
Martin Jambor 9ece21a6c5 [omp, hsa] Do not gridify simd constructs
2016-02-26  Martin Jambor  <mjambor@suse.cz>

	* omp-low.c (grid_find_ungridifiable_statement): Store problematic
	statements to wi->info.  Also disallow omp simd constructs.
	(grid_target_follows_gridifiable_pattern): Use wi.info to dump reason
	for not gridifying.  Dump special string for omp_for.

From-SVN: r233746
2016-02-26 18:35:29 +01:00
Tom de Vries 2175df996b Don't call call_cgraph_insertion_hooks in simd_clone_create
2016-02-16  Tom de Vries  <tom@codesourcery.com>

	PR lto/67709
	* omp-low.c (simd_clone_create): Remove call to
	symtab->call_cgraph_insertion_hooks.

	* testsuite/libgomp.fortran/declare-simd-4.f90: New test.

From-SVN: r233447
2016-02-16 09:23:09 +00:00
Thomas Schwinge 18f6014649 Merge BUILT_IN_GOACC_HOST_DATA into BUILT_IN_GOACC_DATA_START
gcc/
	* omp-builtins.def (BUILT_IN_GOACC_HOST_DATA): Remove.
	* omp-low.c (expand_omp_target): Use BUILT_IN_GOACC_DATA_START
	instead.
	libgomp/
	* libgomp.map (GOACC_2.0): Remove GOACC_host_data.
	* oacc-parallel.c (GOACC_host_data): Remove function definition.

From-SVN: r233074
2016-02-02 14:53:55 +01:00
Jakub Jelinek 8131b4d77f omp-low.c (oacc_parse_default_dims): Avoid -Wsign-compare warning...
* omp-low.c (oacc_parse_default_dims): Avoid
	-Wsign-compare warning, make sure value fits into int
	rather than just unsigned int.

From-SVN: r233044
2016-02-01 20:14:59 +01:00
Nathan Sidwell b6adbb9faa nvptx.c (PTX_GANG_DEFAULT): New.
gcc/
	* config/nvptx/nvptx.c (PTX_GANG_DEFAULT): New.
	(nvptx_goacc_validate_dims): Extend to handle global defaults.
	* target.def (OACC_VALIDATE_DIMS): Extend documentation.
	* doc/tm.texti: Rebuilt.
	* doc/invoke.texi (fopenacc-dim): Document.
	* lto-wrapper.c (merge_and_complain): Add OPT_fopenacc_dim_ case.
	(append_compiler_options): Likewise.
	* omp-low.c (oacc_default_dims, oacc_min_dims): New.
	(oacc_parse_default_dims): New.
	(oacc_validate_dims): Add USED arg.  Select non-unity default when
	possible.
	(oacc_loop_fixed_partitions): Return mask of used partitions.
	(oacc_loop_auto_partitions): Emit dump info.
	(oacc_loop_partition): Return mask of used partitions.
	(execute_oacc_device_lower): Parse default dimension arg.  Adjust
	loop partitioning and validation calls.

	gcc/c-family/
	* c.opt (fopenacc-dim=): New option.

	gcc/fortran/
	* lang.opt (fopenacc-dim=): New option.

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c: New.
	* testsuite/libgomp.oacc-fortran/routine-7.f90: Serialize loop.

From-SVN: r233041
2016-02-01 16:20:13 +00:00
Nathan Sidwell f8393eb0f0 omp-low.h (oacc_fn_attrib_kernels_p): Declare.
* omp-low.h (oacc_fn_attrib_kernels_p): Declare.
	(set_oacc_fn_attrib): Add IS_KERNEL arg.
	* omp-low.c (set_oacc_fn_attrib): Add IS_KERNEL arg.
	(oacc_fn_attrib_kernels_p, oacc_fn_attrib_level): New.
	(expand_omp_target): Pass is_kernel to set_oacc_fn_attrib.
	(oacc_validate_dims): Add LEVEL arg, don't return level.
	(new_oacc_loop_routine): Use oacc_fn_attrib_level, not
	oacc_validate_dims.
	(execute_oacc_device_lower): Adjust, add more dump output.
	* tree-ssa-loop.c (gate_oacc_kernels): Use
	oacc_fn_attrib_kernels_p.
	* tree-parloops.c (create_parallel_loop): Adjust
	set_oacc_fn_attrib call.

From-SVN: r232830
2016-01-26 14:32:30 +00:00
Jakub Jelinek d902b330dc omp-low.c (lower_omp_target): Set DECL_VALUE_EXPR of new_var even for the non-array case.
* omp-low.c (lower_omp_target) <case USE_DEVICE_PTR>: Set
	DECL_VALUE_EXPR of new_var even for the non-array case.  Look
	through DECL_VALUE_EXPR for expansion.

	* c-c++-common/goacc/use_device-1.c: New test.

From-SVN: r232804
2016-01-25 22:34:06 +01:00
Jakub Jelinek 73bfae68eb omp-low.c (expand_omp_target): Avoid -Wmaybe-uninitialized warning.
* omp-low.c (expand_omp_target): Avoid -Wmaybe-uninitialized
	warning.  Fix up formatting.

From-SVN: r232641
2016-01-21 00:55:38 +01:00
Martin Jambor b2b4005150 Merge of HSA
2016-01-19  Martin Jambor  <mjambor@suse.cz>
	    Martin Liska  <mliska@suse.cz>
	    Michael Matz <matz@suse.de>

libgomp/
	* plugin/Makefrag.am: Add HSA plugin requirements.
	* plugin/configfrag.ac (HSA_RUNTIME_INCLUDE): New variable.
	(HSA_RUNTIME_LIB): Likewise.
	(HSA_RUNTIME_CPPFLAGS): Likewise.
	(HSA_RUNTIME_INCLUDE): New substitution.
	(HSA_RUNTIME_LIB): Likewise.
	(HSA_RUNTIME_LDFLAGS): Likewise.
	(hsa-runtime): New configure option.
	(hsa-runtime-include): Likewise.
	(hsa-runtime-lib): Likewise.
	(PLUGIN_HSA): New substitution variable.
	Fill HSA_RUNTIME_INCLUDE and HSA_RUNTIME_LIB according to the new
	configure options.
	(PLUGIN_HSA_CPPFLAGS): Likewise.
	(PLUGIN_HSA_LDFLAGS): Likewise.
	(PLUGIN_HSA_LIBS): Likewise.
	Check that we have access to HSA run-time.
	* libgomp-plugin.h (offload_target_type): New element
	OFFLOAD_TARGET_TYPE_HSA.
	* libgomp.h (gomp_target_task): New fields firstprivate_copies and
	args.
	(bool gomp_create_target_task): Updated.
	(gomp_device_descr): Extra parameter of run_func and async_run_func,
	new field can_run_func.
	* libgomp_g.h (GOMP_target_ext): Update prototype.
	* oacc-host.c (host_run): Added a new parameter args.
	* target.c (calculate_firstprivate_requirements): New function.
	(copy_firstprivate_data): Likewise.
	(gomp_target_fallback_firstprivate): Use them.
	(gomp_target_unshare_firstprivate): New function.
	(gomp_get_target_fn_addr): Allow returning NULL for shared memory
	devices.
	(GOMP_target): Do host fallback for all shared memory devices.  Do not
	pass any args to plugins.
	(GOMP_target_ext): Introduce device-specific argument parameter args.
	Allow host fallback if device shares memory.  Do not remap data if
	device has shared memory.
	(gomp_target_task_fn): Likewise.  Also treat shared memory devices
	like host fallback for mappings.
	(GOMP_target_data): Treat shared memory devices like host fallback.
	(GOMP_target_data_ext): Likewise.
	(GOMP_target_update): Likewise.
	(GOMP_target_update_ext): Likewise.  Also pass NULL as args to
	gomp_create_target_task.
	(GOMP_target_enter_exit_data): Likewise.
	(omp_target_alloc): Treat shared memory devices like host fallback.
	(omp_target_free): Likewise.
	(omp_target_is_present): Likewise.
	(omp_target_memcpy): Likewise.
	(omp_target_memcpy_rect): Likewise.
	(omp_target_associate_ptr): Likewise.
	(gomp_load_plugin_for_device): Also load can_run.
	* task.c (GOMP_PLUGIN_target_task_completion): Free
	firstprivate_copies.
	(gomp_create_target_task): Accept new argument args and store it to
	ttask.
	* plugin/plugin-hsa.c: New file.

gcc/
	* Makefile.in (OBJS): Add new source files.
	(GTFILES): Add hsa.c.
	* common.opt (disable_hsa): New variable.
	(-Whsa): New warning.
	* config.in (ENABLE_HSA): New.
	* configure.ac: Treat hsa differently from other accelerators.
	(OFFLOAD_TARGETS): Define ENABLE_OFFLOADING according to
	$enable_offloading.
	(ENABLE_HSA): Define ENABLE_HSA according to $enable_hsa.
	* doc/install.texi (Configuration): Document --with-hsa-runtime,
	--with-hsa-runtime-include, --with-hsa-runtime-lib and
	--with-hsa-kmt-lib.
	* doc/invoke.texi (-Whsa): Document.
	(hsa-gen-debug-stores): Likewise.
	* lto-wrapper.c (compile_images_for_offload_targets): Do not attempt
	to invoke offload compiler for hsa acclerator.
	* opts.c (common_handle_option): Determine whether HSA offloading
	should be performed.
	* params.def (PARAM_HSA_GEN_DEBUG_STORES): New parameter.
	* builtin-types.def (BT_FN_VOID_UINT_PTR_INT_PTR): New.
	(BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_INT_INT): Removed.
	(BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_PTR): New.
	* gimple-low.c (lower_stmt): Also handle GIMPLE_OMP_GRID_BODY.
	* gimple-pretty-print.c (dump_gimple_omp_for): Also handle
	GF_OMP_FOR_KIND_GRID_LOOP.
	(dump_gimple_omp_block): Also handle GIMPLE_OMP_GRID_BODY.
	(pp_gimple_stmt_1): Likewise.
	* gimple-walk.c (walk_gimple_stmt): Likewise.
	* gimple.c (gimple_build_omp_grid_body): New function.
	(gimple_copy): Also handle GIMPLE_OMP_GRID_BODY.
	* gimple.def (GIMPLE_OMP_GRID_BODY): New.
	* gimple.h (enum gf_mask): Added GF_OMP_PARALLEL_GRID_PHONY,
	GF_OMP_FOR_KIND_GRID_LOOP, GF_OMP_FOR_GRID_PHONY and
	GF_OMP_TEAMS_GRID_PHONY.
	(gimple_statement_omp_single_layout): Updated comments.
	(gimple_build_omp_grid_body): New function.
	(gimple_has_substatements): Also handle GIMPLE_OMP_GRID_BODY.
	(gimple_omp_for_grid_phony): New function.
	(gimple_omp_for_set_grid_phony): Likewise.
	(gimple_omp_parallel_grid_phony): Likewise.
	(gimple_omp_parallel_set_grid_phony): Likewise.
	(gimple_omp_teams_grid_phony): Likewise.
	(gimple_omp_teams_set_grid_phony): Likewise.
	(gimple_return_set_retbnd): Also handle GIMPLE_OMP_GRID_BODY.
	* omp-builtins.def (BUILT_IN_GOMP_OFFLOAD_REGISTER): New.
	(BUILT_IN_GOMP_OFFLOAD_UNREGISTER): Likewise.
	(BUILT_IN_GOMP_TARGET): Updated type.
	* omp-low.c: Include symbol-summary.h, hsa.h and params.h.
	(adjust_for_condition): New function.
	(get_omp_for_step_from_incr): Likewise.
	(extract_omp_for_data): Moved parts to adjust_for_condition and
	get_omp_for_step_from_incr.
	(build_outer_var_ref): Handle GIMPLE_OMP_GRID_BODY.
	(fixup_child_record_type): Bail out if receiver_decl is NULL.
	(scan_sharing_clauses): Handle OMP_CLAUSE__GRIDDIM_.
	(scan_omp_parallel): Do not create child functions for phony
	constructs.
	(check_omp_nesting_restrictions): Handle GIMPLE_OMP_GRID_BODY.
	(scan_omp_1_op): Checking assert we are not remapping to
	ERROR_MARK.  Also also handle GIMPLE_OMP_GRID_BODY.
	(parallel_needs_hsa_kernel_p): New function.
	(expand_parallel_call): Register apprpriate parallel child
	functions as HSA kernels.
	(grid_launch_attributes_trees): New type.
	(grid_attr_trees): New variable.
	(grid_create_kernel_launch_attr_types): New function.
	(grid_insert_store_range_dim): Likewise.
	(grid_get_kernel_launch_attributes): Likewise.
	(get_target_argument_identifier_1): Likewise.
	(get_target_argument_identifier): Likewise.
	(get_target_argument_value): Likewise.
	(push_target_argument_according_to_value): Likewise.
	(get_target_arguments): Likewise.
	(expand_omp_target): Call get_target_arguments instead of looking
	up for teams and thread limit.
	(grid_expand_omp_for_loop): New function.
	(grid_arg_decl_map): New type.
	(grid_remap_kernel_arg_accesses): New function.
	(grid_expand_target_kernel_body): New function.
	(expand_omp): Call it.
	(lower_omp_for): Do not emit phony constructs.
	(lower_omp_taskreg): Do not emit phony constructs but create for them
	a temporary variable receiver_decl.
	(lower_omp_taskreg): Do not emit phony constructs.
	(lower_omp_teams): Likewise.
	(lower_omp_grid_body): New function.
	(lower_omp_1): Call it.
	(grid_reg_assignment_to_local_var_p): New function.
	(grid_seq_only_contains_local_assignments): Likewise.
	(grid_find_single_omp_among_assignments_1): Likewise.
	(grid_find_single_omp_among_assignments): Likewise.
	(grid_find_ungridifiable_statement): Likewise.
	(grid_target_follows_gridifiable_pattern): Likewise.
	(grid_remap_prebody_decls): Likewise.
	(grid_copy_leading_local_assignments): Likewise.
	(grid_process_kernel_body_copy): Likewise.
	(grid_attempt_target_gridification): Likewise.
	(grid_gridify_all_targets_stmt): Likewise.
	(grid_gridify_all_targets): Likewise.
	(execute_lower_omp): Call grid_gridify_all_targets.
	(make_gimple_omp_edges): Handle GIMPLE_OMP_GRID_BODY.
	* tree-core.h (omp_clause_code): Added OMP_CLAUSE__GRIDDIM_.
	(tree_omp_clause): Added union field dimension.
	* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE__GRIDDIM_.
	* tree.c (omp_clause_num_ops): Added number of arguments of
	OMP_CLAUSE__GRIDDIM_.
	(omp_clause_code_name): Added name of OMP_CLAUSE__GRIDDIM_.
	(walk_tree_1): Handle OMP_CLAUSE__GRIDDIM_.
	* tree.h (OMP_CLAUSE_GRIDDIM_DIMENSION): New.
	(OMP_CLAUSE_SET_GRIDDIM_DIMENSION): Likewise.
	(OMP_CLAUSE_GRIDDIM_SIZE): Likewise.
	(OMP_CLAUSE_GRIDDIM_GROUP): Likewise.
	* passes.def: Schedule pass_ipa_hsa and pass_gen_hsail.
	* tree-pass.h (make_pass_gen_hsail): Declare.
	(make_pass_ipa_hsa): Likewise.
	* ipa-hsa.c: New file.
	* lto-section-in.c (lto_section_name): Add hsa section name.
	* lto-streamer.h (lto_section_type): Add hsa section.
	* timevar.def (TV_IPA_HSA): New.
        * hsa-brig-format.h: New file.
	* hsa-brig.c: New file.
	* hsa-dump.c: Likewise.
	* hsa-gen.c: Likewise.
	* hsa.c: Likewise.
	* hsa.h: Likewise.
	* toplev.c (compile_file): Call hsa_output_brig.
	* hsa-regalloc.c: New file.

gcc/fortran/
	* types.def (BT_FN_VOID_UINT_PTR_INT_PTR): New.
	(BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_INT_INT): Removed.
	(BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_PTR): New.

gcc/lto/
	* lto-partition.c: Include "hsa.h"
	(add_symbol_to_partition_1): Put hsa implementations into the
	same partition as host implementations.

liboffloadmic/
	* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_async_run): New
	unused parameter.
	(GOMP_OFFLOAD_run): Likewise.

include/
	* gomp-constants.h (GOMP_DEVICE_HSA): New macro.
	(GOMP_VERSION_HSA): Likewise.
	(GOMP_TARGET_ARG_DEVICE_MASK): Likewise.
	(GOMP_TARGET_ARG_DEVICE_ALL): Likewise.
	(GOMP_TARGET_ARG_SUBSEQUENT_PARAM): Likewise.
	(GOMP_TARGET_ARG_ID_MASK): Likewise.
	(GOMP_TARGET_ARG_NUM_TEAMS): Likewise.
	(GOMP_TARGET_ARG_THREAD_LIMIT): Likewise.
	(GOMP_TARGET_ARG_VALUE_SHIFT): Likewise.
	(GOMP_TARGET_ARG_HSA_KERNEL_ATTRIBUTES): Likewise.

From-SVN: r232549
2016-01-19 11:35:10 +01:00
Tom de Vries 61d9c5274e Add oacc_kernels_p argument to pass_parallelize_loops
2016-01-18  Tom de Vries  <tom@codesourcery.com>

	* omp-low.c (set_oacc_fn_attrib): Make extern.
	* omp-low.h (set_oacc_fn_attrib): Declare.
	* tree-parloops.c (struct reduction_info): Add reduc_addr field.
	(create_call_for_reduction_1): Handle case that reduc_addr is non-NULL.
	(create_parallel_loop, gen_parallel_loop, try_create_reduction_list):
	Add and handle function parameter oacc_kernels_p.
	(find_reduc_addr, get_omp_data_i_param): New function.
	(ref_conflicts_with_region, oacc_entry_exit_ok_1)
	(oacc_entry_exit_single_gang, oacc_entry_exit_ok): New function.
	(parallelize_loops): Add and handle function parameter oacc_kernels_p.
	Calculate dominance info.  Skip loops that are not in a kernels region
	in oacc_kernels_p mode.  Skip inner loops of parallelized loops.
	(pass_parallelize_loops::execute): Call parallelize_loops with
	oacc_kernels_p argument.
	(pass_parallelize_loops::clone, pass_parallelize_loops::set_pass_param):
	New member function.
	(pass_parallelize_loops::bool oacc_kernels_p): New member var.
	* passes.def: Add argument to pass_parallelize_loops instantation.

From-SVN: r232512
2016-01-18 12:52:32 +00:00
Jakub Jelinek 3f217497ca omp-low.c (mark_loops_in_oacc_kernels_region): Work around -Wmaybe-uninitialized warning.
* omp-low.c (mark_loops_in_oacc_kernels_region): Work around
	-Wmaybe-uninitialized warning.

From-SVN: r232484
2016-01-17 19:04:47 +01:00
Tom de Vries 0b0521ba46 Release_defs in expand_omp_atomic_fetch_op
2016-01-16  Tom de Vries  <tom@codesourcery.com>

	* omp-low.c (expand_omp_atomic_fetch_op):  Release defs of update stmt.

From-SVN: r232472
2016-01-16 22:18:56 +00:00
Tom de Vries e6d6ec9e06 Mark symbols in offload tables with force_output in read_offload_tables
2016-01-14  Tom de Vries  <tom@codesourcery.com>

	PR tree-optimization/68773
	* c-parser.c (c_parser_oacc_declare, c_parser_omp_declare_target): Don't
	set force_output.

	* parser.c (cp_parser_oacc_declare, cp_parser_omp_declare_target): Don't
	set force_output.

	* omp-low.c (expand_omp_target): Don't set force_output.
	* varpool.c (varpool_node::get_create): Same.
	* lto-cgraph.c (input_offload_tables): Mark entries in offload_vars and
	offload_funcs with force_output.

From-SVN: r232384
2016-01-14 20:01:39 +00:00
Jakub Jelinek 818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Thomas Schwinge c7b48c8ae5 Merge OMP_CLAUSE_USE_DEVICE into OMP_CLAUSE_USE_DEVICE_PTR
gcc/c/
	* c-parser.c (c_parser_oacc_clause_use_device): Merge function
	into...
	(c_parser_omp_clause_use_device_ptr): ... this function.  Adjust
	all users.
	gcc/
	* tree-core.h (enum omp_clause_code): Merge OMP_CLAUSE_USE_DEVICE
	into OMP_CLAUSE_USE_DEVICE_PTR.  Adjust all users.

From-SVN: r231926
2015-12-23 12:01:18 +01:00
Ilya Verbin 4a38b02b4e c-common.c (c_common_attribute_table): Handle "omp declare target link" attribute.
gcc/c-family/
	* c-common.c (c_common_attribute_table): Handle "omp declare target
	link" attribute.
gcc/
	* cgraphunit.c (output_in_order): Do not assemble "omp declare target
	link" variables in ACCEL_COMPILER.
	* gimplify.c (gimplify_adjust_omp_clauses): Do not remove mapping of
	"omp declare target link" variables.
	* omp-low.c (scan_sharing_clauses): Do not remove mapping of "omp
	declare target link" variables.
	(add_decls_addresses_to_decl_constructor): For "omp declare target link"
	variables output address of the artificial pointer instead of address of
	the variable.  Set most significant bit of the size to mark them.
	(pass_data_omp_target_link): New pass_data.
	(pass_omp_target_link): New class.
	(find_link_var_op): New static function.
	(make_pass_omp_target_link): New function.
	* passes.def: Add pass_omp_target_link.
	* tree-pass.h (make_pass_omp_target_link): Declare.
	* varpool.c (symbol_table::output_variables): Do not assemble "omp
	declare target link" variables in ACCEL_COMPILER.
gcc/lto/
	* lto.c: Include stringpool.h and fold-const.h.
	(offload_handle_link_vars): New static function.
	(lto_main): Call offload_handle_link_vars.
libgomp/
	* libgomp.h (REFCOUNT_LINK): Define.
	(struct splay_tree_key_s): Add link_key.
	* target.c (gomp_map_vars): Treat REFCOUNT_LINK objects as not mapped.
	Replace target address of the pointer with target address of newly
	mapped object in the splay tree.  Set link pointer on target to the
	device address of the mapped object.
	(gomp_unmap_vars): Restore target address of the pointer in the splay
	tree for REFCOUNT_LINK objects after unmapping.
	(gomp_load_image_to_device): Set refcount to REFCOUNT_LINK for "omp
	declare target link" objects.
	(gomp_unload_image_from_device): Replace j with i.  Force unmap of all
	"omp declare target link" objects, which were mapped for the image.
	(gomp_exit_data): Restore target address of the pointer in the splay
	tree for REFCOUNT_LINK objects after unmapping.
	* testsuite/libgomp.c/target-link-1.c: New file.

From-SVN: r231655
2015-12-15 14:56:50 +00:00
Tom de Vries 8498c16b04 Clear restrict in install_var_field
2015-12-08  Tom de Vries  <tom@codesourcery.com>

	PR tree-optimization/68640
	* omp-low.c (install_var_field): Clear the restrict qualifier on the var
	type.

From-SVN: r231411
2015-12-08 14:17:42 +00:00
Tom de Vries 86938de6f6 Mark pointers to allocated target vars as restricted, if possible
2015-12-02  Tom de Vries  <tom@codesourcery.com>

	* omp-low.c (install_var_field, scan_sharing_clauses): Add and handle
	parameter base_pointers_restrict.
	(omp_target_base_pointers_restrict_p): New function.
	(scan_omp_target): Call scan_sharing_clauses with base_pointers_restrict
	arg.

	* c-c++-common/goacc/kernels-alias-2.c: New test.
	* c-c++-common/goacc/kernels-alias-3.c: New test.
	* c-c++-common/goacc/kernels-alias-4.c: New test.
	* c-c++-common/goacc/kernels-alias-5.c: New test.
	* c-c++-common/goacc/kernels-alias-6.c: New test.
	* c-c++-common/goacc/kernels-alias-7.c: New test.
	* c-c++-common/goacc/kernels-alias-8.c: New test.
	* c-c++-common/goacc/kernels-alias.c: New test.

From-SVN: r231182
2015-12-02 15:48:35 +00:00
Julian Brown 37d5ad46dd OpenACC host_data support.
gcc/
	* gimple-pretty-print.c (dump_gimple_omp_target): Add host_data
	support.
	* gimple.h (gf_mask): Add GF_OMP_TARGET_KIND_OACC_HOST_DATA.
	(is_gimple_omp_oacc): Add support for above.
	* gimplify.c (omp_region_type): Add ORT_ACC_HOST_DATA.
	(omp_notice_variable): Diagnose undefined implicit uses of
	use_device variables in offloaded regions.
	(gimplify_scan_omp_clauses): Add host_data, use_device
	support. Diagnose undefined mapping of use_device variables in
	OpenACC clauses.
	(gimplify_omp_workshare): Add host_data support.
	(gimplify_expr): Likewise.
	* omp-builtins.def (BUILT_IN_GOACC_HOST_DATA): New.
	* omp-low.c (lookup_decl_in_outer_ctx)
	(maybe_lookup_decl_in_outer_ctx): Add optional argument to skip
	host_data regions.
	(scan_sharing_clauses): Support use_device.
	(check_omp_nesting_restrictions): Support host_data.
	(expand_omp_target): Support host_data.
	(lower_omp_target): Skip over outer host_data regions when looking
	up decls. Support use_device.
	(make_gimple_omp_edges): Support host_data.
	* tree-nested.c (convert_nonlocal_omp_clauses): Add use_device
	clause.

	gcc/c/
	* c-parser.c (c_parser_omp_clause_name): Add use_device support.
	(c_parser_oacc_clause_use_device): New function.
	(c_parser_oacc_all_clauses): Add use_device support.
	(OACC_HOST_DATA_CLAUSE_MASK): New macro.
	(c_parser_oacc_host_data): New function.
	(c_parser_omp_construct): Add host_data support.
	* c-tree.h (c_finish_oacc_host_data): Add prototype.
	* c-typeck.c (c_finish_oacc_host_data): New function.
	(c_finish_omp_clauses): Add use_device support.

	gcc/cp/
	* cp-tree.h (finish_oacc_host_data): Add prototype.
	* parser.c (cp_parser_omp_clause_name): Add use_device support.
	(cp_parser_oacc_all_clauses): Add use_device support.
	(OACC_HOST_DATA_CLAUSE_MASK): New macro.
	(cp_parser_oacc_host_data): New function.
	(cp_parser_omp_construct): Add host_data support.
	(cp_parser_pragma): Add host_data support.
	* semantics.c (finish_omp_clauses): Add use_device support.
	(finish_oacc_host_data): New function.

	gcc/c-family/
	* c-pragma.c (oacc_pragmas): Add PRAGMA_OACC_HOST_DATA.
	* c-pragma.h (pragma_kind): Add PRAGMA_OACC_HOST_DATA.
	(pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_USE_DEVICE.

	libgomp/
	* oacc-parallel.c (GOACC_host_data): New function.
	* libgomp.map (GOACC_host_data): Add to GOACC_2.0.1.
	* testsuite/libgomp.oacc-c-c++-common/host_data-1.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/host_data-2.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/host_data-3.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/host_data-4.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/host_data-5.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/host_data-6.c: New test.


Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com>
Co-Authored-By: James Norris <James_Norris@mentor.com>

From-SVN: r231118
2015-12-01 15:52:23 +00:00
Tom de Vries 09c5c12e56 Revert "Improve verification of loop->latch in verify_loop_structure"
2015-11-26  Tom de Vries  <tom@codesourcery.com>

	revert:
	2015-11-25  Tom de Vries  <tom@codesourcery.com>

	* cfgloop.c (find_single_latch): New function, factored out of ...
	(flow_loops_find): ... here.
	(verify_loop_structure): Improve verification of loop->latch.
	* cfgloop.h (find_single_latch): Declare.
	* omp-low.c (expand_omp_for_generic): Initialize latch of orig_loop.

From-SVN: r230967
2015-11-26 14:35:27 +00:00
Jakub Jelinek 1a80d6b87d re PR tree-optimization/68128 (A huge regression in Parboil v2.5 OpenMP CUTCP test (2.5 times lower performance))
PR tree-optimization/68128
	* tree.h (OMP_CLAUSE_SHARED_READONLY): Define.
	* gimplify.c: Include gimple-walk.h.
	(enum gimplify_omp_var_data): Add GOVD_WRITTEN.
	(omp_notice_variable): Set flags to n->value if n already
	exists in target region, but we need to jump to do_outer.
	(omp_shared_to_firstprivate_optimizable_decl_p,
	omp_mark_stores, omp_find_stores_op, omp_find_stores_stmt): New
	functions.
	(gimplify_adjust_omp_clauses_1): Set OMP_CLAUSE_SHARED_READONLY
	on OMP_CLAUSE_SHARED if it is a scalar non-addressable that is
	not modified in the body.  Call omp_mark_stores for outer
	contexts on OMP_CLAUSE_SHARED clauses if they could be written
	in the body or on OMP_CLAUSE_LASTPRIVATE.
	(gimplify_adjust_omp_clauses): Add body argument, call
	omp_find_stores_{stmt,op} on the body through walk_gimple_seq.
	Set OMP_CLAUSE_SHARED_READONLY
	on OMP_CLAUSE_SHARED if it is a scalar non-addressable that is
	not modified in the body.  Call omp_mark_stores for outer
	contexts on OMP_CLAUSE_SHARED clauses if they could be written
	in the body or on OMP_CLAUSE_LASTPRIVATE or on OMP_CLAUSE_LINEAR
	without OMP_CLAUSE_LINEAR_NO_COPYOUT or on OMP_CLAUSE_REDUCTION.
	(gimplify_oacc_cache, gimplify_omp_parallel, gimplify_omp_task,
	gimplify_omp_for, gimplify_omp_workshare, gimplify_omp_target_update,
	gimplify_expr): Adjust gimplify_adjust_omp_clauses callers.
	* tree-nested.c (convert_nonlocal_omp_clauses,
	convert_local_omp_clauses): Clear OMP_CLAUSE_SHARED_READONLY on
	non-local vars or local vars referenced from nested routines.
	* omp-low.c (scan_sharing_clauses): For OMP_CLAUSE_SHARED_READONLY
	attempt to optimize it into OMP_CLAUSE_FIRSTPRIVATE.  Even for
	TREE_READONLY, don't call use_pointer_for_field with non-NULL
	second argument until we are sure we are keeping OMP_CLAUSE_SHARED.

	* gcc.dg/gomp/pr68128-1.c: New test.
	* gcc.dg/gomp/pr68128-2.c: New test.

From-SVN: r230932
2015-11-26 11:18:50 +01:00
Tom de Vries b5f34b425a Add pass_oacc_kernels pass group in passes.def
2015-11-25  Tom de Vries  <tom@codesourcery.com>

	* omp-low.c (pass_expand_omp_ssa::clone): New function.
	* passes.def: Add pass_oacc_kernels pass group.
	* tree-ssa-loop-ch.c (pass_ch::clone): New function.

	* g++.dg/tree-ssa/copyprop-1.C: Update after adding new dce1.
	* gcc.dg/pr23911.c: Same.
	* gcc.dg/tree-ssa/20030709-2.c: Same.
	* gcc.dg/tree-ssa/20030731-2.c: Same.
	* gcc.dg/tree-ssa/20040729-1.c: Same.
	* gcc.dg/tree-ssa/cfgcleanup-1.c: Same.
	* gcc.dg/tree-ssa/loop-36.c: Same.
	* gcc.dg/tree-ssa/pr21086.c: Same.
	* gcc.dg/tree-ssa/ssa-dce-1.c: Same.
	* gcc.dg/tree-ssa/ssa-dce-2.c: Same.
	* gcc.dg/vect/pr26359.c: Same.
	* c-c++-common/restrict-2.c: Update after adding new lim1.
	* c-c++-common/restrict-4.c: Same.
	* g++.dg/tree-ssa/pr33615.C: Same.
	* g++.dg/tree-ssa/restrict1.C: Same.
	* gcc.dg/tm/pub-safety-1.c: Same.
	* gcc.dg/tm/reg-promotion.c: Same.
	* gcc.dg/tree-ssa/20050314-1.c: Same.
	* gcc.dg/tree-ssa/loop-32.c: Same.
	* gcc.dg/tree-ssa/loop-33.c: Same.
	* gcc.dg/tree-ssa/loop-34.c: Same.
	* gcc.dg/tree-ssa/loop-35.c: Same.
	* gcc.dg/tree-ssa/loop-7.c: Same.
	* gcc.dg/tree-ssa/pr23109.c: Same.
	* gcc.dg/tree-ssa/restrict-3.c: Same.
	* gcc.dg/tree-ssa/restrict-5.c: Same.
	* gcc.dg/tree-ssa/ssa-lim-1.c: Same.
	* gcc.dg/tree-ssa/ssa-lim-10.c: Same.
	* gcc.dg/tree-ssa/ssa-lim-11.c: Same.
	* gcc.dg/tree-ssa/ssa-lim-12.c: Same.
	* gcc.dg/tree-ssa/ssa-lim-2.c: Same.
	* gcc.dg/tree-ssa/ssa-lim-3.c: Same.
	* gcc.dg/tree-ssa/ssa-lim-6.c: Same.
	* gcc.dg/tree-ssa/ssa-lim-7.c: Same.
	* gcc.dg/tree-ssa/ssa-lim-8.c: Same.
	* gcc.dg/tree-ssa/ssa-lim-9.c: Same.
	* gcc.dg/tree-ssa/structopt-1.c: Same.
	* gfortran.dg/pr32921.f: Same.
	* g++.dg/tree-ssa/pr19637.C: Update after adding new dom1.
	* g++.dg/tree-ssa/pr61009.C: Same.
	* g++.dg/tree-ssa/ssa-dom.C: Same.
	* gcc.dg/pr20115-1.c: Same.
	* gcc.dg/tree-prof/20050826-2.c: Same.
	* gcc.dg/tree-prof/cmpsf-1.c: Same.
	* gcc.dg/tree-ssa/20030821-1.c: Same.
	* gcc.dg/tree-ssa/20030922-2.c: Same.
	* gcc.dg/tree-ssa/20031022-1.c: Same.
	* gcc.dg/tree-ssa/20040615-1.c: Same.
	* gcc.dg/tree-ssa/20040624-1.c: Same.
	* gcc.dg/tree-ssa/pr21417.c: Same.
	* gcc.dg/tree-ssa/pr61607.c: Same.
	* gcc.dg/tree-ssa/slsr-27.c: Same.
	* gcc.dg/tree-ssa/slsr-28.c: Same.
	* gcc.dg/tree-ssa/slsr-29.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-branch-1.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-cse-3.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-1.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-2a.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-2b.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-2c.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-2d.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-2e.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-2f.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-4.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-5.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-6.c: Same.
	* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Same.
	* gcc.dg/tree-ssa/ssa-thread-12.c: Same.
	* gcc.dg/tree-ssa/vrp47.c: Same.
	* gcc.dg/tree-ssa/copy-headers.c: Update after adding ch1.
	* gcc.dg/tree-ssa/foldconst-2.c: Same.
	* gcc.dg/tree-ssa/loop-40.c: Same.
	* gcc.dg/gomp/notify-new-function-3.c: Update after adding ompexpssa1.

From-SVN: r230907
2015-11-25 21:26:37 +00:00
Tom de Vries b81b8bcadb Improve verification of loop->latch in verify_loop_structure
2015-11-25  Tom de Vries  <tom@codesourcery.com>

	* cfgloop.c (find_single_latch): New function, factored out of ...
	(flow_loops_find): ... here.
	(verify_loop_structure): Improve verification of loop->latch.
	* cfgloop.h (find_single_latch): Declare.
	* omp-low.c (expand_omp_for_generic): Initialize latch of orig_loop.

From-SVN: r230866
2015-11-25 11:28:49 +00:00
Tom de Vries 096b85f4b4 Mark by_ref mem_ref in build_receiver_ref as non-trapping
2015-11-23  Tom de Vries  <tom@codesourcery.com>

	* omp-low.c (build_receiver_ref): Mark by_ref mem_ref as non-trapping.

From-SVN: r230738
2015-11-23 08:56:49 +00:00
Jakub Jelinek 48a78aee68 re PR middle-end/68221 (libgomp reduction-11/12 failures)
PR middle-end/68221
	* omp-low.c (lower_rec_input_clauses): If C/C++ array reduction
	has non-zero bias, subtract it in integer type instead of
	pointer plus of negated bias.

	* testsuite/libgomp.c/reduction-11.c: Remove xfail.
	* testsuite/libgomp.c/reduction-12.c: Likewise.
	* testsuite/libgomp.c++/reduction-11.C: Likewise.
	* testsuite/libgomp.c++/reduction-12.C: Likewise.

From-SVN: r230672
2015-11-20 20:50:46 +01:00
Jakub Jelinek 9a784760f1 re PR middle-end/68339 (g++.dg/vect/simd-clone-2.cc ICEs with aggressive GC settings and OpenMP)
PR middle-end/68339
	* omp-low.c (expand_simd_clones): Call node->get_body () before
	allocating stuff in GC.

	* gcc.dg/vect/pr68339.c: New test.

From-SVN: r230671
2015-11-20 20:49:47 +01:00
Tom de Vries 886c388d74 Add in_oacc_kernels_region in struct loop
2015-11-17  Tom de Vries  <tom@codesourcery.com>

	* cfgloop.h (struct loop): Add in_oacc_kernels_region field.
	* omp-low.c (mark_loops_in_oacc_kernels_region): New function.
	(expand_omp_target): Call mark_loops_in_oacc_kernels_region.

From-SVN: r230502
2015-11-17 21:42:09 +00:00
Kirill Yukhin fff7721799 Add __attribute__((__simd__)) to GCC.
gcc/
	* omp-low.c (pass_omp_simd_clone::gate): If target allows - call
	without additional conditions.
	* doc/extend.texi (@item simd): New.
gcc/c-family/
	* c-common.c (handle_simd_attribute): New.
	(struct attribute_spec): Add entry for "simd".
	(handle_simd_attribute): New.
gcc/c/
	* c-parser.c (c_finish_omp_declare_simd): Look for
	"simd" attribute as well. Update error message.
gcc/cp/
	* parser.c (cp_parser_late_parsing_cilk_simd_fn_info): Look for
	"simd" attribute as well. Update error message.
gcc/testsuite/
	* c-c++-common/attr-simd.c: New test.
	* c-c++-common/attr-simd-2.c: New test.
	* c-c++-common/attr-simd-3.c: New test.

From-SVN: r230422
2015-11-16 13:14:57 +00:00
Trevor Saunders 1d899da297 always define ENABLE_OFFLOADING
gcc/cp/ChangeLog:

2015-11-14  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* parser.c (cp_parser_omp_declare_target): Adjust.

gcc/ChangeLog:

2015-11-14  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* configure: Regenerate.
	* configure.ac: Always define ENABLE_OFFLOADING.
	* cgraph.c (cgraph_node::create): Adjust.
	* gcc.c (process_command): Likewise.
	* omp-low.c (create_omp_child_function): Likewise.
	(expand_omp_target): Likewise.
	* varpool.c (varpool_node::get_create): Likewise.

gcc/c/ChangeLog:

2015-11-14  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* c-parser.c (c_parser_omp_declare_target): Adjust.

From-SVN: r230393
2015-11-15 00:18:08 +00:00
Jakub Jelinek e460634820 omp-low.c (lower_omp_ordered): Add argument to GOMP_SMD_ORDERED_* internal calls - 0 if...
gcc/
2015-11-14  Jakub Jelinek  <jakub@redhat.com>

	* omp-low.c (lower_omp_ordered): Add argument to GOMP_SMD_ORDERED_*
	internal calls - 0 if ordered simd and 1 for ordered threads simd.
	* tree-vectorizer.c (adjust_simduid_builtins): If GOMP_SIMD_ORDERED_*
	argument is 1, replace it with GOMP_ordered_* call instead of removing
	it.
gcc/c/
2015-11-14  Jakub Jelinek  <jakub@redhat.com>

	* c-typeck.c (c_finish_omp_clauses): Don't mark
	GOMP_MAP_FIRSTPRIVATE_POINTER decls addressable.
gcc/cp/
2015-11-14  Jakub Jelinek  <jakub@redhat.com>

	* semantics.c (finish_omp_clauses): Don't mark
	GOMP_MAP_FIRSTPRIVATE_POINTER decls addressable.
libgomp/
2015-11-14  Jakub Jelinek  <jakub@redhat.com>
	    Aldy Hernandez  <aldyh@redhat.com>
	    Ilya Verbin  <ilya.verbin@intel.com>

	* ordered.c (gomp_doacross_init, GOMP_doacross_post,
	GOMP_doacross_wait, gomp_doacross_ull_init, GOMP_doacross_ull_post,
	GOMP_doacross_ull_wait): For GFS_GUIDED don't divide number of
	iterators or IV by chunk size.
	* parallel.c (gomp_resolve_num_threads): Don't assume that
	if thr->ts.team is non-NULL, then pool must be non-NULL.
	* libgomp-plugin.h (GOMP_PLUGIN_target_task_completion): Declare.
	* libgomp.map (GOMP_PLUGIN_1.1): New symbol version, export
	GOMP_PLUGIN_target_task_completion.
	* Makefile.am (libgomp_la_SOURCES): Add priority_queue.c.
	* Makefile.in: Regenerate.
	* libgomp.h: Shuffle prototypes and forward definitions around so
	priority queues can be defined.
	(enum gomp_task_kind): Add GOMP_TASK_ASYNC_RUNNING.
	(enum gomp_target_task_state): New enum.
	(struct gomp_target_task): Add state, tgt, task and team fields.
	(gomp_create_target_task): Change return type to bool, add
	state argument.
	(gomp_target_task_fn): Change return type to bool.
	(struct gomp_device_descr): Add async_run_func.
	(struct gomp_task): Remove children, next_child, prev_child,
	next_queue, prev_queue, next_taskgroup, prev_taskgroup.
	Add pnode field.
	(struct gomp_taskgroup): Remove children.
	Add taskgroup_queue.
	(struct gomp_team): Change task_queue type to a priority queue.
	(splay_compare): Define inline.
	(priority_queue_offset): New.
	(priority_node_to_task): New.
	(task_to_priority_node): New.
	* oacc-mem.c: Do not include splay-tree.h.
	* priority_queue.c: New file.
	* priority_queue.h: New file.
	* splay-tree.c: Do not include splay-tree.h.
	(splay_tree_foreach_internal): New.
	(splay_tree_foreach): New.
	* splay-tree.h: Become re-entrant if splay_tree_prefix is defined.
	(splay_tree_callback): Define typedef.
	* target.c (splay_compare): Move to libgomp.h.
	(GOMP_target): Don't adjust *thr in any way around running offloaded
	task.
	(GOMP_target_ext): Likewise.  Handle target nowait.
	(GOMP_target_update_ext, GOMP_target_enter_exit_data): Check
	return value from gomp_create_target_task, if false, fallthrough
	as if no dependencies exist.
	(gomp_target_task_fn): Change return type to bool, return true
	if the task should have another part scheduled later.  Handle
	target nowait.
	(gomp_load_plugin_for_device): Initialize async_run.
	* task.c (gomp_init_task): Initialize children_queue.
	(gomp_clear_parent_in_list): New.
	(gomp_clear_parent_in_tree): New.
	(gomp_clear_parent): Handle priorities.
	(GOMP_task): Likewise.
	(priority_queue_move_task_first,
	gomp_target_task_completion, GOMP_PLUGIN_target_task_completion):
	New functions.
	(gomp_create_target_task): Use priority queues.  Change return type
	to bool, add state argument, return false if for async
	{{enter,exit} data,update} constructs no dependencies need to be
	waited for, handle target nowait.  Set task->fn to NULL instead of
	gomp_target_task_fn.
	(verify_children_queue): Remove.
	(priority_list_upgrade_task): New.
	(priority_queue_upgrade_task): New.
	(verify_task_queue): Remove.
	(priority_list_downgrade_task): New.
	(priority_queue_downgrade_task): New.
	(gomp_task_run_pre): Use priority queues.
	Abstract code out to priority_queue_downgrade_task.
	(gomp_task_run_post_handle_dependers): Use priority queues.
	(gomp_task_run_post_remove_parent): Likewise.
	(gomp_task_run_post_remove_taskgroup): Likewise.
	(gomp_barrier_handle_tasks): Likewise.  Handle target nowait target
	tasks specially.
	(GOMP_taskwait): Likewise.
	(gomp_task_maybe_wait_for_dependencies): Likewise.  Abstract code to
	priority-queue_upgrade_task.
	(GOMP_taskgroup_start): Use priority queues.
	(GOMP_taskgroup_end): Likewise.  Handle target nowait target tasks
	specially.  If taskgroup is NULL, and thr->ts.level is 0, act as a
	barrier.
	* taskloop.c (GOMP_taskloop): Handle priorities.
	* team.c (gomp_new_team): Call priority_queue_init.
	(free_team): Call priority_queue_free.
	(gomp_free_thread): Call gomp_team_end if thr->ts.team is artificial
	team created for target nowait in implicit parallel region.
	(gomp_team_start): For nested check, test thr->ts.level instead of
	thr->ts.team != NULL.
	* testsuite/libgomp.c/doacross-3.c: New test.
	* testsuite/libgomp.c/ordered-5.c: New test.
	* testsuite/libgomp.c/priority.c: New test.
	* testsuite/libgomp.c/target-31.c: New test.
	* testsuite/libgomp.c/target-32.c: New test.
	* testsuite/libgomp.c/target-33.c: New test.
	* testsuite/libgomp.c/target-34.c: New test.
liboffloadmic/
2015-11-14  Ilya Verbin  <ilya.verbin@intel.com>

	* runtime/offload_host.cpp (task_completion_callback): New
	variable.
	(offload_proxy_task_completed_ooo): Call task_completion_callback.
	(__offload_register_task_callback): New function.
	* runtime/offload_host.h (__offload_register_task_callback): New
	declaration.
	* plugin/libgomp-plugin-intelmic.cpp (offload): Add async_data
	argument, handle async offloading.
	(register_main_image): Call register_main_image.
	(GOMP_OFFLOAD_init_device, get_target_table, GOMP_OFFLOAD_alloc,
	GOMP_OFFLOAD_free, GOMP_OFFLOAD_host2dev, GOMP_OFFLOAD_dev2host,
	GOMP_OFFLOAD_dev2dev) Adjust offload callers.
	(GOMP_OFFLOAD_async_run): New function.
	(GOMP_OFFLOAD_run): Implement using GOMP_OFFLOAD_async_run.

From-SVN: r230381
2015-11-14 19:42:13 +01:00
Nathan Sidwell c5a64cfec7 omp-low.c (scan_sharing_clauses): Accept INDEPENDENT, AUTO & SEQ.
gcc/
	* gcc/omp-low.c (scan_sharing_clauses): Accept INDEPENDENT, AUTO &
	SEQ.
	(oacc_loop_fixed_partitions): Correct return type to bool.
	(oacc_loop_auto_partitions): New.
	(oacc_loop_partition): Take mask argument, call
	oacc_loop_auto_partitions.
	(execute_oacc_device_lower): Provide mask to oacc_loop_partition.

	gcc/testsuite/
	* c-c++-common/goacc/loop-auto-1.c: New.

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c: New.

From-SVN: r230354
2015-11-13 21:51:32 +00:00
James Norris 6e232ba424 c-pragma.c (oacc_pragmas): Add entry for declare directive.
2015-11-12  James Norris  <jnorris@codesourcery.com>
	    Joseph Myers  <joseph@codesourcery.com>

	gcc/c-family/
	* c-pragma.c (oacc_pragmas): Add entry for declare directive. 
	* c-pragma.h (enum pragma_kind): Add PRAGMA_OACC_DECLARE.
	(enum pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT and
	PRAGMA_OACC_CLAUSE_LINK.

	gcc/c/
	* c-parser.c (c_parser_pragma): Handle PRAGMA_OACC_DECLARE.
	(c_parser_omp_clause_name): Handle 'device_resident' clause.
	(c_parser_oacc_data_clause): Handle PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT
	and PRAGMA_OMP_CLAUSE_LINK.
	(c_parser_oacc_all_clauses): Handle PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT
	and PRAGMA_OACC_CLAUSE_LINK.
	(OACC_DECLARE_CLAUSE_MASK): New definition.
	(c_parser_oacc_declare): New function.

	gcc/cp/
	* parser.c (cp_parser_omp_clause_name): Handle 'device_resident'
	clause.
	(cp_parser_oacc_data_clause): Handle PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT
	and PRAGMA_OMP_CLAUSE_LINK.
	(cp_paser_oacc_all_clauses): Handle PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT
	and PRAGMA_OMP_CLAUSE_LINK.
	(OACC_DECLARE_CLAUSE_MASK): New definition.
	(cp_parser_oacc_declare): New function.
	(cp_parser_pragma): Handle PRAGMA_OACC_DECLARE.
	* pt.c (tsubst_expr): Handle OACC_DECLARE.

	gcc/
	* gimple-pretty-print.c (dump_gimple_omp_target): Handle
	GF_OMP_TARGET_KIND_OACC_DECLARE. 
	* gimple.h (enum gf_mask): Add GF_OMP_TARGET_KIND_OACC_DECLARE.
	(is_gomple_omp_oacc): Handle GF_OMP_TARGET_KIND_OACC_DECLARE.
	* gimplify.c (oacc_declare_returns): New.
	(gimplify_bind_expr): Prepend 'exit' stmt to cleanup.
	(device_resident_p): New function.
	(oacc_default_clause): Handle device_resident clause.
	(gimplify_oacc_declare_1, gimplify_oacc_declare): New functions.
	(gimplify_expr): Handle OACC_DECLARE.
	* omp-builtins.def (BUILT_IN_GOACC_DECLARE): New builtin.
	* omp-low.c (expand_omp_target): Handle
	GF_OMP_TARGET_KIND_OACC_DECLARE and BUILTIN_GOACC_DECLARE.
	(build_omp_regions_1): Handlde GF_OMP_TARGET_KIND_OACC_DECLARE.
	(lower_omp_target): Handle GF_OMP_TARGET_KIND_OACC_DECLARE,
	GOMP_MAP_DEVICE_RESIDENT and GOMP_MAP_LINK.
	(make_gimple_omp_edges): Handle GF_OMP_TARGET_KIND_OACC_DECLARE.
	* tree-pretty-print.c (dump_omp_clause): Handle GOMP_MAP_LINK and
	GOMP_MAP_DEVICE_RESIDENT.

	gcc/testsuite
	* c-c++-common/goacc/declare-1.c: New test.
	* c-c++-common/goacc/declare-2.c: Likewise.

	include/
	* gomp-constants.h (enum gomp_map_kind): Add GOMP_MAP_DEVICE_RESIDENT
	and GOMP_MAP_LINK.

	libgomp/
	* libgomp.map (GOACC_2.0.1): Export GOACC_declare.
	* oacc-parallel.c (GOACC_declare): New function.
	* testsuite/libgomp.oacc-c-c++-common/declare-1.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/declare-2.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/declare-4.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/declare-5.c: Likewise.
	* testsuite/libgomp.oacc-c++/declare-1.C: Likewise.

Co-Authored-By: Joseph Myers <joseph@codesourcery.com>

From-SVN: r230275
2015-11-12 22:20:41 +00:00
Nathan Sidwell 182190f2b3 gimplify.c (enum omp_region_type): Add ORT_ACC, ORT_ACC_DATA, ORT_ACC_PARALLEL, ORT_ACC_KERNELS.
gcc/
	* gcc/gimplify.c (enum  omp_region_type): Add ORT_ACC,
	ORT_ACC_DATA, ORT_ACC_PARALLEL, ORT_ACC_KERNELS.  Adjust ORT_NONE.
	(gimple_add_tmp_var): Add ORT_ACC checks.
	(gimplify_var_or_parm_decl): Likewise.
	(omp_firstprivatize_variable): Likewise. Use ORT_TARGET_DATA as a
	mask.
	(omp_add_variable): Look in outer contexts for openacc and allow
	reductions with other sharing. Add ORT_ACC and ORT_TARGET_DATA
	checks.
	(omp_notice_variable, omp_is_private, omp_check_private): Add
	ORT_ACC checks.
	(gimplify_scan_omp_clauses: Treat ORT_ACC as ORT_WORKSHARE.
	Permit private openacc reductions.
	(gimplify_oacc_cache): Specify ORT_ACC.
	(gimplify_omp_workshare): Adjust OpenACC region types.
	(gimplify_omp_target_update): Likewise.
	* gcc/omp-low.c (scan_sharing_clauses): Remove Openacc
	firstprivate sorry.
	(lower-rec_input_clauses): Don't handle openacc firstprivate
	references here.
	(lower_omp_target): Emit initializers for openacc firstprivate vars.

	gcc/testsuite/
	* gfortran.dg/goacc/private-3.f95: Remove xfail.
	* gfortran.dg/goacc/combined_loop.f90: Remove xfail.

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c: Remove xfail.
	* testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c: Remove xfail.
	* testsuite/libgomp.oacc-c-c++-common/firstprivate-1.c: New.
	* testsuite/libgomp.oacc-c-c++-common/firstprivate-2.c: New.

Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com>

From-SVN: r230169
2015-11-11 14:24:09 +00:00
Nathan Sidwell 3a40d81dcd omp-low.h (replace_oacc_fn_attrib, [...]): Declare.
* omp-low.h (replace_oacc_fn_attrib, build_oacc_routine_dims): Declare.
	* omp-low.c (build_oacc_routine_dims): New.

	c/
	* c-parser.c (c_parser_declaration_or_fndef): Add OpenACC
	routine arg.
	(c_parser_declaration_or_fndef): Call c_finish_oacc_routine.
	(c_parser_pragma): Parse 'acc routine'.
	(OACC_ROUTINE_CLAUSE_MARK): Define.
	(c_parser_oacc_routine, (c_finish_oacc_routine): New.

	c-family/
	* c-pragma.c (oacc_pragmas): Add "routine".
	* c-pragma.h (pragma_kind): Add PRAGMA_OACC_ROUTINE.

	cp/
	* parser.h (struct cp_parser): Add oacc_routine field.
	* parser.c (cp_ensure_no_oacc_routine): New.
	(cp_parser_new): Initialize oacc_routine field.
	(cp_parser_linkage_specification): Call cp_ensure_no_oacc_routine.
	(cp_parser_namespace_definition,
	cp_parser_class_specifier_1): Likewise.
	(cp_parser_init_declarator): Call cp_finalize_oacc_routine.
	(cp_parser_function_definition,
	cp_parser_save_member_function_body): Likewise.
	(OACC_ROUTINE_CLAUSE_MASK): New.
	(cp_parser_finish_oacc_routine, cp_parser_oacc_routine,
	cp_finalize_oacc_routine): New.
	(cp_parser_pragma): Adjust omp_declare_simd checking.  Call
	cp_ensure_no_oacc_routine.
	(cp_parser_pragma): Add OpenACC routine handling.

From-SVN: r230072
2015-11-10 00:27:26 +00:00
Nathan Sidwell 374d022552 omp-low.c: Fix some OpenACC comment typos.
* omp-low.c: Fix some OpenACC comment typos.
	(lower_reduction_clauses): Remove BUILT_IN_GOACC_GET_THREAD_NUM call.
	* omp-builtins.def (BUILT_IN_GOACC_GET_THREAD_NUM,
	BUILT_IN_GOACC_GET_NUM_THREADS): Delete.

From-SVN: r230054
2015-11-09 21:56:42 +00:00
Jakub Jelinek d9f4ea18ac gimplify.c (gimplify_omp_ordered): Fix up diagnostics wording.
* gimplify.c (gimplify_omp_ordered): Fix up diagnostics
	wording.
	* omp-low.c (check_omp_nesting_restrictions): Update for the
	various new OpenMP 4.5 nesting restrictions, clarified
	nesting glossary, closely nested region relationship clarified
	to mean explicit or implicit parallel regions (target/teams),
	use %</%> or %qs where appropriate.

	* gcc.dg/gomp/ordered-2.c (f1): Expect an extra error.
	* g++.dg/gomp/ordered-2.C (f1): Likewise.
	* gfortran.dg/goacc/parallel-kernels-regions.f95: Adjust
	expected diagnostics for the addition of quotes.
	* gfortran.dg/gomp/target3.f90: Likewise.
	* c-c++-common/goacc/nesting-fail-1.c: Likewise.
	* c-c++-common/goacc-gomp/nesting-fail-1.c: Likewise.
	* c-c++-common/gomp/doacross-1.c: Likewise.
	* c-c++-common/gomp/nesting-warn-1.c: Likewise.
	* c-c++-common/gomp/cancel-1.c (f2): Add some new tests.
	Adjust expected diagnostics wording.
	* c-c++-common/gomp/clauses-4.c (foo): Likewise.
	Don't expect error on ordered threads simd when in for simd.
	* c-c++-common/gomp/nesting-2.c: New test.
	* c-c++-common/gomp/ordered-3.c (foo): Add some new tests.
	* c-c++-common/gomp/ordered-4.c: New test.

From-SVN: r229892
2015-11-06 22:21:16 +01:00
Cesar Philippidis 7a5e4956cc gimplify.c (gimplify_scan_omp_clauses): Add support for OMP_CLAUSE_TILE.
gcc/
	* gimplify.c (gimplify_scan_omp_clauses): Add support for
	OMP_CLAUSE_TILE.  Update handling of OMP_CLAUSE_INDEPENDENT.
	(gimplify_adjust_omp_clauses): Likewise.
	* omp-low.c (scan_sharing_clauses): Add support for OMP_CLAUSE_TILE.
	* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_TILE.
	* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_TILE.
	* tree.c (omp_clause_num_ops): Add an entry for OMP_CLAUSE_TILE.
	(omp_clause_code_name): Likewise.
	(walk_tree_1): Handle OMP_CLAUSE_TILE.
	* tree.h (OMP_TILE_LIST): New macro.

	gcc/c-family/
	* c-omp.c (c_oacc_split_loop_clauses): Make TILE, GANG, WORKER, VECTOR,
	AUTO, SEQ, INDEPENDENT and PRIVATE loop clauses.  Associate REDUCTION
	clauses with parallel and kernels and loops.
	* c-pragma.h (enum pragma_omp_clause): Add entries for
	PRAGMA_OACC_CLAUSE_{INDEPENDENT,TILE,DEFAULT}.
	* pt.c (tsubst_omp_clauses): Add support for OMP_CLAUSE_{NUM_GANGS,
	NUM_WORKERS,VECTOR_LENGTH,GANG,WORKER,VECTOR,ASYNC,WAIT,TILE,AUTO,
	INDEPENDENT,SEQ}. 
	(tsubst_expr): Add support for OMP_CLAUSE_{KERNELS,PARALLEL,LOOP}.

	gcc/c/
	* c-parser.c (c_parser_omp_clause_name): Add support for
	PRAGMA_OACC_CLAUSE_INDEPENDENT and PRAGMA_OACC_CLAUSE_TILE.
	(c_parser_omp_clause_default): Add is_oacc argument. Handle
	default(none) in OpenACC.
	(c_parser_oacc_shape_clause): Allow pointer variables as gang static
	arguments.
	(c_parser_oacc_clause_tile): New function.
	(c_parser_oacc_all_clauses): Add support for OMP_CLAUSE_DEFAULT,
	OMP_CLAUSE_INDEPENDENT and OMP_CLAUSE_TILE.
	(OACC_LOOP_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_{PRIVATE,INDEPENDENT,
	TILE}.
	(OACC_KERNELS_MASK): Add PRAGMA_OACC_CLAUSE_DEFAULT.
	(OACC_PARALLEL_MASK): Add PRAGMA_OACC_CLAUSE_{DEFAULT,PRIVATE,
	FIRSTPRIVATE}.
	(c_parser_omp_all_clauses): Update call to c_parser_omp_clause_default.
	(c_parser_oacc_update): Update the error message for missing clauses.
	* c-typeck.c (c_finish_omp_clauses): Add support for OMP_CLAUSE_TILE
	and OMP_CLAUSE_INDEPENDENT.

	gcc/cp/
	* parser.c (cp_parser_omp_clause_name): Add support for
	PRAGMA_OACC_CLAUSE_INDEPENDENT and PRAGMA_OACC_CLAUSE_TILE.
	(cp_parser_oacc_shape_clause): Allow pointer variables as gang static
	arguments.
	(cp_parser_oacc_clause_tile): New function.
	(cp_parser_omp_clause_default): Add is_oacc argument. Handle
	default(none) in OpenACC.
	(cp_parser_oacc_all_clauses): Add support for
	(cp_parser_omp_all_clauses): Update call to
	cp_parser_omp_clause_default.
	PRAGMA_OACC_CLAUSE_{DEFAULT,INDEPENDENT,TILE,PRIVATE,FIRSTPRIVATE}.
	(OACC_LOOP_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_{PRIVATE,INDEPENDENT,
	TILE}.
	(OACC_KERNELS_MASK): Add PRAGMA_OACC_CLAUSE_DEFAULT.
	(OACC_PARALLEL_MASK): Add PRAGMA_OACC_CLAUSE_{DEFAULT,PRIVATE,
	FIRSTPRIVATE}.
	(cp_parser_oacc_update): Update the error message for missing clauses.
	* semantics.c (finish_omp_clauses): Add support for
	OMP_CLAUSE_INDEPENDENT and OMP_CLAUSE_TILE.

	gcc/fortran/
	* openmp.c (gfc_match_omp_clauses): Update support for the tile
	and default clauses in OpenACC.
	(gfc_match_oacc_update): Error when data clauses are supplied.
	(oacc_compatible_clauses): Delete.
	(resolve_omp_clauses): Give special care for OpenACC reductions.
	Also update error reporting for the tile clause.
	(resolve_oacc_loop_blocks): Update error reporting for the tile clause.
	* trans-openmp.c (gfc_trans_omp_clauses): Update OMP_CLAUSE_SEQ. Add
	OMP_CLAUSE_{AUTO,TILE} and add support the the gang static argument.
	(gfc_trans_oacc_combined_directive): Update the list of clauses which
	are split to acc loops.

	gcc/testsuite/
	* c-c++-common/goacc/combined-directives.c: New test.
	* c-c++-common/goacc/loop-clauses.c: New test.
	* c-c++-common/goacc/tile.c: New test.
	* c-c++-common/goacc/loop-shape.c: Add test for pointer variable
	as gang static arguments.
	* c-c++-common/goacc/update-1.c: Adjust expected error message.
	* g++.dg/goacc/template.C: New test.
	* gfortran.dg/goacc/combined-directives.f90: New test.
	* gfortran.dg/goacc/default.f95: New test.
	* gfortran.dg/goacc/default_none.f95: New test.
	* gfortran.dg/goacc/firstprivate-1.f95: New test.
	* gfortran.dg/goacc/gang-static.f95: New test.
	* gfortran.dg/goacc/kernels-loop-inner.f95: New test.
	* gfortran.dg/goacc/kernels-loops-adjacent.f95: New test.
	* gfortran.dg/goacc/list.f95: Update test.
	* gfortran.dg/goacc/loop-2.f95: Likewise.
	* gfortran.dg/goacc/loop-4.f95: New test.
	* gfortran.dg/goacc/loop-5.f95: New test.
	* gfortran.dg/goacc/loop-6.f95: New test.
	* gfortran.dg/goacc/loop-tree-1.f90: Update test.
	* gfortran.dg/goacc/multi-clause.f90: New test.
	* gfortran.dg/goacc/parallel-tree.f95: Update test.
	* gfortran.dg/goacc/update.f95: New test.


Co-Authored-By: James Norris <jnorris@codesourcery.com>
Co-Authored-By: Nathan Sidwell <nathan@codesourcery.com>
Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
Co-Authored-By: Tom de Vries <tom@codesourcery.com>

From-SVN: r229832
2015-11-05 18:03:48 -08:00