)]}'
{
  "commit": "5f881613fa9128edae5bbfa4e19f9752809e4bd7",
  "tree": "9677f855effa09243c00f6530cb3b5b03b70ffdd",
  "parents": [
    "17c41b39078fc8ad67fd1b82f74ef5174f34452e"
  ],
  "author": {
    "name": "Chung-Lin Tang",
    "email": "cltang@codesourcery.com",
    "time": "Fri May 19 12:14:04 2023 -0700"
  },
  "committer": {
    "name": "Chung-Lin Tang",
    "email": "cltang@codesourcery.com",
    "time": "Fri May 19 12:14:04 2023 -0700"
  },
  "message": "Use OpenACC code to process OpenMP target regions\n\nThis is a backport of:\nhttps://gcc.gnu.org/pipermail/gcc-patches/2023-May/619003.html\n\nThis patch implements \u0027-fopenmp-target\u003dacc\u0027, which enables internally handling\na subset of OpenMP target regions as OpenACC parallel regions. This basically\nincludes target, teams, parallel, distribute, for/do constructs, and atomics.\n\nEssentially, we adjust the internal kinds to OpenACC type, and let OpenACC code\npaths handle them, with various needed adjustments throughout middle-end and\nnvptx backend. When using this \"OMPACC\" mode, if there are cases the patch\ndoesn\u0027t handle, it issues a warning, and reverts to normal processing for that\ntarget region.\n\ngcc/ChangeLog:\n\n\t* builtins.cc (expand_builtin_omp_builtins): New function.\n\t(expand_builtin): Add expand cases for BUILT_IN_GOMP_BARRIER,\n\tBUILT_IN_OMP_GET_THREAD_NUM, BUILT_IN_OMP_GET_NUM_THREADS,\n\tBUILT_IN_OMP_GET_TEAM_NUM, and BUILT_IN_OMP_GET_NUM_TEAMS using\n\texpand_builtin_omp_builtins, enabled under -fopenmp-target\u003dacc.\n\t* cgraphunit.cc (analyze_functions): Add call to\n\tomp_ompacc_attribute_tagging, enabled under -fopenmp-target\u003dacc.\n\t* common.opt (fopenmp-target\u003d): Add new option and enums.\n\t* config/nvptx/mkoffload.cc (main): Handle -fopenmp-target\u003d.\n\t* config/nvptx/nvptx-protos.h (nvptx_expand_omp_get_num_threads): New\n\tprototype.\n\t(nvptx_mem_shared_p): Likewise.\n\t* config/nvptx/nvptx.cc (omp_num_threads_sym): New global static RTX\n\tsymbol for number of threads in team.\n\t(omp_num_threads_align): New var for alignment of omp_num_threads_sym.\n\t(need_omp_num_threads): New bool for if any function references\n\tomp_num_threads_sym.\n\t(nvptx_option_override): Initialize omp_num_threads_sym/align.\n\t(write_as_kernel): Disable normal OpenMP kernel entry under OMPACC mode.\n\t(nvptx_declare_function_name): Disable shim function under OMPACC mode.\n\tDisable soft-stack under OMPACC mode. Add generation of neutering init\n\tcode under OMPACC mode.\n\t(nvptx_output_set_softstack): Return \"\" under OMPACC mode.\n\t(nvptx_expand_call): Set parallelism to vector for function calls with\n\t\"ompacc for\" attached.\n\t(nvptx_expand_oacc_fork): Set mode to GOMP_DIM_VECTOR under OMPACC mode.\n\t(nvptx_expand_oacc_join): Likewise.\n\t(nvptx_expand_omp_get_num_threads): New function.\n\t(nvptx_mem_shared_p): New function.\n\t(nvptx_mach_max_workers): Return 1 under OMPACC mode.\n\t(nvptx_mach_vector_length): Return 32 under OMPACC mode.\n\t(nvptx_single): Add adjustments for OMPACC mode, which have\n\tparallel-construct fork/joins, and regions of code where neutering is\n\tdynamically determined.\n\t(nvptx_reorg): Enable neutering under OMPACC mode when \"ompacc for\"\n\tattribute is attached to function. Disable uniform-simt when under\n\tOMPACC mode.\n\t(nvptx_file_end): Write __nvptx_omp_num_threads out when needed.\n\t(nvptx_goacc_fork_join): Return true under OMPACC mode.\n\t* config/nvptx/nvptx.h (struct GTY(()) machine_function): Add\n\tomp_parallel_predicate and omp_fn_entry_num_threads_reg fields.\n\t* config/nvptx/nvptx.md (unspecv): Add UNSPECV_GET_TID,\n\tUNSPECV_GET_NTID, UNSPECV_GET_CTAID, UNSPECV_GET_NCTAID,\n\tUNSPECV_OMP_PARALLEL_FORK, UNSPECV_OMP_PARALLEL_JOIN entries.\n\t(nvptx_shared_mem_operand): New predicate.\n\t(gomp_barrier): New expand pattern.\n\t(omp_get_num_threads): New expand pattern.\n\t(omp_get_num_teams): New insn pattern.\n\t(omp_get_thread_num): Likewise.\n\t(omp_get_team_num): Likewise.\n\t(get_ntid): Likewise.\n\t(nvptx_omp_parallel_fork): Likewise.\n\t(nvptx_omp_parallel_join): Likewise.\n\n\t* flag-types.h (omp_target_mode_kind): New flag value enum.\n\t* gimplify.cc (struct gimplify_omp_ctx): Add \u0027bool ompacc\u0027 field.\n\t(gimplify_scan_omp_clauses): Handle OMP_CLAUSE__OMPACC_.\n\t(gimplify_adjust_omp_clauses): Likewise.\n\t(gimplify_omp_ctx_ompacc_p): New function.\n\t(gimplify_omp_for): Handle combined loops under OMPACC.\n\n\t* lto-wrapper.cc (append_compiler_options): Add OPT_fopenmp_target_.\n\t* omp-builtins.def (BUILT_IN_OMP_GET_THREAD_NUM): Remove CONST.\n\t(BUILT_IN_OMP_GET_NUM_THREADS): Likewise.\n\t* omp-expand.cc (remove_exit_barrier): Disable addressable-var\n\tprocessing for parallel construct child functions under OMPACC mode.\n\t(expand_oacc_for): Add OMPACC mode handling.\n\t(get_target_arguments): Force thread_limit clause value to 1 under\n\tOMPACC mode.\n\t(expand_omp): Under OMPACC mode, avoid child function expanding of\n\tGIMPLE_OMP_PARALLEL.\n\t* omp-general.cc (omp_extract_for_data): Adjustments for OMPACC mode.\n\t* omp-low.cc (struct omp_context): Add \u0027bool ompacc_p\u0027 field.\n\t(scan_sharing_clauses): Handle OMP_CLAUSE__OMPACC_.\n\t(ompacc_ctx_p): New function.\n\t(scan_omp_parallel): Handle OMPACC mode, avoid creating child function.\n\t(scan_omp_target): Tag \"ompacc\"/\"ompacc for\" attributes for target\n\tconstruct child function, remove OMP_CLAUSE__OMPACC_ clauses.\n\t(lower_oacc_head_mark): Handle OMPACC mode cases.\n\t(lower_omp_for): Adjust OMP_FOR kind from OpenMP to OpenACC kinds, add\n\tvector/gang clauses as needed. Add other OMPACC handling.\n\t(lower_omp_taskreg): Add call to lower_oacc_head_tail for OMPACC case.\n\t(lower_omp_target): Do OpenACC gang privatization under OMPACC case.\n\t(lower_omp_teams): Forward OpenACC privatization variables to outer\n\ttarget region under OMPACC mode.\n\t(lower_omp_1): Do OpenACC gang privatization under OMPACC case for\n\tGIMPLE_BIND.\n\t* omp-offload.cc (ompacc_supported_clauses_p): New function.\n\t(struct target_region_data): New struct type for tree walk.\n\t(scan_fndecl_for_ompacc): New function.\n\t(scan_omp_target_region_r): New function.\n\t(scan_omp_target_construct_r): New function.\n\t(omp_ompacc_attribute_tagging): New function.\n\t(oacc_dim_call): Add OMPACC case handling.\n\t(execute_oacc_device_lower): Make parts explicitly only OpenACC enabled.\n\t(pass_oacc_device_lower::gate): Enable pass under OMPACC mode.\n\t* omp-offload.h (omp_ompacc_attribute_tagging): New prototype.\n\t* opts.cc (finish_options): Only allow -fopenmp-target\u003d when -fopenmp\n\tand no -fopenacc.\n\t* target-insns.def (gomp_barrier): New defined insn pattern.\n\t(omp_get_thread_num): Likewise.\n\t(omp_get_num_threads): Likewise.\n\t(omp_get_team_num): Likewise.\n\t(omp_get_num_teams): Likewise.\n\t* tree-core.h (enum omp_clause_code): Add new OMP_CLAUSE__OMPACC_ entry\n\tfor internal clause.\n\t* tree-nested.cc (convert_nonlocal_omp_clauses): Handle\n\tOMP_CLAUSE__OMPACC_.\n\t* tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE__OMPACC_.\n\t* tree.cc (omp_clause_num_ops): Add OMP_CLAUSE__OMPACC_ entry.\n\t(omp_clause_code_name): Likewise.\n\t* tree.h (OMP_CLAUSE__OMPACC__FOR): New macro for OMP_CLAUSE__OMPACC_.\n\n\t* tree-ssa-loop.cc (pass_oacc_only::gate): Enable pass under OMPACC\n\tmode cases.\n\nlibgomp/ChangeLog:\n\n\t* config/nvptx/team.c (__nvptx_omp_num_threads): New global variable in\n\tshared memory.\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "b8cd75dcb5fb17d91467df273dd45b5fdce09f4c",
      "old_mode": 33188,
      "old_path": "gcc/builtins.cc",
      "new_id": "f36fe1508ef07d7390711d1d0f7aa53f8cead0d5",
      "new_mode": 33188,
      "new_path": "gcc/builtins.cc"
    },
    {
      "type": "modify",
      "old_id": "b949f61b76135182e76ef3e46290df012e70d36a",
      "old_mode": 33188,
      "old_path": "gcc/cgraphunit.cc",
      "new_id": "4d45ab3c7e029fedd38181e7f469da6a48d0f849",
      "new_mode": 33188,
      "new_path": "gcc/cgraphunit.cc"
    },
    {
      "type": "modify",
      "old_id": "e682ceaa7ed273d1f169650b77905eb95e6c4aae",
      "old_mode": 33188,
      "old_path": "gcc/common.opt",
      "new_id": "0caa6455630dfb1dfdec0e3f134284a0be6b1925",
      "new_mode": 33188,
      "new_path": "gcc/common.opt"
    },
    {
      "type": "modify",
      "old_id": "5d89ba8a78882564ed6241d6ab9841f48af1dc6b",
      "old_mode": 33188,
      "old_path": "gcc/config/nvptx/mkoffload.cc",
      "new_id": "82ea313027dd0a7ae7ec28e3d0a451ac0d828beb",
      "new_mode": 33188,
      "new_path": "gcc/config/nvptx/mkoffload.cc"
    },
    {
      "type": "modify",
      "old_id": "dfa08ec83190d202feab37c7b041dbad18229d0f",
      "old_mode": 33188,
      "old_path": "gcc/config/nvptx/nvptx-protos.h",
      "new_id": "a86514b6c6784ef032e9822dec8b9ac9cfcf7078",
      "new_mode": 33188,
      "new_path": "gcc/config/nvptx/nvptx-protos.h"
    },
    {
      "type": "modify",
      "old_id": "9c284ed5b0105c1ff36ecf17b604d5487a6c4b2d",
      "old_mode": 33188,
      "old_path": "gcc/config/nvptx/nvptx.cc",
      "new_id": "3b2bfd3c85fbbec7866bea666c7a5b3821346936",
      "new_mode": 33188,
      "new_path": "gcc/config/nvptx/nvptx.cc"
    },
    {
      "type": "modify",
      "old_id": "d815081147e61b97e521bfd5b32e5d0bf926b884",
      "old_mode": 33188,
      "old_path": "gcc/config/nvptx/nvptx.h",
      "new_id": "59580d27cfd4f2b9c9e6dc2d04d817b1dfb3e619",
      "new_mode": 33188,
      "new_path": "gcc/config/nvptx/nvptx.h"
    },
    {
      "type": "modify",
      "old_id": "d27126556ce07816f8c16895fee3cd9c3961131a",
      "old_mode": 33188,
      "old_path": "gcc/config/nvptx/nvptx.md",
      "new_id": "1d1a8577b4481508d92833717b82d37e711e99f7",
      "new_mode": 33188,
      "new_path": "gcc/config/nvptx/nvptx.md"
    },
    {
      "type": "modify",
      "old_id": "e0a0b801fabc2cd8927b270a2a2c6d690fe7ce6f",
      "old_mode": 33188,
      "old_path": "gcc/expr.cc",
      "new_id": "58a596e7e80ca4a15f3576d11496b62d574c88ff",
      "new_mode": 33188,
      "new_path": "gcc/expr.cc"
    },
    {
      "type": "modify",
      "old_id": "2bfab9805c17b17052fbd420c490ac32e0d4ee32",
      "old_mode": 33188,
      "old_path": "gcc/flag-types.h",
      "new_id": "518caadef10be894fb740b8cc5534bdbf386266b",
      "new_mode": 33188,
      "new_path": "gcc/flag-types.h"
    },
    {
      "type": "modify",
      "old_id": "6a3bd689b9eced3d9d08137802d383d1bba59bbf",
      "old_mode": 33188,
      "old_path": "gcc/gimplify.cc",
      "new_id": "4274c3358f6fd3106b553063545ae0468bf316db",
      "new_mode": 33188,
      "new_path": "gcc/gimplify.cc"
    },
    {
      "type": "modify",
      "old_id": "3d5764379256f38f4d8a104ef29e396349f35303",
      "old_mode": 33188,
      "old_path": "gcc/lto-wrapper.cc",
      "new_id": "3c833fcc207b310674cc06a0619fc6825110ace8",
      "new_mode": 33188,
      "new_path": "gcc/lto-wrapper.cc"
    },
    {
      "type": "modify",
      "old_id": "b3715b91cbbed772013de8320d4c56e5dba65a5d",
      "old_mode": 33188,
      "old_path": "gcc/omp-builtins.def",
      "new_id": "6d7e9d3b6311b9d2bc0d2328d999055429d40190",
      "new_mode": 33188,
      "new_path": "gcc/omp-builtins.def"
    },
    {
      "type": "modify",
      "old_id": "afe00069a56df97440ed0fdbcf9bfff4027eec9a",
      "old_mode": 33188,
      "old_path": "gcc/omp-expand.cc",
      "new_id": "d7e61c1cea511c0e31ec17f3f62c6abd97e2f23e",
      "new_mode": 33188,
      "new_path": "gcc/omp-expand.cc"
    },
    {
      "type": "modify",
      "old_id": "abaae12438d1eae9c86ac9040ce20e12cbe7deb9",
      "old_mode": 33188,
      "old_path": "gcc/omp-general.cc",
      "new_id": "982353529763f85a0ce185086ad0ac3867062bac",
      "new_mode": 33188,
      "new_path": "gcc/omp-general.cc"
    },
    {
      "type": "modify",
      "old_id": "bb4d148d087842c44be5865c38ea03a3763d0948",
      "old_mode": 33188,
      "old_path": "gcc/omp-low.cc",
      "new_id": "9a569df96e2fd2be5ae983a2f012b9033980b723",
      "new_mode": 33188,
      "new_path": "gcc/omp-low.cc"
    },
    {
      "type": "modify",
      "old_id": "b18f28f86b9b36edcde0aa5ae3ecd53ff2fcc7f8",
      "old_mode": 33188,
      "old_path": "gcc/omp-offload.cc",
      "new_id": "9dae07c84654441639577a702b629886933fe1d7",
      "new_mode": 33188,
      "new_path": "gcc/omp-offload.cc"
    },
    {
      "type": "modify",
      "old_id": "f6556afc5ba51809c14d93c0d95727e04297b2fb",
      "old_mode": 33188,
      "old_path": "gcc/omp-offload.h",
      "new_id": "581893fb35ad447007e48b81ae90cf0a6bb1a86e",
      "new_mode": 33188,
      "new_path": "gcc/omp-offload.h"
    },
    {
      "type": "modify",
      "old_id": "3fbfca98d7afe2608fc44d112563ec9b69943408",
      "old_mode": 33188,
      "old_path": "gcc/opts.cc",
      "new_id": "019ec971596cdb152479e22d0956e921b3cfc320",
      "new_mode": 33188,
      "new_path": "gcc/opts.cc"
    },
    {
      "type": "modify",
      "old_id": "de8c0092f989efa9e7d1f8a2a12fcf4ffc4a6013",
      "old_mode": 33188,
      "old_path": "gcc/target-insns.def",
      "new_id": "e146140030b12c4304a865c9ecb6a34bed9eb37f",
      "new_mode": 33188,
      "new_path": "gcc/target-insns.def"
    },
    {
      "type": "modify",
      "old_id": "7a5a87a7af48eee7d939f9b582128829b3198ceb",
      "old_mode": 33188,
      "old_path": "gcc/tree-core.h",
      "new_id": "fcfa87a05941dd0cc51489259d621afd3620e0cc",
      "new_mode": 33188,
      "new_path": "gcc/tree-core.h"
    },
    {
      "type": "modify",
      "old_id": "777f85f581caeb18b7c5d705415dc36630b656d0",
      "old_mode": 33188,
      "old_path": "gcc/tree-nested.cc",
      "new_id": "c6b23ef44b28f0830b6d139dacda2e4706aed92d",
      "new_mode": 33188,
      "new_path": "gcc/tree-nested.cc"
    },
    {
      "type": "modify",
      "old_id": "30c8f7b4a50e77471c6a9dc5a931085155486901",
      "old_mode": 33188,
      "old_path": "gcc/tree-pretty-print.cc",
      "new_id": "df1e86013b3fa190dcf9154611e6ba97bb977809",
      "new_mode": 33188,
      "new_path": "gcc/tree-pretty-print.cc"
    },
    {
      "type": "modify",
      "old_id": "b7a5a0f53f5f327964f9810c992e18fa922bb147",
      "old_mode": 33188,
      "old_path": "gcc/tree-ssa-loop.cc",
      "new_id": "ee651ce7079d0d669eccd220c359f2b7c4fb902f",
      "new_mode": 33188,
      "new_path": "gcc/tree-ssa-loop.cc"
    },
    {
      "type": "modify",
      "old_id": "aed566fcf0ea37d964a4c7e0439aa8c24afd54a8",
      "old_mode": 33188,
      "old_path": "gcc/tree.cc",
      "new_id": "0192fe3f0f400fb26b8a4d21b8832be848664d96",
      "new_mode": 33188,
      "new_path": "gcc/tree.cc"
    },
    {
      "type": "modify",
      "old_id": "177f350eb81bd652a84c983258743b341313ab68",
      "old_mode": 33188,
      "old_path": "gcc/tree.h",
      "new_id": "0b917d05b1eced849a3bea8cbb7806f595a29e90",
      "new_mode": 33188,
      "new_path": "gcc/tree.h"
    },
    {
      "type": "modify",
      "old_id": "b30b8df178d25a2c8fa5c9c7be1a1bac0f106c7f",
      "old_mode": 33188,
      "old_path": "libgomp/config/nvptx/team.c",
      "new_id": "146907a62a489373215ded19a91de589cca516b1",
      "new_mode": 33188,
      "new_path": "libgomp/config/nvptx/team.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "9771aaf2ab514355288ad3e59f5482ff0c2f8fe8",
      "new_mode": 33188,
      "new_path": "libgomp/testsuite/libgomp.c-c++-common/for-17.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "2486d3aa66508c701fae00bf128c15db9c1d5bd9",
      "new_mode": 33188,
      "new_path": "libgomp/testsuite/libgomp.c-c++-common/for-18.c"
    }
  ]
}
