Nvc++ error: namespace "std" has no member "align_val_t"

These are my first steps with the new nvc++ compiler. I’m on Ubuntu 16.04 hitting this error with a simple example, but only when I use -std=c++17. If I change that to c++11, the program compiles & works. But, I’d like to use c++17, eventually.

code:

    #include <algorithm>
    #include <iostream>
    #include <vector>
    #include <execution>

    int main()
    {
        std::vector<int> v = {5,100,3,6,6,109,64,234,656,25,7,44,6,232,2};
        std::sort(std::execution::par_unseq, v.begin(), v.end());
        std::cout << v[0] << '\n';
    }

output:

    > nvc++ -stdpar -std=c++17 par.cpp -o par
    "/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/include-stdpar/thrust/mr/new.h
              ", line 44: error: namespace "std" has no member "align_val_t"
              return ::operator new(bytes, std::align_val_t(alignment));
                                                ^

    "/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/include-stdpar/thrust/mr/new.h
              ", line 66: error: namespace "std" has no member "align_val_t"
              ::operator delete(p, bytes, std::align_val_t(alignment));
                                               ^

    2 errors detected in the compilation of "par.cpp".

Any ideas what I should do to get past this?

> nvc++ --version

nvc++ 20.7-0 LLVM 64-bit target on x86-64 Linux -tp haswell
NVIDIA Compilers and Tools
Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.

In order to be object compatible with g++, nvc++ depends on the GNU C++ standard libraries. On Ubuntu 16.04, I believe the installed g++ version is 5.4 which does not support C++17. You’ll need to either upgrade the OS or GNU version installed on your system in order to use these new features.

Note if you decide to install a newer GNU version (in a separate location) and not replace or update the system version, you’ll need to reconfigure the compilers to use this new version via the command:

makelocalrc -x -d . -gcc=/full/path/to/gnu/bin/gcc -gpp=/full/path/to/gnu/bin/g++ -g77=/full/path/to/gnu/bin/gfortran

This will create a “localrc” file in the current directory. You can then either replace the localrc found in the compiler bin directory if you want all future compilation to be configured to use the new GNU standard libraries, or use the environment flag “NVLOCALRC=/full/path/to/localrc” to only use it in the current environment. Note when using the environment variable, the localrc file can be renamed, such as “localrc.gnu92”, if you want to make it more clear as to which configuration is being used.

Hope this helps,
Mat

2 Likes

Thank you, Mat. You explained the issue perfectly. I did have one nit with the fix in that I was not able to get makelocalrc to work with /full/path/to/gnu/bin/g++. I just passed the g++-7 command name and that seems to do the trick.

> makelocalrc -x -d . -gcc gcc-7 -gpp g++-7
> env NVLOCALRC=/path/to/here/localrc nvc++ -stdpar -std=c++17 par.cpp -o par
> ./par
2

Interesting. Do you know what the issue was? Since you renamed the g++ driver, did you use “/full/path/to/gnu/bin/g+±7”?

Though, I’m glad you were able to get it working.

Oh, apparently, it is the “=”. That causes issues.

> makelocalrc -x -d . -gcc=/usr/bin/gcc-7 -gpp=/usr/bin/g++-7
/opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/bin/makelocalrc: -gpp=/usr/bin/g++-7: directory not found
Usage: /opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/bin/makelocalrc [installdir] [switches]...
[snip]

but

> makelocalrc -x -d . -gcc /usr/bin/gcc-7 -gpp /usr/bin/g++-7

works.