We have a user, who is running CAM, we are compiling with openmpi/1.3.2 built with pgi/8.0.
This user increased his problem size such that when he linked we would get errors about: “relocation truncated to fit: R_X86_64_PC32”
Normally we solved this problem by adding -mcmodel=medium at compile and link.
In this case though, the code would compile with the ‘debug’ options on, those options were:
-g -Ktrap=fp -Mrecursive -Mbound
In our case we found that adding -Mrecursive to the optimized flags, allowed the code to compile.
What we want to know is, what did Mrecursive do to effect this (I was surprised it worked), as it was not needed before the problem size was increased.
Any insight into what is going on would be helpful.
My best guess is that the user didn’t compile their library with “-fpic”. The “R_X86_64_PC32” relocation is used with function calls. So if you are calling a function in static library from within a mcmodel=medium program, the distance to the function is too far. Compiling the libraries with -fpic is the only work-around until the large memory model is supported.
As to why “-Mrecursive” works, again just a guess, but -Mrecursive will place local variables on the heap instead of the stack. So if the user has a very large local static array, by moving it to the heap, the data size may have gotten small enough the -mcmodel=medium is no longer required.
I understood from previous post that compiling libraries with “-fpic” is the only work-around. Can you plz elaborate on how to compile the libraries with “-fpic” (Sorry, I’m not a tech savvy). Or is there is any other solution to fix this.
Shared libraries (.so) are required to be built with position independent code (-fpic) so what you should do is simply add “-Bdynamic” to your link. If you absolutely need to statically link your libraries, the you’ll need to build your own MPICH (See http://www.pgroup.com/resources/mpich/mpich127_pgi90.htm) and add “-fpic” to each of the “FLAG” variables.
Thanks for your suggestion. Now I’m trying to build MPICH with “-fPIC”. While doing so I got stuck with an error message as follow:
** Testing if Fortran77 application can be linked with logging library
/home/mark/Download/mpich-1.2.7p1/bin/mpif77 -I/home/mark/Download/mpich-1.2.7p1/include -c fpi.f
/home/mark/Download/mpich-1.2.7p1/bin/mpif77 -O2 -fPIC -o fpilog fpi.o -L/home/mark/Download/mpich-1.2.7p1/lib -lfmpich -llmpe -lmpe -lm
** Fortran77 application can be linked with logging library
** Testing if Fortran77 application can be linked with graphics library
/home/mark/Download/mpich-1.2.7p1/bin/mpif77 -I/home/mark/Download/mpich-1.2.7p1/include -c fxgraphics.f
/home/mark/Download/mpich-1.2.7p1/bin/mpif77 -O2 -fPIC -o fxgraphics fxgraphics.o -L/home/mark/Download/mpich-1.2.7p1/lib -lmpe -lX11 -lm
** Fortran77 application can be linked with graphics library
Copying SLOG2SDK's lib
Copying SLOG2SDK's doc
Copying SLOG2SDK's logfiles
Creating SLOG2SDK's bin
Installed SLOG2SDK in /home/mark/Download/mpich-1.2.7p1
/home/mark/Download/mpich-1.2.7p1/sbin/mpeuninstall may be used to remove the installation
Installed MPE in /home/mark/Download/mpich-1.2.7p1
/home/mark/Download/mpich-1.2.7p1/sbin/mpeuninstall may be used to remove the installation
Finished making MPE Profiling Libraries
make --no-print-directory mpi-utils
pgcc -O2 -Msignextend -V -fPIC -DUSE_SOCKLEN_T -DUSE_U_INT_FOR_XDR -c /home/mark/Download/mpich-1.2.7p1/mpid/server/serv_p4.c -I./ -o serv_p4.o
pgcc 9.0-4 64-bit target on x86-64 Linux -tp penryn-64
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2009, STMicroelectronics, Inc. All Rights Reserved.
PGC/x86-64 Linux 9.0-4
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2009, STMicroelectronics, Inc. All Rights Reserved.
PGC-S-0137-Incompatible prototype declaration for function getline (/home/mark/Download/mpich-1.2.7p1/mpid/server/serv_p4.c: 204)
PGC/x86-64 Linux 9.0-4: compilation completed with severe errors
make[2]: *** [serv_p4.o] Error 2
bin/mpicc -o /home/mark/Download/mpich-1.2.7p1/bin/mpichversion /home/mark/Download/mpich-1.2.7p1/util/mpichversion.c
rm -f /home/mark/Download/mpich-1.2.7p1/bin/mpireconfig.dat
rm -f /home/mark/Download/mpich-1.2.7p1/bin/mpireconfig.dat
creating util/mympiinstall
The error “Incompatible prototype declaration for function getline” means that some how the getline function is already defined with a different, incompatible, prototype. To determine where this second prototype is coming from, compile with “-P” so only the pre-processing step is performed, and search the resulting “.i” file for instances of “getline”.