66
Overview for Application Programmer The Cactus Team Albert Einstein Institute [email protected]

Overview for Application Programmer The Cactus Team Albert Einstein Institute [email protected]

Embed Size (px)

Citation preview

Page 1: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Overview for Application Programmer

The Cactus Team

Albert Einstein [email protected]

Page 2: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Outline of OverviewOutline of Overview

Required software and supported architectures Cactus Computational Toolkit Application Thorn API (Infrastructure Thorn API) Getting the code Configurations and compilation Running Testing

Page 3: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Required SoftwareRequired Software

For Cactus Flesh and Computational Toolkit: Perl 5.0 www.perl.org GNU make www.gnu.org C/C++ e.g. GNU compilers www.gnu.org

For default parallel driver thorn (CactusPUGH/PUGH): MPI e.g. MPICH www-unix.mcs.anl.gov/mpi/

For Fortran thorns: Fortran 77 e.g. g77 www.gnu.org Fortran 90 e.g. Vast90 www.psrv.com/lnxf90.html

Recommended for checkout: CVS www.gnu.org

Page 4: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Supported ArchitecturesSupported Architectures

In principle, Cactus runs on any architecture: Flesh written in ANSI C Autoconf/Perl deal with machine specific features Just add Known Architectures files for some new

machines/compilers Usual problems with portability of C++ thorns (e.g. templates)

Supported on all architectures we have access to Laptops Workstations Clusters Supercomputers

Page 5: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Supported ArchitecturesSupported Architectures

Machines Operating Systems Processors

PC Linux IA32, IA64PC Windows NT (Cygwin) IA32

Compaq OSF/Linux AlphaCray T3E Unicos Alpha

HP Exemplar (V2500) HP-UX PA8500Macintosh Linux PowerPCNEC SX-5 SuperUX

Sun Solaris Sparc II,Sparc IIIIBM SP2 AIX RS6000

SGI Origin, O2 Irix R8000, R10000, R12000Hitachi SR8000-F1 HIUX-MP PowerPC

Page 6: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Cactus Computational ToolkitCactus Computational ToolkitCactusBase

Boundary, IOUtil, IOBasic, CartGrid3D, IOASCII, Time

CactusBench BenchADM

CactusConnect HTTPD, HTTPDExtra

CactusExample WaveToy1DF77, WaveToy2DF77

CactusElliptic EllBase, EllPETSc, EllSOR,

EllTest

CactusPUGH Interp, PUGH, PUGHReduce,

PUGHSlab

CactusPUGHIO IOFlexIO, IOHDF5, IsoSurfacer

CactusTest TestArrays, TestCoordinates,

TestInclude1, TestInclude2, TestComplex, TestInterp, TestReduce

CactusWave IDScalarWave, IDScalarWaveC,

IDScalarWaveCXX, WaveBinarySource, WaveToyC, WaveToyCXX, WaveToyF77, WaveToyF90, WaveToyFreeF90

external IEEEIO, RemoteIO,

TCPXX,jpeg6b

Page 7: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

In DevelopmentIn Development

AlphaThorns Cart3d IOHDF5 Renderer SimpleWorm isosurfacer MDS TestFunctions

BetaThorns IOASCIIStream IOHDF5Util IOJpeg IOPanda IOStreamedHDF5 Socket

Page 8: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Application Thorn APIApplication Thorn API

Flesh-Thorn and Thorn-Thorn contracts: Cactus data types Configuration files for each thorn detailing their requirements and

capabilities– parameters, variables, scheduling, functions

Cactus grid hierachy variables (Parallel) Driver API IO API Interpolation/Reduction API Errors, warnings and info API Utilities

Page 9: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Cactus Data TypesCactus Data Types

Variables and parameters shared between thorns and Flesh declared using Cactus data types

Ensures portability and consistency between platforms

Size of basic types chosen at compile time (can easily run different precisions)

Data Type Size (bytes)CCTK_INT (4)

