On Wed, Oct 28, 2020 at 03:41:25PM +0000, Kwok Cheung Yeung wrote: > I found this almost two-year old thread while looking for how the OpenMP 5.0 > deprecations were to be handled. > > > E.g. if somebody tries hard to write portable OpenMP code and has: > > omp_lock_t lock; > > #if __OPENMP__ >= 201811L > > omp_init_lock_with_hint (&lock, omp_sync_hint_contended); > > #elif __OPENMP__ >= 201511L > > omp_init_lock_with_hint (&lock, omp_lock_hint_contended); > > #else > > omp_init_lock (&lock); > > #endif > > they would now get a warning even when they did the right thing. > > So, deprecating those when we change __OPENMP__ macro is the right thing. > > 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. > > 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? Jakub