Sandia-OpenSHMEM / SOS

Sandia OpenSHMEM is an implementation of the OpenSHMEM specification over multiple Networking APIs, including Portals 4, the Open Fabric Interface (OFI), and UCX. Please click on the Wiki tab for help with building and using SOS.
Other
61 stars 53 forks source link

Error building with Intel Fortran Compiler (ifx) #1149

Closed ivan-pi closed 1 week ago

ivan-pi commented 1 week ago

I get a build error with the new Intel Fortran compiler (ifx):

$ CC=mpiicx CXX=mpiicpx FC=mpiifx ./configure --prefix=/home/ivan/.local/SOS --enable-mmap --enable-error-checking --enable-pmi-mpi
...
checking for Fortran libraries of mpiifx...  -loopopt=1 -L/opt/intel/oneapi/tbb/2021.11/env/../lib/intel64/gcc4.8 -L/opt/intel/oneapi/mpi/2021.11/lib -L/opt/intel/oneapi/mkl/2024.0/lib/ -L/opt/intel/oneapi/ipp/2021.5.2/lib/intel64 -L/opt/intel/oneapi/dpl/2022.3/lib -L/opt/intel/oneapi/dnnl/2022.0.2/cpu_dpcpp_gpu_dpcpp/lib -L/opt/intel/oneapi/dal/2021.5.3/lib/intel64 -L/opt/intel/oneapi/compiler/2024.0/lib -L/opt/intel/oneapi/clck/2021.5.0/lib/intel64 -L/opt/intel/oneapi/ccl/2021.11/lib/ -L/opt/intel/oneapi/compiler/2024.0/lib/clang/17/lib/x86_64-unknown-linux-gnu -L/opt/intel/oneapi/tbb/2021.11/env/../lib/intel64/gcc4.8/../lib/ -L/opt/intel/oneapi/mpi/2021.11/lib/../lib/ -L/opt/intel/oneapi/mkl/2024.0/lib/../lib/ -L/opt/intel/oneapi/dpl/2022.3/lib/../lib/ -L/opt/intel/oneapi/dnnl/2022.0.2/cpu_dpcpp_gpu_dpcpp/lib/../lib/ -L/opt/intel/oneapi/compiler/2024.0/lib/../lib/ -L/opt/intel/oneapi/ccl/2021.11/lib/../lib/ -L/usr/lib/gcc/x86_64-linux-gnu/9/ -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/ -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib64 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/ -L/lib/x86_64-linux-gnu/ -L/lib/../lib64 -L/lib/../lib/ -L/usr/lib/x86_64-linux-gnu/ -L/usr/lib/../lib64 -L/usr/lib/../lib/ -L/opt/intel/oneapi/tbb/2021.11/env/../lib/intel64/gcc4.8/ -L/opt/intel/oneapi/mpi/2021.11/lib/ -L/opt/intel/oneapi/ipp/2021.5.2/lib/intel64/ -L/opt/intel/oneapi/dpl/2022.3/lib/ -L/opt/intel/oneapi/dnnl/2022.0.2/cpu_dpcpp_gpu_dpcpp/lib/ -L/opt/intel/oneapi/dal/2021.5.3/lib/intel64/ -L/opt/intel/oneapi/compiler/2024.0/lib/ -L/opt/intel/oneapi/clck/2021.5.0/lib/intel64/ -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib -L/usr/lib/i386-linux-gnu -lifport -lifcoremt -limf -lsvml -lm -lipgo -lirc -lpthread -lirc_s -ldl
checking for dummy main to link with Fortran libraries... unknown
configure: error: in `/home/ivan/lrz/SOS-mmap-ifx':
configure: error: linking to Fortran libraries from C fails
See `config.log' for more details

Hopefully I've read the log correctly, but the failed test is this one:

configure:15714: checking for dummy main to link with Fortran libraries
...
configure:15793: result: unknown
configure:15810: error: in `/home/ivan/lrz/SOS-mmap-ifx':
configure:15812: error: linking to Fortran libraries from C fails
See `config.log' for more details

The failing configuration test appears to be searching for the Fortran main symbol (MAIN__). AFAIK it can be found in the compiler libraries folder:

$ ll /opt/intel/oneapi/compiler/latest/lib/for_main.o 
-rwxr-xr-x 1 root root 1312 Dez 13  2023 /opt/intel/oneapi/compiler/latest/lib/for_main.o*
$ nm /opt/intel/oneapi/compiler/latest/lib/for_main.o 
                 U for_rtl_finish_
                 U for_rtl_init_
0000000000000000 T main
                 U MAIN__

This error doesn't occur if I use FC=mpiifort (the old compiler).

If I just compile manually with ifx (without the oshfort wrapper), everything works as intended:

ivan@maxwell:~/shmem_demo$ ifx -c hello.f90 
ivan@maxwell:~/shmem_demo$ oshcc -o hello hello.o
/usr/bin/ld: /lib/x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
/usr/bin/ld: hello.o: in function `MAIN__':
hello.f90:(.text+0xc): undefined reference to `for_set_fpe_'
/usr/bin/ld: hello.f90:(.text+0x16): undefined reference to `for_set_reentrancy'
/usr/bin/ld: hello.f90:(.text+0x6c): undefined reference to `for_write_seq_fmt'
/usr/bin/ld: hello.f90:(.text+0x8a): undefined reference to `for_write_seq_fmt_xmit'
icx: error: linker command failed with exit code 1 (use -v to see invocation)
ivan@maxwell:~/shmem_demo$ oshcc -o hello hello.o /opt/intel/oneapi/compiler/latest/lib/for_main.o -lifcore
ivan@maxwell:~/shmem_demo$ oshrun ./hello 
Hello from 0 of 8
Hello from 1 of 8
Hello from 2 of 8
Hello from 3 of 8
Hello from 4 of 8
Hello from 5 of 8
Hello from 6 of 8
Hello from 7 of 8

(in this case one needs to manually add the Intel Fortran runtime libraries)

The file hello.f90 binds directly with the OpenSHMEM C API:

! hello.f90
implicit none

!
! Library Setup, Exit, and Query Routines
!
interface
    subroutine shmem_init() bind(c)
    end subroutine
    function shmem_my_pe() bind(c)
        use, intrinsic :: iso_c_binding, only: c_int
        integer(c_int) :: shmem_my_pe
    end function
    function shmem_n_pes() bind(c)
        use, intrinsic :: iso_c_binding, only: c_int
        integer(c_int) :: shmem_n_pes
    end function
    subroutine shmem_finalize() bind(c)
    end subroutine
end interface

integer :: mype, npes

call shmem_init

mype = shmem_my_pe()
npes = shmem_n_pes()
print '("Hello from ",I0," of ",I0)', mype, npes

call shmem_finalize

end
davidozog commented 1 week ago

Thanks for the report. Fortran was deprecated back in OpenSHMEM v1.4, so we haven't put much time into supporting the latest compilers.

However, I see a note about this in our configure.ac file:

#The oneAPI ifx compiler requires autoconf 2.70 to support AC_FC_WRAPPERS. If problems, please try ifort or updating autoconf:
#https://community.intel.com/t5/Intel-Fortran-Compiler/ifx-2021-1-beta04-HPC-Toolkit-build-error-with-loopopt/m-p/1184181         

Can you please verify that autoconf --version is less than 2.70, and are you able to update it? If so, I recommend starting with a whole new SOS build directory. If not, can you use ifort in the meantime?

I can reproduce this and fix it on an Aurora pre-release system (autoconf v2.69 by default) by building these from source: https://ftp.gnu.org/gnu/automake/automake-1.17.tar.gz https://ftp.gnu.org/gnu/autoconf/autoconf-2.72.tar.gz

ivan-pi commented 1 week ago

Thanks for the fast reply. Autoconf version is indeed below 2.70:

$ autoconf --version
autoconf (GNU Autoconf) 2.69

Otherwise I'm using Ubuntu 20.04.6 with Intel oneAPI 2024.0. (The default version for Ubuntu 22.04 is autoconf v2.71.)

Using ifort will be fine in the meantime. As shown above it isn't too difficult to use oshcc for final linking and just compile Fortran programs separately with ifx.

I saw the deprecation notice, but I thought I might report the issue just in case someone else encounters the same problem.

Given that the solution is known (upgrade Autoconf) I'll close this.