CCTK_REAL (8)CCTK_COMPLEX (16)

CCTK_INT2 2CCTK_INT4 4CCTK_INT8 8

CCTK_REAL4 4CCTK_REAL8 8CCTK_REAL16 16

CCTK_COMPLEX8 4CCTK_COMPLEX16 8CCTK_COMPLEX32 32

CCTK_CHAR 1

Page 10: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Thorn Configuration FilesThorn Configuration Files

Each thorn contains three configuration (ccl) files, which detail the thorn’s interface with the Flesh and other thorns

These files are parsed (Perl) during compilation by the CST (Cactus Specification Tool), which generates wrappers, argument lists (Fortran!), parameter lists, a run list etc.

interface.ccl Variables, inheritance

param.ccl Parameters

schedule.ccl Routines, run order

Page 11: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

interface.cclinterface.ccl

Implementation: the name of this contract with the fleshInherits, friends: access variables from other thorns

Variable groups: my variablesScope: private, restricted, global

Type: grid function, grid array, grid scalarData type: int, real, complex, etc.

and Timelevels, Dimension, Ghostzones, Size, Distribution, ...

What does my thorn “do”

What are my thorns grid variables?

What variables do I need from other thorns?

What variables am I going to make available to other thorns?

Page 12: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Example: interface.cclExample: interface.cclImplements: matrix_add

Inherits: matrix

public:

real matrices type=GF dim=2 timelevels=2

{

matrix1, matrix2

} “Matrices to add together”

private:

int tempvals type=ARRAY dim=1 distrib=CONSTANT size=arraysize

{

tta1,tta2

} “Temporary arrays for matrix addition”

Page 13: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

param.cclparam.ccl

Uses, Extends: parameters from other thorns Scope: private, protected, public

Data type: keyword, string, boolean, int, real, etc. Ranges and descriptions

Default valueSteerable

What are the parameters for my thorn?

What are their ranges? Are they steerable?

What parameters do I need from other thorns?

Which of my parameters should be available for other thorns?

Page 14: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Example: param.cclExample: param.ccl

Shares: wavetoy

USES timestep

EXTENDS keyword initial_data

{

“Cylindrical” :: “3D data with cylindrical symmetry”

}

Private:

real wavespeed “Physical wave speed”

{

0:1 :: “Only subsonic speeds allowed”

} 0.1

Page 15: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Parameter FilesParameter Files

!DESC “Example parameter file”

ActiveThorns = “pugh pughreduce cartgrid3d wavetoyf77 ioutil ioascii”

(only these thorns are used)

#Parameters for my rundriver::global_nx = 30 (restricted: implementation)

wavetoy::initial_data = “gaussian” (restricted: implementation)

io::out_every = 5 (restricted: implementation)

ioascii::out1d_vars = “wavetoy::phi” (private: thorn)

Page 16: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Parameters at RuntimeParameters at Runtime

Extensive runtime checking of parameters demanded by users!!

Parameters must lie in designated ranges Reports parameters which are not defined Query parameters

cactus_exe -o <parameter name> cactus_exe -O cactus_exe -Ov

Used by parameter file GUIs, remote monitoring

Page 17: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Steerable ParametersSteerable Parameters

Parameters designated “steerable” in param.ccl can have their values changed during a simulation

Before designating a parameter as steerable, must think whether it really makes sense, and add the infrastructure for changing the parameter (for example, check it each timestep)

Examples: Output: how often to output, what variables to output, output directory Timestep ?

Steerable parameters can be changed using remote steering thorns, after restarting from a checkpoint file, or in the future from a command line interface

Page 18: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Program FlowProgram Flow

ParameterFile

Thorn C

Thorn B

Thorn A

ParameterParser

ThornActivator

Scheduler

DriverThorn

Flesh

Page 19: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

schedule.cclschedule.ccl

Schedule at <time bin>

Schedule before or after other routines

Schedule while some condition is true

Schedule routine aliases for implementations

Assign Storage for grid variables

Triggers for analysis routines

When and how should my thorns routines be run?

How do my routines fit in with routines from other thorns?

Which variables should be synchronized on exit?

Page 20: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Example: schedule.cclExample: schedule.cclSTORAGE: mainvars, otherthorn::maxvals

if (doit == 1)

{

schedule MyThorn_Init at INITIAL as InitGeneric before YourThorn_Init

{

LANG: C

STORAGE: tempvars

} “Initialization routine, sets up main variables ready for evolution”

}

while (keepgoing==1)

{

schedule MyThorn_EvolStep at EVOL as StepTwo after StepOne

{

LANG: Fortran

SYNC: evolvemaxwell::mainvars

} “Do a second evolution step if necessary”

}

Page 21: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Scheduling Time BinsScheduling Time Bins

Cactus provides a number of default time bins. Thorns can in addition define their own groups of routines for more control.

Time Bin PurposeCCTK_STARTUP Function registration

CCTK_PARAMCHECK Check consistency of parametersCCTK_BASEGRID Coordinates etcCCTK_RECOVER Recover from checkpoint file

CCTK_INITIAL Dealing with initial dataCCTK_POSTINITIAL Post processing of initial data

CCTK_CPINITIAL Checkpointing of initial dataCCTK_PRESTEP Before the evolution step

CCTK_EVOL The main evolution stepCCTK_POSTSTEP After the evolution step

CCTK_CHECKPOINT Checkpoint simulationCCTK_ANALYSIS Analysis data (for output)

CCTK_TERMINATE Termination routines

Page 22: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Analysis Time BinAnalysis Time Bin

The time bin CCTK_ANALYSIS is special Routines scheduled here are only called by the scheduler if

output is required for one of their “triggers” e.g. Constraint evaluation

schedule ADMConstraints at CCTK_ANALYSIS

{

LANG: Fortran

STORAGE: admconstraints

TRIGGERS: admconstraints

} “Calculate the constraints for the ADM equations”

Page 23: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Example Run ListExample Run List

----------------------------------------------------------- Startup routines CartGrid3D: Register GH Extension for

GridSymmetry CartGrid3D: Register coordinates for the Cartesian grid PUGH: Startup routine. IOUtil: Startup routine IOASCII: Startup routine IOBasic: Startup routine WaveToyF77: Register banner

Parameter checking routines CartGrid3D: Check coordinates IDScalarWave: Check parameters

Initialisation CartGrid3D: Set up spatial 3D Cartesian coordinates on the GH IOASCII: Choose 1D output lines IOASCII: Choose 2D output planes

PUGH: Report on PUGH set up Time: Set timestep based on Courant condition WaveToyF77: Schedule symmetries IDScalarWave: Initial data for 3D wave equation

do loop over timesteps WaveToyF77: Evolution of 3D wave equation WaveToyF77: Boundaries of 3D wave equation t = t+dt if (analysis) endif enddo Termination routines PUGH: Termination routine Shutdown routines-----------------------------------------------------------

Page 24: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Driver ThornDriver Thorn

The management of grid variables, including assigning storage, distribution among processors, and communication is handled by a driver thorn

Cactus is designed around a distributed memory model. Each thorn is passed a section of the global grid, and information about whether its boundaries are physical or just local internal grid boundaries.

The actual parallel driver can use whatever method it likes to decompose the grid across processors and exchange ghost zone information - each thorn is presented with a standard interface, independent of the driver.

Driver thorn can be chosen at run time … easy to compare different parallel paradigms.

Page 25: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Ghost ZonesGhost Zones

The grid on each processor has an extra layer of grid-points (marked here in blue) which are in fact copies of those on the neighbour in that direction (marked in red).

After the calculation step the processors exchange these ghost zones to synchronise their states.

Page 26: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

CactusPUGH/PUGHCactusPUGH/PUGH

The standard driver thorn is called PUGH (Parallel Unigrid Grid Hierachy), which uses MPI for communications.

PUGH can automatically choose the grid decomposition, or it can be manually specified, by the number of processors in each direction and the number of grid points on each processor.

PUGH can deal with all the supported Cactus variable types and data types, in 1,2 or 3 spatial dimensions.

CactusPUGH/PUGHReduce also contains a number of routines for global reductions: maximum, minimum and norms.

Page 27: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Cactus Driver APICactus Driver API

Application thorns should not often need to make direct calls to the driver

CCTK_MyProc(cctkGH) what processor am I?

CCTK_nProcs(cctkGH) how many processors are there altogether?

CCTK_Barrier(cctkGH) wait for all processors to catch up

( CCTK_SyncGroup(cctkGH,“groupname”) ) exchange ghostzones for a group of variables (better to specify in

scheduler)

Page 28: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

IO CapabilitiesIO Capabilities

IO capabilities in Cactus are provided by thorns, which register the IO methods they provide with the flesh.

IO is usually selected through parameter file options, but can also be performed from direct calls using the Cactus IO API. The scheduler calls the output routines

IO thorns also provide the capability for checkpointing Save the state of the simulation (grid variables and parameters) for

restarting, optionally on a different machine, different number of processors

Save initial data for parameter studies

Page 29: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

IO Methods in Computational ToolkitIO Methods in Computational Toolkit

IO method Description Providing ThornScalar Scalars or grid array reductions CactusBase/IOBasic

Info Screen output of scalars or grid arrayreductions

CactusBase/IOBasic

IOASCII_1D 1D line output of grid arrays CactusBase/IOASCII

IOASCII_2D 2D slice output of grid arrays CactusBase/IOASCII

IOHDF5_2D 2D slice output in HDF5 format CactusPUGHIO/IOHDF5

IOHDF5_3D 3D output in HDF5 format CactusPUGHIO/IOHDF5

IOFlexIO_2D 2D slice output in FlexIO format CactusPUGHIO/IOFlexIO

IOFlexIO_3D 3D output in FlexIO format CactusPUGHIO/IOFlexIO

Jpeg 2D slice output as Jpegs CactusNet/Jpeg

IsoSurfacer Constant value isosurfaces CactusPUGHIO/IsoSurfacer

Page 30: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

IO ParametersIO Parameters

Thorn CactusBase/IOUtil acts as a general utility thorn for all the Cactus IO methods, providing default parameters which can be overriden by the individual IO methods from other thorns.

IO from the Cactus thorns can be customised through parameters for a given architecture/number of processors.

IO::outdir = “run1”

IO::out_every = 5

IOASCII::out1d_vars = “wavetoy::phi grid::x”

IOHDF5::out3d_every = 50

IOHDF5::out3d_vars = “wavetoy::phi”

Page 31: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Cactus IO APICactus IO API

If you need to output directly from a thorn ...

CCTK_OutputGH(cctkGH) Loop over all registered IO methods

CCTK_OutputVarAsByMethod(cctkGH,“varname”,“alias”, “method”) Output varname using given IO method, using alias to create the filename

CCTK_OutputVarByMethod(cctkGH,“varname”,“method”) Output varname using given IO method

CCTK_OutputVarAs(cctkGH,“varname”,“alias”) Loop over all registered IO methods, outputting varname, using alias to

create the filenames CCTK_OutputVar(cctkGH, “varname”)

Loop over all registered IO methods, outputting varname

Page 32: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Cactus Interpolation/Reduction APICactus Interpolation/Reduction API

Thorns register interpolation, reduction operators with the Flesh

Thorns call Cactus API, indicating which operator they require (e.g. by parameter value)

call CCTK_ReductionHandle(handle, “minimum”)

call CCTK_Reduce(ierr,cctkGH,handle, … , <fields to reduce>)

Page 33: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

These are C pointers … they cannot be treated as Fortran strings

To compare use

if (CCTK_EQUALS(bound,”gaussian”) then

Note that CCTK_EQUALS returns a logical and CCTK_Equals returns an integer …the case is important!! Don’t use CCTK_Equals as a logical, or you’re code won’t be portable!

String Parameters in FortranString Parameters in Fortran

Page 34: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Include files

Argument lists

Cactus variables

Parameters

Functions

Local variable data types

Cactus Source CodeCactus Source Code

Page 35: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Include FilesInclude Files

For both Fortran and C #include “cctk.h”

– any source file using Cactus infrastructure #include “cctk_Arguments.h”

– any source file using Cactus argument lists #include “cctk_Parameters.h”

– any source file using Cactus parameters

Page 36: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

The scheduler passes in all the variables, through the argument list, that a thorn needs Cactus variables describing the grid hierachy, such as the local grid

size All the variables in the thorns interface.ccl All the variables needed from other thorns (inherited and friends)

#include “cctk_Arguments.h”

subroutine WaveToyF77_Evolution(CCTK_ARGUMENTS)

implicit none

DECLARE_CCTK_ARGUMENTS

Argument ListsArgument Lists

Page 37: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Pass argument list into other routines using:

call WaveToyF77_Boundaries(CCTK_PASS_FTOF) … subroutine WaveToyF77_Boundaries(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS

Can add extra arguments

call WaveToyF77_Boundaries(CCTK_PASS_FTOF,myint) … subroutine WaveToyF77_Boundaries(CCTK_ARGUMENTS,myint) DECLARE_CCTK_ARGUMENTS integer myint

Passing Argument ListsPassing Argument Lists

Page 38: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

All thorn routines called by the Scheduler, are passed the following variables, describing the grid layout:

cctk_dim dimension of this grid cctk_lsh local grid size cctk_delta_time, cctk_time time step, current time cctk_delta_space grid spacing in each direction cctk_nghostzones number of ghostzones in each direction cctkGH pointer identifying grid Plus a few others …

Cactus Variables in Scheduled RoutinesCactus Variables in Scheduled Routines

Page 39: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

All parameters defined in a thorn’s param.ccl (bound), and all global parameters appear as local variables in a thorn

Do not change them!! We don’t stop you! (Because we can’t)

#include “cctk_Parameters.h”

subroutine MySubroutine(arg1,arg2)

DECLARE_CCTK_PARAMETERS

Cactus ParametersCactus Parameters

Page 40: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

These are C pointers … they cannot be treated as Fortran strings

To compare use

if (CCTK_EQUALS(bound,”gaussian”) then

Note that CCTK_EQUALS returns a logical and CCTK_Equals returns an integer …the case is important!! Don’t use CCTK_Equals as a logical, or you’re code won’t be portable!

String Parameters in FortranString Parameters in Fortran

Page 41: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

The function CCTK_WARN is used both to give warnings and to stop the code

Warnings are given a warning level. By default, warning level 0 will stop the code, and warning level 1 will be printed to standard error.

This can be changed at run time from the command line.

CCTK_WARN(0,”Boundary conditions not applied - giving up!”)

CCTK_WARN(1,”You probably don’t want to do this”)CCTK_WARN(4,”Probably harmless, but I’ll tell you”)

Warnings and ErrorsWarnings and Errors

Page 42: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Use CCTK_INFO to write to standard output at runtime:

CCTK_INFO(“Creating initial data”)

Use this rather than “print” statements multiprocessor can switch on and off

Runtime InformationRuntime Information

Page 43: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Infrastructure Thorn APIInfrastructure Thorn API

Cactus provides a richer API for infrastructure programmers to interact with the Flesh

Function and capability registration any number of thorns can register any number of routines e.g. IO, reduction, interpolation, elliptic solvers, coordinates

Function overloading overloadable functions can only be provided by one routine e.g. driver capabilities, CCTK_nProcs e.g. main routines in Flesh are all overloadable

Many utility functions linked lists, hash tables etc. parameter querying

Page 44: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Getting the CodeGetting the Code

Cactus is available for checkout via CVS (recommended) or from automatically generated tar files from the web site.

Full instructions at www.CactusCode.org The easiest way to checkout Cactus is via a “Thorn List”,

which allows you to checkout just the thorns you require for a given application (using GetCactus script from website).

Web site contains sample thorn lists to get you started. Example WaveToy application Benchmark application

Page 45: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Making CactusMaking Cactus

Cactus Executable

Configure

Build

CST Compile

Make

Page 46: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

ConfigurationsConfigurations

Configurations are used to contain details of different compiled versions of Cactus Shared file spaces used by different machines Different thorn lists Different compiler options Repository of (not-)working versions

Page 47: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

ConfiguringConfiguring

Determine Architecture

Find Compilers

Determine Flags

Configure

Fortran Names

KnownArchitectures

Command Line OptionsOptions File

config-data

Page 48: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Cactus Specification Tool (CST)Cactus Specification Tool (CST)

Parse CCL Files

Validate

Output

CST

bindings

ThornList

interface.ccl

param.ccl

schedule.ccl

Flesh

interface.ccl

param.ccl

schedule.ccl

Thorn A

interface.ccl

param.ccl

schedule.ccl

Thorn B

Page 49: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

CompilingCompiling

Dependencies

Preprocess Files

Compile Files

Postprocess Files

libthorn.a

Thorn

config-data+

make.code.defn

Page 50: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Making Cactus Making Cactus

Configure:

gmake <config name>-config <options>

gmake <config name>-config OPTIONS=<filename>

Many options, e.g.

gmake MyCactus-config

gmake MyCactus-config MPI=NATIVE DEBUG=yes

gmake MyCactus-config MPI=CUSTOM MPI_LIBS=mpi

MPI_LIB_DIRS=/usr/lib

MPI_INC_DIRS=/usr/include F90=pgf90

OPTIMISE=yes DEBUG=yes HDF5=yes THORNLIST=mythorns.th

Page 51: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Making Cactus (2)Making Cactus (2)

Build

gmake <config name>-build <options>

Many options, e.g.

gmake MyCactus-build

gmake MyCactus-build WARN=yes TJOBS=4

Executable: exe/cactus_<config name>

Page 52: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

The make system uses source file extensions to indicate the coding language, these include:

Extension Language

.F Fortran 90.F90 Free Form Fortran 90.F77 Fortran 77

.c C.C/.cc C++

Source File NamesSource File Names

Page 53: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

To include source files in the compilation process, add them to the make.code.defn file in the thorn src directory

Use the right file extensions!! (Can completely configure … add your own Makefile etc)

# Main make.code.defn file for thorn WaveToyF77

# Source files in this directory

SRCS = InitSymBound.F77 WaveToy.F77 Startup.c

# Subdirectories containing source files

SUBDIRS =

Compiling Thorn Source FilesCompiling Thorn Source Files

Page 54: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Running CactusRunning Cactus

Cactus is executed from a parameter file

<run command> <executable> <parameter file> <options> e.g. ./exe/cactus_wave wavetoy.par e.g. mpirun -np 4 ./exe/cactus_wave wavetoy.par -w 9

Command line options for warning level, information querying etc.

Designed to provide information for GUIs, portals, etc.

Page 55: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Run Time OutputRun Time Output----------------------------------------------------------------------------- 10 1 0101 ************************ 01 1010 10 The Cactus Code V4.0 1010 1101 011 www.cactuscode.org 1001 100101 ************************ 00010101 100011 (c) Copyright The Authors 0100 GNU Licensed. No Warranty 0101

-----------------------------------------------------------------------------Activating thorn Cactus...Success -> active implementation CactusActivating thorn iobasic...Success -> active implementation IOBasicActivating thorn idscalarwave...Success -> active implementation idscalarwaveActivating thorn time...Success -> active implementation timeActivating thorn wavetoyf77...Success -> active implementation wavetoyActivating thorn pugh...Success -> active implementation driverActivating thorn cartgrid3d...Success -> active implementation gridActivating thorn ioutil...Success -> active implementation IOActivating thorn ioascii...Success -> active implementation IOASCII-----------------------------------------------------------------------------

Page 56: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Run Time Output (2)Run Time Output (2)Startup routines CartGrid3D: Register GH Extension for GridSymmetry CartGrid3D: Register coordinates for the Cartesian grid PUGH: Startup routine. IOUtil: Startup routine IOASCII: Startup routine IOBasic: Startup routine WaveToyF77: Register banner

Parameter checking routines CartGrid3D: Check coordinates for CartGrid3D IDScalarWave: Check parameters

Initialisation CartGrid3D: Set up spatial 3D Cartesian coordinates on the GH IOASCII: Choose 1D output lines IOASCII: Choose 2D output planes PUGH: Report on PUGH set up Time: Set timestep based on Courant condition WaveToyF77: Schedule symmetries IDScalarWave: Initial data for 3D wave equation

Page 57: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Run Time Output (3)Run Time Output (3)do loop over timesteps WaveToyF77: Evolution of 3D wave equation WaveToyF77: Boundaries of 3D wave equation t = t+dt if (analysis) endif enddo Termination routines PUGH: Termination routine Shutdown routines----------------------------------------------------------------------------------------------------------------------------------------------------------Driver provided by PUGH-----------------------------------------------------------------------------WaveToyF77: Evolutions of a Scalar Field-----------------------------------------------------------------------------INFO (CartGrid3D): dx=>3.0000000e-01 dy=>3.0000000e-01 dz=>3.0000000e-01 INFO (CartGrid3D): x=>[-0.150, 8.550] y=>[-0.150, 8.550] z=>[-0.150, 8.550] INFO (PUGH): MPI Evolution on 4 processorsINFO (PUGH): 3-dimensional grid functionsINFO (PUGH): Size: 30 30 30INFO (PUGH): Processor topology: 1 x 2 x 2INFO (PUGH): Local load: 7680 [30 x 16 x 16]INFO (PUGH): Maximum load skew: 0.000000

Page 58: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Run Time Output (4)Run Time Output (4)-------------------------------------------- it | | phi | | t | Min Max |-------------------------------------------- 0 | 0.000| 0.00000000 | 0.99142726 | 10 | 1.500| -0.14944313 | 0.00005206 | 20 | 3.000| -1.16992203 | 0.00000000 | 30 | 4.500| -0.72347868 | -0.00000002 | 40 | 6.000| -0.41127922 | -0.00000094 | 50 | 7.500| -0.29834817 | -0.00002427 | 60 | 9.000| -0.23577373 | -0.00035044 | 70 | 10.500| -0.19532474 | 0.00000311 | 80 | 12.000| -0.16688911 | 0.00010812 | 90 | 13.500| -0.14582895 | 0.00022987 | 100 | 15.000| -0.12957000 | 0.00033802 | 110 | 16.500| -0.11631732 | 0.00025752 | 120 | 18.000| -0.06945640 | 0.00019346 |-----------------------------------------------------------------------------Done.

Page 59: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Command Line ArgumentsCommand Line Arguments

-O, -describe-all-parameters full list of all parameters from all compiled

thorns-o <param>, -describe-parameter <param>

full description of a single parameter

-T, -list-thorns list all compiled thorns

-t <arrangement/thorns>, -test-thorn-compiled <arrangement/thorn>

test if a thorn is included in executable

-h, -?, -help provide help message

-v, -version version information for this executable

-W <level>, -warning-level <level> set the warning level, default value if 1

-E <level>, -error-level <level> set the warning level at which Cactus terminates, default value is 1

-r, -redirect-output redirect standard output from each processor

to a file

Page 60: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Command Line Arguments (2)Command Line Arguments (2)

> ./exe/cactus_tut -T

---------------Compiled Thorns------------- Boundary Cactus CartGrid3D Hyperslab IDBinarySource IDScalarWave IDScalarWaveC IDScalarWaveCXX IOASCII IOBasic IOUtil PUGH Time WaveToyC WaveToyCXX WaveToyF77 WaveToyF90 WaveToyFreeF90-------------------------------------------

Page 61: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Command Line Arguments (3)Command Line Arguments (3)

> ./exe/cactus_tut -t PUGH

Thorn 'PUGH' available.

> ./exe/cactus_tut -t PAGH

Thorn 'PAGH' unavailable.

> ./exe/cactus_tut -v

/home/allen/CACTUS/Cactus/exe/cactus_tut: Version 4.0.b8. Compiled on Jul 12 2000 at 09:53:07

Page 62: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Command Line Arguments (4)Command Line Arguments (4)

> ./exe/cactus_tut -help

/home/allen/CACTUS/Cactus/exe/cactus_tut, compiled on Jul 12 2000 at 09:53:07

Usage: /home/allen/CACTUS/Cactus/exe/cactus_tut [-h] [-O] [-o paramname] [-x [nprocs]] [-W n] [-E n] [-r] [-T] [-t name] [-v] <parameter_file_name>

Valid options:-h, -help : gets this help.-O, -describe-all-parameters : describes all the parameters.-o, -describe-parameter <paramname> : describe the given parameter.-x, -test-parameters [nprocs] : does a quick test of the

parameter file pretending to be on nprocs processors, or 1 if not given.-W, -warning-level <n> : Sets the warning level to n.-E, -error-level <n> : Sets the error level to n.-r, -redirect-stdout : Redirects standard output to files.-T, -list-thorns : Lists the compiled-in thorns.-t, -test-thorn-compiled <name> : Tests for the presence of thorn <name>.-v, -version : Prints the version.

Page 63: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Command Line Arguments (5)Command Line Arguments (5)

> ./exe/cactus_exe -O

...

Parameters of thorn 'IDScalarWaveC' providing implementation 'idscalarwave':

IDScalarWaveC::amplitudeidscalarwave::initial_dataIDScalarWaveC::kxIDScalarWaveC::kyIDScalarWaveC::kzIDScalarWaveC::radiusIDScalarWaveC::sigma

Parameters of thorn 'WaveToyC' providing implementation 'wavetoy':WaveToyC::bound

Parameters of thorn 'WaveToyCXX' providing implementation 'wavetoy':WaveToyCXX::bound

...

Page 64: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Command Line Arguments (6)Command Line Arguments (6)> ./exe/cactus_tut -OvParameter: IDScalarWaveC::sigmaDescription: "The sigma for the gaussian wave"Type: REALDefault: 0.1Scope: PRIVATE Range: 0:* Origin: IDScalarWaveC Description:

Parameters of thorn 'WaveToyC' providing implementation 'wavetoy':Parameter: WaveToyC::boundDescription: "Type of boundary condition to use"Type: KEYWORDDefault: noneScope: PRIVATE Range: radiation Origin: WaveToyC Description: Range: flat Origin: WaveToyC Description: Range: none Origin: WaveToyC Description:

...

Page 65: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Command Line Arguments (7)Command Line Arguments (7)

> ./exe/cactus_tut -o PUGH::global_nx

Parameter: PUGH::global_nx, driver::global_nxDescription: "The size of the grid in the x direction"Type: INTEGERDefault: 10Scope: RESTRICTED Range: 0:* Origin: PUGH Description:

Page 66: Overview for Application Programmer The Cactus Team Albert Einstein Institute cactus@cactuscode.org

Testing CactusTesting Cactus

Cactus provides a testsuite checking mechanism which can be used to compare output from different architectures, different numbers of processors, different code versions etc. against previously saved “correct” output

gmake <config>-testsuite runs all tests applicable for this configuration

It is recommended that testsuites are added for each thorn to test each aspect of its functionality, and are checked each time that changes are made to any part of the code.