1. 27 Jun, 2022 5 commits
    • Andrew Stubbs's avatar
      amdgcn: libgomp plugin USM implementation · cdddaf7f
      Andrew Stubbs authored
      Implement the Unified Shared Memory API calls in the GCN plugin.
      
      The allocate and free are pretty straight-forward because all "target" memory
      allocations are compatible with USM, on the right hardware.  However, there's
      no known way to check what memory region was used, after the fact, so we use a
      splay tree to record allocations so we can answer "is_usm_ptr" later.
      
      libgomp/ChangeLog:
      
      	* plugin/plugin-gcn.c (struct usm_splay_tree_key_s): New.
      	(usm_splay_compare): New.
      	(splay_tree_prefix): New.
      	(GOMP_OFFLOAD_usm_alloc): New.
      	(GOMP_OFFLOAD_usm_free): New.
      	(GOMP_OFFLOAD_is_usm_ptr): New.
      	(GOMP_OFFLOAD_supported_features): Move into the OpenMP API fold.
      	Add GOMP_REQUIRES_UNIFIED_ADDRESS and
      	GOMP_REQUIRES_UNIFIED_SHARED_MEMORY.
      	(gomp_fatal): New.
      	(splay_tree_c): New.
      	* testsuite/lib/libgomp.exp (check_effective_target_omp_usm): New.
      	* testsuite/libgomp.c++/usm-1.C: Use dg-require-effective-target.
      	* testsuite/libgomp.c-c++-common/requires-1.c: Likewise.
      	* testsuite/libgomp.c/usm-1.c: Likewise.
      	* testsuite/libgomp.c/usm-2.c: Likewise.
      	* testsuite/libgomp.c/usm-3.c: Likewise.
      	* testsuite/libgomp.c/usm-4.c: Likewise.
      	* testsuite/libgomp.c/usm-5.c: Likewise.
      	* testsuite/libgomp.c/usm-6.c: Likewise.
      cdddaf7f
    • Andrew Stubbs's avatar
      amdgcn, openmp: Auto-detect USM mode and set HSA_XNACK · d1eb334f
      Andrew Stubbs authored
      The AMD GCN runtime must be set to the correct mode for Unified Shared Memory
      to work, but this is not always clear at compile and link time due to the split
      nature of the offload compilation pipeline.
      
      This patch sets a new attribute on OpenMP offload functions to ensure that the
      information is passed all the way to the backend.  The backend then places a
      marker in the assembler code for mkoffload to find. Finally mkoffload places a
      constructor function into the final program to ensure that the HSA_XNACK
      environment variable passes the correct mode to the GPU.
      
      The HSA_XNACK variable must be set before the HSA runtime is even loaded, so
      it makes more sense to have this set within the constructor than at some point
      later within libgomp or the GCN plugin.
      
      gcc/ChangeLog:
      
      	* config/gcn/gcn.c (unified_shared_memory_enabled): New variable.
      	(gcn_init_cumulative_args): Handle attribute "omp unified memory".
      	(gcn_hsa_declare_function_name): Emit "MKOFFLOAD OPTIONS: USM+".
      	* config/gcn/mkoffload.c (TEST_XNACK_OFF): New macro.
      	(process_asm): Detect "MKOFFLOAD OPTIONS: USM+".
      	Emit configure_xnack constructor, as required.
      	* omp-low.c (create_omp_child_function): Add attribute "omp unified
      	memory".
      d1eb334f
    • Andrew Stubbs's avatar
      amdgcn: Support XNACK mode · 9aefadc9
      Andrew Stubbs authored
      The XNACK feature allows memory load instructions to restart safely following
      a page-miss interrupt.  This is useful for shared-memory devices, like APUs,
      and to implement OpenMP Unified Shared Memory.
      
      To support the feature we must be able to set the appropriate meta-data and
      set the load instructions to early-clobber.  When the port supports scheduling
      of s_waitcnt instructions there will be further requirements.
      
      gcc/ChangeLog:
      
      	* config/gcn/gcn-hsa.h (XNACKOPT): New macro.
      	(ASM_SPEC): Use XNACKOPT.
      	* config/gcn/gcn-opts.h (enum sram_ecc_type): Rename to ...
      	(enum hsaco_attr_type): ... this, and generalize the names.
      	(TARGET_XNACK): New macro.
      	* config/gcn/gcn-valu.md (gather<mode>_insn_1offset<exec>):
      	Add xnack compatible alternatives.
      	(gather<mode>_insn_2offsets<exec>): Likewise.
      	* config/gcn/gcn.c (gcn_option_override): Permit -mxnack for devices
      	other than Fiji.
      	(gcn_expand_epilogue): Remove early-clobber problems.
      	(output_file_start): Emit xnack attributes.
      	(gcn_hsa_declare_function_name): Obey -mxnack setting.
      	* config/gcn/gcn.md (xnack): New attribute.
      	(enabled): Rework to include "xnack" attribute.
      	(*movbi): Add xnack compatible alternatives.
      	(*mov<mode>_insn): Likewise.
      	(*mov<mode>_insn): Likewise.
      	(*mov<mode>_insn): Likewise.
      	(*movti_insn): Likewise.
      	* config/gcn/gcn.opt (-mxnack): Add the "on/off/any" syntax.
      	(sram_ecc_type): Rename to ...
      	(hsaco_attr_type: ... this.)
      	* config/gcn/mkoffload.c (SET_XNACK_ANY): New macro.
      	(TEST_XNACK): Delete.
      	(TEST_XNACK_ANY): New macro.
      	(TEST_XNACK_ON): New macro.
      	(main): Support the new -mxnack=on/off/any syntax.
      9aefadc9
    • Tobias Burnus's avatar
      Fix gfortran.dg/gomp/affinity-clause-1.f90 · 88c73dbc
      Tobias Burnus authored
      The patch
          [OG11][committed][PATCH 01/22] Fortran: delinearize multi-dimensional array accesses
          https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584716.html
      OG11 commit e208eefb causes a different
      dump - update the testcase accordingly.
      
      gcc/testsuite/
      	* gfortran.dg/gomp/affinity-clause-1.f90: Fix scan-tree-dump-times.
      88c73dbc
    • Tobias Burnus's avatar
      Fix gfortran.dg/gomp/num-teams-2.f90 · 1cbfde1c
      Tobias Burnus authored
      OG11 contrary to mainline issues an error for resolve_positive_int_expr
      (-> OG11 commit a14b3f29). Update
      testcase accordingly.
      
      gcc/testsuite/
      	* gfortran.dg/gomp/num-teams-2.f90: Use dg-error not dg-warning.
      1cbfde1c
  2. 17 Jun, 2022 2 commits
    • Chung-Lin Tang's avatar
      openmp: Implement uses_allocators clause · e2435c75
      Chung-Lin Tang authored
      This is a merge of:
      https://gcc.gnu.org/pipermail/gcc-patches/2022-June/596412.html
      
      For user defined allocator handles, this allows target regions to assign
      memory space and traits to allocators, and automatically calls
      omp_init/destroy_allocator() in the beginning/end of the target region.
      
      For pre-defined allocators (i.e. omp_..._mem_alloc names), this is a no-op,
      such clauses are not created.
      
      Asides from the front-end portions, the target region transforms are
      done in gimplify_omp_workshare.
      
      This patch also includes added changes to enforce the "allocate allocator
      must be also in a uses_allocator clause". This is done during
      gimplify_scan_omp_clauses.
      
      gcc/c-family/ChangeLog:
      
      	* c-omp.cc (c_omp_split_clauses): Add OMP_CLAUSE_USES_ALLOCATORS case.
      	* c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_USES_ALLOCATORS.
      
      gcc/c/ChangeLog:
      
      	* c-parser.cc (c_parser_omp_clause_name): Add case for uses_allocators
      	clause.
      	(c_parser_omp_clause_uses_allocators): New function.
      	(c_parser_omp_all_clauses): Add PRAGMA_OMP_CLAUSE_USES_ALLOCATORS case.
      	(OMP_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_USES_ALLOCATORS to mask.
      	* c-typeck.cc (c_finish_omp_clauses): Add case handling for
      	OMP_CLAUSE_USES_ALLOCATORS.
      
      gcc/cp/ChangeLog:
      
      	* parser.cc (cp_parser_omp_clause_name): Add case for uses_allocators
      	clause.
      	(cp_parser_omp_clause_uses_allocators): New function.
      	(cp_parser_omp_all_clauses): Add PRAGMA_OMP_CLAUSE_USES_ALLOCATORS case.
      	(OMP_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_USES_ALLOCATORS to mask.
      	* semantics.cc (finish_omp_clauses): Add case handling for
      	OMP_CLAUSE_USES_ALLOCATORS.
      
      fortran/ChangeLog:
      
      	* gfortran.h (struct gfc_omp_namelist): Add memspace_sym, traits_sym
      	fields.
      	(OMP_LIST_USES_ALLOCATORS): New list enum.
      	* openmp.cc (enum omp_mask2): Add OMP_CLAUSE_USES_ALLOCATORS.
      	(gfc_match_omp_clause_uses_allocators): New function.
      	(gfc_match_omp_clauses): Add case to handle OMP_CLAUSE_USES_ALLOCATORS.
      	(OMP_TARGET_CLAUSES): Add OMP_CLAUSE_USES_ALLOCATORS.
      	(resolve_omp_clauses): Add "USES_ALLOCATORS" to clause_names[].
      	* dump-parse-tree.cc (show_omp_namelist): Handle OMP_LIST_USES_ALLOCATORS.
      	(show_omp_clauses): Likewise.
      	* trans-array.cc (gfc_conv_array_initializer): Adjust array index
      	to always be a created tree expression instead of NULL_TREE when zero.
      	* trans-openmp.cc (gfc_trans_omp_clauses): For ALLOCATE clause, handle
      	using gfc_trans_omp_variable for EXPR_VARIABLE exprs.
      	Add handling of OMP_LIST_USES_ALLOCATORS case.
      	* types.def (BT_FN_VOID_PTRMODE): Define.
      	(BT_FN_PTRMODE_PTRMODE_INT_PTR): Define.
      
      gcc/ChangeLog:
      
      	* builtin-types.def (BT_FN_VOID_PTRMODE): Define.
      	(BT_FN_PTRMODE_PTRMODE_INT_PTR): Define.
      	* omp-builtins.def (BUILT_IN_OMP_INIT_ALLOCATOR): Define.
      	(BUILT_IN_OMP_DESTROY_ALLOCATOR): Define.
      	* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_USES_ALLOCATORS.
      	* tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE_USES_ALLOCATORS.
      	* tree.h (OMP_CLAUSE_USES_ALLOCATORS_ALLOCATOR): New macro.
      	(OMP_CLAUSE_USES_ALLOCATORS_MEMSPACE): New macro.
      	(OMP_CLAUSE_USES_ALLOCATORS_TRAITS): New macro.
      	* tree.cc (omp_clause_num_ops): Add OMP_CLAUSE_USES_ALLOCATORS.
      	(omp_clause_code_name): Add "uses_allocators".
      	(walk_tree_1): Add OMP_CLAUSE_USES_ALLOCATORS case.
      
      	* gimplify.cc (gimplify_scan_omp_clauses): Add checking of OpenMP target
      	region allocate	clauses, to require a uses_allocators clause to exist
      	for allocators.
      	(gimplify_omp_workshare): Add handling of OMP_CLAUSE_USES_ALLOCATORS
      	for OpenMP target regions; create calls of omp_init/destroy_allocator
      	around target region body.
      	* omp-low.cc (lower_private_allocate): Adjust receiving of allocator.
      	(lower_rec_input_clauses): Likewise.
      	(create_task_copyfn): Add dereference for allocator if needed.
      
      	* system.h (startswith): New function.
      
      gcc/testsuite/ChangeLog:
      
      	* c-c++-common/gomp/uses_allocators-1.c: New test.
      	* c-c++-common/gomp/uses_allocators-2.c: New test.
      	* c-c++-common/gomp/uses_allocators-3.c: New test.
      	* gfortran.dg/gomp/allocate-1.f90: Adjust testcase.
      	* gfortran.dg/gomp/uses_allocators-1.f90: New test.
      	* gfortran.dg/gomp/uses_allocators-2.f90: New test.
      	* gfortran.dg/gomp/uses_allocators-3.f90: New test.
      e2435c75
    • Chung-Lin Tang's avatar
      middle-end/103851 - ensure SSA names are released during OMP lowering · efeaf071
      Chung-Lin Tang authored
      This makes sure to release moved & remapped SSA names during OMP
      outlining which happens before going into SSA but with SSA names
      created by gimplification around.
      
      2022-01-03  Richard Biener  <rguenther@suse.de>
      
      	PR middle-end/103851
      	* tree-cfg.c (move_sese_region_to_fn): Always release SSA names.
      
      	* g++.dg/gomp/pr103851.C: New testcase.
      
      (cherry picked from commit 4911609f)
      efeaf071
  3. 14 Jun, 2022 1 commit
  4. 13 Jun, 2022 1 commit
    • Chung-Lin Tang's avatar
      openmp: Implement uses_allocators clause · 729c88aa
      Chung-Lin Tang authored
      This is a merge of:
      https://gcc.gnu.org/pipermail/gcc-patches/2022-June/596412.html
      
      For user defined allocator handles, this allows target regions to assign
      memory space and traits to allocators, and automatically calls
      omp_init/destroy_allocator() in the beginning/end of the target region.
      
      For pre-defined allocators (i.e. omp_..._mem_alloc names), this is a no-op,
      such clauses are not created.
      
      Asides from the front-end portions, the target region transforms are
      done in gimplify_omp_workshare.
      
      This patch also includes added changes to enforce the "allocate allocator
      must be also in a uses_allocator clause". This is done during
      gimplify_scan_omp_clauses.
      
      gcc/c-family/ChangeLog:
      
      	* c-omp.cc (c_omp_split_clauses): Add OMP_CLAUSE_USES_ALLOCATORS case.
      	* c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_USES_ALLOCATORS.
      
      gcc/c/ChangeLog:
      
      	* c-parser.cc (c_parser_omp_clause_name): Add case for uses_allocators
      	clause.
      	(c_parser_omp_clause_uses_allocators): New function.
      	(c_parser_omp_all_clauses): Add PRAGMA_OMP_CLAUSE_USES_ALLOCATORS case.
      	(OMP_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_USES_ALLOCATORS to mask.
      	* c-typeck.cc (c_finish_omp_clauses): Add case handling for
      	OMP_CLAUSE_USES_ALLOCATORS.
      
      gcc/cp/ChangeLog:
      
      	* parser.cc (cp_parser_omp_clause_name): Add case for uses_allocators
      	clause.
      	(cp_parser_omp_clause_uses_allocators): New function.
      	(cp_parser_omp_all_clauses): Add PRAGMA_OMP_CLAUSE_USES_ALLOCATORS case.
      	(OMP_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_USES_ALLOCATORS to mask.
      	* semantics.cc (finish_omp_clauses): Add case handling for
      	OMP_CLAUSE_USES_ALLOCATORS.
      
      fortran/ChangeLog:
      
      	* gfortran.h (struct gfc_omp_namelist): Add memspace_sym, traits_sym
      	fields.
      	(OMP_LIST_USES_ALLOCATORS): New list enum.
      	* openmp.cc (enum omp_mask2): Add OMP_CLAUSE_USES_ALLOCATORS.
      	(gfc_match_omp_clause_uses_allocators): New function.
      	(gfc_match_omp_clauses): Add case to handle OMP_CLAUSE_USES_ALLOCATORS.
      	(OMP_TARGET_CLAUSES): Add OMP_CLAUSE_USES_ALLOCATORS.
      	(resolve_omp_clauses): Add "USES_ALLOCATORS" to clause_names[].
      	* dump-parse-tree.cc (show_omp_namelist): Handle OMP_LIST_USES_ALLOCATORS.
      	(show_omp_clauses): Likewise.
      	* trans-array.cc (gfc_conv_array_initializer): Adjust array index
      	to always be a created tree expression instead of NULL_TREE when zero.
      	* trans-openmp.cc (gfc_trans_omp_clauses): For ALLOCATE clause, handle
      	using gfc_trans_omp_variable for EXPR_VARIABLE exprs.
      	Add handling of OMP_LIST_USES_ALLOCATORS case.
      	* types.def (BT_FN_VOID_PTRMODE): Define.
      	(BT_FN_PTRMODE_PTRMODE_INT_PTR): Define.
      
      gcc/ChangeLog:
      
      	* builtin-types.def (BT_FN_VOID_PTRMODE): Define.
      	(BT_FN_PTRMODE_PTRMODE_INT_PTR): Define.
      	* omp-builtins.def (BUILT_IN_OMP_INIT_ALLOCATOR): Define.
      	(BUILT_IN_OMP_DESTROY_ALLOCATOR): Define.
      	* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_USES_ALLOCATORS.
      	* tree-pretty-print.cc (dump_omp_clause): Handle OMP_CLAUSE_USES_ALLOCATORS.
      	* tree.h (OMP_CLAUSE_USES_ALLOCATORS_ALLOCATOR): New macro.
      	(OMP_CLAUSE_USES_ALLOCATORS_MEMSPACE): New macro.
      	(OMP_CLAUSE_USES_ALLOCATORS_TRAITS): New macro.
      	* tree.cc (omp_clause_num_ops): Add OMP_CLAUSE_USES_ALLOCATORS.
      	(omp_clause_code_name): Add "uses_allocators".
      
      	* gimplify.cc (gimplify_scan_omp_clauses): Add checking of OpenMP target
      	region allocate	clauses, to require a uses_allocators clause to exist
      	for allocators.
      	(gimplify_omp_workshare): Add handling of OMP_CLAUSE_USES_ALLOCATORS
      	for OpenMP target regions; create calls of omp_init/destroy_allocator
      	around target region body.
      	* omp-low.cc (lower_private_allocate): Adjust receiving of allocator.
      	(lower_rec_input_clauses): Likewise.
      	(create_task_copyfn): Add dereference for allocator if needed.
      
      	* system.h (startswith): New function.
      
      gcc/testsuite/ChangeLog:
      
      	* c-c++-common/gomp/uses_allocators-1.c: New test.
      	* c-c++-common/gomp/uses_allocators-2.c: New test.
      	* c-c++-common/gomp/uses_allocators-3.c: New test.
      	* gfortran.dg/gomp/allocate-1.f90: Adjust testcase.
      	* gfortran.dg/gomp/uses_allocators-1.f90: New test.
      	* gfortran.dg/gomp/uses_allocators-2.f90: New test.
      	* gfortran.dg/gomp/uses_allocators-3.f90: New test.
      729c88aa
  5. 30 May, 2022 1 commit
  6. 24 May, 2022 2 commits
    • Andrew Stubbs's avatar
      amdgcn: Add gfx90a support · a1539294
      Andrew Stubbs authored
      This adds architecture options and multilibs for the AMD GFX90a GPUs.
      It also tidies up some of the ISA selection code, and corrects a few small
      mistake in the gfx908 naming.
      
      gcc/ChangeLog:
      
      	* config.gcc (amdgcn): Accept --with-arch=gfx908 and gfx90a.
      	* config/gcn/gcn-opts.h (enum gcn_isa): New.
      	(TARGET_GCN3): Use enum gcn_isa.
      	(TARGET_GCN3_PLUS): Likewise.
      	(TARGET_GCN5): Likewise.
      	(TARGET_GCN5_PLUS): Likewise.
      	(TARGET_CDNA1): New.
      	(TARGET_CDNA1_PLUS): New.
      	(TARGET_CDNA2): New.
      	(TARGET_CDNA2_PLUS): New.
      	(TARGET_M0_LDS_LIMIT): New.
      	(TARGET_PACKED_WORK_ITEMS): New.
      	* config/gcn/gcn.cc (gcn_isa): Change to enum gcn_isa.
      	(gcn_option_override): Recognise CDNA ISA variants.
      	(gcn_omp_device_kind_arch_isa): Support gfx90a.
      	(gcn_expand_prologue): Make m0 init optional.
      	Add support for packed work items.
      	(output_file_start): Support gfx90a.
      	(gcn_hsa_declare_function_name): Support gfx90a metadata.
      	* config/gcn/gcn.h (TARGET_CPU_CPP_BUILTINS):Add __CDNA1__ and
      	__CDNA2__.
      	* config/gcn/gcn.md (<su>mulsi3_highpart): Use TARGET_GCN5_PLUS.
      	(<su>mulsi3_highpart_imm): Likewise.
      	(<su>mulsidi3): Likewise.
      	(<su>mulsidi3_imm): Likewise.
      	* config/gcn/gcn.opt (gpu_type): Add gfx90a.
      	* config/gcn/mkoffload.cc (EF_AMDGPU_MACH_AMDGCN_GFX90a): New.
      	(main): Support gfx90a.
      	* config/gcn/t-gcn-hsa: Add gfx90a multilib.
      	* config/gcn/t-omp-device: Add gfx90a isa.
      
      libgomp/ChangeLog:
      
      	* plugin/plugin-gcn.c (EF_AMDGPU_MACH): Add
      	EF_AMDGPU_MACH_AMDGCN_GFX90a.
      	(gcn_gfx90a_s): New.
      	(isa_hsa_name): Support gfx90a.
      	(isa_code): Likewise.
      
      Backport from cde52d3a.
      a1539294
    • Andrew Stubbs's avatar
      amdgcn: Remove LLVM 9 assembler/linker support · 7d5faa57
      Andrew Stubbs authored
      The minimum required LLVM version is now 13.0.1, and is enforced by configure.
      
      gcc/ChangeLog:
      
      	* config.in: Regenerate.
      	* config/gcn/gcn-hsa.h (X_FIJI): Delete.
      	(X_900): Delete.
      	(X_906): Delete.
      	(X_908): Delete.
      	(S_FIJI): Delete.
      	(S_900): Delete.
      	(S_906): Delete.
      	(S_908): Delete.
      	(NO_XNACK): New macro.
      	(NO_SRAM_ECC): New macro.
      	(SRAMOPT): Keep only v4 variant.
      	(HSACO3_SELECT_OPT): Delete.
      	(DRIVER_SELF_SPECS): Delete.
      	(ASM_SPEC): Remove LLVM 9 support.
      	* config/gcn/gcn-valu.md
      	(gather<mode>_insn_2offsets<exec>): Remove assembler bug workaround.
      	(scatter<mode>_insn_2offsets<exec_scatter>): Likewise.
      	* config/gcn/gcn.cc (output_file_start): Remove LLVM 9 support.
      	(print_operand_address): Remove assembler bug workaround.
      	* config/gcn/mkoffload.cc (EF_AMDGPU_XNACK_V3): Delete.
      	(EF_AMDGPU_SRAM_ECC_V3): Delete.
      	(SET_XNACK_ON): Delete v3 variants.
      	(SET_XNACK_OFF): Delete v3 variants.
      	(TEST_XNACK): Delete v3 variants.
      	(SET_SRAM_ECC_ON): Delete v3 variants.
      	(SET_SRAM_ECC_ANY): Delete v3 variants.
      	(SET_SRAM_ECC_OFF): Delete v3 variants.
      	(SET_SRAM_ECC_UNSUPPORTED): Delete v3 variants.
      	(TEST_SRAM_ECC_ANY): Delete v3 variants.
      	(TEST_SRAM_ECC_ON): Delete v3 variants.
      	(copy_early_debug_info): Remove v3 support.
      	(main): Remove v3 support.
      	* configure: Regenerate.
      	* configure.ac: Replace all GCN feature checks with a version check.
      
      Backport from 8086230e.
      7d5faa57
  7. 12 May, 2022 2 commits
    • Tobias Burnus's avatar
      OpenMP: Handle descriptors in target's firstprivate [PR104949] · edd7d04c
      Tobias Burnus authored
      For allocatable/pointer arrays, a firstprivate to a device
      not only needs to privatize the descriptor but also the actual
      data. This is implemented as:
        firstprivate(x) firstprivate(x.data) attach(x [bias: &x.data-&x)
      where the address of x in device memory is saved in hostaddrs[i]
      by libgomp and the middle end actually passes hostaddrs[i]' to
      attach.
      
      OG11 version of the GCC 13/mainline patch submitted at
        https://gcc.gnu.org/pipermail/gcc-patches/2022-May/594582.html
      Note: Contrary to GCC 12+, OG11 does not support has_device_addr,
      which is the main difference to the posted patch.
      
      gcc/fortran/ChangeLog:
      
      	PR fortran/104949
      	* f95-lang.c (LANG_HOOKS_OMP_ARRAY_SIZE): Redefine.
      	* trans-openmp.c (gfc_omp_array_size): New.
      	* trans.h (gfc_omp_array_size): New.
      
      gcc/ChangeLog:
      
      	PR fortran/104949
      	* langhooks-def.h (lhd_omp_array_size): New.
      	(LANG_HOOKS_OMP_ARRAY_SIZE): Define
      	(LANG_HOOKS_DECLS): Add it.
      	* langhooks.c (lhd_omp_array_size): New.
      	* langhooks.h (struct lang_hooks_for_decls): Add hook.
      	* omp-low.c (scan_sharing_clauses, lower_omp_target):
      	Handle GOMP_MAP_FIRSTPRIVATE for array descriptors.
      
      libgomp/ChangeLog:
      
      	PR fortran/104949
      	* target.c (gomp_map_vars_internal, copy_firstprivate_data):
      	Support attach for GOMP_MAP_FIRSTPRIVATE.
      	* testsuite/libgomp.fortran/target-firstprivate-1.f90: New test.
      	* testsuite/libgomp.fortran/target-firstprivate-2.f90: New test.
      	* testsuite/libgomp.fortran/target-firstprivate-3.f90: New test.
      edd7d04c
    • Tobias Burnus's avatar
      Fortran: Fix proc pointer as elemental arg handling · ee954d94
      Tobias Burnus authored
      The vtab's _callback function calls the elemental 'cb'
        cb (var(:)%comp, comp_types_vtable._callback);
      which gets called in a scalarization loop as 'var' might be a
      nonscalar. Without the patch, that got translated as:
        D.1234 = &comp_types_vtable._callback
        ...
         cb (&(*D.4060)[S.3 + D.4071], &D.1234);
      where 'D.1234' is function_type. With the patch, it remains a pointer;
      i.e. D.1234 = comp... and 'cb (..., D.1234)', avoiding ME ICE.
      
      Note: Fortran (F2018, C15100) requires that dummy arguments are
      dummy data objects, which rules out dummy procs/proc-pointer dummies,
      which is enforced in resolve_fl_procedure.
      Thus, this change only affects the internally generated code.
      
      gcc/fortran/ChangeLog:
      
              * trans-array.c (gfc_scalar_elemental_arg_saved_as_reference):
      	Return true for attr.proc_pointer expressions.
      
      gcc/testsuite/ChangeLog:
      
              * gfortran.dg/finalize_38.f90: Compile with -Ofast.
      ee954d94
  8. 27 Apr, 2022 1 commit
    • Tobias Burnus's avatar
      Fortran: Fix finalization resolution with deep copy (cont) · 492ea356
      Tobias Burnus authored
      gcc/fortran/ChangeLog:
      
      	* resolve.c (gfc_resolve_finalizers): Remove
      	gfc_resolve_finalizers calls, use gfc_is_finalizable.
      	(resolve_fl_derived): Resolve derived-type components
      	first.
      
      gcc/testsuite/ChangeLog:
      
      	* gfortran.dg/abstract_type_6.f03: Remove dg-error as
      	now hidden by other errors; copy to ...
      	* gfortran.dg/abstract_type_6a.f03: ... here; remove
      	some error to diagnose the error.
      	* gfortran.dg/finalize_39.f90: New test.
      492ea356
  9. 25 Apr, 2022 1 commit
  10. 20 Apr, 2022 2 commits
    • Tobias Burnus's avatar
      OpenMP: Fix use_device_{addr,ptr} with in-data-sharing arg · 6cd57652
      Tobias Burnus authored
      For array-descriptor vars, the descriptor is assigned to a temporary. However,
      this failed when the clause's argument was in turn in a data-sharing clause
      as the outer context's VALUE_EXPR wasn't used.
      
      GCC 12/mainline patch submitted at:
      https://gcc.gnu.org/pipermail/gcc-patches/2022-April/593419.html
      
      gcc/ChangeLog:
      
              * omp-low.c (lower_omp_target): Fix use_device_{addr,ptr} with list
              item that is in an outer data-sharing clause.
      
      libgomp/ChangeLog:
      
              * testsuite/libgomp.fortran/use_device_addr-5.f90: New test.
      6cd57652
    • Andrew Stubbs's avatar
      openmp: unified_address support · f0bde8ab
      Andrew Stubbs authored
      This makes "requires unified_address" work by making it eqivalent to
      "requires unified_shared_memory".  This is more than is strictly necessary,
      but should be standard compliant.
      
      gcc/c/ChangeLog:
      
      	* c-parser.c (c_parser_omp_requires): Check requires unified_address
      	for conflict with -foffload-memory=shared.
      
      gcc/cp/ChangeLog:
      
      	* parser.c (cp_parser_omp_requires): Check requires unified_address
      	for conflict with -foffload-memory=shared.
      
      gcc/fortran/ChangeLog:
      
      	* openmp.c (gfc_match_omp_requires): Check requires unified_address
      	for conflict with -foffload-memory=shared.
      
      gcc/ChangeLog:
      
      	* omp-low.c: Do USM transformations for "unified_address".
      
      gcc/testsuite/ChangeLog:
      
      	* c-c++-common/gomp/usm-4.c: New test.
      	* gfortran.dg/gomp/usm-4.f90: New test.
      f0bde8ab
  11. 13 Apr, 2022 1 commit
    • Andrew Stubbs's avatar
      libgomp: autodetect page sizes in pinned memory tests · a82e01cd
      Andrew Stubbs authored
      There's not one number that works everywhere.
      This also fixes the failure mode on non-Linux hosts.
      
      libgomp/ChangeLog:
      
      	* testsuite/libgomp.c/alloc-pinned-1.c: Autodetect page size.
      	* testsuite/libgomp.c/alloc-pinned-2.c: Likewise.
      	* testsuite/libgomp.c/alloc-pinned-3.c: Likewise.
      	* testsuite/libgomp.c/alloc-pinned-4.c: Likewise.
      	* testsuite/libgomp.c/alloc-pinned-5.c: Likewise.
      	* testsuite/libgomp.c/alloc-pinned-6.c: Likewise.
      	* testsuite/libgomp.c/alloc-pinned-7.c: Clean up.
      a82e01cd
  12. 05 Apr, 2022 1 commit
    • Chung-Lin Tang's avatar
      OpenMP: Fix nested use_device_ptr · db43489e
      Chung-Lin Tang authored
      This patch fixes a bug in lower_omp_target, where for Fortran arrays,
      the expanded sender assignment is wrongly using the variable in the
      current ctx, instead of the one looked-up outside, which is causing
      use_device_ptr/addr to fail to work when used inside an omp-parallel
      (where the omp child_fn is split away from the original).
      
      The fix is inside omp-low.cc, though because the omp_array_data langhook
      is used only by Fortran, this is essentially Fortran-specific.
      
      2022-04-05  Chung-Lin Tang  <cltang@codesourcery.com>
      
      gcc/ChangeLog:
      
      	* omp-low.cc (lower_omp_target): Use outer context looked-up 'var' as
      	argument to lang_hooks.decls.omp_array_data, instead of 'ovar' from
      	current clause.
      
      libgomp/ChangeLog:
      
      	* testsuite/libgomp.fortran/use_device_ptr-4.f90: New testcase.
      
      (cherry picked from commit b0af8e3a)
      db43489e
  13. 02 Apr, 2022 1 commit
    • Andrew Stubbs's avatar
      openmp: Do USM transform for omp_target_alloc · da61dd84
      Andrew Stubbs authored
      OpenMP 5.0 says that omp_target_alloc should return USM addresses.
      
      gcc/ChangeLog:
      
      	* omp-low.c (usm_transform): Transform omp_target_alloc and
      	omp_target_free.
      
      libgomp/ChangeLog:
      
      	* testsuite/libgomp.c/usm-6.c: Add omp_target_alloc.
      
      gcc/testsuite/ChangeLog:
      
      	* c-c++-common/gomp/usm-2.c: Add omp_target_alloc.
      	* c-c++-common/gomp/usm-3.c: Add omp_target_alloc.
      da61dd84
  14. 01 Apr, 2022 1 commit
    • Hafiz Abid Qadeer's avatar
      Fix a crash due to mismatch of free and GOMP_alloc. · 2e50103f
      Hafiz Abid Qadeer authored
      With allocate directive, we replace the malloc calls to GOMP_alloc if
      it is associated with the allocate statement.  The memory was supposed
      to be free-d by the implicitely generated free calls which also get
      replaced.  But if user explicitely deallocated the memory using the
      deallocate statement, it can cause a mismatch.  This commit handles
      that case and also replaces the free call generated for deallocate
      clause.
      
      Also added deallocate in the testcase and tidied it up a bit.
      
      gcc/ChangeLog.omp:
      
      	* omp-low.c (lower_omp_allocate): Move allocate declaration
      	inside loop.  Set it to false at the end of condition.
      
      libgomp/ChangeLog.omp:
      	* testsuite/libgomp.fortran/allocate-2.f90: Remove commented lines.
      	Add deallocate.  Remove omp_atk_pool_size trait.
      2e50103f
  15. 30 Mar, 2022 1 commit
    • Andrew Stubbs's avatar
      openmp: BUILT_IN_GOMP_ENABLE_PINNED_MODE · fe9d2322
      Andrew Stubbs authored
      Rework the GOMP_enable_pinned_mode call so that it works on powerpc where
      the old way gave a local call.
      
      gcc/ChangeLog:
      
      	* omp-builtins.def (BUILT_IN_GOMP_ENABLE_PINNED_MODE): New.
      	* omp-low.c (omp_enable_pinned_mode): Use
      	BUILT_IN_GOMP_ENABLE_PINNED_MODE.
      fe9d2322
  16. 29 Mar, 2022 1 commit
    • Andrew Stubbs's avatar
      libgomp, nvptx: report USM supported · 87900a2d
      Andrew Stubbs authored
      libgomp/ChangeLog:
      
      	* plugin/plugin-nvptx.c (GOMP_OFFLOAD_supported_features): Allow
      	GOMP_REQUIRES_UNIFIED_ADDRESS and GOMP_REQUIRES_UNIFIED_SHARED_MEMORY.
      87900a2d
  17. 23 Mar, 2022 2 commits
    • Tobias Burnus's avatar
      LTO: Fixes for renaming issues with offload/OpenMP [PR104285] · d41e8d07
      Tobias Burnus authored
      gcc/lto/ChangeLog:
      
      	PR middle-end/104285
      	* lto-partition.c (maybe_rewrite_identifier): Use get_identifier
      	for the returned string to be usable as hash key.
      	(validize_symbol_for_target): Hence, use return value directly.
      	(privatize_symbol_name_1): Track maybe_rewrite_identifier renames.
      	* lto.c (offload_handle_link_vars): Move function up before ...
      	(do_whole_program_analysis): Call it after static renamings.
      	(lto_main): Move call after static renamings.
      
      libgomp/ChangeLog:
      
      	PR middle-end/104285
      	* testsuite/libgomp.c++/target-same-name-2-a.C: New test.
      	* testsuite/libgomp.c++/target-same-name-2-b.C: New test.
      	* testsuite/libgomp.c++/target-same-name-2.C: New test.
      	* testsuite/libgomp.c-c++-common/target-same-name-1-a.c: New test.
      	* testsuite/libgomp.c-c++-common/target-same-name-1-b.c: New test.
      	* testsuite/libgomp.c-c++-common/target-same-name-1.c: New test.
      
      (cherry picked from commit 1002a7ac)
      d41e8d07
    • Tobias Burnus's avatar
      OpenMP/C++: Permit mapping classes with virtual members [PR102204] · 1073e769
      Tobias Burnus authored
      	PR c++/102204
      gcc/cp/ChangeLog:
      
      	* decl2.c (cp_omp_mappable_type_1): Remove check for virtual
      	members as those are permitted since OpenMP 5.0.
      
      libgomp/ChangeLog:
      
      	* testsuite/libgomp.c++/target-virtual-1.C: New test.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/gomp/unmappable-1.C: Remove previously expected dg-message.
      
      (cherry picked from commit c22f3fb7)
      1073e769
  18. 11 Mar, 2022 9 commits
    • Andrew Stubbs's avatar
      openmp: -foffload-memory=pinned · 8ab67f22
      Andrew Stubbs authored
      Implement the -foffload-memory=pinned option such that libgomp is
      instructed to enable fully-pinned memory at start-up.  The option is
      intended to provide a performance boost to certain offload programs without
      modifying the code.
      
      This feature only works on Linux, at present, and simply calls mlockall to
      enable always-on memory pinning.  It requires that the ulimit feature is
      set high enough to accommodate all the program's memory usage.
      
      In this mode the ompx_pinned_memory_alloc feature is disabled as it is not
      needed and may conflict.
      
      Backport of the patch posted at
      https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591354.html
      
      gcc/ChangeLog:
      
      	* omp-low.c (omp_enable_pinned_mode): New function.
      	(execute_lower_omp): Call omp_enable_pinned_mode.
      
      libgomp/ChangeLog:
      
      	* config/linux/allocator.c (always_pinned_mode): New variable.
      	(GOMP_enable_pinned_mode): New function.
      	(linux_memspace_alloc): Disable pinning when always_pinned_mode set.
      	(linux_memspace_calloc): Likewise.
      	(linux_memspace_free): Likewise.
      	(linux_memspace_realloc): Likewise.
      	* libgomp.map (GOMP_5.1.1): New version space with
      	GOMP_enable_pinned_mode.
      	* testsuite/libgomp.c/alloc-pinned-7.c: New test.
      
      gcc/testsuite/ChangeLog:
      
      	* c-c++-common/gomp/alloc-pinned-1.c: New test.
      8ab67f22
    • Hafiz Abid Qadeer's avatar
      openmp: Use libgomp memory allocation functions with unified shared memory. · 37e77cae
      Hafiz Abid Qadeer authored
      This patches changes calls to malloc/free/calloc/realloc/aligned_alloc and
      operator new to memory allocation functions in libgomp with
      allocator=ompx_unified_shared_mem_alloc.  This helps existing code to benefit
      from the unified shared memory.  The libgomp does the correct thing with all
      the mapping constructs and there is no memory copies if the pointer is pointing
      to unified shared memory.
      
      We only replace replacable new operator and not the class member or placement new.
      
      Backport of a patch posted at
      https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591353.html
      
      gcc/ChangeLog:
      
      	* omp-low.c (usm_transform): New function.
      	(make_pass_usm_transform): Likewise.
      	(class pass_usm_transform): New.
      	* passes.def: Add pass_usm_transform.
      	* tree-pass.h (make_pass_usm_transform): New declaration.
      
      gcc/testsuite/ChangeLog:
      
      	* c-c++-common/gomp/usm-2.c: New test.
      	* c-c++-common/gomp/usm-3.c: New test.
      	* g++.dg/gomp/usm-1.C: New test.
      	* g++.dg/gomp/usm-2.C: New test.
      	* g++.dg/gomp/usm-3.C: New test.
      	* gfortran.dg/gomp/usm-2.f90: New test.
      	* gfortran.dg/gomp/usm-3.f90: New test.
      
      libgomp/ChangeLog:
      
      	* testsuite/libgomp.c/usm-6.c: New test.
      	* testsuite/libgomp.c++/usm-1.C: Likewise.
      37e77cae
    • Andrew Stubbs's avatar
      openmp, nvptx: ompx_unified_shared_mem_alloc · 3c40959d
      Andrew Stubbs authored
      This adds support for using Cuda Managed Memory with omp_alloc.  It will be
      used as the underpinnings for "requires unified_shared_memory" in a later
      patch.
      
      There are two new predefined allocators, ompx_unified_shared_mem_alloc and
      ompx_host_mem_alloc, plus corresponding memory spaces, which can be used to
      allocate memory in the "managed" space and explicitly on the host (it is
      intended that "malloc" will be intercepted by the compiler).
      
      The nvptx plugin is modified to make the necessary Cuda calls, and libgomp
      is modified to switch to shared-memory mode for USM allocated mappings.
      
      	Backport of the patch posted at
      	https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591352.html
      
      libgomp/ChangeLog:
      	* allocator.c (omp_max_predefined_alloc): Update.
      	(omp_aligned_alloc): Don't fallback ompx_host_mem_alloc.
      	(omp_aligned_calloc): Likewise.
      	(omp_realloc): Likewise.
      	* config/linux/allocator.c (linux_memspace_alloc): Handle USM.
      	(linux_memspace_calloc): Handle USM.
      	(linux_memspace_free): Handle USM.
      	(linux_memspace_realloc): Handle USM.
      	* config/nvptx/allocator.c (nvptx_memspace_alloc): Reject
      	ompx_host_mem_alloc.
      	(nvptx_memspace_calloc): Likewise.
      	(nvptx_memspace_realloc): Likewise.
      	* libgomp-plugin.h (GOMP_OFFLOAD_usm_alloc): New prototype.
      	(GOMP_OFFLOAD_usm_free): New prototype.
      	(GOMP_OFFLOAD_is_usm_ptr): New prototype.
      	* libgomp.h (gomp_usm_alloc): New prototype.
      	(gomp_usm_free): New prototype.
      	(gomp_is_usm_ptr): New prototype.
      	(struct gomp_device_descr): Add USM functions.
      	* omp.h.in (omp_memspace_handle_t): Add ompx_unified_shared_mem_space
      	and ompx_host_mem_space.
      	(omp_allocator_handle_t): Add ompx_unified_shared_mem_alloc and
      	ompx_host_mem_alloc.
      	* omp_lib.f90.in: Likewise.
      	* plugin/plugin-nvptx.c (nvptx_alloc): Add "usm" parameter.
      	Call cuMemAllocManaged as appropriate.
      	(GOMP_OFFLOAD_alloc): Move internals to ...
      	(GOMP_OFFLOAD_alloc_1): ... this, and add usm parameter.
      	(GOMP_OFFLOAD_usm_alloc): New function.
      	(GOMP_OFFLOAD_usm_free): New function.
      	(GOMP_OFFLOAD_is_usm_ptr): New function.
      	* target.c (gomp_map_vars_internal): Add USM support.
      	(gomp_usm_alloc): New function.
      	(gomp_usm_free): New function.
      	(gomp_load_plugin_for_device): New function.
      	* testsuite/libgomp.c/usm-1.c: New test.
      	* testsuite/libgomp.c/usm-2.c: New test.
      	* testsuite/libgomp.c/usm-3.c: New test.
      	* testsuite/libgomp.c/usm-4.c: New test.
      	* testsuite/libgomp.c/usm-5.c: New test.
      3c40959d
    • Andrew Stubbs's avatar
      openmp: allow requires unified_shared_memory · 8126f3f0
      Andrew Stubbs authored
      This is the front-end portion of the Unified Shared Memory implementation.
      It checks that -foffload-memory isn't set to an incompatible mode.
      
      Backport of the patch posted at
      https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591351.html
      
      gcc/c/ChangeLog:
      
      	* c-parser.c (c_parser_omp_requires): Check compatibility of
      	-foffload-memory option with requires directive.
      
      gcc/cp/ChangeLog:
      
      	* parser.c (cp_parser_omp_requires): Check compatibility of
      	-foffload-memory option with requires directive.
      
      gcc/fortran/ChangeLog:
      
      	* openmp.c (gfc_match_omp_requires): Check compatibility of
      	-foffload-memory option with requires directive.
      
      gcc/testsuite/ChangeLog:
      
      	* c-c++-common/gomp/usm-1.c: New test.
      	* gfortran.dg/gomp/usm-1.f90: New test.
      8126f3f0
    • Andrew Stubbs's avatar
      openmp: Add -foffload-memory · a17e41ca
      Andrew Stubbs authored
      Add a new option.  It will be used in follow-up patches.
      
      Backport of the patch posted at
      https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591350.html
      
      gcc/ChangeLog:
      
      	* common.opt: Add -foffload-memory and its enum values.
      	* coretypes.h (enum offload_memory): New.
      	* doc/invoke.texi: Document -foffload-memory.
      a17e41ca
    • Andrew Stubbs's avatar
      openmp, nvptx: low-lat memory access traits · ef3c1a66
      Andrew Stubbs authored
      The NVPTX low latency memory is not accessible outside the team that allocates
      it, and therefore should be unavailable for allocators with the access trait
      "all".  This change means that the omp_low_lat_mem_alloc predefined
      allocator now implicitly implies the "pteam" trait.
      
      	Backport of a patch posted at
      	https://gcc.gnu.org/pipermail/gcc-patches/2022-January/589355.html
      
      libgomp/ChangeLog:
      
      	* allocator.c (MEMSPACE_VALIDATE): New macro.
      	(omp_aligned_alloc): Use MEMSPACE_VALIDATE.
      	(omp_aligned_calloc): Likewise.
      	(omp_realloc): Likewise.
      	* config/nvptx/allocator.c (nvptx_memspace_validate): New function.
      	(MEMSPACE_VALIDATE): New macro.
      	* testsuite/libgomp.c/allocators-4.c (main): Add access trait.
      	* testsuite/libgomp.c/allocators-6.c (main): Add access trait.
      	* testsuite/libgomp.c/allocators-7.c: New test.
      ef3c1a66
    • Andrew Stubbs's avatar
      libgomp, openmp: Add ompx_pinned_mem_alloc · b4649663
      Andrew Stubbs authored
      This creates a new predefined allocator as a shortcut for using pinned
      memory with OpenMP.  The name uses the OpenMP extension space and is
      intended to be consistent with other OpenMP implementations currently in
      development.
      
      The allocator is equivalent to using a custom allocator with the pinned
      trait and the null fallback trait.
      
      	Backport of a patch posted at
      	https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588951.html
      
      	* allocator.c (omp_max_predefined_alloc): Update.
      	(omp_aligned_alloc): Support ompx_pinned_mem_alloc.
      	(omp_free): Likewise.
      	(omp_aligned_calloc): Likewise.
      	(omp_realloc): Likewise.
      	* omp.h.in (omp_allocator_handle_t): Add ompx_pinned_mem_alloc.
      	* omp_lib.f90.in: Add ompx_pinned_mem_alloc.
      	* testsuite/libgomp.c/alloc-pinned-5.c: New test.
      	* testsuite/libgomp.c/alloc-pinned-6.c: New test.
      	* testsuite/libgomp.fortran/alloc-pinned-1.f90: New test.
      b4649663
    • Andrew Stubbs's avatar
      libgomp: pinned memory · 4356385e
      Andrew Stubbs authored
      Implement the OpenMP pinned memory trait on Linux hosts using the mlock
      syscall.  Pinned allocations are performed using mmap, not malloc, to ensure
      that they can be unpinned safely when freed.
      
      	Backport of a patch posted at
      	https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588360.html
      
      libgomp/ChangeLog:
      	* allocator.c (MEMSPACE_ALLOC): Add PIN.
      	(MEMSPACE_CALLOC): Add PIN.
      	(MEMSPACE_REALLOC): Add PIN.
      	(MEMSPACE_FREE): Add PIN.
      	(xmlock): New function.
      	(omp_init_allocator): Don't disallow the pinned trait.
      	(omp_aligned_alloc): Add pinning to all MEMSPACE_* calls.
      	(omp_aligned_calloc): Likewise.
      	(omp_realloc): Likewise.
      	(omp_free): Likewise.
      	* config/linux/allocator.c: New file.
      	* config/nvptx/allocator.c (MEMSPACE_ALLOC): Add PIN.
      	(MEMSPACE_CALLOC): Add PIN.
      	(MEMSPACE_REALLOC): Add PIN.
      	(MEMSPACE_FREE): Add PIN.
      	* testsuite/libgomp.c/alloc-pinned-1.c: New test.
      	* testsuite/libgomp.c/alloc-pinned-2.c: New test.
      	* testsuite/libgomp.c/alloc-pinned-3.c: New test.
      	* testsuite/libgomp.c/alloc-pinned-4.c: New test.
      4356385e
    • Chung-Lin Tang's avatar
      openmp: Allow classes with static members to be mappable · 28ea857d
      Chung-Lin Tang authored
      In OpenMP 5.x, static members are supposed to be not a barrier for a class
      to be target-mapped. Remove the check for static members inside
      cp_omp_mappable_type_1, and adjusts a testcase.
      
      Merged from:
      https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591449.html
      
      gcc/cp/ChangeLog:
      
      	* decl2.cc (cp_omp_mappable_type_1): Remove requirement that all
      	members must be non-static; remove check for static fields.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/gomp/unmappable-1.C: Adjust testcase.
      28ea857d
  19. 10 Mar, 2022 5 commits
    • Hafiz Abid Qadeer's avatar
      Fix an ICE with allocate directive. · a03a0195
      Hafiz Abid Qadeer authored
      Add case for OMP_CLAUSE_ALLOCATOR in walk_tree_1.  This helps fix
      an ICE which occurs only on OG11 with allocate directive.
      
      Please note that this change is not needed on master.  The code
      there handles all clauses in the same way so a special case for
      OMP_CLAUSE_ALLOCATOR is not required.
      
      gcc/
      	* tree.c (walk_tree_1): Add case for OMP_CLAUSE_ALLOCATOR.
      a03a0195
    • Hafiz Abid Qadeer's avatar
      Lower allocate directive (OpenMP 5.0). · a58f7c30
      Hafiz Abid Qadeer authored
      Backport of a patch posted at
      https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588372.html
      
      This patch looks for malloc/free calls that were generated by allocate statement
      that is associated with allocate directive and replaces them with GOMP_alloc
      and GOMP_free.
      
      gcc/ChangeLog:
      
      	* omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE_ALLOCATOR.
      	(scan_omp_allocate): New.
      	(scan_omp_1_stmt): Call it.
      	(lower_omp_allocate): New function.
      	(lower_omp_1): Call it.
      
      gcc/testsuite/ChangeLog:
      
      	* gfortran.dg/gomp/allocate-6.f90: Add tests.
      
      libgomp/ChangeLog:
      
      	* testsuite/libgomp.fortran/allocate-2.f90: New test.
      	* gfortran.dg/gomp/allocate-7.f90: New test.
      	* gfortran.dg/gomp/allocate-8.f90: New test.
      a58f7c30
    • Hafiz Abid Qadeer's avatar
      Gimplify allocate directive (OpenMP 5.0). · 001f75fd
      Hafiz Abid Qadeer authored
      Backport of a patch posted at
      https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588371.html
      
      gcc/ChangeLog:
      
      	* doc/gimple.texi: Describe GIMPLE_OMP_ALLOCATE.
      	* gimple-pretty-print.c (dump_gimple_omp_allocate): New function.
      	(pp_gimple_stmt_1): Call it.
      	* gimple.c (gimple_build_omp_allocate): New function.
      	* gimple.def (GIMPLE_OMP_ALLOCATE): New node.
      	* gimple.h (enum gf_mask): Add GF_OMP_ALLOCATE_KIND_MASK,
      	GF_OMP_ALLOCATE_KIND_ALLOCATE and GF_OMP_ALLOCATE_KIND_FREE.
      	(struct gomp_allocate): New.
      	(is_a_helper <gomp_allocate *>::test): New.
      	(is_a_helper <const gomp_allocate *>::test): New.
      	(gimple_build_omp_allocate): Declare.
      	(gimple_omp_subcode): Replace GIMPLE_OMP_TEAMS with
      	GIMPLE_OMP_ALLOCATE.
      	(gimple_omp_allocate_set_clauses): New.
      	(gimple_omp_allocate_set_kind): Likewise.
      	(gimple_omp_allocate_clauses): Likewise.
      	(gimple_omp_allocate_kind): Likewise.
      	(CASE_GIMPLE_OMP): Add GIMPLE_OMP_ALLOCATE.
      	* gimplify.c (gimplify_omp_allocate): New.
      	(gimplify_expr): Call it.
      	* gsstruct.def (GSS_OMP_ALLOCATE): Define.
      
      gcc/testsuite/ChangeLog:
      
      	* gfortran.dg/gomp/allocate-6.f90: Add tests.
      001f75fd
    • Hafiz Abid Qadeer's avatar
      Handle cleanup of omp allocated variables (OpenMP 5.0). · d245b65b
      Hafiz Abid Qadeer authored
      Currently we are only handling omp allocate directive that is associated
      with an allocate statement.  This statement results in malloc and free calls.
      The malloc calls are easy to get to as they are in the same block as allocate
      directive.  But the free calls come in a separate cleanup block.  To help any
      later passes finding them, an allocate directive is generated in the
      cleanup block with kind=free. The normal allocate directive is given
      kind=allocate.
      
      Backport of a patch posted at
      https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588370.html
      
      gcc/fortran/ChangeLog:
      
      	* gfortran.h (struct access_ref): Declare new members
      	omp_allocated and omp_allocated_end.
      	* openmp.c (gfc_match_omp_allocate): Set new_st.resolved_sym to
      	NULL.
      	(prepare_omp_allocated_var_list_for_cleanup): New function.
      	(gfc_resolve_omp_allocate): Call it.
      	* trans-decl.c (gfc_trans_deferred_vars): Process omp_allocated.
      	* trans-openmp.c (gfc_trans_omp_allocate): Set kind for the stmt
      	generated for allocate directive.
      
      gcc/ChangeLog:
      
      	* tree-core.h (struct tree_base): Add comments.
      	* tree-pretty-print.c (dump_generic_node): Handle allocate directive
      	kind.
      	* tree.h (OMP_ALLOCATE_KIND_ALLOCATE): New define.
      	(OMP_ALLOCATE_KIND_FREE): Likewise.
      
      gcc/testsuite/ChangeLog:
      
      	* gfortran.dg/gomp/allocate-6.f90: Test kind of allocate directive.
      d245b65b
    • Hafiz Abid Qadeer's avatar
      Translate allocate directive (OpenMP 5.0). · 7a8f9f47
      Hafiz Abid Qadeer authored
      Backport of a patch posted at
      https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588369.html
      
      gcc/fortran/ChangeLog:
      
      	* trans-openmp.c (gfc_trans_omp_clauses): Handle OMP_LIST_ALLOCATOR.
      	(gfc_trans_omp_allocate): New function.
      	(gfc_trans_omp_directive): Handle EXEC_OMP_ALLOCATE.
      
      gcc/ChangeLog:
      
      	* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_ALLOCATOR.
      	(dump_generic_node): Handle OMP_ALLOCATE.
      	* tree.def (OMP_ALLOCATE): New.
      	* tree.h (OMP_ALLOCATE_CLAUSES): Likewise.
      	(OMP_ALLOCATE_DECL): Likewise.
      	(OMP_ALLOCATE_ALLOCATOR): Likewise.
      	* tree.c (omp_clause_num_ops): Add entry for OMP_CLAUSE_ALLOCATOR.
      
      gcc/testsuite/ChangeLog:
      
      	* gfortran.dg/gomp/allocate-6.f90: New test.
      7a8f9f47