mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-27 05:44:15 +08:00
e01d41e553
2015-11-05 Jakub Jelinek <jakub@redhat.com> Ilya Verbin <ilya.verbin@intel.com> * builtin-types.def (BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR): Remove. (BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_INT_INT): New. * cgraph.h (enum cgraph_simd_clone_arg_type): Add SIMD_CLONE_ARG_TYPE_LINEAR_REF_VARIABLE_STEP, SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_VARIABLE_STEP and SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP. (struct cgraph_simd_clone_arg): Adjust comment. * omp-builtins.def (BUILT_IN_GOMP_TARGET): Rename GOMP_target_41 to GOMP_target_ext. Add num_teams and thread_limit arguments. (BUILT_IN_GOMP_TARGET_DATA): Rename GOMP_target_data_41 to GOMP_target_data_ext. (BUILT_IN_GOMP_TARGET_UPDATE): Rename GOMP_target_update_41 to GOMP_target_update_ext. (BUILT_IN_GOMP_LOOP_NONMONOTONIC_DYNAMIC_START, BUILT_IN_GOMP_LOOP_NONMONOTONIC_GUIDED_START, BUILT_IN_GOMP_LOOP_NONMONOTONIC_DYNAMIC_NEXT, BUILT_IN_GOMP_LOOP_NONMONOTONIC_GUIDED_NEXT, BUILT_IN_GOMP_LOOP_ULL_NONMONOTONIC_DYNAMIC_START, BUILT_IN_GOMP_LOOP_ULL_NONMONOTONIC_GUIDED_START, BUILT_IN_GOMP_LOOP_ULL_NONMONOTONIC_DYNAMIC_NEXT, BUILT_IN_GOMP_LOOP_ULL_NONMONOTONIC_GUIDED_NEXT, BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_DYNAMIC, BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_GUIDED): New built-ins. * tree-core.h (enum omp_clause_schedule_kind): Add OMP_CLAUSE_SCHEDULE_MASK, OMP_CLAUSE_SCHEDULE_MONOTONIC, OMP_CLAUSE_SCHEDULE_NONMONOTONIC and change OMP_CLAUSE_SCHEDULE_LAST value. * tree.def (OMP_SIMD, CILK_SIMD, CILK_FOR, OMP_DISTRIBUTE, OMP_TASKLOOP, OACC_LOOP): Add OMP_FOR_ORIG_DECLS argument. * tree.h (OMP_FOR_ORIG_DECLS): Use OMP_LOOP_CHECK instead of OMP_FOR_CHECK. Remove comment. * tree-pretty-print.c (dump_omp_clause): Handle GOMP_MAP_FIRSTPRIVATE_REFERENCE and GOMP_MAP_ALWAYS_POINTER. Simplify. Print schedule clause modifiers. * tree-vect-stmts.c (vectorizable_simd_clone_call): Add SIMD_CLONE_ARG_TYPE_LINEAR_{REF,VAL,UVAL}_VARIABLE_STEP cases. * gimplify.c (enum gimplify_omp_var_data): Add GOVD_MAP_ALWAYS_TO. (omp_default_clause): Tweak for private/firstprivate/is_device_ptr variables on target construct and use_device_ptr on target data. (omp_check_private): Likewise. (omp_notice_variable): For references check whether what it refers to has mappable type, rather than the reference itself. (omp_is_private): Diagnose linear iteration variables on non-simd constructs. (omp_no_lastprivate): Return true only for Fortran. (gimplify_scan_omp_clauses): Or in GOVD_MAP_ALWAYS_TO for GOMP_MAP_ALWAYS_TO or GOMP_MAP_ALWAYS_TOFROM kinds. Add support for GOMP_MAP_FIRSTPRIVATE_REFERENCE and GOMP_MAP_ALWAYS_POINTER, remove old handling of structure element based array sections. Use GOMP_MAP_ALWAYS_P. Fix up handling of lastprivate and linear when combined with distribute. Gimplify variable low-bound for array reduction. Look through POINTER_PLUS_EXPR when looking for ADDR_EXPR for array section reductions. (gimplify_adjust_omp_clauses_1): For implicit references to variables with reference type and when not ref to scalar or ref to pointer, map what they refer to using tofrom and use GOMP_MAP_FIRSTPRIVATE_REFERENCE for the reference. (gimplify_adjust_omp_clauses): Remove GOMP_MAP_ALWAYS_POINTER from target exit data. Handle GOMP_MAP_FIRSTPRIVATE_REFERENCE. Drop OMP_CLAUSE_MAP_PRIVATE support. Use GOMP_MAP_ALWAYS_P. Diagnose the same var on both firstprivate and lastprivate on distribute construct. (gimplify_omp_for): Fix up handling of predetermined lastprivate or linear iter vars when combined with distribute. (find_omp_teams, computable_teams_clause, optimize_target_teams): New functions. (gimplify_omp_workshare): Call optimize_target_teams. * omp-low.c (struct omp_region): Add sched_modifiers field. (struct omp_for_data): Likewise. (omp_any_child_fn_dumped): New variable. (extract_omp_for_data): Fill in sched_modifiers, and mask out OMP_CLAUSE_SCHEDULE_KIND bits outside of OMP_CLAUSE_SCHEDULE_MASK from sched_kind. (determine_parallel_type): Use only OMP_CLAUSE_SCHEDULE_MASK bits of OMP_CLAUSE_SCHED_KIND. (scan_sharing_clauses): Handle GOMP_MAP_FIRSTPRIVATE_REFERENCE, drop OMP_CLAUSE_MAP_PRIVATE support. Look through POINTER_PLUS_EXPR for array section reductions. (add_taskreg_looptemp_clauses): Add one extra _looptemp_ clause even for distribute parallel for, if there are lastprivate clauses on the for. (lower_rec_input_clauses): Handle non-zero low-bound on array section reductions. (lower_reduction_clauses): Likewise. (lower_send_clauses): Look through POINTER_PLUS_EXPR for array section reductions. (expand_parallel_call): Use nonmonotonic entrypoints for nonmonotonic: dynamic/guided. (expand_omp_taskreg): Call assign_assembler_name_if_neeeded on child_fn if current_function_decl has assembler name set, but child_fn does not. Dump the header and IL of the child function when not in SSA form. (expand_omp_target): Likewise. Pass num_teams and thread_limit arguments to BUILT_IN_GOMP_TARGET. (expand_omp_for_static_nochunk, expand_omp_for_static_chunk): Initialize the extra _looptemp_ clause to fd->loop.n2. (expand_omp_for): Use nonmonotonic entrypoints for nonmonotonic: dynamic/guided. Initialize region->sched_modifiers. (expand_omp): Clear omp_any_child_fn_dumped. Dump function header again if we have dumped any child functions. (lower_omp_for_lastprivate): Determine the right count variable for distribute simd, or distribute parallel for{, simd}. (lower_omp_target): Handle GOMP_MAP_FIRSTPRIVATE_REFERENCE and GOMP_MAP_ALWAYS_POINTER. Drop OMP_CLAUSE_MAP_PRIVATE support. (simd_clone_clauses_extract): Handle variable step for references and arguments passed by reference. (simd_clone_mangle): Mangle ref/uval/val variable steps. (simd_clone_adjust_argument_types): Handle SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_VARIABLE_STEP like SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP and SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP like SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP. (simd_clone_linear_addend): New function. (simd_clone_adjust): Handle variable step like similarly to constant step, use simd_clone_linear_addend to determine the actual step at runtime. gcc/c-family/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> * c-common.h (c_finish_omp_atomic): Add TEST argument. (c_omp_check_loop_iv, c_omp_check_loop_iv_exprs): New prototypes. * c-omp.c (c_finish_omp_atomic): Add TEST argument. Don't call save_expr or create_tmp_var* if TEST is true. (c_finish_omp_for): Store OMP_FOR_ORIG_DECLS always. Don't call add_stmt here. (struct c_omp_check_loop_iv_data): New type. (c_omp_check_loop_iv_r, c_omp_check_loop_iv, c_omp_check_loop_iv_exprs): New functions. (c_omp_split_clauses): Adjust for lastprivate being allowed on distribute. (c_omp_declare_simd_clauses_to_numbers): Change OMP_CLAUSE_LINEAR_VARIABLE_STRIDE OMP_CLAUSE_LINEAR_STEP into numbers. (c_omp_declare_simd_clauses_to_decls): Similarly change those from numbers to PARM_DECLs. gcc/c/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> Ilya Verbin <ilya.verbin@intel.com> * c-parser.c: Include context.h and gimple-expr.h. (c_parser_omp_clause_schedule): Parse schedule modifiers, diagnose monotonic together with nonmonotonic. (c_parser_omp_for_loop): Call c_omp_check_loop_iv. Call add_stmt here. (OMP_DISTRIBUTE_CLAUSE_MASK): Add lastprivate clause. (c_parser_omp_target_data, c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Allow GOMP_MAP_ALWAYS_POINTER. (c_parser_omp_target): Likewise. Evaluate num_teams and thread_limit expressions on combined target teams before the target. (c_parser_omp_declare_target): If decl has "omp declare target" or "omp declare target link" attribute, and cgraph or varpool node already exists, then set corresponding flags. Call c_finish_omp_clauses in the parenthesized extended-list syntax case. * c-decl.c (c_decl_attributes): Don't diagnose block scope vars inside declare target. * c-typeck.c (handle_omp_array_sections_1): Allow non-zero low-bound on OMP_CLAUSE_REDUCTION array sections. (handle_omp_array_sections): Encode low-bound into the MEM_REF, either into the constant offset, or for variable low-bound using POINTER_PLUS_EXPR. For structure element based array sections use GOMP_MAP_ALWAYS_POINTER instead of GOMP_MAP_FIRSTPRIVATE_POINTER. (c_finish_omp_clauses): Drop generic_field_head, structure elements are now always mapped even as array section bases, diagnose same var in data sharing and mapping clauses. Diagnose if linear step on declare simd is neither a constant nor a uniform parameter. Look through POINTER_PLUS_EXPR for array section reductions. Diagnose the same var or function appearing multiple times on the same directive. Fix up wording for the to clause if t is neither a FUNCTION_DECL nor a VAR_DECL. Diagnose nonmonotonic modifier on kinds other than dynamic or guided or nonmonotonic modifier together with ordered clause. gcc/cp/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> Ilya Verbin <ilya.verbin@intel.com> * cp-tree.h (finish_omp_for): Add ORIG_INITS argument. (omp_privatize_field): Add SHARED argument. * parser.c: Include context.h. (cp_parser_omp_clause_schedule): Parse schedule modifiers, diagnose monotonic together with nonmonotonic. (cp_parser_omp_clause_linear): Add DECLARE_SIMD argument. Parse parameter name as linear step as id-expression rather than expression. (cp_parser_omp_all_clauses): Adjust caller. (cp_parser_omp_for_loop_init): Add ORIG_INIT argument, initialize it. Adjust omp_privatize_field caller. (cp_parser_omp_for_loop): Compute orig_inits, pass it's address to finish_omp_for. (OMP_DISTRIBUTE_CLAUSE_MASK): Add lastprivate clause. (cp_parser_omp_target_data, cp_parser_omp_target_enter_data, cp_parser_omp_target_exit_data): Allow GOMP_MAP_ALWAYS_POINTER and GOMP_MAP_FIRSTPRIVATE_REFERENCE. (cp_parser_omp_target): Likewise. Evaluate num_teams and thread_limit expressions on combined target teams before the target. (cp_parser_omp_declare_target): If decl has "omp declare target" or "omp declare target link" attribute, and cgraph or varpool node already exists, then set corresponding flags. Call finish_omp_clauses in the parenthesized extended-list syntax case. Call cp_parser_require_pragma_eol instead of cp_parser_skip_to_pragma_eol. (cp_parser_omp_end_declare_target): Call cp_parser_require_pragma_eol instead of cp_parser_skip_to_pragma_eol. * decl2.c (cplus_decl_attributes): Don't diagnose block scope vars inside declare target. * pt.c (tsubst_omp_clauses): If OMP_CLAUSE_LINEAR_VARIABLE_STRIDE, use tsubst_omp_clause_decl instead of tsubst_expr on OMP_CLAUSE_LINEAR_STEP. Handle non-static data members in shared clauses. (tsubst_omp_for_iterator): Adjust omp_privatize_field caller. (tsubst_find_omp_teams): New function. (tsubst_expr): Evaluate num_teams and thread_limit expressions on combined target teams before the target. Use OMP_FOR_ORIG_DECLS for all OpenMP/OpenACC/Cilk+ looping constructs. Adjust finish_omp_for caller. * semantics.c (omp_privatize_field): Add SHARED argument, if true, always create artificial var and never put it into the hash table or vector. (handle_omp_array_sections_1): Adjust omp_privatize_field caller. Allow non-zero low-bound on OMP_CLAUSE_REDUCTION array sections. (handle_omp_array_sections): For structure element based array sections use GOMP_MAP_ALWAYS_POINTER instead of GOMP_MAP_FIRSTPRIVATE_POINTER. Encode low-bound into the MEM_REF, either into the constant offset, or for variable low-bound using POINTER_PLUS_EXPR. (finish_omp_clauses): Adjust omp_privatize_field caller. Drop generic_field_head, structure elements are now always mapped even as array section bases, diagnose same var in data sharing and mapping clauses. For references map what they refer to using GOMP_MAP_ALWAYS_POINTER for structure elements and GOMP_MAP_FIRSTPRIVATE_REFERENCE otherwise. Diagnose if linear step on declare simd is neither a constant nor a uniform parameter. Allow non-static data members on shared clauses. Look through POINTER_PLUS_EXPR for array section reductions. Diagnose nonmonotonic modifier on kinds other than dynamic or guided or nonmonotonic modifier together with ordered clause. Diagnose the same var or function appearing multiple times on the same directive. Fix up wording for the to clause if t is neither a FUNCTION_DECL nor a VAR_DECL, use special wording for OVERLOADs and TEMPLATE_ID_EXPR. (handle_omp_for_class_iterator): Add ORIG_DECLS argument. Call c_omp_check_loop_iv_exprs on cond. (finish_omp_for): Add ORIG_INITS argument. Call c_omp_check_loop_iv_exprs on ORIG_INITS elements. Adjust handle_omp_for_class_iterator caller. Call c_omp_check_loop_iv. Call add_stmt. (finish_omp_atomic): Adjust c_finish_omp_atomic caller. gcc/fortran/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> * types.def (BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR): Remove. (BT_FN_VOID_INT_OMPFN_SIZE_PTR_PTR_PTR_UINT_PTR_INT_INT): New. gcc/testsuite/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> * c-c++-common/gomp/clauses-2.c (foo): Adjust for diagnostics of variables in both data sharing and mapping clauses and for structure element based array sections being mapped rather than privatized. * c-c++-common/gomp/declare-target-2.c: Add various new tests. Adjust expected diagnostics wording in one case. * c-c++-common/gomp/distribute-1.c: New test. * c-c++-common/gomp/element-1.c: New test. * c-c++-common/gomp/pr61486-2.c: Add #pragma omp declare target and #pragma omp end declare target pair around the function. Change s from a parameter to a file scope variable. * c-c++-common/gomp/pr67521.c: Add dg-error directives. * c-c++-common/gomp/reduction-1.c (foo): Don't expect diagnostics on non-zero low-bound in reduction array sections. Add further tests. * c-c++-common/gomp/schedule-modifiers-1.c: New test. * c-c++-common/gomp/target-teams-1.c: New test. * gcc.dg/gomp/declare-simd-1.c: Add scan-assembler-times directives for expected mangling on x86_64/i?86. * gcc.dg/gomp/declare-simd-3.c: New test. * gcc.dg/gomp/declare-simd-4.c: New test. * gcc.dg/gomp/for-20.c: New test. * gcc.dg/gomp/for-21.c: New test. * gcc.dg/gomp/for-22.c: New test. * gcc.dg/gomp/for-23.c: New test. * gcc.dg/gomp/for-24.c: New test. * gcc.dg/gomp/linear-1.c: New test. * gcc.dg/gomp/loop-1.c: New test. * g++.dg/gomp/atomic-17.C: New test. * g++.dg/gomp/clause-1.C (T::test): Don't expect error on non-static data member in shared clause. Add single construct. * g++.dg/gomp/declare-simd-1.C: Add dg-options. Add scan-assembler-times directives for expected mangling on x86_64/i?86. * g++.dg/gomp/declare-simd-3.C: Likewise. * g++.dg/gomp/declare-simd-4.C: New test. * g++.dg/gomp/declare-simd-5.C: New test. * g++.dg/gomp/declare-target-1.C: New test. * g++.dg/gomp/linear-2.C: New test. * g++.dg/gomp/loop-1.C: New test. * g++.dg/gomp/loop-2.C: New test. * g++.dg/gomp/loop-3.C: New test. * g++.dg/gomp/member-2.C (B::m2, B::m4): Don't expect error on non-static data member in shared clause. * g++.dg/gomp/member-3.C: New test. * g++.dg/gomp/member-4.C: New test. * g++.dg/gomp/pr38639.C (foo): Adjust dg-error. (bar): Remove dg-message. * g++.dg/gomp/target-teams-1.C: New test. include/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> Ilya Verbin <ilya.verbin@intel.com> * gomp-constants.h (GOMP_MAP_FLAG_SPECIAL_2): Define. (GOMP_MAP_FLAG_ALWAYS): Remove. (enum gomp_map_kind): Use GOMP_MAP_FLAG_SPECIAL_2 instead of GOMP_MAP_FLAG_ALWAYS for GOMP_MAP_ALWAYS_TO, GOMP_MAP_ALWAYS_FROM, GOMP_MAP_ALWAYS_TOFROM, GOMP_MAP_STRUCT, GOMP_MAP_RELEASE. Add GOMP_MAP_ALWAYS_POINTER and GOMP_MAP_FIRSTPRIVATE_REFERENCE. (GOMP_MAP_ALWAYS_P): Define. (GOMP_TARGET_FLAG_NOWAIT): Adjust comment. libgomp/ 2015-11-05 Jakub Jelinek <jakub@redhat.com> Ilya Verbin <ilya.verbin@intel.com> * libgomp_g.h (GOMP_loop_nonmonotonic_dynamic_next, GOMP_loop_nonmonotonic_dynamic_start, GOMP_loop_nonmonotonic_guided_next, GOMP_loop_nonmonotonic_guided_start, GOMP_loop_ull_nonmonotonic_dynamic_next, GOMP_loop_ull_nonmonotonic_dynamic_start, GOMP_loop_ull_nonmonotonic_guided_next, GOMP_loop_ull_nonmonotonic_guided_start, GOMP_parallel_loop_nonmonotonic_dynamic, GOMP_parallel_loop_nonmonotonic_guided): New prototypes. (GOMP_target_41): Renamed to ... (GOMP_target_ext): ... this. Add num_teams and thread_limit arguments. (GOMP_target_data_41): Renamed to ... (GOMP_target_data_ext): ... this. (GOMP_target_update_41): Renamed to ... (GOMP_target_update_ext): ... this. * libgomp.map (GOMP_4.5): Export GOMP_target_ext, GOMP_target_data_ext and GOMP_target_update_ext instead of GOMP_target_41, GOMP_target_data_41 and GOMP_target_update_41. Export GOMP_loop_nonmonotonic_dynamic_next, GOMP_loop_nonmonotonic_dynamic_start, GOMP_loop_nonmonotonic_guided_next, GOMP_loop_nonmonotonic_guided_start, GOMP_loop_ull_nonmonotonic_dynamic_next, GOMP_loop_ull_nonmonotonic_dynamic_start, GOMP_loop_ull_nonmonotonic_guided_next, GOMP_loop_ull_nonmonotonic_guided_start, GOMP_parallel_loop_nonmonotonic_dynamic and GOMP_parallel_loop_nonmonotonic_guided. * loop.c (GOMP_parallel_loop_nonmonotonic_dynamic, GOMP_parallel_loop_nonmonotonic_guided, GOMP_loop_nonmonotonic_dynamic_start, GOMP_loop_nonmonotonic_guided_start, GOMP_loop_nonmonotonic_dynamic_next, GOMP_loop_nonmonotonic_guided_next): New aliases or functions. * loop_ull.c (GOMP_loop_ull_nonmonotonic_dynamic_start, GOMP_loop_ull_nonmonotonic_guided_start, GOMP_loop_ull_nonmonotonic_dynamic_next, GOMP_loop_ull_nonmonotonic_guided_next): Likewise. * target.c (gomp_map_0len_lookup, gomp_map_val): New inline functions. (gomp_map_vars): Handle GOMP_MAP_ALWAYS_POINTER. For GOMP_MAP_ZERO_LEN_ARRAY_SECTION use gomp_map_0len_lookup. Use gomp_map_val function. (gomp_target_fallback_firstprivate): New static function. (GOMP_target_41): Renamed to ... (GOMP_target_ext): ... this. Add num_teams and thread_limit arguments. Move firstprivate fallback handling into a new function. (GOMP_target_data_41): Renamed to ... (GOMP_target_data_ext): ... this. (GOMP_target_update_41): Renamed to ... (GOMP_target_update_ext): ... this. (gomp_exit_data): For GOMP_MAP_*ZERO_LEN* use gomp_map_0len_lookup instead of gomp_map_lookup. (omp_target_is_present): Use gomp_map_0len_lookup instead of gomp_map_lookup. * testsuite/libgomp.c/target-28.c: Likewise. * testsuite/libgomp.c/monotonic-1.c: New test. * testsuite/libgomp.c/monotonic-2.c: New test. * testsuite/libgomp.c/nonmonotonic-1.c: New test. * testsuite/libgomp.c/nonmonotonic-2.c: New test. * testsuite/libgomp.c/pr66199-5.c: New test. * testsuite/libgomp.c/pr66199-6.c: New test. * testsuite/libgomp.c/pr66199-7.c: New test. * testsuite/libgomp.c/pr66199-8.c: New test. * testsuite/libgomp.c/pr66199-9.c: New test. * testsuite/libgomp.c/reduction-11.c: New test. * testsuite/libgomp.c/reduction-12.c: New test. * testsuite/libgomp.c/reduction-13.c: New test. * testsuite/libgomp.c/reduction-14.c: New test. * testsuite/libgomp.c/reduction-15.c: New test. * testsuite/libgomp.c/target-12.c (main): Adjust for omp_target_is_present change for one-past-last element. * testsuite/libgomp.c/target-17.c (foo): Drop tests where the same var is both mapped and privatized. * testsuite/libgomp.c/target-19.c (foo): Adjust for different handling of zero-length array sections. * testsuite/libgomp.c/target-28.c: New test. * testsuite/libgomp.c/target-29.c: New test. * testsuite/libgomp.c/target-30.c: New test. * testsuite/libgomp.c/target-teams-1.c: New test. * testsuite/libgomp.c++/member-6.C: New test. * testsuite/libgomp.c++/member-7.C: New test. * testsuite/libgomp.c++/monotonic-1.C: New test. * testsuite/libgomp.c++/monotonic-2.C: New test. * testsuite/libgomp.c++/nonmonotonic-1.C: New test. * testsuite/libgomp.c++/nonmonotonic-2.C: New test. * testsuite/libgomp.c++/pr66199-3.C: New test. * testsuite/libgomp.c++/pr66199-4.C: New test. * testsuite/libgomp.c++/pr66199-5.C: New test. * testsuite/libgomp.c++/pr66199-6.C: New test. * testsuite/libgomp.c++/pr66199-7.C: New test. * testsuite/libgomp.c++/pr66199-8.C: New test. * testsuite/libgomp.c++/pr66199-9.C: New test. * testsuite/libgomp.c++/reduction-11.C: New test. * testsuite/libgomp.c++/reduction-12.C: New test. * testsuite/libgomp.c++/target-13.C: New test. * testsuite/libgomp.c++/target-14.C: New test. * testsuite/libgomp.c++/target-15.C: New test. * testsuite/libgomp.c++/target-16.C: New test. * testsuite/libgomp.c++/target-17.C: New test. * testsuite/libgomp.c++/target-18.C: New test. * testsuite/libgomp.c++/target-19.C: New test. Co-Authored-By: Ilya Verbin <ilya.verbin@intel.com> From-SVN: r229814
889 lines
26 KiB
C
889 lines
26 KiB
C
/* Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
|
Contributed by Richard Henderson <rth@redhat.com>.
|
|
|
|
This file is part of the GNU Offloading and Multi Processing Library
|
|
(libgomp).
|
|
|
|
Libgomp is free software; you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3, or (at your option)
|
|
any later version.
|
|
|
|
Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
more details.
|
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
/* This file handles the LOOP (FOR/DO) construct. */
|
|
|
|
#include <limits.h>
|
|
#include <stdlib.h>
|
|
#include "libgomp.h"
|
|
|
|
|
|
/* Initialize the given work share construct from the given arguments. */
|
|
|
|
static inline void
|
|
gomp_loop_init (struct gomp_work_share *ws, long start, long end, long incr,
|
|
enum gomp_schedule_type sched, long chunk_size)
|
|
{
|
|
ws->sched = sched;
|
|
ws->chunk_size = chunk_size;
|
|
/* Canonicalize loops that have zero iterations to ->next == ->end. */
|
|
ws->end = ((incr > 0 && start > end) || (incr < 0 && start < end))
|
|
? start : end;
|
|
ws->incr = incr;
|
|
ws->next = start;
|
|
if (sched == GFS_DYNAMIC)
|
|
{
|
|
ws->chunk_size *= incr;
|
|
|
|
#ifdef HAVE_SYNC_BUILTINS
|
|
{
|
|
/* For dynamic scheduling prepare things to make each iteration
|
|
faster. */
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
struct gomp_team *team = thr->ts.team;
|
|
long nthreads = team ? team->nthreads : 1;
|
|
|
|
if (__builtin_expect (incr > 0, 1))
|
|
{
|
|
/* Cheap overflow protection. */
|
|
if (__builtin_expect ((nthreads | ws->chunk_size)
|
|
>= 1UL << (sizeof (long)
|
|
* __CHAR_BIT__ / 2 - 1), 0))
|
|
ws->mode = 0;
|
|
else
|
|
ws->mode = ws->end < (LONG_MAX
|
|
- (nthreads + 1) * ws->chunk_size);
|
|
}
|
|
/* Cheap overflow protection. */
|
|
else if (__builtin_expect ((nthreads | -ws->chunk_size)
|
|
>= 1UL << (sizeof (long)
|
|
* __CHAR_BIT__ / 2 - 1), 0))
|
|
ws->mode = 0;
|
|
else
|
|
ws->mode = ws->end > (nthreads + 1) * -ws->chunk_size - LONG_MAX;
|
|
}
|
|
#endif
|
|
}
|
|
}
|
|
|
|
/* The *_start routines are called when first encountering a loop construct
|
|
that is not bound directly to a parallel construct. The first thread
|
|
that arrives will create the work-share construct; subsequent threads
|
|
will see the construct exists and allocate work from it.
|
|
|
|
START, END, INCR are the bounds of the loop; due to the restrictions of
|
|
OpenMP, these values must be the same in every thread. This is not
|
|
verified (nor is it entirely verifiable, since START is not necessarily
|
|
retained intact in the work-share data structure). CHUNK_SIZE is the
|
|
scheduling parameter; again this must be identical in all threads.
|
|
|
|
Returns true if there's any work for this thread to perform. If so,
|
|
*ISTART and *IEND are filled with the bounds of the iteration block
|
|
allocated to this thread. Returns false if all work was assigned to
|
|
other threads prior to this thread's arrival. */
|
|
|
|
static bool
|
|
gomp_loop_static_start (long start, long end, long incr, long chunk_size,
|
|
long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
|
|
thr->ts.static_trip = 0;
|
|
if (gomp_work_share_start (false))
|
|
{
|
|
gomp_loop_init (thr->ts.work_share, start, end, incr,
|
|
GFS_STATIC, chunk_size);
|
|
gomp_work_share_init_done ();
|
|
}
|
|
|
|
return !gomp_iter_static_next (istart, iend);
|
|
}
|
|
|
|
/* The current dynamic implementation is always monotonic. The
|
|
entrypoints without nonmonotonic in them have to be always monotonic,
|
|
but the nonmonotonic ones could be changed to use work-stealing for
|
|
improved scalability. */
|
|
|
|
static bool
|
|
gomp_loop_dynamic_start (long start, long end, long incr, long chunk_size,
|
|
long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
bool ret;
|
|
|
|
if (gomp_work_share_start (false))
|
|
{
|
|
gomp_loop_init (thr->ts.work_share, start, end, incr,
|
|
GFS_DYNAMIC, chunk_size);
|
|
gomp_work_share_init_done ();
|
|
}
|
|
|
|
#ifdef HAVE_SYNC_BUILTINS
|
|
ret = gomp_iter_dynamic_next (istart, iend);
|
|
#else
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
ret = gomp_iter_dynamic_next_locked (istart, iend);
|
|
gomp_mutex_unlock (&thr->ts.work_share->lock);
|
|
#endif
|
|
|
|
return ret;
|
|
}
|
|
|
|
/* Similarly as for dynamic, though the question is how can the chunk sizes
|
|
be decreased without a central locking or atomics. */
|
|
|
|
static bool
|
|
gomp_loop_guided_start (long start, long end, long incr, long chunk_size,
|
|
long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
bool ret;
|
|
|
|
if (gomp_work_share_start (false))
|
|
{
|
|
gomp_loop_init (thr->ts.work_share, start, end, incr,
|
|
GFS_GUIDED, chunk_size);
|
|
gomp_work_share_init_done ();
|
|
}
|
|
|
|
#ifdef HAVE_SYNC_BUILTINS
|
|
ret = gomp_iter_guided_next (istart, iend);
|
|
#else
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
ret = gomp_iter_guided_next_locked (istart, iend);
|
|
gomp_mutex_unlock (&thr->ts.work_share->lock);
|
|
#endif
|
|
|
|
return ret;
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_runtime_start (long start, long end, long incr,
|
|
long *istart, long *iend)
|
|
{
|
|
struct gomp_task_icv *icv = gomp_icv (false);
|
|
switch (icv->run_sched_var)
|
|
{
|
|
case GFS_STATIC:
|
|
return gomp_loop_static_start (start, end, incr,
|
|
icv->run_sched_chunk_size,
|
|
istart, iend);
|
|
case GFS_DYNAMIC:
|
|
return gomp_loop_dynamic_start (start, end, incr,
|
|
icv->run_sched_chunk_size,
|
|
istart, iend);
|
|
case GFS_GUIDED:
|
|
return gomp_loop_guided_start (start, end, incr,
|
|
icv->run_sched_chunk_size,
|
|
istart, iend);
|
|
case GFS_AUTO:
|
|
/* For now map to schedule(static), later on we could play with feedback
|
|
driven choice. */
|
|
return gomp_loop_static_start (start, end, incr, 0, istart, iend);
|
|
default:
|
|
abort ();
|
|
}
|
|
}
|
|
|
|
/* The *_ordered_*_start routines are similar. The only difference is that
|
|
this work-share construct is initialized to expect an ORDERED section. */
|
|
|
|
static bool
|
|
gomp_loop_ordered_static_start (long start, long end, long incr,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
|
|
thr->ts.static_trip = 0;
|
|
if (gomp_work_share_start (true))
|
|
{
|
|
gomp_loop_init (thr->ts.work_share, start, end, incr,
|
|
GFS_STATIC, chunk_size);
|
|
gomp_ordered_static_init ();
|
|
gomp_work_share_init_done ();
|
|
}
|
|
|
|
return !gomp_iter_static_next (istart, iend);
|
|
}
|
|
|
|
static bool
|
|
gomp_loop_ordered_dynamic_start (long start, long end, long incr,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
bool ret;
|
|
|
|
if (gomp_work_share_start (true))
|
|
{
|
|
gomp_loop_init (thr->ts.work_share, start, end, incr,
|
|
GFS_DYNAMIC, chunk_size);
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
gomp_work_share_init_done ();
|
|
}
|
|
else
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
|
|
ret = gomp_iter_dynamic_next_locked (istart, iend);
|
|
if (ret)
|
|
gomp_ordered_first ();
|
|
gomp_mutex_unlock (&thr->ts.work_share->lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static bool
|
|
gomp_loop_ordered_guided_start (long start, long end, long incr,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
bool ret;
|
|
|
|
if (gomp_work_share_start (true))
|
|
{
|
|
gomp_loop_init (thr->ts.work_share, start, end, incr,
|
|
GFS_GUIDED, chunk_size);
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
gomp_work_share_init_done ();
|
|
}
|
|
else
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
|
|
ret = gomp_iter_guided_next_locked (istart, iend);
|
|
if (ret)
|
|
gomp_ordered_first ();
|
|
gomp_mutex_unlock (&thr->ts.work_share->lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_ordered_runtime_start (long start, long end, long incr,
|
|
long *istart, long *iend)
|
|
{
|
|
struct gomp_task_icv *icv = gomp_icv (false);
|
|
switch (icv->run_sched_var)
|
|
{
|
|
case GFS_STATIC:
|
|
return gomp_loop_ordered_static_start (start, end, incr,
|
|
icv->run_sched_chunk_size,
|
|
istart, iend);
|
|
case GFS_DYNAMIC:
|
|
return gomp_loop_ordered_dynamic_start (start, end, incr,
|
|
icv->run_sched_chunk_size,
|
|
istart, iend);
|
|
case GFS_GUIDED:
|
|
return gomp_loop_ordered_guided_start (start, end, incr,
|
|
icv->run_sched_chunk_size,
|
|
istart, iend);
|
|
case GFS_AUTO:
|
|
/* For now map to schedule(static), later on we could play with feedback
|
|
driven choice. */
|
|
return gomp_loop_ordered_static_start (start, end, incr,
|
|
0, istart, iend);
|
|
default:
|
|
abort ();
|
|
}
|
|
}
|
|
|
|
/* The *_doacross_*_start routines are similar. The only difference is that
|
|
this work-share construct is initialized to expect an ORDERED(N) - DOACROSS
|
|
section, and the worksharing loop iterates always from 0 to COUNTS[0] - 1
|
|
and other COUNTS array elements tell the library number of iterations
|
|
in the ordered inner loops. */
|
|
|
|
static bool
|
|
gomp_loop_doacross_static_start (unsigned ncounts, long *counts,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
|
|
thr->ts.static_trip = 0;
|
|
if (gomp_work_share_start (false))
|
|
{
|
|
gomp_loop_init (thr->ts.work_share, 0, counts[0], 1,
|
|
GFS_STATIC, chunk_size);
|
|
gomp_doacross_init (ncounts, counts, chunk_size);
|
|
gomp_work_share_init_done ();
|
|
}
|
|
|
|
return !gomp_iter_static_next (istart, iend);
|
|
}
|
|
|
|
static bool
|
|
gomp_loop_doacross_dynamic_start (unsigned ncounts, long *counts,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
bool ret;
|
|
|
|
if (gomp_work_share_start (false))
|
|
{
|
|
gomp_loop_init (thr->ts.work_share, 0, counts[0], 1,
|
|
GFS_DYNAMIC, chunk_size);
|
|
gomp_doacross_init (ncounts, counts, chunk_size);
|
|
gomp_work_share_init_done ();
|
|
}
|
|
|
|
#ifdef HAVE_SYNC_BUILTINS
|
|
ret = gomp_iter_dynamic_next (istart, iend);
|
|
#else
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
ret = gomp_iter_dynamic_next_locked (istart, iend);
|
|
gomp_mutex_unlock (&thr->ts.work_share->lock);
|
|
#endif
|
|
|
|
return ret;
|
|
}
|
|
|
|
static bool
|
|
gomp_loop_doacross_guided_start (unsigned ncounts, long *counts,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
bool ret;
|
|
|
|
if (gomp_work_share_start (false))
|
|
{
|
|
gomp_loop_init (thr->ts.work_share, 0, counts[0], 1,
|
|
GFS_GUIDED, chunk_size);
|
|
gomp_doacross_init (ncounts, counts, chunk_size);
|
|
gomp_work_share_init_done ();
|
|
}
|
|
|
|
#ifdef HAVE_SYNC_BUILTINS
|
|
ret = gomp_iter_guided_next (istart, iend);
|
|
#else
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
ret = gomp_iter_guided_next_locked (istart, iend);
|
|
gomp_mutex_unlock (&thr->ts.work_share->lock);
|
|
#endif
|
|
|
|
return ret;
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_doacross_runtime_start (unsigned ncounts, long *counts,
|
|
long *istart, long *iend)
|
|
{
|
|
struct gomp_task_icv *icv = gomp_icv (false);
|
|
switch (icv->run_sched_var)
|
|
{
|
|
case GFS_STATIC:
|
|
return gomp_loop_doacross_static_start (ncounts, counts,
|
|
icv->run_sched_chunk_size,
|
|
istart, iend);
|
|
case GFS_DYNAMIC:
|
|
return gomp_loop_doacross_dynamic_start (ncounts, counts,
|
|
icv->run_sched_chunk_size,
|
|
istart, iend);
|
|
case GFS_GUIDED:
|
|
return gomp_loop_doacross_guided_start (ncounts, counts,
|
|
icv->run_sched_chunk_size,
|
|
istart, iend);
|
|
case GFS_AUTO:
|
|
/* For now map to schedule(static), later on we could play with feedback
|
|
driven choice. */
|
|
return gomp_loop_doacross_static_start (ncounts, counts,
|
|
0, istart, iend);
|
|
default:
|
|
abort ();
|
|
}
|
|
}
|
|
|
|
/* The *_next routines are called when the thread completes processing of
|
|
the iteration block currently assigned to it. If the work-share
|
|
construct is bound directly to a parallel construct, then the iteration
|
|
bounds may have been set up before the parallel. In which case, this
|
|
may be the first iteration for the thread.
|
|
|
|
Returns true if there is work remaining to be performed; *ISTART and
|
|
*IEND are filled with a new iteration block. Returns false if all work
|
|
has been assigned. */
|
|
|
|
static bool
|
|
gomp_loop_static_next (long *istart, long *iend)
|
|
{
|
|
return !gomp_iter_static_next (istart, iend);
|
|
}
|
|
|
|
static bool
|
|
gomp_loop_dynamic_next (long *istart, long *iend)
|
|
{
|
|
bool ret;
|
|
|
|
#ifdef HAVE_SYNC_BUILTINS
|
|
ret = gomp_iter_dynamic_next (istart, iend);
|
|
#else
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
ret = gomp_iter_dynamic_next_locked (istart, iend);
|
|
gomp_mutex_unlock (&thr->ts.work_share->lock);
|
|
#endif
|
|
|
|
return ret;
|
|
}
|
|
|
|
static bool
|
|
gomp_loop_guided_next (long *istart, long *iend)
|
|
{
|
|
bool ret;
|
|
|
|
#ifdef HAVE_SYNC_BUILTINS
|
|
ret = gomp_iter_guided_next (istart, iend);
|
|
#else
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
ret = gomp_iter_guided_next_locked (istart, iend);
|
|
gomp_mutex_unlock (&thr->ts.work_share->lock);
|
|
#endif
|
|
|
|
return ret;
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_runtime_next (long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
|
|
switch (thr->ts.work_share->sched)
|
|
{
|
|
case GFS_STATIC:
|
|
case GFS_AUTO:
|
|
return gomp_loop_static_next (istart, iend);
|
|
case GFS_DYNAMIC:
|
|
return gomp_loop_dynamic_next (istart, iend);
|
|
case GFS_GUIDED:
|
|
return gomp_loop_guided_next (istart, iend);
|
|
default:
|
|
abort ();
|
|
}
|
|
}
|
|
|
|
/* The *_ordered_*_next routines are called when the thread completes
|
|
processing of the iteration block currently assigned to it.
|
|
|
|
Returns true if there is work remaining to be performed; *ISTART and
|
|
*IEND are filled with a new iteration block. Returns false if all work
|
|
has been assigned. */
|
|
|
|
static bool
|
|
gomp_loop_ordered_static_next (long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
int test;
|
|
|
|
gomp_ordered_sync ();
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
test = gomp_iter_static_next (istart, iend);
|
|
if (test >= 0)
|
|
gomp_ordered_static_next ();
|
|
gomp_mutex_unlock (&thr->ts.work_share->lock);
|
|
|
|
return test == 0;
|
|
}
|
|
|
|
static bool
|
|
gomp_loop_ordered_dynamic_next (long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
bool ret;
|
|
|
|
gomp_ordered_sync ();
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
ret = gomp_iter_dynamic_next_locked (istart, iend);
|
|
if (ret)
|
|
gomp_ordered_next ();
|
|
else
|
|
gomp_ordered_last ();
|
|
gomp_mutex_unlock (&thr->ts.work_share->lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static bool
|
|
gomp_loop_ordered_guided_next (long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
bool ret;
|
|
|
|
gomp_ordered_sync ();
|
|
gomp_mutex_lock (&thr->ts.work_share->lock);
|
|
ret = gomp_iter_guided_next_locked (istart, iend);
|
|
if (ret)
|
|
gomp_ordered_next ();
|
|
else
|
|
gomp_ordered_last ();
|
|
gomp_mutex_unlock (&thr->ts.work_share->lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_ordered_runtime_next (long *istart, long *iend)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
|
|
switch (thr->ts.work_share->sched)
|
|
{
|
|
case GFS_STATIC:
|
|
case GFS_AUTO:
|
|
return gomp_loop_ordered_static_next (istart, iend);
|
|
case GFS_DYNAMIC:
|
|
return gomp_loop_ordered_dynamic_next (istart, iend);
|
|
case GFS_GUIDED:
|
|
return gomp_loop_ordered_guided_next (istart, iend);
|
|
default:
|
|
abort ();
|
|
}
|
|
}
|
|
|
|
/* The GOMP_parallel_loop_* routines pre-initialize a work-share construct
|
|
to avoid one synchronization once we get into the loop. */
|
|
|
|
static void
|
|
gomp_parallel_loop_start (void (*fn) (void *), void *data,
|
|
unsigned num_threads, long start, long end,
|
|
long incr, enum gomp_schedule_type sched,
|
|
long chunk_size, unsigned int flags)
|
|
{
|
|
struct gomp_team *team;
|
|
|
|
num_threads = gomp_resolve_num_threads (num_threads, 0);
|
|
team = gomp_new_team (num_threads);
|
|
gomp_loop_init (&team->work_shares[0], start, end, incr, sched, chunk_size);
|
|
gomp_team_start (fn, data, num_threads, flags, team);
|
|
}
|
|
|
|
void
|
|
GOMP_parallel_loop_static_start (void (*fn) (void *), void *data,
|
|
unsigned num_threads, long start, long end,
|
|
long incr, long chunk_size)
|
|
{
|
|
gomp_parallel_loop_start (fn, data, num_threads, start, end, incr,
|
|
GFS_STATIC, chunk_size, 0);
|
|
}
|
|
|
|
void
|
|
GOMP_parallel_loop_dynamic_start (void (*fn) (void *), void *data,
|
|
unsigned num_threads, long start, long end,
|
|
long incr, long chunk_size)
|
|
{
|
|
gomp_parallel_loop_start (fn, data, num_threads, start, end, incr,
|
|
GFS_DYNAMIC, chunk_size, 0);
|
|
}
|
|
|
|
void
|
|
GOMP_parallel_loop_guided_start (void (*fn) (void *), void *data,
|
|
unsigned num_threads, long start, long end,
|
|
long incr, long chunk_size)
|
|
{
|
|
gomp_parallel_loop_start (fn, data, num_threads, start, end, incr,
|
|
GFS_GUIDED, chunk_size, 0);
|
|
}
|
|
|
|
void
|
|
GOMP_parallel_loop_runtime_start (void (*fn) (void *), void *data,
|
|
unsigned num_threads, long start, long end,
|
|
long incr)
|
|
{
|
|
struct gomp_task_icv *icv = gomp_icv (false);
|
|
gomp_parallel_loop_start (fn, data, num_threads, start, end, incr,
|
|
icv->run_sched_var, icv->run_sched_chunk_size, 0);
|
|
}
|
|
|
|
ialias_redirect (GOMP_parallel_end)
|
|
|
|
void
|
|
GOMP_parallel_loop_static (void (*fn) (void *), void *data,
|
|
unsigned num_threads, long start, long end,
|
|
long incr, long chunk_size, unsigned flags)
|
|
{
|
|
gomp_parallel_loop_start (fn, data, num_threads, start, end, incr,
|
|
GFS_STATIC, chunk_size, flags);
|
|
fn (data);
|
|
GOMP_parallel_end ();
|
|
}
|
|
|
|
void
|
|
GOMP_parallel_loop_dynamic (void (*fn) (void *), void *data,
|
|
unsigned num_threads, long start, long end,
|
|
long incr, long chunk_size, unsigned flags)
|
|
{
|
|
gomp_parallel_loop_start (fn, data, num_threads, start, end, incr,
|
|
GFS_DYNAMIC, chunk_size, flags);
|
|
fn (data);
|
|
GOMP_parallel_end ();
|
|
}
|
|
|
|
void
|
|
GOMP_parallel_loop_guided (void (*fn) (void *), void *data,
|
|
unsigned num_threads, long start, long end,
|
|
long incr, long chunk_size, unsigned flags)
|
|
{
|
|
gomp_parallel_loop_start (fn, data, num_threads, start, end, incr,
|
|
GFS_GUIDED, chunk_size, flags);
|
|
fn (data);
|
|
GOMP_parallel_end ();
|
|
}
|
|
|
|
#ifdef HAVE_ATTRIBUTE_ALIAS
|
|
extern __typeof(GOMP_parallel_loop_dynamic) GOMP_parallel_loop_nonmonotonic_dynamic
|
|
__attribute__((alias ("GOMP_parallel_loop_dynamic")));
|
|
extern __typeof(GOMP_parallel_loop_guided) GOMP_parallel_loop_nonmonotonic_guided
|
|
__attribute__((alias ("GOMP_parallel_loop_guided")));
|
|
#else
|
|
void
|
|
GOMP_parallel_loop_nonmonotonic_dynamic (void (*fn) (void *), void *data,
|
|
unsigned num_threads, long start,
|
|
long end, long incr, long chunk_size,
|
|
unsigned flags)
|
|
{
|
|
gomp_parallel_loop_start (fn, data, num_threads, start, end, incr,
|
|
GFS_DYNAMIC, chunk_size, flags);
|
|
fn (data);
|
|
GOMP_parallel_end ();
|
|
}
|
|
|
|
void
|
|
GOMP_parallel_loop_nonmonotonic_guided (void (*fn) (void *), void *data,
|
|
unsigned num_threads, long start,
|
|
long end, long incr, long chunk_size,
|
|
unsigned flags)
|
|
{
|
|
gomp_parallel_loop_start (fn, data, num_threads, start, end, incr,
|
|
GFS_GUIDED, chunk_size, flags);
|
|
fn (data);
|
|
GOMP_parallel_end ();
|
|
}
|
|
#endif
|
|
|
|
void
|
|
GOMP_parallel_loop_runtime (void (*fn) (void *), void *data,
|
|
unsigned num_threads, long start, long end,
|
|
long incr, unsigned flags)
|
|
{
|
|
struct gomp_task_icv *icv = gomp_icv (false);
|
|
gomp_parallel_loop_start (fn, data, num_threads, start, end, incr,
|
|
icv->run_sched_var, icv->run_sched_chunk_size,
|
|
flags);
|
|
fn (data);
|
|
GOMP_parallel_end ();
|
|
}
|
|
|
|
/* The GOMP_loop_end* routines are called after the thread is told that
|
|
all loop iterations are complete. The first two versions synchronize
|
|
all threads; the nowait version does not. */
|
|
|
|
void
|
|
GOMP_loop_end (void)
|
|
{
|
|
gomp_work_share_end ();
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_end_cancel (void)
|
|
{
|
|
return gomp_work_share_end_cancel ();
|
|
}
|
|
|
|
void
|
|
GOMP_loop_end_nowait (void)
|
|
{
|
|
gomp_work_share_end_nowait ();
|
|
}
|
|
|
|
|
|
/* We use static functions above so that we're sure that the "runtime"
|
|
function can defer to the proper routine without interposition. We
|
|
export the static function with a strong alias when possible, or with
|
|
a wrapper function otherwise. */
|
|
|
|
#ifdef HAVE_ATTRIBUTE_ALIAS
|
|
extern __typeof(gomp_loop_static_start) GOMP_loop_static_start
|
|
__attribute__((alias ("gomp_loop_static_start")));
|
|
extern __typeof(gomp_loop_dynamic_start) GOMP_loop_dynamic_start
|
|
__attribute__((alias ("gomp_loop_dynamic_start")));
|
|
extern __typeof(gomp_loop_guided_start) GOMP_loop_guided_start
|
|
__attribute__((alias ("gomp_loop_guided_start")));
|
|
extern __typeof(gomp_loop_dynamic_start) GOMP_loop_nonmonotonic_dynamic_start
|
|
__attribute__((alias ("gomp_loop_dynamic_start")));
|
|
extern __typeof(gomp_loop_guided_start) GOMP_loop_nonmonotonic_guided_start
|
|
__attribute__((alias ("gomp_loop_guided_start")));
|
|
|
|
extern __typeof(gomp_loop_ordered_static_start) GOMP_loop_ordered_static_start
|
|
__attribute__((alias ("gomp_loop_ordered_static_start")));
|
|
extern __typeof(gomp_loop_ordered_dynamic_start) GOMP_loop_ordered_dynamic_start
|
|
__attribute__((alias ("gomp_loop_ordered_dynamic_start")));
|
|
extern __typeof(gomp_loop_ordered_guided_start) GOMP_loop_ordered_guided_start
|
|
__attribute__((alias ("gomp_loop_ordered_guided_start")));
|
|
|
|
extern __typeof(gomp_loop_doacross_static_start) GOMP_loop_doacross_static_start
|
|
__attribute__((alias ("gomp_loop_doacross_static_start")));
|
|
extern __typeof(gomp_loop_doacross_dynamic_start) GOMP_loop_doacross_dynamic_start
|
|
__attribute__((alias ("gomp_loop_doacross_dynamic_start")));
|
|
extern __typeof(gomp_loop_doacross_guided_start) GOMP_loop_doacross_guided_start
|
|
__attribute__((alias ("gomp_loop_doacross_guided_start")));
|
|
|
|
extern __typeof(gomp_loop_static_next) GOMP_loop_static_next
|
|
__attribute__((alias ("gomp_loop_static_next")));
|
|
extern __typeof(gomp_loop_dynamic_next) GOMP_loop_dynamic_next
|
|
__attribute__((alias ("gomp_loop_dynamic_next")));
|
|
extern __typeof(gomp_loop_guided_next) GOMP_loop_guided_next
|
|
__attribute__((alias ("gomp_loop_guided_next")));
|
|
extern __typeof(gomp_loop_dynamic_next) GOMP_loop_nonmonotonic_dynamic_next
|
|
__attribute__((alias ("gomp_loop_dynamic_next")));
|
|
extern __typeof(gomp_loop_guided_next) GOMP_loop_nonmonotonic_guided_next
|
|
__attribute__((alias ("gomp_loop_guided_next")));
|
|
|
|
extern __typeof(gomp_loop_ordered_static_next) GOMP_loop_ordered_static_next
|
|
__attribute__((alias ("gomp_loop_ordered_static_next")));
|
|
extern __typeof(gomp_loop_ordered_dynamic_next) GOMP_loop_ordered_dynamic_next
|
|
__attribute__((alias ("gomp_loop_ordered_dynamic_next")));
|
|
extern __typeof(gomp_loop_ordered_guided_next) GOMP_loop_ordered_guided_next
|
|
__attribute__((alias ("gomp_loop_ordered_guided_next")));
|
|
#else
|
|
bool
|
|
GOMP_loop_static_start (long start, long end, long incr, long chunk_size,
|
|
long *istart, long *iend)
|
|
{
|
|
return gomp_loop_static_start (start, end, incr, chunk_size, istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_dynamic_start (long start, long end, long incr, long chunk_size,
|
|
long *istart, long *iend)
|
|
{
|
|
return gomp_loop_dynamic_start (start, end, incr, chunk_size, istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_guided_start (long start, long end, long incr, long chunk_size,
|
|
long *istart, long *iend)
|
|
{
|
|
return gomp_loop_guided_start (start, end, incr, chunk_size, istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_nonmonotonic_dynamic_start (long start, long end, long incr,
|
|
long chunk_size, long *istart,
|
|
long *iend)
|
|
{
|
|
return gomp_loop_dynamic_start (start, end, incr, chunk_size, istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_nonmonotonic_guided_start (long start, long end, long incr,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
return gomp_loop_guided_start (start, end, incr, chunk_size, istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_ordered_static_start (long start, long end, long incr,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
return gomp_loop_ordered_static_start (start, end, incr, chunk_size,
|
|
istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_ordered_dynamic_start (long start, long end, long incr,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
return gomp_loop_ordered_dynamic_start (start, end, incr, chunk_size,
|
|
istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_ordered_guided_start (long start, long end, long incr,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
return gomp_loop_ordered_guided_start (start, end, incr, chunk_size,
|
|
istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_doacross_static_start (unsigned ncounts, long *counts,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
return gomp_loop_doacross_static_start (ncounts, counts, chunk_size,
|
|
istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_doacross_dynamic_start (unsigned ncounts, long *counts,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
return gomp_loop_doacross_dynamic_start (ncounts, counts, chunk_size,
|
|
istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_doacross_guided_start (unsigned ncounts, long *counts,
|
|
long chunk_size, long *istart, long *iend)
|
|
{
|
|
return gomp_loop_doacross_guided_start (ncounts, counts, chunk_size,
|
|
istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_static_next (long *istart, long *iend)
|
|
{
|
|
return gomp_loop_static_next (istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_dynamic_next (long *istart, long *iend)
|
|
{
|
|
return gomp_loop_dynamic_next (istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_guided_next (long *istart, long *iend)
|
|
{
|
|
return gomp_loop_guided_next (istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_nonmonotonic_dynamic_next (long *istart, long *iend)
|
|
{
|
|
return gomp_loop_dynamic_next (istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_nonmonotonic_guided_next (long *istart, long *iend)
|
|
{
|
|
return gomp_loop_guided_next (istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_ordered_static_next (long *istart, long *iend)
|
|
{
|
|
return gomp_loop_ordered_static_next (istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_ordered_dynamic_next (long *istart, long *iend)
|
|
{
|
|
return gomp_loop_ordered_dynamic_next (istart, iend);
|
|
}
|
|
|
|
bool
|
|
GOMP_loop_ordered_guided_next (long *istart, long *iend)
|
|
{
|
|
return gomp_loop_ordered_guided_next (istart, iend);
|
|
}
|
|
#endif
|