-fpic and -mcmodel=medium are not supported together

hai there,

after working on linux AMD 64b serves with the following parameters:

mpif90 > -r8 -fast -Mvect -tp k8-64 -DLinux -mcmodel=medium > -show

ln -s /opt/pgi/linux86-64/6.2/mpi/mpich/include/mpif.h mpif.h
pgf90 -fpic -L/opt/pgi/linux86-64/6.2/mpi/mpich/lib -r8 -fast -Mvect -tp k8-64 -DLinux -mcmodel=medium -lmpichf90 -lmpich -lpthread -lrt
rm -f mpif.h

when it is linking, we got the following error (where cavitat is the executable file desired):

pgf90-Error-Switches > -fpic and -mcmodel=medium are not supported together
make: *** [cavitat] Error 1

So the Portability Package is suitable for this situation because of its explanation on FAQ | PGI. Specially:

64-bit applications that use -mcmodel=medium may not link statically at all, and so the package may be necessary. -fpic runtime libs have a 32-bit offset, and sometimes need to reside near other runtime libs in the shared area of Linux program memory.

After installing the Portability Package (file: portability64-70.tar.gz) in the directory /usr/local/pgi and doing:

export LD_LIBRARY_PATH=/usr/local/pgi
make clean
make

the situation didn’t change, neither improve.
Please, any help would be great.

Many thanks in advanced.
Oriol

Hi Oriol,

What the document says is that you can link your program which compile with -mcmodel=medium and link with the shared library which compile with -fPIC.

If you remove the -fpic from the compile and link line, that should be fine. It should link with the shared library you point it to.

Hongyon

Hai Hongyon,

as you can see:

mpif90 -r8 -fast -Mvect -tp k8-64 -DLinux -mcmodel=medium -show

ln -s /opt/pgi/linux86-64/6.2/mpi/mpich/include/mpif.h mpif.h
pgf90 -fpic -L/opt/pgi/linux86-64/6.2/mpi/mpich/lib -r8 -fast -Mvect -tp k8-64 -DLinux -mcmodel=medium -lmpichf90 -lmpich -lpthread -lrt
rm -f mpif.h

the options used are: -r8 -fast -Mvect -tp k8-64 -DLinux -mcmodel=medium

but mpif90 automatically adds -fPIC.
So I’m wondering how to remove -fPIC and if so, if everything will work properly.

Many thanks in advanced,
Oriol

Hi Oriol,

Unfortunately the mpich script and libraries we provide compiled with -fpic. We add -fpic in the flags. The main reason we do that is that we can create .so files for MPI libraries.

You can find -fpic in mpif90 script and remove, that should be OK.

Hongyon

Hai Hongyon,

after doing the next command in the directory /opt:

grep -nR fPIC pgi* |less

I have found this:


pgicdk/INSTALL.txt:102:/opt/pgi/linux86-64/6.2/libso linux86-64 -fPIC libraries for

pgicdk-6.2-r5/linux86-64/6.2/bin/lin8664rc:43:switch -fPIC is


pgi/linux86-64/6.2/bin/lin8664rc:43:switch -fPIC is
pgi/linux86-64/6.2/bin/lin8664rc:46: set(FPIC=-fPIC)

pgicdk/linux86-64/6.2/bin/lin8664rc:43:switch -fPIC is
pgicdk/linux86-64/6.2/bin/lin8664rc:46: set(FPIC=-fPIC)

I suppose /opt/pgi/linux86-64/6.2/bin/lin8664rc and /opt/pgicdk/linux86-64/6.2/bin/lin8664rc should be modified.

Browsing them I can see:

switch -fPIC is
44 help(Generate position independent code)
45 helpgroup(opt)
46 set(FPIC=-fPIC)
47 set(COMPLIBSUBDIR=libso)
48 set(COMPLIBSO=$COMPBASE/$COMPSYS/$COMPVER/$COMPLIBSUBDIR)
49 set(COMPLIBOBJ=$COMPBASE/$COMPSYS/$COMPVER/$COMPLIBSUBDIR)
50 set(STDRPATHSO=-rpath $COMPBASE/$COMPSYS/$COMPVER/$COMPLIBSUBDIR)
51 append(CGARGS=-x 62 8);

So maybe I just have to put it in this way (correct?):

switch -fPIC is
44 help(Generate position independent code)
45 helpgroup(opt)
46 set(FPIC=)
47 set(COMPLIBSUBDIR=libso)
48 set(COMPLIBSO=$COMPBASE/$COMPSYS/$COMPVER/$COMPLIBSUBDIR)
49 set(COMPLIBOBJ=$COMPBASE/$COMPSYS/$COMPVER/$COMPLIBSUBDIR)
50 set(STDRPATHSO=-rpath $COMPBASE/$COMPSYS/$COMPVER/$COMPLIBSUBDIR)
51 append(CGARGS=-x 62 8);

So I tried it but it did not work properly.

But on the other hand and after browsing /opt/pgicdk/INSTALL.txt I can see:

102 /opt/pgi/linux86-64/6.2/libso linux86-64 -fPIC libraries for
103 -mcmodel=medium support

So now I am wondering that could be better to set this library: /opt/pgi/linux86-64/6.2/libso insted of removing fPIC, but I do not how. I have tried without success:

export LD_LIBRARY_PATH=/opt/pgi/linux86-64/6.2/libso; make clean ; make

and

mpif90 -r8 -fast -Mvect -tp k8-64 -DLinux -mcmodel=medium -o cavitat Main.o ReadInput.o ReadGrid.o ReportGrid.o Init.o CalcVelU_AllQuick_AB.o CalcVelV_AllQuick_AB.o CalcVelW_AllQuick_AB.o CalcVelU_buf.o CalcVelV_buf.o CalcVelW_buf.o CalcP.o CalcP_buf.o BcVel_Jet3D.o BcVel_buf.o CalcViscTurb.o CalcError.o CalcError_buf.o TInit.o CalcT.o BcT_Jet3D.o CalcTError.o CInit.o CalcC.o BcC_Jet3D.o CalcCError.o Reaccio.o Output.o WriteFile.o CalcTime_CPU.o Init_MesPasInt.o DataMP.o VelMP.o HaloMP.o AverageVelInit.o AverageVelWrite.o ReadPerturb.o VelInstant.o QAdjust.o rgrd1.o rgrd2.o rgrd3.o maloc3D.o coarsetofine.o finetocoarse.o addint3D.o resid3D.o compat3D.o relax3D.o slvsml3D.o copy3D.o mglin3D.o grid3D.o fill03D.o bcmg3D.o indexgen.o fi_buf_bc.o VelMP_buf.o WriteFile_buf.o > /opt/pgi/linux86-64/6.2/libso

Please, give an advice.

Many thanks,
Oriol

Hi Oriol,

Sorry, I have not have been cleared about updating the scripts.

Please do not change anything in the compilers directory. This will change the compilers behavior and can cause compiling or runtime error. What you need to change is the mpi scripts, they are in mpi/mpich/bin directory.

Hongyon

In

/opt/pgicdk-6.2-r5/linux86-64/6.2/mpi/mpich/bin/mpif90

changes done:

#LDFLAGSBASE=“-fpic”
LDFLAGSBASE="

"

It works.

M Thanks,

Oriol