diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-05 15:08:08 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-05 15:08:08 +0000 |
commit | 9561765e2f1fbf62fe6844629ca60501078228d4 (patch) | |
tree | 88a0767ea20a49ed4ad6baaa5116b7f228580c68 /libgomp/target.c | |
parent | e1037942590e094a16a0dad5da85dd03b010ae38 (diff) | |
download | gcc-9561765e2f1fbf62fe6844629ca60501078228d4.tar.gz |
gcc/
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229814 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp/target.c')
-rw-r--r-- | libgomp/target.c | 205 |
1 files changed, 140 insertions, 65 deletions
diff --git a/libgomp/target.c b/libgomp/target.c index b7674100326..1bddc6ffcee 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -162,7 +162,20 @@ gomp_map_lookup (splay_tree mem_map, splay_tree_key key) return splay_tree_lookup (mem_map, key); } -/* Handle the case where gomp_map_lookup found oldn for newn. +static inline splay_tree_key +gomp_map_0len_lookup (splay_tree mem_map, splay_tree_key key) +{ + if (key->host_start != key->host_end) + return splay_tree_lookup (mem_map, key); + + key->host_end++; + splay_tree_key n = splay_tree_lookup (mem_map, key); + key->host_end--; + return n; +} + +/* Handle the case where gomp_map_lookup, splay_tree_lookup or + gomp_map_0len_lookup found oldn for newn. Helper function of gomp_map_vars. */ static inline void @@ -306,6 +319,26 @@ gomp_map_fields_existing (struct target_mem_desc *tgt, splay_tree_key n, (void *) cur_node.host_end); } +static inline uintptr_t +gomp_map_val (struct target_mem_desc *tgt, void **hostaddrs, size_t i) +{ + if (tgt->list[i].key != NULL) + return tgt->list[i].key->tgt->tgt_start + + tgt->list[i].key->tgt_offset + + tgt->list[i].offset; + if (tgt->list[i].offset == ~(uintptr_t) 0) + return (uintptr_t) hostaddrs[i]; + if (tgt->list[i].offset == ~(uintptr_t) 1) + return 0; + if (tgt->list[i].offset == ~(uintptr_t) 2) + return tgt->list[i + 1].key->tgt->tgt_start + + tgt->list[i + 1].key->tgt_offset + + tgt->list[i + 1].offset + + (uintptr_t) hostaddrs[i] + - (uintptr_t) hostaddrs[i + 1]; + return tgt->tgt_start + tgt->list[i].offset; +} + attribute_hidden struct target_mem_desc * gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, void **hostaddrs, void **devaddrs, size_t *sizes, void *kinds, @@ -400,6 +433,13 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, i--; continue; } + else if ((kind & typemask) == GOMP_MAP_ALWAYS_POINTER) + { + tgt->list[i].key = NULL; + tgt->list[i].offset = ~(uintptr_t) 1; + has_firstprivate = true; + continue; + } cur_node.host_start = (uintptr_t) hostaddrs[i]; if (!GOMP_MAP_POINTER_P (kind & typemask)) cur_node.host_end = cur_node.host_start + sizes[i]; @@ -420,7 +460,7 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, splay_tree_key n; if ((kind & typemask) == GOMP_MAP_ZERO_LEN_ARRAY_SECTION) { - n = gomp_map_lookup (mem_map, &cur_node); + n = gomp_map_0len_lookup (mem_map, &cur_node); if (!n) { tgt->list[i].key = NULL; @@ -558,6 +598,32 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, sizes, kinds); i--; continue; + case GOMP_MAP_ALWAYS_POINTER: + cur_node.host_start = (uintptr_t) hostaddrs[i]; + cur_node.host_end = cur_node.host_start + sizeof (void *); + n = splay_tree_lookup (mem_map, &cur_node); + if (n == NULL + || n->host_start > cur_node.host_start + || n->host_end < cur_node.host_end) + { + gomp_mutex_unlock (&devicep->lock); + gomp_fatal ("always pointer not mapped"); + } + if ((get_kind (short_mapkind, kinds, i - 1) & typemask) + != GOMP_MAP_ALWAYS_POINTER) + cur_node.tgt_offset = gomp_map_val (tgt, hostaddrs, i - 1); + if (cur_node.tgt_offset) + cur_node.tgt_offset -= sizes[i]; + devicep->host2dev_func (devicep->target_id, + (void *) (n->tgt->tgt_start + + n->tgt_offset + + cur_node.host_start + - n->host_start), + (void *) &cur_node.tgt_offset, + sizeof (void *)); + cur_node.tgt_offset = n->tgt->tgt_start + n->tgt_offset + + cur_node.host_start - n->host_start; + continue; default: break; } @@ -701,26 +767,7 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, { for (i = 0; i < mapnum; i++) { - if (tgt->list[i].key == NULL) - { - if (tgt->list[i].offset == ~(uintptr_t) 0) - cur_node.tgt_offset = (uintptr_t) hostaddrs[i]; - else if (tgt->list[i].offset == ~(uintptr_t) 1) - cur_node.tgt_offset = 0; - else if (tgt->list[i].offset == ~(uintptr_t) 2) - cur_node.tgt_offset = tgt->list[i + 1].key->tgt->tgt_start - + tgt->list[i + 1].key->tgt_offset - + tgt->list[i + 1].offset - + (uintptr_t) hostaddrs[i] - - (uintptr_t) hostaddrs[i + 1]; - else - cur_node.tgt_offset = tgt->tgt_start - + tgt->list[i].offset; - } - else - cur_node.tgt_offset = tgt->list[i].key->tgt->tgt_start - + tgt->list[i].key->tgt_offset - + tgt->list[i].offset; + cur_node.tgt_offset = gomp_map_val (tgt, hostaddrs, i); /* FIXME: see above FIXME comment. */ devicep->host2dev_func (devicep->target_id, (void *) (tgt->tgt_start @@ -1213,7 +1260,7 @@ gomp_fini_device (struct gomp_device_descr *devicep) devicep->is_initialized = false; } -/* Host fallback for GOMP_target{,_41} routines. */ +/* Host fallback for GOMP_target{,_ext} routines. */ static void gomp_target_fallback (void (*fn) (void *), void **hostaddrs) @@ -1231,7 +1278,45 @@ gomp_target_fallback (void (*fn) (void *), void **hostaddrs) *thr = old_thr; } -/* Helper function of GOMP_target{,_41} routines. */ +/* Host fallback with firstprivate map-type handling. */ + +static void +gomp_target_fallback_firstprivate (void (*fn) (void *), size_t mapnum, + void **hostaddrs, size_t *sizes, + unsigned short *kinds) +{ + size_t i, tgt_align = 0, tgt_size = 0; + char *tgt = NULL; + for (i = 0; i < mapnum; i++) + if ((kinds[i] & 0xff) == GOMP_MAP_FIRSTPRIVATE) + { + size_t align = (size_t) 1 << (kinds[i] >> 8); + if (tgt_align < align) + tgt_align = align; + tgt_size = (tgt_size + align - 1) & ~(align - 1); + tgt_size += sizes[i]; + } + if (tgt_align) + { + tgt = gomp_alloca (tgt_size + tgt_align - 1); + uintptr_t al = (uintptr_t) tgt & (tgt_align - 1); + if (al) + tgt += tgt_align - al; + tgt_size = 0; + for (i = 0; i < mapnum; i++) + if ((kinds[i] & 0xff) == GOMP_MAP_FIRSTPRIVATE) + { + size_t align = (size_t) 1 << (kinds[i] >> 8); + tgt_size = (tgt_size + align - 1) & ~(align - 1); + memcpy (tgt + tgt_size, hostaddrs[i], sizes[i]); + hostaddrs[i] = tgt + tgt_size; + tgt_size = tgt_size + sizes[i]; + } + } + gomp_target_fallback (fn, hostaddrs); +} + +/* Helper function of GOMP_target{,_ext} routines. */ static void * gomp_get_target_fn_addr (struct gomp_device_descr *devicep, @@ -1294,13 +1379,31 @@ GOMP_target (int device, void (*fn) (void *), const void *unused, gomp_unmap_vars (tgt_vars, true); } +/* Like GOMP_target, but KINDS is 16-bit, UNUSED is no longer present, + and several arguments have been added: + FLAGS is a bitmask, see GOMP_TARGET_FLAG_* in gomp-constants.h. + DEPEND is array of dependencies, see GOMP_task for details. + NUM_TEAMS is positive if GOMP_teams will be called in the body with + that value, or 1 if teams construct is not present, or 0, if + teams construct does not have num_teams clause and so the choice is + implementation defined, and -1 if it can't be determined on the host + what value will GOMP_teams have on the device. + THREAD_LIMIT similarly is positive if GOMP_teams will be called in the + body with that value, or 0, if teams construct does not have thread_limit + clause or the teams construct is not present, or -1 if it can't be + determined on the host what value will GOMP_teams have on the device. */ + void -GOMP_target_41 (int device, void (*fn) (void *), size_t mapnum, - void **hostaddrs, size_t *sizes, unsigned short *kinds, - unsigned int flags, void **depend) +GOMP_target_ext (int device, void (*fn) (void *), size_t mapnum, + void **hostaddrs, size_t *sizes, unsigned short *kinds, + unsigned int flags, void **depend, int num_teams, + int thread_limit) { struct gomp_device_descr *devicep = resolve_device (device); + (void) num_teams; + (void) thread_limit; + /* If there are depend clauses, but nowait is not present, block the parent task until the dependencies are resolved and then just continue with the rest of the function as if it @@ -1315,35 +1418,7 @@ GOMP_target_41 (int device, void (*fn) (void *), size_t mapnum, if (devicep == NULL || !(devicep->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400)) { - size_t i, tgt_align = 0, tgt_size = 0; - char *tgt = NULL; - for (i = 0; i < mapnum; i++) - if ((kinds[i] & 0xff) == GOMP_MAP_FIRSTPRIVATE) - { - size_t align = (size_t) 1 << (kinds[i] >> 8); - if (tgt_align < align) - tgt_align = align; - tgt_size = (tgt_size + align - 1) & ~(align - 1); - tgt_size += sizes[i]; - } - if (tgt_align) - { - tgt = gomp_alloca (tgt_size + tgt_align - 1); - uintptr_t al = (uintptr_t) tgt & (tgt_align - 1); - if (al) - tgt += tgt_align - al; - tgt_size = 0; - for (i = 0; i < mapnum; i++) - if ((kinds[i] & 0xff) == GOMP_MAP_FIRSTPRIVATE) - { - size_t align = (size_t) 1 << (kinds[i] >> 8); - tgt_size = (tgt_size + align - 1) & ~(align - 1); - memcpy (tgt + tgt_size, hostaddrs[i], sizes[i]); - hostaddrs[i] = tgt + tgt_size; - tgt_size = tgt_size + sizes[i]; - } - } - gomp_target_fallback (fn, hostaddrs); + gomp_target_fallback_firstprivate (fn, mapnum, hostaddrs, sizes, kinds); return; } @@ -1366,7 +1441,7 @@ GOMP_target_41 (int device, void (*fn) (void *), size_t mapnum, gomp_unmap_vars (tgt_vars, true); } -/* Host fallback for GOMP_target_data{,_41} routines. */ +/* Host fallback for GOMP_target_data{,_ext} routines. */ static void gomp_target_data_fallback (void) @@ -1405,8 +1480,8 @@ GOMP_target_data (int device, const void *unused, size_t mapnum, } void -GOMP_target_data_41 (int device, size_t mapnum, void **hostaddrs, size_t *sizes, - unsigned short *kinds) +GOMP_target_data_ext (int device, size_t mapnum, void **hostaddrs, + size_t *sizes, unsigned short *kinds) { struct gomp_device_descr *devicep = resolve_device (device); @@ -1448,9 +1523,9 @@ GOMP_target_update (int device, const void *unused, size_t mapnum, } void -GOMP_target_update_41 (int device, size_t mapnum, void **hostaddrs, - size_t *sizes, unsigned short *kinds, - unsigned int flags, void **depend) +GOMP_target_update_ext (int device, size_t mapnum, void **hostaddrs, + size_t *sizes, unsigned short *kinds, + unsigned int flags, void **depend) { struct gomp_device_descr *devicep = resolve_device (device); @@ -1527,7 +1602,7 @@ gomp_exit_data (struct gomp_device_descr *devicep, size_t mapnum, cur_node.host_end = cur_node.host_start + sizes[i]; splay_tree_key k = (kind == GOMP_MAP_DELETE_ZERO_LEN_ARRAY_SECTION || kind == GOMP_MAP_ZERO_LEN_ARRAY_SECTION) - ? gomp_map_lookup (&devicep->mem_map, &cur_node) + ? gomp_map_0len_lookup (&devicep->mem_map, &cur_node) : splay_tree_lookup (&devicep->mem_map, &cur_node); if (!k) continue; @@ -1642,7 +1717,7 @@ gomp_target_task_fn (void *data) struct gomp_target_task *ttask = (struct gomp_target_task *) data; if (ttask->fn != NULL) { - /* GOMP_target_41 */ + /* GOMP_target_ext */ } else if (ttask->devicep == NULL || !(ttask->devicep->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400)) @@ -1759,7 +1834,7 @@ omp_target_is_present (void *ptr, int device_num) cur_node.host_start = (uintptr_t) ptr; cur_node.host_end = cur_node.host_start; - splay_tree_key n = gomp_map_lookup (mem_map, &cur_node); + splay_tree_key n = gomp_map_0len_lookup (mem_map, &cur_node); int ret = n != NULL; gomp_mutex_unlock (&devicep->lock); return ret; |