mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-27 13:54:19 +08:00
41dbbb3789
contrib/ * gcc_update (files_and_dependencies): Update rules for new libgomp/plugin/Makefrag.am and libgomp/plugin/configfrag.ac files. gcc/ * builtin-types.def (BT_FN_VOID_INT_INT_VAR) (BT_FN_VOID_INT_PTR_SIZE_PTR_PTR_PTR_INT_INT_VAR) (BT_FN_VOID_INT_OMPFN_PTR_SIZE_PTR_PTR_PTR_INT_INT_INT_INT_INT_VAR): New function types. * builtins.c: Include "gomp-constants.h". (expand_builtin_acc_on_device): New function. (expand_builtin, is_inexpensive_builtin): Handle BUILT_IN_ACC_ON_DEVICE. * builtins.def (DEF_GOACC_BUILTIN, DEF_GOACC_BUILTIN_COMPILER): New macros. * cgraph.c (cgraph_node::create): Consider flag_openacc next to flag_openmp. * config.gcc <nvptx-*> (tm_file): Add nvptx/offload.h. <*-intelmic-* | *-intelmicemul-*> (tm_file): Add i386/intelmic-offload.h. * gcc.c (LINK_COMMAND_SPEC, GOMP_SELF_SPECS): For -fopenacc, link to libgomp and its dependencies. * config/arc/arc.h (LINK_COMMAND_SPEC): Likewise. * config/darwin.h (LINK_COMMAND_SPEC_A): Likewise. * config/i386/mingw32.h (GOMP_SELF_SPECS): Likewise. * config/ia64/hpux.h (LIB_SPEC): Likewise. * config/pa/pa-hpux11.h (LIB_SPEC): Likewise. * config/pa/pa64-hpux.h (LIB_SPEC): Likewise. * doc/generic.texi: Update for OpenACC changes. * doc/gimple.texi: Likewise. * doc/invoke.texi: Likewise. * doc/sourcebuild.texi: Likewise. * gimple-pretty-print.c (dump_gimple_omp_for): Handle GF_OMP_FOR_KIND_OACC_LOOP. (dump_gimple_omp_target): Handle GF_OMP_TARGET_KIND_OACC_KERNELS, GF_OMP_TARGET_KIND_OACC_PARALLEL, GF_OMP_TARGET_KIND_OACC_DATA, GF_OMP_TARGET_KIND_OACC_UPDATE, GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA. Dump more data. * gimple.c: Update comments for OpenACC changes. * gimple.def: Likewise. * gimple.h: Likewise. (enum gf_mask): Add GF_OMP_FOR_KIND_OACC_LOOP, GF_OMP_TARGET_KIND_OACC_PARALLEL, GF_OMP_TARGET_KIND_OACC_KERNELS, GF_OMP_TARGET_KIND_OACC_DATA, GF_OMP_TARGET_KIND_OACC_UPDATE, GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA. (gimple_omp_for_cond, gimple_omp_for_set_cond): Sort in the appropriate place. (is_gimple_omp_oacc, is_gimple_omp_offloaded): New functions. * gimplify.c: Include "gomp-constants.h". Update comments for OpenACC changes. (is_gimple_stmt): Handle OACC_PARALLEL, OACC_KERNELS, OACC_DATA, OACC_HOST_DATA, OACC_DECLARE, OACC_UPDATE, OACC_ENTER_DATA, OACC_EXIT_DATA, OACC_CACHE, OACC_LOOP. (gimplify_scan_omp_clauses, gimplify_adjust_omp_clauses): Handle OMP_CLAUSE__CACHE_, OMP_CLAUSE_ASYNC, OMP_CLAUSE_WAIT, OMP_CLAUSE_NUM_GANGS, OMP_CLAUSE_NUM_WORKERS, OMP_CLAUSE_VECTOR_LENGTH, OMP_CLAUSE_GANG, OMP_CLAUSE_WORKER, OMP_CLAUSE_VECTOR, OMP_CLAUSE_DEVICE_RESIDENT, OMP_CLAUSE_USE_DEVICE, OMP_CLAUSE_INDEPENDENT, OMP_CLAUSE_AUTO, OMP_CLAUSE_SEQ. (gimplify_adjust_omp_clauses_1, gimplify_adjust_omp_clauses): Use GOMP_MAP_* instead of OMP_CLAUSE_MAP_*. Use OMP_CLAUSE_SET_MAP_KIND. (gimplify_oacc_cache): New function. (gimplify_omp_for): Handle OACC_LOOP. (gimplify_omp_workshare): Handle OACC_KERNELS, OACC_PARALLEL, OACC_DATA. (gimplify_omp_target_update): Handle OACC_ENTER_DATA, OACC_EXIT_DATA, OACC_UPDATE. (gimplify_expr): Handle OACC_LOOP, OACC_CACHE, OACC_HOST_DATA, OACC_DECLARE, OACC_KERNELS, OACC_PARALLEL, OACC_DATA, OACC_ENTER_DATA, OACC_EXIT_DATA, OACC_UPDATE. (gimplify_body): Consider flag_openacc next to flag_openmp. * lto-streamer-out.c: Include "gomp-constants.h". * omp-builtins.def (BUILT_IN_ACC_GET_DEVICE_TYPE) (BUILT_IN_GOACC_DATA_START, BUILT_IN_GOACC_DATA_END) (BUILT_IN_GOACC_ENTER_EXIT_DATA, BUILT_IN_GOACC_PARALLEL) (BUILT_IN_GOACC_UPDATE, BUILT_IN_GOACC_WAIT) (BUILT_IN_GOACC_GET_THREAD_NUM, BUILT_IN_GOACC_GET_NUM_THREADS) (BUILT_IN_ACC_ON_DEVICE): New builtins. * omp-low.c: Include "gomp-constants.h". Update comments for OpenACC changes. (struct omp_context): Add reduction_map, gwv_below, gwv_this members. (extract_omp_for_data, use_pointer_for_field, install_var_field) (new_omp_context, delete_omp_context, scan_sharing_clauses) (create_omp_child_function, scan_omp_for, scan_omp_target) (check_omp_nesting_restrictions, lower_reduction_clauses) (build_omp_regions_1, diagnose_sb_0, make_gimple_omp_edges): Update for OpenACC changes. (scan_sharing_clauses): Handle OMP_CLAUSE_NUM_GANGS: OMP_CLAUSE_NUM_WORKERS: OMP_CLAUSE_VECTOR_LENGTH, OMP_CLAUSE_ASYNC, OMP_CLAUSE_WAIT, OMP_CLAUSE_GANG, OMP_CLAUSE_WORKER, OMP_CLAUSE_VECTOR, OMP_CLAUSE_DEVICE_RESIDENT, OMP_CLAUSE_USE_DEVICE, OMP_CLAUSE__CACHE_, OMP_CLAUSE_INDEPENDENT, OMP_CLAUSE_AUTO, OMP_CLAUSE_SEQ. Use GOMP_MAP_* instead of OMP_CLAUSE_MAP_*. (expand_omp_for_static_nochunk, expand_omp_for_static_chunk): Handle GF_OMP_FOR_KIND_OACC_LOOP. (expand_omp_target, lower_omp_target): Handle GF_OMP_TARGET_KIND_OACC_PARALLEL, GF_OMP_TARGET_KIND_OACC_KERNELS, GF_OMP_TARGET_KIND_OACC_UPDATE, GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA, GF_OMP_TARGET_KIND_OACC_DATA. (pass_expand_omp::execute, execute_lower_omp) (pass_diagnose_omp_blocks::gate): Consider flag_openacc next to flag_openmp. (offload_symbol_decl): New variable. (oacc_get_reduction_array_id, oacc_max_threads) (get_offload_symbol_decl, get_base_type, lookup_oacc_reduction) (maybe_lookup_oacc_reduction, enclosing_target_ctx) (oacc_loop_or_target_p, oacc_lower_reduction_var_helper) (oacc_gimple_assign, oacc_initialize_reduction_data) (oacc_finalize_reduction_data, oacc_process_reduction_data): New functions. (is_targetreg_ctx): Remove function. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE__CACHE_, OMP_CLAUSE_DEVICE_RESIDENT, OMP_CLAUSE_USE_DEVICE, OMP_CLAUSE_GANG, OMP_CLAUSE_ASYNC, OMP_CLAUSE_WAIT, OMP_CLAUSE_AUTO, OMP_CLAUSE_SEQ, OMP_CLAUSE_INDEPENDENT, OMP_CLAUSE_WORKER, OMP_CLAUSE_VECTOR, OMP_CLAUSE_NUM_GANGS, OMP_CLAUSE_NUM_WORKERS, OMP_CLAUSE_VECTOR_LENGTH. * tree.c (omp_clause_code_name, walk_tree_1): Update accordingly. * tree.h (OMP_CLAUSE_GANG_EXPR, OMP_CLAUSE_GANG_STATIC_EXPR) (OMP_CLAUSE_ASYNC_EXPR, OMP_CLAUSE_WAIT_EXPR) (OMP_CLAUSE_VECTOR_EXPR, OMP_CLAUSE_WORKER_EXPR) (OMP_CLAUSE_NUM_GANGS_EXPR, OMP_CLAUSE_NUM_WORKERS_EXPR) (OMP_CLAUSE_VECTOR_LENGTH_EXPR): New macros. * tree-core.h: Update comments for OpenACC changes. (enum omp_clause_map_kind): Remove. (struct tree_omp_clause): Change type of map_kind member from enum omp_clause_map_kind to unsigned char. * tree-inline.c: Update comments for OpenACC changes. * tree-nested.c: Likewise. Include "gomp-constants.h". (convert_nonlocal_reference_stmt, convert_local_reference_stmt) (convert_tramp_reference_stmt, convert_gimple_call): Update for OpenACC changes. Use GOMP_MAP_* instead of OMP_CLAUSE_MAP_*. Use OMP_CLAUSE_SET_MAP_KIND. * tree-pretty-print.c: Include "gomp-constants.h". (dump_omp_clause): Handle OMP_CLAUSE_DEVICE_RESIDENT, OMP_CLAUSE_USE_DEVICE, OMP_CLAUSE__CACHE_, OMP_CLAUSE_GANG, OMP_CLAUSE_ASYNC, OMP_CLAUSE_AUTO, OMP_CLAUSE_SEQ, OMP_CLAUSE_WAIT, OMP_CLAUSE_WORKER, OMP_CLAUSE_VECTOR, OMP_CLAUSE_NUM_GANGS, OMP_CLAUSE_NUM_WORKERS, OMP_CLAUSE_VECTOR_LENGTH, OMP_CLAUSE_INDEPENDENT. Use GOMP_MAP_* instead of OMP_CLAUSE_MAP_*. (dump_generic_node): Handle OACC_PARALLEL, OACC_KERNELS, OACC_DATA, OACC_HOST_DATA, OACC_DECLARE, OACC_UPDATE, OACC_ENTER_DATA, OACC_EXIT_DATA, OACC_CACHE, OACC_LOOP. * tree-streamer-in.c: Include "gomp-constants.h". (unpack_ts_omp_clause_value_fields) Use GOMP_MAP_* instead of OMP_CLAUSE_MAP_*. Use OMP_CLAUSE_SET_MAP_KIND. * tree-streamer-out.c: Include "gomp-constants.h". (pack_ts_omp_clause_value_fields): Use GOMP_MAP_* instead of OMP_CLAUSE_MAP_*. * tree.def (OACC_PARALLEL, OACC_KERNELS, OACC_DATA) (OACC_HOST_DATA, OACC_LOOP, OACC_CACHE, OACC_DECLARE) (OACC_ENTER_DATA, OACC_EXIT_DATA, OACC_UPDATE): New tree codes. * tree.c (omp_clause_num_ops): Update accordingly. * tree.h (OMP_BODY, OMP_CLAUSES, OMP_LOOP_CHECK, OMP_CLAUSE_SIZE): Likewise. (OACC_PARALLEL_BODY, OACC_PARALLEL_CLAUSES, OACC_KERNELS_BODY) (OACC_KERNELS_CLAUSES, OACC_DATA_BODY, OACC_DATA_CLAUSES) (OACC_HOST_DATA_BODY, OACC_HOST_DATA_CLAUSES, OACC_CACHE_CLAUSES) (OACC_DECLARE_CLAUSES, OACC_ENTER_DATA_CLAUSES) (OACC_EXIT_DATA_CLAUSES, OACC_UPDATE_CLAUSES) (OACC_KERNELS_COMBINED, OACC_PARALLEL_COMBINED): New macros. * tree.h (OMP_CLAUSE_MAP_KIND): Cast it to enum gomp_map_kind. (OMP_CLAUSE_SET_MAP_KIND): New macro. * varpool.c (varpool_node::get_create): Consider flag_openacc next to flag_openmp. * config/i386/intelmic-offload.h: New file. * config/nvptx/offload.h: Likewise. gcc/ada/ * gcc-interface/utils.c (DEF_FUNCTION_TYPE_VAR_8) (DEF_FUNCTION_TYPE_VAR_12): New macros. gcc/c-family/ * c.opt (fopenacc): New option. * c-cppbuiltin.c (c_cpp_builtins): Conditionally define _OPENACC. * c-common.c (DEF_FUNCTION_TYPE_VAR_8, DEF_FUNCTION_TYPE_VAR_12): New macros. * c-common.h (c_finish_oacc_wait): New prototype. * c-omp.c: Include "omp-low.h" and "gomp-constants.h". (c_finish_oacc_wait): New function. * c-pragma.c (oacc_pragmas): New variable. (c_pp_lookup_pragma, init_pragma): Handle it. * c-pragma.h (enum pragma_kind): Add PRAGMA_OACC_CACHE, PRAGMA_OACC_DATA, PRAGMA_OACC_ENTER_DATA, PRAGMA_OACC_EXIT_DATA, PRAGMA_OACC_KERNELS, PRAGMA_OACC_LOOP, PRAGMA_OACC_PARALLEL, PRAGMA_OACC_UPDATE, PRAGMA_OACC_WAIT. (enum pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_ASYNC, PRAGMA_OACC_CLAUSE_AUTO, PRAGMA_OACC_CLAUSE_COLLAPSE, PRAGMA_OACC_CLAUSE_COPY, PRAGMA_OACC_CLAUSE_COPYIN, PRAGMA_OACC_CLAUSE_COPYOUT, PRAGMA_OACC_CLAUSE_CREATE, PRAGMA_OACC_CLAUSE_DELETE, PRAGMA_OACC_CLAUSE_DEVICE, PRAGMA_OACC_CLAUSE_DEVICEPTR, PRAGMA_OACC_CLAUSE_FIRSTPRIVATE, PRAGMA_OACC_CLAUSE_GANG, PRAGMA_OACC_CLAUSE_HOST, PRAGMA_OACC_CLAUSE_IF, PRAGMA_OACC_CLAUSE_NUM_GANGS, PRAGMA_OACC_CLAUSE_NUM_WORKERS, PRAGMA_OACC_CLAUSE_PRESENT, PRAGMA_OACC_CLAUSE_PRESENT_OR_COPY, PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN, PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYOUT, PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE, PRAGMA_OACC_CLAUSE_PRIVATE, PRAGMA_OACC_CLAUSE_REDUCTION, PRAGMA_OACC_CLAUSE_SELF, PRAGMA_OACC_CLAUSE_SEQ, PRAGMA_OACC_CLAUSE_VECTOR, PRAGMA_OACC_CLAUSE_VECTOR_LENGTH, PRAGMA_OACC_CLAUSE_WAIT, PRAGMA_OACC_CLAUSE_WORKER. gcc/c/ * c-parser.c: Include "gomp-constants.h". (c_parser_omp_clause_map): Use enum gomp_map_kind instead of enum omp_clause_map_kind. Use GOMP_MAP_* instead of OMP_CLAUSE_MAP_*. Use OMP_CLAUSE_SET_MAP_KIND. (c_parser_pragma): Handle PRAGMA_OACC_ENTER_DATA, PRAGMA_OACC_EXIT_DATA, PRAGMA_OACC_UPDATE. (c_parser_omp_construct): Handle PRAGMA_OACC_CACHE, PRAGMA_OACC_DATA, PRAGMA_OACC_KERNELS, PRAGMA_OACC_LOOP, PRAGMA_OACC_PARALLEL, PRAGMA_OACC_WAIT. (c_parser_omp_clause_name): Handle "auto", "async", "copy", "copyout", "create", "delete", "deviceptr", "gang", "host", "num_gangs", "num_workers", "present", "present_or_copy", "pcopy", "present_or_copyin", "pcopyin", "present_or_copyout", "pcopyout", "present_or_create", "pcreate", "seq", "self", "vector", "vector_length", "wait", "worker". (OACC_DATA_CLAUSE_MASK, OACC_KERNELS_CLAUSE_MASK) (OACC_ENTER_DATA_CLAUSE_MASK, OACC_EXIT_DATA_CLAUSE_MASK) (OACC_LOOP_CLAUSE_MASK, OACC_PARALLEL_CLAUSE_MASK) (OACC_UPDATE_CLAUSE_MASK, OACC_WAIT_CLAUSE_MASK): New macros. (c_parser_omp_variable_list): Handle OMP_CLAUSE__CACHE_. (c_parser_oacc_wait_list, c_parser_oacc_data_clause) (c_parser_oacc_data_clause_deviceptr) (c_parser_omp_clause_num_gangs, c_parser_omp_clause_num_workers) (c_parser_oacc_clause_async, c_parser_oacc_clause_wait) (c_parser_omp_clause_vector_length, c_parser_oacc_all_clauses) (c_parser_oacc_cache, c_parser_oacc_data, c_parser_oacc_kernels) (c_parser_oacc_enter_exit_data, c_parser_oacc_loop) (c_parser_oacc_parallel, c_parser_oacc_update) (c_parser_oacc_wait): New functions. * c-tree.h (c_finish_oacc_parallel, c_finish_oacc_kernels) (c_finish_oacc_data): New prototypes. * c-typeck.c: Include "gomp-constants.h". (handle_omp_array_sections): Handle GOMP_MAP_FORCE_DEVICEPTR. Use GOMP_MAP_* instead of OMP_CLAUSE_MAP_*. Use OMP_CLAUSE_SET_MAP_KIND. (c_finish_oacc_parallel, c_finish_oacc_kernels) (c_finish_oacc_data): New functions. (c_finish_omp_clauses): Handle OMP_CLAUSE__CACHE_, OMP_CLAUSE_NUM_GANGS, OMP_CLAUSE_NUM_WORKERS, OMP_CLAUSE_VECTOR_LENGTH, OMP_CLAUSE_ASYNC, OMP_CLAUSE_WAIT, OMP_CLAUSE_AUTO, OMP_CLAUSE_SEQ, OMP_CLAUSE_GANG, OMP_CLAUSE_WORKER, OMP_CLAUSE_VECTOR, and OMP_CLAUSE_MAP's GOMP_MAP_FORCE_DEVICEPTR. gcc/cp/ * parser.c: Include "gomp-constants.h". (cp_parser_omp_clause_map): Use enum gomp_map_kind instead of enum omp_clause_map_kind. Use GOMP_MAP_* instead of OMP_CLAUSE_MAP_*. Use OMP_CLAUSE_SET_MAP_KIND. (cp_parser_omp_construct, cp_parser_pragma): Handle PRAGMA_OACC_CACHE, PRAGMA_OACC_DATA, PRAGMA_OACC_ENTER_DATA, PRAGMA_OACC_EXIT_DATA, PRAGMA_OACC_KERNELS, PRAGMA_OACC_PARALLEL, PRAGMA_OACC_LOOP, PRAGMA_OACC_UPDATE, PRAGMA_OACC_WAIT. (cp_parser_omp_clause_name): Handle "async", "copy", "copyout", "create", "delete", "deviceptr", "host", "num_gangs", "num_workers", "present", "present_or_copy", "pcopy", "present_or_copyin", "pcopyin", "present_or_copyout", "pcopyout", "present_or_create", "pcreate", "vector_length", "wait". (OACC_DATA_CLAUSE_MASK, OACC_ENTER_DATA_CLAUSE_MASK) (OACC_EXIT_DATA_CLAUSE_MASK, OACC_KERNELS_CLAUSE_MASK) (OACC_LOOP_CLAUSE_MASK, OACC_PARALLEL_CLAUSE_MASK) (OACC_UPDATE_CLAUSE_MASK, OACC_WAIT_CLAUSE_MASK): New macros. (cp_parser_omp_var_list_no_open): Handle OMP_CLAUSE__CACHE_. (cp_parser_oacc_data_clause, cp_parser_oacc_data_clause_deviceptr) (cp_parser_oacc_clause_vector_length, cp_parser_oacc_wait_list) (cp_parser_oacc_clause_wait, cp_parser_omp_clause_num_gangs) (cp_parser_omp_clause_num_workers, cp_parser_oacc_clause_async) (cp_parser_oacc_all_clauses, cp_parser_oacc_cache) (cp_parser_oacc_data, cp_parser_oacc_enter_exit_data) (cp_parser_oacc_kernels, cp_parser_oacc_loop) (cp_parser_oacc_parallel, cp_parser_oacc_update) (cp_parser_oacc_wait): New functions. * cp-tree.h (finish_oacc_data, finish_oacc_kernels) (finish_oacc_parallel): New prototypes. * semantics.c: Include "gomp-constants.h". (handle_omp_array_sections): Handle GOMP_MAP_FORCE_DEVICEPTR. Use GOMP_MAP_* instead of OMP_CLAUSE_MAP_*. Use OMP_CLAUSE_SET_MAP_KIND. (finish_omp_clauses): Handle OMP_CLAUSE_ASYNC, OMP_CLAUSE_VECTOR_LENGTH, OMP_CLAUSE_WAIT, OMP_CLAUSE__CACHE_. Use GOMP_MAP_* instead of OMP_CLAUSE_MAP_*. (finish_oacc_data, finish_oacc_kernels, finish_oacc_parallel): New functions. gcc/fortran/ * lang.opt (fopenacc): New option. * cpp.c (cpp_define_builtins): Conditionally define _OPENACC. * dump-parse-tree.c (show_omp_node): Split part of it into... (show_omp_clauses): ... this new function. (show_omp_node, show_code_node): Handle EXEC_OACC_PARALLEL_LOOP, EXEC_OACC_PARALLEL, EXEC_OACC_KERNELS_LOOP, EXEC_OACC_KERNELS, EXEC_OACC_DATA, EXEC_OACC_HOST_DATA, EXEC_OACC_LOOP, EXEC_OACC_UPDATE, EXEC_OACC_WAIT, EXEC_OACC_CACHE, EXEC_OACC_ENTER_DATA, EXEC_OACC_EXIT_DATA. (show_namespace): Update for OpenACC. * f95-lang.c (DEF_FUNCTION_TYPE_VAR_2, DEF_FUNCTION_TYPE_VAR_8) (DEF_FUNCTION_TYPE_VAR_12, DEF_GOACC_BUILTIN) (DEF_GOACC_BUILTIN_COMPILER): New macros. * types.def (BT_FN_VOID_INT_INT_VAR) (BT_FN_VOID_INT_PTR_SIZE_PTR_PTR_PTR_INT_INT_VAR) (BT_FN_VOID_INT_OMPFN_PTR_SIZE_PTR_PTR_PTR_INT_INT_INT_INT_INT_VAR): New function types. * gfortran.h (gfc_statement): Add ST_OACC_PARALLEL_LOOP, ST_OACC_END_PARALLEL_LOOP, ST_OACC_PARALLEL, ST_OACC_END_PARALLEL, ST_OACC_KERNELS, ST_OACC_END_KERNELS, ST_OACC_DATA, ST_OACC_END_DATA, ST_OACC_HOST_DATA, ST_OACC_END_HOST_DATA, ST_OACC_LOOP, ST_OACC_END_LOOP, ST_OACC_DECLARE, ST_OACC_UPDATE, ST_OACC_WAIT, ST_OACC_CACHE, ST_OACC_KERNELS_LOOP, ST_OACC_END_KERNELS_LOOP, ST_OACC_ENTER_DATA, ST_OACC_EXIT_DATA, ST_OACC_ROUTINE. (struct gfc_expr_list): New data type. (gfc_get_expr_list): New macro. (gfc_omp_map_op): Add OMP_MAP_FORCE_ALLOC, OMP_MAP_FORCE_DEALLOC, OMP_MAP_FORCE_TO, OMP_MAP_FORCE_FROM, OMP_MAP_FORCE_TOFROM, OMP_MAP_FORCE_PRESENT, OMP_MAP_FORCE_DEVICEPTR. (OMP_LIST_FIRST, OMP_LIST_DEVICE_RESIDENT, OMP_LIST_USE_DEVICE) (OMP_LIST_CACHE): New enumerators. (struct gfc_omp_clauses): Add async_expr, gang_expr, worker_expr, vector_expr, num_gangs_expr, num_workers_expr, vector_length_expr, wait_list, tile_list, async, gang, worker, vector, seq, independent, wait, par_auto, gang_static, and loc members. (struct gfc_namespace): Add oacc_declare_clauses member. (gfc_exec_op): Add EXEC_OACC_KERNELS_LOOP, EXEC_OACC_PARALLEL_LOOP, EXEC_OACC_PARALLEL, EXEC_OACC_KERNELS, EXEC_OACC_DATA, EXEC_OACC_HOST_DATA, EXEC_OACC_LOOP, EXEC_OACC_UPDATE, EXEC_OACC_WAIT, EXEC_OACC_CACHE, EXEC_OACC_ENTER_DATA, EXEC_OACC_EXIT_DATA. (gfc_free_expr_list, gfc_resolve_oacc_directive) (gfc_resolve_oacc_declare, gfc_resolve_oacc_parallel_loop_blocks) (gfc_resolve_oacc_blocks): New prototypes. * match.c (match_exit_cycle): Handle EXEC_OACC_LOOP and EXEC_OACC_PARALLEL_LOOP. * match.h (gfc_match_oacc_cache, gfc_match_oacc_wait) (gfc_match_oacc_update, gfc_match_oacc_declare) (gfc_match_oacc_loop, gfc_match_oacc_host_data) (gfc_match_oacc_data, gfc_match_oacc_kernels) (gfc_match_oacc_kernels_loop, gfc_match_oacc_parallel) (gfc_match_oacc_parallel_loop, gfc_match_oacc_enter_data) (gfc_match_oacc_exit_data, gfc_match_oacc_routine): New prototypes. * openmp.c: Include "diagnostic.h" and "gomp-constants.h". (gfc_free_omp_clauses): Update for members added to struct gfc_omp_clauses. (gfc_match_omp_clauses): Change mask paramter to uint64_t. Add openacc parameter. (resolve_omp_clauses): Add openacc parameter. Update for OpenACC. (struct fortran_omp_context): Add is_openmp member. (gfc_resolve_omp_parallel_blocks): Initialize it. (gfc_resolve_do_iterator): Update for OpenACC. (gfc_resolve_omp_directive): Call resolve_omp_directive_inside_oacc_region. (OMP_CLAUSE_PRIVATE, OMP_CLAUSE_FIRSTPRIVATE) (OMP_CLAUSE_LASTPRIVATE, OMP_CLAUSE_COPYPRIVATE) (OMP_CLAUSE_SHARED, OMP_CLAUSE_COPYIN, OMP_CLAUSE_REDUCTION) (OMP_CLAUSE_IF, OMP_CLAUSE_NUM_THREADS, OMP_CLAUSE_SCHEDULE) (OMP_CLAUSE_DEFAULT, OMP_CLAUSE_ORDERED, OMP_CLAUSE_COLLAPSE) (OMP_CLAUSE_UNTIED, OMP_CLAUSE_FINAL, OMP_CLAUSE_MERGEABLE) (OMP_CLAUSE_ALIGNED, OMP_CLAUSE_DEPEND, OMP_CLAUSE_INBRANCH) (OMP_CLAUSE_LINEAR, OMP_CLAUSE_NOTINBRANCH, OMP_CLAUSE_PROC_BIND) (OMP_CLAUSE_SAFELEN, OMP_CLAUSE_SIMDLEN, OMP_CLAUSE_UNIFORM) (OMP_CLAUSE_DEVICE, OMP_CLAUSE_MAP, OMP_CLAUSE_TO) (OMP_CLAUSE_FROM, OMP_CLAUSE_NUM_TEAMS, OMP_CLAUSE_THREAD_LIMIT) (OMP_CLAUSE_DIST_SCHEDULE): Use uint64_t. (OMP_CLAUSE_ASYNC, OMP_CLAUSE_NUM_GANGS, OMP_CLAUSE_NUM_WORKERS) (OMP_CLAUSE_VECTOR_LENGTH, OMP_CLAUSE_COPY, OMP_CLAUSE_COPYOUT) (OMP_CLAUSE_CREATE, OMP_CLAUSE_PRESENT) (OMP_CLAUSE_PRESENT_OR_COPY, OMP_CLAUSE_PRESENT_OR_COPYIN) (OMP_CLAUSE_PRESENT_OR_COPYOUT, OMP_CLAUSE_PRESENT_OR_CREATE) (OMP_CLAUSE_DEVICEPTR, OMP_CLAUSE_GANG, OMP_CLAUSE_WORKER) (OMP_CLAUSE_VECTOR, OMP_CLAUSE_SEQ, OMP_CLAUSE_INDEPENDENT) (OMP_CLAUSE_USE_DEVICE, OMP_CLAUSE_DEVICE_RESIDENT) (OMP_CLAUSE_HOST_SELF, OMP_CLAUSE_OACC_DEVICE, OMP_CLAUSE_WAIT) (OMP_CLAUSE_DELETE, OMP_CLAUSE_AUTO, OMP_CLAUSE_TILE): New macros. (gfc_match_omp_clauses): Handle those. (OACC_PARALLEL_CLAUSES, OACC_KERNELS_CLAUSES, OACC_DATA_CLAUSES) (OACC_LOOP_CLAUSES, OACC_PARALLEL_LOOP_CLAUSES) (OACC_KERNELS_LOOP_CLAUSES, OACC_HOST_DATA_CLAUSES) (OACC_DECLARE_CLAUSES, OACC_UPDATE_CLAUSES) (OACC_ENTER_DATA_CLAUSES, OACC_EXIT_DATA_CLAUSES) (OACC_WAIT_CLAUSES): New macros. (gfc_free_expr_list, match_oacc_expr_list, match_oacc_clause_gang) (gfc_match_omp_map_clause, gfc_match_oacc_parallel_loop) (gfc_match_oacc_parallel, gfc_match_oacc_kernels_loop) (gfc_match_oacc_kernels, gfc_match_oacc_data) (gfc_match_oacc_host_data, gfc_match_oacc_loop) (gfc_match_oacc_declare, gfc_match_oacc_update) (gfc_match_oacc_enter_data, gfc_match_oacc_exit_data) (gfc_match_oacc_wait, gfc_match_oacc_cache) (gfc_match_oacc_routine, oacc_is_loop) (resolve_oacc_scalar_int_expr, resolve_oacc_positive_int_expr) (check_symbol_not_pointer, check_array_not_assumed) (resolve_oacc_data_clauses, resolve_oacc_deviceptr_clause) (oacc_compatible_clauses, oacc_is_parallel, oacc_is_kernels) (omp_code_to_statement, oacc_code_to_statement) (resolve_oacc_directive_inside_omp_region) (resolve_omp_directive_inside_oacc_region) (resolve_oacc_nested_loops, resolve_oacc_params_in_parallel) (resolve_oacc_loop_blocks, gfc_resolve_oacc_blocks) (resolve_oacc_loop, resolve_oacc_cache, gfc_resolve_oacc_declare) (gfc_resolve_oacc_directive): New functions. * parse.c (next_free): Update for OpenACC. Move some code into... (verify_token_free): ... this new function. (next_fixed): Update for OpenACC. Move some code into... (verify_token_fixed): ... this new function. (case_executable): Add ST_OACC_UPDATE, ST_OACC_WAIT, ST_OACC_CACHE, ST_OACC_ENTER_DATA, and ST_OACC_EXIT_DATA. (case_exec_markers): Add ST_OACC_PARALLEL_LOOP, ST_OACC_PARALLEL, ST_OACC_KERNELS, ST_OACC_DATA, ST_OACC_HOST_DATA, ST_OACC_LOOP, ST_OACC_KERNELS_LOOP. (case_decl): Add ST_OACC_ROUTINE. (push_state, parse_critical_block, parse_progunit): Update for OpenACC. (gfc_ascii_statement): Handle ST_OACC_PARALLEL_LOOP, ST_OACC_END_PARALLEL_LOOP, ST_OACC_PARALLEL, ST_OACC_END_PARALLEL, ST_OACC_KERNELS, ST_OACC_END_KERNELS, ST_OACC_KERNELS_LOOP, ST_OACC_END_KERNELS_LOOP, ST_OACC_DATA, ST_OACC_END_DATA, ST_OACC_HOST_DATA, ST_OACC_END_HOST_DATA, ST_OACC_LOOP, ST_OACC_END_LOOP, ST_OACC_DECLARE, ST_OACC_UPDATE, ST_OACC_WAIT, ST_OACC_CACHE, ST_OACC_ENTER_DATA, ST_OACC_EXIT_DATA, ST_OACC_ROUTINE. (verify_st_order, parse_spec): Handle ST_OACC_DECLARE. (parse_executable): Handle ST_OACC_PARALLEL_LOOP, ST_OACC_KERNELS_LOOP, ST_OACC_LOOP, ST_OACC_PARALLEL, ST_OACC_KERNELS, ST_OACC_DATA, ST_OACC_HOST_DATA. (decode_oacc_directive, parse_oacc_structured_block) (parse_oacc_loop, is_oacc): New functions. * parse.h (struct gfc_state_data): Add oacc_declare_clauses member. (is_oacc): New prototype. * resolve.c (gfc_resolve_blocks, gfc_resolve_code): Handle EXEC_OACC_PARALLEL_LOOP, EXEC_OACC_PARALLEL, EXEC_OACC_KERNELS_LOOP, EXEC_OACC_KERNELS, EXEC_OACC_DATA, EXEC_OACC_HOST_DATA, EXEC_OACC_LOOP, EXEC_OACC_UPDATE, EXEC_OACC_WAIT, EXEC_OACC_CACHE, EXEC_OACC_ENTER_DATA, EXEC_OACC_EXIT_DATA. (resolve_codes): Call gfc_resolve_oacc_declare. * scanner.c (openacc_flag, openacc_locus): New variables. (skip_free_comments): Update for OpenACC. Move some code into... (skip_omp_attribute): ... this new function. (skip_oacc_attribute): New function. (skip_fixed_comments, gfc_next_char_literal): Update for OpenACC. * st.c (gfc_free_statement): Handle EXEC_OACC_PARALLEL_LOOP, EXEC_OACC_PARALLEL, EXEC_OACC_KERNELS_LOOP, EXEC_OACC_KERNELS, EXEC_OACC_DATA, EXEC_OACC_HOST_DATA, EXEC_OACC_LOOP, EXEC_OACC_UPDATE, EXEC_OACC_WAIT, EXEC_OACC_CACHE, EXEC_OACC_ENTER_DATA, EXEC_OACC_EXIT_DATA. * trans-decl.c (gfc_generate_function_code): Update for OpenACC. * trans-openmp.c: Include "gomp-constants.h". (gfc_omp_finish_clause, gfc_trans_omp_clauses): Use GOMP_MAP_* instead of OMP_CLAUSE_MAP_*. Use OMP_CLAUSE_SET_MAP_KIND. (gfc_trans_omp_clauses): Handle OMP_LIST_USE_DEVICE, OMP_LIST_DEVICE_RESIDENT, OMP_LIST_CACHE, and OMP_MAP_FORCE_ALLOC, OMP_MAP_FORCE_DEALLOC, OMP_MAP_FORCE_TO, OMP_MAP_FORCE_FROM, OMP_MAP_FORCE_TOFROM, OMP_MAP_FORCE_PRESENT, OMP_MAP_FORCE_DEVICEPTR, and gfc_omp_clauses' async, seq, independent, wait_list, num_gangs_expr, num_workers_expr, vector_length_expr, vector, vector_expr, worker, worker_expr, gang, gang_expr members. (gfc_trans_omp_do): Handle EXEC_OACC_LOOP. (gfc_convert_expr_to_tree, gfc_trans_oacc_construct) (gfc_trans_oacc_executable_directive) (gfc_trans_oacc_wait_directive, gfc_trans_oacc_combined_directive) (gfc_trans_oacc_declare, gfc_trans_oacc_directive): New functions. * trans-stmt.c (gfc_trans_block_construct): Update for OpenACC. * trans-stmt.h (gfc_trans_oacc_directive, gfc_trans_oacc_declare): New prototypes. * trans.c (tranc_code): Handle EXEC_OACC_CACHE, EXEC_OACC_WAIT, EXEC_OACC_UPDATE, EXEC_OACC_LOOP, EXEC_OACC_HOST_DATA, EXEC_OACC_DATA, EXEC_OACC_KERNELS, EXEC_OACC_KERNELS_LOOP, EXEC_OACC_PARALLEL, EXEC_OACC_PARALLEL_LOOP, EXEC_OACC_ENTER_DATA, EXEC_OACC_EXIT_DATA. * gfortran.texi: Update for OpenACC. * intrinsic.texi: Likewise. * invoke.texi: Likewise. gcc/lto/ * lto-lang.c (DEF_FUNCTION_TYPE_VAR_8, DEF_FUNCTION_TYPE_VAR_12): New macros. * lto.c: Include "gomp-constants.h". gcc/testsuite/ * lib/target-supports.exp (check_effective_target_fopenacc): New procedure. * g++.dg/goacc-gomp/goacc-gomp.exp: New file. * g++.dg/goacc/goacc.exp: Likewise. * gcc.dg/goacc-gomp/goacc-gomp.exp: Likewise. * gcc.dg/goacc/goacc.exp: Likewise. * gfortran.dg/goacc/goacc.exp: Likewise. * c-c++-common/cpp/openacc-define-1.c: New file. * c-c++-common/cpp/openacc-define-2.c: Likewise. * c-c++-common/cpp/openacc-define-3.c: Likewise. * c-c++-common/goacc-gomp/nesting-1.c: Likewise. * c-c++-common/goacc-gomp/nesting-fail-1.c: Likewise. * c-c++-common/goacc/acc_on_device-2-off.c: Likewise. * c-c++-common/goacc/acc_on_device-2.c: Likewise. * c-c++-common/goacc/asyncwait-1.c: Likewise. * c-c++-common/goacc/cache-1.c: Likewise. * c-c++-common/goacc/clauses-fail.c: Likewise. * c-c++-common/goacc/collapse-1.c: Likewise. * c-c++-common/goacc/data-1.c: Likewise. * c-c++-common/goacc/data-2.c: Likewise. * c-c++-common/goacc/data-clause-duplicate-1.c: Likewise. * c-c++-common/goacc/deviceptr-1.c: Likewise. * c-c++-common/goacc/deviceptr-2.c: Likewise. * c-c++-common/goacc/deviceptr-3.c: Likewise. * c-c++-common/goacc/if-clause-1.c: Likewise. * c-c++-common/goacc/if-clause-2.c: Likewise. * c-c++-common/goacc/kernels-1.c: Likewise. * c-c++-common/goacc/loop-1.c: Likewise. * c-c++-common/goacc/loop-private-1.c: Likewise. * c-c++-common/goacc/nesting-1.c: Likewise. * c-c++-common/goacc/nesting-data-1.c: Likewise. * c-c++-common/goacc/nesting-fail-1.c: Likewise. * c-c++-common/goacc/parallel-1.c: Likewise. * c-c++-common/goacc/pcopy.c: Likewise. * c-c++-common/goacc/pcopyin.c: Likewise. * c-c++-common/goacc/pcopyout.c: Likewise. * c-c++-common/goacc/pcreate.c: Likewise. * c-c++-common/goacc/pragma_context.c: Likewise. * c-c++-common/goacc/present-1.c: Likewise. * c-c++-common/goacc/reduction-1.c: Likewise. * c-c++-common/goacc/reduction-2.c: Likewise. * c-c++-common/goacc/reduction-3.c: Likewise. * c-c++-common/goacc/reduction-4.c: Likewise. * c-c++-common/goacc/sb-1.c: Likewise. * c-c++-common/goacc/sb-2.c: Likewise. * c-c++-common/goacc/sb-3.c: Likewise. * c-c++-common/goacc/update-1.c: Likewise. * gcc.dg/goacc/acc_on_device-1.c: Likewise. * gfortran.dg/goacc/acc_on_device-1.f95: Likewise. * gfortran.dg/goacc/acc_on_device-2-off.f95: Likewise. * gfortran.dg/goacc/acc_on_device-2.f95: Likewise. * gfortran.dg/goacc/assumed.f95: Likewise. * gfortran.dg/goacc/asyncwait-1.f95: Likewise. * gfortran.dg/goacc/asyncwait-2.f95: Likewise. * gfortran.dg/goacc/asyncwait-3.f95: Likewise. * gfortran.dg/goacc/asyncwait-4.f95: Likewise. * gfortran.dg/goacc/branch.f95: Likewise. * gfortran.dg/goacc/cache-1.f95: Likewise. * gfortran.dg/goacc/coarray.f95: Likewise. * gfortran.dg/goacc/continuation-free-form.f95: Likewise. * gfortran.dg/goacc/cray.f95: Likewise. * gfortran.dg/goacc/critical.f95: Likewise. * gfortran.dg/goacc/data-clauses.f95: Likewise. * gfortran.dg/goacc/data-tree.f95: Likewise. * gfortran.dg/goacc/declare-1.f95: Likewise. * gfortran.dg/goacc/enter-exit-data.f95: Likewise. * gfortran.dg/goacc/fixed-1.f: Likewise. * gfortran.dg/goacc/fixed-2.f: Likewise. * gfortran.dg/goacc/fixed-3.f: Likewise. * gfortran.dg/goacc/fixed-4.f: Likewise. * gfortran.dg/goacc/host_data-tree.f95: Likewise. * gfortran.dg/goacc/if.f95: Likewise. * gfortran.dg/goacc/kernels-tree.f95: Likewise. * gfortran.dg/goacc/list.f95: Likewise. * gfortran.dg/goacc/literal.f95: Likewise. * gfortran.dg/goacc/loop-1.f95: Likewise. * gfortran.dg/goacc/loop-2.f95: Likewise. * gfortran.dg/goacc/loop-3.f95: Likewise. * gfortran.dg/goacc/loop-tree-1.f90: Likewise. * gfortran.dg/goacc/omp.f95: Likewise. * gfortran.dg/goacc/parallel-kernels-clauses.f95: Likewise. * gfortran.dg/goacc/parallel-kernels-regions.f95: Likewise. * gfortran.dg/goacc/parallel-tree.f95: Likewise. * gfortran.dg/goacc/parameter.f95: Likewise. * gfortran.dg/goacc/private-1.f95: Likewise. * gfortran.dg/goacc/private-2.f95: Likewise. * gfortran.dg/goacc/private-3.f95: Likewise. * gfortran.dg/goacc/pure-elemental-procedures.f95: Likewise. * gfortran.dg/goacc/reduction-2.f95: Likewise. * gfortran.dg/goacc/reduction.f95: Likewise. * gfortran.dg/goacc/routine-1.f90: Likewise. * gfortran.dg/goacc/routine-2.f90: Likewise. * gfortran.dg/goacc/sentinel-free-form.f95: Likewise. * gfortran.dg/goacc/several-directives.f95: Likewise. * gfortran.dg/goacc/sie.f95: Likewise. * gfortran.dg/goacc/subarrays.f95: Likewise. * gfortran.dg/gomp/map-1.f90: Likewise. * gfortran.dg/openacc-define-1.f90: Likewise. * gfortran.dg/openacc-define-2.f90: Likewise. * gfortran.dg/openacc-define-3.f90: Likewise. * g++.dg/gomp/block-1.C: Update for changed compiler output. * g++.dg/gomp/block-2.C: Likewise. * g++.dg/gomp/block-3.C: Likewise. * g++.dg/gomp/block-5.C: Likewise. * g++.dg/gomp/target-1.C: Likewise. * g++.dg/gomp/target-2.C: Likewise. * g++.dg/gomp/taskgroup-1.C: Likewise. * g++.dg/gomp/teams-1.C: Likewise. * gcc.dg/cilk-plus/jump-openmp.c: Likewise. * gcc.dg/cilk-plus/jump.c: Likewise. * gcc.dg/gomp/block-1.c: Likewise. * gcc.dg/gomp/block-10.c: Likewise. * gcc.dg/gomp/block-2.c: Likewise. * gcc.dg/gomp/block-3.c: Likewise. * gcc.dg/gomp/block-4.c: Likewise. * gcc.dg/gomp/block-5.c: Likewise. * gcc.dg/gomp/block-6.c: Likewise. * gcc.dg/gomp/block-7.c: Likewise. * gcc.dg/gomp/block-8.c: Likewise. * gcc.dg/gomp/block-9.c: Likewise. * gcc.dg/gomp/target-1.c: Likewise. * gcc.dg/gomp/target-2.c: Likewise. * gcc.dg/gomp/taskgroup-1.c: Likewise. * gcc.dg/gomp/teams-1.c: Likewise. include/ * gomp-constants.h: New file. libgomp/ * Makefile.am (search_path): Add $(top_srcdir)/../include. (libgomp_la_SOURCES): Add splay-tree.c, libgomp-plugin.c, oacc-parallel.c, oacc-host.c, oacc-init.c, oacc-mem.c, oacc-async.c, oacc-plugin.c, oacc-cuda.c. [USE_FORTRAN] (libgomp_la_SOURCES): Add openacc.f90. Include $(top_srcdir)/plugin/Makefrag.am. (nodist_libsubinclude_HEADERS): Add openacc.h. [USE_FORTRAN] (nodist_finclude_HEADERS): Add openacc_lib.h, openacc.f90, openacc.mod, openacc_kinds.mod. (omp_lib.mod): Generalize into... (%.mod): ... this new rule. (openacc_kinds.mod, openacc.mod): New rules. * plugin/configfrag.ac: New file. * configure.ac: Move plugin/offloading support into it. Include it. Instantiate testsuite/libgomp-test-support.pt.exp. * plugin/Makefrag.am: New file. * testsuite/Makefile.am (OFFLOAD_TARGETS) (OFFLOAD_ADDITIONAL_OPTIONS, OFFLOAD_ADDITIONAL_LIB_PATHS): Don't export. (libgomp-test-support.exp): New rule. (all-local): Depend on it. * Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. * config.h.in: Likewise. * configure: Likewise. * configure.tgt: Harden shell syntax. * env.c: Include "oacc-int.h". (parse_acc_device_type): New function. (gomp_debug_var, goacc_device_type, goacc_device_num): New variables. (initialize_env): Initialize those. Call goacc_runtime_initialize. * error.c (gomp_vdebug, gomp_debug, gomp_vfatal): New functions. (gomp_fatal): Call gomp_vfatal. * libgomp.h: Include "libgomp-plugin.h" and <stdarg.h>. (gomp_debug_var, goacc_device_type, goacc_device_num, gomp_vdebug) (gomp_debug, gomp_verror, gomp_vfatal, gomp_init_targets_once) (splay_tree_node, splay_tree, splay_tree_key) (struct target_mem_desc, struct splay_tree_key_s) (struct gomp_memory_mapping, struct acc_dispatch_t) (struct gomp_device_descr, gomp_acc_insert_pointer) (gomp_acc_remove_pointer, target_mem_desc, gomp_copy_from_async) (gomp_unmap_vars, gomp_init_device, gomp_init_tables) (gomp_free_memmap, gomp_fini_device): New declarations. (gomp_vdebug, gomp_debug): New macros. Include "splay-tree.h". * libgomp.map (OACC_2.0): New symbol version. Use for acc_get_num_devices, acc_get_num_devices_h_, acc_set_device_type, acc_set_device_type_h_, acc_get_device_type, acc_get_device_type_h_, acc_set_device_num, acc_set_device_num_h_, acc_get_device_num, acc_get_device_num_h_, acc_async_test, acc_async_test_h_, acc_async_test_all, acc_async_test_all_h_, acc_wait, acc_wait_h_, acc_wait_async, acc_wait_async_h_, acc_wait_all, acc_wait_all_h_, acc_wait_all_async, acc_wait_all_async_h_, acc_init, acc_init_h_, acc_shutdown, acc_shutdown_h_, acc_on_device, acc_on_device_h_, acc_malloc, acc_free, acc_copyin, acc_copyin_32_h_, acc_copyin_64_h_, acc_copyin_array_h_, acc_present_or_copyin, acc_present_or_copyin_32_h_, acc_present_or_copyin_64_h_, acc_present_or_copyin_array_h_, acc_create, acc_create_32_h_, acc_create_64_h_, acc_create_array_h_, acc_present_or_create, acc_present_or_create_32_h_, acc_present_or_create_64_h_, acc_present_or_create_array_h_, acc_copyout, acc_copyout_32_h_, acc_copyout_64_h_, acc_copyout_array_h_, acc_delete, acc_delete_32_h_, acc_delete_64_h_, acc_delete_array_h_, acc_update_device, acc_update_device_32_h_, acc_update_device_64_h_, acc_update_device_array_h_, acc_update_self, acc_update_self_32_h_, acc_update_self_64_h_, acc_update_self_array_h_, acc_map_data, acc_unmap_data, acc_deviceptr, acc_hostptr, acc_is_present, acc_is_present_32_h_, acc_is_present_64_h_, acc_is_present_array_h_, acc_memcpy_to_device, acc_memcpy_from_device, acc_get_current_cuda_device, acc_get_current_cuda_context, acc_get_cuda_stream, acc_set_cuda_stream. (GOACC_2.0): New symbol version. Use for GOACC_data_end, GOACC_data_start, GOACC_enter_exit_data, GOACC_parallel, GOACC_update, GOACC_wait, GOACC_get_thread_num, GOACC_get_num_threads. (GOMP_PLUGIN_1.0): New symbol version. Use for GOMP_PLUGIN_malloc, GOMP_PLUGIN_malloc_cleared, GOMP_PLUGIN_realloc, GOMP_PLUGIN_debug, GOMP_PLUGIN_error, GOMP_PLUGIN_fatal, GOMP_PLUGIN_async_unmap_vars, GOMP_PLUGIN_acc_thread. * libgomp.texi: Update for OpenACC changes, and GOMP_DEBUG environment variable. * libgomp_g.h (GOACC_data_start, GOACC_data_end) (GOACC_enter_exit_data, GOACC_parallel, GOACC_update, GOACC_wait) (GOACC_get_num_threads, GOACC_get_thread_num): New declarations. * splay-tree.h (splay_tree_lookup, splay_tree_insert) (splay_tree_remove): New declarations. (rotate_left, rotate_right, splay_tree_splay, splay_tree_insert) (splay_tree_remove, splay_tree_lookup): Move into... * splay-tree.c: ... this new file. * target.c: Include "oacc-plugin.h", "oacc-int.h", <assert.h>. (splay_tree_node, splay_tree, splay_tree_key) (struct target_mem_desc, struct splay_tree_key_s) (struct gomp_device_descr): Don't declare. (num_devices_openmp): New variable. (gomp_get_num_devices ): Use it. (gomp_init_targets_once): New function. (gomp_get_num_devices ): Use it. (get_kind, gomp_copy_from_async, gomp_free_memmap) (gomp_fini_device, gomp_register_image_for_device): New functions. (gomp_map_vars): Add devaddrs parameter. (gomp_update): Add mm parameter. (gomp_init_device): Move most of it into... (gomp_init_tables): ... this new function. (gomp_register_images_for_device): Remove function. (splay_compare, gomp_map_vars, gomp_unmap_vars, gomp_init_device): Make them hidden instead of static. (gomp_map_vars_existing, gomp_map_vars, gomp_unmap_vars) (gomp_update, gomp_init_device, GOMP_target, GOMP_target_data) (GOMP_target_end_data, GOMP_target_update) (gomp_load_plugin_for_device, gomp_target_init): Update for OpenACC changes. * oacc-async.c: New file. * oacc-cuda.c: Likewise. * oacc-host.c: Likewise. * oacc-init.c: Likewise. * oacc-int.h: Likewise. * oacc-mem.c: Likewise. * oacc-parallel.c: Likewise. * oacc-plugin.c: Likewise. * oacc-plugin.h: Likewise. * oacc-ptx.h: Likewise. * openacc.f90: Likewise. * openacc.h: Likewise. * openacc_lib.h: Likewise. * plugin/plugin-host.c: Likewise. * plugin/plugin-nvptx.c: Likewise. * libgomp-plugin.c: Likewise. * libgomp-plugin.h: Likewise. * libgomp_target.h: Remove file after merging content into the former file. Update all users. * testsuite/lib/libgomp.exp: Load libgomp-test-support.exp. (offload_targets_s, offload_targets_s_openacc): New variables. (check_effective_target_openacc_nvidia_accel_present) (check_effective_target_openacc_nvidia_accel_selected): New procedures. (libgomp_init): Update for OpenACC changes. * testsuite/libgomp-test-support.exp.in: New file. * testsuite/libgomp.oacc-c++/c++.exp: Likewise. * testsuite/libgomp.oacc-c/c.exp: Likewise. * testsuite/libgomp.oacc-fortran/fortran.exp: Likewise. * testsuite/libgomp.oacc-c-c++-common/abort-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/abort-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/abort-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/abort-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/acc_on_device-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/asyncwait-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/cache-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/clauses-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/clauses-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/collapse-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/collapse-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/collapse-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/collapse-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/context-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/context-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/context-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/context-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-5.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-6.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-7.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/data-already-8.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/deviceptr-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/if-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/kernels-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/kernels-empty.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-10.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-11.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-12.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-13.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-14.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-15.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-16.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-17.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-18.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-19.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-20.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-21.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-22.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-23.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-24.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-25.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-26.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-27.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-28.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-29.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-30.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-31.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-32.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-33.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-34.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-35.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-36.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-37.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-38.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-39.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-40.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-41.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-42.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-43.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-44.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-45.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-46.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-47.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-48.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-49.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-5.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-50.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-51.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-52.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-53.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-54.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-55.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-56.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-57.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-58.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-59.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-6.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-60.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-61.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-62.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-63.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-64.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-65.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-66.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-67.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-68.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-69.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-7.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-70.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-71.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-72.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-73.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-74.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-75.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-76.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-77.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-78.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-79.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-80.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-81.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-82.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-83.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-84.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-85.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-86.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-87.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-88.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-89.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-9.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-90.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-91.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-92.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/nested-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/nested-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/offset-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/parallel-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/parallel-empty.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/pointer-align-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/present-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/present-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/reduction-1.c: Likewise. * 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-initial-1.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/subr.h: Likewise. * testsuite/libgomp.oacc-c-c++-common/subr.ptx: Likewise. * testsuite/libgomp.oacc-c-c++-common/timer.h: Likewise. * testsuite/libgomp.oacc-c-c++-common/update-1-2.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/update-1.c: Likewise. * testsuite/libgomp.oacc-fortran/abort-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/abort-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/acc_on_device-1-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/acc_on_device-1-2.f: Likewise. * testsuite/libgomp.oacc-fortran/acc_on_device-1-3.f: Likewise. * testsuite/libgomp.oacc-fortran/asyncwait-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/asyncwait-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/asyncwait-3.f90: Likewise. * testsuite/libgomp.oacc-fortran/collapse-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/collapse-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/collapse-3.f90: Likewise. * testsuite/libgomp.oacc-fortran/collapse-4.f90: Likewise. * testsuite/libgomp.oacc-fortran/collapse-5.f90: Likewise. * testsuite/libgomp.oacc-fortran/collapse-6.f90: Likewise. * testsuite/libgomp.oacc-fortran/collapse-7.f90: Likewise. * testsuite/libgomp.oacc-fortran/collapse-8.f90: Likewise. * testsuite/libgomp.oacc-fortran/data-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/data-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/data-3.f90: Likewise. * testsuite/libgomp.oacc-fortran/data-4-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/data-4.f90: Likewise. * testsuite/libgomp.oacc-fortran/data-already-1.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-2.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-3.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-4.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-5.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-6.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-7.f: Likewise. * testsuite/libgomp.oacc-fortran/data-already-8.f: Likewise. * testsuite/libgomp.oacc-fortran/lib-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/lib-10.f90: Likewise. * testsuite/libgomp.oacc-fortran/lib-2.f: Likewise. * testsuite/libgomp.oacc-fortran/lib-3.f: Likewise. * testsuite/libgomp.oacc-fortran/lib-4.f90: Likewise. * testsuite/libgomp.oacc-fortran/lib-5.f90: Likewise. * testsuite/libgomp.oacc-fortran/lib-6.f90: Likewise. * testsuite/libgomp.oacc-fortran/lib-7.f90: Likewise. * testsuite/libgomp.oacc-fortran/lib-8.f90: Likewise. * testsuite/libgomp.oacc-fortran/map-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/openacc_version-1.f: Likewise. * testsuite/libgomp.oacc-fortran/openacc_version-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/pointer-align-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/pset-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/reduction-1.f90: Likewise. * 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/routine-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/routine-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/routine-3.f90: Likewise. * testsuite/libgomp.oacc-fortran/routine-4.f90: Likewise. * testsuite/libgomp.oacc-fortran/subarrays-1.f90: Likewise. * testsuite/libgomp.oacc-fortran/subarrays-2.f90: Likewise. liboffloadmic/ * plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_name) (GOMP_OFFLOAD_get_caps, GOMP_OFFLOAD_fini_device): New functions. Co-Authored-By: Bernd Schmidt <bernds@codesourcery.com> Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com> Co-Authored-By: Dmitry Bocharnikov <dmitry.b@samsung.com> Co-Authored-By: Evgeny Gavrin <e.gavrin@samsung.com> Co-Authored-By: Ilmir Usmanov <i.usmanov@samsung.com> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> Co-Authored-By: James Norris <jnorris@codesourcery.com> Co-Authored-By: Julian Brown <julian@codesourcery.com> Co-Authored-By: Nathan Sidwell <nathan@codesourcery.com> Co-Authored-By: Tobias Burnus <burnus@net-b.de> Co-Authored-By: Tom de Vries <tom@codesourcery.com> From-SVN: r219682
920 lines
29 KiB
C
920 lines
29 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 contains data types and function declarations that are not
|
|
part of the official OpenACC or OpenMP user interfaces. There are
|
|
declarations in here that are part of the GNU Offloading and Multi
|
|
Processing ABI, in that the compiler is required to know about them
|
|
and use them.
|
|
|
|
The convention is that the all caps prefix "GOMP" is used group items
|
|
that are part of the external ABI, and the lower case prefix "gomp"
|
|
is used group items that are completely private to the library. */
|
|
|
|
#ifndef LIBGOMP_H
|
|
#define LIBGOMP_H 1
|
|
|
|
#include "config.h"
|
|
#include "gstdint.h"
|
|
#include "libgomp-plugin.h"
|
|
|
|
#include <pthread.h>
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
|
|
#ifdef HAVE_ATTRIBUTE_VISIBILITY
|
|
# pragma GCC visibility push(hidden)
|
|
#endif
|
|
|
|
/* If we were a C++ library, we'd get this from <std/atomic>. */
|
|
enum memmodel
|
|
{
|
|
MEMMODEL_RELAXED = 0,
|
|
MEMMODEL_CONSUME = 1,
|
|
MEMMODEL_ACQUIRE = 2,
|
|
MEMMODEL_RELEASE = 3,
|
|
MEMMODEL_ACQ_REL = 4,
|
|
MEMMODEL_SEQ_CST = 5
|
|
};
|
|
|
|
#include "sem.h"
|
|
#include "mutex.h"
|
|
#include "bar.h"
|
|
#include "ptrlock.h"
|
|
|
|
|
|
/* This structure contains the data to control one work-sharing construct,
|
|
either a LOOP (FOR/DO) or a SECTIONS. */
|
|
|
|
enum gomp_schedule_type
|
|
{
|
|
GFS_RUNTIME,
|
|
GFS_STATIC,
|
|
GFS_DYNAMIC,
|
|
GFS_GUIDED,
|
|
GFS_AUTO
|
|
};
|
|
|
|
struct gomp_work_share
|
|
{
|
|
/* This member records the SCHEDULE clause to be used for this construct.
|
|
The user specification of "runtime" will already have been resolved.
|
|
If this is a SECTIONS construct, this value will always be DYNAMIC. */
|
|
enum gomp_schedule_type sched;
|
|
|
|
int mode;
|
|
|
|
union {
|
|
struct {
|
|
/* This is the chunk_size argument to the SCHEDULE clause. */
|
|
long chunk_size;
|
|
|
|
/* This is the iteration end point. If this is a SECTIONS construct,
|
|
this is the number of contained sections. */
|
|
long end;
|
|
|
|
/* This is the iteration step. If this is a SECTIONS construct, this
|
|
is always 1. */
|
|
long incr;
|
|
};
|
|
|
|
struct {
|
|
/* The same as above, but for the unsigned long long loop variants. */
|
|
unsigned long long chunk_size_ull;
|
|
unsigned long long end_ull;
|
|
unsigned long long incr_ull;
|
|
};
|
|
};
|
|
|
|
/* This is a circular queue that details which threads will be allowed
|
|
into the ordered region and in which order. When a thread allocates
|
|
iterations on which it is going to work, it also registers itself at
|
|
the end of the array. When a thread reaches the ordered region, it
|
|
checks to see if it is the one at the head of the queue. If not, it
|
|
blocks on its RELEASE semaphore. */
|
|
unsigned *ordered_team_ids;
|
|
|
|
/* This is the number of threads that have registered themselves in
|
|
the circular queue ordered_team_ids. */
|
|
unsigned ordered_num_used;
|
|
|
|
/* This is the team_id of the currently acknowledged owner of the ordered
|
|
section, or -1u if the ordered section has not been acknowledged by
|
|
any thread. This is distinguished from the thread that is *allowed*
|
|
to take the section next. */
|
|
unsigned ordered_owner;
|
|
|
|
/* This is the index into the circular queue ordered_team_ids of the
|
|
current thread that's allowed into the ordered reason. */
|
|
unsigned ordered_cur;
|
|
|
|
/* This is a chain of allocated gomp_work_share blocks, valid only
|
|
in the first gomp_work_share struct in the block. */
|
|
struct gomp_work_share *next_alloc;
|
|
|
|
/* The above fields are written once during workshare initialization,
|
|
or related to ordered worksharing. Make sure the following fields
|
|
are in a different cache line. */
|
|
|
|
/* This lock protects the update of the following members. */
|
|
gomp_mutex_t lock __attribute__((aligned (64)));
|
|
|
|
/* This is the count of the number of threads that have exited the work
|
|
share construct. If the construct was marked nowait, they have moved on
|
|
to other work; otherwise they're blocked on a barrier. The last member
|
|
of the team to exit the work share construct must deallocate it. */
|
|
unsigned threads_completed;
|
|
|
|
union {
|
|
/* This is the next iteration value to be allocated. In the case of
|
|
GFS_STATIC loops, this the iteration start point and never changes. */
|
|
long next;
|
|
|
|
/* The same, but with unsigned long long type. */
|
|
unsigned long long next_ull;
|
|
|
|
/* This is the returned data structure for SINGLE COPYPRIVATE. */
|
|
void *copyprivate;
|
|
};
|
|
|
|
union {
|
|
/* Link to gomp_work_share struct for next work sharing construct
|
|
encountered after this one. */
|
|
gomp_ptrlock_t next_ws;
|
|
|
|
/* gomp_work_share structs are chained in the free work share cache
|
|
through this. */
|
|
struct gomp_work_share *next_free;
|
|
};
|
|
|
|
/* If only few threads are in the team, ordered_team_ids can point
|
|
to this array which fills the padding at the end of this struct. */
|
|
unsigned inline_ordered_team_ids[0];
|
|
};
|
|
|
|
/* This structure contains all of the thread-local data associated with
|
|
a thread team. This is the data that must be saved when a thread
|
|
encounters a nested PARALLEL construct. */
|
|
|
|
struct gomp_team_state
|
|
{
|
|
/* This is the team of which the thread is currently a member. */
|
|
struct gomp_team *team;
|
|
|
|
/* This is the work share construct which this thread is currently
|
|
processing. Recall that with NOWAIT, not all threads may be
|
|
processing the same construct. */
|
|
struct gomp_work_share *work_share;
|
|
|
|
/* This is the previous work share construct or NULL if there wasn't any.
|
|
When all threads are done with the current work sharing construct,
|
|
the previous one can be freed. The current one can't, as its
|
|
next_ws field is used. */
|
|
struct gomp_work_share *last_work_share;
|
|
|
|
/* This is the ID of this thread within the team. This value is
|
|
guaranteed to be between 0 and N-1, where N is the number of
|
|
threads in the team. */
|
|
unsigned team_id;
|
|
|
|
/* Nesting level. */
|
|
unsigned level;
|
|
|
|
/* Active nesting level. Only active parallel regions are counted. */
|
|
unsigned active_level;
|
|
|
|
/* Place-partition-var, offset and length into gomp_places_list array. */
|
|
unsigned place_partition_off;
|
|
unsigned place_partition_len;
|
|
|
|
#ifdef HAVE_SYNC_BUILTINS
|
|
/* Number of single stmts encountered. */
|
|
unsigned long single_count;
|
|
#endif
|
|
|
|
/* For GFS_RUNTIME loops that resolved to GFS_STATIC, this is the
|
|
trip number through the loop. So first time a particular loop
|
|
is encountered this number is 0, the second time through the loop
|
|
is 1, etc. This is unused when the compiler knows in advance that
|
|
the loop is statically scheduled. */
|
|
unsigned long static_trip;
|
|
};
|
|
|
|
struct target_mem_desc;
|
|
struct gomp_memory_mapping;
|
|
|
|
/* These are the OpenMP 4.0 Internal Control Variables described in
|
|
section 2.3.1. Those described as having one copy per task are
|
|
stored within the structure; those described as having one copy
|
|
for the whole program are (naturally) global variables. */
|
|
|
|
struct gomp_task_icv
|
|
{
|
|
unsigned long nthreads_var;
|
|
enum gomp_schedule_type run_sched_var;
|
|
int run_sched_modifier;
|
|
int default_device_var;
|
|
unsigned int thread_limit_var;
|
|
bool dyn_var;
|
|
bool nest_var;
|
|
char bind_var;
|
|
/* Internal ICV. */
|
|
struct target_mem_desc *target_data;
|
|
};
|
|
|
|
extern struct gomp_task_icv gomp_global_icv;
|
|
#ifndef HAVE_SYNC_BUILTINS
|
|
extern gomp_mutex_t gomp_managed_threads_lock;
|
|
#endif
|
|
extern unsigned long gomp_max_active_levels_var;
|
|
extern bool gomp_cancel_var;
|
|
extern unsigned long long gomp_spin_count_var, gomp_throttled_spin_count_var;
|
|
extern unsigned long gomp_available_cpus, gomp_managed_threads;
|
|
extern unsigned long *gomp_nthreads_var_list, gomp_nthreads_var_list_len;
|
|
extern char *gomp_bind_var_list;
|
|
extern unsigned long gomp_bind_var_list_len;
|
|
extern void **gomp_places_list;
|
|
extern unsigned long gomp_places_list_len;
|
|
extern int gomp_debug_var;
|
|
extern int goacc_device_num;
|
|
extern char *goacc_device_type;
|
|
|
|
enum gomp_task_kind
|
|
{
|
|
GOMP_TASK_IMPLICIT,
|
|
GOMP_TASK_IFFALSE,
|
|
GOMP_TASK_WAITING,
|
|
GOMP_TASK_TIED
|
|
};
|
|
|
|
struct gomp_task;
|
|
struct gomp_taskgroup;
|
|
struct htab;
|
|
|
|
struct gomp_task_depend_entry
|
|
{
|
|
void *addr;
|
|
struct gomp_task_depend_entry *next;
|
|
struct gomp_task_depend_entry *prev;
|
|
struct gomp_task *task;
|
|
bool is_in;
|
|
bool redundant;
|
|
bool redundant_out;
|
|
};
|
|
|
|
struct gomp_dependers_vec
|
|
{
|
|
size_t n_elem;
|
|
size_t allocated;
|
|
struct gomp_task *elem[];
|
|
};
|
|
|
|
/* Used when in GOMP_taskwait or in gomp_task_maybe_wait_for_dependencies. */
|
|
|
|
struct gomp_taskwait
|
|
{
|
|
bool in_taskwait;
|
|
bool in_depend_wait;
|
|
size_t n_depend;
|
|
struct gomp_task *last_parent_depends_on;
|
|
gomp_sem_t taskwait_sem;
|
|
};
|
|
|
|
/* This structure describes a "task" to be run by a thread. */
|
|
|
|
struct gomp_task
|
|
{
|
|
struct gomp_task *parent;
|
|
struct gomp_task *children;
|
|
struct gomp_task *next_child;
|
|
struct gomp_task *prev_child;
|
|
struct gomp_task *next_queue;
|
|
struct gomp_task *prev_queue;
|
|
struct gomp_task *next_taskgroup;
|
|
struct gomp_task *prev_taskgroup;
|
|
struct gomp_taskgroup *taskgroup;
|
|
struct gomp_dependers_vec *dependers;
|
|
struct htab *depend_hash;
|
|
struct gomp_taskwait *taskwait;
|
|
size_t depend_count;
|
|
size_t num_dependees;
|
|
struct gomp_task_icv icv;
|
|
void (*fn) (void *);
|
|
void *fn_data;
|
|
enum gomp_task_kind kind;
|
|
bool in_tied_task;
|
|
bool final_task;
|
|
bool copy_ctors_done;
|
|
bool parent_depends_on;
|
|
struct gomp_task_depend_entry depend[];
|
|
};
|
|
|
|
struct gomp_taskgroup
|
|
{
|
|
struct gomp_taskgroup *prev;
|
|
struct gomp_task *children;
|
|
bool in_taskgroup_wait;
|
|
bool cancelled;
|
|
gomp_sem_t taskgroup_sem;
|
|
size_t num_children;
|
|
};
|
|
|
|
/* This structure describes a "team" of threads. These are the threads
|
|
that are spawned by a PARALLEL constructs, as well as the work sharing
|
|
constructs that the team encounters. */
|
|
|
|
struct gomp_team
|
|
{
|
|
/* This is the number of threads in the current team. */
|
|
unsigned nthreads;
|
|
|
|
/* This is number of gomp_work_share structs that have been allocated
|
|
as a block last time. */
|
|
unsigned work_share_chunk;
|
|
|
|
/* This is the saved team state that applied to a master thread before
|
|
the current thread was created. */
|
|
struct gomp_team_state prev_ts;
|
|
|
|
/* This semaphore should be used by the master thread instead of its
|
|
"native" semaphore in the thread structure. Required for nested
|
|
parallels, as the master is a member of two teams. */
|
|
gomp_sem_t master_release;
|
|
|
|
/* This points to an array with pointers to the release semaphore
|
|
of the threads in the team. */
|
|
gomp_sem_t **ordered_release;
|
|
|
|
/* List of work shares on which gomp_fini_work_share hasn't been
|
|
called yet. If the team hasn't been cancelled, this should be
|
|
equal to each thr->ts.work_share, but otherwise it can be a possibly
|
|
long list of workshares. */
|
|
struct gomp_work_share *work_shares_to_free;
|
|
|
|
/* List of gomp_work_share structs chained through next_free fields.
|
|
This is populated and taken off only by the first thread in the
|
|
team encountering a new work sharing construct, in a critical
|
|
section. */
|
|
struct gomp_work_share *work_share_list_alloc;
|
|
|
|
/* List of gomp_work_share structs freed by free_work_share. New
|
|
entries are atomically added to the start of the list, and
|
|
alloc_work_share can safely only move all but the first entry
|
|
to work_share_list alloc, as free_work_share can happen concurrently
|
|
with alloc_work_share. */
|
|
struct gomp_work_share *work_share_list_free;
|
|
|
|
#ifdef HAVE_SYNC_BUILTINS
|
|
/* Number of simple single regions encountered by threads in this
|
|
team. */
|
|
unsigned long single_count;
|
|
#else
|
|
/* Mutex protecting addition of workshares to work_share_list_free. */
|
|
gomp_mutex_t work_share_list_free_lock;
|
|
#endif
|
|
|
|
/* This barrier is used for most synchronization of the team. */
|
|
gomp_barrier_t barrier;
|
|
|
|
/* Initial work shares, to avoid allocating any gomp_work_share
|
|
structs in the common case. */
|
|
struct gomp_work_share work_shares[8];
|
|
|
|
gomp_mutex_t task_lock;
|
|
struct gomp_task *task_queue;
|
|
/* Number of all GOMP_TASK_{WAITING,TIED} tasks in the team. */
|
|
unsigned int task_count;
|
|
/* Number of GOMP_TASK_WAITING tasks currently waiting to be scheduled. */
|
|
unsigned int task_queued_count;
|
|
/* Number of GOMP_TASK_{WAITING,TIED} tasks currently running
|
|
directly in gomp_barrier_handle_tasks; tasks spawned
|
|
from e.g. GOMP_taskwait or GOMP_taskgroup_end don't count, even when
|
|
that is called from a task run from gomp_barrier_handle_tasks.
|
|
task_running_count should be always <= team->nthreads,
|
|
and if current task isn't in_tied_task, then it will be
|
|
even < team->nthreads. */
|
|
unsigned int task_running_count;
|
|
int work_share_cancelled;
|
|
int team_cancelled;
|
|
|
|
/* This array contains structures for implicit tasks. */
|
|
struct gomp_task implicit_task[];
|
|
};
|
|
|
|
/* This structure contains all data that is private to libgomp and is
|
|
allocated per thread. */
|
|
|
|
struct gomp_thread
|
|
{
|
|
/* This is the function that the thread should run upon launch. */
|
|
void (*fn) (void *data);
|
|
void *data;
|
|
|
|
/* This is the current team state for this thread. The ts.team member
|
|
is NULL only if the thread is idle. */
|
|
struct gomp_team_state ts;
|
|
|
|
/* This is the task that the thread is currently executing. */
|
|
struct gomp_task *task;
|
|
|
|
/* This semaphore is used for ordered loops. */
|
|
gomp_sem_t release;
|
|
|
|
/* Place this thread is bound to plus one, or zero if not bound
|
|
to any place. */
|
|
unsigned int place;
|
|
|
|
/* User pthread thread pool */
|
|
struct gomp_thread_pool *thread_pool;
|
|
};
|
|
|
|
|
|
struct gomp_thread_pool
|
|
{
|
|
/* This array manages threads spawned from the top level, which will
|
|
return to the idle loop once the current PARALLEL construct ends. */
|
|
struct gomp_thread **threads;
|
|
unsigned threads_size;
|
|
unsigned threads_used;
|
|
struct gomp_team *last_team;
|
|
/* Number of threads running in this contention group. */
|
|
unsigned long threads_busy;
|
|
|
|
/* This barrier holds and releases threads waiting in threads. */
|
|
gomp_barrier_t threads_dock;
|
|
};
|
|
|
|
enum gomp_cancel_kind
|
|
{
|
|
GOMP_CANCEL_PARALLEL = 1,
|
|
GOMP_CANCEL_LOOP = 2,
|
|
GOMP_CANCEL_FOR = GOMP_CANCEL_LOOP,
|
|
GOMP_CANCEL_DO = GOMP_CANCEL_LOOP,
|
|
GOMP_CANCEL_SECTIONS = 4,
|
|
GOMP_CANCEL_TASKGROUP = 8
|
|
};
|
|
|
|
/* ... and here is that TLS data. */
|
|
|
|
#if defined HAVE_TLS || defined USE_EMUTLS
|
|
extern __thread struct gomp_thread gomp_tls_data;
|
|
static inline struct gomp_thread *gomp_thread (void)
|
|
{
|
|
return &gomp_tls_data;
|
|
}
|
|
#else
|
|
extern pthread_key_t gomp_tls_key;
|
|
static inline struct gomp_thread *gomp_thread (void)
|
|
{
|
|
return pthread_getspecific (gomp_tls_key);
|
|
}
|
|
#endif
|
|
|
|
extern struct gomp_task_icv *gomp_new_icv (void);
|
|
|
|
/* Here's how to access the current copy of the ICVs. */
|
|
|
|
static inline struct gomp_task_icv *gomp_icv (bool write)
|
|
{
|
|
struct gomp_task *task = gomp_thread ()->task;
|
|
if (task)
|
|
return &task->icv;
|
|
else if (write)
|
|
return gomp_new_icv ();
|
|
else
|
|
return &gomp_global_icv;
|
|
}
|
|
|
|
/* The attributes to be used during thread creation. */
|
|
extern pthread_attr_t gomp_thread_attr;
|
|
|
|
/* Function prototypes. */
|
|
|
|
/* affinity.c */
|
|
|
|
extern void gomp_init_affinity (void);
|
|
extern void gomp_init_thread_affinity (pthread_attr_t *, unsigned int);
|
|
extern void **gomp_affinity_alloc (unsigned long, bool);
|
|
extern void gomp_affinity_init_place (void *);
|
|
extern bool gomp_affinity_add_cpus (void *, unsigned long, unsigned long,
|
|
long, bool);
|
|
extern bool gomp_affinity_remove_cpu (void *, unsigned long);
|
|
extern bool gomp_affinity_copy_place (void *, void *, long);
|
|
extern bool gomp_affinity_same_place (void *, void *);
|
|
extern bool gomp_affinity_finalize_place_list (bool);
|
|
extern bool gomp_affinity_init_level (int, unsigned long, bool);
|
|
extern void gomp_affinity_print_place (void *);
|
|
|
|
/* alloc.c */
|
|
|
|
extern void *gomp_malloc (size_t) __attribute__((malloc));
|
|
extern void *gomp_malloc_cleared (size_t) __attribute__((malloc));
|
|
extern void *gomp_realloc (void *, size_t);
|
|
|
|
/* Avoid conflicting prototypes of alloca() in system headers by using
|
|
GCC's builtin alloca(). */
|
|
#define gomp_alloca(x) __builtin_alloca(x)
|
|
|
|
/* error.c */
|
|
|
|
extern void gomp_vdebug (int, const char *, va_list);
|
|
extern void gomp_debug (int, const char *, ...)
|
|
__attribute__ ((format (printf, 2, 3)));
|
|
#define gomp_vdebug(KIND, FMT, VALIST) \
|
|
do { \
|
|
if (__builtin_expect (gomp_debug_var, 0)) \
|
|
(gomp_vdebug) ((KIND), (FMT), (VALIST)); \
|
|
} while (0)
|
|
#define gomp_debug(KIND, ...) \
|
|
do { \
|
|
if (__builtin_expect (gomp_debug_var, 0)) \
|
|
(gomp_debug) ((KIND), __VA_ARGS__); \
|
|
} while (0)
|
|
extern void gomp_verror (const char *, va_list);
|
|
extern void gomp_error (const char *, ...)
|
|
__attribute__ ((format (printf, 1, 2)));
|
|
extern void gomp_vfatal (const char *, va_list)
|
|
__attribute__ ((noreturn));
|
|
extern void gomp_fatal (const char *, ...)
|
|
__attribute__ ((noreturn, format (printf, 1, 2)));
|
|
|
|
/* iter.c */
|
|
|
|
extern int gomp_iter_static_next (long *, long *);
|
|
extern bool gomp_iter_dynamic_next_locked (long *, long *);
|
|
extern bool gomp_iter_guided_next_locked (long *, long *);
|
|
|
|
#ifdef HAVE_SYNC_BUILTINS
|
|
extern bool gomp_iter_dynamic_next (long *, long *);
|
|
extern bool gomp_iter_guided_next (long *, long *);
|
|
#endif
|
|
|
|
/* iter_ull.c */
|
|
|
|
extern int gomp_iter_ull_static_next (unsigned long long *,
|
|
unsigned long long *);
|
|
extern bool gomp_iter_ull_dynamic_next_locked (unsigned long long *,
|
|
unsigned long long *);
|
|
extern bool gomp_iter_ull_guided_next_locked (unsigned long long *,
|
|
unsigned long long *);
|
|
|
|
#if defined HAVE_SYNC_BUILTINS && defined __LP64__
|
|
extern bool gomp_iter_ull_dynamic_next (unsigned long long *,
|
|
unsigned long long *);
|
|
extern bool gomp_iter_ull_guided_next (unsigned long long *,
|
|
unsigned long long *);
|
|
#endif
|
|
|
|
/* ordered.c */
|
|
|
|
extern void gomp_ordered_first (void);
|
|
extern void gomp_ordered_last (void);
|
|
extern void gomp_ordered_next (void);
|
|
extern void gomp_ordered_static_init (void);
|
|
extern void gomp_ordered_static_next (void);
|
|
extern void gomp_ordered_sync (void);
|
|
|
|
/* parallel.c */
|
|
|
|
extern unsigned gomp_resolve_num_threads (unsigned, unsigned);
|
|
|
|
/* proc.c (in config/) */
|
|
|
|
extern void gomp_init_num_threads (void);
|
|
extern unsigned gomp_dynamic_max_threads (void);
|
|
|
|
/* task.c */
|
|
|
|
extern void gomp_init_task (struct gomp_task *, struct gomp_task *,
|
|
struct gomp_task_icv *);
|
|
extern void gomp_end_task (void);
|
|
extern void gomp_barrier_handle_tasks (gomp_barrier_state_t);
|
|
|
|
static void inline
|
|
gomp_finish_task (struct gomp_task *task)
|
|
{
|
|
if (__builtin_expect (task->depend_hash != NULL, 0))
|
|
free (task->depend_hash);
|
|
}
|
|
|
|
/* team.c */
|
|
|
|
extern struct gomp_team *gomp_new_team (unsigned);
|
|
extern void gomp_team_start (void (*) (void *), void *, unsigned,
|
|
unsigned, struct gomp_team *);
|
|
extern void gomp_team_end (void);
|
|
extern void gomp_free_thread (void *);
|
|
|
|
/* target.c */
|
|
|
|
extern void gomp_init_targets_once (void);
|
|
extern int gomp_get_num_devices (void);
|
|
|
|
typedef struct splay_tree_node_s *splay_tree_node;
|
|
typedef struct splay_tree_s *splay_tree;
|
|
typedef struct splay_tree_key_s *splay_tree_key;
|
|
|
|
struct target_mem_desc {
|
|
/* Reference count. */
|
|
uintptr_t refcount;
|
|
/* All the splay nodes allocated together. */
|
|
splay_tree_node array;
|
|
/* Start of the target region. */
|
|
uintptr_t tgt_start;
|
|
/* End of the targer region. */
|
|
uintptr_t tgt_end;
|
|
/* Handle to free. */
|
|
void *to_free;
|
|
/* Previous target_mem_desc. */
|
|
struct target_mem_desc *prev;
|
|
/* Number of items in following list. */
|
|
size_t list_count;
|
|
|
|
/* Corresponding target device descriptor. */
|
|
struct gomp_device_descr *device_descr;
|
|
|
|
/* Memory mapping info for the thread that created this descriptor. */
|
|
struct gomp_memory_mapping *mem_map;
|
|
|
|
/* List of splay keys to remove (or decrease refcount)
|
|
at the end of region. */
|
|
splay_tree_key list[];
|
|
};
|
|
|
|
struct splay_tree_key_s {
|
|
/* Address of the host object. */
|
|
uintptr_t host_start;
|
|
/* Address immediately after the host object. */
|
|
uintptr_t host_end;
|
|
/* Descriptor of the target memory. */
|
|
struct target_mem_desc *tgt;
|
|
/* Offset from tgt->tgt_start to the start of the target object. */
|
|
uintptr_t tgt_offset;
|
|
/* Reference count. */
|
|
uintptr_t refcount;
|
|
/* Asynchronous reference count. */
|
|
uintptr_t async_refcount;
|
|
/* True if data should be copied from device to host at the end. */
|
|
bool copy_from;
|
|
};
|
|
|
|
#include "splay-tree.h"
|
|
|
|
/* Information about mapped memory regions (per device/context). */
|
|
|
|
struct gomp_memory_mapping
|
|
{
|
|
/* Mutex for operating with the splay tree and other shared structures. */
|
|
gomp_mutex_t lock;
|
|
|
|
/* True when tables have been added to this memory map. */
|
|
bool is_initialized;
|
|
|
|
/* Splay tree containing information about mapped memory regions. */
|
|
struct splay_tree_s splay_tree;
|
|
};
|
|
|
|
typedef struct acc_dispatch_t
|
|
{
|
|
/* This is a linked list of data mapped using the
|
|
acc_map_data/acc_unmap_data or "acc enter data"/"acc exit data" pragmas.
|
|
Unlike mapped_data in the goacc_thread struct, unmapping can
|
|
happen out-of-order with respect to mapping. */
|
|
/* This is guarded by the lock in the "outer" struct gomp_device_descr. */
|
|
struct target_mem_desc *data_environ;
|
|
|
|
/* Extra information required for a device instance by a given target. */
|
|
/* This is guarded by the lock in the "outer" struct gomp_device_descr. */
|
|
void *target_data;
|
|
|
|
/* Open or close a device instance. */
|
|
void *(*open_device_func) (int n);
|
|
int (*close_device_func) (void *h);
|
|
|
|
/* Set or get the device number. */
|
|
int (*get_device_num_func) (void);
|
|
void (*set_device_num_func) (int);
|
|
|
|
/* Execute. */
|
|
void (*exec_func) (void (*) (void *), size_t, void **, void **, size_t *,
|
|
unsigned short *, int, int, int, int, void *);
|
|
|
|
/* Async cleanup callback registration. */
|
|
void (*register_async_cleanup_func) (void *);
|
|
|
|
/* Asynchronous routines. */
|
|
int (*async_test_func) (int);
|
|
int (*async_test_all_func) (void);
|
|
void (*async_wait_func) (int);
|
|
void (*async_wait_async_func) (int, int);
|
|
void (*async_wait_all_func) (void);
|
|
void (*async_wait_all_async_func) (int);
|
|
void (*async_set_async_func) (int);
|
|
|
|
/* Create/destroy TLS data. */
|
|
void *(*create_thread_data_func) (void *);
|
|
void (*destroy_thread_data_func) (void *);
|
|
|
|
/* NVIDIA target specific routines. */
|
|
struct {
|
|
void *(*get_current_device_func) (void);
|
|
void *(*get_current_context_func) (void);
|
|
void *(*get_stream_func) (int);
|
|
int (*set_stream_func) (int, void *);
|
|
} cuda;
|
|
} acc_dispatch_t;
|
|
|
|
/* This structure describes accelerator device.
|
|
It contains name of the corresponding libgomp plugin, function handlers for
|
|
interaction with the device, ID-number of the device, and information about
|
|
mapped memory. */
|
|
struct gomp_device_descr
|
|
{
|
|
/* Immutable data, which is only set during initialization, and which is not
|
|
guarded by the lock. */
|
|
|
|
/* The name of the device. */
|
|
const char *name;
|
|
|
|
/* Capabilities of device (supports OpenACC, OpenMP). */
|
|
unsigned int capabilities;
|
|
|
|
/* This is the ID number of device among devices of the same type. */
|
|
int target_id;
|
|
|
|
/* This is the TYPE of device. */
|
|
enum offload_target_type type;
|
|
|
|
/* Function handlers. */
|
|
const char *(*get_name_func) (void);
|
|
unsigned int (*get_caps_func) (void);
|
|
int (*get_type_func) (void);
|
|
int (*get_num_devices_func) (void);
|
|
void (*register_image_func) (void *, void *);
|
|
void (*init_device_func) (int);
|
|
void (*fini_device_func) (int);
|
|
int (*get_table_func) (int, struct mapping_table **);
|
|
void *(*alloc_func) (int, size_t);
|
|
void (*free_func) (int, void *);
|
|
void *(*dev2host_func) (int, void *, const void *, size_t);
|
|
void *(*host2dev_func) (int, void *, const void *, size_t);
|
|
void (*run_func) (int, void *, void *);
|
|
|
|
/* Memory-mapping info for this device instance. */
|
|
/* Uses a separate lock. */
|
|
struct gomp_memory_mapping mem_map;
|
|
|
|
/* Mutex for the mutable data. */
|
|
gomp_mutex_t lock;
|
|
|
|
/* Set to true when device is initialized. */
|
|
bool is_initialized;
|
|
|
|
/* True when offload regions have been registered with this device. */
|
|
bool offload_regions_registered;
|
|
|
|
/* OpenACC-specific data and functions. */
|
|
/* This is mutable because of its mutable data_environ and target_data
|
|
members. */
|
|
acc_dispatch_t openacc;
|
|
};
|
|
|
|
extern void gomp_acc_insert_pointer (size_t, void **, size_t *, void *);
|
|
extern void gomp_acc_remove_pointer (void *, bool, int, int);
|
|
|
|
extern struct target_mem_desc *gomp_map_vars (struct gomp_device_descr *,
|
|
size_t, void **, void **,
|
|
size_t *, void *, bool, bool);
|
|
extern void gomp_copy_from_async (struct target_mem_desc *);
|
|
extern void gomp_unmap_vars (struct target_mem_desc *, bool);
|
|
extern void gomp_init_device (struct gomp_device_descr *);
|
|
extern void gomp_init_tables (struct gomp_device_descr *,
|
|
struct gomp_memory_mapping *);
|
|
extern void gomp_free_memmap (struct gomp_memory_mapping *);
|
|
extern void gomp_fini_device (struct gomp_device_descr *);
|
|
|
|
/* work.c */
|
|
|
|
extern void gomp_init_work_share (struct gomp_work_share *, bool, unsigned);
|
|
extern void gomp_fini_work_share (struct gomp_work_share *);
|
|
extern bool gomp_work_share_start (bool);
|
|
extern void gomp_work_share_end (void);
|
|
extern bool gomp_work_share_end_cancel (void);
|
|
extern void gomp_work_share_end_nowait (void);
|
|
|
|
static inline void
|
|
gomp_work_share_init_done (void)
|
|
{
|
|
struct gomp_thread *thr = gomp_thread ();
|
|
if (__builtin_expect (thr->ts.last_work_share != NULL, 1))
|
|
gomp_ptrlock_set (&thr->ts.last_work_share->next_ws, thr->ts.work_share);
|
|
}
|
|
|
|
#ifdef HAVE_ATTRIBUTE_VISIBILITY
|
|
# pragma GCC visibility pop
|
|
#endif
|
|
|
|
/* Now that we're back to default visibility, include the globals. */
|
|
#include "libgomp_g.h"
|
|
|
|
/* Include omp.h by parts. */
|
|
#include "omp-lock.h"
|
|
#define _LIBGOMP_OMP_LOCK_DEFINED 1
|
|
#include "omp.h.in"
|
|
|
|
#if !defined (HAVE_ATTRIBUTE_VISIBILITY) \
|
|
|| !defined (HAVE_ATTRIBUTE_ALIAS) \
|
|
|| !defined (HAVE_AS_SYMVER_DIRECTIVE) \
|
|
|| !defined (PIC) \
|
|
|| !defined (HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
|
|
# undef LIBGOMP_GNU_SYMBOL_VERSIONING
|
|
#endif
|
|
|
|
#ifdef LIBGOMP_GNU_SYMBOL_VERSIONING
|
|
extern void gomp_init_lock_30 (omp_lock_t *) __GOMP_NOTHROW;
|
|
extern void gomp_destroy_lock_30 (omp_lock_t *) __GOMP_NOTHROW;
|
|
extern void gomp_set_lock_30 (omp_lock_t *) __GOMP_NOTHROW;
|
|
extern void gomp_unset_lock_30 (omp_lock_t *) __GOMP_NOTHROW;
|
|
extern int gomp_test_lock_30 (omp_lock_t *) __GOMP_NOTHROW;
|
|
extern void gomp_init_nest_lock_30 (omp_nest_lock_t *) __GOMP_NOTHROW;
|
|
extern void gomp_destroy_nest_lock_30 (omp_nest_lock_t *) __GOMP_NOTHROW;
|
|
extern void gomp_set_nest_lock_30 (omp_nest_lock_t *) __GOMP_NOTHROW;
|
|
extern void gomp_unset_nest_lock_30 (omp_nest_lock_t *) __GOMP_NOTHROW;
|
|
extern int gomp_test_nest_lock_30 (omp_nest_lock_t *) __GOMP_NOTHROW;
|
|
|
|
extern void gomp_init_lock_25 (omp_lock_25_t *) __GOMP_NOTHROW;
|
|
extern void gomp_destroy_lock_25 (omp_lock_25_t *) __GOMP_NOTHROW;
|
|
extern void gomp_set_lock_25 (omp_lock_25_t *) __GOMP_NOTHROW;
|
|
extern void gomp_unset_lock_25 (omp_lock_25_t *) __GOMP_NOTHROW;
|
|
extern int gomp_test_lock_25 (omp_lock_25_t *) __GOMP_NOTHROW;
|
|
extern void gomp_init_nest_lock_25 (omp_nest_lock_25_t *) __GOMP_NOTHROW;
|
|
extern void gomp_destroy_nest_lock_25 (omp_nest_lock_25_t *) __GOMP_NOTHROW;
|
|
extern void gomp_set_nest_lock_25 (omp_nest_lock_25_t *) __GOMP_NOTHROW;
|
|
extern void gomp_unset_nest_lock_25 (omp_nest_lock_25_t *) __GOMP_NOTHROW;
|
|
extern int gomp_test_nest_lock_25 (omp_nest_lock_25_t *) __GOMP_NOTHROW;
|
|
|
|
# define strong_alias(fn, al) \
|
|
extern __typeof (fn) al __attribute__ ((alias (#fn)));
|
|
# define omp_lock_symver(fn) \
|
|
__asm (".symver g" #fn "_30, " #fn "@@OMP_3.0"); \
|
|
__asm (".symver g" #fn "_25, " #fn "@OMP_1.0");
|
|
#else
|
|
# define gomp_init_lock_30 omp_init_lock
|
|
# define gomp_destroy_lock_30 omp_destroy_lock
|
|
# define gomp_set_lock_30 omp_set_lock
|
|
# define gomp_unset_lock_30 omp_unset_lock
|
|
# define gomp_test_lock_30 omp_test_lock
|
|
# define gomp_init_nest_lock_30 omp_init_nest_lock
|
|
# define gomp_destroy_nest_lock_30 omp_destroy_nest_lock
|
|
# define gomp_set_nest_lock_30 omp_set_nest_lock
|
|
# define gomp_unset_nest_lock_30 omp_unset_nest_lock
|
|
# define gomp_test_nest_lock_30 omp_test_nest_lock
|
|
#endif
|
|
|
|
#ifdef HAVE_ATTRIBUTE_VISIBILITY
|
|
# define attribute_hidden __attribute__ ((visibility ("hidden")))
|
|
#else
|
|
# define attribute_hidden
|
|
#endif
|
|
|
|
#ifdef HAVE_ATTRIBUTE_ALIAS
|
|
# define ialias_ulp ialias_str1(__USER_LABEL_PREFIX__)
|
|
# define ialias_str1(x) ialias_str2(x)
|
|
# define ialias_str2(x) #x
|
|
# define ialias(fn) \
|
|
extern __typeof (fn) gomp_ialias_##fn \
|
|
__attribute__ ((alias (#fn))) attribute_hidden;
|
|
# define ialias_redirect(fn) \
|
|
extern __typeof (fn) fn __asm__ (ialias_ulp "gomp_ialias_" #fn) attribute_hidden;
|
|
# define ialias_call(fn) gomp_ialias_ ## fn
|
|
#else
|
|
# define ialias(fn)
|
|
# define ialias_redirect(fn)
|
|
# define ialias_call(fn) fn
|
|
#endif
|
|
|
|
#endif /* LIBGOMP_H */
|