On 28/10/2020 4:06 pm, Jakub Jelinek wrote:
On Wed, Oct 28, 2020 at 03:41:25PM +0000, Kwok Cheung Yeung wrote:
What if we made the definition of __GOMP_DEPRECATED in the original patch
conditional on the current value of __OPENMP__? i.e. Something like:
+#if defined(__GNUC__) && __OPENMP__ >= 201811L
+# define __GOMP_DEPRECATED __attribute__((__deprecated__))
+#else
+# define __GOMP_DEPRECATED
+#endif
In that case, __GOMP_DEPRECATED will not do anything until __OPENMP__ is
updated to reflect OpenMP 5.0, but when it is, the functions will
immediately be marked deprecated without any further work.
That could work, but the macro name would need to incorporate the exact
OpenMP version.
Because some APIs can be deprecated in OpenMP 5.0, others in 5.1 or in 5.2
(all to be removed in 6.0), others in 6.0/6.1 etc. to be removed in 7.0 etc.
I've renamed __GOMP_DEPRECATED to __GOMP_DEPRECATED_5_0.
However, GFortran does not support the deprecated attribute, so how should
it behave? My first thought would be to print out a warning message at
runtime the first time a deprecated function is called (printing it out
every time would probably be too annoying), and maybe add an environment
variable that can be set to disable the warning. A similar runtime warning
could also be printed if the OMP_NESTED environment variable is set. Again,
printing these warnings could be surpressed until the value of __OPENMP__ is
bumped up.
I'm against such runtime diagnostics, that is perhaps good for some
sanitization, but not normal usage. Perhaps better implement deprecated
attribute in gfortran?
I have used Tobias' recently added patch for Fortran deprecation support to mark
omp_get_nested and omp_set_nested as deprecated. If the omp_lock_hint_* integer
parameters are marked though, then the deprecation warnings will fire the moment
omp_lib is used from a Fortran program, even if they are not referenced in the
progam itself - a bug perhaps?
I have added '-cpp' (for preprocessor support) and '-fopenmp' (for the _OPENMP
define) to the Makefile when compiling the omp_lib.f90.
Would a warning message be acceptable if OMP_NESTED is used? Obviously this
cannot be done at compile-time.
Is this patch okay for trunk? We could add the deprecations for omp_lock_hint_*
later when the deprecations for parameters are fixed. I have checked that it
bootstraps on x86_64.
Kwok
From 6e8fc46bdcaf44da11d46968cccca488fdd990ae Mon Sep 17 00:00:00 2001
From: Kwok Cheung Yeung <k...@codesourcery.com>
Date: Wed, 4 Nov 2020 03:59:44 -0800
Subject: [PATCH] openmp: Mark deprecated symbols in OpenMP 5.0
2020-11-04 Ulrich Drepper <drep...@redhat.com>
Kwok Cheung Yeung <k...@codesourcery.com>
libgomp/
* Makefile.am (%.mod): Add -cpp and -fopenmp to compile flags.
* Makefile.in: Regenerate.
* fortran.c: Wrap uses of omp_set_nested and omp_get_nested with
pragmas to ignore -Wdeprecated-declarations warnings.
* icv.c: Likewise.
* omp.h.in (__GOMP_DEPRECATED_5_0): Define.
Mark omp_lock_hint_* enum values, omp_lock_hint_t, omp_set_nested,
and omp_get_nested with __GOMP_DEPRECATED_5_0.
* omp_lib.f90.in: Mark omp_get_nested and omp_set_nested as
deprecated.
---
libgomp/Makefile.am | 2 +-
libgomp/Makefile.in | 2 +-
libgomp/fortran.c | 13 +++++++++++--
libgomp/icv.c | 10 ++++++++--
libgomp/omp.h.in | 22 ++++++++++++++--------
libgomp/omp_lib.f90.in | 4 ++++
6 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am
index 586c930..4cf1f58 100644
--- a/libgomp/Makefile.am
+++ b/libgomp/Makefile.am
@@ -92,7 +92,7 @@ openacc_kinds.mod: openacc.mod
openacc.mod: openacc.lo
:
%.mod: %.f90
- $(FC) $(FCFLAGS) -fsyntax-only $<
+ $(FC) $(FCFLAGS) -cpp -fopenmp -fsyntax-only $<
fortran.lo: libgomp_f.h
fortran.o: libgomp_f.h
env.lo: libgomp_f.h
diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 00d5e29..eb868b3 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -1382,7 +1382,7 @@ openacc_kinds.mod: openacc.mod
openacc.mod: openacc.lo
:
%.mod: %.f90
- $(FC) $(FCFLAGS) -fsyntax-only $<
+ $(FC) $(FCFLAGS) -cpp -fopenmp -fsyntax-only $<
fortran.lo: libgomp_f.h
fortran.o: libgomp_f.h
env.lo: libgomp_f.h
diff --git a/libgomp/fortran.c b/libgomp/fortran.c
index 029dec1..cd719f9 100644
--- a/libgomp/fortran.c
+++ b/libgomp/fortran.c
@@ -47,10 +47,13 @@ ialias_redirect (omp_test_lock)
ialias_redirect (omp_test_nest_lock)
# endif
ialias_redirect (omp_set_dynamic)
-ialias_redirect (omp_set_nested)
-ialias_redirect (omp_set_num_threads)
ialias_redirect (omp_get_dynamic)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ialias_redirect (omp_set_nested)
ialias_redirect (omp_get_nested)
+#pragma GCC diagnostic pop
+ialias_redirect (omp_set_num_threads)
ialias_redirect (omp_in_parallel)
ialias_redirect (omp_get_max_threads)
ialias_redirect (omp_get_num_procs)
@@ -281,6 +284,8 @@ omp_set_dynamic_8_ (const int64_t *set)
omp_set_dynamic (!!*set);
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
void
omp_set_nested_ (const int32_t *set)
{
@@ -292,6 +297,7 @@ omp_set_nested_8_ (const int64_t *set)
{
omp_set_nested (!!*set);
}
+#pragma GCC diagnostic pop
void
omp_set_num_threads_ (const int32_t *set)
@@ -311,11 +317,14 @@ omp_get_dynamic_ (void)
return omp_get_dynamic ();
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
int32_t
omp_get_nested_ (void)
{
return omp_get_nested ();
}
+#pragma GCC diagnostic pop
int32_t
omp_in_parallel_ (void)
diff --git a/libgomp/icv.c b/libgomp/icv.c
index 4da6527..8df15e3 100644
--- a/libgomp/icv.c
+++ b/libgomp/icv.c
@@ -51,6 +51,8 @@ omp_get_dynamic (void)
return icv->dyn_var;
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
void
omp_set_nested (int val)
{
@@ -64,6 +66,7 @@ omp_get_nested (void)
struct gomp_task_icv *icv = gomp_icv (false);
return icv->nest_var;
}
+#pragma GCC diagnostic pop
void
omp_set_schedule (omp_sched_t kind, int chunk_size)
@@ -222,10 +225,13 @@ omp_get_default_allocator (void)
}
ialias (omp_set_dynamic)
-ialias (omp_set_nested)
-ialias (omp_set_num_threads)
ialias (omp_get_dynamic)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ialias (omp_set_nested)
ialias (omp_get_nested)
+#pragma GCC diagnostic pop
+ialias (omp_set_num_threads)
ialias (omp_set_schedule)
ialias (omp_get_schedule)
ialias (omp_get_max_threads)
diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in
index a9e6c44..f6accf2 100644
--- a/libgomp/omp.h.in
+++ b/libgomp/omp.h.in
@@ -26,6 +26,12 @@
#ifndef _OMP_H
#define _OMP_H 1
+#if defined(__GNUC__) && _OPENMP >= 201811
+# define __GOMP_DEPRECATED_5_0 __attribute__((__deprecated__))
+#else
+# define __GOMP_DEPRECATED_5_0
+#endif
+
#ifndef _LIBGOMP_OMP_LOCK_DEFINED
#define _LIBGOMP_OMP_LOCK_DEFINED 1
/* These two structures get edited by the libgomp build process to
@@ -66,18 +72,18 @@ typedef enum omp_proc_bind_t
typedef enum omp_sync_hint_t
{
omp_sync_hint_none = 0,
- omp_lock_hint_none = omp_sync_hint_none,
+ omp_lock_hint_none __GOMP_DEPRECATED_5_0 = omp_sync_hint_none,
omp_sync_hint_uncontended = 1,
- omp_lock_hint_uncontended = omp_sync_hint_uncontended,
+ omp_lock_hint_uncontended __GOMP_DEPRECATED_5_0 = omp_sync_hint_uncontended,
omp_sync_hint_contended = 2,
- omp_lock_hint_contended = omp_sync_hint_contended,
+ omp_lock_hint_contended __GOMP_DEPRECATED_5_0 = omp_sync_hint_contended,
omp_sync_hint_nonspeculative = 4,
- omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative,
+ omp_lock_hint_nonspeculative __GOMP_DEPRECATED_5_0 =
omp_sync_hint_nonspeculative,
omp_sync_hint_speculative = 8,
- omp_lock_hint_speculative = omp_sync_hint_speculative
+ omp_lock_hint_speculative __GOMP_DEPRECATED_5_0 = omp_sync_hint_speculative
} omp_sync_hint_t;
-typedef omp_sync_hint_t omp_lock_hint_t;
+typedef __GOMP_DEPRECATED_5_0 omp_sync_hint_t omp_lock_hint_t;
typedef struct __attribute__((__aligned__ (sizeof (void *)))) omp_depend_t
{
@@ -184,8 +190,8 @@ extern int omp_in_parallel (void) __GOMP_NOTHROW;
extern void omp_set_dynamic (int) __GOMP_NOTHROW;
extern int omp_get_dynamic (void) __GOMP_NOTHROW;
-extern void omp_set_nested (int) __GOMP_NOTHROW;
-extern int omp_get_nested (void) __GOMP_NOTHROW;
+extern void omp_set_nested (int) __GOMP_DEPRECATED_5_0 __GOMP_NOTHROW;
+extern int omp_get_nested (void) __GOMP_DEPRECATED_5_0 __GOMP_NOTHROW;
extern void omp_init_lock (omp_lock_t *) __GOMP_NOTHROW;
extern void omp_init_lock_with_hint (omp_lock_t *, omp_sync_hint_t)
diff --git a/libgomp/omp_lib.f90.in b/libgomp/omp_lib.f90.in
index 2fae57b..3b7f0cb 100644
--- a/libgomp/omp_lib.f90.in
+++ b/libgomp/omp_lib.f90.in
@@ -644,4 +644,8 @@
end function
end interface
+#if _OPENMP >= 201811
+!GCC$ ATTRIBUTES DEPRECATED :: omp_get_nested, omp_set_nested
+#endif
+
end module omp_lib
--
2.8.1