Development Tools For HPC Applications - PowerPoint PPT Presentation

Development Tools
1 / 42

  • Uploaded on
  • Presentation posted in: General

Development Tools For HPC Applications. Deniz Savas, Michael Griffiths Corporate Information and Computing Services The University of Sheffield Email, Outline. Building Applications Gnu compilers, g++, g++, g77

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

Download Presentation

Development Tools For HPC Applications

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Development tools for hpc applications

Development Tools

For HPC Applications

Deniz Savas, Michael Griffiths

Corporate Information and Computing Services

The University of Sheffield


Development tools for hpc applications


  • Building Applications

    • Gnu compilers, g++, g++, g77

    • Portland compilers, pg++, pgf77

      • Calling fortran from C and C from fortran

  • Using, Building and installing libraries

  • Using the make utility

  • The Eclipse Development Environment

  • Links



Invoking the compiler

Invoking the Compiler

  • Compiling FORTRAN Programs

    • pgf77 –o mycode [options] mycode.f

  • Compiling c/c++ Programs

    • pgcc –o mycode [options] mycode.c

Options used with both gnu and portland compilers

Options Used with Both gnu and Portland Compilers

Options used with portland compilers

Options Used with Portland Compilers

Options used with gnu compilers

Options Used with gnu Compilers

Linking a fortran application with nag libraries

Linking a FORTRAN application with NAG libraries

  • NAG best and most comprehensive library of numerical computing routines available

  • Mark20 on iceberg use –lnag and –lacml with the pgf77 or pgf90 compiler

  • Example

    • pgf90 myprogf90 –lnag –lacml

  • See comprehensive documentation at


The amd core math libraries acml

The AMD core math libraries (acml)

  • ACML consists of the following main components:

    • A full implementation of Level 1, 2 and 3 Basic Linear Algebra Subroutines (BLAS), with key routines optimized for high performance on AMD Opteron™ processors.

    • A full suite of Linear Algebra (LAPACK) routines. As well as taking advantage of the highly-tuned BLAS kernels, a key set of LAPACK routines has been further optimized to achieve considerably higher performance than standard LAPACK implementations.

    • A comprehensive suite of Fast Fourier Transforms (FFTs) in both single-, double-, single-complex and double-complex data types.

Using the acml libraries

Using the acml libraries

  • Building an application using the portland compilers

    • pgcc myapp.c -I/opt/acml-pg2.6.0/pgi64/include -L/opt/acml-pg2.6.0/pgi64/lib -lm –lacml

  • Building an application using the gnu compilers

    • gcc myapp.c -I/opt/acml-gnu2.6.0/gnu64/include -L/opt/acml-gnu2.6.0/gnu64/lib -lm –lacml

  • Examples

    • Documentation at

    • See

Building large applications

Building Large Applications

  • Typically compile program using

    • g++ –o myprog myprog.c –lm –g

  • Large programs

    • Modularized

    • Combine into a single executable

  • Building large applications is a multi step process

    • Compile each source file

    • Link resulting objects into an executable

Example multi source program 1

Example Multi Source Program:1

  • To build the Monte-carlo model, mc, we do the following.

    • g++ –c –g mc.cpp

    • g++ –c –g mc_system.cpp

    • g++ –c –g mc_particle.cpp

    • g++ –c -g mc_statistics.cpp

    • g++ –o mc mc.o mc_system.o mc_particle.o mc_statistics.o –lm

  • Note: only one of the sources has a main function

Example multi source program 2

Example Multi Source Program:2

  • If mc_system.cpp is edited we don’t need to recompile

    • mc_statistics, mc_particle or mc

  • Rebuild the application as follows

    • g++ –c –g mc_system.cpp

    • g++ –o mc mc.o mc_system.o mc_particle.o mc_statistics.o –lm

  • Automate these steps using make



  • Libraries are packaged collections of object files

    • Standard library contains printf… etc..

    • Maths library contains sin, cos etc..

  • Specify additional libraries with –l<name>

    • Only standard library is provided automatically

  • To compile a program with a maths library

    • g++ –c myprog myprog.c -lm

Building your own library

Building your own library

  • Benefits of building libraries

    • Share standardised functions with community

    • Separate functionality from detailed code

    • Good way of packing up your most useful routines and reusing them

  • How to build

    • Build libraries using

    • Named as lib<name>.a or lib<name>.so




  • Example my util library

    • g++ -c

      • Generates vec.o

    • g++ -c

      • Generates mat.o

  • Add object files to library

    • ar r myutillib.a vec.o

    • ar r mylibutil.a mat.o

  • Don’t use –l for your own libraries link as follows

    • g++ mylib.a –o myprog

Installing a library

Installing a Library

  • General steps

    • Download and uncompress source

    • Read documentation and build e.g. using configure

    • make and make install to build and install

    • Update your environment


      • Compile with -lMyNewLib

Using the make utility

Using the Make Utility

  • Used to compile and link programs

  • Makefile tells make how to perform link and compilation

  • Consists of rules with the following shape

    target …… : dependencies ……



Development tools for hpc applications


  • target name of file generated by a program

  • dependency used as input to create target

  • Target files are created whenever a dependency has changed

  • Commands can include

    • cc, CC, g++, f77, f95, mpf77

  • make

  • make clean

Make target

make target

  • Perform actions to obtain a target from a set of dependecies

  • Make checks when dependencies last updated

    target : dependencies


Simple makefile almost trivial

Simple Makefile ….. almost trivial!

game : game.o

gcc -o game game.o

game.o : game.c

gcc -c game.c

clean :

rm game game.o

Simple makefile

Simple Makefile

  • Generates executable called game from a single source file called game.c

  • Has a sequence of rules

    • game

      • Rule for building target executable file

    • game.o

      • Rule for building object files

    • clean

      • Rule for cleaning executable and object files

Make multiple source file project

Make multiple source file project

project : main.o data.o io.o

CC -o project main.o data.o io.o

main.o : main.c io.h data.h

CC -c main.c

data.o : data.c io.h data.h

CC -c data.c

io.o : io.c io.h

CC -c io.c

clean :

rm project main.o data.o io.o

Hints for building makefiles

Hints for Building Makefiles

  • Use # at the start of a line for comments

  • Use \ at the end of a line for line continuation

  • The line defining the rule that follows the definition of target and dependencies should normally be indented using a tab character and NOT whitespace characters

Makefile with implict rules for compiling a static library

Makefile with implict rules for compiling a static library

objects = vec.o vecpair.o mat.o

flags = -fast -tp k8-64

libmyutil.a : $(objects)

ar -r -o myutil.a $(objects) $(flags)

vec.o : vec.c

pgCC -c vec.c $(flags)

vecpair.o : vecpair.c

pgCC -c vecpair.c $(flags)

mat.o : mat.c

pgCC -c mat.c $(flags)

clean :

rm myutil.a $(objects)

Macros used with makefiles

Macros Used with Makefiles

$@Full name of the current target .

$<The source file of the current (single) dependency .

$*The part of a filename which matched a suffix rule.

$? The names of all the dependencies newer than the target separated by spaces.

$^ The names of all the dependencies separated by spaces, but with duplicate names removed.



  • Make uses a special target, named .SUFFIXES to allow you to define your own suffixes.

  • For example, the dependency line:.SUFFIXES: .foo .bar

    • tells make that you will be using these special suffixes to make your own rules.

Custom suffix rule

Custom Suffix Rule

  • Similar to how make already knows how to make a .o file from a .c file, you can define rules in the following manner: tr '[A-Z][a-z]' '[N-Z][A-M][n-z][a-m]' < $< > $@ .c.o: $(CC) $(CFLAGS) -c $<

  • The first rule allows you to create a .bar file from a .foo file. (Don't worry about what it does, it basically scrambles the file.)

  • The second rule is the default rule used by make to create a .o file from a .c file.

Makefile with suffix rule

Makefile with suffix rule

objects = blastest.o

flags = -fast -tp k8-64

mk4 : $(objects)

pgCC -o mk4 $(objects) $(flags)


pgCC -c $(flags) $<

clean :

rm mk4 $(objects)

Using eclipse

Using Eclipse

  • Advantages

  • Starting

Using eclipse advantages

Using Eclipse: Advantages

  • Open source

  • Available for many platforms

    • Windows requires cygwin and gnu development tools g++, g77, gdb, gmake, stl etc..

  • Use to develop wide variety of applications in a single development environment

    • e.g. c, c++, f77, f90, java

Eclipse features

Eclipse features

  • Perspectives for java, C/C++, debug and soon fortran development

  • Multiple projects

  • Browsers

    • Help, members, types, namespaces

  • Interactive debugging

  • Build projects using make or ant

Starting eclipse

Starting eclipse

  • Type “eclipse”

  • Requests directory for workspace

    • N.B. Sometimes necessary to start eclipse using

    • eclipse -vm $JAVA_HOME/jre/bin/java

Eclipse c c perspective layout

Eclipse C/C++ Perspective Layout

Creating a new project

Creating a new project

  • Managed make project

    • Helloworld

  • Standard make project

    • Hellotest

    • Provide a make file

Creating a standard make project

Creating a standard make project

Editing project settings

Editing Project Settings

Finishing steps

Finishing Steps

Debug window

Debug Window

Switch between perspectives

Debug windows

Debug stepping


Running the debugger

Running the Debugger

Setting and modifying breakpoint properties

Setting and Modifying Breakpoint Properties

Right click here to edit breakpoint properties

Right click here to toggle breakpoint





    • A useful tutorial on the eclipse cdt


    • Very useful reference section

  • Login