May 09 2015

Compiling PETSc on Windows with VC++/Intel Compilers

Category: semihozmen @ 20:24

Most recent version of this post is in here!
Installation:

Download cygwin
Install cygwin with
gcc,g++(required for making local Petsc tools sowing and c2html )
python
flex (required for making local Petsc tools sowing and c2html )
make
git
Get Petsc source
checkout petsc by git
git clone https://bitbucket.org/petsc/petsc.git
Optional:
git clone https://bitbucket.org/petsc/petsc.git petsc_bddc
if anything to merge:
git fetch && git checkout stefano_zampini/pcbddc-primalfixes
OR get Petsc tarball and untar to cygwin/petsc folder (use tar in cygwin!)
Install Microsoft Visual C++ 2012/2013 (I prefer 2010 since it has MPI Debugger)
Install Microsoft MPI on a path without spaces like C:\MSMPI
Open Cygwin.bat and add
For 32 bit : CALL “%VS110COMNTOOLS%\vsvars32.bat”
For 64 bit : CALL “%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat” amd64
Open Developer Command Prompt for 2012 (just type in start)
Call Cygwin.bat: D:\cygwin\cygwin64\Cygwin.bat
Test if cl Test.cpp
in cygwin shell, go to petsc folder: (red means does not work)
./configure –with-cc=’win32fe cl’ –with-cxx=’win32fe cl’ –with-fc=0 –download-f2cblaslapack –with-mpi-dir=/cygdrive/c/MSMPI
./configure –with-cc=’win32fe cl’ –with-cxx=’win32fe cl’ –with-fc=0 –download-f2cblaslapack –with-mpi-include=/cygdrive/c/MSMPI/Inc/ –with-mpi-lib=\”[/cygdrive/c/MSMPI/Lib/amd64/msmpi.lib,/cygdrive/c/MSMPI/Lib/amd64/msmpifec.lib]\”
./configure –with-cc=’win32fe cl’ –with-cxx=’win32fe cl’ –with-fc=0 –download-f2cblaslapack –with-mpi-include=/cygdrive/c/MSMPI/Inc/ –with-mpi-lib='[/cygdrive/c/MSMPI/Lib/amd64/msmpi.lib,/cygdrive/c/MSMPI/Lib/amd64/msmpifec.lib]’
Cross your fingers and wait
If fails
“rm -rf /home/semih/petsc/arch-mswin-c-debug/”
For git users, clean the git repo with:
git reset –hard
git clean -f -d -x
and then rerun configure
make PETSC_DIR=/home/sozmen/petsc PETSC_ARCH=arch-mswin-c-debug all
make PETSC_DIR=/home/sozmen/petsc PETSC_ARCH=arch-mswin-c-debug test
make PETSC_DIR=/home/sozmen/petsc PETSC_ARCH=arch-mswin-c-debug streams NPMAX=4
You are done with it….

Usage:
export PETSC_DIR=~/petsc
export PETSC_ARCH=arch-mswin-c-debug
make ex2
make runex2
Update:
git pull
Once updated, you will usually want to rebuild completely
./$PETSC_ARCH/conf/reconfigure-$PETSC_ARCH.py
make

Additional options:

–with-openmp
–with-shared-libraries
–useThreads=0
–with-debugging=no
–with-pcbddc
Correct the error in bddcprivate.c @3208

Use for any problem with MKL;
https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/
Hypre:
– Download from http://acts.nersc.gov/hypre/
– Compile it! (MISSING PART: Compilation in Windows required!)
– Or you may use binaries from “Petsc For Windows”
Usage:
–with-hypre-include=/cygdrive/d/WorkDir/hypre-2.9.0b/src/hypre/include
–with-hypre-lib=/cygdrive/d/WorkDir/hypre-2.9.0b/src/hypre/lib/HYPRE.lib
BLAS/LAPACK:
– You need to install Intel MKL
– Usage:
–with-blas-lapack-dir=/cygdrive/d/HardLinks/PETSc/Intel2013/mkl/lib/intel64
ScaLAPACK:
– You need to install Intel MKL with cluster support
– Usage:
–with-scalapack-include=/cygdrive/d/HardLinks/PETSc/Intel2013/mkl/include
–with-scalapack-lib=\”[/cygdrive/d/HardLinks/PETSc/Intel2013/mkl/lib/intel64/mkl_scalapack_lp64.lib,/cygdrive/d/HardLinks/PETSc/Intel2013/mkl/lib/intel64/mkl_blacs_msmpi_lp64.lib]\”
METIS-PARMETIS:
-Download from http://glaros.dtc.umn.edu/gkhome/metis/parmetis/download
– Compile it! (MISSING PART: Compilation in Windows required!)
– Or you may use binaries from “Petsc For Windows”
-Usage:
–with-metis-include=/cygdrive/d/WorkDir/OtherPackages/parmetis-4.0.3_install/include
–with-metis-lib=/cygdrive/d/WorkDir/OtherPackages/parmetis-4.0.3_install/lib/metis.lib
–with-parmetis-include=/cygdrive/d/WorkDir/OtherPackages/parmetis-4.0.3_install/include
–with-parmetis-lib=\”[/cygdrive/d/WorkDir/OtherPackages/parmetis-4.0.3_install/lib/parmetis.lib,/cygdrive/d/WorkDir/OtherPackages/parmetis-4.0.3_install/lib/metis.lib]\”

Using Intel Compilers Instead of VSC

Append following alias to .bash_profile
alias ifort=’ifort -Qlocation,link,”$VCINSTALLDIR/bin”‘
alias icl=’icl -Qlocation,link,”$VCINSTALLDIR/bin”‘
Append following to icl.cfg
$VCINSTALLDIR/bin
mv /usr/bin/link.exe /usr/bin/cygwin_link.exe

Run Intel 64 bit Developer Command Prompt
Run Cygwin.bat
Get petsc source files etc.

Failes with;
– ifort could not find mpif.h !!!!
-Solution: copy C:\MSMPI\Inc\amd64\mpifptr.h to C:\MSMPI\Inc

./configure –with-cc=’win32fe icl’ –with-cxx=’win32fe icl’ –with-fc=’win32fe ifort’ –with-blas-lapack-dir=/cygdrive/c/MKL/lib/intel64 –with-hypre-include=/cygdrive/c/EXTRLIBS/include/HYPRE –with-hypre-lib=/cygdrive/c/EXTRLIBS/lib/HYPRE.lib –with-scalapack-include=/cygdrive/c/MKL/include –with-scalapack-lib='[/cygdrive/c/MKL/lib/intel64/mkl_scalapack_lp64.lib,/cygdrive/c/MKL/lib/intel64/mkl_blacs_msmpi_lp64.lib]’ –with-metis-include=/cygdrive/c/EXTRLIBS/include/parametis –with-metis-lib=/cygdrive/c/EXTRLIBS/lib/metis.lib –with-parmetis-include=/cygdrive/c/EXTRLIBS/include/parametis –with-parmetis-lib='[/cygdrive/c/EXTRLIBS/lib/parmetis.lib,/cygdrive/c/EXTRLIBS/lib/metis.lib]’ –with-mpi-include=/cygdrive/c/MSMPI/Inc/ –with-mpi-lib='[/cygdrive/c/MSMPI/Lib/amd64/msmpi.lib,/cygdrive/c/MSMPI/Lib/amd64/msmpifec.lib]’ –with-shared-libraries –useThreads=0

–with-openmp
————————————————————————————————————–

fp.c^M
C:\CYGWIN~1\PETSC-~1.2\src\sys\error\fp.c(425): error: expression must have arithmetic or pointer type^M
if (feclearexcept(FE_ALL_EXCEPT)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,”Cannot clear floating point exception flags\n”);^M
^^M
^M
C:\CYGWIN~1\PETSC-~1.2\src\sys\error\fp.c(436): error: expression must have arithmetic or pointer type^M
if (fesetenv(FE_DFL_ENV)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,”Cannot disable floating point exceptions”);^M

/cygdrive/c/cygwin_cache/petsc-3.4.2/arch-mswin-c-opt/include/petscconf.h.h
and remove the lines related to PETSC_HAVE_FENV_H
————————————————————————————————————–

Reconfigure PETSc to use ParMetis.
1 linux-c-debug/conf/reconfigure-linux-c-debug.py
-PETSC_ARCH=linux-parmetis
-download-metis -download-parmetis
2 PETSC_ARCH=linux-parmetis make
3 PETSC_ARCH=linux-parmetis make test

python ./config/builder2.py check
$PETSC_DIR/src/snes/examples/tutorials/ex5.c

put breakpoint PetscError() @ ./src/sys/error/err.c

Be Sociable, Share!

Comments are closed.