public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch] libgomp: Add tests for omp_atv_serialized and deprecate omp_atv_sequential.
@ 2021-10-11  9:40 Marcel Vollweiler
  2021-10-11  9:49 ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Marcel Vollweiler @ 2021-10-11  9:40 UTC (permalink / raw)
  To: gcc-patches, fortran; +Cc: Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 840 bytes --]

Hi,

The variable omp_atv_sequential was replaced by omp_atv_serialized in
OpenMP 5.1. This was already implemented by Jakub (C/C++, commit
ea82325afec) and Tobias (Fortran, commit fff15bad1ab).

This patch adds two tests to check if omp_atv_serialized is available
(one test for C/C++ and one for Fortran). Besides that
omp_atv_sequential is marked as deprecated in C/C++ and Fortran for
OpenMP 5.1.

The patch was tested on x86_64-linux and powerpc64le-linux with nvptx
offloading and on x86_64-linux with amdgcn offloading with no regressions.

Marcel
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Attachment #2: omp-atv-serialized-patch.diff --]
[-- Type: text/plain, Size: 4019 bytes --]

libgomp: Add tests for omp_atv_serialized and deprecate omp_atv_sequential.

The variable omp_atv_sequential was replaced by omp_atv_serialized in OpenMP
5.1. This was already implemented by Jakub (C/C++, commit ea82325afec) and
Tobias (Fortran, commit fff15bad1ab).

This patch adds two tests to check if omp_atv_serialized is available (one test
for C/C++ and one for Fortran). Besides that omp_atv_sequential is marked as
deprecated in C/C++ and Fortran for OpenMP 5.1.

libgomp/ChangeLog:

	* allocator.c (omp_init_allocator): Replace omp_atv_sequential with
	omp_atv_serialized.
	* omp.h.in: Add deprecated flag for omp_atv_sequential.
	* omp_lib.f90.in: Add deprecated flag for omp_atv_sequential.
	* testsuite/libgomp.c-c++-common/alloc-10.c: New test.
	* testsuite/libgomp.fortran/alloc-12.f90: New test.

diff --git a/libgomp/allocator.c b/libgomp/allocator.c
index dce600f..deebb6a 100644
--- a/libgomp/allocator.c
+++ b/libgomp/allocator.c
@@ -82,7 +82,7 @@ omp_init_allocator (omp_memspace_handle_t memspace, int ntraits,
 	    break;
 	  case omp_atv_contended:
 	  case omp_atv_uncontended:
-	  case omp_atv_sequential:
+	  case omp_atv_serialized:
 	  case omp_atv_private:
 	    data.sync_hint = traits[i].value;
 	    break;
diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in
index d75ee13..e57e192 100644
--- a/libgomp/omp.h.in
+++ b/libgomp/omp.h.in
@@ -157,7 +157,7 @@ typedef enum omp_alloctrait_value_t
   omp_atv_contended = 3,
   omp_atv_uncontended = 4,
   omp_atv_serialized = 5,
-  omp_atv_sequential = omp_atv_serialized,
+  omp_atv_sequential __GOMP_DEPRECATED_5_1 = omp_atv_serialized,
   omp_atv_private = 6,
   omp_atv_all = 7,
   omp_atv_thread = 8,
diff --git a/libgomp/omp_lib.f90.in b/libgomp/omp_lib.f90.in
index 1063eee..57766b5 100644
--- a/libgomp/omp_lib.f90.in
+++ b/libgomp/omp_lib.f90.in
@@ -810,7 +810,7 @@
 #endif
 
 #if _OPENMP >= 202011
-!GCC$ ATTRIBUTES DEPRECATED :: omp_proc_bind_master
+!GCC$ ATTRIBUTES DEPRECATED :: omp_proc_bind_master, omp_atv_sequential
 #endif
 
       end module omp_lib
diff --git a/libgomp/testsuite/libgomp.c-c++-common/alloc-10.c b/libgomp/testsuite/libgomp.c-c++-common/alloc-10.c
new file mode 100644
index 0000000..742c64a
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/alloc-10.c
@@ -0,0 +1,25 @@
+#include <omp.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+const omp_alloctrait_t traits[]
+= { { omp_atk_alignment, 64 },
+    { omp_atk_sync_hint, omp_atv_serialized },
+    { omp_atk_fallback, omp_atv_null_fb } };
+
+int
+main ()
+{
+  omp_allocator_handle_t a;
+  int *volatile p;
+  a = omp_init_allocator (omp_default_mem_space, 3, traits);
+  if (a == omp_null_allocator)
+    abort ();
+  p = (int *) omp_alloc (3072, a);
+  if ((((uintptr_t) p) % 64) != 0)
+    abort ();
+  p[0] = 1;
+  p[3071 / sizeof (int)] = 2;
+  omp_free (p, a);
+  omp_destroy_allocator (a);
+}
\ No newline at end of file
diff --git a/libgomp/testsuite/libgomp.fortran/alloc-12.f90 b/libgomp/testsuite/libgomp.fortran/alloc-12.f90
new file mode 100644
index 0000000..3d10959
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/alloc-12.f90
@@ -0,0 +1,28 @@
+! { dg-additional-options "-Wall -Wextra" }
+program main
+  use omp_lib
+  use ISO_C_Binding
+  implicit none (external, type)
+  type(c_ptr) :: p
+  integer, pointer, contiguous :: ip(:)
+  type (omp_alloctrait) :: traits(3)
+  integer (omp_allocator_handle_kind) :: a
+  integer (c_ptrdiff_t) :: iptr
+
+  traits = [omp_alloctrait (omp_atk_alignment, 64), &
+            omp_alloctrait (omp_atk_fallback, omp_atv_null_fb), &
+            omp_alloctrait (omp_atk_sync_hint, omp_atv_serialized)]
+  a = omp_init_allocator (omp_default_mem_space, 3, traits)
+  if (a == omp_null_allocator) stop 1
+
+  p = omp_alloc (3 * c_sizeof (0), a)
+  if (.not. c_associated (p)) stop 2
+  call c_f_pointer (p, ip, [3])
+  if (mod (TRANSFER (p, iptr), 64) /= 0) &
+    stop 3
+  ip(1) = 1
+  ip(2) = 2
+  ip(3) = 3
+  call omp_free (p, a)
+  call omp_destroy_allocator (a)
+end program main

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch] libgomp: Add tests for omp_atv_serialized and deprecate omp_atv_sequential.
  2021-10-11  9:40 [Patch] libgomp: Add tests for omp_atv_serialized and deprecate omp_atv_sequential Marcel Vollweiler
@ 2021-10-11  9:49 ` Jakub Jelinek
  2021-10-11 11:28   ` Marcel Vollweiler
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2021-10-11  9:49 UTC (permalink / raw)
  To: Marcel Vollweiler; +Cc: gcc-patches, fortran

On Mon, Oct 11, 2021 at 11:40:54AM +0200, Marcel Vollweiler wrote:
> libgomp: Add tests for omp_atv_serialized and deprecate omp_atv_sequential.
> 
> The variable omp_atv_sequential was replaced by omp_atv_serialized in OpenMP
> 5.1. This was already implemented by Jakub (C/C++, commit ea82325afec) and
> Tobias (Fortran, commit fff15bad1ab).
> 
> This patch adds two tests to check if omp_atv_serialized is available (one test
> for C/C++ and one for Fortran). Besides that omp_atv_sequential is marked as
> deprecated in C/C++ and Fortran for OpenMP 5.1.
> 
> libgomp/ChangeLog:
> 
> 	* allocator.c (omp_init_allocator): Replace omp_atv_sequential with
> 	omp_atv_serialized.
> 	* omp.h.in: Add deprecated flag for omp_atv_sequential.
> 	* omp_lib.f90.in: Add deprecated flag for omp_atv_sequential.
> 	* testsuite/libgomp.c-c++-common/alloc-10.c: New test.
> 	* testsuite/libgomp.fortran/alloc-12.f90: New test.

LGTM, except one nit.

> --- /dev/null
> +++ b/libgomp/testsuite/libgomp.c-c++-common/alloc-10.c
> +}
> \ No newline at end of file

Please make sure the file ends with a newline before committing.

	Jakub


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch] libgomp: Add tests for omp_atv_serialized and deprecate omp_atv_sequential.
  2021-10-11  9:49 ` Jakub Jelinek
@ 2021-10-11 11:28   ` Marcel Vollweiler
  2021-10-11 11:30     ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Marcel Vollweiler @ 2021-10-11 11:28 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, fortran

[-- Attachment #1: Type: text/plain, Size: 1580 bytes --]

Hi Jakub,

Am 11.10.2021 um 11:49 schrieb Jakub Jelinek:
> On Mon, Oct 11, 2021 at 11:40:54AM +0200, Marcel Vollweiler wrote:
>> libgomp: Add tests for omp_atv_serialized and deprecate omp_atv_sequential.
>>
>> The variable omp_atv_sequential was replaced by omp_atv_serialized in OpenMP
>> 5.1. This was already implemented by Jakub (C/C++, commit ea82325afec) and
>> Tobias (Fortran, commit fff15bad1ab).
>>
>> This patch adds two tests to check if omp_atv_serialized is available (one test
>> for C/C++ and one for Fortran). Besides that omp_atv_sequential is marked as
>> deprecated in C/C++ and Fortran for OpenMP 5.1.
>>
>> libgomp/ChangeLog:
>>
>>      * allocator.c (omp_init_allocator): Replace omp_atv_sequential with
>>      omp_atv_serialized.
>>      * omp.h.in: Add deprecated flag for omp_atv_sequential.
>>      * omp_lib.f90.in: Add deprecated flag for omp_atv_sequential.
>>      * testsuite/libgomp.c-c++-common/alloc-10.c: New test.
>>      * testsuite/libgomp.fortran/alloc-12.f90: New test.
>
> LGTM, except one nit.
>
>> --- /dev/null
>> +++ b/libgomp/testsuite/libgomp.c-c++-common/alloc-10.c
>> +}
>> \ No newline at end of file
>
> Please make sure the file ends with a newline before committing.

Changed :)

>
>       Jakub
>

Thanks,
Marcel
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Attachment #2: omp-atv-serialized-patch.diff --]
[-- Type: text/plain, Size: 3992 bytes --]

libgomp: Add tests for omp_atv_serialized and deprecate omp_atv_sequential.

The variable omp_atv_sequential was replaced by omp_atv_serialized in OpenMP
5.1. This was already implemented by Jakub (C/C++, commit ea82325afec) and
Tobias (Fortran, commit fff15bad1ab).

This patch adds two tests to check if omp_atv_serialized is available (one test
for C/C++ and one for Fortran). Besides that omp_atv_sequential is marked as
deprecated in C/C++ and Fortran for OpenMP 5.1.

libgomp/ChangeLog:

	* allocator.c (omp_init_allocator): Replace omp_atv_sequential with
	omp_atv_serialized.
	* omp.h.in: Add deprecated flag for omp_atv_sequential.
	* omp_lib.f90.in: Add deprecated flag for omp_atv_sequential.
	* testsuite/libgomp.c-c++-common/alloc-10.c: New test.
	* testsuite/libgomp.fortran/alloc-12.f90: New test.

diff --git a/libgomp/allocator.c b/libgomp/allocator.c
index dce600f..deebb6a 100644
--- a/libgomp/allocator.c
+++ b/libgomp/allocator.c
@@ -82,7 +82,7 @@ omp_init_allocator (omp_memspace_handle_t memspace, int ntraits,
 	    break;
 	  case omp_atv_contended:
 	  case omp_atv_uncontended:
-	  case omp_atv_sequential:
+	  case omp_atv_serialized:
 	  case omp_atv_private:
 	    data.sync_hint = traits[i].value;
 	    break;
diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in
index d75ee13..e57e192 100644
--- a/libgomp/omp.h.in
+++ b/libgomp/omp.h.in
@@ -157,7 +157,7 @@ typedef enum omp_alloctrait_value_t
   omp_atv_contended = 3,
   omp_atv_uncontended = 4,
   omp_atv_serialized = 5,
-  omp_atv_sequential = omp_atv_serialized,
+  omp_atv_sequential __GOMP_DEPRECATED_5_1 = omp_atv_serialized,
   omp_atv_private = 6,
   omp_atv_all = 7,
   omp_atv_thread = 8,
diff --git a/libgomp/omp_lib.f90.in b/libgomp/omp_lib.f90.in
index 1063eee..57766b5 100644
--- a/libgomp/omp_lib.f90.in
+++ b/libgomp/omp_lib.f90.in
@@ -810,7 +810,7 @@
 #endif
 
 #if _OPENMP >= 202011
-!GCC$ ATTRIBUTES DEPRECATED :: omp_proc_bind_master
+!GCC$ ATTRIBUTES DEPRECATED :: omp_proc_bind_master, omp_atv_sequential
 #endif
 
       end module omp_lib
diff --git a/libgomp/testsuite/libgomp.c-c++-common/alloc-10.c b/libgomp/testsuite/libgomp.c-c++-common/alloc-10.c
new file mode 100644
index 0000000..01ae150d
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/alloc-10.c
@@ -0,0 +1,25 @@
+#include <omp.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+const omp_alloctrait_t traits[]
+= { { omp_atk_alignment, 64 },
+    { omp_atk_sync_hint, omp_atv_serialized },
+    { omp_atk_fallback, omp_atv_null_fb } };
+
+int
+main ()
+{
+  omp_allocator_handle_t a;
+  int *volatile p;
+  a = omp_init_allocator (omp_default_mem_space, 3, traits);
+  if (a == omp_null_allocator)
+    abort ();
+  p = (int *) omp_alloc (3072, a);
+  if ((((uintptr_t) p) % 64) != 0)
+    abort ();
+  p[0] = 1;
+  p[3071 / sizeof (int)] = 2;
+  omp_free (p, a);
+  omp_destroy_allocator (a);
+}
diff --git a/libgomp/testsuite/libgomp.fortran/alloc-12.f90 b/libgomp/testsuite/libgomp.fortran/alloc-12.f90
new file mode 100644
index 0000000..3d10959
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/alloc-12.f90
@@ -0,0 +1,28 @@
+! { dg-additional-options "-Wall -Wextra" }
+program main
+  use omp_lib
+  use ISO_C_Binding
+  implicit none (external, type)
+  type(c_ptr) :: p
+  integer, pointer, contiguous :: ip(:)
+  type (omp_alloctrait) :: traits(3)
+  integer (omp_allocator_handle_kind) :: a
+  integer (c_ptrdiff_t) :: iptr
+
+  traits = [omp_alloctrait (omp_atk_alignment, 64), &
+            omp_alloctrait (omp_atk_fallback, omp_atv_null_fb), &
+            omp_alloctrait (omp_atk_sync_hint, omp_atv_serialized)]
+  a = omp_init_allocator (omp_default_mem_space, 3, traits)
+  if (a == omp_null_allocator) stop 1
+
+  p = omp_alloc (3 * c_sizeof (0), a)
+  if (.not. c_associated (p)) stop 2
+  call c_f_pointer (p, ip, [3])
+  if (mod (TRANSFER (p, iptr), 64) /= 0) &
+    stop 3
+  ip(1) = 1
+  ip(2) = 2
+  ip(3) = 3
+  call omp_free (p, a)
+  call omp_destroy_allocator (a)
+end program main

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch] libgomp: Add tests for omp_atv_serialized and deprecate omp_atv_sequential.
  2021-10-11 11:28   ` Marcel Vollweiler
@ 2021-10-11 11:30     ` Jakub Jelinek
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2021-10-11 11:30 UTC (permalink / raw)
  To: Marcel Vollweiler; +Cc: gcc-patches, fortran

On Mon, Oct 11, 2021 at 01:28:11PM +0200, Marcel Vollweiler wrote:
> > > libgomp/ChangeLog:
> > > 
> > >      * allocator.c (omp_init_allocator): Replace omp_atv_sequential with
> > >      omp_atv_serialized.
> > >      * omp.h.in: Add deprecated flag for omp_atv_sequential.
> > >      * omp_lib.f90.in: Add deprecated flag for omp_atv_sequential.
> > >      * testsuite/libgomp.c-c++-common/alloc-10.c: New test.
> > >      * testsuite/libgomp.fortran/alloc-12.f90: New test.
> > 
> > LGTM, except one nit.
> > 
> > > --- /dev/null
> > > +++ b/libgomp/testsuite/libgomp.c-c++-common/alloc-10.c
> > > +}
> > > \ No newline at end of file
> > 
> > Please make sure the file ends with a newline before committing.
> 
> Changed :)

Thanks, just commit it, the above was meant as "please commit
with this nit fixed", I'm sorry if it wasn't obvious.

	Jakub


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-11 11:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11  9:40 [Patch] libgomp: Add tests for omp_atv_serialized and deprecate omp_atv_sequential Marcel Vollweiler
2021-10-11  9:49 ` Jakub Jelinek
2021-10-11 11:28   ` Marcel Vollweiler
2021-10-11 11:30     ` Jakub Jelinek

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).