Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed OpenMP version such that omp_set_nested is not deprecated #207

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hfp
Copy link

@hfp hfp commented Jan 7, 2025

No description provided.

@mgates3
Copy link
Collaborator

mgates3 commented Jan 7, 2025

What's the motivation here? Please provide a description of what problem this is fixing.

@hfp
Copy link
Author

hfp commented Jan 8, 2025

GNU OpenMP and other OpenMP runtimes are warning about omp_set_nested being deprecated. The code suggests omp_set_max_active_levels is only available since OpenMP 5.0, which is not true.

@mgates3
Copy link
Collaborator

mgates3 commented Jan 8, 2025

What compiler versions are you using? What is the value of the _OPENMP macro? Details help to reproduce issues. The compiler and execution output from the below code may help.

omp_set_nested was deprecated in OpenMP 5.0, which is what the comment in the code refers to.

Sample code

#include <stdio.h>
#include <omp.h>

int main( int argc, char** argv )
{
    //--------------------
    #if __clang__
        printf( "clang %d.%d.%d\n",
                __clang_major__, __clang_major__, __clang_patchlevel__ );
    #elif __GNUC__
        printf( "gcc %d.%d.%d\n",
                __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ );
    #else
        printf( "unknown compiler\n" );
    #endif

    //--------------------
    #if _OPENMP
        printf( "OpenMP %d\n", _OPENMP );
    #else
        printf( "no OpenMP available\n" );
    #endif

    //--------------------
    // Test if omp_set_nested generates deprecated warning.
    printf( "try omp_set_nested\n" );
    omp_set_nested( 1 );

    printf( "try omp_set_nested with guard\n" );
    #if _OPENMP && _OPENMP < 201811
        omp_set_nested( 1 );
    #endif

    return 0;
}

Sample output (gcc)

sh methane openmp> module load gcc/14
sh methane openmp> $CXX --version; $CXX -fopenmp -Wall -o versions versions.cc; echo; ./versions
g++ (Spack GCC) 14.1.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc 14.1.0
OpenMP 201511
try omp_set_nested
try omp_set_nested with guard

No deprecation warnings are generated.

Sample output (clang)

sh methane openmp> module load llvm/11
sh methane openmp> $CXX --version; $CXX -fopenmp -Wall -o versions versions.cc; echo; ./versions
clang version 11.1.0 (https://github.com/spack/spack d82c9e7f2a2f4a59c4e80e7219f57b82dcb87b5d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /apps/spacks/2024-07-19/opt/spack/linux-rocky9-x86_64/gcc-11.4.1/llvm-11.1.0-qrng5w6wli4jtuxygcjdplglvjlmqkhq/bin

clang 11.11.0
OpenMP 201811
try omp_set_nested
OMP: Info #270: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
try omp_set_nested with guard

The unguarded call generates a deprecation warning, but the guarded call does not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants