- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MPI programs cannot be linked using the Fortran compiler flag -fast
When compiling and linking an MPI Fortran program using the compiler
flag -fast duplicate symbols are detected in the MPI library. This can be
demonstrated with a very small program like
program mpi_hello
implicit none
include "mpif.h"
integer :: ierror
call MPI_Init (ierror)
print *, 'hello world'
call MPI_Finalize (ierror)
end program mpi_hello
mpif90 -fast mpi_hello.f90
IPO: performing single-file optimizations
IPO: generating object file ipo_ifortV2sa0.o
/opt/hpmpi/lib/linux_ia64/libhpmpi.a(hpmpinitutil.o)(.sdata+0x10): multiple
definition of `mpi_debug_cont_'
ipo_ifortV2sa0.o(.bss+0x70): first defined here
ld: Disabling relaxation: it will not work with multiple definitions
Compiler flag -fast is a combination of -O3 -ipo -static. The problem is
caused by the combination of -ipo and -static. It does not occur with C
programs, i.e. C programs can be successfully compiled and linked using the -
fast flag.
Would this be considered an Intel Fortran Compiler bug?
When compiling and linking an MPI Fortran program using the compiler
flag -fast duplicate symbols are detected in the MPI library. This can be
demonstrated with a very small program like
program mpi_hello
implicit none
include "mpif.h"
integer :: ierror
call MPI_Init (ierror)
print *, 'hello world'
call MPI_Finalize (ierror)
end program mpi_hello
mpif90 -fast mpi_hello.f90
IPO: performing single-file optimizations
IPO: generating object file ipo_ifortV2sa0.o
/opt/hpmpi/lib/linux_ia64/libhpmpi.a(hpmpinitutil.o)(.sdata+0x10): multiple
definition of `mpi_debug_cont_'
ipo_ifortV2sa0.o(.bss+0x70): first defined here
ld: Disabling relaxation: it will not work with multiple definitions
Compiler flag -fast is a combination of -O3 -ipo -static. The problem is
caused by the combination of -ipo and -static. It does not occur with C
programs, i.e. C programs can be successfully compiled and linked using the -
fast flag.
Would this be considered an Intel Fortran Compiler bug?
Rigoberto
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I didn't try to answer before, as I'm not certain how helpful my reply would be. I'm guessing, from the few clues you give, that you are using some version of mpich.
If you're going to use -ipo this way, you would have had to build your mpi (both C and Fortran) libraries that way. I don't know that it would be worth the trouble, or how you would persuade driver vendors to attempt to support it. I'm not certain that you can expect inter-language linking to work with -ipo. If you make so many MPI calls that there could be any advantage in in-lining them, you have no chance for good performance, even on Infiniband.
We have seen difficulties with MPI linkage, using -static or -static-libcxa, even without attempting -ipo. We have sometimes been able to get better results by hand editing the command string which ifort passes to ld, but then sometimes it works fine without tinkering.
If you're going to use -ipo this way, you would have had to build your mpi (both C and Fortran) libraries that way. I don't know that it would be worth the trouble, or how you would persuade driver vendors to attempt to support it. I'm not certain that you can expect inter-language linking to work with -ipo. If you make so many MPI calls that there could be any advantage in in-lining them, you have no chance for good performance, even on Infiniband.
We have seen difficulties with MPI linkage, using -static or -static-libcxa, even without attempting -ipo. We have sometimes been able to get better results by hand editing the command string which ifort passes to ld, but then sometimes it works fine without tinkering.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for responding so quickly.
This problem was reported by one of our customers who is using HP MPI. I pretty much copied and pasted his problem report as is.
I wasn't clear on your answer, though. Are you saying that if HP MPI didn't use the "-ipo" flag when compiling their "C" code that there would be no benefit in using "-ipo" when compiling the user application or are you saying that you wouldn't expect the linking of the application and the HP MPI libraries to work? Hence, in the latter case, the linking error reported by the customer is normal? The customer did report that using the "-fast" flag works ok with the "C" compiler.
I have very little knowledge of Fortran, but I did try to reproduce this problem outside of HP MPI. I'm not sure if what I did is legit or not, but I will provide some code below which generates the same linking error.
Thank you very much for your help.
Rigoberto
# ls
compile.sh hello.f90 myinc.h mylib.c
compile.sh hello.f90 myinc.h mylib.c
# cat mylib.c
volatile int mpi_debug_cont = 0;
volatile int mpi_debug_cont_ = 0;
volatile int mpi_debug_cont = 0;
volatile int mpi_debug_cont_ = 0;
int myfunc() {
printf("inside myfunc() ");
}
printf("inside myfunc() ");
}
int myfunc_() {
myfunc();
}
myfunc();
}
# cat myinc.h
integer*4 MPI_DEBUG_CONT
common/mpi_debug_cont/MPI_DEBUG_CONT
save /mpi_debug_cont/
# cat hello.f90
program mpi_hello
include "myinc.h"
print *, 'hello world'
call myfunc()
end program mpi_hello
# cat compile.sh
cc -c mylib.c
ar -r libmylib.a mylib.o
ifort -fast hello.f90 -L`pwd` -lmylib -I.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page