public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* building GCC 11.2 with offloading
@ 2021-12-08 20:50 Patrick Begou
  2021-12-10 13:40 ` Patrick Begou
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick Begou @ 2021-12-08 20:50 UTC (permalink / raw)
  To: gcc-help

Hi,

my goal is to compile GCC 11.2 with OpenACC and OpenMP offloading on 
nividia A100 GPU.I found some tutorial on 
https://kristerw.blogspot.com/2017/04/building-gcc-with-support-for-nvidia.html 
but I think I hit the bug 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100289 as it fails with:

    In file included from ../../../../gcc/libgcc/libgcov-merge.c:26:
    ../../../../gcc/libgcc/libgcov.h:49:10: fatal error: sys/mman.h: No
    such file or directory
        49 | #include <sys/mman.h>
           |          ^~~~~~~~~~~~
    compilation terminated.

Is there a workaround for this "configure" problem  as the bug will not 
be addressed before GCC 11.3 ?

The beginning of my script to build GCC is provided below.

Thanks

Patrick


    #!/bin/bash
    module use --append /opt/nvidia/hpc_sdk/modulefiles
    module load nvhpc/20.9

    CC=$(which gcc)
    CXX=$(which g++)

    install_dir=/opt/GCC11.2
    work_dir=/robin/data/begou/GCC11/GCC11.2-offload
    cuda=/opt/nvidia/hpc_sdk/Linux_x86_64/20.9/cuda

    mkdir -p $work_dir
    cd $work_dir

    # Build assembler and linking tools
    git clone https://github.com/MentorEmbedded/nvptx-tools
    cd nvptx-tools
    ./configure \
         --with-cuda-driver-include=$cuda/include \
         --with-cuda-driver-lib=$cuda/lib64 \
         --prefix=$install_dir
    make ||exit 1
    make install || exit 1
    cd ..

    # Set up the GCC source tree
    git clone git://sourceware.org/git/newlib-cygwin.git nvptx-newlib
    git clone --branch releases/gcc-11 git://gcc.gnu.org/git/gcc.git gcc
    cd gcc
    contrib/download_prerequisites
    ln -s ../nvptx-newlib/newlib newlib
    cd ..
    target=$(gcc/config.guess)

    # Build nvptx GCC
    mkdir build-nvptx-gcc
    cd build-nvptx-gcc
    ../gcc/configure \
         --target=nvptx-none
    --with-build-time-tools=$install_dir/nvptx-none/bin \
         --enable-as-accelerator-for=$target \
         --disable-sjlj-exceptions \
         --enable-newlib-io-long-long \
         --enable-languages="c,c++,fortran,lto" \
         --prefix=$install_dir
    make

(and the last make command fails)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: building GCC 11.2 with offloading
  2021-12-08 20:50 building GCC 11.2 with offloading Patrick Begou
@ 2021-12-10 13:40 ` Patrick Begou
  2021-12-10 14:37   ` Stefan Ring
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick Begou @ 2021-12-10 13:40 UTC (permalink / raw)
  To: gcc-help

Hi gcc users,

as my question does not seem to find an audience, I could perhaps 
rephrase it differently:

Has anyone successfully compiled GCC11 with offloading to modern Nvidia 
GPU on RHEL8 / CentOS8 and, if so, could they show me a pointer for  a 
tutorial or some "how-to" documentation?

I was not able to find this or may be i misunderstand the process to do 
this.

Thanks

Patrick



Le 08/12/2021 à 21:50, Patrick Begou a écrit :
>
> Hi,
>
> my goal is to compile GCC 11.2 with OpenACC and OpenMP offloading on 
> nividia A100 GPU.I found some tutorial on 
> https://kristerw.blogspot.com/2017/04/building-gcc-with-support-for-nvidia.html 
> but I think I hit the bug 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100289 as it fails with:
>
>     In file included from ../../../../gcc/libgcc/libgcov-merge.c:26:
>     ../../../../gcc/libgcc/libgcov.h:49:10: fatal error: sys/mman.h:
>     No such file or directory
>        49 | #include <sys/mman.h>
>           |          ^~~~~~~~~~~~
>     compilation terminated.
>
> Is there a workaround for this "configure" problem  as the bug will 
> not be addressed before GCC 11.3 ?
>
> The beginning of my script to build GCC is provided below.
>
> Thanks
>
> Patrick
>
>
>     #!/bin/bash
>     module use --append /opt/nvidia/hpc_sdk/modulefiles
>     module load nvhpc/20.9
>
>     CC=$(which gcc)
>     CXX=$(which g++)
>
>     install_dir=/opt/GCC11.2
>     work_dir=/robin/data/begou/GCC11/GCC11.2-offload
>     cuda=/opt/nvidia/hpc_sdk/Linux_x86_64/20.9/cuda
>
>     mkdir -p $work_dir
>     cd $work_dir
>
>     # Build assembler and linking tools
>     git clone https://github.com/MentorEmbedded/nvptx-tools
>     cd nvptx-tools
>     ./configure \
>         --with-cuda-driver-include=$cuda/include \
>         --with-cuda-driver-lib=$cuda/lib64 \
>         --prefix=$install_dir
>     make ||exit 1
>     make install || exit 1
>     cd ..
>
>     # Set up the GCC source tree
>     git clone git://sourceware.org/git/newlib-cygwin.git nvptx-newlib
>     git clone --branch releases/gcc-11 git://gcc.gnu.org/git/gcc.git gcc
>     cd gcc
>     contrib/download_prerequisites
>     ln -s ../nvptx-newlib/newlib newlib
>     cd ..
>     target=$(gcc/config.guess)
>
>     # Build nvptx GCC
>     mkdir build-nvptx-gcc
>     cd build-nvptx-gcc
>     ../gcc/configure \
>         --target=nvptx-none
>     --with-build-time-tools=$install_dir/nvptx-none/bin \
>         --enable-as-accelerator-for=$target \
>         --disable-sjlj-exceptions \
>         --enable-newlib-io-long-long \
>         --enable-languages="c,c++,fortran,lto" \
>         --prefix=$install_dir
>     make
>
> (and the last make command fails)
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: building GCC 11.2 with offloading
  2021-12-10 13:40 ` Patrick Begou
@ 2021-12-10 14:37   ` Stefan Ring
  2021-12-10 15:42     ` Patrick Begou
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Ring @ 2021-12-10 14:37 UTC (permalink / raw)
  To: gcc-help

On Fri, Dec 10, 2021 at 2:41 PM Patrick Begou via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> Hi gcc users,
>
> as my question does not seem to find an audience, I could perhaps
> rephrase it differently:
>
> Has anyone successfully compiled GCC11 with offloading to modern Nvidia
> GPU on RHEL8 / CentOS8 and, if so, could they show me a pointer for  a
> tutorial or some "how-to" documentation?
>
> I was not able to find this or may be i misunderstand the process to do
> this.

Do you specifically need gcc 11? This seems to be a general problem in
11 for targets that don’t have this header. I ran into the same issue
when trying to build the djgpp version a few days ago. gcc 10 does not
suffer from this, IIRC.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: building GCC 11.2 with offloading
  2021-12-10 14:37   ` Stefan Ring
@ 2021-12-10 15:42     ` Patrick Begou
  2021-12-10 16:51       ` Stefan Ring
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick Begou @ 2021-12-10 15:42 UTC (permalink / raw)
  To: gcc-help

Le 10/12/2021 à 15:37, Stefan Ring via Gcc-help a écrit :
> On Fri, Dec 10, 2021 at 2:41 PM Patrick Begou via Gcc-help
> <gcc-help@gcc.gnu.org>  wrote:
>> Hi gcc users,
>>
>> as my question does not seem to find an audience, I could perhaps
>> rephrase it differently:
>>
>> Has anyone successfully compiled GCC11 with offloading to modern Nvidia
>> GPU on RHEL8 / CentOS8 and, if so, could they show me a pointer for  a
>> tutorial or some "how-to" documentation?
>>
>> I was not able to find this or may be i misunderstand the process to do
>> this.
> Do you specifically need gcc 11? This seems to be a general problem in
> 11 for targets that don’t have this header. I ran into the same issue
> when trying to build the djgpp version a few days ago. gcc 10 does not
> suffer from this, IIRC.

Hi Stephan

thanks for your suggestion. I've also tried with GCC 10.3 (and also with 
master branch in case the problem would be solved).

With GCC 10.3 I get an error in build-nvptx-gcc/nvptx-none/libgcc : /
/

    /"configure: error: cannot compute suffix of object files: cannot
    compile"/

Looking in config.log file it is a ptxas error:

    /ptxas fatal   : Value 'sm_30' is not defined for option 'gpu-name'/
    /nvptx-as: ptxas returned 255 exit status/

looking for this error in google search I found a reply:

    /"This is due to NVIDIA dropping support for SM_30 in latest CUDA
    and gcc-offload-nvptx to force use it."/


But I need a recent Nvidia environment to support my A100 GPU. So I'm 
unable to compile GCC 10.3 for offloading too.

Patrick

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: building GCC 11.2 with offloading
  2021-12-10 15:42     ` Patrick Begou
@ 2021-12-10 16:51       ` Stefan Ring
  2021-12-15  8:59         ` Patrick Begou
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Ring @ 2021-12-10 16:51 UTC (permalink / raw)
  To: gcc-help

On Fri, Dec 10, 2021 at 4:43 PM Patrick Begou via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> But I need a recent Nvidia environment to support my A100 GPU. So I'm
> unable to compile GCC 10.3 for offloading too.

Try if patching along the lines of
https://github.com/apavenis/djgpp-gcc/pull/2 works. In my case it did.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: building GCC 11.2 with offloading
  2021-12-10 16:51       ` Stefan Ring
@ 2021-12-15  8:59         ` Patrick Begou
  2021-12-15 11:59           ` Stefan Ring
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick Begou @ 2021-12-15  8:59 UTC (permalink / raw)
  To: gcc-help

Le 10/12/2021 à 17:51, Stefan Ring via Gcc-help a écrit :
> On Fri, Dec 10, 2021 at 4:43 PM Patrick Begou via Gcc-help
> <gcc-help@gcc.gnu.org>  wrote:
>> But I need a recent Nvidia environment to support my A100 GPU. So I'm
>> unable to compile GCC 10.3 for offloading too.
> Try if patching along the lines of
> https://github.com/apavenis/djgpp-gcc/pull/2  works. In my case it did.

Hi Stefan

I've spent a couple of days trying your suggestion but it did not works 
for me...

- first, using releases/gcc-11 branch I hit the new bug on "undefined 
directly_supported_" 
(https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg276579.html)

- I try the patch with the master branch, but the  "fatal error: 
sys/mman.h: No such file or directory" still occurs.

- I've then tried to specify the compiler where to look for the include 
files using:

CFLAGS="-I/usr/include" ../gcc/configure \
     --target=nvptx-none 
--with-build-time-tools=$install_dir/nvptx-none/bin \
     --enable-as-accelerator-for=$target \
     --disable-sjlj-exceptions \
     --enable-newlib-io-long-long \
     --enable-languages="c,c++,fortran,lto" \
     --prefix=$install_dir

but it has no effect as it is not the installed gcc which fails to 
compile but the just created xgcc:

*/robin/data/begou/GCC11/GCC11.2-offload/build-nvptx-gcc/./gcc/**xgcc* 
-B/robin/data/begou/GCC11/GCC11.2-offload/build-nvptx-gcc/./gcc/ 
-nostdinc 
-B/robin/data/begou/GCC11/GCC11.2-offload/build-nvptx-gcc/nvptx-none/newlib/ 
-isystem 
/robin/data/begou/GCC11/GCC11.2-offload/build-nvptx-gcc/nvptx-none/newlib/targ-include 
-isystem /robin/data/begou/GCC11/GCC11.2-offload/gcc/newlib/libc/include 
-B/opt/GCC11.2/nvptx-none/bin/ -B/opt/GCC11.2/nvptx-none/lib/ -isystem 
/opt/GCC11.2/nvptx-none/include -isystem 
/opt/GCC11.2/nvptx-none/sys-include    -g -O2 -mgomp -O2  -g -O2 
-DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing 
-Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wstrict-prototypes 
-Wmissing-prototypes -Wno-error=format-diag -Wold-style-definition  
-isystem ./include   -g -DIN_LIBGCC2 -fbuilding-libgcc 
-fno-stack-protector -Dinhibit_libc  -I. -I. -I../../.././gcc 
-I../../../../gcc/libgcc -I../../../../gcc/libgcc/. 
-I../../../../gcc/libgcc/../gcc -I../../../../gcc/libgcc/../include  
-DHAVE_CC_TLS -DUSE_EMUTLS -o _gcov_merge_add.o -MT _gcov_merge_add.o 
-MD -MP -MF _gcov_merge_add.dep -DL_gcov_merge_add -c 
../../../../gcc/libgcc/libgcov-merge.c

/In file included from ../../../../gcc/libgcc/libgcov-merge.c:26://
//../../../../gcc/libgcc/libgcov.h:49:10: fatal error: sys/mman.h: No 
such file or directory//
//   49 | #include <sys/mman.h>/

Moreover I'm not sureif  I need to include this file...

My goal is really to use Gnu compilers for offloading on nvidia GPU and 
also AMD GPU. We have a large fortran CFD code and  llvm compilers 
(provided by Nvidia or AMD) needs a lot of time to compile fortran files 
with a lot of "use" statements. Typically more than 20mn per file when 
gfortran is ten time faster. And these files with many dependences are 
compiled at each modification of the code. :-(

Patrick

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: building GCC 11.2 with offloading
  2021-12-15  8:59         ` Patrick Begou
@ 2021-12-15 11:59           ` Stefan Ring
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Ring @ 2021-12-15 11:59 UTC (permalink / raw)
  To: gcc-help

On Wed, Dec 15, 2021 at 10:01 AM Patrick Begou via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> I've spent a couple of days trying your suggestion but it did not works
> for me...
>
> - I've then tried to specify the compiler where to look for the include
> files using:
>
> CFLAGS="-I/usr/include" ../gcc/configure \
>      --target=nvptx-none
> --with-build-time-tools=$install_dir/nvptx-none/bin \
>      --enable-as-accelerator-for=$target \
>      --disable-sjlj-exceptions \
>      --enable-newlib-io-long-long \
>      --enable-languages="c,c++,fortran,lto" \
>      --prefix=$install_dir
>
> but it has no effect as it is not the installed gcc which fails to
> compile but the just created xgcc:
>
> */robin/data/begou/GCC11/GCC11.2-offload/build-nvptx-gcc/./gcc/**xgcc*
> -B/robin/data/begou/GCC11/GCC11.2-offload/build-nvptx-gcc/./gcc/
> -nostdinc
> -B/robin/data/begou/GCC11/GCC11.2-offload/build-nvptx-gcc/nvptx-none/newlib/
> -isystem
> /robin/data/begou/GCC11/GCC11.2-offload/build-nvptx-gcc/nvptx-none/newlib/targ-include
> -isystem /robin/data/begou/GCC11/GCC11.2-offload/gcc/newlib/libc/include
> -B/opt/GCC11.2/nvptx-none/bin/ -B/opt/GCC11.2/nvptx-none/lib/ -isystem
> /opt/GCC11.2/nvptx-none/include -isystem
> /opt/GCC11.2/nvptx-none/sys-include    -g -O2 -mgomp -O2  -g -O2
> -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing
> -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wstrict-prototypes
> -Wmissing-prototypes -Wno-error=format-diag -Wold-style-definition
> -isystem ./include   -g -DIN_LIBGCC2 -fbuilding-libgcc
> -fno-stack-protector -Dinhibit_libc  -I. -I. -I../../.././gcc
> -I../../../../gcc/libgcc -I../../../../gcc/libgcc/.
> -I../../../../gcc/libgcc/../gcc -I../../../../gcc/libgcc/../include
> -DHAVE_CC_TLS -DUSE_EMUTLS -o _gcov_merge_add.o -MT _gcov_merge_add.o
> -MD -MP -MF _gcov_merge_add.dep -DL_gcov_merge_add -c
> ../../../../gcc/libgcc/libgcov-merge.c
>
> /In file included from ../../../../gcc/libgcc/libgcov-merge.c:26://
> //../../../../gcc/libgcc/libgcov.h:49:10: fatal error: sys/mman.h: No
> such file or directory//

That’s not what I suggested. I suggested that you get rid of
HAVE_SYS_MMAN_H in this directory (libgcc). It does not strictly
require mmap and will also build without it.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-12-15 11:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08 20:50 building GCC 11.2 with offloading Patrick Begou
2021-12-10 13:40 ` Patrick Begou
2021-12-10 14:37   ` Stefan Ring
2021-12-10 15:42     ` Patrick Begou
2021-12-10 16:51       ` Stefan Ring
2021-12-15  8:59         ` Patrick Begou
2021-12-15 11:59           ` Stefan Ring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).