Re: Need help to build gcc with AMD offloading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Patrick!

On 2023-07-25T11:37:41+0200, Patrick Begou via Gcc-help <gcc-help@xxxxxxxxxxx> wrote:
> My goal is to build Gcc to use openacc offloading on AMD instinct GPUs.
> I built it successfully for Nvidia GPUs some weeks ago.
>
> I have followed the documentation provided by
> https://gcc.gnu.org/wiki/Offloading#Building_host_and_accel_compilers
>
> - building llvm and renaming the tools,
>
> - building gfortran for the device:
>
> ../configure --prefix=$DEST --target=amdgcn-amdhsa
> --enable-languages=c,c++,lto,fortran --disable-sjlj-exceptions
> --with-newlib \
>               --enable-as-accelerator-for=$target
> --with-build-time-tools=$DEST/bin --disable-libquadmath
>
> - building gfortran for the host:
>
> ../configure --prefix=$DEST --build=x86_64-pc-linux-gnu
> --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --disable-multilib \
> --enable-offload-targets=nvptx-none=$DEST/nvptx-none,amdgcn-amdhsa=$DEST/amdgcn-amdhsa

If you have installed all the GCN/nvptx offloading compiler(s) and the
host compiler into the same '--prefix=$DEST', you shouldn't need:

    --enable-offload-targets=nvptx-none=$DEST/nvptx-none,amdgcn-amdhsa=$DEST/amdgcn-amdhsa

..., but instead just:

    --enable-offload-targets=nvptx-none,amdgcn-amdhsa

(The latter is, I think, the standard configuration; for the former,
while conceptually better, you need some mroe tweaks -- I shall document
that at some point...)

> Compilation is successful but using this new compiler I have an error
> when calling it:
>
> $ make
> gfortran -c -fopenacc -foffload='-march=gfx90a' -cpp -foffload=-lgfortran tab.f90 -o tab.o

For that invocation ('-c'), there is no offloading compilation yet (that
happens at link time; that's when you should specify your offloading
compilation flags, via '-foffload-options=[...]').

> as: Unknown command line argument '--64'.  Try: 'as --help'
> as: Did you mean '-I'?
> make: *** [Makefile:26: tab.o] Error 1
>
> Of course the newly installer 'as' binary from llvm do not accept "--64"
> option.

Indeed this looks as if the host GCC is invoking the GCN 'as' (really:
'llvm-mc') as the host 'as'.  Compare:

    $ llvm-mc --64
    llvm-mc: Unknown command line argument '--64'.  Try: 'llvm-mc --help'
    llvm-mc: Did you mean '-I'?

Via your GCN '--with-build-time-tools=$DEST/bin', I suspect you've
installed the GCN 'as' ('llvm-mc') as '$DEST/bin/as', and similar for the
other LLVM tools?  That's not correct.  Instead, try installing those
into a separate directory, and then point to that one for GCN GCC
'--with-build-time-tools=[...]'.

Hope that helps.  If not, I'll look in more detail.


Grüße
 Thomas


> versions:
>
> - gcc: latest git master branch (24/07/2023)
>
> - llvm: 13.0.1 or 15.0.6
>
>
> Thanks for you advices.
>
> Patrick
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux