[petsc-users] Which IDE you use to develop petsc application

Anton Popov popov at uni-mainz.de
Thu Nov 22 12:07:08 CST 2012


As promised, description files how to use Eclipse PTP for 
development/parallel debugging of PETSc applications are in the attachment.
I recommend installing debug versions of MPICH2, PETSc, parallel SDM 
debugger, and valgrind (if necessary) to /opt directory
Just follow the instructions.
Cheers,
Anton


On 11/18/12 4:43 PM, Fande Kong wrote:
> yeap, It sounds very interesting. Could you please give some 
> instructions on how to use eclipse link both Petsc and MPI?
>
> On Sat, Nov 17, 2012 at 3:08 AM, Anton Popov <popov at uni-mainz.de 
> <mailto:popov at uni-mainz.de>> wrote:
>
>     On 11/16/12 2:03 AM, Barry Smith wrote:
>
>             Because we are developing PETSc as a library that must be
>         portable to many users most people who develop the PETSc
>         libraries do not use a IDE.
>
>             For someone who is writing AN APPLICATION that uses PETSc
>         (especially an application with guis) it makes sense to use an
>         IDL to do that development. What you chose should depend on
>         what machine you develop on and what your are experienced with
>         or comfortable with. In the users manual we try to provide
>         some information on using PETSc from a variety of IDEs. We are
>         interested in collecting information on using PETSc from IDEs
>         and improving our documentation.
>
>     I managed Eclipse PTP on Mac OS (probably the same on Linux).
>     Provided that a debug (preferably valgrind-clean) version of
>     MPICH2 library with MPD process manager can be installed, Eclipse
>     Indigo can be easily configured for using PARALLEL SDM debugger
>     with PETSc applications.
>
>     If you're interested, I can send detailed configuration / setup
>     instructions.
>
>     Anton
>
>
>
>             Barry
>
>
>         On Nov 15, 2012, at 4:52 PM, Fande Kong <fd.kong at siat.ac.cn
>         <mailto:fd.kong at siat.ac.cn>> wrote:
>
>               Got it. Thanks.
>             On Thu, Nov 15, 2012 at 3:49 PM, Matthew Knepley
>             <knepley at gmail.com <mailto:knepley at gmail.com>> wrote:
>             On Thu, Nov 15, 2012 at 5:41 PM, Fande Kong
>             <fande.kong at colorado.edu <mailto:fande.kong at colorado.edu>>
>             wrote:
>
>                 Hi all,
>
>                 In order to improve development the efficient of the
>                 petsc application
>                 development, which IDE are you using?
>
>             Emacs+gdb.
>
>                Matt
>
>                 Regards,
>                 --
>                 Fande Kong
>                 Department of Computer Science
>                 University of Colorado at Boulder
>
>
>
>
>             --
>             What most experimenters take for granted before they begin
>             their
>             experiments is infinitely more interesting than any
>             results to which
>             their experiments lead.
>             -- Norbert Wiener
>
>
>
>
>             -- 
>             Fande Kong
>             ShenZhen Institutes of Advanced Technology
>             Chinese Academy of Sciences
>
>
>
>
>
>
> -- 
> Fande Kong
> ShenZhen Institutes of Advanced Technology
> Chinese Academy of Sciences
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121122/753ecdfa/attachment.html>
-------------- next part --------------

# configure

./configure \
CC= ... \  set here C compiler command (e.g. gcc)
CXX= ... \ set here C++ compiler command (e.g. g++)
F77= ... \ set here FORTRAN 77 compiler command (e.g. gfortran)
FC= ... \  set here FORTRAN 90 compiler command (e.g. gfortran)
CPPFLAGS='-I...' \ full path to valgrind include directory (if you have valgrind) 
--prefix= ... \ set installation directory (I recommend /opt/mpich2-debug)
--enable-f77 \
--enable-fc \
--enable-cxx \
--enable-threads=runtime \
--enable-g=dbg,mem,meminit \
--enable-debuginfo \
--enable-shared \
--enable-sharedlibs="..." \ osx-gcc for Mac OS, gcc for Linux
--enable-fast=none \
--with-thread-package=pthreads \
--with-pm=mpd

# build

make all

# install

sudo make install

# update the path in .bash_profile (.bashrc on Linux)

export PATH=$PATH:/opt/mpich2-debug/bin

# create file .mpd.conf in the home directory

# put the following string in this file

MPD_SECRETWORD=mr45-j9z

##################################################################
# IMPORTANT!!!
# when using debug version you should make sure that 
# mpiexec doesn't complain about mpd
# open a separate console and type the following command there

mpd &

# do not close the console while you're using mpiexec
# otherwise it cannot be guaranteed that mpiexec won't complain
##################################################################


# after installation check if everything works, type in the console:

mpicc -show
mpicxx -show
mpif90 -show 

# compile and run C and FORTRAN hello_world examples

mpicc mpi_hello.c
mpiexec -np 4 ./a.out

mpif90 mpi_hello.f
mpiexec -np 4 ./a.out

-------------- next part --------------

#====================================
# Configuring debug version (example):
#====================================

NOTE: use mpi compiler that you've installed in previous step 
Read the file 01_install_mpich2.txt

./configure \
--prefix= ... \ set installation path here (I recommend /opt/petsc/petsc-int32-debug)
--download-f-blas-lapack=1 \
--with-debugging=1 \
--with-valgrind=1 \ request valgrind (if you have one)
--with-valgrind-dir= ... \ set paths to valgrind root directory (if you have one) 
--COPTFLAGS="-g -O0" \
--FOPTFLAGS="-g -O0" \
--CXXOPTFLAGS="-g -O0" \
--with-c++-support=1 \
--with-fortran=1 \
--with-fortran-kernels=1 \
--with-large-file-io=1 \
--with-mpi-compilers=1 \
--with-cc=mpicc \
--with-cxx=mpicxx \
--with-fc=mpif90 \
--with-shared-libraries=1 \
--download-ml=1 \
--download-hypre=1 \
--download-blacs=1 \
--download-scalapack=1 \
--download-metis=1 \
--download-parmetis=1 \
--download-mumps=1 \
--download-superlu_dist=1

Add more (less) packages (options) if you like

make

sudo make install

# After installation, modify .bash_profile (.bashrc) file to point out to valid petsc directory.

export PETSC_DIR=/opt/petsc/petsc-int32-debug
-------------- next part --------------

Installation of Eclipse on OSX for parallel debugging

NOTE: On Linux just use appropriate version of Eclipse and PTP Proxy

===================================
Eclipse Installation (Mac OS only):
===================================

0. Download and unpack into Applications folder: 
      eclipse-parallel-indigo-SR1-incubation-macosx-cocoa-x86_64.tar.gz

1. Go to eclipse folder and create file eclipse.command, put the string inside:
      /Applications/eclipse/eclipse &

2. Change permissions, execute in console chmod 755 eclipse.command

3. Drag eclipse.command to desktop

4. Right click desktop icon -> Get Info -> Name & Extension, change to Eclipse (optional)

5. Change desktop icon to original Eclipse logo with Command+c, Command+v (optional)

=================
Install PTP Proxy
=================

- Download PTP Proxy from this website: 
http://www.eclipse.org/ptp/downloads_5_0.php

or directly, using the link:
http://www.eclipse.org/downloads/download.php?file=/tools/ptp/updates/indigo/ptp-proxy-5.0.7.zip

- unpack & cd to the following folder:
org.eclipse.ptp.macosx.x86_5.0.7.201203231315

- build Scalable Debug Manager (SDM)
sh BUILD

- install executable to /opt
sudo cp -r bin/ /opt/sdm-bin

More info is found here (eclipse help):
Parallel Tools Platform (PTP) User Guide 
	-> PTP - Prerequisites
		-> http://wiki.eclipse.org/PTP/release_notes/5.0
			-> Install optional PTP server components

=====================

Also helpful: 
   Eclipse->Preferences->General->Editors, check box Show line numbers
                       ->C/C++->Editor, uncheck box Highlight inactive code
-------------- next part --------------

=========================================
Configuring and building Eclipse project:
=========================================

0. Start Eclipse by double clicking desktop icon

1. Right click in Project Explorer -> New -> Project -> C/C++ -> Makefile Project with Existing Code

2. Click Next and set Project Name and location of project ROOT! directory (not just src), click Finish

3. Right click on your project in the Explorer, select Properties -> C/C++ Build

4. Builder Settings tab -> Build directory -> File System, select full path path to project source directory

5. Behaviour tab -> Build (incremental build) set command to buld yor application (e.g. all), 
   set Clean to clean the application (e.g. distclean)

6. Unfold C/C++ Build -> Settings -> Binary Parser (select Mach-O 64 Parser on Mac OS, On Linux select appropriate option)

7. Add full paths to header files used in your project.

   Petsc applications would require setting:
      /opt/mpich2-debug/include
      /opt/petsc/petsc-int32-debug/include

    Each path can be added as follows:
    In the project properties select Path and Symbols -> Includes -> Add
    Place directory path here, also check boxes:
       Add to all configurations 
       Add to all languages

8. Build your application by clicking Hammer icon

=========================================
-------------- next part --------------

======================================
Running and debugging Eclipse project:
======================================

0. Run -> Run configurations -> double click C/C++ application -> Main tab -> Browse,
   select full path to application executable (e.g. in the /bin directory) 

1. Swich to Arguments tab -> Program aruments, 
      insert all command line options that you want to use with your application
   Arguments tab -> Working directory -> File System, 
      select full path to working directory (e.g. /tests, to avoid copying input files) 

2. Switch to debugging perspective: Window -> Open Perspective -> Debug, then click the bug icon 

======================================
-------------- next part --------------

==================================
Configure & start Resource Manager
==================================

- Window -> Open Perspective -> Other -> Parallel Runtime 
- right click Resource Manager tab Add Resource Manager -> MPICH2
- click finish  
- right click on MPICH2 at Local manager -> Start Resource Manager

If there is an error at this stage, most likely mpd is not running,
as usual, just open console and type mpd & (don't close the console afterwards)

More info is found here (eclipse help):
Parallel Tools Platform (PTP) User Guide 
	-> Resource Managers
		-> Configuring Resource Managers

==================================
Configure Parallel Debug
==================================

Run -> Debug Configurations -> Parallel Application

- Resources tab -> Resource manger -> select MPICH2 at local, 
	set number of processors
- Application tab -> Parallel Project (enter project name), 
	Application program (set full path to application executable)
- Arguments tab -> Parallel program arguments (enter application command line options), 
	Directory (set full path to working directory (e.g. tests))
- Debugger tab -> Path to debugger executable (/opt/sdm-bin/sdm)

- lunch debugging session, by clicking Debug button

NOTE: Resource manager must be started before the debug launch 
goto Parallel Runtime perspective and start it (see "Configure & start Resource Manager")

More info is found here (eclipse help):
Parallel Tools Platform (PTP) User Guide 
	-> Parallel Debugging
		-> Creating a Debug Launch Configuration
and here:
		-> Running Parallel Programs
	
==================================
Debug your application
==================================

... 

More info is found here (eclipse help):
Parallel Tools Platform (PTP) User Guide 
	-> Parallel Debugging


==================================
-------------- next part --------------
/* C Example */
#include <stdio.h>
#include <mpi.h>


int main(int argc, char *argv[])
{
	int rank, size;

  MPI_Init (&argc, &argv);	/* starts MPI */
  MPI_Comm_rank (MPI_COMM_WORLD, &rank);	/* get current process id */
  MPI_Comm_size (MPI_COMM_WORLD, &size);	/* get number of processes */
  printf( "Hello world from process %d of %d\n", rank, size );
  MPI_Finalize();
  return 0;
}
-------------- next part --------------
c  Fortran example
      program hello
      include 'mpif.h'
      integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)
      call MPI_INIT(ierror)
      call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierror)
      call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierror)
      print*, 'node', rank, ': Hello world'
      call MPI_FINALIZE(ierror)
      end


More information about the petsc-users mailing list