Skip to content

Building on ORNL Summit (POWER9) with PGI compiler #2718

Closed

Description

@wyphan

After toying around with Makefile.power and Makefile.system for a while, I've successfully built OpenBLAS 0.3.10 on POWER9 at Summit (ORNL) with GCC 6.4.0 (the default GCC version, at the time of writing). No luck with PGI 20.1 or IBM XL 16.1.1-5 yet, though. Both fail with the compiler cannot finding stdatomic.h.
PGI:

"../common.h", line 696: catastrophic error: cannot open source file
          "stdatomic.h"
  #include <stdatomic.h>

XL:

../common.h:696:10: fatal error: 'stdatomic.h' file not found
#include <stdatomic.h>
         ^~~~~~~~~~~~~

I wonder if this header file is part of GCC, or GlibC?


Side note:
It's interesting though that googling "PGI OpenBLAS" brings out this forum post somewhere in the first page for me, where PGI says they ship OpenBLAS with the compiler:
https://forums.developer.nvidia.com/t/auto-type-undefined-when-compiling-openblas/141268
Sure enough, in the include directory of the PGI compiler, there is a file called openblas_config.h. With PGI version 20,1, this file says

#define OPENBLAS_VERSION " OpenBLAS 0.3.7 "

Activity

  1. wyphan commented on Jul 15, 2020

    @wyphan
    ContributorAuthor

    Also, how do I limit the number of compile processes invoked by make to 8, instead of the auto-detected 128? I don't want to slow the cluster down for everybody... I've tried make -j 8 but it still spawns loads of processes.

  2. martin-frbg commented on Jul 15, 2020

    @martin-frbg
    Collaborator

    Edit Makefile.rule or pass MAKE_NB_JOBS=8 to make
    Not sure if PGI ship OpenBLAS with the ppc version of their compiler - probably only x86.
    stdatomic.h should be available if the compiler claims C11 capability I think ? The include line in common.h is guarded with an ifdef and I do not remember seeing this problem before

  3. martin-frbg commented on Jul 15, 2020

    @martin-frbg
    Collaborator

    Well, looks as if old versions of the "legacy" (pre-clang) xlc actually did not provide stdatomic.h, which is a bit unfortunate as there are about ten files in the code where we check for a new enough STDC_VERSION as the sole indicator that atomic operations are supported.

  4. cparrott73 commented on Jul 16, 2020

    @cparrott73
    Contributor

    After toying around with Makefile.power and Makefile.system for a while, I've successfully built OpenBLAS 0.3.10 on POWER9 at Summit (ORNL) with GCC 6.4.0 (the default GCC version, at the time of writing). No luck with PGI 20.1 or IBM XL 16.1.1-5 yet, though. Both fail with the compiler cannot finding stdatomic.h.
    PGI:

    "../common.h", line 696: catastrophic error: cannot open source file
              "stdatomic.h"
      #include <stdatomic.h>
    

    XL:

    ../common.h:696:10: fatal error: 'stdatomic.h' file not found
    #include <stdatomic.h>
             ^~~~~~~~~~~~~
    

    I wonder if this header file is part of GCC, or GlibC?

    Side note:
    It's interesting though that googling "PGI OpenBLAS" brings out this forum post somewhere in the first page for me, where PGI says they ship OpenBLAS with the compiler:
    https://forums.developer.nvidia.com/t/auto-type-undefined-when-compiling-openblas/141268
    Sure enough, in the include directory of the PGI compiler, there is a file called openblas_config.h. With PGI version 20,1, this file says

    #define OPENBLAS_VERSION " OpenBLAS 0.3.7 "
    

    We do ship OpenBLAS with the PGI compilers on Power, though this build is done using a hybrid of GCC (for the C/ASM source files) and PGI (for the Fortran files). This is necessary, due to the presence of several unsupported features used in the C files, which the PGI C compiler is not able to compile. (e.g. the vector keyword present in some of the Power inline assembly files.)

    I can make some patches available if you are interested in building it yourself this way.

  5. wyphan commented on Jul 17, 2020

    @wyphan
    ContributorAuthor

    Sure, that would be great!

    The reason I want to build OpenBLAS on Summit is to use it with MAGMA package. Currently I use MAGMA linked against IBM ESSL (which depends on IBM XL runtime libraries) for the CPU BLAS/LAPACK routines. I noticed that starting with PGI 20.1, whenever there is another OpenMP library, PGI will emit an error message at runtime about NV_OMP_DISABLE_WARNINGS. So, I want to build MAGMA linked against OpenBLAS, but that means I need to be able to build OpenBLAS on Summit using PGI first...

    I've tried building MAGMA with the OpenBLAS version that is bundled with PGI 20.1, but it gives some accuracy issues, so I want to test building it using either OpenBLAS 0.3.10 release version or the development version. For details, here's a link to the MAGMA user forum.
    https://icl.cs.utk.edu/magma/forum/viewtopic.php?f=2&t=4181&p=8624#p8624

    Edit: add MAGMA forum link

  6. wyphan commented on Jul 18, 2020

    @wyphan
    ContributorAuthor

    @cparrott73 Thanks for the patch!
    With PGI 20.1 on Summit (ORNL), I had to also propagate the changes to the POWER9 part. I also tried "translating" the CCOMMON_OPT part to PGI equivalents (e.g. -Ofast to -fast) so the rest of the C files can be compiled with pgcc directly:

    ifeq ($(CORE), POWER9)
    ifeq ($(USE_OPENMP), 1)
    ifneq ($(C_COMPILER), PGI)
    CCOMMON_OPT += -Ofast -mcpu=power9 -mtune=power9 -mvsx -malign-power -DUSE_OPENMP -fno-fast-math -fopenmp
    else
    CCOMMON_OPT += -fast -Mvect=simd -Mcache_align -DUSE_OPENMP -mp
    endif
    ifneq ($(F_COMPILER), PGI)
    FCOMMON_OPT += -O2 -frecursive -mcpu=power9 -mtune=power9 -malign-power -DUSE_OPENMP -fno-fast-math -fopenmp
    else
    FCOMMON_OPT += -O2 -Mrecursive -DUSE_OPENMP -mp
    endif
    else
    ifneq ($(C_COMPILER), PGI)
    CCOMMON_OPT += -Ofast -mcpu=power9 -mtune=power9 -mvsx -malign-power -fno-fast-math
    else
    CCOMMON_OPT += -fast -Mvect=simd -Mcache_align
    endif
    ifneq ($(F_COMPILER), PGI)
    FCOMMON_OPT += -O2 -frecursive -mcpu=power9 -mtune=power9 -malign-power -fno-fast-math
    else
    FCOMMON_OPT += -O2 -Mrecursive
    endif
    endif
    endif

    The -fopenmp flag is not yet aliased for PGI 20.1 (the latest available version on Summit, at the time of writing), so I replaced it with -mp as suggested. I'm unsure about -mvsx to Mvect=simd, as well as -malign-power to -Mcache_align...

    Now I'm stuck at manually recompiling driver/others/blas_server_omp.c. The error message is again due to missing stdatomic.h. When I "force" include GCC 6.4.0's version, I reproduce the identifier "__auto_type" is undefined error mentioned in the NVIDIA developer forum post I referred to earlier.

    Here are the commands I used so far:

    module load gcc/6.4.0
    make MAKE_NB_JOBS=8 CC=gcc FC=pgfortran
    # stops compiling at the first Fortran source file with error pgfortran not found
    module load pgi/20.1
    make MAKE_NB_JOBS=8 CC=pgcc FC=pgfortran
    # stops compiling with link error from blas_server_omp.c, undefined reference to GOMP_parallel
    cd driver/others
    pgcc -mp -O2 -DMAX_STACK_ALLOC=2048 -tp pwr9 -DF_INTERFACE_PGI -fPIC -DSMP_SERVER -DUSE_OPENMP -DNO_WARMUP -DMAX_CPU_NUMBER=128 -DMAX_PARALLEL_NUMBER=1 -DVERSION=\"0.3.10\" -fast -Mvect=simd -Mcache_align -DUSE_OPENMP -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME=blas_server -DASMFNAME=blas_server_ -DNAME=blas_server_ -DCNAME=blas_server -DCHAR_NAME=\"blas_server_\" -DCHAR_CNAME=\"blas_server\" -DNO_AFFINITY -I../.. -I/sw/summit/gcc/6.4.0/lib/gcc/powerpc64le-none-linux-gnu/6.4.0/include -c blas_server_omp.c -o blas_server.o

    The full error message from the last command can be found here.

    Edit: The system GCC on Summit is 4.8.5; could this be the reason it's missing stdatomic.h -- simply because it's too old?

  7. martin-frbg commented on Jul 18, 2020

    @martin-frbg
    Collaborator

    Yes could be that 4.8.5 is too old to have stdatomic.h - but unlike xlc and pgcc it does not claim C11 compatibility. Basically another patch is needed that adds a not IBM or PGI to all checks for __STDC_VERSION >=2011

  8. martin-frbg commented on Jul 18, 2020

    @martin-frbg
    Collaborator

    that linker error about gomp_parallel is probably caused by f_check suppressing certain -lomp linker options when the PGI compilers are used. This seemed to be necessary on x86_64 but may have been papering over some real problem elsewhere

  9. martin-frbg commented on Jul 18, 2020

    @martin-frbg
    Collaborator

    Btw that is basically what cparrott added to the other ticket.
    Actually the -lomp suppression should occur on anything not PGI if I remember correctly, perhaps the problem only comes from trying to do a partial rebuild (which our convoluted makefiles may not handle too well)
    Unfortunately i only have the community release of the compiler which is still 19.10 AFAIK

  10. changed the title [-]Building on POWER9[/-] [+]Building on ORNL Summit (POWER9) with PGI compiler[/+] on Jul 18, 2020
  11. wyphan commented on Jul 18, 2020

    @wyphan
    ContributorAuthor

    @martin-frbg Summit also has PGI 19.10 installed. Should I wait for #2725 to be merged first before trying to build again?

  12. martin-frbg commented on Jul 18, 2020

    @martin-frbg
    Collaborator

    Yes, or get it in patch format by adding .diff to its github url

  13. martin-frbg commented on Jul 18, 2020

    @martin-frbg
    Collaborator

    merged now (note I have not gotten around to merging cparrott73's patch yet but plan to do it tomorrow)

  14. wyphan commented on Jul 21, 2020

    @wyphan
    ContributorAuthor

    With PGI 19.10, after applying the diff patch for #2725, the build strangely didn't choke on blas_server_omp.c. Instead, it went further and finally failed at make shared phase in the second stage (the one using pgcc and pgfortran) with the following error message:

    pgcc -O2 -DMAX_STACK_ALLOC=2048 -DUSE_LOCKING -tp pwr9 -DF_INTERFACE_PGI -fPIC -DNO_WARMUP -DMAX_CPU_NUMBER=128 -DMAX_PARALLEL_NUMBER=1 -DVERSION=\"0.3.10\" -fast -Mvect=simd -Mcache_align -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME=\"_\" -DCHAR_CNAME=\"\" -DNO_AFFINITY -I..  -w -o linktest linktest.c ../libopenblas_power9-r0.3.10.so -L/autofs/nccs-svm1_sw/summit/.swci/0-core/opt/spack/20180914/linux-rhel7-ppc64le/gcc-4.8.5/pgi-19.10-vke4btwz6u5p7gix22s2v2qj4352ctll/linuxpower/19.10/lib -L/usr/lib64 -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5 -Wl,-rpath,/autofs/nccs-svm1_sw/summit/.swci/0-core/opt/spack/20180914/linux-rhel7-ppc64le/gcc-4.8.5/pgi-19.10-vke4btwz6u5p7gix22s2v2qj4352ctll/linuxpower/19.10/lib -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64  -lpgftnrtl -latomic -ldl -lpthread -lpgmath -lpgc -lrt -lpthread -lm -lc   && echo OK.
    linktest.c:
    ../libopenblas_power9-r0.3.10.so: undefined reference to `__get_size_of'
    ../libopenblas_power9-r0.3.10.so: undefined reference to `pgf90_str_copy_klen'
    ../libopenblas_power9-r0.3.10.so: undefined reference to `pgf90_str_cpy1'
    ../libopenblas_power9-r0.3.10.so: undefined reference to `pgf90_strcmp_klen'
    ../libopenblas_power9-r0.3.10.so: undefined reference to `pghpf_maxloc_i8'
    ../libopenblas_power9-r0.3.10.so: undefined reference to `pgf90_set_intrin_type_i8'
    /usr/bin/ld: link errors found, deleting executable `linktest'
    make[1]: *** [../libopenblas_power9-r0.3.10.so] Error 2
    make[1]: Leaving directory `/gpfs/alpine/******/scratch/wyphan/OpenBLAS-0.3.10/exports'
    make: *** [shared] Error 2
    

    (Sorry I had to censor the allocation ID on Summit.)

    I know this error can simply be fixed by adding -pgf90libs to the link line. Where should I add that (specifically, which file)?

    Edit: clarified wording
    Edit 2: found it, see patch below

  15. cparrott73 commented on Jul 21, 2020

    @cparrott73
    Contributor

    With PGI 19.10, after applying the diff patch for #2725, the build ended at the second stage (the one using pgcc and pgfortran) with the following error message:

    pgcc -O2 -DMAX_STACK_ALLOC=2048 -DUSE_LOCKING -tp pwr9 -DF_INTERFACE_PGI -fPIC -DNO_WARMUP -DMAX_CPU_NUMBER=128 -DMAX_PARALLEL_NUMBER=1 -DVERSION=\"0.3.10\" -fast -Mvect=simd -Mcache_align -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME=\"_\" -DCHAR_CNAME=\"\" -DNO_AFFINITY -I..  -w -o linktest linktest.c ../libopenblas_power9-r0.3.10.so -L/autofs/nccs-svm1_sw/summit/.swci/0-core/opt/spack/20180914/linux-rhel7-ppc64le/gcc-4.8.5/pgi-19.10-vke4btwz6u5p7gix22s2v2qj4352ctll/linuxpower/19.10/lib -L/usr/lib64 -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5 -Wl,-rpath,/autofs/nccs-svm1_sw/summit/.swci/0-core/opt/spack/20180914/linux-rhel7-ppc64le/gcc-4.8.5/pgi-19.10-vke4btwz6u5p7gix22s2v2qj4352ctll/linuxpower/19.10/lib -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64  -lpgftnrtl -latomic -ldl -lpthread -lpgmath -lpgc -lrt -lpthread -lm -lc   && echo OK.
    linktest.c:
    ../libopenblas_power9-r0.3.10.so: undefined reference to `__get_size_of'
    ../libopenblas_power9-r0.3.10.so: undefined reference to `pgf90_str_copy_klen'
    ../libopenblas_power9-r0.3.10.so: undefined reference to `pgf90_str_cpy1'
    ../libopenblas_power9-r0.3.10.so: undefined reference to `pgf90_strcmp_klen'
    ../libopenblas_power9-r0.3.10.so: undefined reference to `pghpf_maxloc_i8'
    ../libopenblas_power9-r0.3.10.so: undefined reference to `pgf90_set_intrin_type_i8'
    /usr/bin/ld: link errors found, deleting executable `linktest'
    make[1]: *** [../libopenblas_power9-r0.3.10.so] Error 2
    make[1]: Leaving directory `/gpfs/alpine/******/scratch/wyphan/OpenBLAS-0.3.10/exports'
    make: *** [shared] Error 2
    

    (Sorry I had to censor the allocation ID on Summit.)

    I know this error can simply be fixed by adding -pgf90libs to the link line. Where should I add that?

    You can add -pgf90libs anywhere on the link line. That should resolve the missing references.

  16. 26 remaining items

  17. wyphan commented on Jul 24, 2020

    @wyphan
    ContributorAuthor

    Ah, I just realized that I passed -c99 to the manual build line for blas_server_omp.c. Let me try again without it.
    Edit: Nope, still the same errors. Here is the error log.

  18. martin-frbg commented on Jul 24, 2020

    @martin-frbg
    Collaborator

    Not sure I understand the reasoning behind wanting to recompile just one file and inserting it into the library instead of recompiling everything with consistent settings. Is there something else that needs fixing, or are you just trying to save compile time ?
    Right now I can only assume that your config.h with the define HAVE_C11 stems from a build attempt where you had manually added the (path to the) GCC stdatomic.h somehow.

  19. cparrott73 commented on Jul 24, 2020

    @cparrott73
    Contributor

    Not sure I understand the reasoning behind wanting to recompile just one file and inserting it into the library instead of recompiling everything with consistent settings. Is there something else that needs fixing, or are you just trying to save compile time ?

    This is a bit of an ugly workaround for the fact that the OpenMP interfaces in GCC and PGI are not compatible. (The situation will be improved somewhat with 20.7, in that the NV HPC SDK will support the GOMP interface, which gcc -fopenmp uses. However, GCC will still link against libgomp rather than libnvomp at link time when gcc -fopenmp is used for linking.) So the idea is to build most of OpenBLAS with GCC, but recompile the bits that require OpenMP with PGI.

  20. martin-frbg commented on Jul 24, 2020

    @martin-frbg
    Collaborator

    Hmmm. But the primary reason for that workaround was that OpenBLAS simply would not compile with pgcc ? If you want to keep doing it this way just to benefit from the altivec support in gcc, I guess you'll now need the extra uglyness of removing the define HAVE_C11 from the gcc-"inspired" config.h before recompiling blas_server_omp.c . At least I see no elegant solution for handling a header that is only sometimes available.

  21. cparrott73 commented on Jul 24, 2020

    @cparrott73
    Contributor

    In our automated builds, I normally patch the makefiles with some override rules to force the OpenMP files to be compiled with nvc instead of gcc. But I wouldn't expect you to integrate those into a mainline release. It's a pretty ugly workaround for the fact that our compilers do not support gcc-style altivec features. (I've been nagging our developers about this, but so many priorities...so few developers...)

  22. cparrott73 commented on Jul 24, 2020

    @cparrott73
    Contributor

    BTW, one of my colleagues has found a potential memory consistency issue with OpenBLAS on Power. I'm working with him on a reproducer, will open an issue soon when we have more details.

  23. martin-frbg commented on Jul 24, 2020

    @martin-frbg
    Collaborator

    Guess I could have c_check generate the HAVE_C11 in config.h with an additional #ifndef NO_C11 (or NO_ATOMICS, whatever) around it to make it easier to override on the command line.
    The memory consistency issue is bad news, I had almost hoped we had caught them all by now.

  24. wyphan commented on Aug 4, 2020

    @wyphan
    ContributorAuthor

    One last thing: I just realized that the Summit login nodes have 128 logical cores, while the compute nodes have 168 logical cores. Is this something that can be easily fixed by appending MAX_CPU_NUMBER=168 when invoking make?

  25. martin-frbg commented on Aug 4, 2020

    @martin-frbg
    Collaborator

    Yes, setting MAX_CPU_NUMBER (or NUM_THREADS) should solve this.

  26. wyphan commented on Aug 6, 2020

    @wyphan
    ContributorAuthor

    @martin-frbg Setting NUM_THREADS did the trick, however, now I get the following warning at runtime (repeated for each thread):

    OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
    

    Is this normal? As before, I invoked make with USE_THREADS=0 and USE_LOCKING=1. Does the order matter when issuing the variables to make?
    Attached is the (sanitized) full build log:
    build-gcc6.4.0+pgi19.10.log.gz

  27. martin-frbg commented on Aug 6, 2020

    @martin-frbg
    Collaborator

    This message should only appear when a multithreaded but non-OpenMP libopenblas is called from an OpenMP application, and the library suffix "p" for a pthreads build confirms that this is indeed a multithreaded build.
    Check the spelling of the options - it is USE_THREAD without the "S" (for historic reasons), perhaps we should handle USE_THREADS as an alias.

  28. wyphan commented on Aug 6, 2020

    @wyphan
    ContributorAuthor

    @martin-frbg Whoops, you're right, I have the "S" at the end 😂. Rebuilding now...
    Edit: Rebuild complete, now it's single-threaded, as I intended.

  29. cparrott73 commented on Aug 7, 2020

    @cparrott73
    Contributor

    FYI - everything is now official, and I can update you all on latest developments:

    The NVIDIA HPC SDK has been released this week. This includes a new version of what was formerly the PGI compilers: 20.7. However, the PGI compilers have now been rebranded to become what we shall colloquially refer to as the "NV" compilers going forward: pgcc is now nvc (to avoid clashing with the existing nvcc compiler for CUDA), pgc++ is now nvc++, and pgfortran/pgf90/pgf95 is now nvfortran. For the time being, we are also providing compatibility drivers with the old names, which now point to the new compilers - so you can still use the pg* names for a while longer, if you prefer those.

    There are a lot of places where things like rcfiles, certain compiler switches, etc. have been renamed to remove "pgXXXXXX" references in the new NV compilers. There are too many of these to list here, but you can read through the documentation to get a full sense of what has changed.

    With this release, we are also providing compilers for the aarch64 (ARM64) platform, in addition to the existing x86_64 and ppc64le compilers we have previously developed. One other major change is that the NoLLVM compilers for x86_64 are no longer being developed, tested, or shipped.

    I am aware of a number of issues with our compilers that prevent OpenBLAS from being compiled out of the box with 20.7, and I have opened internal bug reports on many of them. Several of these issues are being actively worked as I write, although I do not have a timetable for when all of them will be fixed at this time. One of the major issues is that our compilers choke on some of the assembly routines that implement various tuned kernels for the above architectures. (In particular, the previous "NoLLVM" workaround that OpenBLAS uses to get around this will no longer be viable, going forward.)

    I do have a patch set that successfully compiles most of OpenBLAS 0.3.10 with nvc/nvfortran 20.7, and falls back to gcc to compile the files that our compilers currently have difficulty with. I have successfully produced working builds of OpenBLAS with nvc/nvfortran/gcc with these patches. I plan to share this patch set within the next few days, so that you all may benefit from it until such time as the NV compilers improve enough to handle the whole thing standalone, without help from gcc. I will leave it up to the OpenBLAS developers as to how much of this they want to incorporate into the mainline source repo.

    Note that we still ship OpenBLAS builds based on 0.3.7 with the 20.7 release, although we do test and evaluate newer versions internally as part of our future planning.

    The NVIDIA HPC SDK is available to everyone to download for free, so go check it out if you haven't already:

    https://developer.nvidia.com/hpc-sdk

  30. cparrott73 commented on Aug 11, 2020

    @cparrott73
    Contributor

    Here is our current patch set for building 0.3.10 using a hybrid of nvc/nvfotran/gcc with the new NVIDIA HPC SDK 20.7 release. This includes our alternative fix for issue #2760 as described there. This also enables building OpenBLAS on arm64 using our compilers. There are rules to fall back to gcc for files that are problematic for nvc. In time, we hope to fix these issues and eliminate these fallbacks. These probably need to be cleaned up a bit before they would be ready for general consideration, but individual users may find this helpful.

    openblas.diff.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions