SoftwareSoftware ProductivityProductivity ToolsTools

Purdue School on HPC Sept. 4-5, 2008

Dave Seaman ([email protected])

Rosen Center for Advanced AA SelectionSelection ofof ToolsTools

ƒƒ TarTar ƒƒ MakeMake ƒƒ PBSPBS ƒƒ VersionVersion controlcontrol systemssystems •• CVSCVS •• subversionsubversion TarTar

ƒƒ SimpleSimple ArchivesArchives ƒƒ CompressedCompressed ArchivesArchives ((gzipgzip)) ƒƒ CompressedCompressed ArchivesArchives ((bzip2bzip2)) SimpleSimple ArchivesArchives

ƒƒ CreatingCreating anan ArchiveArchive ƒƒ ExractingExracting fromfrom anan ArchiveArchive ƒƒ LookingLooking beforebefore YouYou LeapLeap CreatingCreating anan ArchiveArchive

ƒƒ tartar cfcf myarchive.tarmyarchive. filesfiles ƒƒ UseUse cc optionoption toto createcreate anan archivearchive ƒƒ UseUse ff optionoption toto specifyspecify aa diskdisk filefile (default(default isis tape)tape) ExtractingExtracting fromfrom anan ArchiveArchive

ƒƒ tartar xfxf myarchive.tarmyarchive.tar [files[files……]] ƒƒ UseUse xx optionoption toto extractextract files.files. ƒƒ DefaultDefault isis toto extractextract allall filesfiles inin archive.archive. LookingLooking beforebefore YouYou LeapLeap

ƒƒ ManyMany archivesarchives willwill extractextract intointo aa subdirectory,subdirectory, butbut somesome writewrite filesfiles inin currentcurrent .directory. ƒƒ ToTo bebe safe,safe, extractextract intointo anan emptyempty directory.directory. ƒƒ UseUse tt optionoption toto seesee what'swhat's there:there: tartar tftf myarchive.tarmyarchive.tar CompressedCompressed ArchivesArchives ((gzipgzip))

ƒƒ WeWe maymay useuse gzipgzip toto compresscompress anan archive:archive: tartar cfcf mystuff.tarmystuff.tar mystuffmystuff gzipgzip mystuff.tarmystuff.tar

ƒƒ AA shortcutshortcut isis availableavailable whenwhen usingusing GNUGNU tar:tar: tartar zcfzcf mystuff.tar.gzmystuff.tar.gz mystuffmystuff UncompressingUncompressing withwith gunzipgunzip

ƒƒ AA compressedcompressed archivearchive namename maymay endend inin ..tar.gztar.gz,, .tar.Z,.tar.Z, oror ..tgztgz.. ƒƒ WeWe maymay extractextract filesfiles byby usingusing aa twotwo--stepstep process:process: gunzipgunzip mystuff.tar.gzmystuff.tar.gz tartar xfxf mystuff.tarmystuff.tar UncompressingUncompressing ShortcutsShortcuts

ƒƒ WeWe maymay useuse zcatzcat toto unzipunzip andand pipepipe thethe resultresult intointo tar:tar: zcatzcat mystuff.tar.gzmystuff.tar.gz || tartar xfxf -- ƒƒ GNUGNU tartar hashas thethe zz optionoption forfor /unzip:zip/unzip: tartar zxfzxf mystuff.tar.gzmystuff.tar.gz Bzip2Bzip2 CompressionCompression

ƒƒ Bzip2Bzip2 isis usedused muchmuch likelike gzipgzip,, butbut tendstends toto havehave betterbetter compressioncompression ratiosratios atat thethe costcost ofof slightlyslightly moremore .time. mystuff.tar bunzip2 mystuff.tar.bz2 bzcat mystuff.tar.bz2 | tar xf - GNUGNU tartar andand bzip2bzip2

ƒƒ GNUGNU tartar usesuses thethe jj optionoption toto invokeinvoke bzip2/bunzip2:bzip2/bunzip2: tar jcf mystuff.tar.bz2 mystuff tar jxf mystuff.tar.bz2 MakeMake

ƒƒ AutomatesAutomates maintainingmaintaining filesfiles thatthat dependdepend onon otherother files.files. ƒƒ MayMay bebe usedused forfor programs,programs, documents,documents, oror arbitraryarbitrary developmentdevelopment projects.projects. ƒƒ InstructionsInstructions containedcontained inin MakefileMakefile controlcontrol stepssteps neededneeded toto keepkeep filesfiles upup toto date.date. SimpleSimple MakefileMakefile

## variablevariable definitionsdefinitions PROGPROG == graphgraph SRCSRC == main.cmain. graph.cgraph.c OBJOBJ == main.omain.o graph.ograph.o CCCC == iccicc CFLAGSCFLAGS == --O2O2 LOADLIBESLOADLIBES == --lmlm SimpleSimple MakefileMakefile (cont.)(cont.) all:all: $(PROG)$(PROG) $(PROG):$(PROG): $(OBJ)$(OBJ) $(LINK.c)$(LINK.c) --oo $@$@ $(OBJ)$(OBJ) $(LOADLIBES)$(LOADLIBES) ## additionaladditional dependencydependency rulerule main.omain.o graph.o:graph.o: graph.hgraph.h RulesRules target:target: prereq1prereq1 prereq2prereq2 …… command1command1 command2command2 [[……]]

EachEach commandcommand mustmust bebe precededpreceded byby aa tab.tab. InvokingInvoking makemake

ƒ make [-f makefile] [target] [var=defs]… ƒƒ DefaultDefault makefilemakefile namesnames (in(in order):order): •• GNUmakefileGNUmakefile •• makefilemakefile •• MakefileMakefile ƒƒ DefaultDefault targettarget isis firstfirst oneone inin makefilemakefile.. ƒƒ VariableVariable definitionsdefinitions onon commandcommand lineline overrideoverride valuesvalues givengiven inin makefilemakefile.. SimpleSimple MakefileMakefile

## variablevariable definitionsdefinitions PROGPROG == graphgraph SRCSRC == main.cmain.c graph.cgraph.c OBJOBJ == main.omain.o graph.ograph.o CCCC == iccicc CFLAGSCFLAGS == --O2O2 LOADLIBESLOADLIBES == --lmlm SimpleSimple RuleRule

ƒƒ OurOur simplesimple makefilemakefile containscontains asas itsits firstfirst rule:rule: all:all: $(PROG)$(PROG)

ƒƒ ThisThis meansmeans make isis equivalentequivalent toto make all. ƒƒ ThereThere isis oneone prerequisite:prerequisite: thethe targettarget allall dependsdepends onon $(PROG),$(PROG), whichwhich involvesinvolves aa variablevariable substitution:substitution: PROG = graph VariableVariable SubstitutionSubstitution

ƒƒ VariableVariable namename isis precededpreceded byby $$ andand isis enclosedenclosed inin parentheses:parentheses: $(PROG) ƒƒ ParenthesesParentheses maymay bebe omittedomitted onlyonly ifif thethe namename isis aa singlesingle character.character. SomeSome havehave standardstandard meanings,meanings, suchsuch asas $@ forfor thethe targettarget currentlycurrently beingbeing updated.updated. ƒƒ BracesBraces maymay bebe usedused insteadinstead ofof parentheses:parentheses: ${PROG} DefaultDefault RulesRules

ƒƒ TheThe MakefileMakefile sayssays $(PROG)$(PROG) dependsdepends onon $(OBJ)$(OBJ) andand givesgives aa commandcommand toto useuse forfor creatingcreating $(PROG):$(PROG): $(PROG): $(OBJ) $(LINK.c) -o $@ $(OBJ) $(LOADLIBES) ƒƒ However,However, nono rulesrules areare statedstated forfor producingproducing thethe $(OBJ)$(OBJ) files.files. TheThe DefaultDefault RulesRules

ƒƒ SinceSince nono commandscommands werewere foundfound forfor makingmaking thethe objectobject files,files, makemake usedused thethe defaultdefault rule:rule: %.o:%.o: %.c%.c ## builtbuilt--inin commandscommands toto makemake aa .o.o filefile $(COMPILE.c)$(COMPILE.c) $(OUTPUT_OPTION)$(OUTPUT_OPTION) $<$<

ƒƒ TheThe rulerule beginningbeginning withwith %.o: %.c isis anan exampleexample ofof aa patternpattern rulerule.. DefaultDefault CompilationCompilation RuleRule

ƒƒ $(COMPILE.c)$(COMPILE.c) isis predefinedpredefined byby makemake:: COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) \ $(TARGET_ARCH) -c ƒƒ YouYou maymay definedefine thethe variablesvariables (CC,(CC, CFLAGS,CFLAGS, ……)) asas neededneeded inin orderorder toto customizecustomize thethe .command. SomeSome StandardStandard VariablesVariables

$(COMPILE.c) Command for compiling C programs

$(LINK.c) Command for linking C programs

$< First prerequisite

$@ Target being updated

$(CC) C compiler

$(CFLAGS) Flags for C compiler

$(CPPFLAGS) Flags for C preprocessor

$(CXX) C++ compiler CommandsCommands ProducedProduced

ƒƒ RunningRunning makemake withwith thesethese rulesrules maymay produceproduce severalseveral commands:commands: iccicc --O2O2 --cc --oo main.omain.o main.cmain.c iccicc --O2O2 --cc --oo graph.ograph.o graph.cgraph.c iccicc --O2O2 --oo graphgraph main.omain.o graph.ograph.o --lmlm ƒƒ OnlyOnly thethe necessarynecessary stepssteps areare actuallyactually performed,performed, dependingdepending onon whichwhich filesfiles areare olderolder thanthan theirtheir prerequisites.prerequisites. SpecifyingSpecifying DependenciesDependencies

ƒƒ TheThe filesfiles main.cmain.c andand graph.cgraph.c bothboth #include#include "graph.h""graph.h".. IfIf wewe makemake changeschanges inin graph.hgraph.h,, thenthen bothboth main.omain.o andand graph.ograph.o needneed toto bebe updatedupdated (recompiled).(recompiled). ƒƒ NoNo commandscommands areare neededneeded here.here. WeWe onlyonly needneed thethe dependencydependency toto forceforce recompilationrecompilation usingusing thethe builtbuilt--inin rule.rule. OOtherther UseUsefulful FlagsFlags withwith makemake

--nn DisplayDisplay thethe commandscommands thatthat willwill bebe generated,generated, butbut don'tdon't execute.execute. --vv ShowShow verboseverbose output.output.

--pp ShowShow completecomplete databasedatabase ofof rules,rules, includingincluding builtbuilt--inin rules.rules. ForFor MoreMore InformationInformation

ƒƒ http://www.gnu.org/software/make/manual/make.htmlhttp://www.gnu.org/software/make/manual/make.html PortablePortable BatchBatch SSystemystem (PBS)(PBS)

ƒƒ SubmitsSubmits jobsjobs toto runrun onon aa cluster.cluster. ƒƒ SchedulesSchedules jobsjobs toto runrun whenwhen resourcesresources becomebecome available.available. ƒƒ ManagesManages runningrunning ofof jobsjobs andand returnsreturns outputoutput toto user.user. ƒƒ AllowsAllows interactiveinteractive execution.execution. UsefulUseful PBSPBS CommandsCommands qsubqsub SubmitSubmit PBSPBS jobjob qdelqdel DeleteDelete PBSPBS jobjob qstatqstat DisplayDisplay statusstatus ofof PBSPBS jobs,jobs, queues,queues, oror serversservers pbsnodespbsnodes QueryQuery PBSPBS hosthost statusstatus TheThe qsubqsub CommandCommand

ƒƒ ToTo submitsubmit thethe scriptscript myscriptmyscript asas aa batchbatch job,job, use:use: qsub [options] myscript ƒƒ OptionsOptions maymay bebe embeddedembedded inin aa scriptscript filefile oror specifiedspecified onon thethe commandcommand line.line. ƒƒ ToTo submitsubmit anan interactiveinteractive job,job, use:use: qsub -I [options]

ƒƒ UseUse man qsub toto learnlearn .more. UsingUsing OptionsOptions

ƒƒ CommandCommand lineline example:example: qsub -q standby -l select=2:ncpus=4:mpiprocs=4 myscript ƒƒ BatchBatch filefile example:example: #PBS#PBS --qq standbystandby #PBS#PBS --ll select=2:ncpus=4:mpiprocs=4select=2:ncpus=4:mpiprocs=4 #PBS#PBS --ll walltimewalltime=4:00:00=4:00:00 ƒƒ TheThe commandcommand lineline takestakes precedence.precedence. SomeSome UsefulUseful qsubqsub FlagsFlags

--ll resource_listresource_list SpecifySpecify resourcesresources requiredrequired forfor job.job. --qq queue_namequeue_name SpecifySpecify queuequeue inin whichwhich toto runrun job.job. --mm mail_optionsmail_options SpecifySpecify mailmail toto bebe sentsent atat specificspecific times.times. --SS shell_pathshell_path SpecifySpecify shellshell toto useuse (default(default isis loginlogin shell).shell). ResourcesResources

ƒƒ RequestRequest twotwo nodesnodes withwith 44 processorsprocessors perper nodenode forfor runningrunning anan MPIMPI program:program: -l select=2:ncpus=4:mpiprocs=4 ƒƒ RequestRequest oneone nodenode withwith 44 processorsprocessors andand 22 GBGB memorymemory forfor runningrunning anan OpenMPOpenMP program:program: -l select=1:ncpus=4:ompthreads=4:mem=2g ƒƒ RequestRequest anan extendedextended timetime limit:limit: -l walltime=24:00:00 QueuesQueues

ƒƒ UseUse qstat -a toto seesee availableavailable queues.queues. ƒƒ NotNot allall queuesqueues areare availableavailable toto everyevery user.user. ƒƒ DifferentDifferent queuesqueues generallygenerally havehave differentdifferent resourceresource limits.limits.

ƒƒ SpecifySpecify -q queue_name whenwhen submittingsubmitting job.job. MailMail OptionsOptions

--mnmn NoNo mailmail isis sent.sent.

--mama MailMail isis sentsent ifif jobjob isis aborted.aborted. --mbmb MailMail isis sentsent whenwhen jobjob beginsbegins execution.execution. --meme MailMail isis sentsent whenwhen jobjob endsends execution.execution. AA SimpleSimple JobJob ScriptScript

#PBS -S /bin/csh -l nodes=4:ppn=1

# Change to directory where job was submitted. $PBS_O_WORKDIR

# Make sure mpich2 is loaded. module load mpich2-intel

# Run the examples. make test MailMail OptionsOptions

--mnmn NoNo mailmail isis sent.sent.

--mama MailMail isis sentsent ifif jobjob isis aborted.aborted. --mbmb MailMail isis sentsent whenwhen jobjob beginsbegins execution.execution. --meme MailMail isis sentsent whenwhen jobjob endsends execution.execution.