public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Hafiz Abid Qadeer <abidh@codesourcery.com>
Cc: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org, tobias@codesourcery.com
Subject: Re: [PATCH 2/5] [gfortran] Translate allocate directive (OpenMP 5.0).
Date: Tue, 11 Oct 2022 14:24:49 +0200	[thread overview]
Message-ID: <Y0VgkazD/Onwv8q8@tucnak> (raw)
In-Reply-To: <20220113145320.3153087-3-abidh@codesourcery.com>

On Thu, Jan 13, 2022 at 02:53:17PM +0000, Hafiz Abid Qadeer wrote:
> 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.

There is another issue besides what I wrote in my last review,
and I'm afraid I don't know what to do about it, hoping Tobias
has some ideas.
The problem is that without the allocate-stmt associated allocate directive,
Fortran allocatables are easily always allocated with malloc and freed with
free.  The deallocation can be implicit through reallocation, or explicit
deallocate statement etc.
But when some allocatables are now allocated with a different
allocator (when allocate-stmt associated allocate directive is used),
some allocatables are allocated with malloc and others with GOMP_alloc
but we need to free them with the corresponding allocator based on how
they were allocated, what has been allocated with malloc should be
deallocated with free, what has been allocated with GOMP_alloc should be
deallocated with GOMP_free.
The deallocation can be done in a completely different TU from where it has
been allocated, in theory it could be also not compiled with -fopenmp, etc.
So, I'm afraid we need to store somewhere whether we used malloc or
GOMP_alloc for the allocation (say somewhere in the array descriptor and for
other stuff somewhere on the side?) and slow down all code that needs
deallocation to check that bit (or say we don't support
deallocation/reallocation of OpenMP allocated allocatables without -fopenmp
on the deallocation TU and only slow down -fopenmp compiled code)?

Tobias, thoughts on this?

	Jakub


  reply	other threads:[~2022-10-11 12:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13 14:53 [PATCH 0/5] [gfortran] Support for " Hafiz Abid Qadeer
2022-01-13 14:53 ` [PATCH 1/5] [gfortran] Add parsing support " Hafiz Abid Qadeer
2022-10-11 12:13   ` Jakub Jelinek
2023-02-01 11:59   ` [og12] Fix 'omp_allocator_handle_kind' example in 'gfortran.dg/gomp/allocate-4.f90' (was: [PATCH 1/5] [gfortran] Add parsing support for allocate directive (OpenMP 5.0).) Thomas Schwinge
2023-02-01 12:12     ` Tobias Burnus
2023-02-09 11:35   ` [og12] 'gfortran.dg/gomp/allocate-4.f90' -> 'libgomp.fortran/allocate-5.f90' (was: [PATCH 1/5] [gfortran] Add parsing support for allocate directive (OpenMP 5.0)) Thomas Schwinge
2022-01-13 14:53 ` [PATCH 2/5] [gfortran] Translate allocate directive (OpenMP 5.0) Hafiz Abid Qadeer
2022-10-11 12:24   ` Jakub Jelinek [this message]
2022-10-11 13:22     ` Tobias Burnus
2022-10-11 14:15       ` Jakub Jelinek
2022-10-11 14:27         ` Jakub Jelinek
2022-10-11 14:38         ` Tobias Burnus
2022-01-13 14:53 ` [PATCH 3/5] [gfortran] Handle cleanup of omp allocated variables " Hafiz Abid Qadeer
2022-01-13 14:53 ` [PATCH 4/5] [gfortran] Gimplify allocate directive " Hafiz Abid Qadeer
2022-01-13 14:53 ` [PATCH 5/5] [gfortran] Lower " Hafiz Abid Qadeer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y0VgkazD/Onwv8q8@tucnak \
    --to=jakub@redhat.com \
    --cc=abidh@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tobias@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).