From swift at ci.uchicago.edu Tue Aug 5 15:50:03 2014 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Tue, 5 Aug 2014 15:50:03 -0500 (CDT) Subject: [Swift-commit] cog r4041 Message-ID: <20140805205003.B977B8D000A6@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r4041 | yadunand | 2014-08-05 15:48:00 -0500 (Tue, 05 Aug 2014) | 3 lines Committing latest provider changes ------------------------------------------------------------------------ Index: modules/provider-localscheduler/libexec/ec2-cloud-provider/stsubmit.sh =================================================================== --- modules/provider-localscheduler/libexec/ec2-cloud-provider/stsubmit.sh (revision 0) +++ modules/provider-localscheduler/libexec/ec2-cloud-provider/stsubmit.sh (revision 4041) @@ -0,0 +1 @@ +link ../../examples/ec2-cloud-provider/stsubmit.sh \ No newline at end of file Property changes on: modules/provider-localscheduler/libexec/ec2-cloud-provider/stsubmit.sh ___________________________________________________________________ Added: svn:special + * Index: modules/provider-localscheduler/libexec/ec2-cloud-provider/stcancel.sh =================================================================== --- modules/provider-localscheduler/libexec/ec2-cloud-provider/stcancel.sh (revision 0) +++ modules/provider-localscheduler/libexec/ec2-cloud-provider/stcancel.sh (revision 4041) @@ -0,0 +1 @@ +link ../../examples/ec2-cloud-provider/stcancel.sh \ No newline at end of file Property changes on: modules/provider-localscheduler/libexec/ec2-cloud-provider/stcancel.sh ___________________________________________________________________ Added: svn:special + * Index: modules/provider-localscheduler/libexec/ec2-cloud-provider/ststat.sh =================================================================== --- modules/provider-localscheduler/libexec/ec2-cloud-provider/ststat.sh (revision 0) +++ modules/provider-localscheduler/libexec/ec2-cloud-provider/ststat.sh (revision 4041) @@ -0,0 +1 @@ +link ../../examples/ec2-cloud-provider/ststat.sh \ No newline at end of file Property changes on: modules/provider-localscheduler/libexec/ec2-cloud-provider/ststat.sh ___________________________________________________________________ Added: svn:special + * Index: modules/provider-localscheduler/libexec/ec2-cloud-provider/cloud.py =================================================================== --- modules/provider-localscheduler/libexec/ec2-cloud-provider/cloud.py (revision 0) +++ modules/provider-localscheduler/libexec/ec2-cloud-provider/cloud.py (revision 4041) @@ -0,0 +1 @@ +link ../../examples/ec2-cloud-provider/cloud.py \ No newline at end of file Property changes on: modules/provider-localscheduler/libexec/ec2-cloud-provider/cloud.py ___________________________________________________________________ Added: svn:special + * Index: modules/provider-localscheduler/libexec/gce-cloud-provider/stsubmit.sh =================================================================== --- modules/provider-localscheduler/libexec/gce-cloud-provider/stsubmit.sh (revision 0) +++ modules/provider-localscheduler/libexec/gce-cloud-provider/stsubmit.sh (revision 4041) @@ -0,0 +1 @@ +link ../../examples/gce-cloud-provider/stsubmit.sh \ No newline at end of file Property changes on: modules/provider-localscheduler/libexec/gce-cloud-provider/stsubmit.sh ___________________________________________________________________ Added: svn:special + * Index: modules/provider-localscheduler/libexec/gce-cloud-provider/stcancel.sh =================================================================== --- modules/provider-localscheduler/libexec/gce-cloud-provider/stcancel.sh (revision 0) +++ modules/provider-localscheduler/libexec/gce-cloud-provider/stcancel.sh (revision 4041) @@ -0,0 +1 @@ +link ../../examples/gce-cloud-provider/stcancel.sh \ No newline at end of file Property changes on: modules/provider-localscheduler/libexec/gce-cloud-provider/stcancel.sh ___________________________________________________________________ Added: svn:special + * Index: modules/provider-localscheduler/libexec/gce-cloud-provider/ststat.sh =================================================================== --- modules/provider-localscheduler/libexec/gce-cloud-provider/ststat.sh (revision 0) +++ modules/provider-localscheduler/libexec/gce-cloud-provider/ststat.sh (revision 4041) @@ -0,0 +1 @@ +link ../../examples/gce-cloud-provider/ststat.sh \ No newline at end of file Property changes on: modules/provider-localscheduler/libexec/gce-cloud-provider/ststat.sh ___________________________________________________________________ Added: svn:special + * Index: modules/provider-localscheduler/libexec/gce-cloud-provider/cloud.py =================================================================== --- modules/provider-localscheduler/libexec/gce-cloud-provider/cloud.py (revision 0) +++ modules/provider-localscheduler/libexec/gce-cloud-provider/cloud.py (revision 4041) @@ -0,0 +1 @@ +link ../../examples/gce-cloud-provider/cloud.py \ No newline at end of file Property changes on: modules/provider-localscheduler/libexec/gce-cloud-provider/cloud.py ___________________________________________________________________ Added: svn:special + * Index: modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/shell/execution/TaskHandlerImpl.java =================================================================== --- modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/shell/execution/TaskHandlerImpl.java (revision 4040) +++ modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/shell/execution/TaskHandlerImpl.java (working copy) @@ -47,4 +47,4 @@ } -} \ No newline at end of file +} Index: modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/shell/Properties.java =================================================================== --- modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/shell/Properties.java (revision 4040) +++ modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/shell/Properties.java (working copy) @@ -9,7 +9,7 @@ */ package org.globus.cog.abstraction.impl.scheduler.shell; -// import org.apache.log4j.Logger; +import org.apache.log4j.Logger; import org.globus.cog.abstraction.impl.scheduler.common.AbstractProperties; public class Properties extends AbstractProperties { @@ -28,7 +28,7 @@ properties.put(NAME, name); return properties; } - + protected void setDefaults() { setPollInterval(5); } Index: modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/common/AbstractProperties.java =================================================================== --- modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/common/AbstractProperties.java (revision 4040) +++ modules/provider-localscheduler/src/org/globus/cog/abstraction/impl/scheduler/common/AbstractProperties.java (working copy) @@ -19,11 +19,36 @@ private static final long serialVersionUID = 1L; public static final Logger logger = Logger.getLogger(AbstractProperties.class); - + public static final String POLL_INTERVAL = "poll.interval"; - + public static final String DEBUG = "debug"; - + + private String resolve(String var) { + String v = null; + if (var.startsWith("env.")) { + v = System.getenv(var.substring(4)); + } + else { + v = System.getProperty(var); + } + if (v == null) { + throw new IllegalArgumentException("No such system property or environment variable: '" + var + "'"); + } + return v; + } + + private String loadenv(String what) { + int b = what.indexOf("${"); + while (b != -1) { + int e = what.indexOf("}", b); + String var = what.substring(b + 2, e); + what = what.substring(0, b) + resolve(var) + what.substring(e + 1); + b = what.indexOf("${"); + } + return what; + } + protected void load(String name) { setDefaults(); InputStream is = getClass().getClassLoader().getResourceAsStream(name); @@ -33,6 +58,11 @@ else { try { super.load(is); + for (String key: super.stringPropertyNames()){ + String value = super.getProperty(key); + String resolved = loadenv(value); + super.setProperty(key, resolved); + } } catch (IOException e) { } Index: modules/provider-localscheduler/resources/cog-provider.properties =================================================================== --- modules/provider-localscheduler/resources/cog-provider.properties (revision 4040) +++ modules/provider-localscheduler/resources/cog-provider.properties (working copy) @@ -38,3 +38,8 @@ sandbox=false executionTaskHandler=org.globus.cog.abstraction.impl.scheduler.shell.execution.TaskHandlerImpl securityContext=org.globus.cog.abstraction.impl.common.task.SecurityContextImpl + +provider=gce-cloud +sandbox=false +executionTaskHandler=org.globus.cog.abstraction.impl.scheduler.shell.execution.TaskHandlerImpl +securityContext=org.globus.cog.abstraction.impl.common.task.SecurityContextImpl Index: modules/provider-localscheduler/etc/provider-gce-cloud.properties =================================================================== --- modules/provider-localscheduler/etc/provider-gce-cloud.properties (revision 0) +++ modules/provider-localscheduler/etc/provider-gce-cloud.properties (revision 4041) @@ -0,0 +1,3 @@ +submit.command=${env.SWIFT_HOME}/libexec/gce-cloud-provider/stsubmit.sh +cancel.command=${env.SWIFT_HOME}/libexec/gce-cloud-provider/stcancel.sh +poll.command=${env.SWIFT_HOME}/libexec/gce-cloud-provider/ststat.sh \ No newline at end of file Index: modules/provider-localscheduler/etc/provider-ec2-cloud.properties =================================================================== --- modules/provider-localscheduler/etc/provider-ec2-cloud.properties (revision 4040) +++ modules/provider-localscheduler/etc/provider-ec2-cloud.properties (working copy) @@ -1,3 +1,3 @@ -submit.command=/home/yadu/src/swift-trunk/cog/modules/provider-localscheduler/examples/ec2-cloud-provider/stsubmit -cancel.command=/home/yadu/src/swift-trunk/cog/modules/provider-localscheduler/examples/ec2-cloud-provider/stcancel -poll.command=/home/yadu/src/swift-trunk/cog/modules/provider-localscheduler/examples/ec2-cloud-provider/ststat \ No newline at end of file +submit.command=${env.SWIFT_HOME}/libexec/ec2-cloud-provider/stsubmit.sh +cancel.command=${env.SWIFT_HOME}/libexec/ec2-cloud-provider/stcancel.sh +poll.command=${env.SWIFT_HOME}/libexec/ec2-cloud-provider/ststat.sh \ No newline at end of file From yadunandb at ci.uchicago.edu Tue Aug 5 15:50:48 2014 From: yadunandb at ci.uchicago.edu (yadunandb at ci.uchicago.edu) Date: Tue, 5 Aug 2014 15:50:48 -0500 (CDT) Subject: [Swift-commit] r8074 - trunk/resources Message-ID: <20140805205048.761A29D6CD@svn.ci.uchicago.edu> Author: yadunandb Date: 2014-08-05 15:50:48 -0500 (Tue, 05 Aug 2014) New Revision: 8074 Modified: trunk/resources/swift.conf.schema Log: Updating conf schema Modified: trunk/resources/swift.conf.schema =================================================================== --- trunk/resources/swift.conf.schema 2014-07-29 16:40:26 UTC (rev 8073) +++ trunk/resources/swift.conf.schema 2014-08-05 20:50:48 UTC (rev 8074) @@ -110,12 +110,26 @@ ppn: "?StrictlyPositiveInt" pbs.properties: "?String" condor: "?Object" + + # Required ec2 configs : ec2CredentialsFile: "?String" + ec2WorkerImage: "?String" + ec2WorkerType: "?String" + # Optional ec2 configs : ec2SecurityGroup: "?String" ec2KeypairName: "?String" ec2KeypairFile: "?String" - ec2WorkerImage: "?String" - ec2WorkerType: "?String" + + # Required gce configs + gceKeypairFile: "?String" + gceEmailAccount: "?String" + gceProjectId: "?String" + gceZone: "?String" + gceWorkerType: "?String" + gceWorkerImage: "?String" + # Optional gce configs + gceSecurityGroup: "?String" + } } } From swift at ci.uchicago.edu Fri Aug 8 18:00:23 2014 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Fri, 8 Aug 2014 18:00:23 -0500 (CDT) Subject: [Swift-commit] cog r4042 Message-ID: <20140808230023.3ED0D8D000A9@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r4042 | timgarmstrong | 2014-08-08 17:55:28 -0500 (Fri, 08 Aug 2014) | 1 line Set job manager in run_coaster_job - previously the setting was ignored ------------------------------------------------------------------------ Index: modules/provider-coaster-c-client/src/RunCoasterJob.cpp =================================================================== --- modules/provider-coaster-c-client/src/RunCoasterJob.cpp (revision 4041) +++ modules/provider-coaster-c-client/src/RunCoasterJob.cpp (working copy) @@ -258,6 +258,10 @@ j.setStderrLocation(*str); } + if (jobManager != NULL) { + j.setJobManager(jobManager); + } + client.submit(j, configId); client.waitForJob(j); From ketan at ci.uchicago.edu Mon Aug 11 17:16:30 2014 From: ketan at ci.uchicago.edu (ketan at ci.uchicago.edu) Date: Mon, 11 Aug 2014 17:16:30 -0500 (CDT) Subject: [Swift-commit] r8075 - in SwiftTutorials: . ATPESC_2014-08-14 ATPESC_2014-08-14/mainwrap ATPESC_2014-08-14/subjobs swift-cray-tutorial swift-cray-tutorial/app Message-ID: <20140811221630.10ECA9D87A@svn.ci.uchicago.edu> Author: ketan Date: 2014-08-11 17:16:29 -0500 (Mon, 11 Aug 2014) New Revision: 8075 Added: SwiftTutorials/ATPESC_2014-08-14/ SwiftTutorials/ATPESC_2014-08-14/hello/ SwiftTutorials/ATPESC_2014-08-14/mainwrap/ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/ SwiftTutorials/ATPESC_2014-08-14/mainwrap/hello/ SwiftTutorials/ATPESC_2014-08-14/subjobs/ SwiftTutorials/ATPESC_2014-08-14/subjobs/app/ SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/ Modified: SwiftTutorials/swift-cray-tutorial/app/stats.sh SwiftTutorials/swift-cray-tutorial/setup.sh Log: ATPESC 2014 Modified: SwiftTutorials/swift-cray-tutorial/app/stats.sh =================================================================== --- SwiftTutorials/swift-cray-tutorial/app/stats.sh 2014-08-05 20:50:48 UTC (rev 8074) +++ SwiftTutorials/swift-cray-tutorial/app/stats.sh 2014-08-11 22:16:29 UTC (rev 8075) @@ -9,10 +9,10 @@ printenv | sort } -awk ' +#awk ' -{ sum += $1} +#{ sum += $1} -END { printf("%d\n",sum/NR) } -' $* +#END { printf("%d\n",sum/NR) } +#' $* log 1>&2 Modified: SwiftTutorials/swift-cray-tutorial/setup.sh =================================================================== --- SwiftTutorials/swift-cray-tutorial/setup.sh 2014-08-05 20:50:48 UTC (rev 8074) +++ SwiftTutorials/swift-cray-tutorial/setup.sh 2014-08-11 22:16:29 UTC (rev 8075) @@ -1,4 +1,7 @@ # ensure that this script is being sourced +echo ${BASH_VERSINFO[0]} +echo ${BASH_SOURCE[0]} +echo ${0} if [ ${BASH_VERSINFO[0]} -gt 2 -a "${BASH_SOURCE[0]}" = "${0}" ] ; then echo ERROR: script ${BASH_SOURCE[0]} must be executed as: source ${BASH_SOURCE[0]} From ketan at ci.uchicago.edu Mon Aug 11 17:45:12 2014 From: ketan at ci.uchicago.edu (ketan at ci.uchicago.edu) Date: Mon, 11 Aug 2014 17:45:12 -0500 (CDT) Subject: [Swift-commit] r8076 - in SwiftTutorials/ATPESC_2014-08-14/subjobs: . app config hello scripts Message-ID: <20140811224512.C2BA29D87A@svn.ci.uchicago.edu> Author: ketan Date: 2014-08-11 17:45:12 -0500 (Mon, 11 Aug 2014) New Revision: 8076 Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/app/flexpep.swift SwiftTutorials/ATPESC_2014-08-14/subjobs/app/pe.swift SwiftTutorials/ATPESC_2014-08-14/subjobs/config/ SwiftTutorials/ATPESC_2014-08-14/subjobs/config/apps SwiftTutorials/ATPESC_2014-08-14/subjobs/config/cf SwiftTutorials/ATPESC_2014-08-14/subjobs/config/cfps SwiftTutorials/ATPESC_2014-08-14/subjobs/config/cobalt.xml SwiftTutorials/ATPESC_2014-08-14/subjobs/config/localcoast.xml SwiftTutorials/ATPESC_2014-08-14/subjobs/config/pecos.xml SwiftTutorials/ATPESC_2014-08-14/subjobs/config/vesta.xml SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/catsn.swift SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/catsnsleepmpi.swift SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/in.data SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/mpicatnap.c SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/out.data SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/runsubjob.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/ SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/atest.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/getblocks.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/qsub.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/run.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runflexpepswift.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runjob.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runsubjob.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runswift.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runswift_script.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runtestblock.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/script.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/script2.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/script3.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/script4.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/subswift.sh SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/testblock.sh Log: adding stuff to subjob dir Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/app/flexpep.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/app/flexpep.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/app/flexpep.swift 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,34 @@ +type file; + +app (file _scorefile, file sout, file serr) flexpep (file _pdb) +{ + runjob "/projects/ExM/ketan/openmp-gnu-july16-mini/bin/FlexPepDocking.staticmpi.linuxxlcdebug" + "-database /home/ketan/minirosetta_database" + "-pep_refine" "-s" @_pdb "-ex1" "-ex2aro" + "-use_input_sc" "-nstruct" "1" "-overwrite" + "-scorefile" @_scorefile + stdout=@sout stderr=@serr; +} + +file scores[] ; +file pdb_inputs[] ; + +foreach pdb, j in pdb_inputs { + file sout; + file serr; + (scores[j], sout, serr) = flexpep(pdb); +} + +/* +qsub --env BG_SHAREDMEMSIZE=32MB -t 20 -n 2 --proccount 2 \ + --mode c1 \ + /projects/ExM/ketan/openmp-gnu-july16-mini/bin/FlexPepDocking.staticmpi.linuxxlcdebug \ + -database /home/ketan/minirosetta_database/ \ + -pep_refine \ + -s /home/ketan/hlac-97-D/hlac-97-D-AAADAAAAL_complex_0001.pdb \ + -ex1 \ + -ex2aro \ + -use_input_sc \ + -nstruct 1 -overwrite \ + -scorefile AAADAAAAL_complex_91R.sc +*/ Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/app/pe.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/app/pe.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/app/pe.swift 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,12 @@ +type file; + +app (file o) pe () +{ +# sh "-c" "printenv" stdout=@o; + sh "-c" "/home/wilde/swift/lab/runjob.sh" stdout=@o; +} + +file out[]; +foreach j in [1:@toint(@arg("n","1"))] { + out[j] = pe(); +} Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/config/apps =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/config/apps (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/config/apps 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,12 @@ +localhost truecmd /bin/true null null null +localhost falsecmd /bin/falsecmd null null null +localhost echo /bin/echo null null null +localhost ls /bin/ls null null null +localhost sh /bin/sh null null null +localhost cat /bin/cat null null null +cluster cat /bin/cat null null null +pbs cat /bin/cat null null null +mcs cat /bin/cat null null null +localhost catnap /home/ketan/subjoblab/catnap.sh null null GLOBUS::maxwalltime="00:01:00" +#localhost runjob /home/ketan/subjoblab/runjob.sh null null GLOBUS::maxwalltime="00:01:00" +localhost runjob /home/ketan/subjoblab/runsubjob.sh null null GLOBUS::maxwalltime="00:01:00" Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/config/cf =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/config/cf (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/config/cf 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,7 @@ +wrapperlog.always.transfer=true +sitedir.keep=true +execution.retries=0 +lazy.errors=false +status.mode=provider +use.provider.staging=false +provider.staging.pin.swiftfiles=false Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/config/cfps =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/config/cfps (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/config/cfps 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,8 @@ +wrapperlog.always.transfer=true +sitedir.keep=true +execution.retries=0 +lazy.errors=false +status.mode=provider +use.provider.staging=true +provider.staging.pin.swiftfiles=true +use.wrapper.staging=false Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/config/cobalt.xml =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/config/cobalt.xml (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/config/cobalt.xml 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,23 @@ + + + + + 5.11 + 10000 + 8 + 1 + 1 + 1 + 900 + _WORK_ + + + Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/config/localcoast.xml =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/config/localcoast.xml (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/config/localcoast.xml 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,17 @@ + + + + + + 4.79 + 10000 + 1 + 32 + 32 + 3300 + + + /home/ketan/swiftwork + + + Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/config/pecos.xml =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/config/pecos.xml (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/config/pecos.xml 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,25 @@ + + + + + + /tmp/ketan/swiftwork + local + + + + + + 2 + 100 + 100 + 00:05:00 + 5 + 1 + 1 + 4.80 + 10000 + /home/ketan/swiftwork + + + Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/config/vesta.xml =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/config/vesta.xml (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/config/vesta.xml 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,23 @@ + + + + + 5.11 + 10000 + 8 + 1 + 1 + 1 + 900 + /gpfs/mira-home/wilde/swiftwork + + + Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/catsn.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/catsn.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/catsn.swift 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,12 @@ +type file; + +app (file o) cat (file i) +{ + cat @i stdout=@o; +} + +file out[]; +foreach j in [1:@toint(@arg("n","1"))] { + file data<"data.txt">; + out[j] = cat(data); +} Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/catsnsleepmpi.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/catsnsleepmpi.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/catsnsleepmpi.swift 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,15 @@ +type file; + +app (file o, file sout, file serr) cat (file i) +{ + runjob "/home/ketan/subjoblab/mpicatnap" @i @o @arg("s","1") stdout=@sout stderr=@serr; +} + +file out[]; + +foreach j in [1:toint(arg("n","1"))] { + file data<"data.txt">; + file sout; + file serr; + (out[j],sout,serr) = cat(data); +} Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/in.data =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/in.data (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/in.data 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1 @@ +this is my input Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/mpicatnap.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/mpicatnap.c (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/mpicatnap.c 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,45 @@ +#include +#include +#include +#include + +int main (argc, argv) +int argc; +char *argv[]; +{ + int rank, size; + + MPI_Init (&argc, &argv); /* starts MPI */ + + char *ifile = argv[1]; + char *ofile = argv[2]; + int sleeptime = atoi(argv[3]); + + MPI_Comm_rank (MPI_COMM_WORLD, &rank); /* get current MPI process id (rank) */ + MPI_Comm_size (MPI_COMM_WORLD, &size); /* get number of MPI processes */ + + if (rank==0) { + printf("ifile=%s ofile=%s sleeptime=%d\n", ifile, ofile, sleeptime); + + int ifd = open(ifile,O_RDONLY); + int ofd = open(ofile,O_WRONLY|O_CREAT,0664); + char buf[1024*1024]; + for(;;) { + int rc = read(ifd, buf, sizeof(buf)); + if (rc <= 0) { + close(ifd); + close(ofd); + break; + } + write(ofd, buf, rc); + } + } + + sleep(sleeptime); + + char host[512]; + gethostname(host, 512); + printf( "Hello from process %d of %d on %s\n", rank, size, host); + MPI_Finalize(); + return 0; +} Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/out.data =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/out.data (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/out.data 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1 @@ +this is my input Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/runsubjob.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/runsubjob.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/runsubjob.sh 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,16 @@ +#! /bin/bash + +BLOCK=$COBALT_PARTNAME +SWIFT_SUBBLOCK_ARRAY=($SWIFT_SUBBLOCKS) +SUBBLOCK=${SWIFT_SUBBLOCK_ARRAY[$SWIFT_JOB_SLOT]} + +echo $0: running BLOCK=$BLOCK SLOT=$SWIFT_JOB_SLOT SUBBLOCK=$SUBBLOCK +echo $0: running cmd: $0 args: $* + +echo $0: running runjob --block $BLOCK --corner $SUBBLOCK --shape 1x1x1x1x1 : $* + +sleep 1 +runjob --strace 0 --block $BLOCK --corner $SUBBLOCK --shape 1x1x1x1x1 --ranks-per-node 1 : $* +sleep 1 + +exit 0 Property changes on: SwiftTutorials/ATPESC_2014-08-14/subjobs/hello/runsubjob.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/atest.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/atest.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/atest.sh 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,12 @@ +#! /bin/bash + +BLOCKS="VST-20040-31371-128 +VST-22040-33371-128 +VST-02040-13371-128 +VST-00040-11371-128" + +ba=($BLOCKS) + +for i in ${!ba[*]}; do + echo ba[$i]=${ba[$i]} +done Property changes on: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/atest.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/getblocks.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/getblocks.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/getblocks.sh 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,6 @@ +#! /bin/sh + +set -x + +qsub -A ATPESC2014 -n 32 -t 5 -q low --mode script --disable_preboot testblock.sh + Property changes on: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/getblocks.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/qsub.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/qsub.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/qsub.sh 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,12 @@ +qsub --env BG_SHAREDMEMSIZE=32MB -t 20 -n 2 --proccount 2 \ + --mode c1 \ + /projects/ExM/ketan/openmp-gnu-july16-mini/bin/FlexPepDocking.staticmpi.linuxxlcdebug \ + -database /home/ketan/minirosetta_database/ \ + -pep_refine \ + -s /home/ketan/hlac-97-D/hlac-97-D-AAADAAAAL_complex_0001.pdb \ + -ex1 \ + -ex2aro \ + -use_input_sc \ + -nstruct 1 -overwrite \ + -scorefile AAADAAAAL_complex_91R.sc + Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/run.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/run.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/run.sh 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,5 @@ +#! /bin/sh + +set -x + +qsub -A ATPESC2014 -n 512 -t 5 -q low --mode script --disable_preboot script3.sh # ADD as params: mpicatnap in.data out.data 3 Property changes on: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/run.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runflexpepswift.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runflexpepswift.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runflexpepswift.sh 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,6 @@ +#! /bin/sh + +qsub -A ATPESC2014 -n 64 -t 59 --mode script runswift_script.sh -config cf -tc.file apps -sites.file localcoast.xml flexpep.swift + +# --disable_preboot + Property changes on: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runflexpepswift.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runjob.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runjob.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runjob.sh 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,24 @@ +#! /bin/bash + +# BLOCKS="VST-20040-31371-128 +# VST-22040-33371-128 +# VST-02040-13371-128 +# VST-00040-11371-128 +# VST-22040-33371-128 +# VST-02040-13371-128 +# VST-00040-11371-128 +# VST-22040-33371-128 +# VST-02040-13371-128 +# VST-00040-11371-128 +# VST-22040-33371-128 +# VST-02040-13371-128 +# VST-00040-11371-128" + +ba=($BLOCKS) +BLOCK=${ba[$SWIFT_JOB_SLOT]} + +echo running block $SWIFT_JOB_SLOT BLOCK=$BLOCK +echo running cmd: $0 args: $* + +runjob --strace 0 --block $BLOCK : $* +# runjob --block $BLOCK : $* Property changes on: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runjob.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runsubjob.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runsubjob.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runsubjob.sh 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,16 @@ +#! /bin/bash + +BLOCK=$COBALT_PARTNAME +SWIFT_SUBBLOCK_ARRAY=($SWIFT_SUBBLOCKS) +SUBBLOCK=${SWIFT_SUBBLOCK_ARRAY[$SWIFT_JOB_SLOT]} + +echo $0: running BLOCK=$BLOCK SLOT=$SWIFT_JOB_SLOT SUBBLOCK=$SUBBLOCK +echo $0: running cmd: $0 args: $* + +echo $0: running runjob --block $BLOCK --corner $SUBBLOCK --shape 1x1x1x1x1 : $* + +sleep 1 +runjob --strace 0 --block $BLOCK --corner $SUBBLOCK --shape 1x1x1x1x1 --ranks-per-node 1 : $* +sleep 1 + +exit 0 Property changes on: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runsubjob.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runswift.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runswift.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runswift.sh 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,6 @@ +#! /bin/sh + +qsub -A ATPESC2014 -n 32 -t 5 --mode script runswift_script.sh -config cf -tc.file apps -sites.file localcoast.xml catsnsleepmpi.swift -n=8 -s=0 + +# --disable_preboot + Property changes on: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runswift.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runswift_script.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runswift_script.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/subjobs/scripts/runswift_script.sh 2014-08-11 22:45:12 UTC (rev 8076) @@ -0,0 +1,39 @@ +#!/bin/bash + +genblocks() +{ + # PARTITION=VST-22060-33171-32 + PARTITION=$1 + + corner=$(echo $PARTITION | sed -e 's/VST-//' -e 's/-.*//') + + echo 'obase=2; for(i=0;i<32;i++) {print i; print "\n"}' | bc | + for corner_coord in $(awk -v corner=$corner '{printf("%05d\n", $1+corner)}' ); do + corner_node=$(/soft/cobalt/bgq_hardware_mapper/coord2hardware.py $corner_coord) + echo $corner_node + done +} + +export SWIFT_SUBBLOCKS=$(genblocks $COBALT_PARTNAME) + +echo $0: SWIFT_SUBBLOCKS=$SWIFT_SUBBLOCKS + +if [ "_$SWIFT_SUBBLOCKS" = _ ]; then + echo ERROR: $0: SWIFT_SUBBLOCKS is null. + exit 1 +fi + +export SWIFT_SUBBLOCK_ARRAY=($SWIFT_SUBBLOCKS) + +nsb=${#SWIFT_SUBBLOCK_ARRAY[@]} +for ((sb=0;sb Author: ketan Date: 2014-08-11 17:52:06 -0500 (Mon, 11 Aug 2014) New Revision: 8077 Added: SwiftTutorials/ATPESC_2014-08-14/config/ Removed: SwiftTutorials/ATPESC_2014-08-14/subjobs/config/ Log: moved config to top level From ketan at ci.uchicago.edu Mon Aug 11 17:53:08 2014 From: ketan at ci.uchicago.edu (ketan at ci.uchicago.edu) Date: Mon, 11 Aug 2014 17:53:08 -0500 (CDT) Subject: [Swift-commit] r8078 - SwiftTutorials/ATPESC_2014-08-14/config Message-ID: <20140811225308.DD9899D87A@svn.ci.uchicago.edu> Author: ketan Date: 2014-08-11 17:53:08 -0500 (Mon, 11 Aug 2014) New Revision: 8078 Modified: SwiftTutorials/ATPESC_2014-08-14/config/apps Log: cleanup Modified: SwiftTutorials/ATPESC_2014-08-14/config/apps =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/config/apps 2014-08-11 22:52:06 UTC (rev 8077) +++ SwiftTutorials/ATPESC_2014-08-14/config/apps 2014-08-11 22:53:08 UTC (rev 8078) @@ -1,12 +1,11 @@ -localhost truecmd /bin/true null null null -localhost falsecmd /bin/falsecmd null null null -localhost echo /bin/echo null null null -localhost ls /bin/ls null null null -localhost sh /bin/sh null null null -localhost cat /bin/cat null null null -cluster cat /bin/cat null null null -pbs cat /bin/cat null null null -mcs cat /bin/cat null null null -localhost catnap /home/ketan/subjoblab/catnap.sh null null GLOBUS::maxwalltime="00:01:00" -#localhost runjob /home/ketan/subjoblab/runjob.sh null null GLOBUS::maxwalltime="00:01:00" -localhost runjob /home/ketan/subjoblab/runsubjob.sh null null GLOBUS::maxwalltime="00:01:00" +localhost truecmd /bin/true +localhost falsecmd /bin/falsecmd +localhost echo /bin/echo +localhost ls /bin/ls +localhost sh /bin/sh +localhost cat /bin/cat +cluster cat /bin/cat +pbs cat /bin/cat +mcs cat /bin/cat +localhost catnap /home/ketan/subjoblab/catnap.sh +localhost runjob /home/ketan/subjoblab/runsubjob.sh From ketan at ci.uchicago.edu Mon Aug 11 19:40:35 2014 From: ketan at ci.uchicago.edu (ketan at ci.uchicago.edu) Date: Mon, 11 Aug 2014 19:40:35 -0500 (CDT) Subject: [Swift-commit] r8079 - in SwiftTutorials/ATPESC_2014-08-14: . doc Message-ID: <20140812004035.3526C9D87A@svn.ci.uchicago.edu> Author: ketan Date: 2014-08-11 19:40:35 -0500 (Mon, 11 Aug 2014) New Revision: 8079 Added: SwiftTutorials/ATPESC_2014-08-14/doc/ SwiftTutorials/ATPESC_2014-08-14/doc/PaulRich_talk.pdf Log: Rich talk Added: SwiftTutorials/ATPESC_2014-08-14/doc/PaulRich_talk.pdf =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/doc/PaulRich_talk.pdf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream From wozniak at ci.uchicago.edu Tue Aug 12 10:19:36 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:19:36 -0500 (CDT) Subject: [Swift-commit] r8080 - SwiftTutorials/ATPESC_2014-08-14 Message-ID: <20140812151936.C42309CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:19:36 -0500 (Tue, 12 Aug 2014) New Revision: 8080 Added: SwiftTutorials/ATPESC_2014-08-14/old-stuff/ Log: Adding old-stuff From wozniak at ci.uchicago.edu Tue Aug 12 10:20:22 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:20:22 -0500 (CDT) Subject: [Swift-commit] r8081 - SwiftTutorials/ATPESC_2014-08-14 Message-ID: <20140812152022.109EF9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:20:21 -0500 (Tue, 12 Aug 2014) New Revision: 8081 Added: SwiftTutorials/ATPESC_2014-08-14/wozniak.pptx Log: Wozniak CI talk slides for mining Added: SwiftTutorials/ATPESC_2014-08-14/wozniak.pptx =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/wozniak.pptx ___________________________________________________________________ Added: svn:mime-type + application/octet-stream From wozniak at ci.uchicago.edu Tue Aug 12 10:20:38 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:20:38 -0500 (CDT) Subject: [Swift-commit] r8082 - in SwiftTutorials/ATPESC_2014-08-14: . old-stuff Message-ID: <20140812152038.E87179CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:20:38 -0500 (Tue, 12 Aug 2014) New Revision: 8082 Added: SwiftTutorials/ATPESC_2014-08-14/old-stuff/wozniak.pptx Removed: SwiftTutorials/ATPESC_2014-08-14/wozniak.pptx Log: Put in intended location Copied: SwiftTutorials/ATPESC_2014-08-14/old-stuff/wozniak.pptx (from rev 8081, SwiftTutorials/ATPESC_2014-08-14/wozniak.pptx) =================================================================== (Binary files differ) Deleted: SwiftTutorials/ATPESC_2014-08-14/wozniak.pptx =================================================================== (Binary files differ) From wozniak at ci.uchicago.edu Tue Aug 12 10:20:52 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:20:52 -0500 (CDT) Subject: [Swift-commit] r8083 - SwiftTutorials/ATPESC_2014-08-14 Message-ID: <20140812152052.989F29CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:20:52 -0500 (Tue, 12 Aug 2014) New Revision: 8083 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/ Log: Adding swift-t From wozniak at ci.uchicago.edu Tue Aug 12 10:21:14 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:21:14 -0500 (CDT) Subject: [Swift-commit] r8084 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140812152114.004359CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:21:13 -0500 (Tue, 12 Aug 2014) New Revision: 8084 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/ Log: Adding examples From wozniak at ci.uchicago.edu Tue Aug 12 10:30:07 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:30:07 -0500 (CDT) Subject: [Swift-commit] r8085 - SwiftTutorials/ATPESC_2014-08-14 Message-ID: <20140812153007.2C5CD9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:30:07 -0500 (Tue, 12 Aug 2014) New Revision: 8085 Added: SwiftTutorials/ATPESC_2014-08-14/agenda.txt Log: Blank text agenda Added: SwiftTutorials/ATPESC_2014-08-14/agenda.txt =================================================================== From wozniak at ci.uchicago.edu Tue Aug 12 10:30:34 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:30:34 -0500 (CDT) Subject: [Swift-commit] r8086 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples Message-ID: <20140812153034.32EF19CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:30:34 -0500 (Tue, 12 Aug 2014) New Revision: 8086 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/ Log: Adding 01-hello From wozniak at ci.uchicago.edu Tue Aug 12 10:30:43 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:30:43 -0500 (CDT) Subject: [Swift-commit] r8087 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples Message-ID: <20140812153043.5470E9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:30:43 -0500 (Tue, 12 Aug 2014) New Revision: 8087 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/ Log: Adding 02-loop From wozniak at ci.uchicago.edu Tue Aug 12 10:31:18 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:31:18 -0500 (CDT) Subject: [Swift-commit] r8088 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples Message-ID: <20140812153118.58E5D9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:31:18 -0500 (Tue, 12 Aug 2014) New Revision: 8088 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/ Log: Adding 03-blas From wozniak at ci.uchicago.edu Tue Aug 12 10:31:29 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:31:29 -0500 (CDT) Subject: [Swift-commit] r8089 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples Message-ID: <20140812153129.CFBAD9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:31:29 -0500 (Tue, 12 Aug 2014) New Revision: 8089 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-py/ Log: Adding 03-py From wozniak at ci.uchicago.edu Tue Aug 12 10:31:52 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:31:52 -0500 (CDT) Subject: [Swift-commit] r8090 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples Message-ID: <20140812153152.DDF659CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:31:52 -0500 (Tue, 12 Aug 2014) New Revision: 8090 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/ Removed: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-py/ Log: Rename From wozniak at ci.uchicago.edu Tue Aug 12 10:36:53 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:36:53 -0500 (CDT) Subject: [Swift-commit] r8091 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140812153653.CAE2B9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:36:53 -0500 (Tue, 12 Aug 2014) New Revision: 8091 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/ Log: Adding cfg From wozniak at ci.uchicago.edu Tue Aug 12 10:40:25 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:40:25 -0500 (CDT) Subject: [Swift-commit] r8092 - in SwiftTutorials/ATPESC_2014-08-14/swift-t: cfg examples/01-hello Message-ID: <20140812154025.E23279CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:40:25 -0500 (Tue, 12 Aug 2014) New Revision: 8092 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/settings-compute.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-compute.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-local.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/hello.swift Log: Check in settings Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/settings-compute.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/settings-compute.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/settings-compute.sh 2014-08-12 15:40:25 UTC (rev 8092) @@ -0,0 +1 @@ + Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-compute.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-compute.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-compute.sh 2014-08-12 15:40:25 UTC (rev 8092) @@ -0,0 +1,4 @@ + +TOP=/home/wozniak/Public/sfw/ppc64 +PATH=${TOP}/turbine/scripts/submit/cobalt:${PATH} +PATH=${TOP}/stc/bin:${PATH} Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-local.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-local.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-local.sh 2014-08-12 15:40:25 UTC (rev 8092) @@ -0,0 +1,4 @@ + +TOP=/home/wozniak/Public/sfw/ppc64-login +PATH=${TOP}/turbine/bin:${PATH} +PATH=${TOP}/stc/bin:${PATH} Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/hello.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/hello.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/hello.swift 2014-08-12 15:40:25 UTC (rev 8092) @@ -0,0 +1,7 @@ + +import io; + +main +{ + printf("Hello world!"); +} From wozniak at ci.uchicago.edu Tue Aug 12 10:42:12 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:42:12 -0500 (CDT) Subject: [Swift-commit] r8093 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello Message-ID: <20140812154212.B301F9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:42:12 -0500 (Tue, 12 Aug 2014) New Revision: 8093 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-local.sh Log: Adding run-local.sh Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-local.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-local.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-local.sh 2014-08-12 15:42:12 UTC (rev 8093) @@ -0,0 +1,7 @@ +#!/bin/sh -eu + +source ../../cfg/setup-local.sh + +stc hello.swift +turbine hello.tcl + Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-local.sh ___________________________________________________________________ Added: svn:executable + * From wozniak at ci.uchicago.edu Tue Aug 12 10:45:19 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:45:19 -0500 (CDT) Subject: [Swift-commit] r8094 - SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg Message-ID: <20140812154519.16AB29CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:45:18 -0500 (Tue, 12 Aug 2014) New Revision: 8094 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-compute.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-local.sh Log: Turn off logs Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-compute.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-compute.sh 2014-08-12 15:42:12 UTC (rev 8093) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-compute.sh 2014-08-12 15:45:18 UTC (rev 8094) @@ -2,3 +2,6 @@ TOP=/home/wozniak/Public/sfw/ppc64 PATH=${TOP}/turbine/scripts/submit/cobalt:${PATH} PATH=${TOP}/stc/bin:${PATH} + +export TURBINE_LOG=0 +export ADLB_DEBUG=0 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-local.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-local.sh 2014-08-12 15:42:12 UTC (rev 8093) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-local.sh 2014-08-12 15:45:18 UTC (rev 8094) @@ -2,3 +2,6 @@ TOP=/home/wozniak/Public/sfw/ppc64-login PATH=${TOP}/turbine/bin:${PATH} PATH=${TOP}/stc/bin:${PATH} + +export TURBINE_LOG=0 +export ADLB_DEBUG=0 From wozniak at ci.uchicago.edu Tue Aug 12 10:45:39 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:45:39 -0500 (CDT) Subject: [Swift-commit] r8095 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello Message-ID: <20140812154539.09E0D9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:45:38 -0500 (Tue, 12 Aug 2014) New Revision: 8095 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/ Log: Set ignores Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello ___________________________________________________________________ Added: svn:ignore + hello.tcl From wozniak at ci.uchicago.edu Tue Aug 12 10:55:33 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 10:55:33 -0500 (CDT) Subject: [Swift-commit] r8096 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop Message-ID: <20140812155533.10EBC9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 10:55:32 -0500 (Tue, 12 Aug 2014) New Revision: 8096 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/loop.swift SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-local.sh Log: 2nd example Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/loop.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/loop.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/loop.swift 2014-08-12 15:55:32 UTC (rev 8096) @@ -0,0 +1,22 @@ + +import io; + + at dispatch=WORKER +(int j) compute(int i) "turbine" "0.0" +[ +---- + after [ expr <> * 1000 ] + puts "compute: <> [ expr [clock seconds] % 1000]" + set <> [ expr <> * 2 ] +---- +]; + +main +{ + printf("Running loop..."); + foreach i in [0:9] + { + j = compute(i); + printf("compute(%i) = %i", i, j); + } +} Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-local.sh (from rev 8095, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-local.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-local.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-local.sh 2014-08-12 15:55:32 UTC (rev 8096) @@ -0,0 +1,7 @@ +#!/bin/sh -eu + +source ../../cfg/setup-local.sh + +PROGRAM=loop +stc ${PROGRAM}.swift +turbine ${*} ${PROGRAM}.tcl From wozniak at ci.uchicago.edu Tue Aug 12 11:09:05 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 11:09:05 -0500 (CDT) Subject: [Swift-commit] r8097 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140812160905.DA38D9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 11:09:05 -0500 (Tue, 12 Aug 2014) New Revision: 8097 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.swift SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/make-package.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.swift Log: Check in BLAS example Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.swift 2014-08-12 16:09:05 UTC (rev 8097) @@ -0,0 +1,9 @@ + +(float z) blas_ddot(int N, float X[], float Y[]) +{ + blob x = blob_from_floats(X); + blob y = blob_from_floats(Y); + z = blas_ddot_blobs(N, x, y); +} + +(float z) blas_ddot_blobs(int n, blob x, blob y) "blas" "0.0.1" "ddot"; Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh 2014-08-12 16:09:05 UTC (rev 8097) @@ -0,0 +1,58 @@ +#!/bin/bash -eu + +# Build the blas leaf package + +LEAF_PKG=blas +LEAF_SO="libtcl${LEAF_PKG}.so" +LEAF_TCL="${LEAF_PKG}.tcl" + +CBLAS_HOME=/home/wozniak/downloads/ppc64/gcc-login/CBLAS +# BLAS_O=$( ls ${BLAS_HOME}/*.o ) +# CBLAS_INCLUDE=${CBLAS_HOME}/include +# CBLAS_O=$( ls ${CBLAS_HOME}/src/*.o ) + +BLAS_A=$( ls ${BLAS_HOME}/*.a ) +CBLAS_A=$( ls ${CBLAS_HOME}/lib/*.a ) + +check() +{ + CODE=${?} + if [[ ${CODE} != 0 ]] + then + MSG=$1 + echo ${MSG} + exit ${CODE} + fi +} + +check "Could not find tclsh in PATH!" + +TCL_HOME=/home/wozniak/Public/sfw/ppc64-login/tcl-8.5.12 +TCL_CONFIG=${TCL_HOME}/lib/tclConfig.sh +# TCLSH= + +# This loads many Tcl configuration variables +source ${TCL_CONFIG} +check "tclConfig.sh failed!" + +CFLAGS="-fPIC -std=gnu99 -g -I ${CBLAS_INCLUDE}" + +# Compile the Tcl extension +gcc ${CFLAGS} ${TCL_INCLUDE_SPEC} -c ${LEAF_PKG}_wrap.c +check + +# Build the Tcl extension as a shared library +gcc -shared -o ${LEAF_SO} ${LEAF_PKG}_wrap.o ${CBLAS_A} ${BLAS_A} +check +echo "created library: ${LEAF_SO}" + +# Make the Tcl package index +export LEAF_PKG LEAF_SO LEAF_TCL +${TCLSH} make-package.tcl > pkgIndex.tcl +check +echo "created package." + +# Tell the user what they need to do to run this +echo "Set in environment: TURBINE_USER_LIB=${PWD}" + +exit 0 Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/make-package.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/make-package.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/make-package.tcl 2014-08-12 16:09:05 UTC (rev 8097) @@ -0,0 +1,8 @@ + +set name $env(LEAF_PKG) +set version 0.0.1 +set leaf_so $env(LEAF_SO) +set leaf_tcl $env(LEAF_TCL) + +puts [ ::pkg::create -name $name -version $version \ + -load $leaf_so -source $leaf_tcl ] Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.sh 2014-08-12 16:09:05 UTC (rev 8097) @@ -0,0 +1,33 @@ +#!/bin/bash + +export TURBINE_USER_LIB=${PWD} + +check() +{ + if [[ ${?} != 0 ]] + then + MSG=$1 + echo ${MSG} + fi +} + +STC=$( which stc ) +check +echo "using stc: ${STC}" + +TURBINE=$( which turbine ) +check +echo "using turbine: ${TURBINE}" + +STC_OUT=test-blas.tcl +${STC} test-blas.swift ${STC_OUT} +check + +echo "compiled to: ${STC_OUT}" + +export ADLB_EXHAUST_TIME=1 +export TURBINE_USER_LIB=${PWD} +${TURBINE} -l -n 3 ${STC_OUT} +check + +exit 0 Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.swift 2014-08-12 16:09:05 UTC (rev 8097) @@ -0,0 +1,19 @@ + +#include +#include +#include "blas.swift" + +main { + // Swift floats are 64-bit + float A[]; + float B[]; + int N = 3; + foreach i in [0:N-1] + { + A[i] = itof(i); + B[i] = itof(i+1); + } + + float z = blas_ddot(N, A, B); + printf("A*B=%0.1f", z); +} From wozniak at ci.uchicago.edu Tue Aug 12 11:13:03 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 11:13:03 -0500 (CDT) Subject: [Swift-commit] r8098 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140812161303.E2C1E9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 11:13:03 -0500 (Tue, 12 Aug 2014) New Revision: 8098 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas_wrap.c Log: Adding blas_wrap.c Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas_wrap.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas_wrap.c (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas_wrap.c 2014-08-12 16:13:03 UTC (rev 8098) @@ -0,0 +1,83 @@ + +#include + +#include + +#include "cblas.h" + +/** + Set leaf package name here: +*/ +#define LEAF_PKG_NAME blas + +/** + Set leaf package version here: +*/ +#define LEAF_PKG_VERSION 0.0.1 + +/** + Shorten command creation lines. + The namespace is prepended + */ +#define COMMAND(tcl_function, pkg, c_function) + +/** + usage: blas::ddot [ N blob_X blob_Y ] => double_result + Z = dot product X*Y + */ +static int +BLAS_ddot_Cmd(ClientData cdata, Tcl_Interp *interp, + int objc, Tcl_Obj *const objv[]) +{ + assert(objc == 4); + int N; + double* X; + double* Y; + int rc; + + // Unpack Tcl inputs + rc = Tcl_GetIntFromObj(interp, objv[1], &N); + assert(rc == TCL_OK); + long pointer; + rc = Tcl_GetLongFromObj(interp, objv[2], &pointer); + assert(rc == TCL_OK); + X = (double*) pointer; + rc = Tcl_GetLongFromObj(interp, objv[3], &pointer); + assert(rc == TCL_OK); + Y = (double*) pointer; + + /* printf("N: %i\n", N); */ + /* for (int i = 0; i < N; i++) */ + /* { */ + /* printf("X[%i]=%f\n", i, X[i]); */ + /* printf("Y[%i]=%f\n", i, Y[i]); */ + /* } */ + + // Call BLAS + double Z = cblas_ddot(N, X, 1, Y, 1); + + // Pack Tcl outputs + Tcl_Obj* result = Tcl_NewDoubleObj(Z); + Tcl_SetObjResult(interp, result); + return TCL_OK; +} + +int DLLEXPORT +Tclblas_Init(Tcl_Interp *interp) +{ + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) + return TCL_ERROR; + + if (Tcl_PkgProvide(interp, "blas", "0.0.1") == TCL_ERROR) + return TCL_ERROR; + + Tcl_CreateObjCommand(interp, + "blas::c::ddot", BLAS_ddot_Cmd, + NULL, NULL); + + Tcl_Namespace* ns = + Tcl_FindNamespace(interp, "blas", NULL, 0); + + Tcl_Export(interp, ns, "*", 0); + return TCL_OK; +} From wozniak at ci.uchicago.edu Tue Aug 12 11:14:02 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 11:14:02 -0500 (CDT) Subject: [Swift-commit] r8099 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140812161402.908D89D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 11:14:02 -0500 (Tue, 12 Aug 2014) New Revision: 8099 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh Log: Fixes to build.sh Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh 2014-08-12 16:13:03 UTC (rev 8098) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh 2014-08-12 16:14:02 UTC (rev 8099) @@ -6,9 +6,11 @@ LEAF_SO="libtcl${LEAF_PKG}.so" LEAF_TCL="${LEAF_PKG}.tcl" +BLAS_HOME=/home/wozniak/downloads/ppc64/gcc-login/BLAS CBLAS_HOME=/home/wozniak/downloads/ppc64/gcc-login/CBLAS + # BLAS_O=$( ls ${BLAS_HOME}/*.o ) -# CBLAS_INCLUDE=${CBLAS_HOME}/include +CBLAS_INCLUDE=${CBLAS_HOME}/include # CBLAS_O=$( ls ${CBLAS_HOME}/src/*.o ) BLAS_A=$( ls ${BLAS_HOME}/*.a ) @@ -29,7 +31,7 @@ TCL_HOME=/home/wozniak/Public/sfw/ppc64-login/tcl-8.5.12 TCL_CONFIG=${TCL_HOME}/lib/tclConfig.sh -# TCLSH= +TCLSH=${TCL_HOME}/bin/tclsh8.5 # This loads many Tcl configuration variables source ${TCL_CONFIG} From wozniak at ci.uchicago.edu Tue Aug 12 11:14:32 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 11:14:32 -0500 (CDT) Subject: [Swift-commit] r8100 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140812161432.9A3B49D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 11:14:32 -0500 (Tue, 12 Aug 2014) New Revision: 8100 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh Removed: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.sh Log: Rename Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh (from rev 8098, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh 2014-08-12 16:14:32 UTC (rev 8100) @@ -0,0 +1,33 @@ +#!/bin/bash + +export TURBINE_USER_LIB=${PWD} + +check() +{ + if [[ ${?} != 0 ]] + then + MSG=$1 + echo ${MSG} + fi +} + +STC=$( which stc ) +check +echo "using stc: ${STC}" + +TURBINE=$( which turbine ) +check +echo "using turbine: ${TURBINE}" + +STC_OUT=test-blas.tcl +${STC} test-blas.swift ${STC_OUT} +check + +echo "compiled to: ${STC_OUT}" + +export ADLB_EXHAUST_TIME=1 +export TURBINE_USER_LIB=${PWD} +${TURBINE} -l -n 3 ${STC_OUT} +check + +exit 0 Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.sh 2014-08-12 16:14:02 UTC (rev 8099) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.sh 2014-08-12 16:14:32 UTC (rev 8100) @@ -1,33 +0,0 @@ -#!/bin/bash - -export TURBINE_USER_LIB=${PWD} - -check() -{ - if [[ ${?} != 0 ]] - then - MSG=$1 - echo ${MSG} - fi -} - -STC=$( which stc ) -check -echo "using stc: ${STC}" - -TURBINE=$( which turbine ) -check -echo "using turbine: ${TURBINE}" - -STC_OUT=test-blas.tcl -${STC} test-blas.swift ${STC_OUT} -check - -echo "compiled to: ${STC_OUT}" - -export ADLB_EXHAUST_TIME=1 -export TURBINE_USER_LIB=${PWD} -${TURBINE} -l -n 3 ${STC_OUT} -check - -exit 0 From wozniak at ci.uchicago.edu Tue Aug 12 11:17:37 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 11:17:37 -0500 (CDT) Subject: [Swift-commit] r8101 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140812161737.ABDCE9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 11:17:37 -0500 (Tue, 12 Aug 2014) New Revision: 8101 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.tcl Log: Adding blas.tcl Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.tcl 2014-08-12 16:17:37 UTC (rev 8101) @@ -0,0 +1,35 @@ + +# BLAS Turbine Tcl wrapper + +namespace eval blas { + + proc ddot { stack outputs inputs } { + + turbine::rule "ddot-$outputs" $inputs $turbine::LOCAL \ + "blas::ddot_body $outputs $inputs" + } + + proc ddot_body { z n x y } { + + puts "$z,$n,$x,$y" + + set N [ retrieve_integer $n ] + # Note: L = [ list pointer length ] + set LX [ adlb::blob_cache $x ] + set pointerX [ lindex $LX 0 ] + set lengthX [ lindex $LX 1 ] + set LY [ adlb::blob_cache $y ] + set pointerY [ lindex $LY 0 ] + set lengthY [ lindex $LY 1 ] + + if { $lengthX != $lengthY } { + error "ddot: length(x) != length(y)" + } + + set result [ blas::c::ddot $N $pointerX $pointerY ] + puts "result: $result" + turbine::store_float $z $result + adlb::blob_free $x + adlb::blob_free $y + } +} From wozniak at ci.uchicago.edu Tue Aug 12 11:35:09 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 11:35:09 -0500 (CDT) Subject: [Swift-commit] r8102 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140812163509.B48549D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 11:35:09 -0500 (Tue, 12 Aug 2014) New Revision: 8102 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/dot.swift Removed: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.swift Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.swift SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh Log: BLAS example works Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.swift 2014-08-12 16:17:37 UTC (rev 8101) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.swift 2014-08-12 16:35:09 UTC (rev 8102) @@ -6,4 +6,12 @@ z = blas_ddot_blobs(N, x, y); } -(float z) blas_ddot_blobs(int n, blob x, blob y) "blas" "0.0.1" "ddot"; +// (float z) blas_ddot_blobs(int n, blob x, blob y) "blas" "0.0.1" "ddot"; + +(float z) blas_ddot_blobs(int n, blob x, blob y) +"blas" "0.0.1" +[ +---- + set <> [ blas::ddot_impl <> <> <> ] +---- +]; Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.tcl 2014-08-12 16:17:37 UTC (rev 8101) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.tcl 2014-08-12 16:35:09 UTC (rev 8102) @@ -3,33 +3,40 @@ namespace eval blas { - proc ddot { stack outputs inputs } { + # proc ddot { stack outputs inputs } { - turbine::rule "ddot-$outputs" $inputs $turbine::LOCAL \ - "blas::ddot_body $outputs $inputs" - } + # turbine::rule "ddot-$outputs" $inputs $turbine::LOCAL \ + # "blas::ddot_body $outputs $inputs" + # } - proc ddot_body { z n x y } { + # proc ddot_body { z n x y } { - puts "$z,$n,$x,$y" + # puts "$z,$n,$x,$y" - set N [ retrieve_integer $n ] - # Note: L = [ list pointer length ] - set LX [ adlb::blob_cache $x ] - set pointerX [ lindex $LX 0 ] - set lengthX [ lindex $LX 1 ] - set LY [ adlb::blob_cache $y ] - set pointerY [ lindex $LY 0 ] - set lengthY [ lindex $LY 1 ] + # set N [ retrieve_integer $n ] + # # Note: L = [ list pointer length ] + # set LX [ adlb::blob_cache $x ] + # set pointerX [ lindex $LX 0 ] + # set lengthX [ lindex $LX 1 ] + # set LY [ adlb::blob_cache $y ] + # set pointerY [ lindex $LY 0 ] + # set lengthY [ lindex $LY 1 ] - if { $lengthX != $lengthY } { - error "ddot: length(x) != length(y)" - } + # if { $lengthX != $lengthY } { + # error "ddot: length(x) != length(y)" + # } - set result [ blas::c::ddot $N $pointerX $pointerY ] - puts "result: $result" - turbine::store_float $z $result - adlb::blob_free $x - adlb::blob_free $y + # set result [ blas::c::ddot $N $pointerX $pointerY ] + # puts "result: $result" + # turbine::store_float $z $result + # adlb::blob_free $x + # adlb::blob_free $y + # } + + proc ddot_impl { n x y } { + set x_ptr [ lindex $x 0 ] + set y_ptr [ lindex $y 0 ] + set z [ blas::c::ddot $n $x_ptr $y_ptr ] + return $z } } Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/dot.swift (from rev 8098, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.swift) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/dot.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/dot.swift 2014-08-12 16:35:09 UTC (rev 8102) @@ -0,0 +1,35 @@ + +/** + Example 3 - DOT.SWIFT +*/ + +// Swift/T libraries: +import blob; +import io; +import matrix; + +// BLAS library for this example: +import blas; + +main +{ + // Swift floats are 64-bit + float A[]; + float B[]; + int N = 3; + foreach i in [0:N-1] + { + A[i] = itof(i); + B[i] = itof(i+1); + } + + // Use => for output ordering + printf("A") => + vector_print(A) => + printf("\nB") => + vector_print(B) + => + float z = blas_ddot(N, A, B); + + printf("\nA*B=%0.1f", z); +} Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh 2014-08-12 16:17:37 UTC (rev 8101) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh 2014-08-12 16:35:09 UTC (rev 8102) @@ -1,33 +1,9 @@ -#!/bin/bash +#!/bin/bash -eu -export TURBINE_USER_LIB=${PWD} +source ../../cfg/setup-local.sh -check() -{ - if [[ ${?} != 0 ]] - then - MSG=$1 - echo ${MSG} - fi -} - -STC=$( which stc ) -check -echo "using stc: ${STC}" - -TURBINE=$( which turbine ) -check -echo "using turbine: ${TURBINE}" - -STC_OUT=test-blas.tcl -${STC} test-blas.swift ${STC_OUT} -check - -echo "compiled to: ${STC_OUT}" - -export ADLB_EXHAUST_TIME=1 export TURBINE_USER_LIB=${PWD} -${TURBINE} -l -n 3 ${STC_OUT} -check -exit 0 +PROGRAM=dot +stc ${PROGRAM}.swift +turbine ${PROGRAM}.tcl Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.swift 2014-08-12 16:17:37 UTC (rev 8101) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/test-blas.swift 2014-08-12 16:35:09 UTC (rev 8102) @@ -1,19 +0,0 @@ - -#include -#include -#include "blas.swift" - -main { - // Swift floats are 64-bit - float A[]; - float B[]; - int N = 3; - foreach i in [0:N-1] - { - A[i] = itof(i); - B[i] = itof(i+1); - } - - float z = blas_ddot(N, A, B); - printf("A*B=%0.1f", z); -} From wozniak at ci.uchicago.edu Tue Aug 12 11:35:34 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 11:35:34 -0500 (CDT) Subject: [Swift-commit] r8103 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140812163534.C7B5C9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 11:35:34 -0500 (Tue, 12 Aug 2014) New Revision: 8103 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/ Log: Set ignores Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas ___________________________________________________________________ Added: svn:ignore + pkgIndex.tcl dot.tcl From wozniak at ci.uchicago.edu Tue Aug 12 11:56:24 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 11:56:24 -0500 (CDT) Subject: [Swift-commit] r8104 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py Message-ID: <20140812165624.596229D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 11:56:24 -0500 (Tue, 12 Aug 2014) New Revision: 8104 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-local.sh Log: Working Python example Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift 2014-08-12 16:56:24 UTC (rev 8104) @@ -0,0 +1,43 @@ + +import io; +import python; +import string; + +f() +{ + python( +---- +print("Python works!") +repr(0) +----); +} + +global const string numpy = "from numpy import *\n\n"; + +typedef matrix string; + +(matrix A) eye(int n) +{ + string command = sprintf("repr(eye(%i))", n); + string code = numpy+command; + matrix t = python(code); + A = replace_all(t, "\n", "", 0); +} + +(matrix R) add(matrix A1, matrix A2) +{ + string command = sprintf("repr(%s+%s)", A1, A2); + string code = numpy+command; + matrix t = python(code); + R = replace_all(t, "\n", "", 0); +} + +main +{ + f(); + matrix A1 = eye(3); + matrix A2 = eye(3); + matrix sum = add(A1, A2); + printf("2*eye(3)=%s", sum); +} + Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-local.sh (from rev 8102, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-local.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-local.sh 2014-08-12 16:56:24 UTC (rev 8104) @@ -0,0 +1,7 @@ +#!/bin/bash -eu + +source ../../cfg/setup-local.sh + +PROGRAM=numpy +stc ${PROGRAM}.swift +turbine ${PROGRAM}.tcl From wozniak at ci.uchicago.edu Tue Aug 12 11:59:38 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 11:59:38 -0500 (CDT) Subject: [Swift-commit] r8105 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py Message-ID: <20140812165938.1699F9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 11:59:37 -0500 (Tue, 12 Aug 2014) New Revision: 8105 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/add.swift Removed: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-local.sh Log: Rename, make numpy library Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/add.swift (from rev 8104, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/add.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/add.swift 2014-08-12 16:59:37 UTC (rev 8105) @@ -0,0 +1,27 @@ + +// Swift/T libraries: +import io; +import python; +import string; + +// This example: See ./numpy.swift +import numpy; + +f() +{ + python( +---- +print("Python works!") +repr(0) +----); +} + +main +{ + f(); + matrix A1 = eye(3); + matrix A2 = eye(3); + matrix sum = add(A1, A2); + printf("2*eye(3)=%s", sum); +} + Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift 2014-08-12 16:56:24 UTC (rev 8104) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift 2014-08-12 16:59:37 UTC (rev 8105) @@ -1,43 +0,0 @@ - -import io; -import python; -import string; - -f() -{ - python( ----- -print("Python works!") -repr(0) -----); -} - -global const string numpy = "from numpy import *\n\n"; - -typedef matrix string; - -(matrix A) eye(int n) -{ - string command = sprintf("repr(eye(%i))", n); - string code = numpy+command; - matrix t = python(code); - A = replace_all(t, "\n", "", 0); -} - -(matrix R) add(matrix A1, matrix A2) -{ - string command = sprintf("repr(%s+%s)", A1, A2); - string code = numpy+command; - matrix t = python(code); - R = replace_all(t, "\n", "", 0); -} - -main -{ - f(); - matrix A1 = eye(3); - matrix A2 = eye(3); - matrix sum = add(A1, A2); - printf("2*eye(3)=%s", sum); -} - Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-local.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-local.sh 2014-08-12 16:56:24 UTC (rev 8104) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-local.sh 2014-08-12 16:59:37 UTC (rev 8105) @@ -2,6 +2,6 @@ source ../../cfg/setup-local.sh -PROGRAM=numpy +PROGRAM=add stc ${PROGRAM}.swift turbine ${PROGRAM}.tcl From wozniak at ci.uchicago.edu Tue Aug 12 11:59:45 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 11:59:45 -0500 (CDT) Subject: [Swift-commit] r8106 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py Message-ID: <20140812165945.575A69D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 11:59:45 -0500 (Tue, 12 Aug 2014) New Revision: 8106 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift Log: Adding numpy.swift Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift 2014-08-12 16:59:45 UTC (rev 8106) @@ -0,0 +1,22 @@ + +// Numpy/Swift library + +global const string numpy = "from numpy import *\n\n"; + +typedef matrix string; + +(matrix A) eye(int n) +{ + string command = sprintf("repr(eye(%i))", n); + string code = numpy+command; + matrix t = python(code); + A = replace_all(t, "\n", "", 0); +} + +(matrix R) add(matrix A1, matrix A2) +{ + string command = sprintf("repr(%s+%s)", A1, A2); + string code = numpy+command; + matrix t = python(code); + R = replace_all(t, "\n", "", 0); +} From wozniak at ci.uchicago.edu Tue Aug 12 11:59:55 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 11:59:55 -0500 (CDT) Subject: [Swift-commit] r8107 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py Message-ID: <20140812165955.039959D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 11:59:54 -0500 (Tue, 12 Aug 2014) New Revision: 8107 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/ Log: Set ignores Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py ___________________________________________________________________ Added: svn:ignore + add.tcl From wilde at ci.uchicago.edu Tue Aug 12 12:30:15 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Tue, 12 Aug 2014 12:30:15 -0500 (CDT) Subject: [Swift-commit] r8108 - in SwiftTutorials/ATPESC_2014-08-14: . lecture Message-ID: <20140812173015.78EC69CC96@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-12 12:30:15 -0500 (Tue, 12 Aug 2014) New Revision: 8108 Added: SwiftTutorials/ATPESC_2014-08-14/lecture/ SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftT.pptx SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_Workflow.pptx Log: Add base version of lecture slides, from ATPESC 2013 and Justins CI talk. Added: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftT.pptx =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftT.pptx ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_Workflow.pptx =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_Workflow.pptx ___________________________________________________________________ Added: svn:mime-type + application/octet-stream From wozniak at ci.uchicago.edu Tue Aug 12 12:33:44 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 12:33:44 -0500 (CDT) Subject: [Swift-commit] r8109 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140812173344.CD4529CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 12:33:44 -0500 (Tue, 12 Aug 2014) New Revision: 8109 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/clean.sh Log: Adding clean.sh Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/clean.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/clean.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/clean.sh 2014-08-12 17:33:44 UTC (rev 8109) @@ -0,0 +1,6 @@ +#!/bin/sh -eu + +# CLEAN.SH + +rm -fv dot.tcl *.o *.so pkgIndex.tcl + Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/clean.sh ___________________________________________________________________ Added: svn:executable + * From wozniak at ci.uchicago.edu Tue Aug 12 12:34:21 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 12:34:21 -0500 (CDT) Subject: [Swift-commit] r8110 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140812173421.0C2919CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 12:34:20 -0500 (Tue, 12 Aug 2014) New Revision: 8110 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh Log: Fix BLAS locations Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh 2014-08-12 17:33:44 UTC (rev 8109) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh 2014-08-12 17:34:20 UTC (rev 8110) @@ -1,17 +1,16 @@ #!/bin/bash -eu +# BUILD.SH # Build the blas leaf package LEAF_PKG=blas LEAF_SO="libtcl${LEAF_PKG}.so" LEAF_TCL="${LEAF_PKG}.tcl" -BLAS_HOME=/home/wozniak/downloads/ppc64/gcc-login/BLAS -CBLAS_HOME=/home/wozniak/downloads/ppc64/gcc-login/CBLAS +BLAS_HOME=/home/wozniak/Public/sfw/ppc64-login/BLAS +CBLAS_HOME=/home/wozniak/Public/sfw/ppc64-login/CBLAS -# BLAS_O=$( ls ${BLAS_HOME}/*.o ) CBLAS_INCLUDE=${CBLAS_HOME}/include -# CBLAS_O=$( ls ${CBLAS_HOME}/src/*.o ) BLAS_A=$( ls ${BLAS_HOME}/*.a ) CBLAS_A=$( ls ${CBLAS_HOME}/lib/*.a ) From ketan at ci.uchicago.edu Tue Aug 12 12:38:43 2014 From: ketan at ci.uchicago.edu (ketan at ci.uchicago.edu) Date: Tue, 12 Aug 2014 12:38:43 -0500 (CDT) Subject: [Swift-commit] r8111 - SwiftTutorials/ATPESC_2014-08-14/mainwrap/app Message-ID: <20140812173843.739B69CC96@svn.ci.uchicago.edu> Author: ketan Date: 2014-08-12 12:38:43 -0500 (Tue, 12 Aug 2014) New Revision: 8111 Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/build-docs.sh SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/clean-data.sh SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/clean.sh SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/create-data.sh SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/install-docs.sh SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/link-static-tcl.sh SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/mockdock.c SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/mockdock.h SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/mockdock.manifest SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/preproc.sh SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/prerun.sh SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/run-cobalt.sh SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/run.sh SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/settings.bgq.sh Log: mockdock Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/build-docs.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/build-docs.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/build-docs.sh 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,5 @@ +#!/bin/bash + +# Build asciidoc html from README.txt + +asciidoc -a toc -a toclevels=2 -a max-width=750px -a textwidth=80 -o README.html README.txt Property changes on: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/build-docs.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/clean-data.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/clean-data.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/clean-data.sh 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,5 @@ +#!/bin/bash -eu + +# Removes data created by create-data.sh + +rm -rfv peptides prots prot.txt Property changes on: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/clean-data.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/clean.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/clean.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/clean.sh 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,9 @@ +#!/bin/bash -eu + +rm -fv *.o *.so *.a mockdock +rm -fv *_wrap* +rm -fv static_leaf_main{,.c} extension.c +rm -fv make-package.tcl pkgIndex.tcl +rm -fv user-code.{swift,tcl} +rm -fv user-leaf.{c,h,tcl} +rm -fv run-*.out Property changes on: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/clean.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/create-data.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/create-data.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/create-data.sh 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,49 @@ +#!/bin/bash -eu + +# Creates input data for mockdock + +usage() { + echo "gendata: usage:" + echo + printf "\t\t gendata " + echo + printf "\t where: \n" + printf "\t\t NUMPEPT is the number of peptides in each entry\n" + printf "\t\t NUMENT is the number of entries\n" +} + +if [[ ${#*} != 2 ]] +then + usage + exit 1 +fi + +numpept=$1 +nument=$2 + +# Clean up +rm -rf peptides + +mkdir -p peptides +pushd peptides 2>&1 > /dev/null + +for j in $(seq 1 $nument) ; do + echo $RANDOM +done > master.txt + +for i in $(seq 1 $numpept) ; do + #symlink to master + ln -s master.txt pept${i}.txt +done + +popd 2>&1 > /dev/null + +echo $RANDOM > prot.txt + +#Create dummy prot files for nested loop +mkdir -p prots +pushd prots 2>&1 > /dev/null +for k in $(seq 1 20) ; do + echo $RANDOM > prot${k}.txt +done +popd 2>&1 > /dev/null Property changes on: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/create-data.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/install-docs.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/install-docs.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/install-docs.sh 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,5 @@ +#!/bin/bash + +# Install asciidoc html in CI WWW + +scp README.html login.ci.uchicago.edu:/ci/www/projects/swift/guides/T/main-wrap.html Property changes on: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/install-docs.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/link-static-tcl.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/link-static-tcl.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/link-static-tcl.sh 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,10 @@ +#!/bin/bash -eu + +bgxlc_r -c -I . \ + -I /home/wozniak/Public/sfw/ppc64/bgxlc/static_r/tcl-8.5.12/include \ + static_leaf_main_tcl.c + + +bgxlc_r -o static_leaf_main_tcl static_leaf_main_tcl.o leaf_main.a \ + -L /home/wozniak/Public/sfw/ppc64/bgxlc/static_r/tcl-8.5.12/lib \ + -ltcl8.5 Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/mockdock.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/mockdock.c (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/mockdock.c 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,65 @@ + +/** + The mockdock application code + May be run as + 1) stand-alone executable via Makefile + 2) as Swift library via genleaf +*/ + +#include +#include +#include +#include +#include +#include +#include +#include "mockdock.h" + +static void usage(void){ + printf("usage: mockdock \n"); +} + +int main(int argc, char** argv){ + + if (argc != 4){ + usage(); + exit(EXIT_FAILURE); + } + char* protfile = argv[1]; + char* peptfile = argv[2]; + int runtime = atoi(argv[3]); + + int fd1 = open(protfile, O_RDONLY); + if (fd1 < 0){ + printf("could not open: %s\n", protfile); + exit(1); + } + + int fd2 = open(peptfile, O_RDONLY); + if (fd2 < 0){ + printf("could not open: %s\n", peptfile); + exit(1); + } + sleep(runtime); + printf("result number: %d\n", dock(fd1, fd2)); + + close(fd1); + close(fd2); + + return 0; +} + +size_t maxsize=10*1024*1024; + +int dock(int fd1, int fd2){ + + char* buf = malloc(maxsize); + + int len1 = read(fd1, buf, maxsize); + assert(len1 >= 0); + + int len2 = read(fd2, buf, maxsize); + assert(len2 >= 0); + + return(len1 * 1000000 + len2); +} Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/mockdock.h =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/mockdock.h (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/mockdock.h 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,2 @@ +int dock(int fd1, int fd2); +int leaf_main(int argc, char** argv); Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/mockdock.manifest =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/mockdock.manifest (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/mockdock.manifest 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,38 @@ + +# MOCKDOCK.MANIFEST +# Manifest file to build Turbine application executable +# Copied from Turbine's example.manifest + +# Name and version of Tcl package +pkg_name = leaf_main +pkg_version = 0.0 + +# C function names to initialise Tcl modules +lib_init = Mockdock_wrap_Init + +# lib scripts are executed in specified order, before main_script and +# after lib_inits +lib_script = mockdock_wrap.tcl + +# Headers for user Tcl code, e.g. lib_init functions +lib_include = mockdock.h +lib_include = extension.h + +# STC-generated Turbine Tcl script. +main_script = user-code.tcl + +# Build info follows: required to compile and link executable + +# lib objects are linked into executable +lib_object = leaf_main.a +# lib_object = /home/wozniak/Public/sfw/ppc64/tcl-8.5.12/lib/libtclstub8.5.a +# lib_object = /home/wozniak/Public/sfw/ppc64/c-utils/lib/libexmcutils.a +# lib_object = /home/wozniak/Public/sfw/ppc64/lb/lib/libadlb.a + +# lib shared object (linked against - not preferred). +# This goes last on link command +linker_libs = + +# Local Variables: +# mode:tcl +# End: Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/preproc.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/preproc.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/preproc.sh 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,4 @@ +# @dispatch=WORKER +# (int v) leaf_main(string arg[], string env[]) "leaf_main" "0.0" "leaf_main"; + +sed -e '/mainapp/i at dispatch=WORKER' -e '/mainapp/s/^.*mainapp \(.*\);/(int v) \1_main(string arg[]) "\1_main" "0.0" "\1_main_wrap";/' Property changes on: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/preproc.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/prerun.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/prerun.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/prerun.sh 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,5 @@ +#!/bin/bash + +ln -s $PWD/peptides $TURBINE_OUTPUT +ln -s $PWD/prots $TURBINE_OUTPUT +ln -s $PWD/prot.txt $TURBINE_OUTPUT Property changes on: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/prerun.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/run-cobalt.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/run-cobalt.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/run-cobalt.sh 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,80 @@ +#!/bin/bash -eu + +show_machine_files() +{ + ( cd $GENLEAF_HOME/settings + ls machine.*.sh | sed 's/machine\.\(.*\).sh/ \t * \1/' ) +} + +usage() +{ + echo "run-cobalt.sh: usage:" + echo + printf "\t\t run-cobalt.sh \n" + echo + printf "\t where: \n" + printf "\t\t MACHINE is the machine type\n" + printf "\t\t PROCS is the number of MPI processes\n" + echo + echo "known machine types:" + show_machine_files +} + +crash() +{ + MSG=$* + echo "crash!" + echo $MSG + exit 1 +} + +TURBINE_RUN=$( which turbine-cobalt-run.zsh ; true ) +if [[ $TURBINE_RUN == "" ]] +then + echo "Could not find turbine-cobalt-run.zsh in PATH!" + exit 1 +fi + +TURBINE_HOME=$( cd $( dirname $TURBINE_RUN )/../../.. ; /bin/pwd ) +GENLEAF_HOME=$TURBINE_HOME/scripts/main-wrap + +echo "TURBINE_HOME=$TURBINE_HOME" + +if [[ ${#*} != 2 ]] +then + usage + exit 1 +fi + +MACHINE=$1 +numprocs=$2 + +# Assert that numprocs is a number: +if ! (( $numprocs + 1 )) ; then + echo "PROCS must be a number: received: $numprocs" + exit 1 +fi + +USER_SWIFT=user-code.swift + +MACHINE_FILE=$TURBINE_HOME/scripts/main-wrap/settings/machine.$MACHINE.sh +[[ -f $MACHINE_FILE ]] || crash "unknown machine type: $MACHINE" +source $MACHINE_FILE + +USER_TCL=user-code.tcl +[[ -f $USER_TCL ]] || crash "could not find compiled Swift runtime code: $USER_TCL" + +rm -rf work +mkdir work + +export TURBINE_OUTPUT=$PWD/work + +ln -s $PWD/peptides $TURBINE_OUTPUT +ln -s $PWD/prot.txt $TURBINE_OUTPUT + +ENV="--env ADLB_DEBUG=0:ADLB_TRACE=0" + +# $TURBINE_RUN -n $numprocs -s settings.bgq.sh $USER_TCL +export PROJECT=ExM +set -x +qsub -n $numprocs -t 5 $ENV $PWD/static_leaf_main Property changes on: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/run-cobalt.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/run.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/run.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/run.sh 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,11 @@ +#!/bin/bash -eu + +# Run the user program locally using normal Turbine +# Creates run-*.out containing a copy of the output + +export TURBINE_USER_LIB=$PWD + +TIME=$( date +%H:%M:%S ) +OUTPUT=run-$TIME.out + +turbine -l -n 4 user-code.tcl |& tee $OUTPUT Property changes on: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/run.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/settings.bgq.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/settings.bgq.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/mainwrap/app/settings.bgq.sh 2014-08-12 17:38:43 UTC (rev 8111) @@ -0,0 +1,10 @@ +export MODE=BGQ +export WALLTIME=00:15:00 +export PROJECT=ExM +export PPN=64 +export QUEUE=default +export ADLB_PRINT_TIME=1 +export TURBINE_LOG=0 +export TURBINE_DEBUG=0 +export TURBINE_ENGINES=128 +export ADLB_SERVERS=128 From wozniak at ci.uchicago.edu Tue Aug 12 12:40:46 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 12:40:46 -0500 (CDT) Subject: [Swift-commit] r8112 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140812174046.82F0C9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 12:40:46 -0500 (Tue, 12 Aug 2014) New Revision: 8112 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.swift SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas_wrap.c Log: Clean up; add note Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.swift 2014-08-12 17:38:43 UTC (rev 8111) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.swift 2014-08-12 17:40:46 UTC (rev 8112) @@ -6,11 +6,12 @@ z = blas_ddot_blobs(N, x, y); } -// (float z) blas_ddot_blobs(int n, blob x, blob y) "blas" "0.0.1" "ddot"; - (float z) blas_ddot_blobs(int n, blob x, blob y) "blas" "0.0.1" [ +// Blobs are presented to Tcl as a [ list pointer length handle ] +// The pointer is an integer: you can cast it to a pointer at the C level +// The length is in bytes - ignore the handle ---- set <> [ blas::ddot_impl <> <> <> ] ---- Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.tcl 2014-08-12 17:38:43 UTC (rev 8111) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas.tcl 2014-08-12 17:40:46 UTC (rev 8112) @@ -3,36 +3,6 @@ namespace eval blas { - # proc ddot { stack outputs inputs } { - - # turbine::rule "ddot-$outputs" $inputs $turbine::LOCAL \ - # "blas::ddot_body $outputs $inputs" - # } - - # proc ddot_body { z n x y } { - - # puts "$z,$n,$x,$y" - - # set N [ retrieve_integer $n ] - # # Note: L = [ list pointer length ] - # set LX [ adlb::blob_cache $x ] - # set pointerX [ lindex $LX 0 ] - # set lengthX [ lindex $LX 1 ] - # set LY [ adlb::blob_cache $y ] - # set pointerY [ lindex $LY 0 ] - # set lengthY [ lindex $LY 1 ] - - # if { $lengthX != $lengthY } { - # error "ddot: length(x) != length(y)" - # } - - # set result [ blas::c::ddot $N $pointerX $pointerY ] - # puts "result: $result" - # turbine::store_float $z $result - # adlb::blob_free $x - # adlb::blob_free $y - # } - proc ddot_impl { n x y } { set x_ptr [ lindex $x 0 ] set y_ptr [ lindex $y 0 ] Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas_wrap.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas_wrap.c 2014-08-12 17:38:43 UTC (rev 8111) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/blas_wrap.c 2014-08-12 17:40:46 UTC (rev 8112) @@ -1,4 +1,10 @@ +/** + BLAS_WRAP.C + Tcl/C interface for BLAS functions + (You can auto-generate this with SWIG) +*/ + #include #include @@ -46,13 +52,6 @@ assert(rc == TCL_OK); Y = (double*) pointer; - /* printf("N: %i\n", N); */ - /* for (int i = 0; i < N; i++) */ - /* { */ - /* printf("X[%i]=%f\n", i, X[i]); */ - /* printf("Y[%i]=%f\n", i, Y[i]); */ - /* } */ - // Call BLAS double Z = cblas_ddot(N, X, 1, Y, 1); From ketan at ci.uchicago.edu Tue Aug 12 12:42:38 2014 From: ketan at ci.uchicago.edu (ketan at ci.uchicago.edu) Date: Tue, 12 Aug 2014 12:42:38 -0500 (CDT) Subject: [Swift-commit] r8113 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140812174238.D1F109CC96@svn.ci.uchicago.edu> Author: ketan Date: 2014-08-12 12:42:38 -0500 (Tue, 12 Aug 2014) New Revision: 8113 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh Log: small change in build Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh 2014-08-12 17:40:46 UTC (rev 8112) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh 2014-08-12 17:42:38 UTC (rev 8113) @@ -54,6 +54,7 @@ echo "created package." # Tell the user what they need to do to run this -echo "Set in environment: TURBINE_USER_LIB=${PWD}" +echo "Set in environment: " +echo "TURBINE_USER_LIB=${PWD}" exit 0 From wozniak at ci.uchicago.edu Tue Aug 12 12:46:40 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 12:46:40 -0500 (CDT) Subject: [Swift-commit] r8114 - SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg Message-ID: <20140812174640.8B3A19CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 12:46:40 -0500 (Tue, 12 Aug 2014) New Revision: 8114 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/settings-compute.sh Log: Fill in settings file for compute nodes Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/settings-compute.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/settings-compute.sh 2014-08-12 17:42:38 UTC (rev 8113) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/settings-compute.sh 2014-08-12 17:46:40 UTC (rev 8114) @@ -1 +1,6 @@ +export MODE=BGQ +export PROJECT=ATPESC2014 +export QUEUE=Q.ATPESC +export WALLTIME=5 # Minutes +export PPN=1 From wozniak at ci.uchicago.edu Tue Aug 12 12:47:16 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 12:47:16 -0500 (CDT) Subject: [Swift-commit] r8115 - in SwiftTutorials/ATPESC_2014-08-14/swift-t/examples: 01-hello 02-loop Message-ID: <20140812174716.125439CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 12:47:15 -0500 (Tue, 12 Aug 2014) New Revision: 8115 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/hello.swift SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/loop.swift Log: Add headers Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/hello.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/hello.swift 2014-08-12 17:46:40 UTC (rev 8114) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/hello.swift 2014-08-12 17:47:15 UTC (rev 8115) @@ -1,4 +1,8 @@ +/** + Example 1 - HELLO.SWIFT +*/ + import io; main Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/loop.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/loop.swift 2014-08-12 17:46:40 UTC (rev 8114) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/loop.swift 2014-08-12 17:47:15 UTC (rev 8115) @@ -1,4 +1,8 @@ +/** + Example 2 - LOOP.SWIFT +*/ + import io; @dispatch=WORKER From wozniak at ci.uchicago.edu Tue Aug 12 12:47:33 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 12:47:33 -0500 (CDT) Subject: [Swift-commit] r8116 - in SwiftTutorials/ATPESC_2014-08-14/swift-t/examples: . 02-loop Message-ID: <20140812174733.8C68E9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 12:47:33 -0500 (Tue, 12 Aug 2014) New Revision: 8116 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/ Log: Set ignores Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples ___________________________________________________________________ Added: svn:ignore + turbine-directory.txt Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop ___________________________________________________________________ Added: svn:ignore + loop.tcl From wozniak at ci.uchicago.edu Tue Aug 12 12:55:47 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 12:55:47 -0500 (CDT) Subject: [Swift-commit] r8117 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello Message-ID: <20140812175547.3A8A39CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 12:55:47 -0500 (Tue, 12 Aug 2014) New Revision: 8117 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh Log: Adding run-compute.sh Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh 2014-08-12 17:55:47 UTC (rev 8117) @@ -0,0 +1,9 @@ +#!/bin/sh -eu + +source ../../cfg/setup-compute.sh +SETTINGS=../../cfg/settings-compute.sh + +PROGRAM=hello.swift +stc ${PROGRAM}.swift +turbine-cobalt-run.zsh -n 4 -s ${SETTINGS} ${PROGRAM}.tcl + Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh ___________________________________________________________________ Added: svn:executable + * From wozniak at ci.uchicago.edu Tue Aug 12 13:04:48 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 13:04:48 -0500 (CDT) Subject: [Swift-commit] r8118 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop Message-ID: <20140812180448.E0FEF9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 13:04:48 -0500 (Tue, 12 Aug 2014) New Revision: 8118 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-compute.sh Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/ Log: Compute node run script Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop ___________________________________________________________________ Modified: svn:ignore - loop.tcl + turbine-directory.txt loop.tcl Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-compute.sh (from rev 8117, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-compute.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-compute.sh 2014-08-12 18:04:48 UTC (rev 8118) @@ -0,0 +1,18 @@ +#!/bin/bash -eu + +source ../../cfg/setup-compute.sh +SETTINGS=../../cfg/settings-compute.sh + +PROCS=4 +while getopts "n:" OPTION +do + echo $OPTION + case ${OPTION} in + n) PROCS=${OPTARG} ;; + *) exit 1 ;; + esac +done + +PROGRAM=loop +stc ${PROGRAM}.swift +turbine-cobalt-run.zsh -n ${PROCS} -s ${SETTINGS} ${PROGRAM}.tcl From wozniak at ci.uchicago.edu Tue Aug 12 13:14:18 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 13:14:18 -0500 (CDT) Subject: [Swift-commit] r8119 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140812181418.CA15A9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 13:14:18 -0500 (Tue, 12 Aug 2014) New Revision: 8119 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-compute.sh Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/ Log: Compute node script Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas ___________________________________________________________________ Modified: svn:ignore - pkgIndex.tcl dot.tcl + turbine-directory.txt pkgIndex.tcl dot.tcl Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-compute.sh (from rev 8117, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-compute.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-compute.sh 2014-08-12 18:14:18 UTC (rev 8119) @@ -0,0 +1,11 @@ +#!/bin/sh -eu + +source ../../cfg/setup-compute.sh +SETTINGS=../../cfg/settings-compute.sh + +export TURBINE_USER_LIB=${PWD} + +PROGRAM=dot +stc ${PROGRAM}.swift +turbine-cobalt-run.zsh -n 2 -s ${SETTINGS} ${PROGRAM}.tcl + From wozniak at ci.uchicago.edu Tue Aug 12 13:15:34 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Tue, 12 Aug 2014 13:15:34 -0500 (CDT) Subject: [Swift-commit] r8120 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello Message-ID: <20140812181534.14CB39D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-12 13:15:34 -0500 (Tue, 12 Aug 2014) New Revision: 8120 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh Log: Bug fix Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello ___________________________________________________________________ Modified: svn:ignore - hello.tcl + hello.tcl turbine-directory.txt Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh 2014-08-12 18:14:18 UTC (rev 8119) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh 2014-08-12 18:15:34 UTC (rev 8120) @@ -3,7 +3,7 @@ source ../../cfg/setup-compute.sh SETTINGS=../../cfg/settings-compute.sh -PROGRAM=hello.swift +PROGRAM=hello stc ${PROGRAM}.swift -turbine-cobalt-run.zsh -n 4 -s ${SETTINGS} ${PROGRAM}.tcl +turbine-cobalt-run.zsh -n 2 -s ${SETTINGS} ${PROGRAM}.tcl From wilde at ci.uchicago.edu Wed Aug 13 10:17:37 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Wed, 13 Aug 2014 10:17:37 -0500 (CDT) Subject: [Swift-commit] r8121 - in demo/xsede.2014.0425: . app part04m Message-ID: <20140813151737.E7E159D92B@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-13 10:17:37 -0500 (Wed, 13 Aug 2014) New Revision: 8121 Added: demo/xsede.2014.0425/app/mdtotk demo/xsede.2014.0425/app/viz Modified: demo/xsede.2014.0425/app/mdmaxk demo/xsede.2014.0425/part04m/swift.properties demo/xsede.2014.0425/setup.midway.sh Log: Updating mdlite-based demo, originally targeted for xsede, for use at ATPESC and beyond. Modified: demo/xsede.2014.0425/app/mdmaxk =================================================================== --- demo/xsede.2014.0425/app/mdmaxk 2014-08-12 18:15:34 UTC (rev 8120) +++ demo/xsede.2014.0425/app/mdmaxk 2014-08-13 15:17:37 UTC (rev 8121) @@ -33,6 +33,6 @@ -' $* | sort -n -k2 | tail -$nfiles | awk '{print $1}' +' $* | sort -n -k2 | tail -$nfiles # | awk '{print $1}' # log 1>&2 Added: demo/xsede.2014.0425/app/mdtotk =================================================================== --- demo/xsede.2014.0425/app/mdtotk (rev 0) +++ demo/xsede.2014.0425/app/mdtotk 2014-08-13 15:17:37 UTC (rev 8121) @@ -0,0 +1,37 @@ +#! /bin/sh + +log() { + printf "\nCalled as: $0: $cmdargs\n\n" + printf "Start time: "; /bin/date + printf "Running as user: "; /usr/bin/id + printf "Running on node: "; /bin/hostname + printf "Node IP address: "; /bin/hostname -I + printf "\nEnvironment:\n\n" + printenv | sort +} + +nfiles=$1 +shift + +gawk ' + +BEGIN { totKe = 0.0; LASTFILE="";} + +{ + if ( $1 == "Step" ) next; + if ( (LASTFILE != "") && (FILENAME != LASTFILE)) { + printf("%s %f\n", LASTFILE, totKe ) + totKe = 0.0; + } + totKe += $3 + 0.0; + LASTFILE=FILENAME +} + +#END { printf("tot Ke for %s is %f\n", LASTFILE, totKe ) } + END { printf("%s %f\n", LASTFILE, totKe ) } + + + +' $* | sort -n -k2 | tail -$nfiles # | awk '{print $1}' + +# log 1>&2 Property changes on: demo/xsede.2014.0425/app/mdtotk ___________________________________________________________________ Added: svn:executable + * Added: demo/xsede.2014.0425/app/viz =================================================================== --- demo/xsede.2014.0425/app/viz (rev 0) +++ demo/xsede.2014.0425/app/viz 2014-08-13 15:17:37 UTC (rev 8121) @@ -0,0 +1,34 @@ +#! /bin/sh + +mdtrj=$1 +vzout=$2 + +wd=`mktemp -d viz.XXXXXX` + +ln $1 $wd + +cd $wd + +tar zxf *.tgz + +cat <c-ray-cmds +# walls +s 0 -1000 2 99 0.2 0.2 0.2 0.0 0.0 + +# lights +l -50 100 -50 + +# camera +# position FOV target +c 0 6 -17 45 0 -1 0 +EOF + +for t in md??.trj; do + cat $t c-ray-cmds | c-ray >$t.ppm + convert $t.ppm $t.png +done + +convert -delay 20 md??.trj.png ../$(basename $1 .tgz).gif + +# mv md.dat $mdout +# mv t.gif $vzout Property changes on: demo/xsede.2014.0425/app/viz ___________________________________________________________________ Added: svn:executable + * Modified: demo/xsede.2014.0425/part04m/swift.properties =================================================================== --- demo/xsede.2014.0425/part04m/swift.properties 2014-08-12 18:15:34 UTC (rev 8120) +++ demo/xsede.2014.0425/part04m/swift.properties 2014-08-13 15:17:37 UTC (rev 8121) @@ -1,2 +1,2 @@ -site=midway-westmere -site.midway-westmere.slurm.exclusive=false +site=midway-sandyb +site.midway-sandyb.slurm.exclusive=false Modified: demo/xsede.2014.0425/setup.midway.sh =================================================================== --- demo/xsede.2014.0425/setup.midway.sh 2014-08-12 18:15:34 UTC (rev 8120) +++ demo/xsede.2014.0425/setup.midway.sh 2014-08-13 15:17:37 UTC (rev 8121) @@ -4,7 +4,7 @@ module load ant -PATH=/home/wilde/swift/src/trunk/cog/modules/swift/dist/swift-svn/bin:$PATH +#PATH=/home/wilde/swift/src/trunk/cog/modules/swift/dist/swift-svn/bin:$PATH echo Swift version is $(swift -version) From wilde at ci.uchicago.edu Wed Aug 13 10:34:52 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Wed, 13 Aug 2014 10:34:52 -0500 (CDT) Subject: [Swift-commit] r8122 - demo/xsede.2014.0425/part04m Message-ID: <20140813153452.274AC9D92B@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-13 10:34:52 -0500 (Wed, 13 Aug 2014) New Revision: 8122 Added: demo/xsede.2014.0425/part04m/p4b.swift Log: Refined md demo. Added: demo/xsede.2014.0425/part04m/p4b.swift =================================================================== --- demo/xsede.2014.0425/part04m/p4b.swift (rev 0) +++ demo/xsede.2014.0425/part04m/p4b.swift 2014-08-13 15:34:52 UTC (rev 8122) @@ -0,0 +1,56 @@ +type file; + +(int result) randomInt () +{ + float range = 9999999.0; + float rand = java("java.lang.Math","random"); + string s[] = strsplit(toString(range*rand),"\\."); + result = toInt(s[0]); +} + +app (file out, file traj) simulation (string npart, string steps, string mass) +{ +# mdviz @out @traj 3 npart steps 50 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt(); + md 3 npart steps 10 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt() @out @traj; +} + +app (file o) analyze (file s[]) +{ + mdstats filenames(s) stdout=filename(o); +} + +app (file o) maxk (file s[]) +{ + mdmaxk filenames(s) stdout=filename(o); +} + +app (file o) analyze (file s[]) +{ + mdstats filenames(s) stdout=filename(o); +} + +app (file o) convert (file s[]) +{ + convert filenames(s) filename(o); +} + +int nsim = toInt(arg("nsim","10")); +string npart = arg("npart","50"); +string steps = arg("steps","1000"); +string mass = arg("mass",".005"); + +file sim[] ; +file trj[] ; + +foreach i in [0:nsim-1] { + (sim[i],trj[i]) = simulation(npart,steps,mass); +} + +file stats_out<"output/average.out">; +stats_out = analyze(sim); + +file ke_out<"output/kinetic.out">; +ke_out = maxk(sim); + +#file viz_all<"output/all.gif">; +#viz_all = convert(gifs); From wozniak at ci.uchicago.edu Wed Aug 13 10:45:17 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 10:45:17 -0500 (CDT) Subject: [Swift-commit] r8123 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples Message-ID: <20140813154517.9A1F79D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 10:45:17 -0500 (Wed, 13 Aug 2014) New Revision: 8123 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/ Log: Adding 05-md From wozniak at ci.uchicago.edu Wed Aug 13 10:46:03 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 10:46:03 -0500 (CDT) Subject: [Swift-commit] r8124 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813154603.A38109D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 10:46:03 -0500 (Wed, 13 Aug 2014) New Revision: 8124 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c Log: Copied from: URL: https://svn.ci.uchicago.edu/svn/vdl2/demo/xsede.2014.0425/src/md Revision: 8122 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 15:46:03 UTC (rev 8124) @@ -0,0 +1,787 @@ +# include +# include +# include +# include + +int main ( int argc, char *argv[] ); +void compute ( int np, int nd, double pos[], double vel[], + double mass, double f[], double *pot, double *kin ); +double cpu_time ( void ); +double dist ( int nd, double r1[], double r2[], double dr[] ); +void initialize ( int np, int nd, double box[], int *seed, double pos[], + double vel[], double acc[] ); +double r8_uniform_01 ( int *seed ); +void timestamp ( void ); +void update ( int np, int nd, double pos[], double vel[], double f[], + double acc[], double mass, double dt ); +void snap ( int np, int nd, double pos[], double vel[], double f[], + double acc[], double mass, double dt ); + +double scale_factor = 2.5, scale_offset = -2.0; +char *printinfo = "0.05 1.0 0.2 0.05 50.0 0.1"; +char *outfile = "md.dat"; +char *trjfile = "md.trj.tgz"; + + +/******************************************************************************/ + +int main ( int argc, char *argv[] ) + +/******************************************************************************/ +/* + Purpose: + + MAIN is the main program for MD. + + Discussion: + + MD implements a simple molecular dynamics simulation. + + The velocity Verlet time integration scheme is used. + + The particles interact with a central pair potential. + + Usage: + + md nd np step_num print_step_num dt mass printinfo scale_factor scale_offset seed outFile trajectoryFile + where + * nd is the spatial dimension (2 or 3); + * np is the number of particles (500, for instance); + * step_num is the number of time steps (500, for instance); + * print_step_num is the number of snapshot prints (10 for instance); + * dt is size of timestep; + * mass is particle mass; + * printinfo is a string to append to each particle coord + * scale_offset and scale_factor are used to scale particle positions for logging/rendering (FIXME) + * seed sets the initial configuration + + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 05 November 2010 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + None +*/ +{ + double *acc; + double *box; + double ctime; + double ctime1; + double ctime2; + double dt = 0.0001; + double e0; + double *force; + int i; + int id; + double kinetic; + double mass = 1.0 * .0001; + int nd; + int np; + double *pos; + double potential; + int seed = 123456789; + int step; + int step_num; + int step_print; + int step_print_index; + int step_print_num=10; + double *vel; + + timestamp ( ); + printf ( "\n" ); + printf ( "MD\n" ); + printf ( " C version\n" ); + printf ( " A molecular dynamics program.\n" ); +/* + Get the spatial dimension. +*/ + if ( 1 < argc ) + { + nd = atoi ( argv[1] ); + } + else + { + printf ( "\n" ); + printf ( " Enter ND, the spatial dimension (2 or 3).\n" ); + scanf ( "%d", &nd ); + } +// +// Get the number of points. +// + if ( 2 < argc ) + { + np = atoi ( argv[2] ); + } + else + { + printf ( "\n" ); + printf ( " Enter NP, the number of points (500, for instance).\n" ); + scanf ( "%d", &np ); + } +// +// Get the number of time steps. +// + if ( 3 < argc ) + { + step_num = atoi ( argv[3] ); + } + else + { + printf ( "\n" ); + printf ( " Enter ND, the number of time steps (500 or 1000, for instance).\n" ); + scanf ( "%d", &step_num ); + } + /* + Get any additional args (command-line only) + md nd np step_num [ step__print_num dt mass printinfo scale_factor scale_offset randomseed outfile trjfile ] + */ + if ( 4 < argc ) + { + step_print_num = atoi ( argv[4] ); + } + if ( 5 < argc ) + { + dt = atof ( argv[5] ); + } + if ( 6 < argc ) + { + mass = atof ( argv[6] ); + } + if ( 7 < argc ) + { + printinfo = ( argv[7] ); + } + if ( 8 < argc ) + { + scale_factor = atof ( argv[8] ); + } + if ( 9 < argc ) + { + scale_offset = atof ( argv[9] ); + } + if ( 10 < argc ) + { + seed = atof ( argv[10] ); + } + if ( 11 < argc ) + { + outfile = argv[11]; + } + if ( 12 < argc ) + { + trjfile = argv[12]; + } + +/* + Report. +*/ + printf ( "\n" ); + printf ( " MD: Argument count: %d\n", argc ); + printf ( " ND, the spatial dimension, is %d\n", nd ); + printf ( " NP, the number of particles in the simulation, is %d\n", np ); + printf ( " STEP_NUM, the number of time steps, is %d\n", step_num ); + printf ( " STEP_PRINT_NUM, the number of snapshots to print, is %d\n", step_print_num ); + printf ( " DT, the size of each time step, is %f\n", dt ); + printf ( " MASS, the particle mass, is %f\n", mass ); + printf ( " PRINTINFO, the pass-through info to c-ray, is %s\n", printinfo ); + printf ( " SCALE_FACTOR, the particle position scaling factor, is %f\n", scale_factor ); + printf ( " SCALE_OFFSET, the particle position scaling offset, is %f\n", scale_offset ); + printf ( " SEED, the simulation randomization seed, is %d\n", seed ); +/* + Allocate memory. +*/ + acc = ( double * ) malloc ( nd * np * sizeof ( double ) ); + box = ( double * ) malloc ( nd * sizeof ( double ) ); + force = ( double * ) malloc ( nd * np * sizeof ( double ) ); + pos = ( double * ) malloc ( nd * np * sizeof ( double ) ); + vel = ( double * ) malloc ( nd * np * sizeof ( double ) ); +/* + Set the dimensions of the box. +*/ + for ( i = 0; i < nd; i++ ) + { + box[i] = 10.0; + } + + printf ( "\n" ); + printf ( " Initializing positions, velocities, and accelerations.\n" ); +/* + Set initial positions, velocities, and accelerations. +*/ + initialize ( np, nd, box, &seed, pos, vel, acc ); +/* + Compute the forces and energies. +*/ + printf ( "\n" ); + printf ( " Computing initial forces and energies.\n" ); + + compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); + + e0 = potential + kinetic; +/* + This is the main time stepping loop: + Compute forces and energies, + Update positions, velocities, accelerations. +*/ + printf ( "\n" ); + printf ( " At each step, we report the potential and kinetic energies.\n" ); + printf ( " The sum of these energies should be a constant.\n" ); + printf ( " As an accuracy check, we also print the relative error\n" ); + printf ( " in the total energy.\n" ); + printf ( "\n" ); + printf ( " Step Potential Kinetic (P+K-E0)/E0\n" ); + printf ( " Energy P Energy K Relative Energy Error\n" ); + printf ( "\n" ); + + FILE *ofile = fopen(outfile,"w"); + fprintf (ofile, " Step Potential Kinetic RelativeErr\n" ); + + step_print = 0; + step_print_index = 0; + + step = 0; + printf ( " %8d %14f %14f %14e\n", + step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); + fprintf ( ofile, " %8d %14f %14f %14e\n", + step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); + step_print_index = step_print_index + 1; + step_print = ( step_print_index * step_num ) / step_print_num; + + ctime1 = cpu_time ( ); + + for ( step = 1; step <= step_num; step++ ) + { + compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); + + if ( step == step_print ) + { + printf ( " %8d %14f %14f %14e\n", step, potential, kinetic, + ( potential + kinetic - e0 ) / e0 ); + fprintf ( ofile, " %8d %14f %14f %14e\n", step, potential, kinetic, + ( potential + kinetic - e0 ) / e0 ); + step_print_index = step_print_index + 1; + step_print = ( step_print_index * step_num ) / step_print_num; + snap ( np, nd, pos, vel, force, acc, mass, dt ); + } + update ( np, nd, pos, vel, force, acc, mass, dt ); + } + ctime2 = cpu_time ( ); + ctime = ctime2 - ctime1; + + printf ( "\n" ); + printf ( " Elapsed cpu time for main computation:\n" ); + printf ( " %f seconds.\n", ctime ); + + free ( acc ); + free ( box ); + free ( force ); + free ( pos ); + free ( vel ); + char tarcmd[2000]; + sprintf(tarcmd,"tar zcf %s md??.trj",trjfile); + system(tarcmd); +/* + Terminate. +*/ + printf ( "\n" ); + printf ( "MD\n" ); + printf ( " Normal end of execution.\n" ); + + printf ( "\n" ); + timestamp ( ); + + fclose(ofile); + return 0; +} +/******************************************************************************/ + +void compute ( int np, int nd, double pos[], double vel[], + double mass, double f[], double *pot, double *kin ) + +/******************************************************************************/ +/* + Purpose: + + COMPUTE computes the forces and energies. + + Discussion: + + The computation of forces and energies is fully parallel. + + The potential function V(X) is a harmonic well which smoothly + saturates to a maximum value at PI/2: + + v(x) = ( sin ( min ( x, PI2 ) ) )^2 + + The derivative of the potential is: + + dv(x) = 2.0 * sin ( min ( x, PI2 ) ) * cos ( min ( x, PI2 ) ) + = sin ( 2.0 * min ( x, PI2 ) ) + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 21 November 2007 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + Input, int NP, the number of particles. + + Input, int ND, the number of spatial dimensions. + + Input, double POS[ND*NP], the position of each particle. + + Input, double VEL[ND*NP], the velocity of each particle. + + Input, double MASS, the mass of each particle. + + Output, double F[ND*NP], the forces. + + Output, double *POT, the total potential energy. + + Output, double *KIN, the total kinetic energy. +*/ +{ + double d; + double d2; + int i; + int j; + int k; + double ke; + double pe; + double PI2 = 3.141592653589793 / 2.0; + double rij[3]; + + pe = 0.0; + ke = 0.0; + + for ( k = 0; k < np; k++ ) + { +/* + Compute the potential energy and forces. +*/ + for ( i = 0; i < nd; i++ ) + { + f[i+k*nd] = 0.0; + } + + for ( j = 0; j < np; j++ ) + { + if ( k != j ) + { + d = dist ( nd, pos+k*nd, pos+j*nd, rij ); +/* + Attribute half of the potential energy to particle J. +*/ + if ( d < PI2 ) + { + d2 = d; + } + else + { + d2 = PI2; + } + + pe = pe + 0.5 * pow ( sin ( d2 ), 2 ); + + for ( i = 0; i < nd; i++ ) + { + f[i+k*nd] = f[i+k*nd] - rij[i] * sin ( 2.0 * d2 ) / d; + } + } + } +/* + Compute the kinetic energy. +*/ + for ( i = 0; i < nd; i++ ) + { + ke = ke + vel[i+k*nd] * vel[i+k*nd]; + } + } + + ke = ke * 0.5 * mass; + + *pot = pe; + *kin = ke; + + return; +} +/*******************************************************************************/ + +double cpu_time ( void ) + +/*******************************************************************************/ +/* + Purpose: + + CPU_TIME reports the total CPU time for a program. + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 27 September 2005 + + Author: + + John Burkardt + + Parameters: + + Output, double CPU_TIME, the current total elapsed CPU time in second. +*/ +{ + double value; + + value = ( double ) clock ( ) / ( double ) CLOCKS_PER_SEC; + + return value; +} +/******************************************************************************/ + +double dist ( int nd, double r1[], double r2[], double dr[] ) + +/******************************************************************************/ +/* + Purpose: + + DIST computes the displacement (and its norm) between two particles. + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 21 November 2007 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + Input, int ND, the number of spatial dimensions. + + Input, double R1[ND], R2[ND], the positions of the particles. + + Output, double DR[ND], the displacement vector. + + Output, double D, the Euclidean norm of the displacement. +*/ +{ + double d; + int i; + + d = 0.0; + for ( i = 0; i < nd; i++ ) + { + dr[i] = r1[i] - r2[i]; + d = d + dr[i] * dr[i]; + } + d = sqrt ( d ); + + return d; +} +/******************************************************************************/ + +void initialize ( int np, int nd, double box[], int *seed, double pos[], + double vel[], double acc[] ) + +/******************************************************************************/ +/* + Purpose: + + INITIALIZE initializes the positions, velocities, and accelerations. + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 20 July 2008 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + Input, int NP, the number of particles. + + Input, int ND, the number of spatial dimensions. + + Input, double BOX[ND], specifies the maximum position + of particles in each dimension. + + Input, int *SEED, a seed for the random number generator. + + Output, double POS[ND*NP], the position of each particle. + + Output, double VEL[ND*NP], the velocity of each particle. + + Output, double ACC[ND*NP], the acceleration of each particle. +*/ +{ + int i; + int j; +/* + Give the particles random positions within the box. +*/ + for ( j = 0; j < np; j++ ) + { + for ( i = 0; i < nd; i++ ) + { + pos[i+j*nd] = box[i] * r8_uniform_01 ( seed ); + vel[i+j*nd] = 0.0; + acc[i+j*nd] = 0.0; + } + } + return; +} +/******************************************************************************/ + +double r8_uniform_01 ( int *seed ) + +/******************************************************************************/ +/* + Purpose: + + R8_UNIFORM_01 is a unit pseudorandom R8. + + Discussion: + + This routine implements the recursion + + seed = 16807 * seed mod ( 2^31 - 1 ) + unif = seed / ( 2^31 - 1 ) + + The integer arithmetic never requires more than 32 bits, + including a sign bit. + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 11 August 2004 + + Author: + + John Burkardt + + Reference: + + Paul Bratley, Bennett Fox, Linus Schrage, + A Guide to Simulation, + Springer Verlag, pages 201-202, 1983. + + Bennett Fox, + Algorithm 647: + Implementation and Relative Efficiency of Quasirandom + Sequence Generators, + ACM Transactions on Mathematical Software, + Volume 12, Number 4, pages 362-376, 1986. + + Parameters: + + Input/output, int *SEED, a seed for the random number generator. + + Output, double R8_UNIFORM_01, a new pseudorandom variate, strictly between + 0 and 1. +*/ +{ + int k; + double r; + + k = *seed / 127773; + + *seed = 16807 * ( *seed - k * 127773 ) - k * 2836; + + if ( *seed < 0 ) + { + *seed = *seed + 2147483647; + } + + r = ( double ) ( *seed ) * 4.656612875E-10; + + return r; +} +/******************************************************************************/ + +void timestamp ( void ) + +/******************************************************************************/ +/* + Purpose: + + TIMESTAMP prints the current YMDHMS date as a time stamp. + + Example: + + 31 May 2001 09:45:54 AM + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 24 September 2003 + + Author: + + John Burkardt + + Parameters: + + None +*/ +{ +# define TIME_SIZE 40 + + static char time_buffer[TIME_SIZE]; + const struct tm *tm; + size_t len; + time_t now; + + now = time ( NULL ); + tm = localtime ( &now ); + + len = strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); + + printf ( "%s\n", time_buffer ); + + return; +# undef TIME_SIZE +} +/******************************************************************************/ + +void update ( int np, int nd, double pos[], double vel[], double f[], + double acc[], double mass, double dt ) + +/******************************************************************************/ +/* + Purpose: + + UPDATE updates positions, velocities and accelerations. + + Discussion: + + The time integration is fully parallel. + + A velocity Verlet algorithm is used for the updating. + + x(t+dt) = x(t) + v(t) * dt + 0.5 * a(t) * dt * dt + v(t+dt) = v(t) + 0.5 * ( a(t) + a(t+dt) ) * dt + a(t+dt) = f(t) / m + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 21 November 2007 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + Input, int NP, the number of particles. + + Input, int ND, the number of spatial dimensions. + + Input/output, double POS[ND*NP], the position of each particle. + + Input/output, double VEL[ND*NP], the velocity of each particle. + + Input, double F[ND*NP], the force on each particle. + + Input/output, double ACC[ND*NP], the acceleration of each particle. + + Input, double MASS, the mass of each particle. + + Input, double DT, the time step. +*/ +{ + int i; + int j; + double rmass; + + rmass = 1.0 / mass; + + for ( j = 0; j < np; j++ ) + { + for ( i = 0; i < nd; i++ ) + { + pos[i+j*nd] = pos[i+j*nd] + vel[i+j*nd] * dt + 0.5 * acc[i+j*nd] * dt * dt; + vel[i+j*nd] = vel[i+j*nd] + 0.5 * dt * ( f[i+j*nd] * rmass + acc[i+j*nd] ); + acc[i+j*nd] = f[i+j*nd] * rmass; + } + /* +s -0.5 -0.3 -1 0.05 1.0 0.2 0.05 50.0 0.1 +s 0.5 -0.4 0 0.05 0.1 0.85 1.0 50.0 0.1 + */ + char *s = "0.05 1.0 0.2 0.05 50.0 0.1"; + /* printf("s %f %f %f %s\n", pos[0+j*nd]/20.0, pos[1+j*nd]/20.0, pos[2+j*nd]/20.0, s); */ + } + + return; +} + + +double scale (double x) +{ + return( (x / scale_factor) - scale_offset); + /* return( (x / 2.5) - 2.0); */ +} + +static int snapid = 0; + +void snap ( int np, int nd, double pos[], double vel[], double f[], + double acc[], double mass, double dt ) +{ + int j; + + char snapfile[100]; + sprintf(snapfile, "md%02d.trj", snapid); + + FILE *sf = fopen(snapfile, "w"); + + for ( j = 0; j < np; j++ ) + { + fprintf(sf, "s %f %f %f %s\n", scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); + } + + fclose(sf); + snapid++; +} From wozniak at ci.uchicago.edu Wed Aug 13 10:50:14 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 10:50:14 -0500 (CDT) Subject: [Swift-commit] r8125 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813155014.6DEB09D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 10:50:14 -0500 (Wed, 13 Aug 2014) New Revision: 8125 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile Log: Copied from: URL: https://svn.ci.uchicago.edu/svn/vdl2/demo/xsede.2014.0425/src/md Revision: 8122 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile 2014-08-13 15:50:14 UTC (rev 8125) @@ -0,0 +1,20 @@ +bin = md +src = md.c + +CC = gcc +#CFLAGS = -O3 -ffast-math + +$(bin): $(src) + $(CC) -o $@ $(bin).c -lm + +.PHONY: clean +clean: + rm -f $(obj) $(bin) + +.PHONY: install +install: + cp $(bin) ../../bin/$(bin) + +.PHONY: uninstall +uninstall: + rm -f ../../bin/$(bin) From wozniak at ci.uchicago.edu Wed Aug 13 10:54:44 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 10:54:44 -0500 (CDT) Subject: [Swift-commit] r8126 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813155444.C12E39D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 10:54:44 -0500 (Wed, 13 Aug 2014) New Revision: 8126 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.sh Log: Adding test-md.sh Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.sh 2014-08-13 15:54:44 UTC (rev 8126) @@ -0,0 +1,10 @@ +#!/bin/sh -eu + +NPART=4 +STEPS=10 +MASS=1 +SEED=42 +OUT=output.txt +TRJ=output.trj + +./md 3 ${NPART} ${STEPS} 10 ".0001" ${MASS} "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 ${SEED} ${OUT} ${TRJ} Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.sh ___________________________________________________________________ Added: svn:executable + * From wozniak at ci.uchicago.edu Wed Aug 13 10:55:17 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 10:55:17 -0500 (CDT) Subject: [Swift-commit] r8127 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813155517.7189C9D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 10:55:17 -0500 (Wed, 13 Aug 2014) New Revision: 8127 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/ Log: Set ignores Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md ___________________________________________________________________ Added: svn:ignore + .cproject md *.trj output.* From wozniak at ci.uchicago.edu Wed Aug 13 11:02:28 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 11:02:28 -0500 (CDT) Subject: [Swift-commit] r8128 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813160228.631219D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 11:02:28 -0500 (Wed, 13 Aug 2014) New Revision: 8128 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c Log: Working version - split out main.c Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile 2014-08-13 15:55:17 UTC (rev 8127) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile 2014-08-13 16:02:28 UTC (rev 8128) @@ -1,12 +1,17 @@ bin = md -src = md.c CC = gcc -#CFLAGS = -O3 -ffast-math +CFLAGS = -O0 -g -fPIC +# CFLAGS = -O3 -ffast-math -g -fPIC -$(bin): $(src) - $(CC) -o $@ $(bin).c -lm +SRC = main.c md.c +OBJ = $(patsubst %.c,%.o,$(SRC)) +all: $(bin) + +$(bin): $(OBJ) + $(CC) -o $(@) $(OBJ) -lm + .PHONY: clean clean: rm -f $(obj) $(bin) Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c 2014-08-13 16:02:28 UTC (rev 8128) @@ -0,0 +1,298 @@ + +/* + * main.c + * + * Created on: Aug 13, 2014 + * Author: wozniak + */ + +#include +#include +#include "md.h" + + +char *outfile = "md.dat"; +char *trjfile = "md.trj.tgz"; + + +/******************************************************************************/ + +int main ( int argc, char *argv[] ) + +/******************************************************************************/ +/* + Purpose: + + MAIN is the main program for MD. + + Discussion: + + MD implements a simple molecular dynamics simulation. + + The velocity Verlet time integration scheme is used. + + The particles interact with a central pair potential. + + Usage: + + md nd np step_num print_step_num dt mass printinfo scale_factor scale_offset seed outFile trajectoryFile + where + * nd is the spatial dimension (2 or 3); + * np is the number of particles (500, for instance); + * step_num is the number of time steps (500, for instance); + * print_step_num is the number of snapshot prints (10 for instance); + * dt is size of timestep; + * mass is particle mass; + * printinfo is a string to append to each particle coord + * scale_offset and scale_factor are used to scale particle positions for logging/rendering (FIXME) + * seed sets the initial configuration + + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 05 November 2010 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + None +*/ +{ + double *acc; + double *box; + double ctime; + double ctime1; + double ctime2; + double dt = 0.0001; + double e0; + double *force; + int i; + int id; + double kinetic; + double mass = 1.0 * .0001; + int nd; + int np; + double *pos; + double potential; + int seed = 123456789; + int step; + int step_num; + int step_print; + int step_print_index; + int step_print_num=10; + double *vel; + + timestamp ( ); + printf ( "\n" ); + printf ( "MD\n" ); + printf ( " C version\n" ); + printf ( " A molecular dynamics program.\n" ); +/* + Get the spatial dimension. +*/ + if ( 1 < argc ) + { + nd = atoi ( argv[1] ); + } + else + { + printf ( "\n" ); + printf ( " Enter ND, the spatial dimension (2 or 3).\n" ); + scanf ( "%d", &nd ); + } +// +// Get the number of points. +// + if ( 2 < argc ) + { + np = atoi ( argv[2] ); + } + else + { + printf ( "\n" ); + printf ( " Enter NP, the number of points (500, for instance).\n" ); + scanf ( "%d", &np ); + } +// +// Get the number of time steps. +// + if ( 3 < argc ) + { + step_num = atoi ( argv[3] ); + } + else + { + printf ( "\n" ); + printf ( " Enter ND, the number of time steps (500 or 1000, for instance).\n" ); + scanf ( "%d", &step_num ); + } + /* + Get any additional args (command-line only) + md nd np step_num [ step__print_num dt mass printinfo scale_factor scale_offset randomseed outfile trjfile ] + */ + if ( 4 < argc ) + { + step_print_num = atoi ( argv[4] ); + } + if ( 5 < argc ) + { + dt = atof ( argv[5] ); + } + if ( 6 < argc ) + { + mass = atof ( argv[6] ); + } + if ( 7 < argc ) + { + printinfo = ( argv[7] ); + } + if ( 8 < argc ) + { + scale_factor = atof ( argv[8] ); + } + if ( 9 < argc ) + { + scale_offset = atof ( argv[9] ); + } + if ( 10 < argc ) + { + seed = atof ( argv[10] ); + } + if ( 11 < argc ) + { + outfile = argv[11]; + } + if ( 12 < argc ) + { + trjfile = argv[12]; + } + +/* + Report. +*/ + printf ( "\n" ); + printf ( " MD: Argument count: %d\n", argc ); + printf ( " ND, the spatial dimension, is %d\n", nd ); + printf ( " NP, the number of particles in the simulation, is %d\n", np ); + printf ( " STEP_NUM, the number of time steps, is %d\n", step_num ); + printf ( " STEP_PRINT_NUM, the number of snapshots to print, is %d\n", step_print_num ); + printf ( " DT, the size of each time step, is %f\n", dt ); + printf ( " MASS, the particle mass, is %f\n", mass ); + printf ( " PRINTINFO, the pass-through info to c-ray, is %s\n", printinfo ); + printf ( " SCALE_FACTOR, the particle position scaling factor, is %f\n", scale_factor ); + printf ( " SCALE_OFFSET, the particle position scaling offset, is %f\n", scale_offset ); + printf ( " SEED, the simulation randomization seed, is %d\n", seed ); +/* + Allocate memory. +*/ + acc = ( double * ) malloc ( nd * np * sizeof ( double ) ); + box = ( double * ) malloc ( nd * sizeof ( double ) ); + force = ( double * ) malloc ( nd * np * sizeof ( double ) ); + pos = ( double * ) malloc ( nd * np * sizeof ( double ) ); + vel = ( double * ) malloc ( nd * np * sizeof ( double ) ); +/* + Set the dimensions of the box. +*/ + for ( i = 0; i < nd; i++ ) + { + box[i] = 10.0; + } + + printf ( "\n" ); + printf ( " Initializing positions, velocities, and accelerations.\n" ); +/* + Set initial positions, velocities, and accelerations. +*/ + initialize ( np, nd, box, &seed, pos, vel, acc ); +/* + Compute the forces and energies. +*/ + printf ( "\n" ); + printf ( " Computing initial forces and energies.\n" ); + + compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); + + e0 = potential + kinetic; +/* + This is the main time stepping loop: + Compute forces and energies, + Update positions, velocities, accelerations. +*/ + printf ( "\n" ); + printf ( " At each step, we report the potential and kinetic energies.\n" ); + printf ( " The sum of these energies should be a constant.\n" ); + printf ( " As an accuracy check, we also print the relative error\n" ); + printf ( " in the total energy.\n" ); + printf ( "\n" ); + printf ( " Step Potential Kinetic (P+K-E0)/E0\n" ); + printf ( " Energy P Energy K Relative Energy Error\n" ); + printf ( "\n" ); + + FILE *ofile = fopen(outfile,"w"); + fprintf (ofile, " Step Potential Kinetic RelativeErr\n" ); + + step_print = 0; + step_print_index = 0; + + step = 0; + printf ( " %8d %14f %14f %14e\n", + step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); + fprintf ( ofile, " %8d %14f %14f %14e\n", + step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); + step_print_index = step_print_index + 1; + step_print = ( step_print_index * step_num ) / step_print_num; + + ctime1 = cpu_time ( ); + + for ( step = 1; step <= step_num; step++ ) + { + compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); + + if ( step == step_print ) + { + printf ( " %8d %14f %14f %14e\n", step, potential, kinetic, + ( potential + kinetic - e0 ) / e0 ); + fprintf ( ofile, " %8d %14f %14f %14e\n", step, potential, kinetic, + ( potential + kinetic - e0 ) / e0 ); + step_print_index = step_print_index + 1; + step_print = ( step_print_index * step_num ) / step_print_num; + snap ( np, nd, pos, vel, force, acc, mass, dt ); + } + update ( np, nd, pos, vel, force, acc, mass, dt ); + } + ctime2 = cpu_time ( ); + ctime = ctime2 - ctime1; + + printf ( "\n" ); + printf ( " Elapsed cpu time for main computation:\n" ); + printf ( " %f seconds.\n", ctime ); + + free ( acc ); + free ( box ); + free ( force ); + free ( pos ); + free ( vel ); + char tarcmd[2000]; + sprintf(tarcmd,"tar zcf %s md??.trj",trjfile); + system(tarcmd); +/* + Terminate. +*/ + printf ( "\n" ); + printf ( "MD\n" ); + printf ( " Normal end of execution.\n" ); + + printf ( "\n" ); + timestamp ( ); + + fclose(ofile); + return 0; +} Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 15:55:17 UTC (rev 8127) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 16:02:28 UTC (rev 8128) @@ -3,7 +3,8 @@ # include # include -int main ( int argc, char *argv[] ); +#include "md.h" + void compute ( int np, int nd, double pos[], double vel[], double mass, double f[], double *pot, double *kin ); double cpu_time ( void ); @@ -19,293 +20,9 @@ double scale_factor = 2.5, scale_offset = -2.0; char *printinfo = "0.05 1.0 0.2 0.05 50.0 0.1"; -char *outfile = "md.dat"; -char *trjfile = "md.trj.tgz"; - /******************************************************************************/ -int main ( int argc, char *argv[] ) - -/******************************************************************************/ -/* - Purpose: - - MAIN is the main program for MD. - - Discussion: - - MD implements a simple molecular dynamics simulation. - - The velocity Verlet time integration scheme is used. - - The particles interact with a central pair potential. - - Usage: - - md nd np step_num print_step_num dt mass printinfo scale_factor scale_offset seed outFile trajectoryFile - where - * nd is the spatial dimension (2 or 3); - * np is the number of particles (500, for instance); - * step_num is the number of time steps (500, for instance); - * print_step_num is the number of snapshot prints (10 for instance); - * dt is size of timestep; - * mass is particle mass; - * printinfo is a string to append to each particle coord - * scale_offset and scale_factor are used to scale particle positions for logging/rendering (FIXME) - * seed sets the initial configuration - - - Licensing: - - This code is distributed under the GNU LGPL license. - - Modified: - - 05 November 2010 - - Author: - - Original FORTRAN90 version by Bill Magro. - C version by John Burkardt. - - Parameters: - - None -*/ -{ - double *acc; - double *box; - double ctime; - double ctime1; - double ctime2; - double dt = 0.0001; - double e0; - double *force; - int i; - int id; - double kinetic; - double mass = 1.0 * .0001; - int nd; - int np; - double *pos; - double potential; - int seed = 123456789; - int step; - int step_num; - int step_print; - int step_print_index; - int step_print_num=10; - double *vel; - - timestamp ( ); - printf ( "\n" ); - printf ( "MD\n" ); - printf ( " C version\n" ); - printf ( " A molecular dynamics program.\n" ); -/* - Get the spatial dimension. -*/ - if ( 1 < argc ) - { - nd = atoi ( argv[1] ); - } - else - { - printf ( "\n" ); - printf ( " Enter ND, the spatial dimension (2 or 3).\n" ); - scanf ( "%d", &nd ); - } -// -// Get the number of points. -// - if ( 2 < argc ) - { - np = atoi ( argv[2] ); - } - else - { - printf ( "\n" ); - printf ( " Enter NP, the number of points (500, for instance).\n" ); - scanf ( "%d", &np ); - } -// -// Get the number of time steps. -// - if ( 3 < argc ) - { - step_num = atoi ( argv[3] ); - } - else - { - printf ( "\n" ); - printf ( " Enter ND, the number of time steps (500 or 1000, for instance).\n" ); - scanf ( "%d", &step_num ); - } - /* - Get any additional args (command-line only) - md nd np step_num [ step__print_num dt mass printinfo scale_factor scale_offset randomseed outfile trjfile ] - */ - if ( 4 < argc ) - { - step_print_num = atoi ( argv[4] ); - } - if ( 5 < argc ) - { - dt = atof ( argv[5] ); - } - if ( 6 < argc ) - { - mass = atof ( argv[6] ); - } - if ( 7 < argc ) - { - printinfo = ( argv[7] ); - } - if ( 8 < argc ) - { - scale_factor = atof ( argv[8] ); - } - if ( 9 < argc ) - { - scale_offset = atof ( argv[9] ); - } - if ( 10 < argc ) - { - seed = atof ( argv[10] ); - } - if ( 11 < argc ) - { - outfile = argv[11]; - } - if ( 12 < argc ) - { - trjfile = argv[12]; - } - -/* - Report. -*/ - printf ( "\n" ); - printf ( " MD: Argument count: %d\n", argc ); - printf ( " ND, the spatial dimension, is %d\n", nd ); - printf ( " NP, the number of particles in the simulation, is %d\n", np ); - printf ( " STEP_NUM, the number of time steps, is %d\n", step_num ); - printf ( " STEP_PRINT_NUM, the number of snapshots to print, is %d\n", step_print_num ); - printf ( " DT, the size of each time step, is %f\n", dt ); - printf ( " MASS, the particle mass, is %f\n", mass ); - printf ( " PRINTINFO, the pass-through info to c-ray, is %s\n", printinfo ); - printf ( " SCALE_FACTOR, the particle position scaling factor, is %f\n", scale_factor ); - printf ( " SCALE_OFFSET, the particle position scaling offset, is %f\n", scale_offset ); - printf ( " SEED, the simulation randomization seed, is %d\n", seed ); -/* - Allocate memory. -*/ - acc = ( double * ) malloc ( nd * np * sizeof ( double ) ); - box = ( double * ) malloc ( nd * sizeof ( double ) ); - force = ( double * ) malloc ( nd * np * sizeof ( double ) ); - pos = ( double * ) malloc ( nd * np * sizeof ( double ) ); - vel = ( double * ) malloc ( nd * np * sizeof ( double ) ); -/* - Set the dimensions of the box. -*/ - for ( i = 0; i < nd; i++ ) - { - box[i] = 10.0; - } - - printf ( "\n" ); - printf ( " Initializing positions, velocities, and accelerations.\n" ); -/* - Set initial positions, velocities, and accelerations. -*/ - initialize ( np, nd, box, &seed, pos, vel, acc ); -/* - Compute the forces and energies. -*/ - printf ( "\n" ); - printf ( " Computing initial forces and energies.\n" ); - - compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); - - e0 = potential + kinetic; -/* - This is the main time stepping loop: - Compute forces and energies, - Update positions, velocities, accelerations. -*/ - printf ( "\n" ); - printf ( " At each step, we report the potential and kinetic energies.\n" ); - printf ( " The sum of these energies should be a constant.\n" ); - printf ( " As an accuracy check, we also print the relative error\n" ); - printf ( " in the total energy.\n" ); - printf ( "\n" ); - printf ( " Step Potential Kinetic (P+K-E0)/E0\n" ); - printf ( " Energy P Energy K Relative Energy Error\n" ); - printf ( "\n" ); - - FILE *ofile = fopen(outfile,"w"); - fprintf (ofile, " Step Potential Kinetic RelativeErr\n" ); - - step_print = 0; - step_print_index = 0; - - step = 0; - printf ( " %8d %14f %14f %14e\n", - step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); - fprintf ( ofile, " %8d %14f %14f %14e\n", - step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); - step_print_index = step_print_index + 1; - step_print = ( step_print_index * step_num ) / step_print_num; - - ctime1 = cpu_time ( ); - - for ( step = 1; step <= step_num; step++ ) - { - compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); - - if ( step == step_print ) - { - printf ( " %8d %14f %14f %14e\n", step, potential, kinetic, - ( potential + kinetic - e0 ) / e0 ); - fprintf ( ofile, " %8d %14f %14f %14e\n", step, potential, kinetic, - ( potential + kinetic - e0 ) / e0 ); - step_print_index = step_print_index + 1; - step_print = ( step_print_index * step_num ) / step_print_num; - snap ( np, nd, pos, vel, force, acc, mass, dt ); - } - update ( np, nd, pos, vel, force, acc, mass, dt ); - } - ctime2 = cpu_time ( ); - ctime = ctime2 - ctime1; - - printf ( "\n" ); - printf ( " Elapsed cpu time for main computation:\n" ); - printf ( " %f seconds.\n", ctime ); - - free ( acc ); - free ( box ); - free ( force ); - free ( pos ); - free ( vel ); - char tarcmd[2000]; - sprintf(tarcmd,"tar zcf %s md??.trj",trjfile); - system(tarcmd); -/* - Terminate. -*/ - printf ( "\n" ); - printf ( "MD\n" ); - printf ( " Normal end of execution.\n" ); - - printf ( "\n" ); - timestamp ( ); - - fclose(ofile); - return 0; -} -/******************************************************************************/ - void compute ( int np, int nd, double pos[], double vel[], double mass, double f[], double *pot, double *kin ) Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h 2014-08-13 16:02:28 UTC (rev 8128) @@ -0,0 +1,14 @@ +/* + * md.h + * + * Created on: Aug 13, 2014 + * Author: wozniak + */ + +#ifndef MD_H +#define MD_H + +extern double scale_factor, scale_offset; +extern char *printinfo; + +#endif From wozniak at ci.uchicago.edu Wed Aug 13 11:23:07 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 11:23:07 -0500 (CDT) Subject: [Swift-commit] r8129 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813162307.A0A749D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 11:23:07 -0500 (Wed, 13 Aug 2014) New Revision: 8129 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile Log: Improve Makefile Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile 2014-08-13 16:02:28 UTC (rev 8128) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile 2014-08-13 16:23:07 UTC (rev 8129) @@ -1,8 +1,9 @@ bin = md CC = gcc -CFLAGS = -O0 -g -fPIC -# CFLAGS = -O3 -ffast-math -g -fPIC +OPTZ = -O0 +OPTS = -O3 -ffast-math +CFLAGS = $(OPTZ) -g -fPIC -std=gnu99 SRC = main.c md.c OBJ = $(patsubst %.c,%.o,$(SRC)) @@ -14,7 +15,7 @@ .PHONY: clean clean: - rm -f $(obj) $(bin) + rm -f $(OBJ) $(bin) .PHONY: install install: From wozniak at ci.uchicago.edu Wed Aug 13 11:23:58 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 11:23:58 -0500 (CDT) Subject: [Swift-commit] r8130 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813162358.30D0F9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 11:23:58 -0500 (Wed, 13 Aug 2014) New Revision: 8130 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h Log: Split out new function simulate() Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c 2014-08-13 16:23:07 UTC (rev 8129) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c 2014-08-13 16:23:58 UTC (rev 8130) @@ -86,8 +86,8 @@ int step; int step_num; int step_print; - int step_print_index; - int step_print_num=10; + int step_print_index = 0; + int step_print_num = 10; double *vel; timestamp ( ); @@ -239,10 +239,6 @@ FILE *ofile = fopen(outfile,"w"); fprintf (ofile, " Step Potential Kinetic RelativeErr\n" ); - step_print = 0; - step_print_index = 0; - - step = 0; printf ( " %8d %14f %14f %14e\n", step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); fprintf ( ofile, " %8d %14f %14f %14e\n", @@ -252,22 +248,13 @@ ctime1 = cpu_time ( ); - for ( step = 1; step <= step_num; step++ ) - { - compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); + simulate (step_num, step_print_num, step_print, step_print_index, + np, nd, pos, vel, + mass, force, acc, + potential, kinetic, e0, + dt, + ofile); - if ( step == step_print ) - { - printf ( " %8d %14f %14f %14e\n", step, potential, kinetic, - ( potential + kinetic - e0 ) / e0 ); - fprintf ( ofile, " %8d %14f %14f %14e\n", step, potential, kinetic, - ( potential + kinetic - e0 ) / e0 ); - step_print_index = step_print_index + 1; - step_print = ( step_print_index * step_num ) / step_print_num; - snap ( np, nd, pos, vel, force, acc, mass, dt ); - } - update ( np, nd, pos, vel, force, acc, mass, dt ); - } ctime2 = cpu_time ( ); ctime = ctime2 - ctime1; Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 16:23:07 UTC (rev 8129) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 16:23:58 UTC (rev 8130) @@ -5,22 +5,44 @@ #include "md.h" -void compute ( int np, int nd, double pos[], double vel[], - double mass, double f[], double *pot, double *kin ); -double cpu_time ( void ); +double scale_factor = 2.5, scale_offset = -2.0; +char *printinfo = "0.05 1.0 0.2 0.05 50.0 0.1"; + + double dist ( int nd, double r1[], double r2[], double dr[] ); -void initialize ( int np, int nd, double box[], int *seed, double pos[], - double vel[], double acc[] ); + double r8_uniform_01 ( int *seed ); -void timestamp ( void ); -void update ( int np, int nd, double pos[], double vel[], double f[], +void update ( int np, int nd, double pos[], double vel[], double f[], double acc[], double mass, double dt ); -void snap ( int np, int nd, double pos[], double vel[], double f[], +void snap ( int np, int nd, double pos[], double vel[], double f[], double acc[], double mass, double dt ); -double scale_factor = 2.5, scale_offset = -2.0; -char *printinfo = "0.05 1.0 0.2 0.05 50.0 0.1"; +void simulate (int step_num, int step_print_num, + int step_print, int step_print_index, + int np, int nd, double pos[], double vel[], + double mass, double force[], double acc[], + double potential, double kinetic, double e0, + double dt, + FILE* ofile) +{ + for (int step = 1; step <= step_num; step++ ) + { + compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); + if ( step == step_print ) + { + printf ( " %8d %14f %14f %14e\n", step, potential, kinetic, + ( potential + kinetic - e0 ) / e0 ); + fprintf ( ofile, " %8d %14f %14f %14e\n", step, potential, kinetic, + ( potential + kinetic - e0 ) / e0 ); + step_print_index = step_print_index + 1; + step_print = ( step_print_index * step_num ) / step_print_num; + snap ( np, nd, pos, vel, force, acc, mass, dt ); + } + update ( np, nd, pos, vel, force, acc, mass, dt ); + } +} + /******************************************************************************/ void compute ( int np, int nd, double pos[], double vel[], Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h 2014-08-13 16:23:07 UTC (rev 8129) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h 2014-08-13 16:23:58 UTC (rev 8130) @@ -11,4 +11,22 @@ extern double scale_factor, scale_offset; extern char *printinfo; +double cpu_time ( void ); + +void timestamp ( void ); + +void initialize ( int np, int nd, double box[], int *seed, double pos[], + double vel[], double acc[] ); + +void compute ( int np, int nd, double pos[], double vel[], + double mass, double f[], double *pot, double *kin ); + +void simulate (int step_num, int step_print_num, + int step_print, int step_print_index, + int np, int nd, double pos[], double vel[], + double mass, double force[], double acc[], + double potential, double kinetic, double e0, + double dt, + FILE* ofile); + #endif From wozniak at ci.uchicago.edu Wed Aug 13 11:30:05 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 11:30:05 -0500 (CDT) Subject: [Swift-commit] r8131 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813163005.69F8D9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 11:30:05 -0500 (Wed, 13 Aug 2014) New Revision: 8131 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h Log: Move more into simulate() Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c 2014-08-13 16:23:58 UTC (rev 8130) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c 2014-08-13 16:30:05 UTC (rev 8131) @@ -66,8 +66,7 @@ None */ { - double *acc; - double *box; + double ctime; double ctime1; double ctime2; @@ -80,7 +79,7 @@ double mass = 1.0 * .0001; int nd; int np; - double *pos; + double potential; int seed = 123456789; int step; @@ -190,70 +189,12 @@ printf ( " SCALE_FACTOR, the particle position scaling factor, is %f\n", scale_factor ); printf ( " SCALE_OFFSET, the particle position scaling offset, is %f\n", scale_offset ); printf ( " SEED, the simulation randomization seed, is %d\n", seed ); -/* - Allocate memory. -*/ - acc = ( double * ) malloc ( nd * np * sizeof ( double ) ); - box = ( double * ) malloc ( nd * sizeof ( double ) ); - force = ( double * ) malloc ( nd * np * sizeof ( double ) ); - pos = ( double * ) malloc ( nd * np * sizeof ( double ) ); - vel = ( double * ) malloc ( nd * np * sizeof ( double ) ); -/* - Set the dimensions of the box. -*/ - for ( i = 0; i < nd; i++ ) - { - box[i] = 10.0; - } - printf ( "\n" ); - printf ( " Initializing positions, velocities, and accelerations.\n" ); -/* - Set initial positions, velocities, and accelerations. -*/ - initialize ( np, nd, box, &seed, pos, vel, acc ); -/* - Compute the forces and energies. -*/ - printf ( "\n" ); - printf ( " Computing initial forces and energies.\n" ); - - compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); - - e0 = potential + kinetic; -/* - This is the main time stepping loop: - Compute forces and energies, - Update positions, velocities, accelerations. -*/ - printf ( "\n" ); - printf ( " At each step, we report the potential and kinetic energies.\n" ); - printf ( " The sum of these energies should be a constant.\n" ); - printf ( " As an accuracy check, we also print the relative error\n" ); - printf ( " in the total energy.\n" ); - printf ( "\n" ); - printf ( " Step Potential Kinetic (P+K-E0)/E0\n" ); - printf ( " Energy P Energy K Relative Energy Error\n" ); - printf ( "\n" ); - - FILE *ofile = fopen(outfile,"w"); - fprintf (ofile, " Step Potential Kinetic RelativeErr\n" ); - - printf ( " %8d %14f %14f %14e\n", - step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); - fprintf ( ofile, " %8d %14f %14f %14e\n", - step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); - step_print_index = step_print_index + 1; - step_print = ( step_print_index * step_num ) / step_print_num; - ctime1 = cpu_time ( ); simulate (step_num, step_print_num, step_print, step_print_index, - np, nd, pos, vel, - mass, force, acc, - potential, kinetic, e0, - dt, - ofile); + np, nd, mass, potential, kinetic, e0, + dt, seed, outfile); ctime2 = cpu_time ( ); ctime = ctime2 - ctime1; @@ -262,11 +203,7 @@ printf ( " Elapsed cpu time for main computation:\n" ); printf ( " %f seconds.\n", ctime ); - free ( acc ); - free ( box ); - free ( force ); - free ( pos ); - free ( vel ); + char tarcmd[2000]; sprintf(tarcmd,"tar zcf %s md??.trj",trjfile); system(tarcmd); @@ -280,6 +217,5 @@ printf ( "\n" ); timestamp ( ); - fclose(ofile); return 0; } Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 16:23:58 UTC (rev 8130) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 16:30:05 UTC (rev 8131) @@ -19,13 +19,72 @@ void simulate (int step_num, int step_print_num, int step_print, int step_print_index, - int np, int nd, double pos[], double vel[], - double mass, double force[], double acc[], + int np, int nd, + double mass, double potential, double kinetic, double e0, double dt, - FILE* ofile) + int seed, + char* outfile) { - for (int step = 1; step <= step_num; step++ ) + /* + Allocate memory. + */ + double* acc = ( double * ) malloc ( nd * np * sizeof ( double ) ); + double* box = ( double * ) malloc ( nd * sizeof ( double ) ); + double* force = ( double * ) malloc ( nd * np * sizeof ( double ) ); + double* pos = ( double * ) malloc ( nd * np * sizeof ( double ) ); + double* vel = ( double * ) malloc ( nd * np * sizeof ( double ) ); + /* + Set the dimensions of the box. + */ + for (int i = 0; i < nd; i++ ) + { + box[i] = 10.0; + } + + printf ( "\n" ); + printf ( " Initializing positions, velocities, and accelerations.\n" ); + /* + Set initial positions, velocities, and accelerations. + */ + initialize ( np, nd, box, &seed, pos, vel, acc ); + /* + Compute the forces and energies. + */ + printf ( "\n" ); + printf ( " Computing initial forces and energies.\n" ); + + compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); + + e0 = potential + kinetic; + /* + This is the main time stepping loop: + Compute forces and energies, + Update positions, velocities, accelerations. + */ + printf ( "\n" ); + printf ( " At each step, we report the potential and kinetic energies.\n" ); + printf ( " The sum of these energies should be a constant.\n" ); + printf ( " As an accuracy check, we also print the relative error\n" ); + printf ( " in the total energy.\n" ); + printf ( "\n" ); + printf ( " Step Potential Kinetic (P+K-E0)/E0\n" ); + printf ( " Energy P Energy K Relative Energy Error\n" ); + printf ( "\n" ); + + FILE *ofile = fopen(outfile,"w"); + fprintf (ofile, " Step Potential Kinetic RelativeErr\n" ); + + int step = 0; + printf ( " %8d %14f %14f %14e\n", + step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); + fprintf ( ofile, " %8d %14f %14f %14e\n", + step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); + step_print_index = step_print_index + 1; + step_print = ( step_print_index * step_num ) / step_print_num; + + + for (step = 1; step <= step_num; step++ ) { compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); @@ -41,6 +100,14 @@ } update ( np, nd, pos, vel, force, acc, mass, dt ); } + + free ( acc ); + free ( box ); + free ( force ); + free ( pos ); + free ( vel ); + + fclose(ofile); } /******************************************************************************/ Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h 2014-08-13 16:23:58 UTC (rev 8130) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h 2014-08-13 16:30:05 UTC (rev 8131) @@ -23,10 +23,11 @@ void simulate (int step_num, int step_print_num, int step_print, int step_print_index, - int np, int nd, double pos[], double vel[], - double mass, double force[], double acc[], + int np, int nd, + double mass, double potential, double kinetic, double e0, double dt, - FILE* ofile); + int seed, + char* outfile); #endif From wozniak at ci.uchicago.edu Wed Aug 13 11:35:59 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 11:35:59 -0500 (CDT) Subject: [Swift-commit] r8132 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813163559.8AE1F9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 11:35:59 -0500 (Wed, 13 Aug 2014) New Revision: 8132 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c Log: Make one big TRJ file Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 16:30:05 UTC (rev 8131) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 16:35:59 UTC (rev 8132) @@ -1,3 +1,4 @@ +# include # include # include # include @@ -17,6 +18,9 @@ void snap ( int np, int nd, double pos[], double vel[], double f[], double acc[], double mass, double dt ); +static void snap_file_open(void); +static void snap_file_close(void); + void simulate (int step_num, int step_print_num, int step_print, int step_print_index, int np, int nd, @@ -44,6 +48,9 @@ printf ( "\n" ); printf ( " Initializing positions, velocities, and accelerations.\n" ); + + snap_file_open(); + /* Set initial positions, velocities, and accelerations. */ @@ -108,6 +115,7 @@ free ( vel ); fclose(ofile); + snap_file_close(); } /******************************************************************************/ @@ -572,22 +580,32 @@ } static int snapid = 0; +static FILE *snap_file = NULL; +static void snap_file_open() +{ + char snapfile[100]; + sprintf(snapfile, "md%02d.trj", snapid); + snap_file = fopen(snapfile, "w"); + assert(snap_file != NULL); +} + +static void snap_file_close() +{ + fclose(snap_file); + snap_file = NULL; +} + void snap ( int np, int nd, double pos[], double vel[], double f[], double acc[], double mass, double dt ) { int j; - - char snapfile[100]; - sprintf(snapfile, "md%02d.trj", snapid); - FILE *sf = fopen(snapfile, "w"); - for ( j = 0; j < np; j++ ) { - fprintf(sf, "s %f %f %f %s\n", scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); + fprintf(snap_file, "s %f %f %f %s\n", + scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); } - fclose(sf); snapid++; } From wozniak at ci.uchicago.edu Wed Aug 13 11:37:09 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 11:37:09 -0500 (CDT) Subject: [Swift-commit] r8133 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py Message-ID: <20140813163709.83E659D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 11:37:09 -0500 (Wed, 13 Aug 2014) New Revision: 8133 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-compute.sh Log: New run-compute Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-compute.sh (from rev 8117, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-compute.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-compute.sh 2014-08-13 16:37:09 UTC (rev 8133) @@ -0,0 +1,9 @@ +#!/bin/sh -eu + +source ../../cfg/setup-compute.sh +SETTINGS=../../cfg/settings-compute.sh + +PROGRAM=add +stc ${PROGRAM}.swift +turbine-cobalt-run.zsh -n 2 -s ${SETTINGS} ${PROGRAM}.tcl + From wozniak at ci.uchicago.edu Wed Aug 13 11:42:54 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 11:42:54 -0500 (CDT) Subject: [Swift-commit] r8134 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813164254.2BC6F9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 11:42:54 -0500 (Wed, 13 Aug 2014) New Revision: 8134 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c Log: Prepend time in snap file Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 16:37:09 UTC (rev 8133) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 16:42:54 UTC (rev 8134) @@ -15,7 +15,7 @@ double r8_uniform_01 ( int *seed ); void update ( int np, int nd, double pos[], double vel[], double f[], double acc[], double mass, double dt ); -void snap ( int np, int nd, double pos[], double vel[], double f[], +void snap ( int np, int nd, double t, double pos[], double vel[], double f[], double acc[], double mass, double dt ); static void snap_file_open(void); @@ -103,7 +103,7 @@ ( potential + kinetic - e0 ) / e0 ); step_print_index = step_print_index + 1; step_print = ( step_print_index * step_num ) / step_print_num; - snap ( np, nd, pos, vel, force, acc, mass, dt ); + snap (np, nd, step*dt, pos, vel, force, acc, mass, dt ); } update ( np, nd, pos, vel, force, acc, mass, dt ); } @@ -596,15 +596,15 @@ snap_file = NULL; } -void snap ( int np, int nd, double pos[], double vel[], double f[], +void snap ( int np, int nd, double t, double pos[], double vel[], double f[], double acc[], double mass, double dt ) { int j; for ( j = 0; j < np; j++ ) { - fprintf(snap_file, "s %f %f %f %s\n", - scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); + fprintf(snap_file, "%f s %f %f %f %s\n", + t, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); } snapid++; From wozniak at ci.uchicago.edu Wed Aug 13 11:43:02 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 11:43:02 -0500 (CDT) Subject: [Swift-commit] r8135 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813164302.754849D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 11:43:02 -0500 (Wed, 13 Aug 2014) New Revision: 8135 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/ Log: Set ignores Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md ___________________________________________________________________ Modified: svn:ignore - .cproject md *.trj output.* + .cproject .settings md *.trj output.* From wozniak at ci.uchicago.edu Wed Aug 13 11:59:15 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 11:59:15 -0500 (CDT) Subject: [Swift-commit] r8136 - demo/xsede.2014.0425/src/md Message-ID: <20140813165915.8AFD29D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 11:59:15 -0500 (Wed, 13 Aug 2014) New Revision: 8136 Added: demo/xsede.2014.0425/src/md/main.c demo/xsede.2014.0425/src/md/md.h demo/xsede.2014.0425/src/md/test-md.sh Modified: demo/xsede.2014.0425/src/md/Makefile demo/xsede.2014.0425/src/md/md.c Log: Latest Modified: demo/xsede.2014.0425/src/md/Makefile =================================================================== --- demo/xsede.2014.0425/src/md/Makefile 2014-08-13 16:43:02 UTC (rev 8135) +++ demo/xsede.2014.0425/src/md/Makefile 2014-08-13 16:59:15 UTC (rev 8136) @@ -1,15 +1,43 @@ bin = md -src = md.c CC = gcc -#CFLAGS = -O3 -ffast-math +INCLUDES := +OPTZ = -O0 +OPTS = -O3 -ffast-math +CFLAGS = $(OPTZ) -g -fPIC -std=gnu99 $(INCLUDES) -$(bin): $(src) - $(CC) -o $@ $(bin).c -lm +SRC = main.c md.c +OBJ = $(patsubst %.c,%.o,$(SRC)) + + +all: $(bin) + +# Link stand-alone executable: +$(bin): $(OBJ) + $(CC) -o $(@) $(OBJ) -lm + +# Swift/T integration: + +USE_SWIFT = 1 +ifeq ($(USE_SWIFT),1) + +TCL_HOME = $(HOME)/sfw/tcl-8.6.0 +INCLUDES += -I $(TCL_HOME)/include + +swift-pkg: libtclmd.so + +md_wrap.c: md.i + swig $(<) + +libtclmd.so: md_wrap.o $(OBJ) + gcc -shared -o $(@) $(^) -L $(TCL_HOME)/lib -l tcl8.6 + +endif + .PHONY: clean clean: - rm -f $(obj) $(bin) + rm -f $(OBJ) $(bin) .PHONY: install install: @@ -18,3 +46,4 @@ .PHONY: uninstall uninstall: rm -f ../../bin/$(bin) + Added: demo/xsede.2014.0425/src/md/main.c =================================================================== --- demo/xsede.2014.0425/src/md/main.c (rev 0) +++ demo/xsede.2014.0425/src/md/main.c 2014-08-13 16:59:15 UTC (rev 8136) @@ -0,0 +1,221 @@ + +/* + * main.c + * + * Created on: Aug 13, 2014 + * Author: wozniak + */ + +#include +#include +#include "md.h" + + +char *outfile = "md.dat"; +char *trjfile = "md.trj.tgz"; + + +/******************************************************************************/ + +int main ( int argc, char *argv[] ) + +/******************************************************************************/ +/* + Purpose: + + MAIN is the main program for MD. + + Discussion: + + MD implements a simple molecular dynamics simulation. + + The velocity Verlet time integration scheme is used. + + The particles interact with a central pair potential. + + Usage: + + md nd np step_num print_step_num dt mass printinfo scale_factor scale_offset seed outFile trajectoryFile + where + * nd is the spatial dimension (2 or 3); + * np is the number of particles (500, for instance); + * step_num is the number of time steps (500, for instance); + * print_step_num is the number of snapshot prints (10 for instance); + * dt is size of timestep; + * mass is particle mass; + * printinfo is a string to append to each particle coord + * scale_offset and scale_factor are used to scale particle positions for logging/rendering (FIXME) + * seed sets the initial configuration + + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 05 November 2010 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + None +*/ +{ + + double ctime; + double ctime1; + double ctime2; + double dt = 0.0001; + double e0; + double *force; + int i; + int id; + double kinetic; + double mass = 1.0 * .0001; + int nd; + int np; + + double potential; + int seed = 123456789; + int step; + int step_num; + int step_print; + int step_print_index = 0; + int step_print_num = 10; + double *vel; + + timestamp ( ); + printf ( "\n" ); + printf ( "MD\n" ); + printf ( " C version\n" ); + printf ( " A molecular dynamics program.\n" ); +/* + Get the spatial dimension. +*/ + if ( 1 < argc ) + { + nd = atoi ( argv[1] ); + } + else + { + printf ( "\n" ); + printf ( " Enter ND, the spatial dimension (2 or 3).\n" ); + scanf ( "%d", &nd ); + } +// +// Get the number of points. +// + if ( 2 < argc ) + { + np = atoi ( argv[2] ); + } + else + { + printf ( "\n" ); + printf ( " Enter NP, the number of points (500, for instance).\n" ); + scanf ( "%d", &np ); + } +// +// Get the number of time steps. +// + if ( 3 < argc ) + { + step_num = atoi ( argv[3] ); + } + else + { + printf ( "\n" ); + printf ( " Enter ND, the number of time steps (500 or 1000, for instance).\n" ); + scanf ( "%d", &step_num ); + } + /* + Get any additional args (command-line only) + md nd np step_num [ step__print_num dt mass printinfo scale_factor scale_offset randomseed outfile trjfile ] + */ + if ( 4 < argc ) + { + step_print_num = atoi ( argv[4] ); + } + if ( 5 < argc ) + { + dt = atof ( argv[5] ); + } + if ( 6 < argc ) + { + mass = atof ( argv[6] ); + } + if ( 7 < argc ) + { + printinfo = ( argv[7] ); + } + if ( 8 < argc ) + { + scale_factor = atof ( argv[8] ); + } + if ( 9 < argc ) + { + scale_offset = atof ( argv[9] ); + } + if ( 10 < argc ) + { + seed = atof ( argv[10] ); + } + if ( 11 < argc ) + { + outfile = argv[11]; + } + if ( 12 < argc ) + { + trjfile = argv[12]; + } + +/* + Report. +*/ + printf ( "\n" ); + printf ( " MD: Argument count: %d\n", argc ); + printf ( " ND, the spatial dimension, is %d\n", nd ); + printf ( " NP, the number of particles in the simulation, is %d\n", np ); + printf ( " STEP_NUM, the number of time steps, is %d\n", step_num ); + printf ( " STEP_PRINT_NUM, the number of snapshots to print, is %d\n", step_print_num ); + printf ( " DT, the size of each time step, is %f\n", dt ); + printf ( " MASS, the particle mass, is %f\n", mass ); + printf ( " PRINTINFO, the pass-through info to c-ray, is %s\n", printinfo ); + printf ( " SCALE_FACTOR, the particle position scaling factor, is %f\n", scale_factor ); + printf ( " SCALE_OFFSET, the particle position scaling offset, is %f\n", scale_offset ); + printf ( " SEED, the simulation randomization seed, is %d\n", seed ); + + ctime1 = cpu_time ( ); + + simulate (step_num, step_print_num, step_print, step_print_index, + np, nd, mass, potential, kinetic, e0, + dt, seed, outfile); + + ctime2 = cpu_time ( ); + ctime = ctime2 - ctime1; + + printf ( "\n" ); + printf ( " Elapsed cpu time for main computation:\n" ); + printf ( " %f seconds.\n", ctime ); + + + char tarcmd[2000]; + sprintf(tarcmd,"tar zcf %s md??.trj",trjfile); + system(tarcmd); +/* + Terminate. +*/ + printf ( "\n" ); + printf ( "MD\n" ); + printf ( " Normal end of execution.\n" ); + + printf ( "\n" ); + timestamp ( ); + + return 0; +} Modified: demo/xsede.2014.0425/src/md/md.c =================================================================== --- demo/xsede.2014.0425/src/md/md.c 2014-08-13 16:43:02 UTC (rev 8135) +++ demo/xsede.2014.0425/src/md/md.c 2014-08-13 16:59:15 UTC (rev 8136) @@ -1,3 +1,4 @@ +# include # include # include # include @@ -3,262 +4,92 @@ # include -int main ( int argc, char *argv[] ); -void compute ( int np, int nd, double pos[], double vel[], - double mass, double f[], double *pot, double *kin ); -double cpu_time ( void ); -double dist ( int nd, double r1[], double r2[], double dr[] ); -void initialize ( int np, int nd, double box[], int *seed, double pos[], - double vel[], double acc[] ); -double r8_uniform_01 ( int *seed ); -void timestamp ( void ); -void update ( int np, int nd, double pos[], double vel[], double f[], - double acc[], double mass, double dt ); -void snap ( int np, int nd, double pos[], double vel[], double f[], - double acc[], double mass, double dt ); +#include "md.h" double scale_factor = 2.5, scale_offset = -2.0; char *printinfo = "0.05 1.0 0.2 0.05 50.0 0.1"; -char *outfile = "md.dat"; -char *trjfile = "md.trj.tgz"; -/******************************************************************************/ +double dist ( int nd, double r1[], double r2[], double dr[] ); -int main ( int argc, char *argv[] ) +double r8_uniform_01 ( int *seed ); +void update ( int np, int nd, double pos[], double vel[], double f[], + double acc[], double mass, double dt ); +void snap ( int np, int nd, double t, double pos[], double vel[], double f[], + double acc[], double mass, double dt ); -/******************************************************************************/ -/* - Purpose: +static void snap_file_open(void); +static void snap_file_close(void); - MAIN is the main program for MD. +void simulate (int step_num, int step_print_num, + int step_print, int step_print_index, + int np, int nd, + double mass, + double potential, double kinetic, double e0, + double dt, + int seed, + char* outfile) +{ + /* + Allocate memory. + */ + double* acc = ( double * ) malloc ( nd * np * sizeof ( double ) ); + double* box = ( double * ) malloc ( nd * sizeof ( double ) ); + double* force = ( double * ) malloc ( nd * np * sizeof ( double ) ); + double* pos = ( double * ) malloc ( nd * np * sizeof ( double ) ); + double* vel = ( double * ) malloc ( nd * np * sizeof ( double ) ); + /* + Set the dimensions of the box. + */ + for (int i = 0; i < nd; i++ ) + { + box[i] = 10.0; + } - Discussion: + printf ( "\n" ); + printf ( " Initializing positions, velocities, and accelerations.\n" ); - MD implements a simple molecular dynamics simulation. + snap_file_open(); - The velocity Verlet time integration scheme is used. + /* + Set initial positions, velocities, and accelerations. + */ + initialize ( np, nd, box, &seed, pos, vel, acc ); + /* + Compute the forces and energies. + */ + printf ( "\n" ); + printf ( " Computing initial forces and energies.\n" ); - The particles interact with a central pair potential. + compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); - Usage: - - md nd np step_num print_step_num dt mass printinfo scale_factor scale_offset seed outFile trajectoryFile - where - * nd is the spatial dimension (2 or 3); - * np is the number of particles (500, for instance); - * step_num is the number of time steps (500, for instance); - * print_step_num is the number of snapshot prints (10 for instance); - * dt is size of timestep; - * mass is particle mass; - * printinfo is a string to append to each particle coord - * scale_offset and scale_factor are used to scale particle positions for logging/rendering (FIXME) - * seed sets the initial configuration - - - Licensing: - - This code is distributed under the GNU LGPL license. - - Modified: - - 05 November 2010 - - Author: - - Original FORTRAN90 version by Bill Magro. - C version by John Burkardt. - - Parameters: - - None -*/ -{ - double *acc; - double *box; - double ctime; - double ctime1; - double ctime2; - double dt = 0.0001; - double e0; - double *force; - int i; - int id; - double kinetic; - double mass = 1.0 * .0001; - int nd; - int np; - double *pos; - double potential; - int seed = 123456789; - int step; - int step_num; - int step_print; - int step_print_index; - int step_print_num=10; - double *vel; - - timestamp ( ); - printf ( "\n" ); - printf ( "MD\n" ); - printf ( " C version\n" ); - printf ( " A molecular dynamics program.\n" ); -/* - Get the spatial dimension. -*/ - if ( 1 < argc ) - { - nd = atoi ( argv[1] ); - } - else - { + e0 = potential + kinetic; + /* + This is the main time stepping loop: + Compute forces and energies, + Update positions, velocities, accelerations. + */ printf ( "\n" ); - printf ( " Enter ND, the spatial dimension (2 or 3).\n" ); - scanf ( "%d", &nd ); - } -// -// Get the number of points. -// - if ( 2 < argc ) - { - np = atoi ( argv[2] ); - } - else - { + printf ( " At each step, we report the potential and kinetic energies.\n" ); + printf ( " The sum of these energies should be a constant.\n" ); + printf ( " As an accuracy check, we also print the relative error\n" ); + printf ( " in the total energy.\n" ); printf ( "\n" ); - printf ( " Enter NP, the number of points (500, for instance).\n" ); - scanf ( "%d", &np ); - } -// -// Get the number of time steps. -// - if ( 3 < argc ) - { - step_num = atoi ( argv[3] ); - } - else - { + printf ( " Step Potential Kinetic (P+K-E0)/E0\n" ); + printf ( " Energy P Energy K Relative Energy Error\n" ); printf ( "\n" ); - printf ( " Enter ND, the number of time steps (500 or 1000, for instance).\n" ); - scanf ( "%d", &step_num ); - } - /* - Get any additional args (command-line only) - md nd np step_num [ step__print_num dt mass printinfo scale_factor scale_offset randomseed outfile trjfile ] - */ - if ( 4 < argc ) - { - step_print_num = atoi ( argv[4] ); - } - if ( 5 < argc ) - { - dt = atof ( argv[5] ); - } - if ( 6 < argc ) - { - mass = atof ( argv[6] ); - } - if ( 7 < argc ) - { - printinfo = ( argv[7] ); - } - if ( 8 < argc ) - { - scale_factor = atof ( argv[8] ); - } - if ( 9 < argc ) - { - scale_offset = atof ( argv[9] ); - } - if ( 10 < argc ) - { - seed = atof ( argv[10] ); - } - if ( 11 < argc ) - { - outfile = argv[11]; - } - if ( 12 < argc ) - { - trjfile = argv[12]; - } -/* - Report. -*/ - printf ( "\n" ); - printf ( " MD: Argument count: %d\n", argc ); - printf ( " ND, the spatial dimension, is %d\n", nd ); - printf ( " NP, the number of particles in the simulation, is %d\n", np ); - printf ( " STEP_NUM, the number of time steps, is %d\n", step_num ); - printf ( " STEP_PRINT_NUM, the number of snapshots to print, is %d\n", step_print_num ); - printf ( " DT, the size of each time step, is %f\n", dt ); - printf ( " MASS, the particle mass, is %f\n", mass ); - printf ( " PRINTINFO, the pass-through info to c-ray, is %s\n", printinfo ); - printf ( " SCALE_FACTOR, the particle position scaling factor, is %f\n", scale_factor ); - printf ( " SCALE_OFFSET, the particle position scaling offset, is %f\n", scale_offset ); - printf ( " SEED, the simulation randomization seed, is %d\n", seed ); -/* - Allocate memory. -*/ - acc = ( double * ) malloc ( nd * np * sizeof ( double ) ); - box = ( double * ) malloc ( nd * sizeof ( double ) ); - force = ( double * ) malloc ( nd * np * sizeof ( double ) ); - pos = ( double * ) malloc ( nd * np * sizeof ( double ) ); - vel = ( double * ) malloc ( nd * np * sizeof ( double ) ); -/* - Set the dimensions of the box. -*/ - for ( i = 0; i < nd; i++ ) - { - box[i] = 10.0; - } + FILE *ofile = fopen(outfile,"w"); + fprintf (ofile, " Step Potential Kinetic RelativeErr\n" ); - printf ( "\n" ); - printf ( " Initializing positions, velocities, and accelerations.\n" ); -/* - Set initial positions, velocities, and accelerations. -*/ - initialize ( np, nd, box, &seed, pos, vel, acc ); -/* - Compute the forces and energies. -*/ - printf ( "\n" ); - printf ( " Computing initial forces and energies.\n" ); + int step = 0; + printf ( " %8d %14f %14f %14e\n", + step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); + fprintf ( ofile, " %8d %14f %14f %14e\n", + step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); + step_print_index = step_print_index + 1; + step_print = ( step_print_index * step_num ) / step_print_num; - compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); - e0 = potential + kinetic; -/* - This is the main time stepping loop: - Compute forces and energies, - Update positions, velocities, accelerations. -*/ - printf ( "\n" ); - printf ( " At each step, we report the potential and kinetic energies.\n" ); - printf ( " The sum of these energies should be a constant.\n" ); - printf ( " As an accuracy check, we also print the relative error\n" ); - printf ( " in the total energy.\n" ); - printf ( "\n" ); - printf ( " Step Potential Kinetic (P+K-E0)/E0\n" ); - printf ( " Energy P Energy K Relative Energy Error\n" ); - printf ( "\n" ); - - FILE *ofile = fopen(outfile,"w"); - fprintf (ofile, " Step Potential Kinetic RelativeErr\n" ); - - step_print = 0; - step_print_index = 0; - - step = 0; - printf ( " %8d %14f %14f %14e\n", - step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); - fprintf ( ofile, " %8d %14f %14f %14e\n", - step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); - step_print_index = step_print_index + 1; - step_print = ( step_print_index * step_num ) / step_print_num; - - ctime1 = cpu_time ( ); - - for ( step = 1; step <= step_num; step++ ) + for (step = 1; step <= step_num; step++ ) { compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); @@ -267,43 +98,26 @@ if ( step == step_print ) { printf ( " %8d %14f %14f %14e\n", step, potential, kinetic, - ( potential + kinetic - e0 ) / e0 ); + ( potential + kinetic - e0 ) / e0 ); fprintf ( ofile, " %8d %14f %14f %14e\n", step, potential, kinetic, - ( potential + kinetic - e0 ) / e0 ); + ( potential + kinetic - e0 ) / e0 ); step_print_index = step_print_index + 1; step_print = ( step_print_index * step_num ) / step_print_num; - snap ( np, nd, pos, vel, force, acc, mass, dt ); + snap (np, nd, step*dt, pos, vel, force, acc, mass, dt ); } update ( np, nd, pos, vel, force, acc, mass, dt ); } - ctime2 = cpu_time ( ); - ctime = ctime2 - ctime1; - printf ( "\n" ); - printf ( " Elapsed cpu time for main computation:\n" ); - printf ( " %f seconds.\n", ctime ); - free ( acc ); free ( box ); free ( force ); free ( pos ); free ( vel ); - char tarcmd[2000]; - sprintf(tarcmd,"tar zcf %s md??.trj",trjfile); - system(tarcmd); -/* - Terminate. -*/ - printf ( "\n" ); - printf ( "MD\n" ); - printf ( " Normal end of execution.\n" ); - printf ( "\n" ); - timestamp ( ); - fclose(ofile); - return 0; + snap_file_close(); } + /******************************************************************************/ void compute ( int np, int nd, double pos[], double vel[], @@ -766,22 +580,32 @@ } static int snapid = 0; +static FILE *snap_file = NULL; -void snap ( int np, int nd, double pos[], double vel[], double f[], - double acc[], double mass, double dt ) +static void snap_file_open() { - int j; - char snapfile[100]; sprintf(snapfile, "md%02d.trj", snapid); + snap_file = fopen(snapfile, "w"); + assert(snap_file != NULL); +} - FILE *sf = fopen(snapfile, "w"); +static void snap_file_close() +{ + fclose(snap_file); + snap_file = NULL; +} +void snap ( int np, int nd, double t, double pos[], double vel[], double f[], + double acc[], double mass, double dt ) +{ + int j; + for ( j = 0; j < np; j++ ) { - fprintf(sf, "s %f %f %f %s\n", scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); + fprintf(snap_file, "%f s %f %f %f %s\n", + t, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); } - fclose(sf); snapid++; } Added: demo/xsede.2014.0425/src/md/md.h =================================================================== --- demo/xsede.2014.0425/src/md/md.h (rev 0) +++ demo/xsede.2014.0425/src/md/md.h 2014-08-13 16:59:15 UTC (rev 8136) @@ -0,0 +1,33 @@ +/* + * md.h + * + * Created on: Aug 13, 2014 + * Author: wozniak + */ + +#ifndef MD_H +#define MD_H + +extern double scale_factor, scale_offset; +extern char *printinfo; + +double cpu_time ( void ); + +void timestamp ( void ); + +void initialize ( int np, int nd, double box[], int *seed, double pos[], + double vel[], double acc[] ); + +void compute ( int np, int nd, double pos[], double vel[], + double mass, double f[], double *pot, double *kin ); + +void simulate (int step_num, int step_print_num, + int step_print, int step_print_index, + int np, int nd, + double mass, + double potential, double kinetic, double e0, + double dt, + int seed, + char* outfile); + +#endif Added: demo/xsede.2014.0425/src/md/test-md.sh =================================================================== --- demo/xsede.2014.0425/src/md/test-md.sh (rev 0) +++ demo/xsede.2014.0425/src/md/test-md.sh 2014-08-13 16:59:15 UTC (rev 8136) @@ -0,0 +1,10 @@ +#!/bin/sh -eu + +NPART=4 +STEPS=10 +MASS=1 +SEED=42 +OUT=output.txt +TRJ=output.trj + +./md 3 ${NPART} ${STEPS} 10 ".0001" ${MASS} "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 ${SEED} ${OUT} ${TRJ} Property changes on: demo/xsede.2014.0425/src/md/test-md.sh ___________________________________________________________________ Added: svn:executable + * From wozniak at ci.uchicago.edu Wed Aug 13 12:10:42 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 12:10:42 -0500 (CDT) Subject: [Swift-commit] r8137 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813171042.A64EE9D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 12:10:42 -0500 (Wed, 13 Aug 2014) New Revision: 8137 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c Log: Make TRJ output time an integer Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile 2014-08-13 16:59:15 UTC (rev 8136) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile 2014-08-13 17:10:42 UTC (rev 8137) @@ -1,18 +1,40 @@ bin = md CC = gcc +INCLUDES := OPTZ = -O0 OPTS = -O3 -ffast-math -CFLAGS = $(OPTZ) -g -fPIC -std=gnu99 +CFLAGS = $(OPTZ) -g -fPIC -std=gnu99 $(INCLUDES) SRC = main.c md.c OBJ = $(patsubst %.c,%.o,$(SRC)) + + all: $(bin) +# Link stand-alone executable: $(bin): $(OBJ) $(CC) -o $(@) $(OBJ) -lm +# Swift/T integration: + +USE_SWIFT = 1 +ifeq ($(USE_SWIFT),1) + +TCL_HOME = $(HOME)/sfw/tcl-8.6.0 +INCLUDES += -I $(TCL_HOME)/include + +swift-pkg: libtclmd.so + +md_wrap.c: md.i + swig $(<) + +libtclmd.so: md_wrap.o $(OBJ) + gcc -shared -o $(@) $(^) -L $(TCL_HOME)/lib -l tcl8.6 + +endif + .PHONY: clean clean: rm -f $(OBJ) $(bin) @@ -24,3 +46,4 @@ .PHONY: uninstall uninstall: rm -f ../../bin/$(bin) + Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 16:59:15 UTC (rev 8136) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 17:10:42 UTC (rev 8137) @@ -15,7 +15,7 @@ double r8_uniform_01 ( int *seed ); void update ( int np, int nd, double pos[], double vel[], double f[], double acc[], double mass, double dt ); -void snap ( int np, int nd, double t, double pos[], double vel[], double f[], +void snap ( int np, int nd, int t, double pos[], double vel[], double f[], double acc[], double mass, double dt ); static void snap_file_open(void); @@ -103,7 +103,7 @@ ( potential + kinetic - e0 ) / e0 ); step_print_index = step_print_index + 1; step_print = ( step_print_index * step_num ) / step_print_num; - snap (np, nd, step*dt, pos, vel, force, acc, mass, dt ); + snap (np, nd, step, pos, vel, force, acc, mass, dt ); } update ( np, nd, pos, vel, force, acc, mass, dt ); } @@ -596,14 +596,14 @@ snap_file = NULL; } -void snap ( int np, int nd, double t, double pos[], double vel[], double f[], +void snap ( int np, int nd, int t, double pos[], double vel[], double f[], double acc[], double mass, double dt ) { int j; for ( j = 0; j < np; j++ ) { - fprintf(snap_file, "%f s %f %f %f %s\n", + fprintf(snap_file, "%i s %f %f %f %s\n", t, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); } From wilde at ci.uchicago.edu Wed Aug 13 12:47:41 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Wed, 13 Aug 2014 12:47:41 -0500 (CDT) Subject: [Swift-commit] r8138 - demo/xsede.2014.0425/src/md Message-ID: <20140813174741.EEFD19D92B@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-13 12:47:41 -0500 (Wed, 13 Aug 2014) New Revision: 8138 Modified: demo/xsede.2014.0425/src/md/main.c demo/xsede.2014.0425/src/md/md.c demo/xsede.2014.0425/src/md/md.h Log: Renamed snap open/close functions. Disabled system(tar) stuff. Used integer snapid for trj file. Snapshot of trajectory is now done to a single .trj file. Modified: demo/xsede.2014.0425/src/md/main.c =================================================================== --- demo/xsede.2014.0425/src/md/main.c 2014-08-13 17:10:42 UTC (rev 8137) +++ demo/xsede.2014.0425/src/md/main.c 2014-08-13 17:47:41 UTC (rev 8138) @@ -12,7 +12,7 @@ char *outfile = "md.dat"; -char *trjfile = "md.trj.tgz"; +char *trjfile = "md.trj"; /******************************************************************************/ @@ -194,7 +194,7 @@ simulate (step_num, step_print_num, step_print, step_print_index, np, nd, mass, potential, kinetic, e0, - dt, seed, outfile); + dt, seed, outfile, trjfile); ctime2 = cpu_time ( ); ctime = ctime2 - ctime1; @@ -203,10 +203,12 @@ printf ( " Elapsed cpu time for main computation:\n" ); printf ( " %f seconds.\n", ctime ); - +#ifdef NOTDEF char tarcmd[2000]; sprintf(tarcmd,"tar zcf %s md??.trj",trjfile); system(tarcmd); +#endif + /* Terminate. */ Modified: demo/xsede.2014.0425/src/md/md.c =================================================================== --- demo/xsede.2014.0425/src/md/md.c 2014-08-13 17:10:42 UTC (rev 8137) +++ demo/xsede.2014.0425/src/md/md.c 2014-08-13 17:47:41 UTC (rev 8138) @@ -18,8 +18,8 @@ void snap ( int np, int nd, double t, double pos[], double vel[], double f[], double acc[], double mass, double dt ); -static void snap_file_open(void); -static void snap_file_close(void); +static void trj_file_open(char *trjfile); +static void trj_file_close(void); void simulate (int step_num, int step_print_num, int step_print, int step_print_index, @@ -28,7 +28,8 @@ double potential, double kinetic, double e0, double dt, int seed, - char* outfile) + char* outfile, + char* trjfile) { /* Allocate memory. @@ -49,7 +50,7 @@ printf ( "\n" ); printf ( " Initializing positions, velocities, and accelerations.\n" ); - snap_file_open(); + trj_file_open(trjfile); /* Set initial positions, velocities, and accelerations. @@ -115,7 +116,7 @@ free ( vel ); fclose(ofile); - snap_file_close(); + trj_file_close(); } /******************************************************************************/ @@ -580,20 +581,22 @@ } static int snapid = 0; -static FILE *snap_file = NULL; +static FILE *trj_file = NULL; -static void snap_file_open() +static void trj_file_open(char *trjfile) { +#ifdef NOTDEF char snapfile[100]; sprintf(snapfile, "md%02d.trj", snapid); - snap_file = fopen(snapfile, "w"); - assert(snap_file != NULL); +#endif + trj_file = fopen(trjfile, "w"); + assert(trj_file != NULL); } -static void snap_file_close() +static void trj_file_close() { - fclose(snap_file); - snap_file = NULL; + fclose(trj_file); + trj_file = NULL; } void snap ( int np, int nd, double t, double pos[], double vel[], double f[], @@ -603,8 +606,8 @@ for ( j = 0; j < np; j++ ) { - fprintf(snap_file, "%f s %f %f %f %s\n", - t, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); + fprintf(trj_file, "%d s %f %f %f %s\n", + snapid, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); } snapid++; Modified: demo/xsede.2014.0425/src/md/md.h =================================================================== --- demo/xsede.2014.0425/src/md/md.h 2014-08-13 17:10:42 UTC (rev 8137) +++ demo/xsede.2014.0425/src/md/md.h 2014-08-13 17:47:41 UTC (rev 8138) @@ -28,6 +28,7 @@ double potential, double kinetic, double e0, double dt, int seed, - char* outfile); + char* outfile, + char* trjfile); #endif From wozniak at ci.uchicago.edu Wed Aug 13 14:50:12 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 14:50:12 -0500 (CDT) Subject: [Swift-commit] r8139 - demo/xsede.2014.0425/src/md Message-ID: <20140813195012.F192B9D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 14:50:12 -0500 (Wed, 13 Aug 2014) New Revision: 8139 Added: demo/xsede.2014.0425/src/md/make-package.tcl demo/xsede.2014.0425/src/md/md.i demo/xsede.2014.0425/src/md/md.tcl demo/xsede.2014.0425/src/md/test-md.tcl Modified: demo/xsede.2014.0425/src/md/Makefile demo/xsede.2014.0425/src/md/main.c demo/xsede.2014.0425/src/md/md.c demo/xsede.2014.0425/src/md/md.h Log: Tcl binding and test Modified: demo/xsede.2014.0425/src/md/Makefile =================================================================== --- demo/xsede.2014.0425/src/md/Makefile 2014-08-13 17:47:41 UTC (rev 8138) +++ demo/xsede.2014.0425/src/md/Makefile 2014-08-13 19:50:12 UTC (rev 8139) @@ -24,20 +24,30 @@ TCL_HOME = $(HOME)/sfw/tcl-8.6.0 INCLUDES += -I $(TCL_HOME)/include +TCLSH = $(TCL_HOME)/bin/tclsh8.6 -swift-pkg: libtclmd.so +swift-pkg: pkgIndex.tcl -md_wrap.c: md.i +md_wrap.c: md.i md.h swig $(<) + sed -i s/Md_Init/Tclmd_Init/ $(@) libtclmd.so: md_wrap.o $(OBJ) gcc -shared -o $(@) $(^) -L $(TCL_HOME)/lib -l tcl8.6 -endif +pkgIndex.tcl: libtclmd.so + LEAF_PKG=md LEAF_VERSION=0.0 \ + LEAF_SO=$(<) LEAF_TCL=md.tcl \ + $(TCLSH) ./make-package.tcl > $(@) +clean:: + rm -fv pkgIndex.tcl libtclmd.so md_wrap.c + +endif # Swift/T + .PHONY: clean -clean: - rm -f $(OBJ) $(bin) +clean:: + rm -fv $(OBJ) $(bin) .PHONY: install install: Modified: demo/xsede.2014.0425/src/md/main.c =================================================================== --- demo/xsede.2014.0425/src/md/main.c 2014-08-13 17:47:41 UTC (rev 8138) +++ demo/xsede.2014.0425/src/md/main.c 2014-08-13 19:50:12 UTC (rev 8139) @@ -71,16 +71,12 @@ double ctime1; double ctime2; double dt = 0.0001; - double e0; - double *force; int i; int id; - double kinetic; double mass = 1.0 * .0001; int nd; int np; - double potential; int seed = 123456789; int step; int step_num; @@ -193,7 +189,7 @@ ctime1 = cpu_time ( ); simulate (step_num, step_print_num, step_print, step_print_index, - np, nd, mass, potential, kinetic, e0, + np, nd, mass, dt, seed, outfile, trjfile); ctime2 = cpu_time ( ); Added: demo/xsede.2014.0425/src/md/make-package.tcl =================================================================== --- demo/xsede.2014.0425/src/md/make-package.tcl (rev 0) +++ demo/xsede.2014.0425/src/md/make-package.tcl 2014-08-13 19:50:12 UTC (rev 8139) @@ -0,0 +1,9 @@ + +set name $env(LEAF_PKG) +set version $env(LEAF_VERSION) +set leaf_so $env(LEAF_SO) +set leaf_tcl $env(LEAF_TCL) + +puts [ ::pkg::create -name $name -version $version \ + -load $leaf_so -source $leaf_tcl ] + Property changes on: demo/xsede.2014.0425/src/md/make-package.tcl ___________________________________________________________________ Added: svn:executable + * Modified: demo/xsede.2014.0425/src/md/md.c =================================================================== --- demo/xsede.2014.0425/src/md/md.c 2014-08-13 17:47:41 UTC (rev 8138) +++ demo/xsede.2014.0425/src/md/md.c 2014-08-13 19:50:12 UTC (rev 8139) @@ -15,7 +15,7 @@ double r8_uniform_01 ( int *seed ); void update ( int np, int nd, double pos[], double vel[], double f[], double acc[], double mass, double dt ); -void snap ( int np, int nd, double t, double pos[], double vel[], double f[], +void snap ( int np, int nd, int t, double pos[], double vel[], double f[], double acc[], double mass, double dt ); static void trj_file_open(char *trjfile); @@ -25,7 +25,6 @@ int step_print, int step_print_index, int np, int nd, double mass, - double potential, double kinetic, double e0, double dt, int seed, char* outfile, @@ -62,9 +61,9 @@ printf ( "\n" ); printf ( " Computing initial forces and energies.\n" ); + double potential, kinetic; compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); - - e0 = potential + kinetic; + double e0 = potential + kinetic; /* This is the main time stepping loop: Compute forces and energies, @@ -104,7 +103,7 @@ ( potential + kinetic - e0 ) / e0 ); step_print_index = step_print_index + 1; step_print = ( step_print_index * step_num ) / step_print_num; - snap (np, nd, step*dt, pos, vel, force, acc, mass, dt ); + snap (np, nd, step, pos, vel, force, acc, mass, dt ); } update ( np, nd, pos, vel, force, acc, mass, dt ); } @@ -599,7 +598,7 @@ trj_file = NULL; } -void snap ( int np, int nd, double t, double pos[], double vel[], double f[], +void snap ( int np, int nd, int t, double pos[], double vel[], double f[], double acc[], double mass, double dt ) { int j; Modified: demo/xsede.2014.0425/src/md/md.h =================================================================== --- demo/xsede.2014.0425/src/md/md.h 2014-08-13 17:47:41 UTC (rev 8138) +++ demo/xsede.2014.0425/src/md/md.h 2014-08-13 19:50:12 UTC (rev 8139) @@ -25,7 +25,6 @@ int step_print, int step_print_index, int np, int nd, double mass, - double potential, double kinetic, double e0, double dt, int seed, char* outfile, Added: demo/xsede.2014.0425/src/md/md.i =================================================================== --- demo/xsede.2014.0425/src/md/md.i (rev 0) +++ demo/xsede.2014.0425/src/md/md.i 2014-08-13 19:50:12 UTC (rev 8139) @@ -0,0 +1,6 @@ + +%module md +%include "md.h" +%{ + #include "md.h" +%} Added: demo/xsede.2014.0425/src/md/md.tcl =================================================================== --- demo/xsede.2014.0425/src/md/md.tcl (rev 0) +++ demo/xsede.2014.0425/src/md/md.tcl 2014-08-13 19:50:12 UTC (rev 8139) @@ -0,0 +1,4 @@ + +namespace eval md { + # Nothing +} Added: demo/xsede.2014.0425/src/md/test-md.tcl =================================================================== --- demo/xsede.2014.0425/src/md/test-md.tcl (rev 0) +++ demo/xsede.2014.0425/src/md/test-md.tcl 2014-08-13 19:50:12 UTC (rev 8139) @@ -0,0 +1,7 @@ +#!/usr/bin/env tclsh8.6 + +lappend auto_path $env(PWD) +package require md 0.0 + +simulate 4 2 0 0 10 2 1 0.1 9 out.txt + Property changes on: demo/xsede.2014.0425/src/md/test-md.tcl ___________________________________________________________________ Added: svn:executable + * From wozniak at ci.uchicago.edu Wed Aug 13 14:51:08 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 14:51:08 -0500 (CDT) Subject: [Swift-commit] r8140 - demo/xsede.2014.0425 Message-ID: <20140813195108.14F7E9D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 14:51:07 -0500 (Wed, 13 Aug 2014) New Revision: 8140 Added: demo/xsede.2014.0425/part07/ Log: Adding part07 From wozniak at ci.uchicago.edu Wed Aug 13 15:01:48 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 15:01:48 -0500 (CDT) Subject: [Swift-commit] r8141 - demo/xsede.2014.0425/part07 Message-ID: <20140813200148.3369A9D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 15:01:48 -0500 (Wed, 13 Aug 2014) New Revision: 8141 Added: demo/xsede.2014.0425/part07/md.swift demo/xsede.2014.0425/part07/run-md.sh Log: Initial working Swift/T call Added: demo/xsede.2014.0425/part07/md.swift =================================================================== --- demo/xsede.2014.0425/part07/md.swift (rev 0) +++ demo/xsede.2014.0425/part07/md.swift 2014-08-13 20:01:48 UTC (rev 8141) @@ -0,0 +1,13 @@ + + at dispatch=WORKER +(file outfile, file trjfile) +simulate(int step_num, int step_print_num, + int step_print, int step_print_index, + int np, int nd, + float mass, + float dt, + int seed) +"md" "0.0" +[ +"simulate <> <> <> <> <> <> <> <
> <> [ lindex <> 0 ] [ lindex<> 0 ]" +]; Added: demo/xsede.2014.0425/part07/run-md.sh =================================================================== --- demo/xsede.2014.0425/part07/run-md.sh (rev 0) +++ demo/xsede.2014.0425/part07/run-md.sh 2014-08-13 20:01:48 UTC (rev 8141) @@ -0,0 +1,10 @@ +#!/bin/sh -eu + +stc run-md.swift + +MD_PKG=$( cd ${PWD}/../src/md ; /bin/pwd ) +export TURBINE_USER_LIB=${MD_PKG} +export TURBINE_LOG=0 ADLB_DEBUG=0 +turbine run-md.tcl + + Property changes on: demo/xsede.2014.0425/part07/run-md.sh ___________________________________________________________________ Added: svn:executable + * From wilde at ci.uchicago.edu Wed Aug 13 15:04:06 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Wed, 13 Aug 2014 15:04:06 -0500 (CDT) Subject: [Swift-commit] r8142 - in demo/xsede.2014.0425: app part04m Message-ID: <20140813200406.1DDBC9D92B@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-13 15:04:05 -0500 (Wed, 13 Aug 2014) New Revision: 8142 Added: demo/xsede.2014.0425/app/genmovie demo/xsede.2014.0425/app/gettrj.sh demo/xsede.2014.0425/app/renderframe Modified: demo/xsede.2014.0425/app/mdmaxk demo/xsede.2014.0425/app/mdtotk demo/xsede.2014.0425/part04m/p4b.swift Log: First end-to-end movie-making workflow (p4b.swift) for mdlite. Added: demo/xsede.2014.0425/app/genmovie =================================================================== --- demo/xsede.2014.0425/app/genmovie (rev 0) +++ demo/xsede.2014.0425/app/genmovie 2014-08-13 20:04:05 UTC (rev 8142) @@ -0,0 +1,6 @@ +#! /bin/sh + +movie=$1 +shift + +convert -delay 20 $* $movie Added: demo/xsede.2014.0425/app/gettrj.sh =================================================================== --- demo/xsede.2014.0425/app/gettrj.sh (rev 0) +++ demo/xsede.2014.0425/app/gettrj.sh 2014-08-13 20:04:05 UTC (rev 8142) @@ -0,0 +1,3 @@ +# awk "\$1 == ${1:-1} { print \$0 }" + +awk "\$1 == ${1:-1} { for (i=2; ic-ray-trailer +# walls +s 0 -1000 2 99 0.2 0.2 0.2 0.0 0.0 + +# lights +l -50 100 -50 + +# camera +# position FOV target +c 0 6 -17 45 0 -1 0 +END + +( + awk "\$1 == $frame {for (i=2; it.ppm + +convert t.ppm $vzout + + + Property changes on: demo/xsede.2014.0425/app/renderframe ___________________________________________________________________ Added: svn:executable + * Modified: demo/xsede.2014.0425/part04m/p4b.swift =================================================================== --- demo/xsede.2014.0425/part04m/p4b.swift 2014-08-13 20:01:48 UTC (rev 8141) +++ demo/xsede.2014.0425/part04m/p4b.swift 2014-08-13 20:04:05 UTC (rev 8142) @@ -1,5 +1,10 @@ type file; +type kineticInfo { + int sim; + float energy; +} + (int result) randomInt () { float range = 9999999.0; @@ -8,10 +13,10 @@ result = toInt(s[0]); } -app (file out, file traj) simulation (string npart, string steps, string mass) +app (file out, file traj) simulation (int npart, int steps, int trsnaps, float mass) { # mdviz @out @traj 3 npart steps 50 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt(); - md 3 npart steps 10 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt() @out @traj; + md 3 npart steps trsnaps ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt() @out @traj; } app (file o) analyze (file s[]) @@ -19,38 +24,55 @@ mdstats filenames(s) stdout=filename(o); } -app (file o) maxk (file s[]) +app (file o) kinetic (file s[]) { - mdmaxk filenames(s) stdout=filename(o); + mdmaxk 9999 filenames(s) stdout=filename(o); } -app (file o) analyze (file s[]) +app (file o) render (file traj, int frame) { - mdstats filenames(s) stdout=filename(o); + renderframe filename(traj) filename(o) frame; } app (file o) convert (file s[]) { - convert filenames(s) filename(o); + convert "-delay" 20 filenames(s) filename(o); } -int nsim = toInt(arg("nsim","10")); -string npart = arg("npart","50"); -string steps = arg("steps","1000"); -string mass = arg("mass",".005"); +int nsim = toInt(arg("nsim","10")); +int npart = toInt(arg("npart","50")); +int steps = toInt(arg("steps","1000")); +int trsnaps = 10; +float mass = toFloat(arg("mass",".005")); file sim[] ; -file trj[] ; +file trj[] ; foreach i in [0:nsim-1] { - (sim[i],trj[i]) = simulation(npart,steps,mass); + (sim[i],trj[i]) = simulation(npart,steps,trsnaps,mass); } file stats_out<"output/average.out">; stats_out = analyze(sim); file ke_out<"output/kinetic.out">; -ke_out = maxk(sim); +ke_out = kinetic(sim); -#file viz_all<"output/all.gif">; -#viz_all = convert(gifs); +kineticInfo kd[] = readData(ke_out); + +tracef("min eK simulation: %i eK: %f\n", kd[0].sim, kd[0].energy); +tracef("max eK simulation: %i eK: %f\n", kd[nsim-1].sim, kd[nsim-1].energy); + +file mink[] ; +file maxk[] ; + +foreach i in [0:trsnaps-1] { + mink[i] = render(trj[kd[0].sim], i); + maxk[i] = render(trj[kd[nsim-1].sim], i); +} + +file minkmovie <"output/mink.gif">; +file maxkmovie <"output/maxk.gif">; + +minkmovie = convert(mink); +maxkmovie = convert(maxk); From wozniak at ci.uchicago.edu Wed Aug 13 15:07:47 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 15:07:47 -0500 (CDT) Subject: [Swift-commit] r8143 - demo/xsede.2014.0425/part07 Message-ID: <20140813200747.32D519D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 15:07:47 -0500 (Wed, 13 Aug 2014) New Revision: 8143 Added: demo/xsede.2014.0425/part07/run-md.swift Log: Adding run-md.swift Added: demo/xsede.2014.0425/part07/run-md.swift =================================================================== --- demo/xsede.2014.0425/part07/run-md.swift (rev 0) +++ demo/xsede.2014.0425/part07/run-md.swift 2014-08-13 20:07:47 UTC (rev 8143) @@ -0,0 +1,9 @@ + +import md; + +main +{ + file out_txt<"out.txt">; + file out_trj<"out.trj">; + (out_txt, out_trj) = simulate(10, 10, 3, 0, 10, 2, 1, 0.1, 42); +} From wozniak at ci.uchicago.edu Wed Aug 13 15:09:36 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 15:09:36 -0500 (CDT) Subject: [Swift-commit] r8144 - demo/xsede.2014.0425/part07 Message-ID: <20140813200936.4B3D09D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 15:09:36 -0500 (Wed, 13 Aug 2014) New Revision: 8144 Added: demo/xsede.2014.0425/part07/run-mds.swift Log: Will run multiple sims Copied: demo/xsede.2014.0425/part07/run-mds.swift (from rev 8143, demo/xsede.2014.0425/part07/run-md.swift) =================================================================== --- demo/xsede.2014.0425/part07/run-mds.swift (rev 0) +++ demo/xsede.2014.0425/part07/run-mds.swift 2014-08-13 20:09:36 UTC (rev 8144) @@ -0,0 +1,9 @@ + +import md; + +main +{ + file out_txt<"out.txt">; + file out_trj<"out.trj">; + (out_txt, out_trj) = simulate(10, 10, 3, 0, 10, 2, 1, 0.1, 42); +} From wozniak at ci.uchicago.edu Wed Aug 13 15:17:32 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 15:17:32 -0500 (CDT) Subject: [Swift-commit] r8145 - demo/xsede.2014.0425/part07 Message-ID: <20140813201732.470369D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 15:17:32 -0500 (Wed, 13 Aug 2014) New Revision: 8145 Modified: demo/xsede.2014.0425/part07/md.swift Log: Bug fix Modified: demo/xsede.2014.0425/part07/md.swift =================================================================== --- demo/xsede.2014.0425/part07/md.swift 2014-08-13 20:09:36 UTC (rev 8144) +++ demo/xsede.2014.0425/part07/md.swift 2014-08-13 20:17:32 UTC (rev 8145) @@ -9,5 +9,5 @@ int seed) "md" "0.0" [ -"simulate <> <> <> <> <> <> <> <
> <> [ lindex <> 0 ] [ lindex<> 0 ]" +"simulate <> <> <> <> <> <> <> <
> <> [ lindex $<> 0 ] [ lindex $<> 0 ]" ]; From wozniak at ci.uchicago.edu Wed Aug 13 15:17:50 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 15:17:50 -0500 (CDT) Subject: [Swift-commit] r8146 - demo/xsede.2014.0425/part07 Message-ID: <20140813201750.1DB8A9D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 15:17:50 -0500 (Wed, 13 Aug 2014) New Revision: 8146 Added: demo/xsede.2014.0425/part07/run-mds.sh Modified: demo/xsede.2014.0425/part07/run-mds.swift Log: Run multiple concurrent simulations Copied: demo/xsede.2014.0425/part07/run-mds.sh (from rev 8141, demo/xsede.2014.0425/part07/run-md.sh) =================================================================== --- demo/xsede.2014.0425/part07/run-mds.sh (rev 0) +++ demo/xsede.2014.0425/part07/run-mds.sh 2014-08-13 20:17:50 UTC (rev 8146) @@ -0,0 +1,8 @@ +#!/bin/sh -eu + +stc run-mds.swift + +MD_PKG=$( cd ${PWD}/../src/md ; /bin/pwd ) +export TURBINE_USER_LIB=${MD_PKG} +export TURBINE_LOG=0 ADLB_DEBUG=0 +turbine -n 2 run-mds.tcl --simulations=4 --steps=10 Modified: demo/xsede.2014.0425/part07/run-mds.swift =================================================================== --- demo/xsede.2014.0425/part07/run-mds.swift 2014-08-13 20:17:32 UTC (rev 8145) +++ demo/xsede.2014.0425/part07/run-mds.swift 2014-08-13 20:17:50 UTC (rev 8146) @@ -1,9 +1,17 @@ +import string; +import sys; + import md; main { - file out_txt<"out.txt">; - file out_trj<"out.trj">; - (out_txt, out_trj) = simulate(10, 10, 3, 0, 10, 2, 1, 0.1, 42); + int simulations = toint(argv("simulations")); + int steps = toint(argv("steps")); + foreach i in [0:simulations-1] + { + file out_txt; + file out_trj; + (out_txt, out_trj) = simulate(steps, 10, 3, 0, 10, 2, 1, 0.1, 42); + } } From wozniak at ci.uchicago.edu Wed Aug 13 16:19:54 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 16:19:54 -0500 (CDT) Subject: [Swift-commit] r8147 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813211954.1FB0B9D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 16:19:54 -0500 (Wed, 13 Aug 2014) New Revision: 8147 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h Log: Copy back from xsede demo Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile 2014-08-13 20:17:50 UTC (rev 8146) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile 2014-08-13 21:19:54 UTC (rev 8147) @@ -24,20 +24,30 @@ TCL_HOME = $(HOME)/sfw/tcl-8.6.0 INCLUDES += -I $(TCL_HOME)/include +TCLSH = $(TCL_HOME)/bin/tclsh8.6 -swift-pkg: libtclmd.so +swift-pkg: pkgIndex.tcl -md_wrap.c: md.i +md_wrap.c: md.i md.h swig $(<) + sed -i s/Md_Init/Tclmd_Init/ $(@) libtclmd.so: md_wrap.o $(OBJ) gcc -shared -o $(@) $(^) -L $(TCL_HOME)/lib -l tcl8.6 -endif +pkgIndex.tcl: libtclmd.so + LEAF_PKG=md LEAF_VERSION=0.0 \ + LEAF_SO=$(<) LEAF_TCL=md.tcl \ + $(TCLSH) ./make-package.tcl > $(@) +clean:: + rm -fv pkgIndex.tcl libtclmd.so md_wrap.c + +endif # Swift/T + .PHONY: clean -clean: - rm -f $(OBJ) $(bin) +clean:: + rm -fv $(OBJ) $(bin) .PHONY: install install: Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh 2014-08-13 21:19:54 UTC (rev 8147) @@ -0,0 +1,2 @@ +#! /bin/sh +rm -f md??.trj md.dat Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh ___________________________________________________________________ Added: svn:executable + * Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c 2014-08-13 20:17:50 UTC (rev 8146) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c 2014-08-13 21:19:54 UTC (rev 8147) @@ -12,7 +12,7 @@ char *outfile = "md.dat"; -char *trjfile = "md.trj.tgz"; +char *trjfile = "md.trj"; /******************************************************************************/ @@ -71,16 +71,12 @@ double ctime1; double ctime2; double dt = 0.0001; - double e0; - double *force; int i; int id; - double kinetic; double mass = 1.0 * .0001; int nd; int np; - double potential; int seed = 123456789; int step; int step_num; @@ -193,8 +189,8 @@ ctime1 = cpu_time ( ); simulate (step_num, step_print_num, step_print, step_print_index, - np, nd, mass, potential, kinetic, e0, - dt, seed, outfile); + np, nd, mass, + dt, seed, outfile, trjfile); ctime2 = cpu_time ( ); ctime = ctime2 - ctime1; @@ -203,10 +199,12 @@ printf ( " Elapsed cpu time for main computation:\n" ); printf ( " %f seconds.\n", ctime ); - +#ifdef NOTDEF char tarcmd[2000]; sprintf(tarcmd,"tar zcf %s md??.trj",trjfile); system(tarcmd); +#endif + /* Terminate. */ Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl 2014-08-13 21:19:54 UTC (rev 8147) @@ -0,0 +1,9 @@ + +set name $env(LEAF_PKG) +set version $env(LEAF_VERSION) +set leaf_so $env(LEAF_SO) +set leaf_tcl $env(LEAF_TCL) + +puts [ ::pkg::create -name $name -version $version \ + -load $leaf_so -source $leaf_tcl ] + Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl ___________________________________________________________________ Added: svn:executable + * Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 20:17:50 UTC (rev 8146) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 21:19:54 UTC (rev 8147) @@ -18,17 +18,17 @@ void snap ( int np, int nd, int t, double pos[], double vel[], double f[], double acc[], double mass, double dt ); -static void snap_file_open(void); -static void snap_file_close(void); +static void trj_file_open(char *trjfile); +static void trj_file_close(void); void simulate (int step_num, int step_print_num, int step_print, int step_print_index, int np, int nd, double mass, - double potential, double kinetic, double e0, double dt, int seed, - char* outfile) + char* outfile, + char* trjfile) { /* Allocate memory. @@ -49,7 +49,7 @@ printf ( "\n" ); printf ( " Initializing positions, velocities, and accelerations.\n" ); - snap_file_open(); + trj_file_open(trjfile); /* Set initial positions, velocities, and accelerations. @@ -61,9 +61,9 @@ printf ( "\n" ); printf ( " Computing initial forces and energies.\n" ); + double potential, kinetic; compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); - - e0 = potential + kinetic; + double e0 = potential + kinetic; /* This is the main time stepping loop: Compute forces and energies, @@ -115,7 +115,7 @@ free ( vel ); fclose(ofile); - snap_file_close(); + trj_file_close(); } /******************************************************************************/ @@ -580,20 +580,22 @@ } static int snapid = 0; -static FILE *snap_file = NULL; +static FILE *trj_file = NULL; -static void snap_file_open() +static void trj_file_open(char *trjfile) { +#ifdef NOTDEF char snapfile[100]; sprintf(snapfile, "md%02d.trj", snapid); - snap_file = fopen(snapfile, "w"); - assert(snap_file != NULL); +#endif + trj_file = fopen(trjfile, "w"); + assert(trj_file != NULL); } -static void snap_file_close() +static void trj_file_close() { - fclose(snap_file); - snap_file = NULL; + fclose(trj_file); + trj_file = NULL; } void snap ( int np, int nd, int t, double pos[], double vel[], double f[], @@ -603,8 +605,8 @@ for ( j = 0; j < np; j++ ) { - fprintf(snap_file, "%i s %f %f %f %s\n", - t, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); + fprintf(trj_file, "%d s %f %f %f %s\n", + snapid, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); } snapid++; Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h 2014-08-13 20:17:50 UTC (rev 8146) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h 2014-08-13 21:19:54 UTC (rev 8147) @@ -25,9 +25,9 @@ int step_print, int step_print_index, int np, int nd, double mass, - double potential, double kinetic, double e0, double dt, int seed, - char* outfile); + char* outfile, + char* trjfile); #endif Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i 2014-08-13 21:19:54 UTC (rev 8147) @@ -0,0 +1,6 @@ + +%module md +%include "md.h" +%{ + #include "md.h" +%} Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl 2014-08-13 21:19:54 UTC (rev 8147) @@ -0,0 +1,4 @@ + +namespace eval md { + # Nothing +} Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl 2014-08-13 21:19:54 UTC (rev 8147) @@ -0,0 +1,21 @@ +#!/usr/bin/env tclsh8.6 + +lappend auto_path $env(PWD) +package require md 0.0 + +set cmds [ info commands ] + +set L [list] + +foreach cmd $cmds { + puts $cmd + if { [ regexp .*.* $cmd ] || \ + [ regexp .*.* $cmd ] } { + lappend L $cmd + } +} + +set L [ lsort $L ] +foreach cmd $L { + puts $cmd +} Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl 2014-08-13 21:19:54 UTC (rev 8147) @@ -0,0 +1,8 @@ +#!/usr/bin/env tclsh8.6 + +lappend auto_path $env(PWD) +package require md 0.0 + +simulate 4 2 0 0 10 2 1 0.1 9 out.txt out.trj + + Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh 2014-08-13 21:19:54 UTC (rev 8147) @@ -0,0 +1,3 @@ +#! /bin/sh + +./md 3 50 1000 Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh ___________________________________________________________________ Added: svn:executable + * From wozniak at ci.uchicago.edu Wed Aug 13 16:20:13 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 16:20:13 -0500 (CDT) Subject: [Swift-commit] r8148 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813212013.0F3BA9D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 16:20:12 -0500 (Wed, 13 Aug 2014) New Revision: 8148 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-1.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-2.sh Removed: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh Log: Renames Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-1.sh (from rev 8147, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-1.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-1.sh 2014-08-13 21:20:12 UTC (rev 8148) @@ -0,0 +1,3 @@ +#! /bin/sh + +./md 3 50 1000 Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-2.sh (from rev 8136, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-2.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-2.sh 2014-08-13 21:20:12 UTC (rev 8148) @@ -0,0 +1,10 @@ +#!/bin/sh -eu + +NPART=4 +STEPS=10 +MASS=1 +SEED=42 +OUT=output.txt +TRJ=output.trj + +./md 3 ${NPART} ${STEPS} 10 ".0001" ${MASS} "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 ${SEED} ${OUT} ${TRJ} Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.sh 2014-08-13 21:19:54 UTC (rev 8147) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.sh 2014-08-13 21:20:12 UTC (rev 8148) @@ -1,10 +0,0 @@ -#!/bin/sh -eu - -NPART=4 -STEPS=10 -MASS=1 -SEED=42 -OUT=output.txt -TRJ=output.trj - -./md 3 ${NPART} ${STEPS} 10 ".0001" ${MASS} "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 ${SEED} ${OUT} ${TRJ} Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh 2014-08-13 21:19:54 UTC (rev 8147) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test.sh 2014-08-13 21:20:12 UTC (rev 8148) @@ -1,3 +0,0 @@ -#! /bin/sh - -./md 3 50 1000 From wozniak at ci.uchicago.edu Wed Aug 13 16:28:08 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 16:28:08 -0500 (CDT) Subject: [Swift-commit] r8149 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples Message-ID: <20140813212808.190AF9D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 16:28:07 -0500 (Wed, 13 Aug 2014) New Revision: 8149 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/ Log: Adding md-src From wozniak at ci.uchicago.edu Wed Aug 13 16:29:51 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 16:29:51 -0500 (CDT) Subject: [Swift-commit] r8150 - in SwiftTutorials/ATPESC_2014-08-14/swift-t/examples: 05-md md-src Message-ID: <20140813212951.D546E9D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 16:29:51 -0500 (Wed, 13 Aug 2014) New Revision: 8150 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/Makefile SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/clean.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/main.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/make-package.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.i SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/scan.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md-1.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md-2.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md.tcl Removed: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-1.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-2.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl Log: Populate md-src Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile 2014-08-13 21:28:07 UTC (rev 8149) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile 2014-08-13 21:29:51 UTC (rev 8150) @@ -1,59 +0,0 @@ -bin = md - -CC = gcc -INCLUDES := -OPTZ = -O0 -OPTS = -O3 -ffast-math -CFLAGS = $(OPTZ) -g -fPIC -std=gnu99 $(INCLUDES) - -SRC = main.c md.c -OBJ = $(patsubst %.c,%.o,$(SRC)) - - - -all: $(bin) - -# Link stand-alone executable: -$(bin): $(OBJ) - $(CC) -o $(@) $(OBJ) -lm - -# Swift/T integration: - -USE_SWIFT = 1 -ifeq ($(USE_SWIFT),1) - -TCL_HOME = $(HOME)/sfw/tcl-8.6.0 -INCLUDES += -I $(TCL_HOME)/include -TCLSH = $(TCL_HOME)/bin/tclsh8.6 - -swift-pkg: pkgIndex.tcl - -md_wrap.c: md.i md.h - swig $(<) - sed -i s/Md_Init/Tclmd_Init/ $(@) - -libtclmd.so: md_wrap.o $(OBJ) - gcc -shared -o $(@) $(^) -L $(TCL_HOME)/lib -l tcl8.6 - -pkgIndex.tcl: libtclmd.so - LEAF_PKG=md LEAF_VERSION=0.0 \ - LEAF_SO=$(<) LEAF_TCL=md.tcl \ - $(TCLSH) ./make-package.tcl > $(@) - -clean:: - rm -fv pkgIndex.tcl libtclmd.so md_wrap.c - -endif # Swift/T - -.PHONY: clean -clean:: - rm -fv $(OBJ) $(bin) - -.PHONY: install -install: - cp $(bin) ../../bin/$(bin) - -.PHONY: uninstall -uninstall: - rm -f ../../bin/$(bin) - Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh 2014-08-13 21:28:07 UTC (rev 8149) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh 2014-08-13 21:29:51 UTC (rev 8150) @@ -1,2 +0,0 @@ -#! /bin/sh -rm -f md??.trj md.dat Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c 2014-08-13 21:28:07 UTC (rev 8149) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c 2014-08-13 21:29:51 UTC (rev 8150) @@ -1,219 +0,0 @@ - -/* - * main.c - * - * Created on: Aug 13, 2014 - * Author: wozniak - */ - -#include -#include -#include "md.h" - - -char *outfile = "md.dat"; -char *trjfile = "md.trj"; - - -/******************************************************************************/ - -int main ( int argc, char *argv[] ) - -/******************************************************************************/ -/* - Purpose: - - MAIN is the main program for MD. - - Discussion: - - MD implements a simple molecular dynamics simulation. - - The velocity Verlet time integration scheme is used. - - The particles interact with a central pair potential. - - Usage: - - md nd np step_num print_step_num dt mass printinfo scale_factor scale_offset seed outFile trajectoryFile - where - * nd is the spatial dimension (2 or 3); - * np is the number of particles (500, for instance); - * step_num is the number of time steps (500, for instance); - * print_step_num is the number of snapshot prints (10 for instance); - * dt is size of timestep; - * mass is particle mass; - * printinfo is a string to append to each particle coord - * scale_offset and scale_factor are used to scale particle positions for logging/rendering (FIXME) - * seed sets the initial configuration - - - Licensing: - - This code is distributed under the GNU LGPL license. - - Modified: - - 05 November 2010 - - Author: - - Original FORTRAN90 version by Bill Magro. - C version by John Burkardt. - - Parameters: - - None -*/ -{ - - double ctime; - double ctime1; - double ctime2; - double dt = 0.0001; - int i; - int id; - double mass = 1.0 * .0001; - int nd; - int np; - - int seed = 123456789; - int step; - int step_num; - int step_print; - int step_print_index = 0; - int step_print_num = 10; - double *vel; - - timestamp ( ); - printf ( "\n" ); - printf ( "MD\n" ); - printf ( " C version\n" ); - printf ( " A molecular dynamics program.\n" ); -/* - Get the spatial dimension. -*/ - if ( 1 < argc ) - { - nd = atoi ( argv[1] ); - } - else - { - printf ( "\n" ); - printf ( " Enter ND, the spatial dimension (2 or 3).\n" ); - scanf ( "%d", &nd ); - } -// -// Get the number of points. -// - if ( 2 < argc ) - { - np = atoi ( argv[2] ); - } - else - { - printf ( "\n" ); - printf ( " Enter NP, the number of points (500, for instance).\n" ); - scanf ( "%d", &np ); - } -// -// Get the number of time steps. -// - if ( 3 < argc ) - { - step_num = atoi ( argv[3] ); - } - else - { - printf ( "\n" ); - printf ( " Enter ND, the number of time steps (500 or 1000, for instance).\n" ); - scanf ( "%d", &step_num ); - } - /* - Get any additional args (command-line only) - md nd np step_num [ step__print_num dt mass printinfo scale_factor scale_offset randomseed outfile trjfile ] - */ - if ( 4 < argc ) - { - step_print_num = atoi ( argv[4] ); - } - if ( 5 < argc ) - { - dt = atof ( argv[5] ); - } - if ( 6 < argc ) - { - mass = atof ( argv[6] ); - } - if ( 7 < argc ) - { - printinfo = ( argv[7] ); - } - if ( 8 < argc ) - { - scale_factor = atof ( argv[8] ); - } - if ( 9 < argc ) - { - scale_offset = atof ( argv[9] ); - } - if ( 10 < argc ) - { - seed = atof ( argv[10] ); - } - if ( 11 < argc ) - { - outfile = argv[11]; - } - if ( 12 < argc ) - { - trjfile = argv[12]; - } - -/* - Report. -*/ - printf ( "\n" ); - printf ( " MD: Argument count: %d\n", argc ); - printf ( " ND, the spatial dimension, is %d\n", nd ); - printf ( " NP, the number of particles in the simulation, is %d\n", np ); - printf ( " STEP_NUM, the number of time steps, is %d\n", step_num ); - printf ( " STEP_PRINT_NUM, the number of snapshots to print, is %d\n", step_print_num ); - printf ( " DT, the size of each time step, is %f\n", dt ); - printf ( " MASS, the particle mass, is %f\n", mass ); - printf ( " PRINTINFO, the pass-through info to c-ray, is %s\n", printinfo ); - printf ( " SCALE_FACTOR, the particle position scaling factor, is %f\n", scale_factor ); - printf ( " SCALE_OFFSET, the particle position scaling offset, is %f\n", scale_offset ); - printf ( " SEED, the simulation randomization seed, is %d\n", seed ); - - ctime1 = cpu_time ( ); - - simulate (step_num, step_print_num, step_print, step_print_index, - np, nd, mass, - dt, seed, outfile, trjfile); - - ctime2 = cpu_time ( ); - ctime = ctime2 - ctime1; - - printf ( "\n" ); - printf ( " Elapsed cpu time for main computation:\n" ); - printf ( " %f seconds.\n", ctime ); - -#ifdef NOTDEF - char tarcmd[2000]; - sprintf(tarcmd,"tar zcf %s md??.trj",trjfile); - system(tarcmd); -#endif - -/* - Terminate. -*/ - printf ( "\n" ); - printf ( "MD\n" ); - printf ( " Normal end of execution.\n" ); - - printf ( "\n" ); - timestamp ( ); - - return 0; -} Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl 2014-08-13 21:28:07 UTC (rev 8149) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl 2014-08-13 21:29:51 UTC (rev 8150) @@ -1,9 +0,0 @@ - -set name $env(LEAF_PKG) -set version $env(LEAF_VERSION) -set leaf_so $env(LEAF_SO) -set leaf_tcl $env(LEAF_TCL) - -puts [ ::pkg::create -name $name -version $version \ - -load $leaf_so -source $leaf_tcl ] - Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 21:28:07 UTC (rev 8149) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c 2014-08-13 21:29:51 UTC (rev 8150) @@ -1,613 +0,0 @@ -# include -# include -# include -# include -# include - -#include "md.h" - -double scale_factor = 2.5, scale_offset = -2.0; -char *printinfo = "0.05 1.0 0.2 0.05 50.0 0.1"; - - -double dist ( int nd, double r1[], double r2[], double dr[] ); - -double r8_uniform_01 ( int *seed ); -void update ( int np, int nd, double pos[], double vel[], double f[], - double acc[], double mass, double dt ); -void snap ( int np, int nd, int t, double pos[], double vel[], double f[], - double acc[], double mass, double dt ); - -static void trj_file_open(char *trjfile); -static void trj_file_close(void); - -void simulate (int step_num, int step_print_num, - int step_print, int step_print_index, - int np, int nd, - double mass, - double dt, - int seed, - char* outfile, - char* trjfile) -{ - /* - Allocate memory. - */ - double* acc = ( double * ) malloc ( nd * np * sizeof ( double ) ); - double* box = ( double * ) malloc ( nd * sizeof ( double ) ); - double* force = ( double * ) malloc ( nd * np * sizeof ( double ) ); - double* pos = ( double * ) malloc ( nd * np * sizeof ( double ) ); - double* vel = ( double * ) malloc ( nd * np * sizeof ( double ) ); - /* - Set the dimensions of the box. - */ - for (int i = 0; i < nd; i++ ) - { - box[i] = 10.0; - } - - printf ( "\n" ); - printf ( " Initializing positions, velocities, and accelerations.\n" ); - - trj_file_open(trjfile); - - /* - Set initial positions, velocities, and accelerations. - */ - initialize ( np, nd, box, &seed, pos, vel, acc ); - /* - Compute the forces and energies. - */ - printf ( "\n" ); - printf ( " Computing initial forces and energies.\n" ); - - double potential, kinetic; - compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); - double e0 = potential + kinetic; - /* - This is the main time stepping loop: - Compute forces and energies, - Update positions, velocities, accelerations. - */ - printf ( "\n" ); - printf ( " At each step, we report the potential and kinetic energies.\n" ); - printf ( " The sum of these energies should be a constant.\n" ); - printf ( " As an accuracy check, we also print the relative error\n" ); - printf ( " in the total energy.\n" ); - printf ( "\n" ); - printf ( " Step Potential Kinetic (P+K-E0)/E0\n" ); - printf ( " Energy P Energy K Relative Energy Error\n" ); - printf ( "\n" ); - - FILE *ofile = fopen(outfile,"w"); - fprintf (ofile, " Step Potential Kinetic RelativeErr\n" ); - - int step = 0; - printf ( " %8d %14f %14f %14e\n", - step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); - fprintf ( ofile, " %8d %14f %14f %14e\n", - step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); - step_print_index = step_print_index + 1; - step_print = ( step_print_index * step_num ) / step_print_num; - - - for (step = 1; step <= step_num; step++ ) - { - compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); - - if ( step == step_print ) - { - printf ( " %8d %14f %14f %14e\n", step, potential, kinetic, - ( potential + kinetic - e0 ) / e0 ); - fprintf ( ofile, " %8d %14f %14f %14e\n", step, potential, kinetic, - ( potential + kinetic - e0 ) / e0 ); - step_print_index = step_print_index + 1; - step_print = ( step_print_index * step_num ) / step_print_num; - snap (np, nd, step, pos, vel, force, acc, mass, dt ); - } - update ( np, nd, pos, vel, force, acc, mass, dt ); - } - - free ( acc ); - free ( box ); - free ( force ); - free ( pos ); - free ( vel ); - - fclose(ofile); - trj_file_close(); -} - -/******************************************************************************/ - -void compute ( int np, int nd, double pos[], double vel[], - double mass, double f[], double *pot, double *kin ) - -/******************************************************************************/ -/* - Purpose: - - COMPUTE computes the forces and energies. - - Discussion: - - The computation of forces and energies is fully parallel. - - The potential function V(X) is a harmonic well which smoothly - saturates to a maximum value at PI/2: - - v(x) = ( sin ( min ( x, PI2 ) ) )^2 - - The derivative of the potential is: - - dv(x) = 2.0 * sin ( min ( x, PI2 ) ) * cos ( min ( x, PI2 ) ) - = sin ( 2.0 * min ( x, PI2 ) ) - - Licensing: - - This code is distributed under the GNU LGPL license. - - Modified: - - 21 November 2007 - - Author: - - Original FORTRAN90 version by Bill Magro. - C version by John Burkardt. - - Parameters: - - Input, int NP, the number of particles. - - Input, int ND, the number of spatial dimensions. - - Input, double POS[ND*NP], the position of each particle. - - Input, double VEL[ND*NP], the velocity of each particle. - - Input, double MASS, the mass of each particle. - - Output, double F[ND*NP], the forces. - - Output, double *POT, the total potential energy. - - Output, double *KIN, the total kinetic energy. -*/ -{ - double d; - double d2; - int i; - int j; - int k; - double ke; - double pe; - double PI2 = 3.141592653589793 / 2.0; - double rij[3]; - - pe = 0.0; - ke = 0.0; - - for ( k = 0; k < np; k++ ) - { -/* - Compute the potential energy and forces. -*/ - for ( i = 0; i < nd; i++ ) - { - f[i+k*nd] = 0.0; - } - - for ( j = 0; j < np; j++ ) - { - if ( k != j ) - { - d = dist ( nd, pos+k*nd, pos+j*nd, rij ); -/* - Attribute half of the potential energy to particle J. -*/ - if ( d < PI2 ) - { - d2 = d; - } - else - { - d2 = PI2; - } - - pe = pe + 0.5 * pow ( sin ( d2 ), 2 ); - - for ( i = 0; i < nd; i++ ) - { - f[i+k*nd] = f[i+k*nd] - rij[i] * sin ( 2.0 * d2 ) / d; - } - } - } -/* - Compute the kinetic energy. -*/ - for ( i = 0; i < nd; i++ ) - { - ke = ke + vel[i+k*nd] * vel[i+k*nd]; - } - } - - ke = ke * 0.5 * mass; - - *pot = pe; - *kin = ke; - - return; -} -/*******************************************************************************/ - -double cpu_time ( void ) - -/*******************************************************************************/ -/* - Purpose: - - CPU_TIME reports the total CPU time for a program. - - Licensing: - - This code is distributed under the GNU LGPL license. - - Modified: - - 27 September 2005 - - Author: - - John Burkardt - - Parameters: - - Output, double CPU_TIME, the current total elapsed CPU time in second. -*/ -{ - double value; - - value = ( double ) clock ( ) / ( double ) CLOCKS_PER_SEC; - - return value; -} -/******************************************************************************/ - -double dist ( int nd, double r1[], double r2[], double dr[] ) - -/******************************************************************************/ -/* - Purpose: - - DIST computes the displacement (and its norm) between two particles. - - Licensing: - - This code is distributed under the GNU LGPL license. - - Modified: - - 21 November 2007 - - Author: - - Original FORTRAN90 version by Bill Magro. - C version by John Burkardt. - - Parameters: - - Input, int ND, the number of spatial dimensions. - - Input, double R1[ND], R2[ND], the positions of the particles. - - Output, double DR[ND], the displacement vector. - - Output, double D, the Euclidean norm of the displacement. -*/ -{ - double d; - int i; - - d = 0.0; - for ( i = 0; i < nd; i++ ) - { - dr[i] = r1[i] - r2[i]; - d = d + dr[i] * dr[i]; - } - d = sqrt ( d ); - - return d; -} -/******************************************************************************/ - -void initialize ( int np, int nd, double box[], int *seed, double pos[], - double vel[], double acc[] ) - -/******************************************************************************/ -/* - Purpose: - - INITIALIZE initializes the positions, velocities, and accelerations. - - Licensing: - - This code is distributed under the GNU LGPL license. - - Modified: - - 20 July 2008 - - Author: - - Original FORTRAN90 version by Bill Magro. - C version by John Burkardt. - - Parameters: - - Input, int NP, the number of particles. - - Input, int ND, the number of spatial dimensions. - - Input, double BOX[ND], specifies the maximum position - of particles in each dimension. - - Input, int *SEED, a seed for the random number generator. - - Output, double POS[ND*NP], the position of each particle. - - Output, double VEL[ND*NP], the velocity of each particle. - - Output, double ACC[ND*NP], the acceleration of each particle. -*/ -{ - int i; - int j; -/* - Give the particles random positions within the box. -*/ - for ( j = 0; j < np; j++ ) - { - for ( i = 0; i < nd; i++ ) - { - pos[i+j*nd] = box[i] * r8_uniform_01 ( seed ); - vel[i+j*nd] = 0.0; - acc[i+j*nd] = 0.0; - } - } - return; -} -/******************************************************************************/ - -double r8_uniform_01 ( int *seed ) - -/******************************************************************************/ -/* - Purpose: - - R8_UNIFORM_01 is a unit pseudorandom R8. - - Discussion: - - This routine implements the recursion - - seed = 16807 * seed mod ( 2^31 - 1 ) - unif = seed / ( 2^31 - 1 ) - - The integer arithmetic never requires more than 32 bits, - including a sign bit. - - Licensing: - - This code is distributed under the GNU LGPL license. - - Modified: - - 11 August 2004 - - Author: - - John Burkardt - - Reference: - - Paul Bratley, Bennett Fox, Linus Schrage, - A Guide to Simulation, - Springer Verlag, pages 201-202, 1983. - - Bennett Fox, - Algorithm 647: - Implementation and Relative Efficiency of Quasirandom - Sequence Generators, - ACM Transactions on Mathematical Software, - Volume 12, Number 4, pages 362-376, 1986. - - Parameters: - - Input/output, int *SEED, a seed for the random number generator. - - Output, double R8_UNIFORM_01, a new pseudorandom variate, strictly between - 0 and 1. -*/ -{ - int k; - double r; - - k = *seed / 127773; - - *seed = 16807 * ( *seed - k * 127773 ) - k * 2836; - - if ( *seed < 0 ) - { - *seed = *seed + 2147483647; - } - - r = ( double ) ( *seed ) * 4.656612875E-10; - - return r; -} -/******************************************************************************/ - -void timestamp ( void ) - -/******************************************************************************/ -/* - Purpose: - - TIMESTAMP prints the current YMDHMS date as a time stamp. - - Example: - - 31 May 2001 09:45:54 AM - - Licensing: - - This code is distributed under the GNU LGPL license. - - Modified: - - 24 September 2003 - - Author: - - John Burkardt - - Parameters: - - None -*/ -{ -# define TIME_SIZE 40 - - static char time_buffer[TIME_SIZE]; - const struct tm *tm; - size_t len; - time_t now; - - now = time ( NULL ); - tm = localtime ( &now ); - - len = strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); - - printf ( "%s\n", time_buffer ); - - return; -# undef TIME_SIZE -} -/******************************************************************************/ - -void update ( int np, int nd, double pos[], double vel[], double f[], - double acc[], double mass, double dt ) - -/******************************************************************************/ -/* - Purpose: - - UPDATE updates positions, velocities and accelerations. - - Discussion: - - The time integration is fully parallel. - - A velocity Verlet algorithm is used for the updating. - - x(t+dt) = x(t) + v(t) * dt + 0.5 * a(t) * dt * dt - v(t+dt) = v(t) + 0.5 * ( a(t) + a(t+dt) ) * dt - a(t+dt) = f(t) / m - - Licensing: - - This code is distributed under the GNU LGPL license. - - Modified: - - 21 November 2007 - - Author: - - Original FORTRAN90 version by Bill Magro. - C version by John Burkardt. - - Parameters: - - Input, int NP, the number of particles. - - Input, int ND, the number of spatial dimensions. - - Input/output, double POS[ND*NP], the position of each particle. - - Input/output, double VEL[ND*NP], the velocity of each particle. - - Input, double F[ND*NP], the force on each particle. - - Input/output, double ACC[ND*NP], the acceleration of each particle. - - Input, double MASS, the mass of each particle. - - Input, double DT, the time step. -*/ -{ - int i; - int j; - double rmass; - - rmass = 1.0 / mass; - - for ( j = 0; j < np; j++ ) - { - for ( i = 0; i < nd; i++ ) - { - pos[i+j*nd] = pos[i+j*nd] + vel[i+j*nd] * dt + 0.5 * acc[i+j*nd] * dt * dt; - vel[i+j*nd] = vel[i+j*nd] + 0.5 * dt * ( f[i+j*nd] * rmass + acc[i+j*nd] ); - acc[i+j*nd] = f[i+j*nd] * rmass; - } - /* -s -0.5 -0.3 -1 0.05 1.0 0.2 0.05 50.0 0.1 -s 0.5 -0.4 0 0.05 0.1 0.85 1.0 50.0 0.1 - */ - char *s = "0.05 1.0 0.2 0.05 50.0 0.1"; - /* printf("s %f %f %f %s\n", pos[0+j*nd]/20.0, pos[1+j*nd]/20.0, pos[2+j*nd]/20.0, s); */ - } - - return; -} - - -double scale (double x) -{ - return( (x / scale_factor) - scale_offset); - /* return( (x / 2.5) - 2.0); */ -} - -static int snapid = 0; -static FILE *trj_file = NULL; - -static void trj_file_open(char *trjfile) -{ -#ifdef NOTDEF - char snapfile[100]; - sprintf(snapfile, "md%02d.trj", snapid); -#endif - trj_file = fopen(trjfile, "w"); - assert(trj_file != NULL); -} - -static void trj_file_close() -{ - fclose(trj_file); - trj_file = NULL; -} - -void snap ( int np, int nd, int t, double pos[], double vel[], double f[], - double acc[], double mass, double dt ) -{ - int j; - - for ( j = 0; j < np; j++ ) - { - fprintf(trj_file, "%d s %f %f %f %s\n", - snapid, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); - } - - snapid++; -} Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h 2014-08-13 21:28:07 UTC (rev 8149) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h 2014-08-13 21:29:51 UTC (rev 8150) @@ -1,33 +0,0 @@ -/* - * md.h - * - * Created on: Aug 13, 2014 - * Author: wozniak - */ - -#ifndef MD_H -#define MD_H - -extern double scale_factor, scale_offset; -extern char *printinfo; - -double cpu_time ( void ); - -void timestamp ( void ); - -void initialize ( int np, int nd, double box[], int *seed, double pos[], - double vel[], double acc[] ); - -void compute ( int np, int nd, double pos[], double vel[], - double mass, double f[], double *pot, double *kin ); - -void simulate (int step_num, int step_print_num, - int step_print, int step_print_index, - int np, int nd, - double mass, - double dt, - int seed, - char* outfile, - char* trjfile); - -#endif Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i 2014-08-13 21:28:07 UTC (rev 8149) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i 2014-08-13 21:29:51 UTC (rev 8150) @@ -1,6 +0,0 @@ - -%module md -%include "md.h" -%{ - #include "md.h" -%} Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl 2014-08-13 21:28:07 UTC (rev 8149) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl 2014-08-13 21:29:51 UTC (rev 8150) @@ -1,4 +0,0 @@ - -namespace eval md { - # Nothing -} Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl 2014-08-13 21:28:07 UTC (rev 8149) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl 2014-08-13 21:29:51 UTC (rev 8150) @@ -1,21 +0,0 @@ -#!/usr/bin/env tclsh8.6 - -lappend auto_path $env(PWD) -package require md 0.0 - -set cmds [ info commands ] - -set L [list] - -foreach cmd $cmds { - puts $cmd - if { [ regexp .*.* $cmd ] || \ - [ regexp .*.* $cmd ] } { - lappend L $cmd - } -} - -set L [ lsort $L ] -foreach cmd $L { - puts $cmd -} Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-1.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-1.sh 2014-08-13 21:28:07 UTC (rev 8149) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-1.sh 2014-08-13 21:29:51 UTC (rev 8150) @@ -1,3 +0,0 @@ -#! /bin/sh - -./md 3 50 1000 Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-2.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-2.sh 2014-08-13 21:28:07 UTC (rev 8149) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-2.sh 2014-08-13 21:29:51 UTC (rev 8150) @@ -1,10 +0,0 @@ -#!/bin/sh -eu - -NPART=4 -STEPS=10 -MASS=1 -SEED=42 -OUT=output.txt -TRJ=output.trj - -./md 3 ${NPART} ${STEPS} 10 ".0001" ${MASS} "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 ${SEED} ${OUT} ${TRJ} Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl 2014-08-13 21:28:07 UTC (rev 8149) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl 2014-08-13 21:29:51 UTC (rev 8150) @@ -1,8 +0,0 @@ -#!/usr/bin/env tclsh8.6 - -lappend auto_path $env(PWD) -package require md 0.0 - -simulate 4 2 0 0 10 2 1 0.1 9 out.txt out.trj - - Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/Makefile (from rev 8147, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/Makefile) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/Makefile (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/Makefile 2014-08-13 21:29:51 UTC (rev 8150) @@ -0,0 +1,59 @@ +bin = md + +CC = gcc +INCLUDES := +OPTZ = -O0 +OPTS = -O3 -ffast-math +CFLAGS = $(OPTZ) -g -fPIC -std=gnu99 $(INCLUDES) + +SRC = main.c md.c +OBJ = $(patsubst %.c,%.o,$(SRC)) + + + +all: $(bin) + +# Link stand-alone executable: +$(bin): $(OBJ) + $(CC) -o $(@) $(OBJ) -lm + +# Swift/T integration: + +USE_SWIFT = 1 +ifeq ($(USE_SWIFT),1) + +TCL_HOME = $(HOME)/sfw/tcl-8.6.0 +INCLUDES += -I $(TCL_HOME)/include +TCLSH = $(TCL_HOME)/bin/tclsh8.6 + +swift-pkg: pkgIndex.tcl + +md_wrap.c: md.i md.h + swig $(<) + sed -i s/Md_Init/Tclmd_Init/ $(@) + +libtclmd.so: md_wrap.o $(OBJ) + gcc -shared -o $(@) $(^) -L $(TCL_HOME)/lib -l tcl8.6 + +pkgIndex.tcl: libtclmd.so + LEAF_PKG=md LEAF_VERSION=0.0 \ + LEAF_SO=$(<) LEAF_TCL=md.tcl \ + $(TCLSH) ./make-package.tcl > $(@) + +clean:: + rm -fv pkgIndex.tcl libtclmd.so md_wrap.* + +endif # Swift/T + +.PHONY: clean +clean:: + rm -fv $(OBJ) $(bin) + +.PHONY: install +install: + cp $(bin) ../../bin/$(bin) + +.PHONY: uninstall +uninstall: + rm -f ../../bin/$(bin) + Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/clean.sh (from rev 8147, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/clean.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/clean.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/clean.sh 2014-08-13 21:29:51 UTC (rev 8150) @@ -0,0 +1,2 @@ +#! /bin/sh +rm -f md??.trj md.dat Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/main.c (from rev 8147, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/main.c) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/main.c (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/main.c 2014-08-13 21:29:51 UTC (rev 8150) @@ -0,0 +1,219 @@ + +/* + * main.c + * + * Created on: Aug 13, 2014 + * Author: wozniak + */ + +#include +#include +#include "md.h" + + +char *outfile = "md.dat"; +char *trjfile = "md.trj"; + + +/******************************************************************************/ + +int main ( int argc, char *argv[] ) + +/******************************************************************************/ +/* + Purpose: + + MAIN is the main program for MD. + + Discussion: + + MD implements a simple molecular dynamics simulation. + + The velocity Verlet time integration scheme is used. + + The particles interact with a central pair potential. + + Usage: + + md nd np step_num print_step_num dt mass printinfo scale_factor scale_offset seed outFile trajectoryFile + where + * nd is the spatial dimension (2 or 3); + * np is the number of particles (500, for instance); + * step_num is the number of time steps (500, for instance); + * print_step_num is the number of snapshot prints (10 for instance); + * dt is size of timestep; + * mass is particle mass; + * printinfo is a string to append to each particle coord + * scale_offset and scale_factor are used to scale particle positions for logging/rendering (FIXME) + * seed sets the initial configuration + + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 05 November 2010 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + None +*/ +{ + + double ctime; + double ctime1; + double ctime2; + double dt = 0.0001; + int i; + int id; + double mass = 1.0 * .0001; + int nd; + int np; + + int seed = 123456789; + int step; + int step_num; + int step_print; + int step_print_index = 0; + int step_print_num = 10; + double *vel; + + timestamp ( ); + printf ( "\n" ); + printf ( "MD\n" ); + printf ( " C version\n" ); + printf ( " A molecular dynamics program.\n" ); +/* + Get the spatial dimension. +*/ + if ( 1 < argc ) + { + nd = atoi ( argv[1] ); + } + else + { + printf ( "\n" ); + printf ( " Enter ND, the spatial dimension (2 or 3).\n" ); + scanf ( "%d", &nd ); + } +// +// Get the number of points. +// + if ( 2 < argc ) + { + np = atoi ( argv[2] ); + } + else + { + printf ( "\n" ); + printf ( " Enter NP, the number of points (500, for instance).\n" ); + scanf ( "%d", &np ); + } +// +// Get the number of time steps. +// + if ( 3 < argc ) + { + step_num = atoi ( argv[3] ); + } + else + { + printf ( "\n" ); + printf ( " Enter ND, the number of time steps (500 or 1000, for instance).\n" ); + scanf ( "%d", &step_num ); + } + /* + Get any additional args (command-line only) + md nd np step_num [ step__print_num dt mass printinfo scale_factor scale_offset randomseed outfile trjfile ] + */ + if ( 4 < argc ) + { + step_print_num = atoi ( argv[4] ); + } + if ( 5 < argc ) + { + dt = atof ( argv[5] ); + } + if ( 6 < argc ) + { + mass = atof ( argv[6] ); + } + if ( 7 < argc ) + { + printinfo = ( argv[7] ); + } + if ( 8 < argc ) + { + scale_factor = atof ( argv[8] ); + } + if ( 9 < argc ) + { + scale_offset = atof ( argv[9] ); + } + if ( 10 < argc ) + { + seed = atof ( argv[10] ); + } + if ( 11 < argc ) + { + outfile = argv[11]; + } + if ( 12 < argc ) + { + trjfile = argv[12]; + } + +/* + Report. +*/ + printf ( "\n" ); + printf ( " MD: Argument count: %d\n", argc ); + printf ( " ND, the spatial dimension, is %d\n", nd ); + printf ( " NP, the number of particles in the simulation, is %d\n", np ); + printf ( " STEP_NUM, the number of time steps, is %d\n", step_num ); + printf ( " STEP_PRINT_NUM, the number of snapshots to print, is %d\n", step_print_num ); + printf ( " DT, the size of each time step, is %f\n", dt ); + printf ( " MASS, the particle mass, is %f\n", mass ); + printf ( " PRINTINFO, the pass-through info to c-ray, is %s\n", printinfo ); + printf ( " SCALE_FACTOR, the particle position scaling factor, is %f\n", scale_factor ); + printf ( " SCALE_OFFSET, the particle position scaling offset, is %f\n", scale_offset ); + printf ( " SEED, the simulation randomization seed, is %d\n", seed ); + + ctime1 = cpu_time ( ); + + simulate (step_num, step_print_num, step_print, step_print_index, + np, nd, mass, + dt, seed, outfile, trjfile); + + ctime2 = cpu_time ( ); + ctime = ctime2 - ctime1; + + printf ( "\n" ); + printf ( " Elapsed cpu time for main computation:\n" ); + printf ( " %f seconds.\n", ctime ); + +#ifdef NOTDEF + char tarcmd[2000]; + sprintf(tarcmd,"tar zcf %s md??.trj",trjfile); + system(tarcmd); +#endif + +/* + Terminate. +*/ + printf ( "\n" ); + printf ( "MD\n" ); + printf ( " Normal end of execution.\n" ); + + printf ( "\n" ); + timestamp ( ); + + return 0; +} Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/make-package.tcl (from rev 8147, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/make-package.tcl) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/make-package.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/make-package.tcl 2014-08-13 21:29:51 UTC (rev 8150) @@ -0,0 +1,9 @@ + +set name $env(LEAF_PKG) +set version $env(LEAF_VERSION) +set leaf_so $env(LEAF_SO) +set leaf_tcl $env(LEAF_TCL) + +puts [ ::pkg::create -name $name -version $version \ + -load $leaf_so -source $leaf_tcl ] + Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c (from rev 8147, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.c) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c 2014-08-13 21:29:51 UTC (rev 8150) @@ -0,0 +1,613 @@ +# include +# include +# include +# include +# include + +#include "md.h" + +double scale_factor = 2.5, scale_offset = -2.0; +char *printinfo = "0.05 1.0 0.2 0.05 50.0 0.1"; + + +double dist ( int nd, double r1[], double r2[], double dr[] ); + +double r8_uniform_01 ( int *seed ); +void update ( int np, int nd, double pos[], double vel[], double f[], + double acc[], double mass, double dt ); +void snap ( int np, int nd, int t, double pos[], double vel[], double f[], + double acc[], double mass, double dt ); + +static void trj_file_open(char *trjfile); +static void trj_file_close(void); + +void simulate (int step_num, int step_print_num, + int step_print, int step_print_index, + int np, int nd, + double mass, + double dt, + int seed, + char* outfile, + char* trjfile) +{ + /* + Allocate memory. + */ + double* acc = ( double * ) malloc ( nd * np * sizeof ( double ) ); + double* box = ( double * ) malloc ( nd * sizeof ( double ) ); + double* force = ( double * ) malloc ( nd * np * sizeof ( double ) ); + double* pos = ( double * ) malloc ( nd * np * sizeof ( double ) ); + double* vel = ( double * ) malloc ( nd * np * sizeof ( double ) ); + /* + Set the dimensions of the box. + */ + for (int i = 0; i < nd; i++ ) + { + box[i] = 10.0; + } + + printf ( "\n" ); + printf ( " Initializing positions, velocities, and accelerations.\n" ); + + trj_file_open(trjfile); + + /* + Set initial positions, velocities, and accelerations. + */ + initialize ( np, nd, box, &seed, pos, vel, acc ); + /* + Compute the forces and energies. + */ + printf ( "\n" ); + printf ( " Computing initial forces and energies.\n" ); + + double potential, kinetic; + compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); + double e0 = potential + kinetic; + /* + This is the main time stepping loop: + Compute forces and energies, + Update positions, velocities, accelerations. + */ + printf ( "\n" ); + printf ( " At each step, we report the potential and kinetic energies.\n" ); + printf ( " The sum of these energies should be a constant.\n" ); + printf ( " As an accuracy check, we also print the relative error\n" ); + printf ( " in the total energy.\n" ); + printf ( "\n" ); + printf ( " Step Potential Kinetic (P+K-E0)/E0\n" ); + printf ( " Energy P Energy K Relative Energy Error\n" ); + printf ( "\n" ); + + FILE *ofile = fopen(outfile,"w"); + fprintf (ofile, " Step Potential Kinetic RelativeErr\n" ); + + int step = 0; + printf ( " %8d %14f %14f %14e\n", + step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); + fprintf ( ofile, " %8d %14f %14f %14e\n", + step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); + step_print_index = step_print_index + 1; + step_print = ( step_print_index * step_num ) / step_print_num; + + + for (step = 1; step <= step_num; step++ ) + { + compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); + + if ( step == step_print ) + { + printf ( " %8d %14f %14f %14e\n", step, potential, kinetic, + ( potential + kinetic - e0 ) / e0 ); + fprintf ( ofile, " %8d %14f %14f %14e\n", step, potential, kinetic, + ( potential + kinetic - e0 ) / e0 ); + step_print_index = step_print_index + 1; + step_print = ( step_print_index * step_num ) / step_print_num; + snap (np, nd, step, pos, vel, force, acc, mass, dt ); + } + update ( np, nd, pos, vel, force, acc, mass, dt ); + } + + free ( acc ); + free ( box ); + free ( force ); + free ( pos ); + free ( vel ); + + fclose(ofile); + trj_file_close(); +} + +/******************************************************************************/ + +void compute ( int np, int nd, double pos[], double vel[], + double mass, double f[], double *pot, double *kin ) + +/******************************************************************************/ +/* + Purpose: + + COMPUTE computes the forces and energies. + + Discussion: + + The computation of forces and energies is fully parallel. + + The potential function V(X) is a harmonic well which smoothly + saturates to a maximum value at PI/2: + + v(x) = ( sin ( min ( x, PI2 ) ) )^2 + + The derivative of the potential is: + + dv(x) = 2.0 * sin ( min ( x, PI2 ) ) * cos ( min ( x, PI2 ) ) + = sin ( 2.0 * min ( x, PI2 ) ) + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 21 November 2007 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + Input, int NP, the number of particles. + + Input, int ND, the number of spatial dimensions. + + Input, double POS[ND*NP], the position of each particle. + + Input, double VEL[ND*NP], the velocity of each particle. + + Input, double MASS, the mass of each particle. + + Output, double F[ND*NP], the forces. + + Output, double *POT, the total potential energy. + + Output, double *KIN, the total kinetic energy. +*/ +{ + double d; + double d2; + int i; + int j; + int k; + double ke; + double pe; + double PI2 = 3.141592653589793 / 2.0; + double rij[3]; + + pe = 0.0; + ke = 0.0; + + for ( k = 0; k < np; k++ ) + { +/* + Compute the potential energy and forces. +*/ + for ( i = 0; i < nd; i++ ) + { + f[i+k*nd] = 0.0; + } + + for ( j = 0; j < np; j++ ) + { + if ( k != j ) + { + d = dist ( nd, pos+k*nd, pos+j*nd, rij ); +/* + Attribute half of the potential energy to particle J. +*/ + if ( d < PI2 ) + { + d2 = d; + } + else + { + d2 = PI2; + } + + pe = pe + 0.5 * pow ( sin ( d2 ), 2 ); + + for ( i = 0; i < nd; i++ ) + { + f[i+k*nd] = f[i+k*nd] - rij[i] * sin ( 2.0 * d2 ) / d; + } + } + } +/* + Compute the kinetic energy. +*/ + for ( i = 0; i < nd; i++ ) + { + ke = ke + vel[i+k*nd] * vel[i+k*nd]; + } + } + + ke = ke * 0.5 * mass; + + *pot = pe; + *kin = ke; + + return; +} +/*******************************************************************************/ + +double cpu_time ( void ) + +/*******************************************************************************/ +/* + Purpose: + + CPU_TIME reports the total CPU time for a program. + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 27 September 2005 + + Author: + + John Burkardt + + Parameters: + + Output, double CPU_TIME, the current total elapsed CPU time in second. +*/ +{ + double value; + + value = ( double ) clock ( ) / ( double ) CLOCKS_PER_SEC; + + return value; +} +/******************************************************************************/ + +double dist ( int nd, double r1[], double r2[], double dr[] ) + +/******************************************************************************/ +/* + Purpose: + + DIST computes the displacement (and its norm) between two particles. + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 21 November 2007 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + Input, int ND, the number of spatial dimensions. + + Input, double R1[ND], R2[ND], the positions of the particles. + + Output, double DR[ND], the displacement vector. + + Output, double D, the Euclidean norm of the displacement. +*/ +{ + double d; + int i; + + d = 0.0; + for ( i = 0; i < nd; i++ ) + { + dr[i] = r1[i] - r2[i]; + d = d + dr[i] * dr[i]; + } + d = sqrt ( d ); + + return d; +} +/******************************************************************************/ + +void initialize ( int np, int nd, double box[], int *seed, double pos[], + double vel[], double acc[] ) + +/******************************************************************************/ +/* + Purpose: + + INITIALIZE initializes the positions, velocities, and accelerations. + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 20 July 2008 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + Input, int NP, the number of particles. + + Input, int ND, the number of spatial dimensions. + + Input, double BOX[ND], specifies the maximum position + of particles in each dimension. + + Input, int *SEED, a seed for the random number generator. + + Output, double POS[ND*NP], the position of each particle. + + Output, double VEL[ND*NP], the velocity of each particle. + + Output, double ACC[ND*NP], the acceleration of each particle. +*/ +{ + int i; + int j; +/* + Give the particles random positions within the box. +*/ + for ( j = 0; j < np; j++ ) + { + for ( i = 0; i < nd; i++ ) + { + pos[i+j*nd] = box[i] * r8_uniform_01 ( seed ); + vel[i+j*nd] = 0.0; + acc[i+j*nd] = 0.0; + } + } + return; +} +/******************************************************************************/ + +double r8_uniform_01 ( int *seed ) + +/******************************************************************************/ +/* + Purpose: + + R8_UNIFORM_01 is a unit pseudorandom R8. + + Discussion: + + This routine implements the recursion + + seed = 16807 * seed mod ( 2^31 - 1 ) + unif = seed / ( 2^31 - 1 ) + + The integer arithmetic never requires more than 32 bits, + including a sign bit. + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 11 August 2004 + + Author: + + John Burkardt + + Reference: + + Paul Bratley, Bennett Fox, Linus Schrage, + A Guide to Simulation, + Springer Verlag, pages 201-202, 1983. + + Bennett Fox, + Algorithm 647: + Implementation and Relative Efficiency of Quasirandom + Sequence Generators, + ACM Transactions on Mathematical Software, + Volume 12, Number 4, pages 362-376, 1986. + + Parameters: + + Input/output, int *SEED, a seed for the random number generator. + + Output, double R8_UNIFORM_01, a new pseudorandom variate, strictly between + 0 and 1. +*/ +{ + int k; + double r; + + k = *seed / 127773; + + *seed = 16807 * ( *seed - k * 127773 ) - k * 2836; + + if ( *seed < 0 ) + { + *seed = *seed + 2147483647; + } + + r = ( double ) ( *seed ) * 4.656612875E-10; + + return r; +} +/******************************************************************************/ + +void timestamp ( void ) + +/******************************************************************************/ +/* + Purpose: + + TIMESTAMP prints the current YMDHMS date as a time stamp. + + Example: + + 31 May 2001 09:45:54 AM + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 24 September 2003 + + Author: + + John Burkardt + + Parameters: + + None +*/ +{ +# define TIME_SIZE 40 + + static char time_buffer[TIME_SIZE]; + const struct tm *tm; + size_t len; + time_t now; + + now = time ( NULL ); + tm = localtime ( &now ); + + len = strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); + + printf ( "%s\n", time_buffer ); + + return; +# undef TIME_SIZE +} +/******************************************************************************/ + +void update ( int np, int nd, double pos[], double vel[], double f[], + double acc[], double mass, double dt ) + +/******************************************************************************/ +/* + Purpose: + + UPDATE updates positions, velocities and accelerations. + + Discussion: + + The time integration is fully parallel. + + A velocity Verlet algorithm is used for the updating. + + x(t+dt) = x(t) + v(t) * dt + 0.5 * a(t) * dt * dt + v(t+dt) = v(t) + 0.5 * ( a(t) + a(t+dt) ) * dt + a(t+dt) = f(t) / m + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 21 November 2007 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + Input, int NP, the number of particles. + + Input, int ND, the number of spatial dimensions. + + Input/output, double POS[ND*NP], the position of each particle. + + Input/output, double VEL[ND*NP], the velocity of each particle. + + Input, double F[ND*NP], the force on each particle. + + Input/output, double ACC[ND*NP], the acceleration of each particle. + + Input, double MASS, the mass of each particle. + + Input, double DT, the time step. +*/ +{ + int i; + int j; + double rmass; + + rmass = 1.0 / mass; + + for ( j = 0; j < np; j++ ) + { + for ( i = 0; i < nd; i++ ) + { + pos[i+j*nd] = pos[i+j*nd] + vel[i+j*nd] * dt + 0.5 * acc[i+j*nd] * dt * dt; + vel[i+j*nd] = vel[i+j*nd] + 0.5 * dt * ( f[i+j*nd] * rmass + acc[i+j*nd] ); + acc[i+j*nd] = f[i+j*nd] * rmass; + } + /* +s -0.5 -0.3 -1 0.05 1.0 0.2 0.05 50.0 0.1 +s 0.5 -0.4 0 0.05 0.1 0.85 1.0 50.0 0.1 + */ + char *s = "0.05 1.0 0.2 0.05 50.0 0.1"; + /* printf("s %f %f %f %s\n", pos[0+j*nd]/20.0, pos[1+j*nd]/20.0, pos[2+j*nd]/20.0, s); */ + } + + return; +} + + +double scale (double x) +{ + return( (x / scale_factor) - scale_offset); + /* return( (x / 2.5) - 2.0); */ +} + +static int snapid = 0; +static FILE *trj_file = NULL; + +static void trj_file_open(char *trjfile) +{ +#ifdef NOTDEF + char snapfile[100]; + sprintf(snapfile, "md%02d.trj", snapid); +#endif + trj_file = fopen(trjfile, "w"); + assert(trj_file != NULL); +} + +static void trj_file_close() +{ + fclose(trj_file); + trj_file = NULL; +} + +void snap ( int np, int nd, int t, double pos[], double vel[], double f[], + double acc[], double mass, double dt ) +{ + int j; + + for ( j = 0; j < np; j++ ) + { + fprintf(trj_file, "%d s %f %f %f %s\n", + snapid, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); + } + + snapid++; +} Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h (from rev 8147, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.h) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h 2014-08-13 21:29:51 UTC (rev 8150) @@ -0,0 +1,33 @@ +/* + * md.h + * + * Created on: Aug 13, 2014 + * Author: wozniak + */ + +#ifndef MD_H +#define MD_H + +extern double scale_factor, scale_offset; +extern char *printinfo; + +double cpu_time ( void ); + +void timestamp ( void ); + +void initialize ( int np, int nd, double box[], int *seed, double pos[], + double vel[], double acc[] ); + +void compute ( int np, int nd, double pos[], double vel[], + double mass, double f[], double *pot, double *kin ); + +void simulate (int step_num, int step_print_num, + int step_print, int step_print_index, + int np, int nd, + double mass, + double dt, + int seed, + char* outfile, + char* trjfile); + +#endif Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.i (from rev 8147, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.i) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.i (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.i 2014-08-13 21:29:51 UTC (rev 8150) @@ -0,0 +1,6 @@ + +%module md +%include "md.h" +%{ + #include "md.h" +%} Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.tcl (from rev 8147, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.tcl) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.tcl 2014-08-13 21:29:51 UTC (rev 8150) @@ -0,0 +1,4 @@ + +namespace eval md { + # Nothing +} Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/scan.tcl (from rev 8147, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/scan.tcl) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/scan.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/scan.tcl 2014-08-13 21:29:51 UTC (rev 8150) @@ -0,0 +1,21 @@ +#!/usr/bin/env tclsh8.6 + +lappend auto_path $env(PWD) +package require md 0.0 + +set cmds [ info commands ] + +set L [list] + +foreach cmd $cmds { + puts $cmd + if { [ regexp .*.* $cmd ] || \ + [ regexp .*.* $cmd ] } { + lappend L $cmd + } +} + +set L [ lsort $L ] +foreach cmd $L { + puts $cmd +} Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md-1.sh (from rev 8148, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-1.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md-1.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md-1.sh 2014-08-13 21:29:51 UTC (rev 8150) @@ -0,0 +1,3 @@ +#! /bin/sh + +./md 3 50 1000 Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md-2.sh (from rev 8148, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md-2.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md-2.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md-2.sh 2014-08-13 21:29:51 UTC (rev 8150) @@ -0,0 +1,10 @@ +#!/bin/sh -eu + +NPART=4 +STEPS=10 +MASS=1 +SEED=42 +OUT=output.txt +TRJ=output.trj + +./md 3 ${NPART} ${STEPS} 10 ".0001" ${MASS} "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 ${SEED} ${OUT} ${TRJ} Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md.tcl (from rev 8147, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/test-md.tcl) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md.tcl 2014-08-13 21:29:51 UTC (rev 8150) @@ -0,0 +1,8 @@ +#!/usr/bin/env tclsh8.6 + +lappend auto_path $env(PWD) +package require md 0.0 + +simulate 4 2 0 0 10 2 1 0.1 9 out.txt out.trj + + From wozniak at ci.uchicago.edu Wed Aug 13 16:31:24 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 16:31:24 -0500 (CDT) Subject: [Swift-commit] r8151 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813213124.1A6349D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 16:31:24 -0500 (Wed, 13 Aug 2014) New Revision: 8151 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.swift SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.swift Log: MD Swift stuff Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.swift 2014-08-13 21:31:24 UTC (rev 8151) @@ -0,0 +1,13 @@ + + at dispatch=WORKER +(file outfile, file trjfile) +simulate(int step_num, int step_print_num, + int step_print, int step_print_index, + int np, int nd, + float mass, + float dt, + int seed) +"md" "0.0" +[ +"simulate <> <> <> <> <> <> <> <
> <> [ lindex $<> 0 ] [ lindex $<> 0 ]" +]; Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh 2014-08-13 21:31:24 UTC (rev 8151) @@ -0,0 +1,10 @@ +#!/bin/sh -eu + +stc run-md.swift + +MD_PKG=$( cd ${PWD}/../src/md ; /bin/pwd ) +export TURBINE_USER_LIB=${MD_PKG} +export TURBINE_LOG=0 ADLB_DEBUG=0 +turbine run-md.tcl + + Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift 2014-08-13 21:31:24 UTC (rev 8151) @@ -0,0 +1,9 @@ + +import md; + +main +{ + file out_txt<"out.txt">; + file out_trj<"out.trj">; + (out_txt, out_trj) = simulate(10, 10, 3, 0, 10, 2, 1, 0.1, 42); +} Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh 2014-08-13 21:31:24 UTC (rev 8151) @@ -0,0 +1,8 @@ +#!/bin/sh -eu + +stc run-mds.swift + +MD_PKG=$( cd ${PWD}/../src/md ; /bin/pwd ) +export TURBINE_USER_LIB=${MD_PKG} +export TURBINE_LOG=0 ADLB_DEBUG=0 +turbine -n 2 run-mds.tcl --simulations=4 --steps=10 Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.swift 2014-08-13 21:31:24 UTC (rev 8151) @@ -0,0 +1,17 @@ + +import string; +import sys; + +import md; + +main +{ + int simulations = toint(argv("simulations")); + int steps = toint(argv("steps")); + foreach i in [0:simulations-1] + { + file out_txt; + file out_trj; + (out_txt, out_trj) = simulate(steps, 10, 3, 0, 10, 2, 1, 0.1, 42); + } +} From wozniak at ci.uchicago.edu Wed Aug 13 16:33:03 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 16:33:03 -0500 (CDT) Subject: [Swift-commit] r8152 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813213303.69F489D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 16:33:03 -0500 (Wed, 13 Aug 2014) New Revision: 8152 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/setup-md.sh Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh Log: Fix settings for new src tree Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh 2014-08-13 21:31:24 UTC (rev 8151) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh 2014-08-13 21:33:03 UTC (rev 8152) @@ -1,10 +1,9 @@ -#!/bin/sh -eu +#!/bin/bash -eu stc run-md.swift -MD_PKG=$( cd ${PWD}/../src/md ; /bin/pwd ) -export TURBINE_USER_LIB=${MD_PKG} -export TURBINE_LOG=0 ADLB_DEBUG=0 +source setup-md.sh + turbine run-md.tcl Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh 2014-08-13 21:31:24 UTC (rev 8151) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh 2014-08-13 21:33:03 UTC (rev 8152) @@ -1,8 +1,7 @@ -#!/bin/sh -eu +#!/bin/bash -eu stc run-mds.swift -MD_PKG=$( cd ${PWD}/../src/md ; /bin/pwd ) -export TURBINE_USER_LIB=${MD_PKG} -export TURBINE_LOG=0 ADLB_DEBUG=0 +source setup-md.sh + turbine -n 2 run-mds.tcl --simulations=4 --steps=10 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/setup-md.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/setup-md.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/setup-md.sh 2014-08-13 21:33:03 UTC (rev 8152) @@ -0,0 +1,4 @@ + +MD_PKG=$( cd ${PWD}/../md-src ; /bin/pwd ) +export TURBINE_USER_LIB=${MD_PKG} +export TURBINE_LOG=0 ADLB_DEBUG=0 From yadunandb at ci.uchicago.edu Wed Aug 13 16:47:24 2014 From: yadunandb at ci.uchicago.edu (yadunandb at ci.uchicago.edu) Date: Wed, 13 Aug 2014 16:47:24 -0500 (CDT) Subject: [Swift-commit] r8153 - demo/xsede.2014.0425/app Message-ID: <20140813214724.160199D92B@svn.ci.uchicago.edu> Author: yadunandb Date: 2014-08-13 16:47:23 -0500 (Wed, 13 Aug 2014) New Revision: 8153 Modified: demo/xsede.2014.0425/app/renderframe Log: find c-ray in CWD instead of PATH Modified: demo/xsede.2014.0425/app/renderframe =================================================================== --- demo/xsede.2014.0425/app/renderframe 2014-08-13 21:33:03 UTC (rev 8152) +++ demo/xsede.2014.0425/app/renderframe 2014-08-13 21:47:23 UTC (rev 8153) @@ -4,6 +4,8 @@ vzout=$2 frame=$3 +APPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + cat <c-ray-trailer # walls s 0 -1000 2 99 0.2 0.2 0.2 0.0 0.0 @@ -20,7 +22,7 @@ awk "\$1 == $frame {for (i=2; it.ppm +) | $APPDIR/c-ray >t.ppm convert t.ppm $vzout From wozniak at ci.uchicago.edu Wed Aug 13 16:55:28 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 16:55:28 -0500 (CDT) Subject: [Swift-commit] r8154 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813215528.5E6D59D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 16:55:28 -0500 (Wed, 13 Aug 2014) New Revision: 8154 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-md.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh Removed: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh Log: Make local run scripts Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-md.sh (from rev 8153, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-md.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-md.sh 2014-08-13 21:55:28 UTC (rev 8154) @@ -0,0 +1,8 @@ +#!/bin/bash -eu + +source ../../cfg/setup-local.sh +source setup-md.sh + +PROGRAM=run-md +stc ${PROGRAM}.swift +turbine ${PROGRAM}.tcl Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh (from rev 8153, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-13 21:55:28 UTC (rev 8154) @@ -0,0 +1,8 @@ +#!/bin/bash -eu + +source ../../cfg/setup-local.sh +source setup-md.sh + +PROGRAM=run-mds +stc ${PROGRAM}.swift +turbine ${PROGRAM}.tcl Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh 2014-08-13 21:47:23 UTC (rev 8153) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.sh 2014-08-13 21:55:28 UTC (rev 8154) @@ -1,9 +0,0 @@ -#!/bin/bash -eu - -stc run-md.swift - -source setup-md.sh - -turbine run-md.tcl - - Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh 2014-08-13 21:47:23 UTC (rev 8153) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.sh 2014-08-13 21:55:28 UTC (rev 8154) @@ -1,7 +0,0 @@ -#!/bin/bash -eu - -stc run-mds.swift - -source setup-md.sh - -turbine -n 2 run-mds.tcl --simulations=4 --steps=10 From wozniak at ci.uchicago.edu Wed Aug 13 16:57:14 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 16:57:14 -0500 (CDT) Subject: [Swift-commit] r8155 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src Message-ID: <20140813215714.CABBD9D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 16:57:14 -0500 (Wed, 13 Aug 2014) New Revision: 8155 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/Makefile Log: Fix path for Cetus Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/Makefile =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/Makefile 2014-08-13 21:55:28 UTC (rev 8154) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/Makefile 2014-08-13 21:57:14 UTC (rev 8155) @@ -9,8 +9,6 @@ SRC = main.c md.c OBJ = $(patsubst %.c,%.o,$(SRC)) - - all: $(bin) # Link stand-alone executable: @@ -22,9 +20,13 @@ USE_SWIFT = 1 ifeq ($(USE_SWIFT),1) -TCL_HOME = $(HOME)/sfw/tcl-8.6.0 +# TCL_HOME = $(HOME)/sfw/tcl-8.6.0 +# TCL_VERSION = 8.6 +TCL_HOME = /home/wozniak/Public/sfw/ppc64/bgxlc/dynamic/tcl-8.5.12 +TCL_VERSION = 8.5 +TCLSH = $(TCL_HOME)/bin/tclsh$(TCL_VERSION) + INCLUDES += -I $(TCL_HOME)/include -TCLSH = $(TCL_HOME)/bin/tclsh8.6 swift-pkg: pkgIndex.tcl @@ -33,7 +35,7 @@ sed -i s/Md_Init/Tclmd_Init/ $(@) libtclmd.so: md_wrap.o $(OBJ) - gcc -shared -o $(@) $(^) -L $(TCL_HOME)/lib -l tcl8.6 + gcc -shared -o $(@) $(^) -L $(TCL_HOME)/lib -l tcl$(TCL_VERSION) pkgIndex.tcl: libtclmd.so LEAF_PKG=md LEAF_VERSION=0.0 \ From wozniak at ci.uchicago.edu Wed Aug 13 16:58:51 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 16:58:51 -0500 (CDT) Subject: [Swift-commit] r8156 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813215851.3BF3E9D92B@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 16:58:51 -0500 (Wed, 13 Aug 2014) New Revision: 8156 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh Log: Add args Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-13 21:57:14 UTC (rev 8155) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-13 21:58:51 UTC (rev 8156) @@ -5,4 +5,4 @@ PROGRAM=run-mds stc ${PROGRAM}.swift -turbine ${PROGRAM}.tcl +turbine -n 2 ${PROGRAM}.tcl --simulations=4 --steps=10 From wozniak at ci.uchicago.edu Wed Aug 13 17:13:39 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 17:13:39 -0500 (CDT) Subject: [Swift-commit] r8157 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813221339.67E3A9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 17:13:39 -0500 (Wed, 13 Aug 2014) New Revision: 8157 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.swift Log: Support more arguments Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-13 21:58:51 UTC (rev 8156) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-13 22:13:39 UTC (rev 8157) @@ -1,8 +1,29 @@ #!/bin/bash -eu +if [[ ${#*} != 7 ]] +then + echo "usage: SIMULATIONS STEPS NP ND MASS DT SEED" + exit 1 +fi + +SIMULATIONS=$1 +STEPS=$2 +NP=$3 +ND=$4 +MASS=$5 +DT=$6 +SEED=$7 + source ../../cfg/setup-local.sh source setup-md.sh PROGRAM=run-mds stc ${PROGRAM}.swift -turbine -n 2 ${PROGRAM}.tcl --simulations=4 --steps=10 +turbine -n 2 ${PROGRAM}.tcl \ + --simulations=${SIMULATIONS} \ + --steps=${STEPS} \ + --np=${NP} \ + --nd=${ND} \ + --mass=${MASS} \ + --dt=${DT} \ + --seed=${SEED} Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.swift 2014-08-13 21:58:51 UTC (rev 8156) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.swift 2014-08-13 22:13:39 UTC (rev 8157) @@ -8,10 +8,16 @@ { int simulations = toint(argv("simulations")); int steps = toint(argv("steps")); + int np = toint(argv("np")); + int nd = toint(argv("nd")); + float mass = tofloat(argv("mass")); + float dt = tofloat(argv("dt")); + int seed = toint(argv("seed")); foreach i in [0:simulations-1] { file out_txt; file out_trj; - (out_txt, out_trj) = simulate(steps, 10, 3, 0, 10, 2, 1, 0.1, 42); + (out_txt, out_trj) = + simulate(steps, 10, 0, 0, np, nd, mass, dt, seed); } } From wozniak at ci.uchicago.edu Wed Aug 13 17:21:26 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 13 Aug 2014 17:21:26 -0500 (CDT) Subject: [Swift-commit] r8158 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140813222126.7D8839D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-13 17:21:26 -0500 (Wed, 13 Aug 2014) New Revision: 8158 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh Log: Create tar output Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-13 22:13:39 UTC (rev 8157) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-13 22:21:26 UTC (rev 8158) @@ -1,18 +1,19 @@ -#!/bin/bash -eu +#!/bin/zsh -eu -if [[ ${#*} != 7 ]] +A=( SIMULATIONS STEPS NP ND MASS DT SEED OUTPUT_TAR ) + +if [[ ${#*} != ${#A} ]] then - echo "usage: SIMULATIONS STEPS NP ND MASS DT SEED" + echo "usage: ${A}" exit 1 fi -SIMULATIONS=$1 -STEPS=$2 -NP=$3 -ND=$4 -MASS=$5 -DT=$6 -SEED=$7 +# Scan argv +for a in ${A} +do + eval ${a}=$1 + shift +done source ../../cfg/setup-local.sh source setup-md.sh @@ -27,3 +28,5 @@ --mass=${MASS} \ --dt=${DT} \ --seed=${SEED} + +tar cfz ${OUTPUT_TAR} out-{0..$((SIMULATIONS-1))}.{txt,trj} From wilde at ci.uchicago.edu Wed Aug 13 17:41:42 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Wed, 13 Aug 2014 17:41:42 -0500 (CDT) Subject: [Swift-commit] r8159 - SwiftTutorials/ATPESC_2014-08-14/lecture Message-ID: <20140813224142.28C189D82D@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-13 17:41:42 -0500 (Wed, 13 Aug 2014) New Revision: 8159 Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftT.pptx SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_Workflow.pptx Log: Update lecture material. These 3 files will be combined into one, to post to the ATPESC site. Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftT.pptx =================================================================== (Binary files differ) Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_Workflow.pptx =================================================================== (Binary files differ) From wilde at ci.uchicago.edu Wed Aug 13 17:52:54 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Wed, 13 Aug 2014 17:52:54 -0500 (CDT) Subject: [Swift-commit] r8160 - demo/xsede.2014.0425 Message-ID: <20140813225254.C93CB9D82D@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-13 17:52:54 -0500 (Wed, 13 Aug 2014) New Revision: 8160 Added: demo/xsede.2014.0425/part08/ Removed: demo/xsede.2014.0425/part04m/ Log: Move part04m (themdlite module) to part08. We want to switch this with part07 in a subsequence commit. From wilde at ci.uchicago.edu Wed Aug 13 18:00:29 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Wed, 13 Aug 2014 18:00:29 -0500 (CDT) Subject: [Swift-commit] r8161 - demo/xsede.2014.0425 Message-ID: <20140813230029.885189D82D@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-13 18:00:29 -0500 (Wed, 13 Aug 2014) New Revision: 8161 Added: demo/xsede.2014.0425/partx7/ Removed: demo/xsede.2014.0425/part07/ Log: dir move From wilde at ci.uchicago.edu Wed Aug 13 18:01:09 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Wed, 13 Aug 2014 18:01:09 -0500 (CDT) Subject: [Swift-commit] r8162 - demo/xsede.2014.0425 Message-ID: <20140813230109.83E729D82D@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-13 18:01:09 -0500 (Wed, 13 Aug 2014) New Revision: 8162 Added: demo/xsede.2014.0425/part07/ Removed: demo/xsede.2014.0425/part08/ Log: dir move 2 From wilde at ci.uchicago.edu Wed Aug 13 18:01:58 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Wed, 13 Aug 2014 18:01:58 -0500 (CDT) Subject: [Swift-commit] r8163 - demo/xsede.2014.0425 Message-ID: <20140813230158.A2C359D82D@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-13 18:01:58 -0500 (Wed, 13 Aug 2014) New Revision: 8163 Added: demo/xsede.2014.0425/part08/ Removed: demo/xsede.2014.0425/partx7/ Log: dir move 3 From wilde at ci.uchicago.edu Wed Aug 13 18:34:36 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Wed, 13 Aug 2014 18:34:36 -0500 (CDT) Subject: [Swift-commit] r8165 - SwiftTutorials/ATPESC_2014-08-14/swift-k Message-ID: <20140813233436.DD23C9D92B@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-13 18:34:36 -0500 (Wed, 13 Aug 2014) New Revision: 8165 Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.tukey.sh Log: initial setup script for tukey for ATPESC Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.tukey.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.tukey.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.tukey.sh 2014-08-13 23:34:36 UTC (rev 8165) @@ -0,0 +1,22 @@ + +PATH=/home/yadunand/bin/swift-0.95-main/bin:/home/yadunand/bin/jdk1.7.0_25/bin:$PATH + +echo Swift version is $(swift -version) + +# Add applications to $PATH + +TUTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +PATH=$TUTDIR/bin:$TUTDIR/app:$PATH + +( cd src/md; make; make install ) + +( cd src/c-ray; make; make install ) + +: < Author: wilde Date: 2014-08-13 18:39:59 -0500 (Wed, 13 Aug 2014) New Revision: 8166 Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p7.swift Removed: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties Log: Rename p4 to p7. Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4.swift 2014-08-13 23:34:36 UTC (rev 8165) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4.swift 2014-08-13 23:39:59 UTC (rev 8166) @@ -1,43 +0,0 @@ -type file; - -(int result) randomInt () -{ - float range = 9999999.0; - float rand = java("java.lang.Math","random"); - string s[] = strsplit(toString(range*rand),"\\."); - result = toInt(s[0]); -} - -app (file out, file traj) simulation (string npart, string steps, string mass) -{ -# mdviz @out @traj 3 npart steps 50 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt(); - md 3 npart steps 10 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt() @out @traj; -} - -app (file o) analyze (file s[]) -{ - mdstats filenames(s) stdout=filename(o); -} - -app (file o) convert (file s[]) -{ - convert filenames(s) filename(o); -} - -int nsim = toInt(arg("nsim","10")); -string npart = arg("npart","50"); -string steps = arg("steps","1000"); -string mass = arg("mass",".005"); - -file sim[] ; -file trj[] ; - -foreach i in [0:nsim-1] { - (sim[i],trj[i]) = simulation(npart,steps,mass); -} - -file stats_out<"output/average.out">; -stats_out = analyze(sim); - -#file viz_all<"output/all.gif">; -#viz_all = convert(gifs); Deleted: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift 2014-08-13 23:34:36 UTC (rev 8165) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift 2014-08-13 23:39:59 UTC (rev 8166) @@ -1,78 +0,0 @@ -type file; - -type kineticInfo { - int sim; - float energy; -} - -(int result) randomInt () -{ - float range = 9999999.0; - float rand = java("java.lang.Math","random"); - string s[] = strsplit(toString(range*rand),"\\."); - result = toInt(s[0]); -} - -app (file out, file traj) simulation (int npart, int steps, int trsnaps, float mass) -{ -# mdviz @out @traj 3 npart steps 50 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt(); - md 3 npart steps trsnaps ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt() @out @traj; -} - -app (file o) analyze (file s[]) -{ - mdstats filenames(s) stdout=filename(o); -} - -app (file o) kinetic (file s[]) -{ - mdmaxk 9999 filenames(s) stdout=filename(o); -} - -app (file o) render (file traj, int frame) -{ - renderframe filename(traj) filename(o) frame; -} - -app (file o) convert (file s[]) -{ - convert "-delay" 20 filenames(s) filename(o); -} - -int nsim = toInt(arg("nsim","10")); -int npart = toInt(arg("npart","50")); -int steps = toInt(arg("steps","1000")); -int trsnaps = 10; -float mass = toFloat(arg("mass",".005")); - -file sim[] ; -file trj[] ; - -foreach i in [0:nsim-1] { - (sim[i],trj[i]) = simulation(npart,steps,trsnaps,mass); -} - -file stats_out<"output/average.out">; -stats_out = analyze(sim); - -file ke_out<"output/kinetic.out">; -ke_out = kinetic(sim); - -kineticInfo kd[] = readData(ke_out); - -tracef("min eK simulation: %i eK: %f\n", kd[0].sim, kd[0].energy); -tracef("max eK simulation: %i eK: %f\n", kd[nsim-1].sim, kd[nsim-1].energy); - -file mink[] ; -file maxk[] ; - -foreach i in [0:trsnaps-1] { - mink[i] = render(trj[kd[0].sim], i); - maxk[i] = render(trj[kd[nsim-1].sim], i); -} - -file minkmovie <"output/mink.gif">; -file maxkmovie <"output/maxk.gif">; - -minkmovie = convert(mink); -maxkmovie = convert(maxk); Copied: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p7.swift (from rev 8165, SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p7.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p7.swift 2014-08-13 23:39:59 UTC (rev 8166) @@ -0,0 +1,78 @@ +type file; + +type kineticInfo { + int sim; + float energy; +} + +(int result) randomInt () +{ + float range = 9999999.0; + float rand = java("java.lang.Math","random"); + string s[] = strsplit(toString(range*rand),"\\."); + result = toInt(s[0]); +} + +app (file out, file traj) simulation (int npart, int steps, int trsnaps, float mass) +{ +# mdviz @out @traj 3 npart steps 50 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt(); + md 3 npart steps trsnaps ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt() @out @traj; +} + +app (file o) analyze (file s[]) +{ + mdstats filenames(s) stdout=filename(o); +} + +app (file o) kinetic (file s[]) +{ + mdmaxk 9999 filenames(s) stdout=filename(o); +} + +app (file o) render (file traj, int frame) +{ + renderframe filename(traj) filename(o) frame; +} + +app (file o) convert (file s[]) +{ + convert "-delay" 20 filenames(s) filename(o); +} + +int nsim = toInt(arg("nsim","10")); +int npart = toInt(arg("npart","50")); +int steps = toInt(arg("steps","1000")); +int trsnaps = 10; +float mass = toFloat(arg("mass",".005")); + +file sim[] ; +file trj[] ; + +foreach i in [0:nsim-1] { + (sim[i],trj[i]) = simulation(npart,steps,trsnaps,mass); +} + +file stats_out<"output/average.out">; +stats_out = analyze(sim); + +file ke_out<"output/kinetic.out">; +ke_out = kinetic(sim); + +kineticInfo kd[] = readData(ke_out); + +tracef("min eK simulation: %i eK: %f\n", kd[0].sim, kd[0].energy); +tracef("max eK simulation: %i eK: %f\n", kd[nsim-1].sim, kd[nsim-1].energy); + +file mink[] ; +file maxk[] ; + +foreach i in [0:trsnaps-1] { + mink[i] = render(trj[kd[0].sim], i); + maxk[i] = render(trj[kd[nsim-1].sim], i); +} + +file minkmovie <"output/mink.gif">; +file maxkmovie <"output/maxk.gif">; + +minkmovie = convert(mink); +maxkmovie = convert(maxk); Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties 2014-08-13 23:34:36 UTC (rev 8165) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties 2014-08-13 23:39:59 UTC (rev 8166) @@ -1,2 +1,22 @@ -site=midway-sandyb +site=tukey + +site.tukey { + jobmanager=localhost:cobalt + taskWalltime=00:15:00 + workdir=/home/$USER/swiftwork + filesystem=local + maxJobs=10 + tasksPerWorker=8 + taskThrottle=300 + initialscore=10000 +} + +app.tukey.md=$PWD/../app/md +app.tukey.mdstats=$PWD/../app/mdstats +app.tukey.mdmaxk=$PWD/../app/mdmaxk +app.tukey.renderframe=$PWD/../app/renderframe +app.tukey.convert=/usr/bin/convert + +# site=midway-sandyb + site.midway-sandyb.slurm.exclusive=false From wilde at ci.uchicago.edu Wed Aug 13 23:28:18 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Wed, 13 Aug 2014 23:28:18 -0500 (CDT) Subject: [Swift-commit] r8167 - in SwiftTutorials/ATPESC_2014-08-14/swift-k: . app part04 part05 part06 part07 Message-ID: <20140814042818.9D7229D82D@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-13 23:28:18 -0500 (Wed, 13 Aug 2014) New Revision: 8167 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.tukey.sh Log: Adjust setup for tukey and ATPESC. Correct issues with apps in swift.properties. Point to correct c-ray in renderframe. Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe 2014-08-13 23:39:59 UTC (rev 8166) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe 2014-08-14 04:28:18 UTC (rev 8167) @@ -5,6 +5,7 @@ frame=$3 APPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +BINDIR="$( cd $APPDIR/../bin && pwd )" cat <c-ray-trailer # walls @@ -20,9 +21,8 @@ ( awk "\$1 == $frame {for (i=2; it.ppm +) | $BINDIR/c-ray >t.ppm convert t.ppm $vzout Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/swift.properties 2014-08-13 23:39:59 UTC (rev 8166) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/swift.properties 2014-08-14 04:28:18 UTC (rev 8167) @@ -1,2 +1,25 @@ -site=midway-westmere -site.westmere.slurm.exclusive=false +site=tukey + +site.tukey { + jobmanager=localhost:cobalt + taskWalltime=00:15:00 + workdir=/home/$USER/swiftwork + filesystem=local + maxJobs=4 + tasksPerWorker=8 + taskThrottle=300 + initialscore=10000 +} + + +app.tukey.simulate=$PWD/../app/simulate +app.tukey.stats=$PWD/../app/stats +app.tukey.md=$PWD/../bin/md +app.tukey.mdstats=$PWD/../app/mdstats +app.tukey.mdmaxk=$PWD/../app/mdmaxk +app.tukey.renderframe=$PWD/../app/renderframe +app.tukey.convert=/usr/bin/convert + +# site=midway-sandyb + +site.midway-sandyb.slurm.exclusive=false Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/swift.properties 2014-08-13 23:39:59 UTC (rev 8166) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/swift.properties 2014-08-14 04:28:18 UTC (rev 8167) @@ -1,2 +1,25 @@ -site=westmere -site.westmere.slurm.exclusive=false +site=tukey + +site.tukey { + jobmanager=localhost:cobalt + taskWalltime=00:15:00 + workdir=/home/$USER/swiftwork + filesystem=local + maxJobs=4 + tasksPerWorker=8 + taskThrottle=300 + initialscore=10000 +} + + +app.tukey.simulate=$PWD/../app/simulate +app.tukey.stats=$PWD/../app/stats +app.tukey.md=$PWD/../bin/md +app.tukey.mdstats=$PWD/../app/mdstats +app.tukey.mdmaxk=$PWD/../app/mdmaxk +app.tukey.renderframe=$PWD/../app/renderframe +app.tukey.convert=/usr/bin/convert + +# site=midway-sandyb + +site.midway-sandyb.slurm.exclusive=false Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/swift.properties 2014-08-13 23:39:59 UTC (rev 8166) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/swift.properties 2014-08-14 04:28:18 UTC (rev 8167) @@ -1,2 +1,25 @@ -site=westmere -site.westmere.slurm.exclusive=false +site=tukey + +site.tukey { + jobmanager=localhost:cobalt + taskWalltime=00:15:00 + workdir=/home/$USER/swiftwork + filesystem=local + maxJobs=4 + tasksPerWorker=8 + taskThrottle=300 + initialscore=10000 +} + + +app.tukey.simulate=$PWD/../app/simulate +app.tukey.stats=$PWD/../app/stats +app.tukey.md=$PWD/../bin/md +app.tukey.mdstats=$PWD/../app/mdstats +app.tukey.mdmaxk=$PWD/../app/mdmaxk +app.tukey.renderframe=$PWD/../app/renderframe +app.tukey.convert=/usr/bin/convert + +# site=midway-sandyb + +site.midway-sandyb.slurm.exclusive=false Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties 2014-08-13 23:39:59 UTC (rev 8166) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties 2014-08-14 04:28:18 UTC (rev 8167) @@ -5,13 +5,16 @@ taskWalltime=00:15:00 workdir=/home/$USER/swiftwork filesystem=local - maxJobs=10 + maxJobs=4 tasksPerWorker=8 taskThrottle=300 initialscore=10000 } -app.tukey.md=$PWD/../app/md + +app.tukey.simulate=$PWD/../app/simulate +app.tukey.stats=$PWD/../app/stats +app.tukey.md=$PWD/../bin/md app.tukey.mdstats=$PWD/../app/mdstats app.tukey.mdmaxk=$PWD/../app/mdmaxk app.tukey.renderframe=$PWD/../app/renderframe Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.tukey.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.tukey.sh 2014-08-13 23:39:59 UTC (rev 8166) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.tukey.sh 2014-08-14 04:28:18 UTC (rev 8167) @@ -13,10 +13,3 @@ ( cd src/c-ray; make; make install ) -: < Author: wozniak Date: 2014-08-14 09:27:08 -0500 (Thu, 14 Aug 2014) New Revision: 8168 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-md.sh Log: Compute node script Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-md.sh (from rev 8167, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-md.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-md.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-md.sh 2014-08-14 14:27:08 UTC (rev 8168) @@ -0,0 +1,9 @@ +#!/bin/bash -eu + +source ../../cfg/setup-compute.sh +source setup-md.sh +SETTINGS=../../cfg/settings-compute.sh + +PROGRAM=run-md +stc ${PROGRAM}.swift +turbine-cobalt-run.zsh -n 4 -s ${SETTINGS} ${PROGRAM}.tcl From wozniak at ci.uchicago.edu Thu Aug 14 09:30:44 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 09:30:44 -0500 (CDT) Subject: [Swift-commit] r8169 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140814143044.1A8029CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 09:30:42 -0500 (Thu, 14 Aug 2014) New Revision: 8169 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh Log: Multi-sim compute script Copied: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh (from rev 8167, SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh 2014-08-14 14:30:42 UTC (rev 8169) @@ -0,0 +1,31 @@ +#!/bin/zsh -eu + +A=( SIMULATIONS STEPS NP ND MASS DT SEED ) + +if [[ ${#*} != ${#A} ]] +then + echo "usage: ${A}" + exit 1 +fi + +# Scan argv +for a in ${A} +do + eval ${a}=$1 + shift +done + +source ../../cfg/setup-local.sh +source setup-md.sh +SETTINGS=../../cfg/settings-compute.sh + +PROGRAM=run-mds +stc ${PROGRAM}.swift +turbine-cobalt-run.zsh -n 2 -s ${SETTINGS} ${PROGRAM}.tcl \ + --simulations=${SIMULATIONS} \ + --steps=${STEPS} \ + --np=${NP} \ + --nd=${ND} \ + --mass=${MASS} \ + --dt=${DT} \ + --seed=${SEED} From wozniak at ci.uchicago.edu Thu Aug 14 09:31:59 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 09:31:59 -0500 (CDT) Subject: [Swift-commit] r8170 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140814143159.B3B9A9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 09:31:59 -0500 (Thu, 14 Aug 2014) New Revision: 8170 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh Log: Drop tar output Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 14:30:42 UTC (rev 8169) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 14:31:59 UTC (rev 8170) @@ -1,6 +1,6 @@ #!/bin/zsh -eu -A=( SIMULATIONS STEPS NP ND MASS DT SEED OUTPUT_TAR ) +A=( SIMULATIONS STEPS NP ND MASS DT SEED ) if [[ ${#*} != ${#A} ]] then @@ -28,5 +28,3 @@ --mass=${MASS} \ --dt=${DT} \ --seed=${SEED} - -tar cfz ${OUTPUT_TAR} out-{0..$((SIMULATIONS-1))}.{txt,trj} From wozniak at ci.uchicago.edu Thu Aug 14 09:58:42 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 09:58:42 -0500 (CDT) Subject: [Swift-commit] r8171 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140814145842.0A17A9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 09:58:41 -0500 (Thu, 14 Aug 2014) New Revision: 8171 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt Log: Adding tutorial.txt Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 14:58:41 UTC (rev 8171) @@ -0,0 +1,38 @@ + += Tutorial: Swift/T + +This tutorial will walk through 4 examples of the use of Swift/T, in +addition to a molecular dynamics example. + +== Files + +The examples are in the +examples/+ directory. + +Each example directory is numbered from +01+ to +05+. + +Configuration files are in +cfg/+. These refer to public +installations of Swift/T on Cetus/Mira. + +Each example contains a +*.swift+ Swift script that is the Swift +program. There is also a +run-local+ script to run the Swift script +on the login node and a +run-compute+ script to submit the Swift +program to Cobalt. + +== Swift/T installations + +Two Swift/T installations are provided- one that runs on the login +node and one that runs on the compute nodes (via Cobalt). The login +node installation should be used with caution- expensive computation +will impact other users on the login nodes. + +== Examples + +=== 01 Hello world + +1. +cd+ into the directory +01-hello+ +2. Run: ++ +---- +./run-local.sh +---- +3. This From wozniak at ci.uchicago.edu Thu Aug 14 10:02:48 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 10:02:48 -0500 (CDT) Subject: [Swift-commit] r8172 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140814150248.52D559CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 10:02:48 -0500 (Thu, 14 Aug 2014) New Revision: 8172 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/swift.css Log: Adding swift.css Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/swift.css =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/swift.css (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/swift.css 2014-08-14 15:02:48 UTC (rev 8172) @@ -0,0 +1,10 @@ + +/* SWIFT/T GUIDE CUSTOMIZATIONS */ + +a:visited { + color: gray; +} +h5 { + font-size: 0.8em; +} + From wozniak at ci.uchicago.edu Thu Aug 14 10:12:01 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 10:12:01 -0500 (CDT) Subject: [Swift-commit] r8173 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140814151201.D58D89CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 10:12:01 -0500 (Thu, 14 Aug 2014) New Revision: 8173 Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/build-docs.sh Log: Adding build-docs.sh Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/build-docs.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/build-docs.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/build-docs.sh 2014-08-14 15:12:01 UTC (rev 8173) @@ -0,0 +1,3 @@ +#!/bin/sh -eu + +asciidoc --attribute stylesheet=${PWD}/swift.css -a max-width=750px -a textwidth=80 tutorial.txt Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-t/build-docs.sh ___________________________________________________________________ Added: svn:executable + * From wozniak at ci.uchicago.edu Thu Aug 14 10:12:13 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 10:12:13 -0500 (CDT) Subject: [Swift-commit] r8174 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140814151213.CFC479CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 10:12:13 -0500 (Thu, 14 Aug 2014) New Revision: 8174 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt Log: Doc example 01 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 15:12:01 UTC (rev 8173) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 15:12:13 UTC (rev 8174) @@ -1,9 +1,18 @@ +:toc: + = Tutorial: Swift/T This tutorial will walk through 4 examples of the use of Swift/T, in addition to a molecular dynamics example. +== Swift/T materials + +For more information on Swift/T, see: + +* http://swift-lang.org/Swift-T[Swift/T home] +* http://swift-lang.org/Swift-T/guide.html[Swift/T user guide] + == Files The examples are in the +examples/+ directory. @@ -14,9 +23,15 @@ installations of Swift/T on Cetus/Mira. Each example contains a +*.swift+ Swift script that is the Swift -program. There is also a +run-local+ script to run the Swift script +program. The Swift/T compiler +stc+ translates the Swift script into +an MPI program encoded in a +*.tcl+ file. This is launched by using +the +turbine+ program or a scheduler-specific script, such as the +provided +turbine-cobalt-run.zsh+ script. + +There is also a +run-local+ script to run the Swift script on the login node and a +run-compute+ script to submit the Swift -program to Cobalt. +program to Cobalt. These scripts add +stc+ and +turbine+ entries to +your +PATH+ automatically. == Swift/T installations @@ -35,4 +50,35 @@ ---- ./run-local.sh ---- -3. This +3. This program is a simple Hello World example. ++ +---- +include::examples/01-hello/hello.swift[] +---- +4. Run: ++ +---- +./run-compute.sh +---- ++ +This will report something like: ++ +---- +SETTINGS=../../cfg/settings-compute.sh +TURBINE_OUTPUT=/home/user/turbine-output/2014/08/14/10/06/20 +SCRIPT_NAME=hello.tcl +NODES=2 +project: ATPESC2014 +JOB_ID=312170 +---- ++ +Turbine will copy +hello.tcl+ to +TURBINE_OUTPUT+ and run from that +directory. The Cobalt log may be found there. Standard output is +directed to +TURBINE_OUTPUT/output.txt+. ++ +The contents of +output.txt+ are the Blue Gene runtime output plus the +Swift-generated line: ++ +---- +stdout[0]: Hello world! +---- From wilde at ci.uchicago.edu Thu Aug 14 10:16:26 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Thu, 14 Aug 2014 10:16:26 -0500 (CDT) Subject: [Swift-commit] r8175 - SwiftTutorials/ATPESC_2014-08-14/swift-k/part08 Message-ID: <20140814151626.401AE9CC96@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-14 10:16:26 -0500 (Thu, 14 Aug 2014) New Revision: 8175 Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/cmd.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/connect.sh Log: Commands for remote exec. Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/cmd.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/cmd.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/cmd.sh 2014-08-14 15:16:26 UTC (rev 8175) @@ -0,0 +1,7 @@ +#! /bin/sh + +SSHSOCKET=~/.ssh/$USER at cetus.alcf.anl.gov + +ssh -o ControlPath=$SSHSOCKET $USER at cetus.alcf.anl.gov $* + +# scp -o ControlPath=$SSHSOCKET myUsername at targetServerName:remoteFile.txt ./ \ No newline at end of file Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/cmd.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/connect.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/connect.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/connect.sh 2014-08-14 15:16:26 UTC (rev 8175) @@ -0,0 +1,24 @@ +#! /bin/sh + +SSHSOCKET=~/.ssh/$USER at cetus.alcf.anl.gov +ssh -M -N -o ControlPath=$SSHSOCKET $USER at cetus.alcf.anl.gov + +# ssh -M -f -N -o ControlPath=$SSHSOCKET $USER at cetus.alcf.anl.gov + +exit + +The options have the following meaning: + +-M instructs SSH to become the master, i.e. to create a master socket that will be used by the slave connections +-f makes SSH to go into the background after the authentication +-N tells SSH not to execute any command or to expect an input from the user; that?s good because we want it only to manage and keep open the master connection and nothing else +-o ControlPath=$SSHSOCKET ? this defines the name to be used for the socket that represents the master connection; the slaves will use the same value to connect via it +Thanks to -N and -f the SSH master connection will get out of the way but will stay open and such usable by subsequent ssh/scp invocations. This is exactly what we need in a shell script. If you just do something manually than you can leave out -N and -f and use directly this connection for whatever you need while you can also open a slave connection in another terminal window. Just don?t forget that once the master connection exits slaves won?t work. + +2. Open and close other connections without re-authenticating as you like + +Now you can do as many ssh/scp operations as you like and you won?t be prompted for a password. You only always have to provide the command with the same ControlPath, which we ensure by having stored it into the variable SSHSOCKET: + +ssh -o ControlPath=$SSHSOCKET myUsername at targetServerName "echo 'Hello from the remote server!'; ls" +... +scp -o ControlPath=$SSHSOCKET myUsername at targetServerName:remoteFile.txt ./ \ No newline at end of file Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/connect.sh ___________________________________________________________________ Added: svn:executable + * From wozniak at ci.uchicago.edu Thu Aug 14 10:25:44 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 10:25:44 -0500 (CDT) Subject: [Swift-commit] r8176 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140814152544.AA4F79CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 10:25:44 -0500 (Thu, 14 Aug 2014) New Revision: 8176 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt Log: Doc 02 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 15:16:26 UTC (rev 8175) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 15:25:44 UTC (rev 8176) @@ -44,6 +44,8 @@ === 01 Hello world +This is a very simple Swift/T program that illustrates Swift/T usage. + 1. +cd+ into the directory +01-hello+ 2. Run: + @@ -82,3 +84,34 @@ ---- stdout[0]: Hello world! ---- + +=== 02 Loop + +This example shows one way to obtain concurrency from Swift/T. + +---- +include::examples/02-loop/loop.swift[] +---- + +The program executes +compute()+ 10 times concurrently, because the +Swift +foreach+ loop is concurrent. The +compute()+ function is +implemented as a Tcl fragment that does 3 things: + +1. Delay progress with +after+ (sleeps for +i*1000+ milliseconds) +2. Print a timestamp for reference +3. Set a result value + +The result value is printed by Swift's +printf()+. + +Note the use of the +<<++x++>>+ syntax, which maps Swift variable +x+ to a +Tcl variable. + +This script may be run as the Hello World case, but the run scripts +accept Turbine runtime arguments: + ++-l+:: Prepend outputs with the MPI rank number (like +mpiexec -l+) ++-n N+:: Run +N+ MPI processes (like +mpiexec -n N+). Note that one +process is dedicated for Swift logic, so choose +N>1+. + +Add more processes and see how that improves time to job +completion. From wozniak at ci.uchicago.edu Thu Aug 14 10:39:38 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 10:39:38 -0500 (CDT) Subject: [Swift-commit] r8177 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas Message-ID: <20140814153938.70E739CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 10:39:38 -0500 (Thu, 14 Aug 2014) New Revision: 8177 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/dot.swift Log: Add comment Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/dot.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/dot.swift 2014-08-14 15:25:44 UTC (rev 8176) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/dot.swift 2014-08-14 15:39:38 UTC (rev 8177) @@ -3,7 +3,7 @@ Example 3 - DOT.SWIFT */ -// Swift/T libraries: +// Swift/T libraries: import blob; import io; import matrix; @@ -19,7 +19,7 @@ int N = 3; foreach i in [0:N-1] { - A[i] = itof(i); + A[i] = itof(i); // integer-to-float B[i] = itof(i+1); } @@ -28,7 +28,7 @@ vector_print(A) => printf("\nB") => vector_print(B) - => + => float z = blas_ddot(N, A, B); printf("\nA*B=%0.1f", z); From wozniak at ci.uchicago.edu Thu Aug 14 10:39:45 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 10:39:45 -0500 (CDT) Subject: [Swift-commit] r8178 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140814153945.EDEF59CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 10:39:45 -0500 (Thu, 14 Aug 2014) New Revision: 8178 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt Log: Doc 03 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 15:39:38 UTC (rev 8177) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 15:39:45 UTC (rev 8178) @@ -114,4 +114,42 @@ process is dedicated for Swift logic, so choose +N>1+. Add more processes and see how that improves time to job -completion. +completion. Check +output.txt+ for the +ADLB Total Elapsed Time:+, +which is a good measure of total execution time (discounts queue and +allocation startup/shutdown time). + +NOTE: Ease of calling to Tcl makes for ease of calling to native code, +as shown in the next example. + +== 03 BLAS + +In this example, we use Swift to call a BLAS routine for dot product. + +---- +include::examples/03-blas/dot.swift[] +---- + +In this example, we created a stub of a Swift BLAS library in ++blas.swift+. This calls the CBLAS +cblas_ddot()+ function through a +Tcl interface. + +1. Run: ++ +---- +./build.sh +---- ++ +This creates a Tcl package for BLAS (using a hand-coded method- we +also use SWIG to automate this). + +2. Run +./run-*.sh+. + +In +dot.swift+, the Swift statement +import blas;+ brings +blas.swift+ +into the program. The Swift call to +blas_ddot()+ operates on the +Swift arrays +A+ and +B+. In +blas.swift+, the Swift arrays are +converted to C-compatible arrays of +double+, which are represented in +Swift/T with the +blob+ type. These are passed to the BLAS package. + +Thus, calling native code from Swift/T is comparable in complexity to +calling native code from other scripting languages such as Tcl or +Python. From wozniak at ci.uchicago.edu Thu Aug 14 10:50:58 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 10:50:58 -0500 (CDT) Subject: [Swift-commit] r8179 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140814155058.A50D49CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 10:50:58 -0500 (Thu, 14 Aug 2014) New Revision: 8179 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt Log: Doc 04 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 15:39:45 UTC (rev 8178) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 15:50:58 UTC (rev 8179) @@ -140,7 +140,7 @@ ---- + This creates a Tcl package for BLAS (using a hand-coded method- we -also use SWIG to automate this). +could also use http://swig.org[SWIG] to automate this). 2. Run +./run-*.sh+. @@ -153,3 +153,34 @@ Thus, calling native code from Swift/T is comparable in complexity to calling native code from other scripting languages such as Tcl or Python. + +=== 04 Python + +Another good way to call native code and bind it together in a script +is through Python. Swift/T has convenient interfaces for Python, Tcl, +R, Julia, and Qt Script (and the shell). In this example, we call +into Python and its numerical package Numpy, which uses BLAS +internally for numerical operations. + +---- +include::examples/04-py/add.swift[] +---- + +In this example, we also created a stub Swift numerical library in ++numpy.swift+. This is imported into the main Swift script ++add.swift+. + +First, this program calls +f()+, which is a simple use of the +Swift/T-Python interface. The Python code fragment must return a +value in its last line as a string- in this case, we return +"0"+. + +Second, we use the +numpy.swift+ features. We allocate 2 Numpy arrays +_I~3~_ and add them together, producing _2I~3~_. + +Swift/T can call into arbitrary Python modules, just set +PYTHONPATH+. +C/C++ code can be easily wrapped for Python with +http://swig.org[SWIG], Fortran code with SciPy's +http://wiki.scipy.org/Cookbook/F2Py[F2PY]. + +Thus, a variety of scripts and libraries can be easily integrated with +Swift/T and run concurrently on massive computers like the Blue Gene/Q! From wozniak at ci.uchicago.edu Thu Aug 14 11:22:06 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 11:22:06 -0500 (CDT) Subject: [Swift-commit] r8180 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140814162206.D4E629CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 11:22:06 -0500 (Thu, 14 Aug 2014) New Revision: 8180 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt Log: Doc 05 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 15:50:58 UTC (rev 8179) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 16:22:06 UTC (rev 8180) @@ -22,7 +22,7 @@ Configuration files are in +cfg/+. These refer to public installations of Swift/T on Cetus/Mira. -Each example contains a +*.swift+ Swift script that is the Swift +Each example contains a +*.swift+ Swift script that is the Swift program. The Swift/T compiler +stc+ translates the Swift script into an MPI program encoded in a +*.tcl+ file. This is launched by using the +turbine+ program or a scheduler-specific script, such as the @@ -121,7 +121,7 @@ NOTE: Ease of calling to Tcl makes for ease of calling to native code, as shown in the next example. -== 03 BLAS +=== 03 BLAS In this example, we use Swift to call a BLAS routine for dot product. @@ -182,5 +182,32 @@ http://swig.org[SWIG], Fortran code with SciPy's http://wiki.scipy.org/Cookbook/F2Py[F2PY]. -Thus, a variety of scripts and libraries can be easily integrated with -Swift/T and run concurrently on massive computers like the Blue Gene/Q! +[red]*★* Thus, a variety of scripts and +libraries can be easily integrated with Swift/T and run concurrently +on massive computers like the Blue Gene/Q! + +=== 05 Molecular dynamics + +In our most realistic example, we bundle a small molecular dynamics +simulator http://people.sc.fsu.edu/~jburkardt/c_src/md/md.html[MD] for +Swift/T and call it concurrently. + +1. +cd+ to +examples/md-src/+ and run: ++ +---- +make +---- ++ +This builds the Tcl package by: ++ +a. Running SWIG to expose the core +simulate()+ function to Tcl; +b. Compiling the SWIG-generated wrapper code and linking it as a Tcl +package. +2. +cd+ back to +examples/05-md/+. +3. The +md.swift+ library shows the calling sequence for MD. +4. The +run-md.swift+ script shows how to call MD once. The output +files are indicated in the script, in addition to the usual ++output.txt+. Run this with +./run-*-md.sh+. +5. A concurrent ensemble of simulations is launched by ++run-mds.swift+. This script accepts many arguments on the command +line: see +run-*-mds.sh+. From wozniak at ci.uchicago.edu Thu Aug 14 11:27:51 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 11:27:51 -0500 (CDT) Subject: [Swift-commit] r8181 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py Message-ID: <20140814162751.DAC7B9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 11:27:51 -0500 (Thu, 14 Aug 2014) New Revision: 8181 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/add.swift Log: Add header Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/add.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/add.swift 2014-08-14 16:22:06 UTC (rev 8180) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/add.swift 2014-08-14 16:27:51 UTC (rev 8181) @@ -1,4 +1,8 @@ +/** + Example 4 - ADD.SWIFT +*/ + // Swift/T libraries: import io; import python; @@ -10,7 +14,7 @@ f() { python( ----- +---- print("Python works!") repr(0) ----); @@ -24,4 +28,3 @@ matrix sum = add(A1, A2); printf("2*eye(3)=%s", sum); } - From wozniak at ci.uchicago.edu Thu Aug 14 11:29:11 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 11:29:11 -0500 (CDT) Subject: [Swift-commit] r8182 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src Message-ID: <20140814162911.C54D89CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 11:29:11 -0500 (Thu, 14 Aug 2014) New Revision: 8182 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md.tcl Log: Fix for Cetus Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md.tcl 2014-08-14 16:27:51 UTC (rev 8181) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/test-md.tcl 2014-08-14 16:29:11 UTC (rev 8182) @@ -1,8 +1,6 @@ -#!/usr/bin/env tclsh8.6 +#!/usr/bin/env tclsh8.5 lappend auto_path $env(PWD) package require md 0.0 simulate 4 2 0 0 10 2 1 0.1 9 out.txt out.trj - - From wilde at ci.uchicago.edu Thu Aug 14 11:34:57 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Thu, 14 Aug 2014 11:34:57 -0500 (CDT) Subject: [Swift-commit] r8183 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src Message-ID: <20140814163457.661A29CC96@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-14 11:34:57 -0500 (Thu, 14 Aug 2014) New Revision: 8183 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/main.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h Log: Adjust arguments and order. Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/main.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/main.c 2014-08-14 16:29:11 UTC (rev 8182) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/main.c 2014-08-14 16:34:57 UTC (rev 8183) @@ -13,8 +13,8 @@ char *outfile = "md.dat"; char *trjfile = "md.trj"; +char *printinfo = "0.1 1.0 0.2 0.05 50.0 0.1"; - /******************************************************************************/ int main ( int argc, char *argv[] ) @@ -83,6 +83,8 @@ int step_print; int step_print_index = 0; int step_print_num = 10; + double scale_factor = 2.5; + double scale_offset = 2.0; double *vel; timestamp ( ); @@ -188,10 +190,16 @@ ctime1 = cpu_time ( ); + /* simulate (step_num, step_print_num, step_print, step_print_index, np, nd, mass, dt, seed, outfile, trjfile); + */ + simulate (nd, np, step_num, step_print_num, + dt, mass, printinfo, scale_factor, scale_offset, + seed, outfile, trjfile); + ctime2 = cpu_time ( ); ctime = ctime2 - ctime1; Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c 2014-08-14 16:29:11 UTC (rev 8182) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c 2014-08-14 16:34:57 UTC (rev 8183) @@ -6,10 +6,12 @@ #include "md.h" -double scale_factor = 2.5, scale_offset = -2.0; +double scale_factor_g, scale_offset_g; /* FIXME */ + +/* char *printinfo = "0.05 1.0 0.2 0.05 50.0 0.1"; +*/ - double dist ( int nd, double r1[], double r2[], double dr[] ); double r8_uniform_01 ( int *seed ); @@ -21,15 +23,21 @@ static void trj_file_open(char *trjfile); static void trj_file_close(void); -void simulate (int step_num, int step_print_num, - int step_print, int step_print_index, - int np, int nd, - double mass, - double dt, - int seed, - char* outfile, - char* trjfile) +void simulate ( int nd, int np, + int step_num, int step_print_num, + double dt, + double mass, + char *printinfo, + double scale_factor, + double scale_offset, + int seed, + char* outfile, + char* trjfile) { + int step_print, step_print_index; + scale_factor_g = scale_factor; + scale_offset_g = scale_offset; + /* Allocate memory. */ @@ -575,7 +583,7 @@ double scale (double x) { - return( (x / scale_factor) - scale_offset); + return( (x / scale_factor_g) - scale_offset_g); /* return( (x / 2.5) - 2.0); */ } Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h 2014-08-14 16:29:11 UTC (rev 8182) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h 2014-08-14 16:34:57 UTC (rev 8183) @@ -21,6 +21,7 @@ void compute ( int np, int nd, double pos[], double vel[], double mass, double f[], double *pot, double *kin ); +/* void simulate (int step_num, int step_print_num, int step_print, int step_print_index, int np, int nd, @@ -29,5 +30,16 @@ int seed, char* outfile, char* trjfile); +*/ +void simulate ( int nd, int np, + int step_num, int step_print_num, + double dt, + double mass, + char *printinfo, + double scale_factor, + double scale_offset, + int seed, + char* outfile, + char* trjfile); #endif From wozniak at ci.uchicago.edu Thu Aug 14 11:47:23 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 11:47:23 -0500 (CDT) Subject: [Swift-commit] r8184 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140814164723.E2EA89CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 11:47:23 -0500 (Thu, 14 Aug 2014) New Revision: 8184 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.swift SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift Log: Version crashes STC Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.swift 2014-08-14 16:34:57 UTC (rev 8183) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.swift 2014-08-14 16:47:23 UTC (rev 8184) @@ -1,13 +1,16 @@ @dispatch=WORKER (file outfile, file trjfile) -simulate(int step_num, int step_print_num, - int step_print, int step_print_index, - int np, int nd, +simulate(int np, int nd, + int step_num, int step_print_num, + float dt, float mass, - float dt, - int seed) + string printinfo, + float scale_factor, + float scale_offset, + int seed, + file outfile, file trjfile) "md" "0.0" [ -"simulate <> <> <> <> <> <> <> <
> <> [ lindex $<> 0 ] [ lindex $<> 0 ]" +"simulate <> <> <> <> <
> <> <> <> <> <> [ lindex $<> 0 ] [ lindex $<> 0 ]" ]; Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift 2014-08-14 16:34:57 UTC (rev 8183) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift 2014-08-14 16:47:23 UTC (rev 8184) @@ -5,5 +5,7 @@ { file out_txt<"out.txt">; file out_trj<"out.trj">; - (out_txt, out_trj) = simulate(10, 10, 3, 0, 10, 2, 1, 0.1, 42); + (out_txt, out_trj) = simulate(3, 0, 10, 10, 0.1, 1, + "0.1 1.0 0.2 0.05 50.0 0.1", + 2.5, 2.0, 42, out_txt, out_trj); } From wozniak at ci.uchicago.edu Thu Aug 14 11:53:03 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 11:53:03 -0500 (CDT) Subject: [Swift-commit] r8185 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src Message-ID: <20140814165303.C68BA9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 11:53:03 -0500 (Thu, 14 Aug 2014) New Revision: 8185 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/Makefile Log: Turn on -Wall Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/Makefile =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/Makefile 2014-08-14 16:47:23 UTC (rev 8184) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/Makefile 2014-08-14 16:53:03 UTC (rev 8185) @@ -1,21 +1,21 @@ bin = md CC = gcc -INCLUDES := -OPTZ = -O0 +INCLUDES := +OPTZ = -O0 OPTS = -O3 -ffast-math -CFLAGS = $(OPTZ) -g -fPIC -std=gnu99 $(INCLUDES) +CFLAGS = $(OPTZ) -g -fPIC -std=gnu99 -Wall $(INCLUDES) -SRC = main.c md.c +SRC = main.c md.c OBJ = $(patsubst %.c,%.o,$(SRC)) all: $(bin) -# Link stand-alone executable: +# Link stand-alone executable: $(bin): $(OBJ) $(CC) -o $(@) $(OBJ) -lm -# Swift/T integration: +# Swift/T integration: USE_SWIFT = 1 ifeq ($(USE_SWIFT),1) @@ -42,7 +42,7 @@ LEAF_SO=$(<) LEAF_TCL=md.tcl \ $(TCLSH) ./make-package.tcl > $(@) -clean:: +clean:: rm -fv pkgIndex.tcl libtclmd.so md_wrap.* endif # Swift/T @@ -58,4 +58,3 @@ .PHONY: uninstall uninstall: rm -f ../../bin/$(bin) - From wozniak at ci.uchicago.edu Thu Aug 14 11:53:39 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 11:53:39 -0500 (CDT) Subject: [Swift-commit] r8186 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src Message-ID: <20140814165339.670609CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 11:53:39 -0500 (Thu, 14 Aug 2014) New Revision: 8186 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/main.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h Log: Satisfy -Wall; fix unlinked symbol Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/main.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/main.c 2014-08-14 16:53:03 UTC (rev 8185) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/main.c 2014-08-14 16:53:39 UTC (rev 8186) @@ -71,21 +71,15 @@ double ctime1; double ctime2; double dt = 0.0001; - int i; - int id; double mass = 1.0 * .0001; int nd; int np; int seed = 123456789; - int step; int step_num; - int step_print; - int step_print_index = 0; int step_print_num = 10; double scale_factor = 2.5; double scale_offset = 2.0; - double *vel; timestamp ( ); printf ( "\n" ); Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c 2014-08-14 16:53:03 UTC (rev 8185) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c 2014-08-14 16:53:39 UTC (rev 8186) @@ -34,7 +34,7 @@ char* outfile, char* trjfile) { - int step_print, step_print_index; + int step_print, step_print_index = 0; scale_factor_g = scale_factor; scale_offset_g = scale_offset; @@ -489,13 +489,12 @@ static char time_buffer[TIME_SIZE]; const struct tm *tm; - size_t len; time_t now; now = time ( NULL ); tm = localtime ( &now ); - len = strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); + strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); printf ( "%s\n", time_buffer ); @@ -573,7 +572,7 @@ s -0.5 -0.3 -1 0.05 1.0 0.2 0.05 50.0 0.1 s 0.5 -0.4 0 0.05 0.1 0.85 1.0 50.0 0.1 */ - char *s = "0.05 1.0 0.2 0.05 50.0 0.1"; + // char *s = "0.05 1.0 0.2 0.05 50.0 0.1"; /* printf("s %f %f %f %s\n", pos[0+j*nd]/20.0, pos[1+j*nd]/20.0, pos[2+j*nd]/20.0, s); */ } Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h 2014-08-14 16:53:03 UTC (rev 8185) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h 2014-08-14 16:53:39 UTC (rev 8186) @@ -8,7 +8,6 @@ #ifndef MD_H #define MD_H -extern double scale_factor, scale_offset; extern char *printinfo; double cpu_time ( void ); @@ -21,17 +20,6 @@ void compute ( int np, int nd, double pos[], double vel[], double mass, double f[], double *pot, double *kin ); -/* -void simulate (int step_num, int step_print_num, - int step_print, int step_print_index, - int np, int nd, - double mass, - double dt, - int seed, - char* outfile, - char* trjfile); -*/ - void simulate ( int nd, int np, int step_num, int step_print_num, double dt, From wozniak at ci.uchicago.edu Thu Aug 14 11:59:32 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 11:59:32 -0500 (CDT) Subject: [Swift-commit] r8187 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140814165932.E14039CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 11:59:32 -0500 (Thu, 14 Aug 2014) New Revision: 8187 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.swift SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift Log: run-md.swift works now - STC crash was due to input error - will file Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.swift 2014-08-14 16:53:39 UTC (rev 8186) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/md.swift 2014-08-14 16:59:32 UTC (rev 8187) @@ -8,9 +8,8 @@ string printinfo, float scale_factor, float scale_offset, - int seed, - file outfile, file trjfile) + int seed) "md" "0.0" [ -"simulate <> <> <> <> <
> <> <> <> <> <> [ lindex $<> 0 ] [ lindex $<> 0 ]" + "simulate <> <> <> <> <
> <> <> <> <> <> [ lindex $<> 0 ] [ lindex $<> 0 ]" ]; Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift 2014-08-14 16:53:39 UTC (rev 8186) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift 2014-08-14 16:59:32 UTC (rev 8187) @@ -7,5 +7,5 @@ file out_trj<"out.trj">; (out_txt, out_trj) = simulate(3, 0, 10, 10, 0.1, 1, "0.1 1.0 0.2 0.05 50.0 0.1", - 2.5, 2.0, 42, out_txt, out_trj); + 2.5, 2.0, 42); } From wozniak at ci.uchicago.edu Thu Aug 14 12:02:39 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:02:39 -0500 (CDT) Subject: [Swift-commit] r8188 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140814170239.3BAF99CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:02:39 -0500 (Thu, 14 Aug 2014) New Revision: 8188 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.swift Log: Update for new args Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 16:59:32 UTC (rev 8187) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 17:02:39 UTC (rev 8188) @@ -1,6 +1,7 @@ #!/bin/zsh -eu -A=( SIMULATIONS STEPS NP ND MASS DT SEED ) +A=( SIMULATIONS NP ND STEP_NUM STEP_PRINT_NUM DT MASS PRINTINFO + SCALE_FACTOR SCALE_OFFSET SEED ) if [[ ${#*} != ${#A} ]] then @@ -8,10 +9,11 @@ exit 1 fi +set -x # Scan argv for a in ${A} do - eval ${a}=$1 + eval "${a}='$1'" shift done @@ -20,11 +22,15 @@ PROGRAM=run-mds stc ${PROGRAM}.swift -turbine -n 2 ${PROGRAM}.tcl \ - --simulations=${SIMULATIONS} \ - --steps=${STEPS} \ - --np=${NP} \ - --nd=${ND} \ - --mass=${MASS} \ - --dt=${DT} \ +turbine -n 2 ${PROGRAM}.tcl \ + --simulations=${SIMULATIONS} \ + --np=${NP} \ + --nd=${ND} \ + --step_num=${STEP_NUM} \ + --step_print_num=${STEP_PRINT_NUM} \ + --dt=${DT} \ + --mass=${MASS} \ + --printinfo=${PRINTINFO} \ + --scale_factor=${SCALE_FACTOR} \ + --scale_offset=${SCALE_OFFSET} \ --seed=${SEED} Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.swift 2014-08-14 16:59:32 UTC (rev 8187) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-mds.swift 2014-08-14 17:02:39 UTC (rev 8188) @@ -7,17 +7,22 @@ main { int simulations = toint(argv("simulations")); - int steps = toint(argv("steps")); int np = toint(argv("np")); int nd = toint(argv("nd")); + int step_num = toint(argv("step_num")); + int step_print_num = toint(argv("step_print_num")); + float dt = tofloat(argv("dt")); float mass = tofloat(argv("mass")); - float dt = tofloat(argv("dt")); + string printinfo = argv("printinfo"); + float scale_factor = tofloat(argv("scale_factor")); + float scale_offset = tofloat(argv("scale_offset")); int seed = toint(argv("seed")); foreach i in [0:simulations-1] { file out_txt; file out_trj; (out_txt, out_trj) = - simulate(steps, 10, 0, 0, np, nd, mass, dt, seed); + simulate(np, nd, step_num, step_print_num, dt, mass, + printinfo, scale_factor, scale_offset, seed); } } From wozniak at ci.uchicago.edu Thu Aug 14 12:06:45 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:06:45 -0500 (CDT) Subject: [Swift-commit] r8189 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140814170645.334649CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:06:45 -0500 (Thu, 14 Aug 2014) New Revision: 8189 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh Log: Clean up Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 17:02:39 UTC (rev 8188) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 17:06:45 UTC (rev 8189) @@ -9,7 +9,6 @@ exit 1 fi -set -x # Scan argv for a in ${A} do From wozniak at ci.uchicago.edu Thu Aug 14 12:17:29 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:17:29 -0500 (CDT) Subject: [Swift-commit] r8190 - www Message-ID: <20140814171729.7473A9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:17:29 -0500 (Thu, 14 Aug 2014) New Revision: 8190 Added: www/ATPESC_2014/ Log: Adding ATPESC_2014 From wozniak at ci.uchicago.edu Thu Aug 14 12:19:47 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:19:47 -0500 (CDT) Subject: [Swift-commit] r8191 - SwiftTutorials/ATPESC_2014-08-14 Message-ID: <20140814171947.DFA3D9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:19:47 -0500 (Thu, 14 Aug 2014) New Revision: 8191 Added: SwiftTutorials/ATPESC_2014-08-14/build-docs.sh Log: Adding build-docs.sh Added: SwiftTutorials/ATPESC_2014-08-14/build-docs.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/build-docs.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/build-docs.sh 2014-08-14 17:19:47 UTC (rev 8191) @@ -0,0 +1,3 @@ +#!/bin/sh -eu + +asciidoc --attribute stylesheet=${PWD}/swift.css -a max-width=750px -a textwidth=80 tutorial.txt Property changes on: SwiftTutorials/ATPESC_2014-08-14/build-docs.sh ___________________________________________________________________ Added: svn:executable + * From wozniak at ci.uchicago.edu Thu Aug 14 12:21:26 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:21:26 -0500 (CDT) Subject: [Swift-commit] r8192 - SwiftTutorials/ATPESC_2014-08-14 Message-ID: <20140814172126.B360E9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:21:26 -0500 (Thu, 14 Aug 2014) New Revision: 8192 Added: SwiftTutorials/ATPESC_2014-08-14/swift.css SwiftTutorials/ATPESC_2014-08-14/tutorial.txt Log: Initial page Copied: SwiftTutorials/ATPESC_2014-08-14/swift.css (from rev 8183, SwiftTutorials/ATPESC_2014-08-14/swift-t/swift.css) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift.css (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift.css 2014-08-14 17:21:26 UTC (rev 8192) @@ -0,0 +1,10 @@ + +/* SWIFT/T GUIDE CUSTOMIZATIONS */ + +a:visited { + color: gray; +} +h5 { + font-size: 0.8em; +} + Added: SwiftTutorials/ATPESC_2014-08-14/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/tutorial.txt (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/tutorial.txt 2014-08-14 17:21:26 UTC (rev 8192) @@ -0,0 +1,7 @@ + += ATPESC 2014 Swift Tutorial + +This is the Swift tutorial for http://extremecomputingtraining.anl.gov[ATPESC 2014]. + +* Swift/K tutorial +* link:swift-t/tutorial.html From wozniak at ci.uchicago.edu Thu Aug 14 12:22:18 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:22:18 -0500 (CDT) Subject: [Swift-commit] r8193 - www/ATPESC_2014 Message-ID: <20140814172218.A79629D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:22:18 -0500 (Thu, 14 Aug 2014) New Revision: 8193 Added: www/ATPESC_2014/swift-t/ Log: Adding swift-t From wozniak at ci.uchicago.edu Thu Aug 14 12:22:32 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:22:32 -0500 (CDT) Subject: [Swift-commit] r8194 - www/ATPESC_2014 Message-ID: <20140814172232.DBDD69D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:22:32 -0500 (Thu, 14 Aug 2014) New Revision: 8194 Added: www/ATPESC_2014/tutorial.html Log: Adding tutorial.html Added: www/ATPESC_2014/tutorial.html =================================================================== --- www/ATPESC_2014/tutorial.html (rev 0) +++ www/ATPESC_2014/tutorial.html 2014-08-14 17:22:32 UTC (rev 8194) @@ -0,0 +1,764 @@ + + + + + +ATPESC 2014 Swift Tutorial + + + + + +
+
+
+

This is the Swift tutorial for ATPESC 2014.

+
    +
  • +

    +Swift/K tutorial +

    +
  • +
  • +

    +link:swift-t/tutorial.html +

    +
  • +
+
+
+
+

+ + + From wozniak at ci.uchicago.edu Thu Aug 14 12:24:44 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:24:44 -0500 (CDT) Subject: [Swift-commit] r8195 - www Message-ID: <20140814172444.7C3AA9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:24:44 -0500 (Thu, 14 Aug 2014) New Revision: 8195 Modified: www/push_to.sh Log: Add ATPESC_2014 Modified: www/push_to.sh =================================================================== --- www/push_to.sh 2014-08-14 17:22:32 UTC (rev 8194) +++ www/push_to.sh 2014-08-14 17:24:44 UTC (rev 8195) @@ -17,7 +17,7 @@ UPDATE=0 while getopts "hu" OPTION do - case $OPTION in + case $OPTION in h) usage ; exit 0 ;; u) UPDATE=1 ;; *) exit 1 ;; # Bash prints an error message @@ -26,8 +26,8 @@ shift $(( OPTIND -1 )) U="" -if (( UPDATE )) -then +if (( UPDATE )) +then U=u fi @@ -123,8 +123,8 @@ case_studies/images/rdcep3.png case_studies/images/rdcep4.png case_studies/images/rna.png -case_studies/images/hydrology.jpg -case_studies/images/glass2.jpg +case_studies/images/hydrology.jpg +case_studies/images/glass2.jpg case_studies/index.php case_studies/CIM-Earth.php case_studies/Hydrology.php @@ -154,7 +154,7 @@ updatenodocs.sh template_info/template.php papers/index.php -papers/pdfs/*.pdf +papers/pdfs/*.pdf usage/charts.swf usage/usage.php usage/resources/cursor/cursor.swf @@ -247,6 +247,7 @@ docs/usage_data.php docs/index.php shBrushVDL2.js +ATPESC_2014/*.html ) # Make sure destination directory exists @@ -270,6 +271,6 @@ popd > /dev/null 2>&1 -# Local Variables: +# Local Variables: # sh-basic-offset: 3 # End: From wozniak at ci.uchicago.edu Thu Aug 14 12:26:04 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:26:04 -0500 (CDT) Subject: [Swift-commit] r8196 - www/ATPESC_2014 Message-ID: <20140814172604.A03CB9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:26:04 -0500 (Thu, 14 Aug 2014) New Revision: 8196 Modified: www/ATPESC_2014/tutorial.html Log: Fix link Modified: www/ATPESC_2014/tutorial.html =================================================================== --- www/ATPESC_2014/tutorial.html 2014-08-14 17:24:44 UTC (rev 8195) +++ www/ATPESC_2014/tutorial.html 2014-08-14 17:26:04 UTC (rev 8196) @@ -535,6 +535,16 @@ } + +/* SWIFT/T GUIDE CUSTOMIZATIONS */ + +a:visited { + color: gray; +} +h5 { + font-size: 0.8em; +} + + + + +
+
+
+

This tutorial will walk through 4 examples of the use of Swift/T, in +addition to a molecular dynamics example.

+
+
+
+

Swift/T materials

+
+

For more information on Swift/T, see:

+
+
+
+
+

Files

+
+

The examples are in the examples/ directory.

+

Each example directory is numbered from 01 to 05.

+

Configuration files are in cfg/. These refer to public +installations of Swift/T on Cetus/Mira.

+

Each example contains a *.swift Swift script that is the Swift +program. The Swift/T compiler stc translates the Swift script into +an MPI program encoded in a *.tcl file. This is launched by using +the turbine program or a scheduler-specific script, such as the +provided turbine-cobalt-run.zsh script.

+

There is also a run-local script to run the Swift script +on the login node and a run-compute script to submit the Swift +program to Cobalt. These scripts add stc and turbine entries to +your PATH automatically.

+
+
+
+

Swift/T installations

+
+

Two Swift/T installations are provided- one that runs on the login +node and one that runs on the compute nodes (via Cobalt). The login +node installation should be used with caution- expensive computation +will impact other users on the login nodes.

+
+
+
+

Examples

+
+
+

01 Hello world

+

This is a very simple Swift/T program that illustrates Swift/T usage.

+
    +
  1. +

    +cd into the directory 01-hello +

    +
  2. +
  3. +

    +Run: +

    +
    +
    +
    ./run-local.sh
    +
    +
  4. +
  5. +

    +This program is a simple Hello World example. +

    +
    +
    +
    /**
    +   Example 1 - HELLO.SWIFT
    +*/
    +
    +import io;
    +
    +main
    +{
    +  printf("Hello world!");
    +}
    +
    +
  6. +
  7. +

    +Run: +

    +
    +
    +
    ./run-compute.sh
    +
    +

    This will report something like:

    +
    +
    +
    SETTINGS=../../cfg/settings-compute.sh
    +TURBINE_OUTPUT=/home/user/turbine-output/2014/08/14/10/06/20
    +SCRIPT_NAME=hello.tcl
    +NODES=2
    +project: ATPESC2014
    +JOB_ID=312170
    +
    +

    Turbine will copy hello.tcl to TURBINE_OUTPUT and run from that +directory. The Cobalt log may be found there. Standard output is +directed to TURBINE_OUTPUT/output.txt.

    +

    The contents of output.txt are the Blue Gene runtime output plus the +Swift-generated line:

    +
    +
    +
    stdout[0]: Hello world!
    +
    +
  8. +
+
+
+

02 Loop

+

This example shows one way to obtain concurrency from Swift/T.

+
+
+
/**
+   Example 2 - LOOP.SWIFT
+*/
+
+import io;
+
+ at dispatch=WORKER
+(int j) compute(int i) "turbine" "0.0"
+[
+----
+  after [ expr <<i>> * 1000 ]
+  puts "compute: <<i>> [ expr [clock seconds] % 1000]"
+  set <<j>> [ expr <<i>> * 2 ]
+----
+];
+
+main
+{
+  printf("Running loop...");
+  foreach i in [0:9]
+  {
+    j = compute(i);
+    printf("compute(%i) = %i", i, j);
+  }
+}
+
+

The program executes compute() 10 times concurrently, because the +Swift foreach loop is concurrent. The compute() function is +implemented as a Tcl fragment that does 3 things:

+
    +
  1. +

    +Delay progress with after (sleeps for i*1000 milliseconds) +

    +
  2. +
  3. +

    +Print a timestamp for reference +

    +
  4. +
  5. +

    +Set a result value +

    +
  6. +
+

The result value is printed by Swift’s printf().

+

Note the use of the <<x>> syntax, which maps Swift variable x to a +Tcl variable.

+

This script may be run as the Hello World case, but the run scripts +accept Turbine runtime arguments:

+
+
+-l +
+
+

+Prepend outputs with the MPI rank number (like mpiexec -l) +

+
+
+-n N +
+
+

+Run N MPI processes (like mpiexec -n N). Note that one +process is dedicated for Swift logic, so choose N>1. +

+
+
+

Add more processes and see how that improves time to job +completion. Check output.txt for the ADLB Total Elapsed Time:, +which is a good measure of total execution time (discounts queue and +allocation startup/shutdown time).

+
+ + + +
+
Note
+
Ease of calling to Tcl makes for ease of calling to native code, +as shown in the next example.
+
+
+
+

03 BLAS

+

In this example, we use Swift to call a BLAS routine for dot product.

+
+
+
/**
+   Example 3 - DOT.SWIFT
+*/
+
+// Swift/T libraries:
+import blob;
+import io;
+import matrix;
+
+// BLAS library for this example:
+import blas;
+
+main
+{
+  // Swift floats are 64-bit
+  float A[];
+  float B[];
+  int N = 3;
+  foreach i in [0:N-1]
+  {
+    A[i] = itof(i);   // integer-to-float
+    B[i] = itof(i+1);
+  }
+
+  // Use => for output ordering
+  printf("A") =>
+    vector_print(A) =>
+    printf("\nB") =>
+    vector_print(B)
+    =>
+    float z = blas_ddot(N, A, B);
+
+  printf("\nA*B=%0.1f", z);
+}
+
+

In this example, we created a stub of a Swift BLAS library in +blas.swift. This calls the CBLAS cblas_ddot() function through a +Tcl interface.

+
    +
  1. +

    +Run: +

    +
    +
    +
    ./build.sh
    +
    +

    This creates a Tcl package for BLAS (using a hand-coded method- we +could also use SWIG to automate this).

    +
  2. +
  3. +

    +Run ./run-*.sh. +

    +
  4. +
+

In dot.swift, the Swift statement import blas; brings blas.swift +into the program. The Swift call to blas_ddot() operates on the +Swift arrays A and B. In blas.swift, the Swift arrays are +converted to C-compatible arrays of double, which are represented in +Swift/T with the blob type. These are passed to the BLAS package.

+

Thus, calling native code from Swift/T is comparable in complexity to +calling native code from other scripting languages such as Tcl or +Python.

+
+
+

04 Python

+

Another good way to call native code and bind it together in a script +is through Python. Swift/T has convenient interfaces for Python, Tcl, +R, Julia, and Qt Script (and the shell). In this example, we call +into Python and its numerical package Numpy, which uses BLAS +internally for numerical operations.

+
+
+
/**
+   Example 4 - ADD.SWIFT
+*/
+
+// Swift/T libraries:
+import io;
+import python;
+import string;
+
+// This example: See ./numpy.swift
+import numpy;
+
+f()
+{
+  python(
+----
+print("Python works!")
+repr(0)
+----);
+}
+
+main
+{
+  f();
+  matrix A1 = eye(3);
+  matrix A2 = eye(3);
+  matrix sum = add(A1, A2);
+  printf("2*eye(3)=%s", sum);
+}
+
+

In this example, we also created a stub Swift numerical library in +numpy.swift. This is imported into the main Swift script +add.swift.

+

First, this program calls f(), which is a simple use of the +Swift/T-Python interface. The Python code fragment must return a +value in its last line as a string- in this case, we return "0".

+

Second, we use the numpy.swift features. We allocate 2 Numpy arrays +I3 and add them together, producing 2I3.

+

Swift/T can call into arbitrary Python modules, just set PYTHONPATH. +C/C++ code can be easily wrapped for Python with +SWIG, Fortran code with SciPy’s +F2PY.

+

Thus, a variety of scripts and +libraries can be easily integrated with Swift/T and run concurrently +on massive computers like the Blue Gene/Q!

+
+
+

05 Molecular dynamics

+

In our most realistic example, we bundle a small molecular dynamics +simulator MD for +Swift/T and call it concurrently.

+
    +
  1. +

    +cd to examples/md-src/ and run: +

    +
    +
    +
    make
    +
    +

    This builds the stand-alone md program. You can test it with +test-md-*.sh. +2. Run:

    +
    +
    +
    make swift-pkg
    +
    +

    This builds the Tcl package by:

    +
      +
    1. +

      +Running SWIG to expose the core simulate() function to Tcl; +

      +
    2. +
    3. +

      +Compiling the SWIG-generated wrapper code and linking it as a Tcl +package. +

      +

      You can test the Tcl function with ./test-md.tcl, which simply loads +the package and calls simulate once.

      +
    4. +
    +
  2. +
  3. +

    +cd back to examples/05-md/. +

    +
  4. +
  5. +

    +The md.swift library shows the calling sequence for MD. +

    +
  6. +
  7. +

    +The run-md.swift script shows how to call MD once. The output +files are indicated in the script, in addition to the usual +output.txt. Run this with ./run-*-md.sh. +

    +
  8. +
  9. +

    +A concurrent ensemble of simulations is launched by +run-mds.swift. This script accepts many arguments on the command +line: see run-*-mds.sh. +

    +
  10. +
+
+
+
+
+

+ + + From wozniak at ci.uchicago.edu Thu Aug 14 12:30:11 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:30:11 -0500 (CDT) Subject: [Swift-commit] r8198 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140814173011.0889C9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:30:10 -0500 (Thu, 14 Aug 2014) New Revision: 8198 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt Log: More build notes Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 17:28:59 UTC (rev 8197) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 17:30:10 UTC (rev 8198) @@ -198,16 +198,28 @@ make ---- + +This builds the stand-alone +md+ program. You can test it with ++test-md-*.sh+. +2. Run: ++ +---- +make swift-pkg +---- ++ This builds the Tcl package by: + a. Running SWIG to expose the core +simulate()+ function to Tcl; b. Compiling the SWIG-generated wrapper code and linking it as a Tcl package. -2. +cd+ back to +examples/05-md/+. -3. The +md.swift+ library shows the calling sequence for MD. -4. The +run-md.swift+ script shows how to call MD once. The output ++ +You can test the Tcl function with +./test-md.tcl+, which simply loads +the package and calls +simulate+ once. + +3. +cd+ back to +examples/05-md/+. +4. The +md.swift+ library shows the calling sequence for MD. +5. The +run-md.swift+ script shows how to call MD once. The output files are indicated in the script, in addition to the usual +output.txt+. Run this with +./run-*-md.sh+. -5. A concurrent ensemble of simulations is launched by +6. A concurrent ensemble of simulations is launched by +run-mds.swift+. This script accepts many arguments on the command line: see +run-*-mds.sh+. From wozniak at ci.uchicago.edu Thu Aug 14 12:30:17 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:30:17 -0500 (CDT) Subject: [Swift-commit] r8199 - SwiftTutorials/ATPESC_2014-08-14 Message-ID: <20140814173017.7C7F69D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:30:17 -0500 (Thu, 14 Aug 2014) New Revision: 8199 Modified: SwiftTutorials/ATPESC_2014-08-14/tutorial.txt Log: Fix link Modified: SwiftTutorials/ATPESC_2014-08-14/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/tutorial.txt 2014-08-14 17:30:10 UTC (rev 8198) +++ SwiftTutorials/ATPESC_2014-08-14/tutorial.txt 2014-08-14 17:30:17 UTC (rev 8199) @@ -4,4 +4,4 @@ This is the Swift tutorial for http://extremecomputingtraining.anl.gov[ATPESC 2014]. * Swift/K tutorial -* link:swift-t/tutorial.html +* link:./swift-t/tutorial.html[Swift/T tutorial] From wozniak at ci.uchicago.edu Thu Aug 14 12:43:06 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:43:06 -0500 (CDT) Subject: [Swift-commit] r8200 - in SwiftTutorials/ATPESC_2014-08-14/swift-k: . doc Message-ID: <20140814174306.229279D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:43:06 -0500 (Thu, 14 Aug 2014) New Revision: 8200 Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/build-docs.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/swift.css Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README Log: Asciidoc and fixes Copied: SwiftTutorials/ATPESC_2014-08-14/swift-k/build-docs.sh (from rev 8191, SwiftTutorials/ATPESC_2014-08-14/build-docs.sh) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/build-docs.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/build-docs.sh 2014-08-14 17:43:06 UTC (rev 8200) @@ -0,0 +1,3 @@ +#!/bin/sh -eu + +asciidoc --attribute stylesheet=${PWD}/swift.css -a max-width=750px -a textwidth=80 README Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README 2014-08-14 17:30:17 UTC (rev 8199) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README 2014-08-14 17:43:06 UTC (rev 8200) @@ -1,7 +1,7 @@ Swift Tutorial for RCC Midway Cluster ===================================== -//// +//// This is the asciidoc input file. Its content is viewable as a plain-text README file. @@ -59,7 +59,7 @@ the instructions at http://docs.rcc.uchicago.edu/tutorials/intro-to-rcc-workshop.html for more information on using a yubikey to log in. -Once you are logged into the Midway login host, run the following commands +Once you are logged into the Midway login host, run the following commands to set up your environment. ----- @@ -67,7 +67,7 @@ $ wget http://swiftlang.org/tutorials/midway/swift-midway-tutorial.tar.gz $ tar xvfz swift-midway-tutorial.tar.gz $ cd swift-midway-tutorial -$ source setup.sh +$ source setup.sh ----- Verify your environment @@ -117,7 +117,7 @@ -b|--bias offset bias: add this integer to all results -B|--biasfile file of integer biases to add to results -l|--log generate a log in stderr if not null - -n|--nvalues print this many values per simulation + -n|--nvalues print this many values per simulation -r|--range range (limit) of generated results -s|--seed use this integer [0..32767] as a seed -S|--seedfile use this file (containing integer seeds [0..32767]) one per line @@ -152,7 +152,7 @@ 51 $ head -5 log -Called as: /home/davidkelly999/swift-midway-tutorial/app/simulate: +Called as: /home/davidkelly999/swift-midway-tutorial/app/simulate: Start time: Mon Dec 2 13:47:41 CST 2013 Running as user: uid=88848(davidkelly999) gid=88848(davidkelly999) groups=88848(davidkelly999),10008(rcc),10030(pi-gavoth),10031(sp-swift),10036(swift),10058(pi-joshuaelliott),10084(pi-wilde),10118(cron-account),10124(cmts),10138(cmtsworkshop) @@ -274,7 +274,7 @@ .p1.swift ----- -sys::[cat ../part01/p1.swift] +sys::[cat ./part01/p1.swift] ----- @@ -287,10 +287,10 @@ RunID: 20130827-1413-oa6fdib2 Progress: time: Tue, 27 Aug 2013 14:13:33 -0500 Final status: Tue, 27 Aug 2013 14:13:33 -0500 Finished successfully:1 -$ cat sim.out +$ cat sim.out 84 $ swift p1.swift -$ cat sim.out +$ cat sim.out 36 ----- @@ -317,7 +317,7 @@ .p2.swift ----- -sys::[cat ../part02/p2.swift] +sys::[cat ./part02/p2.swift] ----- The script also shows an @@ -360,7 +360,7 @@ .p3.swift ---- -sys::[cat ../part03/p3.swift] +sys::[cat ./part03/p3.swift] ---- To run: @@ -390,8 +390,8 @@ int values = toInt(arg("values","5")); ----- -Now we can specify that more runs should be performed and that each should run -for more timesteps, and produce more that one value each, within a specified range, +Now we can specify that more runs should be performed and that each should run +for more timesteps, and produce more that one value each, within a specified range, using command line arguments placed after the Swift script name in the form `-parameterName=value`: ----- @@ -437,7 +437,7 @@ Now try running (`-nsim=`) 100 simulations of (`-steps=`) 1 second each: ----- -$ swift p3.swift -nsim=100 -steps=1 +$ swift p3.swift -nsim=100 -steps=1 Swift 0.94.1 RC2 swift-r6895 cog-r3765 RunID: 20130827-1444-rq809ts6 @@ -464,9 +464,9 @@ Part 4: Running a parallel ensemble on Midway compute nodes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -`p4.swift` will run our mock "simulation" applications on Midway -compute nodes. The script is similar to as `p3.swift`, but specifies -that each simulation app invocation should additionally return the +`p4.swift` will run our mock "simulation" applications on Midway +compute nodes. The script is similar to as `p3.swift`, but specifies +that each simulation app invocation should additionally return the log file which the application writes to `stderr`. Now when you run `swift p4.swift` you'll see that two types output @@ -481,7 +481,7 @@ Start time: Mon Dec 2 12:17:06 CST 2013 Running as user: uid=88848(davidkelly999) gid=88848(davidkelly999) groups=88848(davidkelly999),10008(rcc),10030(pi-gavoth),10031(sp-swift),10036(swift),10058(pi-joshuaelliott),10084(pi-wilde),10118(cron-account),10124(cmts),10138(cmtsworkshop) Running on node: midway002 -Node IP address: 10.50.181.2 172.25.181.2 +Node IP address: 10.50.181.2 172.25.181.2 Simulation parameters: @@ -510,9 +510,9 @@ Consider for example that Midway has several Slurm partitions. The sandyb partition has 16 cores, and the westmere partition has 12 cores. Depending on the application and which partitions are busy, you may want to modify -where you run. +where you run. -Here is an example of the swift.properties in the part04 directory: +Here is an example of the swift.properties in the part04 directory: ----- site=westmere @@ -521,7 +521,7 @@ ----- The first line, site=westmere, allows you to define which partition to run on. Swift includes -templates for each partition that provides some reasonable default values. Other valid partitions +templates for each partition that provides some reasonable default values. Other valid partitions are amd, bigmem, gpu, local, and sandyb. The second and third line override some of the default values, by specifying a reservation that will @@ -537,7 +537,7 @@ Performing larger Swift runs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -To test with larger runs, there are two changes that are required. The first is a +To test with larger runs, there are two changes that are required. The first is a change to the command line arguments. The example below will run 1000 simulations with each simulation taking 5 seconds. @@ -556,7 +556,7 @@ After each Swift run, a new run directory is created called runNNN. Each run directory will have a log file with a similar name called -runNNN.log. Once you have identified the log file name, run the +runNNN.log. Once you have identified the log file name, run the command `plot.sh` ` to generate the plots for that specific run. For example: @@ -569,7 +569,7 @@ $ ls apps cf p3-20131202-2004-0kh4ha6e.d run000.log sites.xml -$ plot.sh run000.log +$ plot.sh run000.log ----- This yields plots like: @@ -595,7 +595,7 @@ .p6.swift ---- -sys::[cat ../part06/p6.swift] +sys::[cat ./part06/p6.swift] ---- Note that the workflow is based on data flow dependencies: each simulation depends on the seed value, calculated in this statement: @@ -714,4 +714,3 @@ bias values as is needed for each simulation. As a further exercise, modify the script to generate a unique seed value for each simulation, which is a common practice in ensemble computations. - Copied: SwiftTutorials/ATPESC_2014-08-14/swift-k/swift.css (from rev 8192, SwiftTutorials/ATPESC_2014-08-14/swift.css) =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/swift.css (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/swift.css 2014-08-14 17:43:06 UTC (rev 8200) @@ -0,0 +1,10 @@ + +/* SWIFT/T GUIDE CUSTOMIZATIONS */ + +a:visited { + color: gray; +} +h5 { + font-size: 0.8em; +} + From wozniak at ci.uchicago.edu Thu Aug 14 12:43:18 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:43:18 -0500 (CDT) Subject: [Swift-commit] r8201 - www/ATPESC_2014 Message-ID: <20140814174318.71FC79D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:43:18 -0500 (Thu, 14 Aug 2014) New Revision: 8201 Added: www/ATPESC_2014/swift-k/ Log: Adding swift-k From wozniak at ci.uchicago.edu Thu Aug 14 12:43:36 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:43:36 -0500 (CDT) Subject: [Swift-commit] r8202 - www/ATPESC_2014/swift-k Message-ID: <20140814174336.4A2319D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:43:36 -0500 (Thu, 14 Aug 2014) New Revision: 8202 Added: www/ATPESC_2014/swift-k/README.html Log: Adding swift-k/README.html Added: www/ATPESC_2014/swift-k/README.html =================================================================== --- www/ATPESC_2014/swift-k/README.html (rev 0) +++ www/ATPESC_2014/swift-k/README.html 2014-08-14 17:43:36 UTC (rev 8202) @@ -0,0 +1,1568 @@ + + + + + +Swift Tutorial for RCC Midway Cluster + + + + + +
+
+
+ +
+
+
+

Introduction: Why Parallel Scripting?

+
+

Swift is a simple scripting language for executing many instances of +ordinary application programs on distributed parallel resources. +Swift scripts run many copies of ordinary programs concurrently, using +statements like this:

+
+
+
foreach protein in proteinList {
+  runBLAST(protein);
+}
+
+

Swift acts like a structured "shell" language. It runs programs +concurrently as soon as their inputs are available, reducing the need +for complex parallel programming. Swift expresses your workflow in a +portable fashion: The same script runs on multicore computers, +clusters, clouds, grids, and supercomputers.

+

In this tutorial, you’ll be able to first try a few Swift examples +(parts 1-3) on a Midway login host, to get a sense of the +language. Then in parts 4-6 you’ll run similar workflows on Midway +compute nodes, and see how more complex workflows can be expressed +with Swift scripts.

+
+
+
+

Swift tutorial setup

+
+

If you are using a temporary/guest account to access Midway, follow +the instructions at http://docs.rcc.uchicago.edu/tutorials/intro-to-rcc-workshop.html +for more information on using a yubikey to log in.

+

Once you are logged into the Midway login host, run the following commands +to set up your environment.

+
+
+
$ cd $HOME
+$ wget http://swiftlang.org/tutorials/midway/swift-midway-tutorial.tar.gz
+$ tar xvfz swift-midway-tutorial.tar.gz
+$ cd swift-midway-tutorial
+$ source setup.sh
+
+
+

Verify your environment

+

To verify that Swift loaded, do:

+
+
+
$ swift -version  # verify that you have Swift 0.95 RC1
+
+
+ + + +
+
Note
+
If you re-login or open new ssh sessions, you must re-run source setup.sh in each ssh shell/window.
+
+
+
+

To check out the tutorial scripts from SVN

+

If you later want to get the most recent version of this tutorial from +the Swift Subversion repository, do:

+
+
+
$ svn co https://svn.ci.uchicago.edu/svn/vdl2/SwiftTutorials/swift-midway-tutorial
+
+

This will create a directory called "swift-midway-tutorial" which contains all of the +files used in this tutorial.

+
+
+
+
+

Simple "science applications" for the workflow tutorial

+
+

This tutorial is based on two intentionally trivial example programs, +simulation and stats, (implemented as bash shell scripts) +that serve as easy-to-understand proxies for real science +applications. These "programs" behave as follows.

+
+

simulate.sh

+

The simulation script serves as a trivial proxy for any more +complex scientific simulation application. It generates and prints a +set of one or more random integers in the range [0-2^62) as controlled +by its command line arguments, which are:

+
+
+
$ simulate -help
+simulate: usage:
+    -b|--bias       offset bias: add this integer to all results
+    -B|--biasfile   file of integer biases to add to results
+    -l|--log        generate a log in stderr if not null
+    -n|--nvalues    print this many values per simulation
+    -r|--range      range (limit) of generated results
+    -s|--seed       use this integer [0..32767] as a seed
+    -S|--seedfile   use this file (containing integer seeds [0..32767]) one per line
+    -t|--timesteps  number of simulated "timesteps" in seconds (determines runtime)
+    -x|--scale      scale the results by this integer
+    -h|-?|?|--help  print this help
+
+

All of these arguments are optional, with default values indicated above as [n].

+

With no arguments, simulate prints 1 number in the range of +1-100. Otherwise it generates n numbers of the form (R*scale)+bias +where R is a random integer. By default it logs information about its +execution environment to stderr. Here’s some examples of its usage:

+
+
+
$ simulate 2>log
+      51
+$ head -5 log
+
+Called as: /home/davidkelly999/swift-midway-tutorial/app/simulate:
+Start time: Mon Dec  2 13:47:41 CST 2013
+Running as user: uid=88848(davidkelly999) gid=88848(davidkelly999) groups=88848(davidkelly999),10008(rcc),10030(pi-gavoth),10031(sp-swift),10036(swift),10058(pi-joshuaelliott),10084(pi-wilde),10118(cron-account),10124(cmts),10138(cmtsworkshop)
+
+$ simulate -n 4 -r 1000000 2>log
+  239454
+  386702
+   13849
+  873526
+
+$ simulate -n 3 -r 1000000 -x 100 2>log
+ 6643700
+62182300
+ 5230600
+
+$ simulate -n 2 -r 1000 -x 1000 2>log
+  565000
+  636000
+
+$ time simulate -n 2 -r 1000 -x 1000 -t 3 2>log
+  336000
+  320000
+real    0m3.012s
+user    0m0.005s
+sys     0m0.006s
+
+
+
+

stats

+

The stats script serves as a trivial model of an "analysis" +program. It reads N files each containing M integers and simply prints +the average of all those numbers to stdout. Similarly to simulate +it logs environmental information to the stderr.

+
+
+
$ ls f*
+f1  f2  f3  f4
+
+$ cat f*
+25
+60
+40
+75
+
+$ stats f* 2>log
+50
+
+
+
+
+
+

Basic of the Swift language with local execution

+
+
+

A Summary of Swift in a nutshell

+
    +
  • +

    +Swift scripts are text files ending in .swift The swift command +runs on any host, and executes these scripts. swift is a Java +application, which you can install almost anywhere. On Linux, just +unpack the distribution tar file and add its bin/ directory to +your PATH. +

    +
  • +
  • +

    +Swift scripts run ordinary applications, just like shell scripts +do. Swift makes it easy to run these applications on parallel and +remote computers (from laptops to supercomputers). If you can ssh to +the system, Swift can likely run applications there. +

    +
  • +
  • +

    +The details of where to run applications and how to get files back +and forth are described in configuration files separate from your +program. Swift speaks ssh, PBS, Condor, SLURM, LSF, SGE, Cobalt, and +Globus to run applications, and scp, http, ftp, and GridFTP to move +data. +

    +
  • +
  • +

    +The Swift language has 5 main data types: boolean, int, +string, float, and file. Collections of these are dynamic, +sparse arrays of arbitrary dimension and structures of scalars and/or +arrays defined by the type declaration. +

    +
  • +
  • +

    +Swift file variables are "mapped" to external files. Swift sends +files to and from remote systems for you automatically. +

    +
  • +
  • +

    +Swift variables are "single assignment": once you set them you can’t +change them (in a given block of code). This makes Swift a natural, +"parallel data flow" language. This programming model keeps your +workflow scripts simple and easy to write and understand. +

    +
  • +
  • +

    +Swift lets you define functions to "wrap" application programs, and +to cleanly structure more complex scripts. Swift app functions take +files and parameters as inputs and return files as outputs. +

    +
  • +
  • +

    +A compact set of built-in functions for string and file +manipulation, type conversions, high level IO, etc. is provided. +Swift’s equivalent of printf() is tracef(), with limited and +slightly different format codes. +

    +
  • +
  • +

    +Swift’s foreach {} statement is the main parallel workhorse of the +language, and executes all iterations of the loop concurrently. The +actual number of parallel tasks executed is based on available +resources and settable "throttles". +

    +
  • +
  • +

    +In fact, Swift conceptually executes all the statements, +expressions and function calls in your program in parallel, based on +data flow. These are similarly throttled based on available resources +and settings. +

    +
  • +
  • +

    +Swift also has if and switch statements for conditional +execution. These are seldom needed in simple workflows but they enable +very dynamic workflow patterns to be specified. +

    +
  • +
+

We’ll see many of these points in action in the examples below. Lets +get started!

+
+
+

Part 1: Run a single application under Swift

+

The first swift script, p1.swift, runs simulate to generate a +single random number. It writes the number to a file.

+
+
+p1 workflow +
+
+
+
p1.swift
+
+
type file;
+
+app (file o) simulation ()
+{
+  simulate stdout=filename(o);
+}
+
+file f <"sim.out">;
+f = simulation();
+
+

To run this script, run the following command:

+
+
+
$ cd part01
+$ swift p1.swift
+Swift 0.94.1 RC2 swift-r6895 cog-r3765
+
+RunID: 20130827-1413-oa6fdib2
+Progress:  time: Tue, 27 Aug 2013 14:13:33 -0500
+Final status: Tue, 27 Aug 2013 14:13:33 -0500  Finished successfully:1
+$ cat sim.out
+      84
+$ swift p1.swift
+$ cat sim.out
+      36
+
+

To cleanup the directory and remove all outputs (including the log +files and directories that Swift generates), run the cleanup script +which is located in the tutorial PATH:

+
+
+
$ cleanup
+
+
+ + + +
+
Note
+
You’ll also find a Swift configuration file in each partNN +directory of this tutorial. This file specifies the environment-specific +details of how to run. These files will be explained in more +detail in parts 4-6, and can be ignored for now.
+
+
+
+

Part 2: Running an ensemble of many apps in parallel with a "foreach" loop

+

The p2.swift script introduces the foreach parallel iteration +construct to run many concurrent simulations.

+
+
+part02.png +
+
+
+
p2.swift
+
+
type file;
+
+app (file o) simulation ()
+{
+  simulate stdout=filename(o);
+}
+
+foreach i in [0:9] {
+  file f <single_file_mapper; file=strcat("output/sim_",i,".out")>;
+  f = simulation();
+}
+
+

The script also shows an +example of naming the output files of an ensemble run. In this case, the output files will be named +output/sim_N.out.

+

To run the script and view the output:

+
+
+
$ cd ../part02
+$ swift p2.swift
+$ ls output
+sim_0.out  sim_1.out  sim_2.out  sim_3.out  sim_4.out  sim_5.out  sim_6.out  sim_7.out  sim_8.out  sim_9.out
+$ more output/*
+::::::::::::::
+output/sim_0.out
+::::::::::::::
+      44
+::::::::::::::
+output/sim_1.out
+::::::::::::::
+      55
+...
+::::::::::::::
+output/sim_9.out
+::::::::::::::
+      82
+
+
+
+

Part 3: Analyzing results of a parallel ensemble

+

After all the parallel simulations in an ensemble run have completed, +its typically necessary to gather and analyze their results with some +kind of post-processing analysis program or script. p3.swift +introduces such a postprocessing step. In this case, the files created +by all of the parallel runs of simulation will be averaged by by +the trivial "analysis application" stats:

+
+
+part03.png +
+
+
+
p3.swift
+
+
type file;
+
+app (file o) simulation (int sim_steps, int sim_range, int sim_values)
+{
+  simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=filename(o);
+}
+
+app (file o) analyze (file s[])
+{
+  stats filenames(s) stdout=filename(o);
+}
+
+int nsim   = toInt(arg("nsim","10"));
+int steps  = toInt(arg("steps","1"));
+int range  = toInt(arg("range","100"));
+int values = toInt(arg("values","5"));
+
+file sims[];
+
+foreach i in [0:nsim-1] {
+  file simout <single_file_mapper; file=strcat("output/sim_",i,".out")>;
+  simout = simulation(steps,range,values);
+  sims[i] = simout;
+}
+
+file stats<"output/average.out">;
+stats = analyze(sims);
+
+

To run:

+
+
+
$ cd part03
+$ swift p3.swift
+
+

Note that in p3.swift we expose more of the capabilities of the +simulate application to the simulation() app function:

+
+
+
app (file o) simulation (int sim_steps, int sim_range, int sim_values)
+{
+  simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=@filename(o);
+}
+
+

p3.swift also shows how to fetch application-specific values from +the swift command line in a Swift script using arg() which +accepts a keyword-style argument and its default value:

+
+
+
int nsim   = toInt(arg("nsim","10"));
+int steps  = toInt(arg("steps","1"));
+int range  = toInt(arg("range","100"));
+int values = toInt(arg("values","5"));
+
+

Now we can specify that more runs should be performed and that each should run +for more timesteps, and produce more that one value each, within a specified range, +using command line arguments placed after the Swift script name in the form -parameterName=value:

+
+
+
$ swift p3.swift -nsim=3 -steps=10 -values=4 -range=1000000
+
+Swift 0.94.1 RC2 swift-r6895 cog-r3765
+
+RunID: 20130827-1439-s3vvo809
+Progress:  time: Tue, 27 Aug 2013 14:39:42 -0500
+Progress:  time: Tue, 27 Aug 2013 14:39:53 -0500  Active:2  Stage out:1
+Final status: Tue, 27 Aug 2013 14:39:53 -0500  Finished successfully:4
+
+$ ls output/
+average.out  sim_0.out  sim_1.out  sim_2.out
+$ more output/*
+::::::::::::::
+output/average.out
+::::::::::::::
+651368
+::::::::::::::
+output/sim_0.out
+::::::::::::::
+  735700
+  886206
+  997391
+  982970
+::::::::::::::
+output/sim_1.out
+::::::::::::::
+  260071
+  264195
+  869198
+  933537
+::::::::::::::
+output/sim_2.out
+::::::::::::::
+  201806
+  213540
+  527576
+  944233
+
+

Now try running (-nsim=) 100 simulations of (-steps=) 1 second each:

+
+
+
$ swift p3.swift -nsim=100 -steps=1
+Swift 0.94.1 RC2 swift-r6895 cog-r3765
+
+RunID: 20130827-1444-rq809ts6
+Progress:  time: Tue, 27 Aug 2013 14:44:55 -0500
+Progress:  time: Tue, 27 Aug 2013 14:44:56 -0500  Selecting site:79  Active:20  Stage out:1
+Progress:  time: Tue, 27 Aug 2013 14:44:58 -0500  Selecting site:58  Active:20  Stage out:1  Finished successfully:21
+Progress:  time: Tue, 27 Aug 2013 14:44:59 -0500  Selecting site:37  Active:20  Stage out:1  Finished successfully:42
+Progress:  time: Tue, 27 Aug 2013 14:45:00 -0500  Selecting site:16  Active:20  Stage out:1  Finished successfully:63
+Progress:  time: Tue, 27 Aug 2013 14:45:02 -0500  Active:15  Stage out:1  Finished successfully:84
+Progress:  time: Tue, 27 Aug 2013 14:45:03 -0500  Finished successfully:101
+Final status: Tue, 27 Aug 2013 14:45:03 -0500  Finished successfully:101
+
+

We can see from Swift’s "progress" status that the tutorial’s default +parameters for local execution allow Swift to run up to 20 +application invocations concurrently on the login node. We’ll look at +this in more detail in the next sections where we execute applications +on the site’s compute nodes.

+
+
+
+
+

Running applications on Midway compute nodes with Swift

+
+
+

Part 4: Running a parallel ensemble on Midway compute nodes

+

p4.swift will run our mock "simulation" applications on Midway +compute nodes. The script is similar to as p3.swift, but specifies +that each simulation app invocation should additionally return the +log file which the application writes to stderr.

+

Now when you run swift p4.swift you’ll see that two types output +files will placed in the output/ directory: sim_N.out and +sim_N.log. The log files provide data on the runtime environment of +each app invocation. For example:

+
+
+
$ cat output/sim_0.log
+Called as: /home/davidkelly999/swift-midway-tutorial/app/simulate: --timesteps 1 --range 100 --nvalues 5
+
+Start time: Mon Dec  2 12:17:06 CST 2013
+Running as user: uid=88848(davidkelly999) gid=88848(davidkelly999) groups=88848(davidkelly999),10008(rcc),10030(pi-gavoth),10031(sp-swift),10036(swift),10058(pi-joshuaelliott),10084(pi-wilde),10118(cron-account),10124(cmts),10138(cmtsworkshop)
+Running on node: midway002
+Node IP address: 10.50.181.2 172.25.181.2
+
+Simulation parameters:
+
+bias=0
+biasfile=none
+initseed=none
+log=yes
+paramfile=none
+range=100
+scale=1
+seedfile=none
+timesteps=1
+output width=8
+
+Environment:
+
+ANTLR_ROOT=/software/antlr-2.7-el6-x86_64
+ANT_HOME=/software/ant-1.8.4-all
+ANT_HOME_modshare=/software/ant-1.8.4-all:3
+...
+
+

Swift’s swift.properties configuration file allows many parameters to +specify how jobs should be run on a given cluster.

+

Consider for example that Midway has several Slurm partitions. The sandyb +partition has 16 cores, and the westmere partition has 12 cores. Depending +on the application and which partitions are busy, you may want to modify +where you run.

+

Here is an example of the swift.properties in the part04 directory:

+
+
+
site=westmere
+site.westmere.slurm.reservation=workshop
+site.westmere.slurm.exclusive=false
+
+

The first line, site=westmere, allows you to define which partition to run on. Swift includes +templates for each partition that provides some reasonable default values. Other valid partitions +are amd, bigmem, gpu, local, and sandyb.

+

The second and third line override some of the default values, by specifying a reservation that will +be used for this session, and enabling node sharing.

+

Try changing the queue to run on the sandyb queue. The new swift.properties should look like this:

+
+
+
site=sandyb
+site.sandyb.slurm.reservation=workshop
+site.sandyb.slurm.exclusive=false
+
+
+
+

Performing larger Swift runs

+

To test with larger runs, there are two changes that are required. The first is a +change to the command line arguments. The example below will run 1000 simulations +with each simulation taking 5 seconds.

+
+
+
$ swift p6.swift -steps=5 -nsim=1000
+
+
+
+

Plotting run activity

+

The tutorial bin directory in your PATH provides a script +plot.sh to plot the progress of a Swift script. It generates two +image files: activeplot.png, which shows the number of active jobs +over time, and cumulativeplot.png, which shows the total number of +app calls completed as the Swift script progresses.

+

After each Swift run, a new run directory is created called runNNN. +Each run directory will have a log file with a similar name called +runNNN.log. Once you have identified the log file name, run the +command plot.sh <logfile>` to generate the plots for that +specific run. For example:

+
+
+
$ ls
+output  p3.swift  run000  swift.properties
+
+$ cd run000/
+
+$ ls
+apps  cf  p3-20131202-2004-0kh4ha6e.d  run000.log  sites.xml
+
+$ plot.sh run000.log
+
+

This yields plots like:

+
+
+width=700 +
+
+
+
+width=700 +
+
+
+
+

Part 5: Controlling the compute-node pools where applications run

+

This section is under development.

+
+
+

Part 6: Specifying more complex workflow patterns

+

p6.swift expands the workflow pattern of p4.swift to add additional +stages to the workflow. Here, we generate a dynamic seed value that +will be used by all of the simulations, and for each simulation, we +run an pre-processing application to generate a unique "bias +file". This pattern is shown below, followed by the Swift script.

+
+
+part06.png +
+
+
+
p6.swift
+
+
type file;
+
+# app() functions for application programs to be called:
+
+app (file out) genseed (int nseeds)
+{
+  simulate "-r" 2000000 "-n" nseeds stdout=@out;
+}
+
+app (file out) genbias (int bias_range, int nvalues)
+{
+  simulate "-r" bias_range "-n" nvalues stdout=@out;
+}
+
+app (file out, file log) simulation (int timesteps, int sim_range, file bias_file,
+                                     int scale, int sim_count, file seed_file)
+{
+  simulate "-t" timesteps "-r" sim_range "-B" @bias_file "-x" scale
+           "-n" sim_count "-S" @seed_file stdout=@out stderr=@log;
+}
+
+app (file out, file log) analyze (file s[])
+{
+  stats filenames(s) stdout=@out stderr=@log;
+}
+
+# Command line arguments
+
+int   nsim = toInt(arg("nsim",   "10"));  # number of simulation programs to run
+int  steps = toInt(arg("steps",  "1"));   # number of timesteps (seconds) per simulation
+int  range = toInt(arg("range",  "100")); # range of the generated random numbers
+int values = toInt(arg("values", "10"));  # number of values generated per simulation
+
+# Main script and data
+file seedfile <"output/seed.dat">;        # Dynamically generated bias for simulation ensemble
+
+tracef("\n*** Script parameters: nsim=%i range=%i num values=%i\n\n", nsim, range, values);
+seedfile = genseed(1);
+
+file sims[];                      # Array of files to hold each simulation output
+
+foreach i in [0:nsim-1] {
+  file biasfile <single_file_mapper; file=strcat("output/bias_",i,".dat")>;
+  file simout   <single_file_mapper; file=strcat("output/sim_",i,".out")>;
+  file simlog   <single_file_mapper; file=strcat("output/sim_",i,".log")>;
+  biasfile = genbias(1000, 20);
+  (simout,simlog) = simulation(steps, range, biasfile, 1000000, values, seedfile);
+  sims[i] = simout;
+}
+
+file stats_out<"output/average.out">;
+file stats_log<"output/average.log">;
+(stats_out,stats_log) = analyze(sims);
+
+

Note that the workflow is based on data flow dependencies: each simulation depends on the seed value, calculated in this statement:

+
+
+
seedfile = genseed(1);
+
+

and on the bias file, computed and then consumed in these two dependent statements:

+
+
+
  biasfile = genbias(1000, 20);
+  (simout,simlog) = simulation(steps, range, biasfile, 1000000, values, seedfile);
+
+

To run:

+
+
+
$ cd ../part06
+$ swift p6.swift
+
+

The default parameters result in the following execution log:

+
+
+
$ swift p6.swift
+Swift 0.94.1 RC2 swift-r6895 cog-r3765
+
+RunID: 20130827-1917-jvs4gqm5
+Progress:  time: Tue, 27 Aug 2013 19:17:56 -0500
+
+*** Script parameters: nsim=10 range=100 num values=10
+
+Progress:  time: Tue, 27 Aug 2013 19:17:57 -0500  Stage in:1  Submitted:10
+Generated seed=382537
+Progress:  time: Tue, 27 Aug 2013 19:17:59 -0500  Active:9  Stage out:1  Finished successfully:11
+Final status: Tue, 27 Aug 2013 19:18:00 -0500  Finished successfully:22
+
+

which produces the following output:

+
+
+
$ ls -lrt output
+total 264
+-rw-r--r-- 1 p01532 61532     9 Aug 27 19:17 seed.dat
+-rw-r--r-- 1 p01532 61532   180 Aug 27 19:17 bias_9.dat
+-rw-r--r-- 1 p01532 61532   180 Aug 27 19:17 bias_8.dat
+-rw-r--r-- 1 p01532 61532   180 Aug 27 19:17 bias_7.dat
+-rw-r--r-- 1 p01532 61532   180 Aug 27 19:17 bias_6.dat
+-rw-r--r-- 1 p01532 61532   180 Aug 27 19:17 bias_5.dat
+-rw-r--r-- 1 p01532 61532   180 Aug 27 19:17 bias_4.dat
+-rw-r--r-- 1 p01532 61532   180 Aug 27 19:17 bias_3.dat
+-rw-r--r-- 1 p01532 61532   180 Aug 27 19:17 bias_2.dat
+-rw-r--r-- 1 p01532 61532   180 Aug 27 19:17 bias_1.dat
+-rw-r--r-- 1 p01532 61532   180 Aug 27 19:17 bias_0.dat
+-rw-r--r-- 1 p01532 61532    90 Aug 27 19:17 sim_9.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_9.log
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_8.log
+-rw-r--r-- 1 p01532 61532    90 Aug 27 19:17 sim_7.out
+-rw-r--r-- 1 p01532 61532    90 Aug 27 19:17 sim_6.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_6.log
+-rw-r--r-- 1 p01532 61532    90 Aug 27 19:17 sim_5.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_5.log
+-rw-r--r-- 1 p01532 61532    90 Aug 27 19:17 sim_4.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_4.log
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_1.log
+-rw-r--r-- 1 p01532 61532    90 Aug 27 19:18 sim_8.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:18 sim_7.log
+-rw-r--r-- 1 p01532 61532    90 Aug 27 19:18 sim_3.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:18 sim_3.log
+-rw-r--r-- 1 p01532 61532    90 Aug 27 19:18 sim_2.out
+-rw-r--r-- 1 p01532 61532 14898 Aug 27 19:18 sim_2.log
+-rw-r--r-- 1 p01532 61532    90 Aug 27 19:18 sim_1.out
+-rw-r--r-- 1 p01532 61532    90 Aug 27 19:18 sim_0.out
+-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:18 sim_0.log
+-rw-r--r-- 1 p01532 61532     9 Aug 27 19:18 average.out
+-rw-r--r-- 1 p01532 61532 14675 Aug 27 19:18 average.log
+
+

Each sim_N.out file is the sum of its bias file plus newly "simulated" random output scaled by 1,000,000:

+
+
+
$ cat output/bias_0.dat
+     302
+     489
+      81
+     582
+     664
+     290
+     839
+     258
+     506
+     310
+     293
+     508
+      88
+     261
+     453
+     187
+      26
+     198
+     402
+     555
+
+$ cat output/sim_0.out
+64000302
+38000489
+32000081
+12000582
+46000664
+36000290
+35000839
+22000258
+49000506
+75000310
+
+

We produce 20 values in each bias file. Simulations of less than that +number of values ignore the unneeded number, while simualtions of more +than 20 will use the last bias number for all remoaining values past +20. As an exercise, adjust the code to produce the same number of +bias values as is needed for each simulation. As a further exercise, +modify the script to generate a unique seed value for each simulation, +which is a common practice in ensemble computations.

+
+
+
+
+

+ + + From wozniak at ci.uchicago.edu Thu Aug 14 12:44:34 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:44:34 -0500 (CDT) Subject: [Swift-commit] r8203 - www/ATPESC_2014 Message-ID: <20140814174434.4254B9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:44:34 -0500 (Thu, 14 Aug 2014) New Revision: 8203 Modified: www/ATPESC_2014/tutorial.html Log: Add Swift/K link Modified: www/ATPESC_2014/tutorial.html =================================================================== --- www/ATPESC_2014/tutorial.html 2014-08-14 17:43:36 UTC (rev 8202) +++ www/ATPESC_2014/tutorial.html 2014-08-14 17:44:34 UTC (rev 8203) @@ -752,7 +752,7 @@
  • -Swift/K tutorial +Swift/K tutorial

  • @@ -767,7 +767,7 @@

    From wozniak at ci.uchicago.edu Thu Aug 14 12:48:18 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:48:18 -0500 (CDT) Subject: [Swift-commit] r8204 - www/ATPESC_2014/swift-k Message-ID: <20140814174818.7AAEE9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:48:18 -0500 (Thu, 14 Aug 2014) New Revision: 8204 Added: www/ATPESC_2014/swift-k/activeplot.png www/ATPESC_2014/swift-k/cumulativeplot.png www/ATPESC_2014/swift-k/part01.png www/ATPESC_2014/swift-k/part02.png www/ATPESC_2014/swift-k/part03.png www/ATPESC_2014/swift-k/part04.png www/ATPESC_2014/swift-k/part05.png www/ATPESC_2014/swift-k/part06.png Log: Adding activeplot.png cumulativeplot.png part01.png part02.png part03.png part04.png part05.png part06.png Added: www/ATPESC_2014/swift-k/activeplot.png =================================================================== (Binary files differ) Property changes on: www/ATPESC_2014/swift-k/activeplot.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: www/ATPESC_2014/swift-k/cumulativeplot.png =================================================================== (Binary files differ) Property changes on: www/ATPESC_2014/swift-k/cumulativeplot.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: www/ATPESC_2014/swift-k/part01.png =================================================================== (Binary files differ) Property changes on: www/ATPESC_2014/swift-k/part01.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: www/ATPESC_2014/swift-k/part02.png =================================================================== (Binary files differ) Property changes on: www/ATPESC_2014/swift-k/part02.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: www/ATPESC_2014/swift-k/part03.png =================================================================== (Binary files differ) Property changes on: www/ATPESC_2014/swift-k/part03.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: www/ATPESC_2014/swift-k/part04.png =================================================================== (Binary files differ) Property changes on: www/ATPESC_2014/swift-k/part04.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: www/ATPESC_2014/swift-k/part05.png =================================================================== (Binary files differ) Property changes on: www/ATPESC_2014/swift-k/part05.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: www/ATPESC_2014/swift-k/part06.png =================================================================== (Binary files differ) Property changes on: www/ATPESC_2014/swift-k/part06.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream From wozniak at ci.uchicago.edu Thu Aug 14 12:49:19 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:49:19 -0500 (CDT) Subject: [Swift-commit] r8205 - www Message-ID: <20140814174919.8DDC09D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:49:19 -0500 (Thu, 14 Aug 2014) New Revision: 8205 Modified: www/push_to.sh Log: Add PNGs Modified: www/push_to.sh =================================================================== --- www/push_to.sh 2014-08-14 17:48:18 UTC (rev 8204) +++ www/push_to.sh 2014-08-14 17:49:19 UTC (rev 8205) @@ -248,6 +248,8 @@ docs/index.php shBrushVDL2.js ATPESC_2014/*.html +ATPESC_2014/**/*.html +ATPESC_2014/**/*.png ) # Make sure destination directory exists From wozniak at ci.uchicago.edu Thu Aug 14 12:51:18 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 12:51:18 -0500 (CDT) Subject: [Swift-commit] r8206 - SwiftTutorials/ATPESC_2014-08-14 Message-ID: <20140814175118.52B7E9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 12:51:18 -0500 (Thu, 14 Aug 2014) New Revision: 8206 Modified: SwiftTutorials/ATPESC_2014-08-14/tutorial.txt Log: Add link Modified: SwiftTutorials/ATPESC_2014-08-14/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/tutorial.txt 2014-08-14 17:49:19 UTC (rev 8205) +++ SwiftTutorials/ATPESC_2014-08-14/tutorial.txt 2014-08-14 17:51:18 UTC (rev 8206) @@ -3,5 +3,5 @@ This is the Swift tutorial for http://extremecomputingtraining.anl.gov[ATPESC 2014]. -* Swift/K tutorial +* link:./swift-k/README[Swift/K tutorial] * link:./swift-t/tutorial.html[Swift/T tutorial] From tga at ci.uchicago.edu Thu Aug 14 14:10:42 2014 From: tga at ci.uchicago.edu (tga at ci.uchicago.edu) Date: Thu, 14 Aug 2014 14:10:42 -0500 (CDT) Subject: [Swift-commit] r8207 - in SwiftTutorials/ATPESC_2014-08-14/swift-t: . examples/01-hello Message-ID: <20140814191042.93C989CC96@svn.ci.uchicago.edu> Author: tga Date: 2014-08-14 14:10:42 -0500 (Thu, 14 Aug 2014) New Revision: 8207 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-local.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt Log: Make it more obvious that this should be run on Cetus/Mira Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-local.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-local.sh 2014-08-14 17:51:18 UTC (rev 8206) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-local.sh 2014-08-14 19:10:42 UTC (rev 8207) @@ -1,6 +1,6 @@ #!/bin/sh -eu -source ../../cfg/setup-local.sh +. ../../cfg/setup-local.sh stc hello.swift turbine hello.tcl Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 17:51:18 UTC (rev 8206) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 19:10:42 UTC (rev 8207) @@ -35,6 +35,9 @@ == Swift/T installations +These instructions assume you will be running a preinstalled version +of Swift/T on Cetus or Mira. + Two Swift/T installations are provided- one that runs on the login node and one that runs on the compute nodes (via Cobalt). The login node installation should be used with caution- expensive computation From tga at ci.uchicago.edu Thu Aug 14 14:16:48 2014 From: tga at ci.uchicago.edu (tga at ci.uchicago.edu) Date: Thu, 14 Aug 2014 14:16:48 -0500 (CDT) Subject: [Swift-commit] r8208 - in SwiftTutorials/ATPESC_2014-08-14/swift-t/examples: 01-hello 02-loop 03-blas 04-py 05-md Message-ID: <20140814191648.0608B9CC96@svn.ci.uchicago.edu> Author: tga Date: 2014-08-14 14:16:47 -0500 (Thu, 14 Aug 2014) New Revision: 8208 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-compute.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-local.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-compute.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-compute.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-local.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-md.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-md.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh Log: Avoid using source - only works in bash (not dash, which is /bin/sh on some systems) Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh 2014-08-14 19:10:42 UTC (rev 8207) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/01-hello/run-compute.sh 2014-08-14 19:16:47 UTC (rev 8208) @@ -1,6 +1,6 @@ #!/bin/sh -eu -source ../../cfg/setup-compute.sh +. ../../cfg/setup-compute.sh SETTINGS=../../cfg/settings-compute.sh PROGRAM=hello Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-compute.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-compute.sh 2014-08-14 19:10:42 UTC (rev 8207) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-compute.sh 2014-08-14 19:16:47 UTC (rev 8208) @@ -1,6 +1,6 @@ #!/bin/bash -eu -source ../../cfg/setup-compute.sh +. ../../cfg/setup-compute.sh SETTINGS=../../cfg/settings-compute.sh PROCS=4 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-local.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-local.sh 2014-08-14 19:10:42 UTC (rev 8207) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/02-loop/run-local.sh 2014-08-14 19:16:47 UTC (rev 8208) @@ -1,6 +1,6 @@ #!/bin/sh -eu -source ../../cfg/setup-local.sh +. ../../cfg/setup-local.sh PROGRAM=loop stc ${PROGRAM}.swift Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh 2014-08-14 19:10:42 UTC (rev 8207) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/build.sh 2014-08-14 19:16:47 UTC (rev 8208) @@ -33,7 +33,7 @@ TCLSH=${TCL_HOME}/bin/tclsh8.5 # This loads many Tcl configuration variables -source ${TCL_CONFIG} +. ${TCL_CONFIG} check "tclConfig.sh failed!" CFLAGS="-fPIC -std=gnu99 -g -I ${CBLAS_INCLUDE}" Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-compute.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-compute.sh 2014-08-14 19:10:42 UTC (rev 8207) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-compute.sh 2014-08-14 19:16:47 UTC (rev 8208) @@ -1,6 +1,6 @@ #!/bin/sh -eu -source ../../cfg/setup-compute.sh +. ../../cfg/setup-compute.sh SETTINGS=../../cfg/settings-compute.sh export TURBINE_USER_LIB=${PWD} Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh 2014-08-14 19:10:42 UTC (rev 8207) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas/run-local.sh 2014-08-14 19:16:47 UTC (rev 8208) @@ -1,6 +1,6 @@ #!/bin/bash -eu -source ../../cfg/setup-local.sh +. ../../cfg/setup-local.sh export TURBINE_USER_LIB=${PWD} Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-compute.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-compute.sh 2014-08-14 19:10:42 UTC (rev 8207) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-compute.sh 2014-08-14 19:16:47 UTC (rev 8208) @@ -1,6 +1,6 @@ #!/bin/sh -eu -source ../../cfg/setup-compute.sh +. ../../cfg/setup-compute.sh SETTINGS=../../cfg/settings-compute.sh PROGRAM=add Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-local.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-local.sh 2014-08-14 19:10:42 UTC (rev 8207) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/run-local.sh 2014-08-14 19:16:47 UTC (rev 8208) @@ -1,6 +1,6 @@ #!/bin/bash -eu -source ../../cfg/setup-local.sh +. ../../cfg/setup-local.sh PROGRAM=add stc ${PROGRAM}.swift Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-md.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-md.sh 2014-08-14 19:10:42 UTC (rev 8207) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-md.sh 2014-08-14 19:16:47 UTC (rev 8208) @@ -1,7 +1,7 @@ #!/bin/bash -eu -source ../../cfg/setup-compute.sh -source setup-md.sh +. ../../cfg/setup-compute.sh +. setup-md.sh SETTINGS=../../cfg/settings-compute.sh PROGRAM=run-md Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh 2014-08-14 19:10:42 UTC (rev 8207) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh 2014-08-14 19:16:47 UTC (rev 8208) @@ -15,8 +15,8 @@ shift done -source ../../cfg/setup-local.sh -source setup-md.sh +. ../../cfg/setup-local.sh +. setup-md.sh SETTINGS=../../cfg/settings-compute.sh PROGRAM=run-mds Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-md.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-md.sh 2014-08-14 19:10:42 UTC (rev 8207) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-md.sh 2014-08-14 19:16:47 UTC (rev 8208) @@ -1,7 +1,7 @@ #!/bin/bash -eu -source ../../cfg/setup-local.sh -source setup-md.sh +. ../../cfg/setup-local.sh +. setup-md.sh PROGRAM=run-md stc ${PROGRAM}.swift Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 19:10:42 UTC (rev 8207) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 19:16:47 UTC (rev 8208) @@ -16,8 +16,8 @@ shift done -source ../../cfg/setup-local.sh -source setup-md.sh +. ../../cfg/setup-local.sh +. setup-md.sh PROGRAM=run-mds stc ${PROGRAM}.swift From tga at ci.uchicago.edu Thu Aug 14 14:20:25 2014 From: tga at ci.uchicago.edu (tga at ci.uchicago.edu) Date: Thu, 14 Aug 2014 14:20:25 -0500 (CDT) Subject: [Swift-commit] r8209 - SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg Message-ID: <20140814192025.C3FAF9CC96@svn.ci.uchicago.edu> Author: tga Date: 2014-08-14 14:20:25 -0500 (Thu, 14 Aug 2014) New Revision: 8209 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-local.sh Log: Allow overriding of install directory Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-local.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-local.sh 2014-08-14 19:16:47 UTC (rev 8208) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/cfg/setup-local.sh 2014-08-14 19:20:25 UTC (rev 8209) @@ -1,5 +1,5 @@ -TOP=/home/wozniak/Public/sfw/ppc64-login +TOP=${SWIFTT_TOP:-/home/wozniak/Public/sfw/ppc64-login} PATH=${TOP}/turbine/bin:${PATH} PATH=${TOP}/stc/bin:${PATH} From wozniak at ci.uchicago.edu Thu Aug 14 14:28:06 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 14:28:06 -0500 (CDT) Subject: [Swift-commit] r8210 - SwiftTutorials/ATPESC_2014-08-14/lecture Message-ID: <20140814192806.05FAE9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 14:28:05 -0500 (Thu, 14 Aug 2014) New Revision: 8210 Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftT.pptx Log: Minor changes Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftT.pptx =================================================================== (Binary files differ) From wozniak at ci.uchicago.edu Thu Aug 14 14:41:06 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 14:41:06 -0500 (CDT) Subject: [Swift-commit] r8211 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140814194106.8C0CA9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 14:41:06 -0500 (Thu, 14 Aug 2014) New Revision: 8211 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt Log: Fix asciidoc syntax Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 19:28:05 UTC (rev 8210) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 19:41:06 UTC (rev 8211) @@ -201,10 +201,10 @@ make ---- + -This builds the stand-alone +md+ program. You can test it with -+test-md-*.sh+. +This builds the stand-alone +md+ program. You can test it with +test-md-*.sh+. + 2. Run: -+ ++ ---- make swift-pkg ---- @@ -220,9 +220,8 @@ 3. +cd+ back to +examples/05-md/+. 4. The +md.swift+ library shows the calling sequence for MD. -5. The +run-md.swift+ script shows how to call MD once. The output -files are indicated in the script, in addition to the usual -+output.txt+. Run this with +./run-*-md.sh+. +5. The +run-md.swift+ script shows how to call MD once. The output files are indicated in the script, in addition to the usual +output.txt+. Run this with +./run-*-md.sh+. 6. A concurrent ensemble of simulations is launched by +run-mds.swift+. This script accepts many arguments on the command line: see +run-*-mds.sh+. + From wilde at ci.uchicago.edu Thu Aug 14 14:41:57 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Thu, 14 Aug 2014 14:41:57 -0500 (CDT) Subject: [Swift-commit] r8212 - SwiftTutorials/ATPESC_2014-08-14/lecture Message-ID: <20140814194157.C885A9CC96@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-14 14:41:57 -0500 (Thu, 14 Aug 2014) New Revision: 8212 Added: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftK.pptx Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_Workflow.pptx Log: Updates to Intro and SwiftK slides. Added: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftK.pptx =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftK.pptx ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_Workflow.pptx =================================================================== (Binary files differ) From wozniak at ci.uchicago.edu Thu Aug 14 14:44:54 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 14:44:54 -0500 (CDT) Subject: [Swift-commit] r8213 - www/ATPESC_2014/swift-t Message-ID: <20140814194454.9A3BE9CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 14:44:54 -0500 (Thu, 14 Aug 2014) New Revision: 8213 Modified: www/ATPESC_2014/swift-t/tutorial.html Log: Minor fix Modified: www/ATPESC_2014/swift-t/tutorial.html =================================================================== --- www/ATPESC_2014/swift-t/tutorial.html 2014-08-14 19:41:57 UTC (rev 8212) +++ www/ATPESC_2014/swift-t/tutorial.html 2014-08-14 19:44:54 UTC (rev 8213) @@ -3,26 +3,29 @@ - + Tutorial: Swift/T @@ -777,24 +575,26 @@

    Files

    -

    The examples are in the examples/ directory.

    -

    Each example directory is numbered from 01 to 05.

    -

    Configuration files are in cfg/. These refer to public +

    The examples are in the examples/ directory.

    +

    Each example directory is numbered from 01 to 05.

    +

    Configuration files are in cfg/. These refer to public installations of Swift/T on Cetus/Mira.

    -

    Each example contains a *.swift Swift script that is the Swift -program. The Swift/T compiler stc translates the Swift script into -an MPI program encoded in a *.tcl file. This is launched by using -the turbine program or a scheduler-specific script, such as the -provided turbine-cobalt-run.zsh script.

    -

    There is also a run-local script to run the Swift script -on the login node and a run-compute script to submit the Swift -program to Cobalt. These scripts add stc and turbine entries to -your PATH automatically.

    +

    Each example contains a *.swift Swift script that is the Swift +program. The Swift/T compiler stc translates the Swift script into +an MPI program encoded in a *.tcl file. This is launched by using +the turbine program or a scheduler-specific script, such as the +provided turbine-cobalt-run.zsh script.

    +

    There is also a run-local script to run the Swift script +on the login node and a run-compute script to submit the Swift +program to Cobalt. These scripts add stc and turbine entries to +your PATH automatically.

    Swift/T installations

    +

    These instructions assume you will be running a preinstalled version +of Swift/T on Cetus or Mira.

    Two Swift/T installations are provided- one that runs on the login node and one that runs on the compute nodes (via Cobalt). The login node installation should be used with caution- expensive computation @@ -810,7 +610,7 @@

    1. -cd into the directory 01-hello +cd into the directory 01-hello

    2. @@ -819,7 +619,7 @@

      -
      ./run-local.sh
      +
      ./run-local.sh
    3. @@ -828,7 +628,7 @@

      -
      /**
      +
      /**
          Example 1 - HELLO.SWIFT
       */
       
      @@ -837,7 +637,7 @@
       main
       {
         printf("Hello world!");
      -}
      +}
    4. @@ -846,26 +646,26 @@

      -
      ./run-compute.sh
      +
      ./run-compute.sh

      This will report something like:

      -
      SETTINGS=../../cfg/settings-compute.sh
      +
      SETTINGS=../../cfg/settings-compute.sh
       TURBINE_OUTPUT=/home/user/turbine-output/2014/08/14/10/06/20
       SCRIPT_NAME=hello.tcl
       NODES=2
       project: ATPESC2014
      -JOB_ID=312170
      +JOB_ID=312170
      -

      Turbine will copy hello.tcl to TURBINE_OUTPUT and run from that +

      Turbine will copy hello.tcl to TURBINE_OUTPUT and run from that directory. The Cobalt log may be found there. Standard output is -directed to TURBINE_OUTPUT/output.txt.

      -

      The contents of output.txt are the Blue Gene runtime output plus the +directed to TURBINE_OUTPUT/output.txt.

      +

      The contents of output.txt are the Blue Gene runtime output plus the Swift-generated line:

      -
      stdout[0]: Hello world!
      +
      stdout[0]: Hello world!
    @@ -875,7 +675,7 @@

    This example shows one way to obtain concurrency from Swift/T.

    -
    /**
    +
    /**
        Example 2 - LOOP.SWIFT
     */
     
    @@ -899,15 +699,15 @@
         j = compute(i);
         printf("compute(%i) = %i", i, j);
       }
    -}
    +}
    -

    The program executes compute() 10 times concurrently, because the -Swift foreach loop is concurrent. The compute() function is +

    The program executes compute() 10 times concurrently, because the +Swift foreach loop is concurrent. The compute() function is implemented as a Tcl fragment that does 3 things:

    1. -Delay progress with after (sleeps for i*1000 milliseconds) +Delay progress with after (sleeps for i*1000 milliseconds)

    2. @@ -921,32 +721,32 @@

    -

    The result value is printed by Swift’s printf().

    -

    Note the use of the <<x>> syntax, which maps Swift variable x to a +

    The result value is printed by Swift’s printf().

    +

    Note the use of the <<x>> syntax, which maps Swift variable x to a Tcl variable.

    This script may be run as the Hello World case, but the run scripts accept Turbine runtime arguments:

    --l +-l

    -Prepend outputs with the MPI rank number (like mpiexec -l) +Prepend outputs with the MPI rank number (like mpiexec -l)

    --n N +-n N

    -Run N MPI processes (like mpiexec -n N). Note that one -process is dedicated for Swift logic, so choose N>1. +Run N MPI processes (like mpiexec -n N). Note that one +process is dedicated for Swift logic, so choose N>1.

    Add more processes and see how that improves time to job -completion. Check output.txt for the ADLB Total Elapsed Time:, +completion. Check output.txt for the ADLB Total Elapsed Time:, which is a good measure of total execution time (discounts queue and allocation startup/shutdown time).

    @@ -964,7 +764,7 @@

    In this example, we use Swift to call a BLAS routine for dot product.

    -
    /**
    +
    /**
        Example 3 - DOT.SWIFT
     */
     
    @@ -997,10 +797,10 @@
         float z = blas_ddot(N, A, B);
     
       printf("\nA*B=%0.1f", z);
    -}
    +}

    In this example, we created a stub of a Swift BLAS library in -blas.swift. This calls the CBLAS cblas_ddot() function through a +blas.swift. This calls the CBLAS cblas_ddot() function through a Tcl interface.

    1. @@ -1009,22 +809,22 @@

      -
      ./build.sh
      +
      ./build.sh

      This creates a Tcl package for BLAS (using a hand-coded method- we could also use SWIG to automate this).

    2. -Run ./run-*.sh. +Run ./run-*.sh.

    -

    In dot.swift, the Swift statement import blas; brings blas.swift -into the program. The Swift call to blas_ddot() operates on the -Swift arrays A and B. In blas.swift, the Swift arrays are -converted to C-compatible arrays of double, which are represented in -Swift/T with the blob type. These are passed to the BLAS package.

    +

    In dot.swift, the Swift statement import blas; brings blas.swift +into the program. The Swift call to blas_ddot() operates on the +Swift arrays A and B. In blas.swift, the Swift arrays are +converted to C-compatible arrays of double, which are represented in +Swift/T with the blob type. These are passed to the BLAS package.

    Thus, calling native code from Swift/T is comparable in complexity to calling native code from other scripting languages such as Tcl or Python.

    @@ -1038,7 +838,7 @@ internally for numerical operations.

    -
    /**
    +
    /**
        Example 4 - ADD.SWIFT
     */
     
    @@ -1066,17 +866,17 @@
       matrix A2 = eye(3);
       matrix sum = add(A1, A2);
       printf("2*eye(3)=%s", sum);
    -}
    +}

    In this example, we also created a stub Swift numerical library in -numpy.swift. This is imported into the main Swift script -add.swift.

    -

    First, this program calls f(), which is a simple use of the +numpy.swift. This is imported into the main Swift script +add.swift.

    +

    First, this program calls f(), which is a simple use of the Swift/T-Python interface. The Python code fragment must return a -value in its last line as a string- in this case, we return "0".

    -

    Second, we use the numpy.swift features. We allocate 2 Numpy arrays +value in its last line as a string- in this case, we return "0".

    +

    Second, we use the numpy.swift features. We allocate 2 Numpy arrays I3 and add them together, producing 2I3.

    -

    Swift/T can call into arbitrary Python modules, just set PYTHONPATH. +

    Swift/T can call into arbitrary Python modules, just set PYTHONPATH. C/C++ code can be easily wrapped for Python with SWIG, Fortran code with SciPy’s F2PY.

    @@ -1092,24 +892,27 @@
    1. -cd to examples/md-src/ and run: +cd to examples/md-src/ and run:

      -
      make
      +
      make
      -

      This builds the stand-alone md program. You can test it with -test-md-*.sh. -2. Run:

      +

      This builds the stand-alone md program. You can test it with test-md-*.sh.

      +
    2. +
    3. +

      +Run: +

      -
      make swift-pkg
      +
      make swift-pkg

      This builds the Tcl package by:

      1. -Running SWIG to expose the core simulate() function to Tcl; +Running SWIG to expose the core simulate() function to Tcl;

      2. @@ -1117,33 +920,31 @@ Compiling the SWIG-generated wrapper code and linking it as a Tcl package.

        -

        You can test the Tcl function with ./test-md.tcl, which simply loads -the package and calls simulate once.

        +

        You can test the Tcl function with ./test-md.tcl, which simply loads +the package and calls simulate once.

    4. -cd back to examples/05-md/. +cd back to examples/05-md/.

    5. -The md.swift library shows the calling sequence for MD. +The md.swift library shows the calling sequence for MD.

    6. -The run-md.swift script shows how to call MD once. The output -files are indicated in the script, in addition to the usual -output.txt. Run this with ./run-*-md.sh. +The run-md.swift script shows how to call MD once. The output files are indicated in the script, in addition to the usual output.txt. Run this with ./run-*-md.sh.

    7. A concurrent ensemble of simulations is launched by -run-mds.swift. This script accepts many arguments on the command -line: see run-*-mds.sh. +run-mds.swift. This script accepts many arguments on the command +line: see run-*-mds.sh.

    @@ -1154,7 +955,7 @@

    From yadunandb at ci.uchicago.edu Thu Aug 14 14:48:21 2014 From: yadunandb at ci.uchicago.edu (yadunandb at ci.uchicago.edu) Date: Thu, 14 Aug 2014 14:48:21 -0500 (CDT) Subject: [Swift-commit] r8214 - SwiftTutorials/ATPESC_2014-08-14 Message-ID: <20140814194821.4C1CC9CC96@svn.ci.uchicago.edu> Author: yadunandb Date: 2014-08-14 14:48:21 -0500 (Thu, 14 Aug 2014) New Revision: 8214 Modified: SwiftTutorials/ATPESC_2014-08-14/tutorial.txt Log: Tutorial page with direction Modified: SwiftTutorials/ATPESC_2014-08-14/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/tutorial.txt 2014-08-14 19:44:54 UTC (rev 8213) +++ SwiftTutorials/ATPESC_2014-08-14/tutorial.txt 2014-08-14 19:48:21 UTC (rev 8214) @@ -3,5 +3,35 @@ This is the Swift tutorial for http://extremecomputingtraining.anl.gov[ATPESC 2014]. -* link:./swift-k/README[Swift/K tutorial] -* link:./swift-t/tutorial.html[Swift/T tutorial] + + +Try swift at Tryswift web interface +----------------------------------- + +* Go to the tryswift webpage http://swift-lang.org/tryswift/[here]. +* 6 example scripts to try. + + +Running the Swift/K tutorial on Tukey +------------------------------------- + +* Login to Tukey - login.tukey.pub.alcf.anl.gov +* Checkout the tutorial repository from svn: +[source,bash] +----- +svn co https://svn.ci.uchicago.edu/svn/vdl2/SwiftTutorials/ATPESC_2014-08-14/swift-k +----- + +* Follow the link:./swift-k/README.html[Swift/K tutorial] + +Running the Swift/T tutorial on Cetus +------------------------------------- + +* Login to Cetus +* Checkout the Swift/T tutorial from svn: +[source,bash] +----- +svn co https://svn.ci.uchicago.edu/svn/vdl2/SwiftTutorials/ATPESC_2014-08-14/swift-t +----- + +* Follow the link:./swift-t/tutorial.html[Swift/T tutorial] From wilde at ci.uchicago.edu Thu Aug 14 14:48:41 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Thu, 14 Aug 2014 14:48:41 -0500 (CDT) Subject: [Swift-commit] r8215 - in SwiftTutorials/ATPESC_2014-08-14/lecture: . OLD Message-ID: <20140814194841.105EE9CC96@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-14 14:48:40 -0500 (Thu, 14 Aug 2014) New Revision: 8215 Added: SwiftTutorials/ATPESC_2014-08-14/lecture/OLD/ SwiftTutorials/ATPESC_2014-08-14/lecture/OLD/ATPESC2014_SwiftK.pptx Removed: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftK.pptx Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_Workflow.pptx Log: Copied Swift/K slides to main slide deck. Deleted: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftK.pptx =================================================================== (Binary files differ) Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_Workflow.pptx =================================================================== (Binary files differ) Copied: SwiftTutorials/ATPESC_2014-08-14/lecture/OLD/ATPESC2014_SwiftK.pptx (from rev 8212, SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftK.pptx) =================================================================== (Binary files differ) From wilde at ci.uchicago.edu Thu Aug 14 14:59:19 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Thu, 14 Aug 2014 14:59:19 -0500 (CDT) Subject: [Swift-commit] r8216 - SwiftTutorials/ATPESC_2014-08-14/lecture Message-ID: <20140814195919.09C719CC96@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-14 14:59:18 -0500 (Thu, 14 Aug 2014) New Revision: 8216 Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_Workflow.pptx Log: Copied a snapshot of SwiftT slides to main slide deck. Sending this version to post on ATPESC site. Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_Workflow.pptx =================================================================== (Binary files differ) From yadunandb at ci.uchicago.edu Thu Aug 14 15:00:44 2014 From: yadunandb at ci.uchicago.edu (yadunandb at ci.uchicago.edu) Date: Thu, 14 Aug 2014 15:00:44 -0500 (CDT) Subject: [Swift-commit] r8217 - SwiftTutorials/ATPESC_2014-08-14/swift-k/doc Message-ID: <20140814200044.BDD3A9CC96@svn.ci.uchicago.edu> Author: yadunandb Date: 2014-08-14 15:00:44 -0500 (Thu, 14 Aug 2014) New Revision: 8217 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README Log: Committing changes from midway to tukey Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README 2014-08-14 19:59:18 UTC (rev 8216) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README 2014-08-14 20:00:44 UTC (rev 8217) @@ -9,7 +9,7 @@ //// This tutorial is viewable at: -http://swiftlang.org/tutorials/midway/tutorial.html +http://swift-lang.org/ATPESC_2014/swift-k/README.html //// @@ -23,7 +23,7 @@ Compute-node exercises, running apps via qsub and aprun: - p4 - Running apps on RCC Midway cluster + p4 - Running apps on Tukey p5 - Running on multiple pools of compute nodes p6 - Running a more complex workflow pattern @@ -48,26 +48,22 @@ clusters, clouds, grids, and supercomputers. In this tutorial, you'll be able to first try a few Swift examples -(parts 1-3) on a Midway login host, to get a sense of the -language. Then in parts 4-6 you'll run similar workflows on Midway +(parts 1-3) on a Tukey login host, to get a sense of the +language. Then in parts 4-6 you'll run similar workflows on Tukey compute nodes, and see how more complex workflows can be expressed with Swift scripts. Swift tutorial setup -------------------- -If you are using a temporary/guest account to access Midway, follow -the instructions at http://docs.rcc.uchicago.edu/tutorials/intro-to-rcc-workshop.html -for more information on using a yubikey to log in. -Once you are logged into the Midway login host, run the following commands +Once you are logged into the Tukey login host, run the following commands to set up your environment. ----- $ cd $HOME -$ wget http://swiftlang.org/tutorials/midway/swift-midway-tutorial.tar.gz -$ tar xvfz swift-midway-tutorial.tar.gz -$ cd swift-midway-tutorial -$ source setup.sh +$ svn co https://svn.ci.uchicago.edu/svn/vdl2/SwiftTutorials/ATPESC_2014-08-14/swift-k +$ cd swift-k +$ source setup.tukey.sh ----- Verify your environment @@ -79,20 +75,13 @@ $ swift -version # verify that you have Swift 0.95 RC1 ----- -NOTE: If you re-login or open new ssh sessions, you must re-run `source setup.sh` in each ssh shell/window. +Ensure that you have the PROJECT env variable set -To check out the tutorial scripts from SVN -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -If you later want to get the most recent version of this tutorial from -the Swift Subversion repository, do: - ----- -$ svn co https://svn.ci.uchicago.edu/svn/vdl2/SwiftTutorials/swift-midway-tutorial +$ export PROJECT=ATPESC2014 ----- -This will create a directory called "swift-midway-tutorial" which contains all of the -files used in this tutorial. +NOTE: If you re-login or open new ssh sessions, you must re-run `source setup.sh` in each ssh shell/window. Simple "science applications" for the workflow tutorial @@ -458,13 +447,13 @@ on the site's compute nodes. -Running applications on Midway compute nodes with Swift +Running applications on Tukey compute nodes with Swift ------------------------------------------------------- -Part 4: Running a parallel ensemble on Midway compute nodes +Part 4: Running a parallel ensemble on Tukey compute nodes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -`p4.swift` will run our mock "simulation" applications on Midway +`p4.swift` will run our mock "simulation" applications on Tukey compute nodes. The script is similar to as `p3.swift`, but specifies that each simulation app invocation should additionally return the log file which the application writes to `stderr`. @@ -507,33 +496,39 @@ Swift's `swift.properties` configuration file allows many parameters to specify how jobs should be run on a given cluster. -Consider for example that Midway has several Slurm partitions. The sandyb -partition has 16 cores, and the westmere partition has 12 cores. Depending -on the application and which partitions are busy, you may want to modify -where you run. Here is an example of the swift.properties in the part04 directory: ----- -site=westmere -site.westmere.slurm.reservation=workshop -site.westmere.slurm.exclusive=false +site=tukey + +site.tukey { + jobmanager=localhost:cobalt + taskWalltime=00:15:00 + workdir=/home/$USER/swiftwork + filesystem=local + maxJobs=4 + tasksPerWorker=8 + taskThrottle=300 + initialscore=10000 +} + + +app.tukey.simulate=$PWD/../app/simulate +app.tukey.stats=$PWD/../app/stats +app.tukey.md=$PWD/../bin/md +app.tukey.mdstats=$PWD/../app/mdstats +app.tukey.mdmaxk=$PWD/../app/mdmaxk +app.tukey.renderframe=$PWD/../app/renderframe +app.tukey.convert=/usr/bin/convert ----- -The first line, site=westmere, allows you to define which partition to run on. Swift includes -templates for each partition that provides some reasonable default values. Other valid partitions -are amd, bigmem, gpu, local, and sandyb. +The first line, site=tukey, allows you to define which site to run on. Swift also includes +templates for several sites that provides some reasonable default values. The second and third line override some of the default values, by specifying a reservation that will be used for this session, and enabling node sharing. -Try changing the queue to run on the sandyb queue. The new swift.properties should look like this: ------ -site=sandyb -site.sandyb.slurm.reservation=workshop -site.sandyb.slurm.exclusive=false ----- - Performing larger Swift runs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From tga at ci.uchicago.edu Thu Aug 14 15:09:06 2014 From: tga at ci.uchicago.edu (tga at ci.uchicago.edu) Date: Thu, 14 Aug 2014 15:09:06 -0500 (CDT) Subject: [Swift-commit] r8218 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140814200906.2C01F9D82D@svn.ci.uchicago.edu> Author: tga Date: 2014-08-14 15:09:06 -0500 (Thu, 14 Aug 2014) New Revision: 8218 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh Log: Fix source paths for zsh Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh 2014-08-14 20:00:44 UTC (rev 8217) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh 2014-08-14 20:09:06 UTC (rev 8218) @@ -1,4 +1,4 @@ -#!/bin/zsh -eu +#!/bin/sh -eu A=( SIMULATIONS STEPS NP ND MASS DT SEED ) @@ -16,7 +16,7 @@ done . ../../cfg/setup-local.sh -. setup-md.sh +. ./setup-md.sh SETTINGS=../../cfg/settings-compute.sh PROGRAM=run-mds Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 20:00:44 UTC (rev 8217) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 20:09:06 UTC (rev 8218) @@ -17,7 +17,7 @@ done . ../../cfg/setup-local.sh -. setup-md.sh +. ./setup-md.sh PROGRAM=run-mds stc ${PROGRAM}.swift From tga at ci.uchicago.edu Thu Aug 14 15:45:42 2014 From: tga at ci.uchicago.edu (tga at ci.uchicago.edu) Date: Thu, 14 Aug 2014 15:45:42 -0500 (CDT) Subject: [Swift-commit] r8219 - SwiftTutorials/ATPESC_2014-08-14/swift-k/doc Message-ID: <20140814204542.EB2649D82D@svn.ci.uchicago.edu> Author: tga Date: 2014-08-14 15:45:42 -0500 (Thu, 14 Aug 2014) New Revision: 8219 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README Log: Remove last references to midway Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README 2014-08-14 20:09:06 UTC (rev 8218) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README 2014-08-14 20:45:42 UTC (rev 8219) @@ -1,4 +1,4 @@ -Swift Tutorial for RCC Midway Cluster +Swift Tutorial for Argonne Tukey Cluster ===================================== //// @@ -141,7 +141,7 @@ 51 $ head -5 log -Called as: /home/davidkelly999/swift-midway-tutorial/app/simulate: +Called as: /home/davidkelly999/swift-tutorial/app/simulate: Start time: Mon Dec 2 13:47:41 CST 2013 Running as user: uid=88848(davidkelly999) gid=88848(davidkelly999) groups=88848(davidkelly999),10008(rcc),10030(pi-gavoth),10031(sp-swift),10036(swift),10058(pi-joshuaelliott),10084(pi-wilde),10118(cron-account),10124(cmts),10138(cmtsworkshop) @@ -465,11 +465,11 @@ ----- $ cat output/sim_0.log -Called as: /home/davidkelly999/swift-midway-tutorial/app/simulate: --timesteps 1 --range 100 --nvalues 5 +Called as: /home/davidkelly999/swift-tutorial/app/simulate: --timesteps 1 --range 100 --nvalues 5 Start time: Mon Dec 2 12:17:06 CST 2013 Running as user: uid=88848(davidkelly999) gid=88848(davidkelly999) groups=88848(davidkelly999),10008(rcc),10030(pi-gavoth),10031(sp-swift),10036(swift),10058(pi-joshuaelliott),10084(pi-wilde),10118(cron-account),10124(cmts),10138(cmtsworkshop) -Running on node: midway002 +Running on node: node002 Node IP address: 10.50.181.2 172.25.181.2 Simulation parameters: From wozniak at ci.uchicago.edu Thu Aug 14 15:47:54 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 15:47:54 -0500 (CDT) Subject: [Swift-commit] r8220 - in SwiftTutorials/ATPESC_2014-08-14/swift-t/examples: 05-md md-src Message-ID: <20140814204754.B4B0E9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 15:47:54 -0500 (Thu, 14 Aug 2014) New Revision: 8220 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h Log: Fix np/nd issue Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 20:45:42 UTC (rev 8219) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 20:47:54 UTC (rev 8220) @@ -1,6 +1,6 @@ #!/bin/zsh -eu -A=( SIMULATIONS NP ND STEP_NUM STEP_PRINT_NUM DT MASS PRINTINFO +A=( SIMULATIONS ND NP STEP_NUM STEP_PRINT_NUM DT MASS PRINTINFO SCALE_FACTOR SCALE_OFFSET SEED ) if [[ ${#*} != ${#A} ]] Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift 2014-08-14 20:45:42 UTC (rev 8219) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-md.swift 2014-08-14 20:47:54 UTC (rev 8220) @@ -5,7 +5,7 @@ { file out_txt<"out.txt">; file out_trj<"out.trj">; - (out_txt, out_trj) = simulate(3, 0, 10, 10, 0.1, 1, + (out_txt, out_trj) = simulate(10, 2, 10, 10, 0.1, 1, "0.1 1.0 0.2 0.05 50.0 0.1", 2.5, 2.0, 42); } Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c 2014-08-14 20:45:42 UTC (rev 8219) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.c 2014-08-14 20:47:54 UTC (rev 8220) @@ -23,7 +23,7 @@ static void trj_file_open(char *trjfile); static void trj_file_close(void); -void simulate ( int nd, int np, +void simulate ( int np, int nd, int step_num, int step_print_num, double dt, double mass, Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h 2014-08-14 20:45:42 UTC (rev 8219) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/md-src/md.h 2014-08-14 20:47:54 UTC (rev 8220) @@ -20,7 +20,7 @@ void compute ( int np, int nd, double pos[], double vel[], double mass, double f[], double *pot, double *kin ); -void simulate ( int nd, int np, +void simulate ( int np, int nd, int step_num, int step_print_num, double dt, double mass, From wozniak at ci.uchicago.edu Thu Aug 14 16:01:14 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 16:01:14 -0500 (CDT) Subject: [Swift-commit] r8221 - www/ATPESC_2014 Message-ID: <20140814210114.81F5C9D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 16:01:14 -0500 (Thu, 14 Aug 2014) New Revision: 8221 Modified: www/ATPESC_2014/tutorial.html Log: Add use case Modified: www/ATPESC_2014/tutorial.html =================================================================== --- www/ATPESC_2014/tutorial.html 2014-08-14 20:47:54 UTC (rev 8220) +++ www/ATPESC_2014/tutorial.html 2014-08-14 21:01:14 UTC (rev 8221) @@ -3,26 +3,29 @@ - -ATPESC 2014 Swift Tutorial + +Tutorial: Swift/T
    -

    This is the Swift tutorial for ATPESC 2014.

    +

    This tutorial will walk through 4 examples of the use of Swift/T, in +addition to a molecular dynamics example.

    +
    +
    +
    +

    Swift/T materials

    +
    +

    For more information on Swift/T, see:

    +
    +

    Files

    +
    +

    The examples are in the examples/ directory.

    +

    Each example directory is numbered from 01 to 05.

    +

    Configuration files are in cfg/. These refer to public +installations of Swift/T on Cetus/Mira.

    +

    Each example contains a *.swift Swift script that is the Swift +program. The Swift/T compiler stc translates the Swift script into +an MPI program encoded in a *.tcl file. This is launched by using +the turbine program or a scheduler-specific script, such as the +provided turbine-cobalt-run.zsh script.

    +

    There is also a run-local script to run the Swift script +on the login node and a run-compute script to submit the Swift +program to Cobalt. These scripts add stc and turbine entries to +your PATH automatically.

    +
    +
    +

    Swift/T installations

    +
    +

    These instructions assume you will be running a preinstalled version +of Swift/T on Cetus or Mira.

    +

    Two Swift/T installations are provided- one that runs on the login +node and one that runs on the compute nodes (via Cobalt). The login +node installation should be used with caution- expensive computation +will impact other users on the login nodes.

    +
    +
    +
    +

    Examples

    +
    +
    +

    01 Hello world

    +

    This is a very simple Swift/T program that illustrates Swift/T usage.

    +
      +
    1. +

      +cd into the directory 01-hello +

      +
    2. +
    3. +

      +Run: +

      +
      +
      +
      ./run-local.sh
      +
      +
    4. +
    5. +

      +This program is a simple Hello World example. +

      +
      +
      +
      /**
      +   Example 1 - HELLO.SWIFT
      +*/
      +
      +import io;
      +
      +main
      +{
      +  printf("Hello world!");
      +}
      +
      +
    6. +
    7. +

      +Run: +

      +
      +
      +
      ./run-compute.sh
      +
      +

      This will report something like:

      +
      +
      +
      SETTINGS=../../cfg/settings-compute.sh
      +TURBINE_OUTPUT=/home/user/turbine-output/2014/08/14/10/06/20
      +SCRIPT_NAME=hello.tcl
      +NODES=2
      +project: ATPESC2014
      +JOB_ID=312170
      +
      +

      Turbine will copy hello.tcl to TURBINE_OUTPUT and run from that +directory. The Cobalt log may be found there. Standard output is +directed to TURBINE_OUTPUT/output.txt.

      +

      The contents of output.txt are the Blue Gene runtime output plus the +Swift-generated line:

      +
      +
      +
      stdout[0]: Hello world!
      +
      +
    8. +
    +
    +
    +

    02 Loop

    +

    This example shows one way to obtain concurrency from Swift/T.

    +
    +
    +
    /**
    +   Example 2 - LOOP.SWIFT
    +*/
    +
    +import io;
    +
    + at dispatch=WORKER
    +(int j) compute(int i) "turbine" "0.0"
    +[
    +----
    +  after [ expr <<i>> * 1000 ]
    +  puts "compute: <<i>> [ expr [clock seconds] % 1000]"
    +  set <<j>> [ expr <<i>> * 2 ]
    +----
    +];
    +
    +main
    +{
    +  printf("Running loop...");
    +  foreach i in [0:9]
    +  {
    +    j = compute(i);
    +    printf("compute(%i) = %i", i, j);
    +  }
    +}
    +
    +

    The program executes compute() 10 times concurrently, because the +Swift foreach loop is concurrent. The compute() function is +implemented as a Tcl fragment that does 3 things:

    +
      +
    1. +

      +Delay progress with after (sleeps for i*1000 milliseconds) +

      +
    2. +
    3. +

      +Print a timestamp for reference +

      +
    4. +
    5. +

      +Set a result value +

      +
    6. +
    +

    The result value is printed by Swift’s printf().

    +

    Note the use of the <<x>> syntax, which maps Swift variable x to a +Tcl variable.

    +

    This script may be run as the Hello World case, but the run scripts +accept Turbine runtime arguments:

    +
    +
    +-l +
    +
    +

    +Prepend outputs with the MPI rank number (like mpiexec -l) +

    +
    +
    +-n N +
    +
    +

    +Run N MPI processes (like mpiexec -n N). Note that one +process is dedicated for Swift logic, so choose N>1. +

    +
    +
    +

    Add more processes and see how that improves time to job +completion. Check output.txt for the ADLB Total Elapsed Time:, +which is a good measure of total execution time (discounts queue and +allocation startup/shutdown time).

    +
    + + + +
    +
    Note
    +
    Ease of calling to Tcl makes for ease of calling to native code, +as shown in the next example.
    +
    +
    +
    +

    03 BLAS

    +

    In this example, we use Swift to call a BLAS routine for dot product.

    +
    +
    +
    /**
    +   Example 3 - DOT.SWIFT
    +*/
    +
    +// Swift/T libraries:
    +import blob;
    +import io;
    +import matrix;
    +
    +// BLAS library for this example:
    +import blas;
    +
    +main
    +{
    +  // Swift floats are 64-bit
    +  float A[];
    +  float B[];
    +  int N = 3;
    +  foreach i in [0:N-1]
    +  {
    +    A[i] = itof(i);   // integer-to-float
    +    B[i] = itof(i+1);
    +  }
    +
    +  // Use => for output ordering
    +  printf("A") =>
    +    vector_print(A) =>
    +    printf("\nB") =>
    +    vector_print(B)
    +    =>
    +    float z = blas_ddot(N, A, B);
    +
    +  printf("\nA*B=%0.1f", z);
    +}
    +
    +

    In this example, we created a stub of a Swift BLAS library in +blas.swift. This calls the CBLAS cblas_ddot() function through a +Tcl interface.

    +
      +
    1. +

      +Run: +

      +
      +
      +
      ./build.sh
      +
      +

      This creates a Tcl package for BLAS (using a hand-coded method- we +could also use SWIG to automate this).

      +
    2. +
    3. +

      +Run ./run-*.sh. +

      +
    4. +
    +

    In dot.swift, the Swift statement import blas; brings blas.swift +into the program. The Swift call to blas_ddot() operates on the +Swift arrays A and B. In blas.swift, the Swift arrays are +converted to C-compatible arrays of double, which are represented in +Swift/T with the blob type. These are passed to the BLAS package.

    +

    Thus, calling native code from Swift/T is comparable in complexity to +calling native code from other scripting languages such as Tcl or +Python.

    +
    +
    +

    04 Python

    +

    Another good way to call native code and bind it together in a script +is through Python. Swift/T has convenient interfaces for Python, Tcl, +R, Julia, and Qt Script (and the shell). In this example, we call +into Python and its numerical package Numpy, which uses BLAS +internally for numerical operations.

    +
    +
    +
    /**
    +   Example 4 - ADD.SWIFT
    +*/
    +
    +// Swift/T libraries:
    +import io;
    +import python;
    +import string;
    +
    +// This example: See ./numpy.swift
    +import numpy;
    +
    +f()
    +{
    +  python(
    +----
    +print("Python works!")
    +repr(0)
    +----);
    +}
    +
    +main
    +{
    +  f();
    +  matrix A1 = eye(3);
    +  matrix A2 = eye(3);
    +  matrix sum = add(A1, A2);
    +  printf("2*eye(3)=%s", sum);
    +}
    +
    +

    In this example, we also created a stub Swift numerical library in +numpy.swift. This is imported into the main Swift script +add.swift.

    +

    First, this program calls f(), which is a simple use of the +Swift/T-Python interface. The Python code fragment must return a +value in its last line as a string- in this case, we return "0".

    +

    Second, we use the numpy.swift features. We allocate 2 Numpy arrays +I3 and add them together, producing 2I3.

    +

    Swift/T can call into arbitrary Python modules, just set PYTHONPATH. +C/C++ code can be easily wrapped for Python with +SWIG, Fortran code with SciPy’s +F2PY.

    +

    Thus, a variety of scripts and +libraries can be easily integrated with Swift/T and run concurrently +on massive computers like the Blue Gene/Q!

    +
    +
    +

    05 Molecular dynamics

    +

    In our most realistic example, we bundle a small molecular dynamics +simulator MD for +Swift/T and call it concurrently.

    +
      +
    1. +

      +cd to examples/md-src/ and run: +

      +
      +
      +
      make
      +
      +

      This builds the stand-alone md program. You can test it with test-md-*.sh.

      +
    2. +
    3. +

      +Run: +

      +
      +
      +
      make swift-pkg
      +
      +

      This builds the Tcl package by:

      +
        +
      1. +

        +Running SWIG to expose the core simulate() function to Tcl; +

        +
      2. +
      3. +

        +Compiling the SWIG-generated wrapper code and linking it as a Tcl +package. +

        +

        You can test the Tcl function with ./test-md.tcl, which simply loads +the package and calls simulate once.

        +
      4. +
      +
    4. +
    5. +

      +cd back to examples/05-md/. +

      +
    6. +
    7. +

      +The md.swift library shows the calling sequence for MD. +

      +
    8. +
    9. +

      +The run-md.swift script shows how to call MD once. The output files are indicated in the script, in addition to the usual output.txt. Run this with ./run-*-md.sh. +

      +
    10. +
    11. +

      +A concurrent ensemble of simulations is launched by +run-mds.swift. This script accepts many arguments on the command +line: see run-*-mds.sh. For example, you can run: +

      +
      +
      +
      ./run-local-mds.sh 1 3 2 10 10 0.1 1 "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 42
      +
      +
    12. +
    +
    +
    +
    +

    From wozniak at ci.uchicago.edu Thu Aug 14 16:22:47 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 16:22:47 -0500 (CDT) Subject: [Swift-commit] r8222 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md Message-ID: <20140814212247.B2E349D82D@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 16:22:47 -0500 (Thu, 14 Aug 2014) New Revision: 8222 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh Log: Update args Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh 2014-08-14 21:01:14 UTC (rev 8221) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-compute-mds.sh 2014-08-14 21:22:47 UTC (rev 8222) @@ -1,6 +1,7 @@ -#!/bin/sh -eu +#!/bin/zsh -eu -A=( SIMULATIONS STEPS NP ND MASS DT SEED ) +A=( SIMULATIONS NP ND STEP_NUM STEP_PRINT_NUM DT MASS PRINTINFO + SCALE_FACTOR SCALE_OFFSET SEED ) if [[ ${#*} != ${#A} ]] then @@ -11,7 +12,7 @@ # Scan argv for a in ${A} do - eval ${a}=$1 + eval "${a}='$1'" shift done @@ -22,10 +23,15 @@ PROGRAM=run-mds stc ${PROGRAM}.swift turbine-cobalt-run.zsh -n 2 -s ${SETTINGS} ${PROGRAM}.tcl \ - --simulations=${SIMULATIONS} \ - --steps=${STEPS} \ - --np=${NP} \ - --nd=${ND} \ - --mass=${MASS} \ - --dt=${DT} \ + --simulations=${SIMULATIONS} \ + --np=${NP} \ + --nd=${ND} \ + --step_num=${STEP_NUM} \ + --step_print_num=${STEP_PRINT_NUM} \ + --dt=${DT} \ + --mass=${MASS} \ + --printinfo=${PRINTINFO} \ + --scale_factor=${SCALE_FACTOR} \ + --scale_offset=${SCALE_OFFSET} \ --seed=${SEED} + Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 21:01:14 UTC (rev 8221) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/05-md/run-local-mds.sh 2014-08-14 21:22:47 UTC (rev 8222) @@ -1,6 +1,6 @@ #!/bin/zsh -eu -A=( SIMULATIONS ND NP STEP_NUM STEP_PRINT_NUM DT MASS PRINTINFO +A=( SIMULATIONS NP ND STEP_NUM STEP_PRINT_NUM DT MASS PRINTINFO SCALE_FACTOR SCALE_OFFSET SEED ) if [[ ${#*} != ${#A} ]] From wozniak at ci.uchicago.edu Thu Aug 14 19:01:17 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 19:01:17 -0500 (CDT) Subject: [Swift-commit] r8223 - SwiftTutorials/ATPESC_2014-08-14/swift-t Message-ID: <20140815000117.A3CB59CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 19:01:17 -0500 (Thu, 14 Aug 2014) New Revision: 8223 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt Log: Add use case Modified: SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-14 21:22:47 UTC (rev 8222) +++ SwiftTutorials/ATPESC_2014-08-14/swift-t/tutorial.txt 2014-08-15 00:01:17 UTC (rev 8223) @@ -223,5 +223,8 @@ 5. The +run-md.swift+ script shows how to call MD once. The output files are indicated in the script, in addition to the usual +output.txt+. Run this with +./run-*-md.sh+. 6. A concurrent ensemble of simulations is launched by +run-mds.swift+. This script accepts many arguments on the command -line: see +run-*-mds.sh+. - +line: see +run-*-mds.sh+. For example, you can run: ++ +---- +./run-local-mds.sh 1 3 2 10 10 0.1 1 "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 42 +---- From wozniak at ci.uchicago.edu Thu Aug 14 19:01:39 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 14 Aug 2014 19:01:39 -0500 (CDT) Subject: [Swift-commit] r8224 - SwiftTutorials/ATPESC_2014-08-14/lecture Message-ID: <20140815000139.57CE49CC96@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-14 19:01:39 -0500 (Thu, 14 Aug 2014) New Revision: 8224 Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftT.pptx Log: Minors Modified: SwiftTutorials/ATPESC_2014-08-14/lecture/ATPESC2014_SwiftT.pptx =================================================================== (Binary files differ) From yadunandb at ci.uchicago.edu Thu Aug 14 19:06:05 2014 From: yadunandb at ci.uchicago.edu (yadunandb at ci.uchicago.edu) Date: Thu, 14 Aug 2014 19:06:05 -0500 (CDT) Subject: [Swift-commit] r8225 - SwiftTutorials/ATPESC_2014-08-14/swift-k/doc Message-ID: <20140815000605.7F0979CC96@svn.ci.uchicago.edu> Author: yadunandb Date: 2014-08-14 19:06:05 -0500 (Thu, 14 Aug 2014) New Revision: 8225 Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README Log: Correcting the headline Modified: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README 2014-08-15 00:01:39 UTC (rev 8224) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README 2014-08-15 00:06:05 UTC (rev 8225) @@ -1,5 +1,5 @@ -Swift Tutorial for Argonne Tukey Cluster -===================================== +Swift Tutorial for Tukey +======================== //// From tga at ci.uchicago.edu Fri Aug 15 19:19:16 2014 From: tga at ci.uchicago.edu (tga at ci.uchicago.edu) Date: Fri, 15 Aug 2014 19:19:16 -0500 (CDT) Subject: [Swift-commit] r8226 - trunk/docs/userguide Message-ID: <20140816001916.47A8A9D792@svn.ci.uchicago.edu> Author: tga Date: 2014-08-15 19:19:16 -0500 (Fri, 15 Aug 2014) New Revision: 8226 Modified: trunk/docs/userguide/configuration.new Log: Caught typo in docs Modified: trunk/docs/userguide/configuration.new =================================================================== --- trunk/docs/userguide/configuration.new 2014-08-15 00:06:05 UTC (rev 8225) +++ trunk/docs/userguide/configuration.new 2014-08-16 00:19:16 UTC (rev 8226) @@ -173,7 +173,7 @@ - global application declarations - Swift configuration properties -Site Delcarations +Site Declarations ^^^^^^^^^^^^^^^^^ Swift site declarations are specified using the +site.+ property, where text From wozniak at ci.uchicago.edu Fri Aug 22 15:23:09 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Fri, 22 Aug 2014 15:23:09 -0500 (CDT) Subject: [Swift-commit] r8229 - www/Swift-T Message-ID: <20140822202309.A0FDD9D850@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-22 15:23:09 -0500 (Fri, 22 Aug 2014) New Revision: 8229 Modified: www/Swift-T/guide.html Log: Improve @prio Modified: www/Swift-T/guide.html =================================================================== --- www/Swift-T/guide.html 2014-08-22 20:17:00 UTC (rev 8228) +++ www/Swift-T/guide.html 2014-08-22 20:23:09 UTC (rev 8229) @@ -2984,7 +2984,8 @@
    foreach i in [0:n-1] {
    -  @prio=i f(i);
    +  @prio=i f(i);         // or
    +  int j = @prio=i f(i);
     }

    In this case, f() will operate on higher values of i first. @@ -3776,7 +3777,7 @@


    From wozniak at ci.uchicago.edu Mon Aug 25 22:46:38 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Mon, 25 Aug 2014 22:46:38 -0500 (CDT) Subject: [Swift-commit] r8230 - usertools/plotter/src/plotter Message-ID: <20140826034638.7D54A9CCFA@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-25 22:46:38 -0500 (Mon, 25 Aug 2014) New Revision: 8230 Modified: usertools/plotter/src/plotter/Lines.java Log: Support date axes Modified: usertools/plotter/src/plotter/Lines.java =================================================================== --- usertools/plotter/src/plotter/Lines.java 2014-08-22 20:23:09 UTC (rev 8229) +++ usertools/plotter/src/plotter/Lines.java 2014-08-26 03:46:38 UTC (rev 8230) @@ -19,6 +19,7 @@ import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.XYTextAnnotation; +import org.jfree.chart.axis.DateAxis; import org.jfree.chart.axis.LogAxis; import org.jfree.chart.axis.LogarithmicAxis; import org.jfree.chart.axis.NumberAxis; @@ -120,16 +121,12 @@ { File file = new File(name); Util.verbose("open: " + file); - List lines = null; double[][] array; try { - lines = LineReader.read(file); - + List lines = LineReader.read(file); if (lines == null) - { System.err.println("Problem when reading: "+file); - } array = LineReader.array(lines); } catch (FileNotFoundException e) @@ -142,18 +139,24 @@ (e.getMessage() + "\n" + "In file: " + file); } - if (array.length == 0) - throw new UserInputException - ("file has no data: " + name); - if (array[0].length != 2) - throw new UserInputException - ("file is not two-column: " + name); + checkRead(name, array); data.add(array); addLabel(name, labels); Util.verbose("array:\n" + toString(array)); } } + static void checkRead(String name, double[][] array) + throws UserInputException + { + if (array.length == 0) + throw new UserInputException + ("file has no data: " + name); + if (array[0].length != 2) + throw new UserInputException + ("file is not two-column: " + name); + } + /** Generate simple plot. @param collection The x,y data. @@ -256,6 +259,7 @@ private static void setupPlot(JFreeChart chart, XYSeriesCollection collection) + throws UserInputException { XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); @@ -283,6 +287,7 @@ } static void setAxes(XYPlot plot) + throws UserInputException { setAxisTypes(plot); @@ -315,14 +320,20 @@ private static void setAxisTypes(XYPlot plot) + throws UserInputException { if (axis_x_type.equals("logarithmic")) { NumberAxis domainAxis = new LogarithmicAxis(xlabel); plot.setDomainAxis(domainAxis); } + else if (axis_x_type.equals("date")) + { + DateAxis dateAxis = new DateAxis(xlabel); + plot.setDomainAxis(dateAxis); + } else if (!axis_x_type.equals("normal")) - throw new RuntimeException + throw new UserInputException ("Invalid axis.x type: " + axis_x_type); if (axis_y_type.equals("logarithmic")) @@ -331,7 +342,7 @@ plot.setRangeAxis(rangeAxis); } else if (!axis_y_type.equals("normal")) - throw new RuntimeException + throw new UserInputException ("Invalid axis.y type: " + axis_y_type); } From wozniak at ci.uchicago.edu Wed Aug 27 15:11:14 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 27 Aug 2014 15:11:14 -0500 (CDT) Subject: [Swift-commit] r8231 - www/Swift-T Message-ID: <20140827201114.1A1789CFB2@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-27 15:11:13 -0500 (Wed, 27 Aug 2014) New Revision: 8231 Modified: www/Swift-T/turbine-sites.html Log: Document Titan Modified: www/Swift-T/turbine-sites.html =================================================================== --- www/Swift-T/turbine-sites.html 2014-08-26 03:46:38 UTC (rev 8230) +++ www/Swift-T/turbine-sites.html 2014-08-27 20:11:13 UTC (rev 8231) @@ -746,8 +746,8 @@

    Turbine Sites Guide

    Justin M. Wozniak
    <wozniak at mcs.anl.gov>
    -version 0.5.0, -April 2014 +version 0.6.1, +August 2014
    Table of Contents
    @@ -1661,11 +1661,129 @@

    Cray

    +

    Titan

    +

    Titan is a Cray XK7 at the Oak Ridge Leadership Computing Facility.

    +
    +

    Public installation

    +

    As of: 8/27/2014

    +
      +
    • +

      +Swift/T trunk - 8/27/2013 +

      +
    • +
    • +

      +Turbine: /lustre/atlas2/mat049/proj-shared/sfw/compute/turbine/scripts/submit/cray/turbine-cray-run.zsh +

      +
    • +
    • +

      +STC: /lustre/atlas2/mat049/proj-shared/sfw/compute/stc/bin/stc +

      +
    • +
    • +

      +SWIG: /lustre/atlas2/mat049/proj-shared/sfw/swig-3.0.2 +

      +
    • +
    • +

      +Tcl: /lustre/atlas2/mat049/proj-shared/sfw/tcl-8.6.2 +

      +
    • +
    +
    +
    +

    Submitting jobs

    +

    Titan requires that user output goes to a Lustre file system. Set a +soft link like this so that Turbine output goes to Lustre:

    +
    +
    +
    mkdir /lustre/atlas/scratch/YOUR_USERNAME/turbine-output
    +cd ~
    +ln -s /lustre/atlas/scratch/YOUR_USERNAME/turbine-output
    +
    +

    Or, you may set TURBINE_OUTPUT manually.

    +

    Titan requires the submit script to specify job size using different +directives to other Cray systems. It does not support the #PBS -l ppn: +directive. The correct directive is:

    +
    +
    +
    #PBS -l nodes=32
    +
    +

    PPN is handled by setting the -n argument.

    +

    The turbine-aprun-run.zsh script supports Titan. You can invoke +it as follows (for a single node/32 processes per node):

    +
    +
    +
    export PROJECT=MAT049
    +export QUEUE=debug
    +export TITAN=true
    +turbine-aprun-run.zsh -n 32 helloworld.tcl
    +
    +

    These environment variables may be placed in your -s +settings file.

    +
    +
    +

    Build procedure

    +

    As of: 8/27/2014

    +

    Cray systems do not use mpicc. We set CC=gcc and use compiler +flags to configure the MPI library.

    +
      +
    • +

      +Configure ADLB with: +

      +
      +
      +
      ./configure --prefix=/path/to/lb --with-c-utils=/path/to/c-utils
      +CC=gcc
      +CFLAGS=-I/opt/cray/mpt/default/gni/mpich2-gnu/47/include
      +LDFLAGS="-L/opt/cray/mpt/default/gni/mpich2-gnu/47/lib -lmpich"
      +--enable-mpi-2
      +
      +
    • +
    • +

      +In the Turbine configure step, replace the --with-mpi option with: +

      +
      +
      +
      --enable-custom-mpi --with-mpi=/opt/cray/mpt/default/gni/mpich2-gnu/47
      +
      +
    • +
    +
    +
    +

    Submitting jobs

    +

    Titan requires the submit script to specify job size using different +directives to other Cray systems. It does not support the #PBS -l ppn: +directive. The correct directive is:

    +
    +
    +
    #PBS -l nodes=32
    +
    +

    PPN is handled by setting the -n argument.

    +

    The turbine-aprun-run.zsh script supports Titan. You can invoke +it as follows (for a single node/32 processes per node):

    +
    +
    +
    export QUEUE=normal
    +export TITAN=true
    +export PPN=32
    +turbine-aprun-run.zsh -n 32 helloworld.tcl
    +
    +

    These environment variables may be placed in your +settings file.

    +
    +
    +

    Blue Waters

    Blue Waters is a Cray XE6/XK7 at the University of Illinois at Urbana-Champaign.

    -

    Build procedure

    +

    Build procedure

    As of: 11/05/2013

    Cray systems do not use mpicc. We set CC=gcc and use compiler flags to configure the MPI library.

    @@ -1715,7 +1833,7 @@
-

Submitting jobs

+

Submitting jobs

Submitting jobs on Blue Waters is largely the same with with other Cray systems. One difference is that the size of the job is specified using a different notation.

@@ -1883,7 +2001,7 @@ NFS (including home directories). Thus, you must install Turbine and its libraries in /lustre. Also, your data must be in /lustre.

-

Public installation

+

Public installation

Login nodes

This installation is for use on the login node.

@@ -1945,7 +2063,7 @@
-

Build procedure

+

Build procedure

Cray systems do not use mpicc. We set CC=gcc and use compiler flags to configure the MPI library.

    @@ -2004,7 +2122,7 @@

    Raven

    Raven is a Cray XE6/XK7 at Cray.

    -

    Build procedure

    +

    Build procedure

    • @@ -2141,12 +2259,31 @@

+
+

Mac OS X

+
+

Swift/T is regularly tested on the Mac. You may use Swift/T as on any +other single system.

+
    +
  • +

    +SWIG: You may use SWIG from source or the MacPorts swig-tcl package +

    +
  • +
  • +

    +MPI: You may use any MPI implementation +

    +
  • +
+
+

From wozniak at ci.uchicago.edu Wed Aug 27 15:18:18 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Wed, 27 Aug 2014 15:18:18 -0500 (CDT) Subject: [Swift-commit] r8232 - www/Swift-T Message-ID: <20140827201818.DCF599CFB2@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-27 15:18:18 -0500 (Wed, 27 Aug 2014) New Revision: 8232 Modified: www/Swift-T/turbine-sites.html Log: Fix numbers Modified: www/Swift-T/turbine-sites.html =================================================================== --- www/Swift-T/turbine-sites.html 2014-08-27 20:11:13 UTC (rev 8231) +++ www/Swift-T/turbine-sites.html 2014-08-27 20:18:18 UTC (rev 8232) @@ -1714,13 +1714,14 @@

PPN is handled by setting the -n argument.

The turbine-aprun-run.zsh script supports Titan. You can invoke -it as follows (for a single node/32 processes per node):

+it as follows (for a 2 nodes, 32 processes per node):

export PROJECT=MAT049
 export QUEUE=debug
 export TITAN=true
-turbine-aprun-run.zsh -n 32 helloworld.tcl
+export PPN=32 +turbine-aprun-run.zsh -n 64 helloworld.tcl

These environment variables may be placed in your -s settings file.

@@ -2283,7 +2284,7 @@ From swift at ci.uchicago.edu Wed Aug 27 17:25:07 2014 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Wed, 27 Aug 2014 17:25:07 -0500 (CDT) Subject: [Swift-commit] cog r4043 Message-ID: <20140827222507.47C568D000A9@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r4043 | timgarmstrong | 2014-08-27 17:21:30 -0500 (Wed, 27 Aug 2014) | 1 line Print debug messages at appropriate log level ------------------------------------------------------------------------ Index: modules/provider-coaster-c-client/src/JobSubmitCommand.cpp =================================================================== --- modules/provider-coaster-c-client/src/JobSubmitCommand.cpp (revision 4042) +++ modules/provider-coaster-c-client/src/JobSubmitCommand.cpp (working copy) @@ -5,7 +5,6 @@ using namespace Coaster; -using std::cout; using std::map; using std::ostream; using std::string; @@ -75,12 +74,12 @@ } if (job->getJobManager().empty()) { - cout<< "getJobManager == NULL, setting to : fork "<< endl; + LogDebug << "getJobManager == NULL, setting to : fork "<< endl; add(ss, "jm", "fork"); } else { - const char *jm_string = (job->getJobManager()).c_str(); - cout<< "getJobManager != !NULL, setting to : "<< job->getJobManager() << endl; + const char *jm_string = (job->getJobManager()).c_str(); + LogDebug << "getJobManager != !NULL, setting to : "<< job->getJobManager() << endl; add(ss, "jm", jm_string); } addOutData(Buffer::wrap(ss)); From swift at ci.uchicago.edu Wed Aug 27 17:35:06 2014 From: swift at ci.uchicago.edu (swift at ci.uchicago.edu) Date: Wed, 27 Aug 2014 17:35:06 -0500 (CDT) Subject: [Swift-commit] cog r4044 Message-ID: <20140827223506.7DBF88D000A9@bridled.ci.uchicago.edu> ------------------------------------------------------------------------ r4044 | timgarmstrong | 2014-08-27 17:30:27 -0500 (Wed, 27 Aug 2014) | 1 line Add feature to remove settings ------------------------------------------------------------------------ Index: modules/provider-coaster-c-client/src/coaster.cpp =================================================================== --- modules/provider-coaster-c-client/src/coaster.cpp (revision 4043) +++ modules/provider-coaster-c-client/src/coaster.cpp (working copy) @@ -234,6 +234,19 @@ } coaster_rc +coaster_settings_remove(coaster_settings *settings, + const char *key, size_t key_len) COASTER_THROWS_NOTHING { + try { + settings->remove(key, key_len); + return COASTER_SUCCESS; + } catch (const CoasterError& err) { + return coaster_error_rc(err); + } catch (const std::exception& ex) { + return exception_rc(ex); + } +} + +coaster_rc coaster_settings_get(coaster_settings *settings, const char *key, size_t key_len, const char **value, size_t *value_len) COASTER_THROWS_NOTHING { Index: modules/provider-coaster-c-client/src/Settings.h =================================================================== --- modules/provider-coaster-c-client/src/Settings.h (revision 4043) +++ modules/provider-coaster-c-client/src/Settings.h (working copy) @@ -34,6 +34,7 @@ void set(const char* key, size_t key_len, const char* value, size_t value_len); void remove(const std::string& key); + void remove(const char* key, size_t key_len); bool contains(const std::string& key); Index: modules/provider-coaster-c-client/src/Settings.cpp =================================================================== --- modules/provider-coaster-c-client/src/Settings.cpp (revision 4043) +++ modules/provider-coaster-c-client/src/Settings.cpp (working copy) @@ -60,6 +60,10 @@ settings.erase(key); } +void Settings::remove(const char* key, size_t key_len) { + settings.erase(key); +} + bool Settings::contains(const string& key) { return settings.find(key) != settings.end(); } Index: modules/provider-coaster-c-client/src/coaster.h =================================================================== --- modules/provider-coaster-c-client/src/coaster.h (revision 4043) +++ modules/provider-coaster-c-client/src/coaster.h (working copy) @@ -148,14 +148,25 @@ coaster_rc coaster_settings_parse(coaster_settings *settings, const char *str, size_t str_len, char separator) COASTER_THROWS_NOTHING; + /* - * Set settings individually. + * Set settings individually. Will overwrite previous values. + * key[_len]: settings key (must be non-null) + * values[_len]: settings value (must be non-null) */ coaster_rc coaster_settings_set(coaster_settings *settings, const char *key, size_t key_len, const char *value, size_t value_len) COASTER_THROWS_NOTHING; /* + * Erase a key/value pair in settings. + * key[_len]: settings key (must be non-null) + */ +coaster_rc +coaster_settings_remove(coaster_settings *settings, + const char *key, size_t key_len) COASTER_THROWS_NOTHING; + +/* * Get settings individually. * value[_len]: set to value of string, null if not present in settings. * Settings retains ownership of strings: any subsequent From wozniak at ci.uchicago.edu Thu Aug 28 09:37:42 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Thu, 28 Aug 2014 09:37:42 -0500 (CDT) Subject: [Swift-commit] r8233 - usertools/plotter/src/plotter Message-ID: <20140828143742.D388E9CFBF@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-28 09:37:41 -0500 (Thu, 28 Aug 2014) New Revision: 8233 Modified: usertools/plotter/src/plotter/Lines.java Log: Merge Modified: usertools/plotter/src/plotter/Lines.java =================================================================== --- usertools/plotter/src/plotter/Lines.java 2014-08-27 20:18:18 UTC (rev 8232) +++ usertools/plotter/src/plotter/Lines.java 2014-08-28 14:37:41 UTC (rev 8233) @@ -19,11 +19,7 @@ import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.XYTextAnnotation; -import org.jfree.chart.axis.DateAxis; -import org.jfree.chart.axis.LogAxis; -import org.jfree.chart.axis.LogarithmicAxis; -import org.jfree.chart.axis.NumberAxis; -import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.axis.*; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; @@ -329,8 +325,8 @@ } else if (axis_x_type.equals("date")) { - DateAxis dateAxis = new DateAxis(xlabel); - plot.setDomainAxis(dateAxis); + DateAxis domainAxis = new DateAxis(); + plot.setDomainAxis(domainAxis); } else if (!axis_x_type.equals("normal")) throw new UserInputException From wilde at ci.uchicago.edu Wed Aug 13 18:08:09 2014 From: wilde at ci.uchicago.edu (wilde at ci.uchicago.edu) Date: Wed, 13 Aug 2014 23:08:09 -0000 Subject: [Swift-commit] r8164 - in SwiftTutorials/ATPESC_2014-08-14: . swift-k swift-k/app swift-k/bin swift-k/doc swift-k/doc/figs swift-k/doc/images swift-k/doc/images/icons swift-k/part01 swift-k/part01m swift-k/part02 swift-k/part02m swift-k/part03 swift-k/part03m swift-k/part04 swift-k/part05 swift-k/part06 swift-k/part06m swift-k/part07 swift-k/part08 swift-k/src swift-k/src/c-ray swift-k/src/md swift-k/src/shdemo Message-ID: <20140813231419.CE8E39D92B@svn.ci.uchicago.edu> Author: wilde Date: 2014-08-13 18:14:19 -0500 (Wed, 13 Aug 2014) New Revision: 8164 Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/ SwiftTutorials/ATPESC_2014-08-14/swift-k/README SwiftTutorials/ATPESC_2014-08-14/swift-k/app/ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/genmovie SwiftTutorials/ATPESC_2014-08-14/swift-k/app/gettrj.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdmaxk SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdstats SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdtotk SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdviz SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe SwiftTutorials/ATPESC_2014-08-14/swift-k/app/simulate SwiftTutorials/ATPESC_2014-08-14/swift-k/app/stats SwiftTutorials/ATPESC_2014-08-14/swift-k/app/viz SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/ SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/cleanup SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/hosts SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/package_tutorial.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/plot.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/TODO SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/activeplot.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/asciidoc.css SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/build_docs.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/cumulativeplot.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/modis.dia SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/modis.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/caution.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/example.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/home.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/important.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/next.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/note.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/prev.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/tip.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/up.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/warning.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part01.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part02.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part03.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part04.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part05.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part06.png SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/push.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/ SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/p1.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/ SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/p1.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/ SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/p2.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/ SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/p2.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/ SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/p3.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/ SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/p3.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/ SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/p4.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/ SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/p5.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/ SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/p6.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/ SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/p6m.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/ SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/md.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.swift SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.midway.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/src/ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/Makefile SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/README SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/c-ray.c SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/scene.cr SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/sphfract.cr SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/test.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/Makefile SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/clean.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/main.c SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/make-package.tcl SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.c SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.h SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.i SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.tcl SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.tcl SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d01.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d02.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d03.sh SwiftTutorials/ATPESC_2014-08-14/swift-k/tukey.properties SwiftTutorials/ATPESC_2014-08-14/swift-k/tutorial.pptx Log: Copy swift-k tutorial structure from xsede.2014.0425 where the md (particle) demo was developed, for ATPESC 2014. Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/README =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/README (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/README 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1 @@ +link doc/README \ No newline at end of file Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/README ___________________________________________________________________ Added: svn:special + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/genmovie =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/genmovie (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/genmovie 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,6 @@ +#! /bin/sh + +movie=$1 +shift + +convert -delay 20 $* $movie Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/gettrj.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/gettrj.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/gettrj.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,3 @@ +# awk "\$1 == ${1:-1} { print \$0 }" + +awk "\$1 == ${1:-1} { for (i=2; i maxKe ) maxKe = Ke; + LASTFILE=FILENAME +} + +#END { printf("max Ke for %s is %f\n", LASTFILE, maxKe ) } + END { printf("%s %f\n", FILENUM, maxKe ) } + + + +' $* | sort -n -k2 | tail -$nfiles # | awk '{print $1}' + +# log 1>&2 Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdmaxk ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdstats =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdstats (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdstats 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,23 @@ +#! /bin/sh + +log() { + printf "\nCalled as: $0: $cmdargs\n\n" + printf "Start time: "; /bin/date + printf "Running as user: "; /usr/bin/id + printf "Running on node: "; /bin/hostname + printf "Node IP address: "; /bin/hostname -I + printf "\nEnvironment:\n\n" + printenv | sort +} + +awk ' + +{ + sum2 += $2 + sum3 += $3 + sum4 += $4 +} + +END { printf("%f %f %f\n", sum2/NR, sum3/NR, sum4/NR) } +' $* +log 1>&2 Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdstats ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdtotk =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdtotk (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdtotk 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,37 @@ +#! /bin/sh + +log() { + printf "\nCalled as: $0: $cmdargs\n\n" + printf "Start time: "; /bin/date + printf "Running as user: "; /usr/bin/id + printf "Running on node: "; /bin/hostname + printf "Node IP address: "; /bin/hostname -I + printf "\nEnvironment:\n\n" + printenv | sort +} + +nfiles=$1 +shift + +gawk ' + +BEGIN { totKe = 0.0; LASTFILE=""; FILENUM=0} + +{ + if ( $1 == "Step" ) next; + if ( (LASTFILE != "") && (FILENAME != LASTFILE)) { + printf("%s %f\n", FILENUM++, totKe ) + totKe = 0.0; + } + totKe += $3 + 0.0; + LASTFILE=FILENAME +} + +#END { printf("tot Ke for %s is %f\n", LASTFILE, totKe ) } + END { printf("%s %f\n", FILENUM, totKe ) } + + + +' $* | sort -n -k2 | tail -$nfiles # | awk '{print $1}' + +# log 1>&2 Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdtotk ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdviz =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdviz (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdviz 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,29 @@ +#! /bin/sh + +mdout=$1 +vzout=$2 +shift 2 + +md "$@" >& md.out # Run the MD command + +cat <c-ray-cmds +# walls +s 0 -1000 2 99 0.2 0.2 0.2 0.0 0.0 + +# lights +l -50 100 -50 + +# camera +# position FOV target +c 0 6 -17 45 0 -1 0 +EOF + +for t in md??.trj; do + cat $t c-ray-cmds | c-ray >$t.ppm + convert $t.ppm $t.png +done + +convert -delay 20 md??.trj.png t.gif + +mv md.dat $mdout +mv t.gif $vzout Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/mdviz ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,30 @@ +#! /bin/sh + +mdtrj=$1 +vzout=$2 +frame=$3 + +APPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +cat <c-ray-trailer +# walls +s 0 -1000 2 99 0.2 0.2 0.2 0.0 0.0 + +# lights +l -50 100 -50 + +# camera +# position FOV target +c 0 6 -17 45 0 -1 0 +END + +( + awk "\$1 == $frame {for (i=2; it.ppm + +convert t.ppm $vzout + + + Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/renderframe ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/simulate =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/simulate (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/simulate 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,135 @@ +#! /bin/bash + +printparams() +{ + printf "\nSimulation parameters:\n\n" + echo bias=$bias + echo biasfile=$biasfile + echo initseed=$initseed + echo log=$log + echo paramfile=$paramfile + echo range=$range + echo scale=$scale + echo seedfile=$seedfile + echo timesteps=$timesteps + echo output width=$width +} + +log() { + printf "\nCalled as: $0: $cmdargs\n\n" + printf "Start time: "; /bin/date + printf "Running as user: "; /usr/bin/id + printf "Running on node: "; /bin/hostname + printf "Node IP address: "; /bin/hostname -I + printparams + printf "\nEnvironment:\n\n" + printenv | sort +} + +addsims() { + while read f1 ; do + read -u 3 f2 + if [ _$f1 = _ ]; then f1=$lastf1; fi + if [ _$f2 = _ ]; then f2=$lastf2; fi + printf "%${width}d\n" $(($f1+$f2)) + lastf1=$f1 + lastf2=$f2 + done <$1 3<$2 +} + +# set defaults + +bias=0 +biasfile=none +initseed=none +log=yes +paramfile=none +range=100 +scale=1 +seedfile=none +timesteps=0 +nvalues=1 +width=8 +cmdargs="$*" + +usage() +{ + echo $( basename $0 ): usage: + cat <$simout + +# process file of biases + +if [ $biasfile != none ]; then + addsims $simout $biasfile +else + cat $simout +fi +rm $simout + +# log environmental data + +if [ $log != off ]; then + log 1>&2 +fi Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/simulate ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/stats =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/stats (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/stats 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,19 @@ +#! /bin/sh + +log() { + printf "\nCalled as: $0: $cmdargs\n\n" + printf "Start time: "; /bin/date + printf "Running as user: "; /usr/bin/id + printf "Running on node: "; /bin/hostname + printf "Node IP address: "; /bin/hostname -I + printf "\nEnvironment:\n\n" + printenv | sort +} + +awk ' + +{ sum += $1} + +END { printf("%f\n",sum/NR) } +' $* +log 1>&2 Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/stats ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/viz =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/app/viz (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/app/viz 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,34 @@ +#! /bin/sh + +mdtrj=$1 +vzout=$2 + +wd=`mktemp -d viz.XXXXXX` + +ln $1 $wd + +cd $wd + +tar zxf *.tgz + +cat <c-ray-cmds +# walls +s 0 -1000 2 99 0.2 0.2 0.2 0.0 0.0 + +# lights +l -50 100 -50 + +# camera +# position FOV target +c 0 6 -17 45 0 -1 0 +EOF + +for t in md??.trj; do + cat $t c-ray-cmds | c-ray >$t.ppm + convert $t.ppm $t.png +done + +convert -delay 20 md??.trj.png ../$(basename $1 .tgz).gif + +# mv md.dat $mdout +# mv t.gif $vzout Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/app/viz ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/cleanup =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/cleanup (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/cleanup 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,2 @@ +rm -rf *.rlog *.kml *.swiftx *.out output outdir logs hi.* _concurrent .swift/tmp run0* + Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/cleanup ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/hosts =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/hosts (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/hosts 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1 @@ +for h in $(cat hosts.txt); do ssh $h hostname -f; done Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/hosts ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/package_tutorial.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/package_tutorial.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/package_tutorial.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,15 @@ +#! /bin/sh + +BIN=$(cd $(dirname $0); pwd) +BASE=$(cd $BIN/..; pwd) +LOC=$(cd $BASE/..; pwd) + +echo executing $0 from BIN=$BIN +echo making tutorial package of BASE=$BASE +echo placing tutorial package in LOC=$LOC + +( + cd $LOC + tar zcf swift-cray-tutorial.tgz --exclude-vcs swift-cray-tutorial + scp swift-cray-tutorial.tgz p01532 at raven.cray.com: +) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/package_tutorial.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/plot.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/plot.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/plot.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,68 @@ +#!/bin/bash + +#usage: ./plotswiftlogs.ketan + +SWIFTLOGFILE=$1 + +#TMPDIR=`mktemp -d plotlog.XXX` + +grep -i ProgressTicker $SWIFTLOGFILE > swiftoutfile.out + +SWIFTOUTFILE=swiftoutfile.out + +#extract start time +TMPDATE=`grep -i progress $SWIFTOUTFILE 2>/dev/null | head -n 1 | cut -f1-2 -d ' '` +START_TIME=`date +%s -d "$TMPDATE"` + +#extract end time +TMPDATE=`grep -i progress $SWIFTOUTFILE 2>/dev/null | tail -n 1 | cut -f1-2 -d ' '` +END_TIME=`date +%s -d "$TMPDATE"` + +#duration +DIFFTIME=$((END_TIME - START_TIME)) + +#extract active runs in a file +(grep -o -i "Active:[0-9]*" $SWIFTOUTFILE 2>/dev/null | awk -F: '{print $2}' >active.txt) + +#extract successful completions in a file +(grep -o -i "Successfully:[0-9]*" $SWIFTOUTFILE 2>/dev/null | awk -F: '{print $2}' > cumulative.txt) + +#prepare tics +activelines=`wc -l active.txt | awk '{print $1}'` +cumulines=`wc -l cumulative.txt | awk '{print $1}'` + +if [ $activelines -ne 0 ] +then + activelinespertic=`echo "scale=5 ; $DIFFTIME / $activelines" | bc` +fi + +seq 0 $activelinespertic $DIFFTIME > activetics.txt + +if [ $cumulines -ne 0 ] +then + cumulinespertic=`echo "scale=5 ; $DIFFTIME / $cumulines" | bc` +fi + +seq 0 $cumulinespertic $DIFFTIME > cumultics.txt + +#final plot data +paste activetics.txt active.txt > plot_active.txt +paste cumultics.txt cumulative.txt > plot_cumulative.txt + +cat << EOF1 > plotit.gp +set terminal png enhanced +set nokey +set output "cumulativeplot.png" +set xlabel "Time in sec" +set ylabel "number of completed apps" +set title "Cumulative Apps Completed" +plot "plot_cumulative.txt" using 1:2 with lines +set output "activeplot.png" +set xlabel "Time in sec" +set ylabel "number of active apps" +set title "Active Apps" +plot "plot_active.txt" using 1:2 with line +EOF1 + +gnuplot plotit.gp 2>/dev/null +rm swiftoutfile.out plotit.gp active.txt cumulative.txt activetics.txt plot_active.txt plot_cumulative.txt cumultics.txt Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/bin/plot.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/README 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,717 @@ +Swift Tutorial for RCC Midway Cluster +===================================== + +//// + +This is the asciidoc input file. +Its content is viewable as a plain-text README file. + +//// + +This tutorial is viewable at: +http://swiftlang.org/tutorials/midway/tutorial.html + +//// + +Tutorial Outline: + +Introductory example, running apps locally on login node: + + p1 - Run an application under Swift + p2 - Parallel loops with foreach + p3 - Merging/reducing the results of a parallel foreach loop + +Compute-node exercises, running apps via qsub and aprun: + + p4 - Running apps on RCC Midway cluster + p5 - Running on multiple pools of compute nodes + p6 - Running a more complex workflow pattern + +//// + +Introduction: Why Parallel Scripting? +------------------------------------ + +Swift is a simple scripting language for executing many instances of +ordinary application programs on distributed parallel resources. +Swift scripts run many copies of ordinary programs concurrently, using +statements like this: +----- +foreach protein in proteinList { + runBLAST(protein); +} +----- +Swift acts like a structured "shell" language. It runs programs +concurrently as soon as their inputs are available, reducing the need +for complex parallel programming. Swift expresses your workflow in a +portable fashion: The same script runs on multicore computers, +clusters, clouds, grids, and supercomputers. + +In this tutorial, you'll be able to first try a few Swift examples +(parts 1-3) on a Midway login host, to get a sense of the +language. Then in parts 4-6 you'll run similar workflows on Midway +compute nodes, and see how more complex workflows can be expressed +with Swift scripts. + +Swift tutorial setup +-------------------- +If you are using a temporary/guest account to access Midway, follow +the instructions at http://docs.rcc.uchicago.edu/tutorials/intro-to-rcc-workshop.html +for more information on using a yubikey to log in. + +Once you are logged into the Midway login host, run the following commands +to set up your environment. + +----- +$ cd $HOME +$ wget http://swiftlang.org/tutorials/midway/swift-midway-tutorial.tar.gz +$ tar xvfz swift-midway-tutorial.tar.gz +$ cd swift-midway-tutorial +$ source setup.sh +----- + +Verify your environment +~~~~~~~~~~~~~~~~~~~~~~~ + +To verify that Swift loaded, do: + +----- +$ swift -version # verify that you have Swift 0.95 RC1 +----- + +NOTE: If you re-login or open new ssh sessions, you must re-run `source setup.sh` in each ssh shell/window. + +To check out the tutorial scripts from SVN +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you later want to get the most recent version of this tutorial from +the Swift Subversion repository, do: + +----- +$ svn co https://svn.ci.uchicago.edu/svn/vdl2/SwiftTutorials/swift-midway-tutorial +----- + +This will create a directory called "swift-midway-tutorial" which contains all of the +files used in this tutorial. + + +Simple "science applications" for the workflow tutorial +------------------------------------------------------- + +This tutorial is based on two intentionally trivial example programs, +`simulation` and `stats`, (implemented as bash shell scripts) +that serve as easy-to-understand proxies for real science +applications. These "programs" behave as follows. + +simulate.sh +~~~~~~~~~~~ + +The simulation script serves as a trivial proxy for any more +complex scientific simulation application. It generates and prints a +set of one or more random integers in the range [0-2^62) as controlled +by its command line arguments, which are: + +----- +$ simulate -help +simulate: usage: + -b|--bias offset bias: add this integer to all results + -B|--biasfile file of integer biases to add to results + -l|--log generate a log in stderr if not null + -n|--nvalues print this many values per simulation + -r|--range range (limit) of generated results + -s|--seed use this integer [0..32767] as a seed + -S|--seedfile use this file (containing integer seeds [0..32767]) one per line + -t|--timesteps number of simulated "timesteps" in seconds (determines runtime) + -x|--scale scale the results by this integer + -h|-?|?|--help print this help +----- + +All of these arguments are optional, with default values indicated above as `[n]`. + +//// +.simulation arguments +[width="80%",cols="^2,10",options="header"] + +|======================= +|Argument|Short|Description +|1 |runtime: sets run time of simulation in seconds +|2 |range: limits generated values to the range [0,range-1] +|3 |biasfile: add the integer contained in this file to each value generated +|4 |scale: multiplies each generated value by this integer +|5 |count: number of values to generate in the simulation +|======================= +//// + +With no arguments, simulate prints 1 number in the range of +1-100. Otherwise it generates n numbers of the form (R*scale)+bias +where R is a random integer. By default it logs information about its +execution environment to stderr. Here's some examples of its usage: + +----- +$ simulate 2>log + 51 +$ head -5 log + +Called as: /home/davidkelly999/swift-midway-tutorial/app/simulate: +Start time: Mon Dec 2 13:47:41 CST 2013 +Running as user: uid=88848(davidkelly999) gid=88848(davidkelly999) groups=88848(davidkelly999),10008(rcc),10030(pi-gavoth),10031(sp-swift),10036(swift),10058(pi-joshuaelliott),10084(pi-wilde),10118(cron-account),10124(cmts),10138(cmtsworkshop) + +$ simulate -n 4 -r 1000000 2>log + 239454 + 386702 + 13849 + 873526 + +$ simulate -n 3 -r 1000000 -x 100 2>log + 6643700 +62182300 + 5230600 + +$ simulate -n 2 -r 1000 -x 1000 2>log + 565000 + 636000 + +$ time simulate -n 2 -r 1000 -x 1000 -t 3 2>log + 336000 + 320000 +real 0m3.012s +user 0m0.005s +sys 0m0.006s +----- + +stats +~~~~~ + +The stats script serves as a trivial model of an "analysis" +program. It reads N files each containing M integers and simply prints +the average of all those numbers to stdout. Similarly to simulate +it logs environmental information to the stderr. + +----- +$ ls f* +f1 f2 f3 f4 + +$ cat f* +25 +60 +40 +75 + +$ stats f* 2>log +50 +----- + + +Basic of the Swift language with local execution +------------------------------------------------ + +A Summary of Swift in a nutshell +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* Swift scripts are text files ending in `.swift` The `swift` command +runs on any host, and executes these scripts. `swift` is a Java +application, which you can install almost anywhere. On Linux, just +unpack the distribution `tar` file and add its `bin/` directory to +your `PATH`. + +* Swift scripts run ordinary applications, just like shell scripts +do. Swift makes it easy to run these applications on parallel and +remote computers (from laptops to supercomputers). If you can `ssh` to +the system, Swift can likely run applications there. + +* The details of where to run applications and how to get files back +and forth are described in configuration files separate from your +program. Swift speaks ssh, PBS, Condor, SLURM, LSF, SGE, Cobalt, and +Globus to run applications, and scp, http, ftp, and GridFTP to move +data. + +* The Swift language has 5 main data types: `boolean`, `int`, +`string`, `float`, and `file`. Collections of these are dynamic, +sparse arrays of arbitrary dimension and structures of scalars and/or +arrays defined by the `type` declaration. + +* Swift file variables are "mapped" to external files. Swift sends +files to and from remote systems for you automatically. + +* Swift variables are "single assignment": once you set them you can't +change them (in a given block of code). This makes Swift a natural, +"parallel data flow" language. This programming model keeps your +workflow scripts simple and easy to write and understand. + +* Swift lets you define functions to "wrap" application programs, and +to cleanly structure more complex scripts. Swift `app` functions take +files and parameters as inputs and return files as outputs. + +* A compact set of built-in functions for string and file +manipulation, type conversions, high level IO, etc. is provided. +Swift's equivalent of `printf()` is `tracef()`, with limited and +slightly different format codes. + +* Swift's `foreach {}` statement is the main parallel workhorse of the +language, and executes all iterations of the loop concurrently. The +actual number of parallel tasks executed is based on available +resources and settable "throttles". + +* In fact, Swift conceptually executes *all* the statements, +expressions and function calls in your program in parallel, based on +data flow. These are similarly throttled based on available resources +and settings. + +* Swift also has `if` and `switch` statements for conditional +execution. These are seldom needed in simple workflows but they enable +very dynamic workflow patterns to be specified. + +We'll see many of these points in action in the examples below. Lets +get started! + +Part 1: Run a single application under Swift +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The first swift script, p1.swift, runs simulate to generate a +single random number. It writes the number to a file. + +image::part01.png["p1 workflow",align="center"] + +.p1.swift +----- +sys::[cat ../part01/p1.swift] +----- + + +To run this script, run the following command: +----- +$ cd part01 +$ swift p1.swift +Swift 0.94.1 RC2 swift-r6895 cog-r3765 + +RunID: 20130827-1413-oa6fdib2 +Progress: time: Tue, 27 Aug 2013 14:13:33 -0500 +Final status: Tue, 27 Aug 2013 14:13:33 -0500 Finished successfully:1 +$ cat sim.out + 84 +$ swift p1.swift +$ cat sim.out + 36 +----- + +To cleanup the directory and remove all outputs (including the log +files and directories that Swift generates), run the cleanup script +which is located in the tutorial PATH: + +----- +$ cleanup +------ + +NOTE: You'll also find a Swift configuration file in each `partNN` +directory of this tutorial. This file specifies the environment-specific +details of how to run. These files will be explained in more +detail in parts 4-6, and can be ignored for now. + +Part 2: Running an ensemble of many apps in parallel with a "foreach" loop +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The `p2.swift` script introduces the `foreach` parallel iteration +construct to run many concurrent simulations. + +image::part02.png[align="center"] + +.p2.swift +----- +sys::[cat ../part02/p2.swift] +----- + +The script also shows an +example of naming the output files of an ensemble run. In this case, the output files will be named +`output/sim_N.out`. + +To run the script and view the output: +----- +$ cd ../part02 +$ swift p2.swift +$ ls output +sim_0.out sim_1.out sim_2.out sim_3.out sim_4.out sim_5.out sim_6.out sim_7.out sim_8.out sim_9.out +$ more output/* +:::::::::::::: +output/sim_0.out +:::::::::::::: + 44 +:::::::::::::: +output/sim_1.out +:::::::::::::: + 55 +... +:::::::::::::: +output/sim_9.out +:::::::::::::: + 82 +----- + +Part 3: Analyzing results of a parallel ensemble +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +After all the parallel simulations in an ensemble run have completed, +its typically necessary to gather and analyze their results with some +kind of post-processing analysis program or script. p3.swift +introduces such a postprocessing step. In this case, the files created +by all of the parallel runs of `simulation` will be averaged by by +the trivial "analysis application" `stats`: + +image::part03.png[align="center"] + +.p3.swift +---- +sys::[cat ../part03/p3.swift] +---- + +To run: +---- +$ cd part03 +$ swift p3.swift +---- + +Note that in `p3.swift` we expose more of the capabilities of the +`simulate` application to the `simulation()` app function: + +----- +app (file o) simulation (int sim_steps, int sim_range, int sim_values) +{ + simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=@filename(o); +} +----- + +`p3.swift` also shows how to fetch application-specific values from +the `swift` command line in a Swift script using `arg()` which +accepts a keyword-style argument and its default value: + +----- +int nsim = toInt(arg("nsim","10")); +int steps = toInt(arg("steps","1")); +int range = toInt(arg("range","100")); +int values = toInt(arg("values","5")); +----- + +Now we can specify that more runs should be performed and that each should run +for more timesteps, and produce more that one value each, within a specified range, +using command line arguments placed after the Swift script name in the form `-parameterName=value`: + +----- +$ swift p3.swift -nsim=3 -steps=10 -values=4 -range=1000000 + +Swift 0.94.1 RC2 swift-r6895 cog-r3765 + +RunID: 20130827-1439-s3vvo809 +Progress: time: Tue, 27 Aug 2013 14:39:42 -0500 +Progress: time: Tue, 27 Aug 2013 14:39:53 -0500 Active:2 Stage out:1 +Final status: Tue, 27 Aug 2013 14:39:53 -0500 Finished successfully:4 + +$ ls output/ +average.out sim_0.out sim_1.out sim_2.out +$ more output/* +:::::::::::::: +output/average.out +:::::::::::::: +651368 +:::::::::::::: +output/sim_0.out +:::::::::::::: + 735700 + 886206 + 997391 + 982970 +:::::::::::::: +output/sim_1.out +:::::::::::::: + 260071 + 264195 + 869198 + 933537 +:::::::::::::: +output/sim_2.out +:::::::::::::: + 201806 + 213540 + 527576 + 944233 +----- + +Now try running (`-nsim=`) 100 simulations of (`-steps=`) 1 second each: + +----- +$ swift p3.swift -nsim=100 -steps=1 +Swift 0.94.1 RC2 swift-r6895 cog-r3765 + +RunID: 20130827-1444-rq809ts6 +Progress: time: Tue, 27 Aug 2013 14:44:55 -0500 +Progress: time: Tue, 27 Aug 2013 14:44:56 -0500 Selecting site:79 Active:20 Stage out:1 +Progress: time: Tue, 27 Aug 2013 14:44:58 -0500 Selecting site:58 Active:20 Stage out:1 Finished successfully:21 +Progress: time: Tue, 27 Aug 2013 14:44:59 -0500 Selecting site:37 Active:20 Stage out:1 Finished successfully:42 +Progress: time: Tue, 27 Aug 2013 14:45:00 -0500 Selecting site:16 Active:20 Stage out:1 Finished successfully:63 +Progress: time: Tue, 27 Aug 2013 14:45:02 -0500 Active:15 Stage out:1 Finished successfully:84 +Progress: time: Tue, 27 Aug 2013 14:45:03 -0500 Finished successfully:101 +Final status: Tue, 27 Aug 2013 14:45:03 -0500 Finished successfully:101 +----- + +We can see from Swift's "progress" status that the tutorial's default +parameters for local execution allow Swift to run up to 20 +application invocations concurrently on the login node. We'll look at +this in more detail in the next sections where we execute applications +on the site's compute nodes. + + +Running applications on Midway compute nodes with Swift +------------------------------------------------------- + +Part 4: Running a parallel ensemble on Midway compute nodes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`p4.swift` will run our mock "simulation" applications on Midway +compute nodes. The script is similar to as `p3.swift`, but specifies +that each simulation app invocation should additionally return the +log file which the application writes to `stderr`. + +Now when you run `swift p4.swift` you'll see that two types output +files will placed in the `output/` directory: `sim_N.out` and +`sim_N.log`. The log files provide data on the runtime environment of +each app invocation. For example: + +----- +$ cat output/sim_0.log +Called as: /home/davidkelly999/swift-midway-tutorial/app/simulate: --timesteps 1 --range 100 --nvalues 5 + +Start time: Mon Dec 2 12:17:06 CST 2013 +Running as user: uid=88848(davidkelly999) gid=88848(davidkelly999) groups=88848(davidkelly999),10008(rcc),10030(pi-gavoth),10031(sp-swift),10036(swift),10058(pi-joshuaelliott),10084(pi-wilde),10118(cron-account),10124(cmts),10138(cmtsworkshop) +Running on node: midway002 +Node IP address: 10.50.181.2 172.25.181.2 + +Simulation parameters: + +bias=0 +biasfile=none +initseed=none +log=yes +paramfile=none +range=100 +scale=1 +seedfile=none +timesteps=1 +output width=8 + +Environment: + +ANTLR_ROOT=/software/antlr-2.7-el6-x86_64 +ANT_HOME=/software/ant-1.8.4-all +ANT_HOME_modshare=/software/ant-1.8.4-all:3 +... +----- + +Swift's `swift.properties` configuration file allows many parameters to +specify how jobs should be run on a given cluster. + +Consider for example that Midway has several Slurm partitions. The sandyb +partition has 16 cores, and the westmere partition has 12 cores. Depending +on the application and which partitions are busy, you may want to modify +where you run. + +Here is an example of the swift.properties in the part04 directory: + +----- +site=westmere +site.westmere.slurm.reservation=workshop +site.westmere.slurm.exclusive=false +----- + +The first line, site=westmere, allows you to define which partition to run on. Swift includes +templates for each partition that provides some reasonable default values. Other valid partitions +are amd, bigmem, gpu, local, and sandyb. + +The second and third line override some of the default values, by specifying a reservation that will +be used for this session, and enabling node sharing. + +Try changing the queue to run on the sandyb queue. The new swift.properties should look like this: +----- +site=sandyb +site.sandyb.slurm.reservation=workshop +site.sandyb.slurm.exclusive=false +---- + +Performing larger Swift runs +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To test with larger runs, there are two changes that are required. The first is a +change to the command line arguments. The example below will run 1000 simulations +with each simulation taking 5 seconds. + +----- +$ swift p6.swift -steps=5 -nsim=1000 +----- + +Plotting run activity +~~~~~~~~~~~~~~~~~~~~~ + +The tutorial `bin` directory in your `PATH` provides a script +`plot.sh` to plot the progress of a Swift script. It generates two +image files: `activeplot.png`, which shows the number of active jobs +over time, and `cumulativeplot.png`, which shows the total number of +app calls completed as the Swift script progresses. + +After each Swift run, a new run directory is created called runNNN. +Each run directory will have a log file with a similar name called +runNNN.log. Once you have identified the log file name, run the +command `plot.sh` ` to generate the plots for that +specific run. For example: + +----- +$ ls +output p3.swift run000 swift.properties + +$ cd run000/ + +$ ls +apps cf p3-20131202-2004-0kh4ha6e.d run000.log sites.xml + +$ plot.sh run000.log +----- + +This yields plots like: + +image::activeplot.png[width=700,align=center] +image::cumulativeplot.png[width=700,align=center] + +Part 5: Controlling the compute-node pools where applications run +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This section is under development. + +Part 6: Specifying more complex workflow patterns +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +p6.swift expands the workflow pattern of p4.swift to add additional +stages to the workflow. Here, we generate a dynamic seed value that +will be used by all of the simulations, and for each simulation, we +run an pre-processing application to generate a unique "bias +file". This pattern is shown below, followed by the Swift script. + +image::part06.png[align="center"] + +.p6.swift +---- +sys::[cat ../part06/p6.swift] +---- + +Note that the workflow is based on data flow dependencies: each simulation depends on the seed value, calculated in this statement: +----- +seedfile = genseed(1); +----- +and on the bias file, computed and then consumed in these two dependent statements: +----- + biasfile = genbias(1000, 20); + (simout,simlog) = simulation(steps, range, biasfile, 1000000, values, seedfile); +----- + +To run: +---- +$ cd ../part06 +$ swift p6.swift +---- + +The default parameters result in the following execution log: + +----- +$ swift p6.swift +Swift 0.94.1 RC2 swift-r6895 cog-r3765 + +RunID: 20130827-1917-jvs4gqm5 +Progress: time: Tue, 27 Aug 2013 19:17:56 -0500 + +*** Script parameters: nsim=10 range=100 num values=10 + +Progress: time: Tue, 27 Aug 2013 19:17:57 -0500 Stage in:1 Submitted:10 +Generated seed=382537 +Progress: time: Tue, 27 Aug 2013 19:17:59 -0500 Active:9 Stage out:1 Finished successfully:11 +Final status: Tue, 27 Aug 2013 19:18:00 -0500 Finished successfully:22 +----- +which produces the following output: +----- +$ ls -lrt output +total 264 +-rw-r--r-- 1 p01532 61532 9 Aug 27 19:17 seed.dat +-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_9.dat +-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_8.dat +-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_7.dat +-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_6.dat +-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_5.dat +-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_4.dat +-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_3.dat +-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_2.dat +-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_1.dat +-rw-r--r-- 1 p01532 61532 180 Aug 27 19:17 bias_0.dat +-rw-r--r-- 1 p01532 61532 90 Aug 27 19:17 sim_9.out +-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_9.log +-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_8.log +-rw-r--r-- 1 p01532 61532 90 Aug 27 19:17 sim_7.out +-rw-r--r-- 1 p01532 61532 90 Aug 27 19:17 sim_6.out +-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_6.log +-rw-r--r-- 1 p01532 61532 90 Aug 27 19:17 sim_5.out +-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_5.log +-rw-r--r-- 1 p01532 61532 90 Aug 27 19:17 sim_4.out +-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_4.log +-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:17 sim_1.log +-rw-r--r-- 1 p01532 61532 90 Aug 27 19:18 sim_8.out +-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:18 sim_7.log +-rw-r--r-- 1 p01532 61532 90 Aug 27 19:18 sim_3.out +-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:18 sim_3.log +-rw-r--r-- 1 p01532 61532 90 Aug 27 19:18 sim_2.out +-rw-r--r-- 1 p01532 61532 14898 Aug 27 19:18 sim_2.log +-rw-r--r-- 1 p01532 61532 90 Aug 27 19:18 sim_1.out +-rw-r--r-- 1 p01532 61532 90 Aug 27 19:18 sim_0.out +-rw-r--r-- 1 p01532 61532 14897 Aug 27 19:18 sim_0.log +-rw-r--r-- 1 p01532 61532 9 Aug 27 19:18 average.out +-rw-r--r-- 1 p01532 61532 14675 Aug 27 19:18 average.log +----- + +Each sim_N.out file is the sum of its bias file plus newly "simulated" random output scaled by 1,000,000: + +----- +$ cat output/bias_0.dat + 302 + 489 + 81 + 582 + 664 + 290 + 839 + 258 + 506 + 310 + 293 + 508 + 88 + 261 + 453 + 187 + 26 + 198 + 402 + 555 + +$ cat output/sim_0.out +64000302 +38000489 +32000081 +12000582 +46000664 +36000290 +35000839 +22000258 +49000506 +75000310 +----- + +We produce 20 values in each bias file. Simulations of less than that +number of values ignore the unneeded number, while simualtions of more +than 20 will use the last bias number for all remoaining values past +20. As an exercise, adjust the code to produce the same number of +bias values as is needed for each simulation. As a further exercise, +modify the script to generate a unique seed value for each simulation, +which is a common practice in ensemble computations. + Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/TODO =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/TODO (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/TODO 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,137 @@ +PLAN + +basics +cloud +uc3 +multisystems +(modis) + +get hosts.txt for cloud dynamically + +Show variety of UC3 activity and what ran where + +get hostname and app_resources into provider staging (hostname into all _swiftwrap) + +Show gridftp and go connect to process the modis dataset + +Show SwiftR for R users, SwiftPy for Enthought PY? + +fetching apps vs sending apps vs parrot/cvmfs/oasis etc ???? + +Demo script-aps, bin apps, building apps, caching apps. etc. + +Do a Swift BLAST workflow -- with viz !!! (spice it up with help from Dina) + +OSG page from Mats: "Is your job HTC-ready" + +Use new Trunk config in tutorial? + + +Add viz and status display; add node probing to tutorial. + +Debug failure with pinfiles + + +What "exercises to suggest?" + +- run stats app locally +- installed vs transferred apps +- transferred programs vs transferred scripts +- summarize things about the env from the .log files, ala stats. + +Y-style dag: 2 sims and average + +Show how to find temp files at runtime... + +Show how to find hung processes at runtime... (or get other trace data...) + +make your owb versions of the programs; verify that you can substitute them + +Add a layer to isolate shell version v installed version + +Show how to handle a paramfile + +Test if OSGCOnnect works and account string (PorjectName) works OK for both! + +SHow how to handle long lists of files (eg writeData and other swift.properties) + +Expand arith to arb prec using bc + + +ISSUES + +error in pin files? debug and turn back on +PATH issues for various providers + +bin dir? + +setup.csh and .csh testing + +IMPROVEMENTS + +1. Cleanup.sh mentioned in the tutorial +[fixed] + +2. cd ../part02 +[fixed] + +3. support for zsh, csh +[pending] + +4. What results are created and where did the outputs go ? +and pointers to what the log files mean +[pending] + +5. Part4, +- cd ../part04 is missing. Cleanup the README +[fixed] + +6. Part5 +- cd ../part05 is missing. Cleanup +[fixed] + +7. Part7 +-Change from running on Tukey analysis cluster compute nodes +[fixed] + +8. Part6 +command line args for nsim and steps, tell user the different behavior +that can be expected with different arg options +[pending] + +9. Draw workflow for the modis demos +[pending] + +10. Link to more technical swift-lang references +[pending] + +11. Links to detailed language constructs, when explaining +apps, link to the section on apps in the userguide. +[pending] + + + +--- + +From Yadu: + +I've committed all the changes that I made on Friday and you can get them +from -> https://svn.ci.uchicago.edu/svn/vdl2/SwiftTutorials/CIC_2013-08-09 + +I'm trying to make this tutorial easily work on several sites so that, we +do not have to tweak things for every single tutorial. Once this is done, +I can also add it to the test-battery as well. I think this has value +considering that we spend atleast 1-2 days for every demo. + +Now, the major pending item is the Modis demo, specifically the issue of +bringing data to any site and scripts. Slight tweaks to allow for sending +the scripts as args to apps would also be needed. + +So the major changes are: +1. Source the setup.sh script with the target site name +eg. source setups.sh +2. No separate cloud folder +3. [pending] fix modis data and scripts +4. [pending] support for zsh and other shells? + +--- Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/activeplot.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/activeplot.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/asciidoc.css =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/asciidoc.css (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/asciidoc.css 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,26 @@ +a:link { color:navy; } +a:visited { color:navy; } + +.monospaced, code, pre { + font-family: "Courier New", Courier, monospace; + font-size: medium; /* inherit; */ + color: black; + padding: 0; + margin: 0; +} + +/* + background: #f8f8f8; + border: 1px solid #dddddd; + border-left: 5px solid #f0f0f0; + margin-right: 10%; +*/ + +div.listingblock > div.content { + padding: 0.5em; + background: none; + border: none; + border-left: none; + margin-right: none; +} + Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/build_docs.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/build_docs.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/build_docs.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,3 @@ +#!/bin/bash -e + +asciidoc -a icons -a toc -a toplevels=2 -a stylesheet=$PWD/asciidoc.css -a max-width=800px -o tutorial.html README Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/build_docs.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/cumulativeplot.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/cumulativeplot.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/modis.dia =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/modis.dia ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/modis.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/figs/modis.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/caution.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/caution.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/example.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/example.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/home.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/home.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/important.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/important.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/next.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/next.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/note.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/note.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/prev.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/prev.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/tip.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/tip.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/up.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/up.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/warning.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/images/icons/warning.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part01.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part01.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part02.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part02.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part03.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part03.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part04.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part04.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part05.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part05.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part06.png =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/part06.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/push.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/push.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/push.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,5 @@ +#! /bin/sh + +# scp -r swift-cray-tutorial.html images *png login.ci.uchicago.edu:/ci/www/projects/swift/tutorials/cray + +tar zcf - --exclude-vcs *html *png images | ssh ci "cd /ci/www/projects/swift/tutorials/midway; tar zxf -" Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/doc/push.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/p1.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/p1.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/p1.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,9 @@ +type file; + +app (file o) simulation () +{ + simulate stdout=filename(o); +} + +file f <"sim.out">; +f = simulation(); Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/swift.properties (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part01/swift.properties 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1 @@ +site=local Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/p1.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/p1.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/p1.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,9 @@ +type file; + +app (file o) simulation () +{ + md 3 50 1000 stdout=filename(o); +} + +file f <"sim.out">; +f = simulation(); Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/swift.properties (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part01m/swift.properties 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,3 @@ +site=local +ticker.date.format=HH:mm:ss +ticker.prefix= Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/p2.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/p2.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/p2.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,11 @@ +type file; + +app (file o) simulation () +{ + simulate stdout=filename(o); +} + +foreach i in [0:9] { + file f ; + f = simulation(); +} Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/swift.properties (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part02/swift.properties 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1 @@ +site=local Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/p2.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/p2.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/p2.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,11 @@ +type file; + +app (file o) simulation () +{ + sh "-c" "md 3 50 1000 >/dev/null; cat md.dat" stdout=filename(o); +} + +foreach i in [0:9] { + file f ; + f = simulation(); +} Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/swift.properties (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part02m/swift.properties 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,3 @@ +site=local +ticker.date.format=HH:mm:ss +ticker.prefix= Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/p3.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/p3.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/p3.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,27 @@ +type file; + +app (file o) simulation (int sim_steps, int sim_range, int sim_values) +{ + simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=filename(o); +} + +app (file o) analyze (file s[]) +{ + stats filenames(s) stdout=filename(o); +} + +int nsim = toInt(arg("nsim","10")); +int steps = toInt(arg("steps","1")); +int range = toInt(arg("range","100")); +int values = toInt(arg("values","5")); + +file sims[]; + +foreach i in [0:nsim-1] { + file simout ; + simout = simulation(steps,range,values); + sims[i] = simout; +} + +file stats<"output/average.out">; +stats = analyze(sims); Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/swift.properties (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part03/swift.properties 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1 @@ +site=local Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/p3.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/p3.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/p3.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,44 @@ +type file; + +/* + md nd np step_num print_step_num dt mass printinfo scale_factor scale_offset + where + * nd is the spatial dimension (2 or 3); + * np is the number of particles (500, for instance); + * step_num is the number of time steps (500, for instance); + * print_step_num is the number of snapshot prints (10 for instance); + * dt is size of timestep; + * mass is particle mass; + * printinfo is a string to append to each particle coord + * scale_offset and scale_factor are used to scale particle positions for logging/rendering (FIXME) + + e.g.: + + md 3 50 30000 50 .0001 .005 "0.03 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 +*/ + +app (file o) simulation (string npart, string steps, string mass) +{ + sh "-c" strjoin(["md","3",npart,steps,">/dev/null; cat md.dat"]," ") stdout=filename(o); +} + +app (file o) analyze (file s[]) +{ + mdstats filenames(s) stdout=filename(o); +} + +int nsim = toInt(arg("nsim","10")); +string npart = arg("npart","50"); +string steps = arg("steps","1000"); +string mass = arg("mass",".0001"); + +file sims[]; + +foreach i in [0:nsim-1] { + file simout ; + simout = simulation(npart,steps,mass); + sims[i] = simout; +} + +file stats<"output/average.out">; +stats = analyze(sims); Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/swift.properties (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part03m/swift.properties 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,3 @@ +site=local +ticker.date.format=HH:mm:ss +ticker.prefix= Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/p4.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/p4.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/p4.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,29 @@ +type file; + +app (file out, file log) simulation (int sim_steps, int sim_range, int sim_values) +{ + simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=@out stderr=@log; +} + +app (file out, file log) analyze (file s[]) +{ + stats filenames(s) stdout=@out stderr=@log; +} + +int nsim = toInt(arg("nsim", "10")); +int steps = toInt(arg("steps", "1")); +int range = toInt(arg("range", "100")); +int values = toInt(arg("values", "5")); + +file sims[]; + +foreach i in [0:nsim-1] { + file simout ; + file simlog ; + (simout,simlog) = simulation(steps,range,values); + sims[i] = simout; +} + +file stats_out<"output/average.out">; +file stats_log<"output/average.log">; +(stats_out, stats_log) = analyze(sims); Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/swift.properties (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part04/swift.properties 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,2 @@ +site=midway-westmere +site.westmere.slurm.exclusive=false Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/p5.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/p5.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/p5.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,29 @@ +type file; + +app (file out, file log) simulation (int sim_steps, int sim_range, int sim_values) +{ + simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=@out stderr=@log; +} + +app (file out, file log) analyze (file s[]) +{ + stats filenames(s) stdout=@out stderr=@log; +} + +int nsim = toInt(arg("nsim", "10")); +int steps = toInt(arg("steps", "1")); +int range = toInt(arg("range", "100")); +int values = toInt(arg("values", "5")); + +file sims[]; + +foreach i in [0:nsim-1] { + file simout ; + file simlog ; + (simout,simlog) = simulation(steps,range,values); + sims[i] = simout; +} + +file stats_out<"output/average.out">; +file stats_log<"output/average.log">; +(stats_out, stats_log) = analyze(sims); Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/swift.properties (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part05/swift.properties 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,2 @@ +site=westmere +site.westmere.slurm.exclusive=false Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/p6.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/p6.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/p6.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,53 @@ +type file; + +# app() functions for application programs to be called: + +app (file out) genseed (int nseeds) +{ + simulate "-r" 2000000 "-n" nseeds stdout=@out; +} + +app (file out) genbias (int bias_range, int nvalues) +{ + simulate "-r" bias_range "-n" nvalues stdout=@out; +} + +app (file out, file log) simulation (int timesteps, int sim_range, file bias_file, + int scale, int sim_count, file seed_file) +{ + simulate "-t" timesteps "-r" sim_range "-B" @bias_file "-x" scale + "-n" sim_count "-S" @seed_file stdout=@out stderr=@log; +} + +app (file out, file log) analyze (file s[]) +{ + stats filenames(s) stdout=@out stderr=@log; +} + +# Command line arguments + +int nsim = toInt(arg("nsim", "10")); # number of simulation programs to run +int steps = toInt(arg("steps", "1")); # number of timesteps (seconds) per simulation +int range = toInt(arg("range", "100")); # range of the generated random numbers +int values = toInt(arg("values", "10")); # number of values generated per simulation + +# Main script and data +file seedfile <"output/seed.dat">; # Dynamically generated bias for simulation ensemble + +tracef("\n*** Script parameters: nsim=%i range=%i num values=%i\n\n", nsim, range, values); +seedfile = genseed(1); + +file sims[]; # Array of files to hold each simulation output + +foreach i in [0:nsim-1] { + file biasfile ; + file simout ; + file simlog ; + biasfile = genbias(1000, 20); + (simout,simlog) = simulation(steps, range, biasfile, 1000000, values, seedfile); + sims[i] = simout; +} + +file stats_out<"output/average.out">; +file stats_log<"output/average.log">; +(stats_out,stats_log) = analyze(sims); Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/swift.properties (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part06/swift.properties 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,2 @@ +site=westmere +site.westmere.slurm.exclusive=false Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/p6m.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/p6m.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/p6m.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,54 @@ +type file; + +(int result) randomInt () +{ + float range = 9999999.0; + float rand = java("java.lang.Math","random"); + string s[] = strsplit(toString(range*rand),"\\."); + result = toInt(s[0]); +} + +app (file out, file traj) simulation (string npart, string steps, string mass, int randval) +{ +# mdviz @out @traj 3 npart steps 50 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt(); + md 3 npart steps 10 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randval @out @traj; +} + +app (file out) genconfig () +{ + simulate "-n" 1 "-r" 1000000 stdout=filename(out); +} + +app (file o) analyze (file s[]) +{ + mdstats filenames(s) stdout=filename(o); +} + +app (file o) maxkinetic (file s[]) +{ + mdmaxk "3" filenames(s) stdout=filename(o); +} + +app (file o) convert (file s[]) +{ + convert filenames(s) filename(o); +} + +int nsim = toInt(arg("nsim","10")); +string npart = arg("npart","50"); +string steps = arg("steps","1000"); +string mass = arg("mass",".005"); + +file sim[] ; +file trj[] ; + +foreach i in [0:nsim-1] { + int startstate = readData(genconfig()); + (sim[i],trj[i]) = simulation(npart,steps,mass,startstate); +} + +file stats_out<"output/average.out">; +stats_out = analyze(sim); + +#file viz_all<"output/all.gif">; +#viz_all = convert(gifs); Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/swift.properties (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part06m/swift.properties 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,2 @@ +site=midway-westmere +site.midway-westmere.slurm.exclusive=false Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,43 @@ +type file; + +(int result) randomInt () +{ + float range = 9999999.0; + float rand = java("java.lang.Math","random"); + string s[] = strsplit(toString(range*rand),"\\."); + result = toInt(s[0]); +} + +app (file out, file traj) simulation (string npart, string steps, string mass) +{ +# mdviz @out @traj 3 npart steps 50 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt(); + md 3 npart steps 10 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt() @out @traj; +} + +app (file o) analyze (file s[]) +{ + mdstats filenames(s) stdout=filename(o); +} + +app (file o) convert (file s[]) +{ + convert filenames(s) filename(o); +} + +int nsim = toInt(arg("nsim","10")); +string npart = arg("npart","50"); +string steps = arg("steps","1000"); +string mass = arg("mass",".005"); + +file sim[] ; +file trj[] ; + +foreach i in [0:nsim-1] { + (sim[i],trj[i]) = simulation(npart,steps,mass); +} + +file stats_out<"output/average.out">; +stats_out = analyze(sim); + +#file viz_all<"output/all.gif">; +#viz_all = convert(gifs); Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/p4b.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,78 @@ +type file; + +type kineticInfo { + int sim; + float energy; +} + +(int result) randomInt () +{ + float range = 9999999.0; + float rand = java("java.lang.Math","random"); + string s[] = strsplit(toString(range*rand),"\\."); + result = toInt(s[0]); +} + +app (file out, file traj) simulation (int npart, int steps, int trsnaps, float mass) +{ +# mdviz @out @traj 3 npart steps 50 ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt(); + md 3 npart steps trsnaps ".0001" mass "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 randomInt() @out @traj; +} + +app (file o) analyze (file s[]) +{ + mdstats filenames(s) stdout=filename(o); +} + +app (file o) kinetic (file s[]) +{ + mdmaxk 9999 filenames(s) stdout=filename(o); +} + +app (file o) render (file traj, int frame) +{ + renderframe filename(traj) filename(o) frame; +} + +app (file o) convert (file s[]) +{ + convert "-delay" 20 filenames(s) filename(o); +} + +int nsim = toInt(arg("nsim","10")); +int npart = toInt(arg("npart","50")); +int steps = toInt(arg("steps","1000")); +int trsnaps = 10; +float mass = toFloat(arg("mass",".005")); + +file sim[] ; +file trj[] ; + +foreach i in [0:nsim-1] { + (sim[i],trj[i]) = simulation(npart,steps,trsnaps,mass); +} + +file stats_out<"output/average.out">; +stats_out = analyze(sim); + +file ke_out<"output/kinetic.out">; +ke_out = kinetic(sim); + +kineticInfo kd[] = readData(ke_out); + +tracef("min eK simulation: %i eK: %f\n", kd[0].sim, kd[0].energy); +tracef("max eK simulation: %i eK: %f\n", kd[nsim-1].sim, kd[nsim-1].energy); + +file mink[] ; +file maxk[] ; + +foreach i in [0:trsnaps-1] { + mink[i] = render(trj[kd[0].sim], i); + maxk[i] = render(trj[kd[nsim-1].sim], i); +} + +file minkmovie <"output/mink.gif">; +file maxkmovie <"output/maxk.gif">; + +minkmovie = convert(mink); +maxkmovie = convert(maxk); Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part07/swift.properties 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,2 @@ +site=midway-sandyb +site.midway-sandyb.slurm.exclusive=false Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/md.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/md.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/md.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,13 @@ + + at dispatch=WORKER +(file outfile, file trjfile) +simulate(int step_num, int step_print_num, + int step_print, int step_print_index, + int np, int nd, + float mass, + float dt, + int seed) +"md" "0.0" +[ +"simulate <> <> <> <> <> <> <> <
> <> [ lindex $<> 0 ] [ lindex $<> 0 ]" +]; Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,10 @@ +#!/bin/sh -eu + +stc run-md.swift + +MD_PKG=$( cd ${PWD}/../src/md ; /bin/pwd ) +export TURBINE_USER_LIB=${MD_PKG} +export TURBINE_LOG=0 ADLB_DEBUG=0 +turbine run-md.tcl + + Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-md.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,9 @@ + +import md; + +main +{ + file out_txt<"out.txt">; + file out_trj<"out.trj">; + (out_txt, out_trj) = simulate(10, 10, 3, 0, 10, 2, 1, 0.1, 42); +} Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,8 @@ +#!/bin/sh -eu + +stc run-mds.swift + +MD_PKG=$( cd ${PWD}/../src/md ; /bin/pwd ) +export TURBINE_USER_LIB=${MD_PKG} +export TURBINE_LOG=0 ADLB_DEBUG=0 +turbine -n 2 run-mds.tcl --simulations=4 --steps=10 Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.swift =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.swift (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/part08/run-mds.swift 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,17 @@ + +import string; +import sys; + +import md; + +main +{ + int simulations = toint(argv("simulations")); + int steps = toint(argv("steps")); + foreach i in [0:simulations-1] + { + file out_txt; + file out_trj; + (out_txt, out_trj) = simulate(steps, 10, 3, 0, 10, 2, 1, 0.1, 42); + } +} Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.midway.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.midway.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/setup.midway.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,13 @@ +# Load modules +#module unload swift +#module load swift/0.95-RC1 + +module load ant + +#PATH=/home/wilde/swift/src/trunk/cog/modules/swift/dist/swift-svn/bin:$PATH + +echo Swift version is $(swift -version) + +# Add applications to $PATH +TUTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PATH=$TUTDIR/bin:$TUTDIR/app:$PATH Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/Makefile =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/Makefile (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/Makefile 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,23 @@ +#obj = c-ray-mt.o +bin = c-ray + +CC = gcc +CFLAGS = -O3 -ffast-math + +$(bin): $(obj) + $(CC) -o $@ $(bin).c -lm -lpthread + +#$(bin): $(obj) +# $(CC) -o $@ $(obj) -lm -lpthread + +.PHONY: clean +clean: + rm -f $(obj) $(bin) + +.PHONY: install +install: + cp $(bin) ../../bin/$(bin) + +.PHONY: uninstall +uninstall: + rm -f ../../bin/$(bin) Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/README =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/README (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/README 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,395 @@ + + C-Ray Simple Raytracing Tests + + http://www.futuretech.blinkenlights.nl/c-ray.html + + By: John Tsiombikas + + Test suite compiled by: Ian Mapleson + + Last Change: 10/Apr/2008 + + +1. Introduction +2. The C-Ray Tests (how to compile) +3. Running the Tests +4. Submitting Results +5. Background +6. Appendix A: Invalid Tests + +********************************************************************** + +1. Introduction + +C-Ray is a simple raytracer written by John Tsiombikas; in his +own words, it is: + + "...an extremely small program I did one day to figure out how + would the simplest raytracer program look like in the least + ammount of code lines." + +The relevant discussion on Nekochan is at: + + http://forums.nekochan.net/viewtopic.php?f=3&t=15719 + +The default data set is very small, so C-ray really only tests the pure +floating-point (fp) speed of a CPU core (or multiple CPUs/cores using the +threaded version), ie. RAM speed is not a significant factor. John said: + + This thing only measures 'floating point CPU performance' and + nothing more, and it's good that nothing else affects the results. + A real rendering program/scene would be still CPU-limited meaning + that by far the major part of the time spent would be CPU time in + the fpu, but it would have more overhead for disk I/O, shader + parsing, more strain for the memory bandwidth, and various other + things. So it's a good approximation being a renderer itself, but + it's definitely not representative." + +Nevertheless, the results are certainly interesting: + + http://www.futuretech.blinkenlights.nl/c-ray.html + +If you wish to submit your own results, follow the instructions given +below. Send the data to me, not to John, and I will add them to the +relevant tables; please include all requested details. + +Comments and feedback welcome! + +Ian. + +mapesdhs at yahoo.com +sgidepot at blueyonder.co.uk +http://www.futuretech.blinkenlights.nl/sgidepot/ + +********************************************************************** + +2. The C-Ray Tests + +Two programs are included in this archive for testing: + +c-ray-f: + + This is for single-CPU systems, or for testing just a single core + of a multi-core CPU. + +c-ray-mt: + + This is the multithreaded version for testing multi-CPU systems, and/or + systems with more than one CPU core. Note that on some systems c-ray-mt + with just one thread may be faster than c-ray-f. Use whichever version + gives you the best results in each case. Use the -t option to specify + the number of threads; without the -t option, only 1 thread is used. + +Compile the source files for your target platform with gcc or whatever +compiler you have. Just enter 'make', though feel free to add any arch- +specific optimizations for your compiler in CFLAGS first. By default, +the Makefile is designed for use with GCC. If you are using an SGI and +want to use MIPS Pro to compile the programs, then enter: + + /bin/cp Makefile.mips Makefile + +and then enter 'make'. + +Note that the c-ray binaries as supplied were compiled for an SGI +Octane2 R12K/R14 system (users of other SGI models should recompile +if possible), while the example x86 binary in the x86 directory was +compiled by John for a 3GHz P4. + +If you don't want to use make, then typical compile lines for each +program on SGIs using MIPS Pro are as follows (in this case for an +Octane system - use a different IP number for other SGI systems): + + cc -O3 -mips4 -TARG:platform=ip30 -Ofast=ip30 c-ray-f.c -o c-ray-f -lm + +while for the threaded version the pthread library must be included: + + cc -O3 -mips4 -TARG:platform=ip30 -Ofast=ip30 c-ray-mt.c -o c-ray-mt -lm -lpthread + +See the 'cc' man page for full details of available optimisation options. + +The file 'sgi.txt' has further example compile lines for SGI O2 and +Octane machines, some with extra example optimisation options. Try +them out, see which one works best on your system. Those using GCC +should consult the gcc man page for full details of available options. + +NOTE: results for tests done with pre-run profiling/virtualisation +compiler optimisations will NOT be accepted! (see Appendix A for details). + +Before running the tests, naturally you should shut down any other +applications, processes, etc. which might interfere with the test. +For example, on SGI systems, I shut down the mediad and sgi_apache +daemons: + + /etc/init.d/mediad stop + /etc/init.d/sgi_apache stop + +Better still, turn off timed, nsd, and rlogin remotely to run the tests. +It should be possible to do the same thing on a Linux/BSD system. + +On a Windows machine, shut down all unnecessary processes, close any +antivirus/firewall applications/processes, and it may be worthwhile +forcing any pending idle tasks to complete before running the tests, +ie. select Run from the Start menu and enter: + + Rundll32.exe advapi32.dll,ProcessIdleTasks + +Assuming you are now ready to use the binary programs for the tests... + +********************************************************************** + +3. Running the Tests + +There are two data files used for the tests: + +'scene' is a simple environment, with just three reflective spheres. +Examine scene.jpg to see the final image. + +'sphract' is a much more complex scenario, with dozens of spheres in +a fractal pattern (see gen_fract.txt for details of how the scene +description was created). Examine sphract.jpg to see the final image. + +There are four tests; the first is the shortest, the data from which +are used for the main table on the results page. The tests are: + + + Test Data File Image Resolution Oversampling + + 1. scene Default 800x600 NONE + 2. sphract Default 800x600 NONE + 3. sphract 1024 x 768 8X + 4. scene 7500 x 3500 NONE + +If you are using a single-CPU system which only has one core, or wish +to test just one CPU/core of a multi-CPU/core system, then run the +tests with c-ray-f, or with c-ray-mt using just 1 thread. For systems +with multiple CPUs/cores, please submit results for just a single +CPU/core aswell as the fastest results for using all CPUs/cores (this +allows one to see how well parallel systems scale). + +On UNIX systems, the programs receive the scene description data from +the standard input and send the results (the image created) to the +standard output. To run the first test on a UNIX system, enter: + + cat scene | ./c-ray-f > foo.ppm + +On a Windows system, enter the following in a Command window: + + c-ray-f -i scene -o foo.ppm + +The output will resemble the following (in this case run on a R14000 +550MHz SGI Octane2): + + Rendering took: 1 seconds (1888 milliseconds) + +The result to submit is the number of milliseconds. Run each test +several times if possible to observe a typical result. It's up to +you whether you submit a typical result or the fastest overall result. + +If you have a multi-CPU/core system, now run the test multithreaded with +c-ray-mt, using the -t option to specify the number of threads, eg. + + UNIX: cat scene | ./c-ray-mt -t 32 > foo.ppm + Windows: c-ray-mt -t 32 -i scene -o foo.ppm + +For multi-CPU/core systems, the optimum number of threads varies +greatly from one system to another, though a good estimate is 16 +times the number of cores. Try different numbers, eg. 32, 64, 128, +or some inbetween number such as 40, 60, etc. But also try smaller +number too, eg. just 8 threads for a quad-core system. + +The maximum number of threads c-ray-mt can use is the vertical +resolution of the output image. As the number of threads increases, +eventually the speedup obtained by the parallel processing will be +outweighed by the overhead cost of managing the threads. Experiment +to find what works best for each test. + +Thus, for the other tests, the commands to enter on a UNIX system +would be as follows, using 32 threads just as an example here: + + cat sphract | ./c-ray-f > foo.ppm + cat sphract | ./c-ray-mt -t 32 > foo.ppm + cat sphract | ./c-ray-f -s 1024x768 -r 8 > foo.ppm + cat sphract | ./c-ray-mt -t 32 -s 1024x768 -r 8 > foo.ppm + cat scene | ./c-ray-f -s 7500x3500 > foo.ppm + cat scene | ./c-ray-mt -t 32 -s 7500x3500 > foo.ppm + +while on a Windows system these would be: + + c-ray-f -i sphract -o foo.ppm + c-ray-mt -t 32 -i sphract -o foo.ppm + c-ray-f -s 1024x768 -r 8 -i sphract -o foo.ppm + c-ray-mt -t 32 -s 1024x768 -r 8 -i sphract -o foo.ppm + c-ray-f -s 7500x3500 -i scene -o foo.ppm + c-ray-mt -t 32 -s 7500x3500 -i scene -o foo.ppm + +If you don't want to bother experimenting, then the script RUN.full +will execute all the tests, with the c-ray-mt tests done using 32 +threads, but remember 32 threads might not be optimal for your system. + +********************************************************************** + +4. Submitting Results + +Do not send any results to John; instead, send all results to me at +both of my email addresses (include "C-Ray" in the subject line): + + mapesdhs at yahoo.com + sgidepot at blueyonder.co.uk + +Apart from the run-times reported by each test, please remember +to state which tests are multithreaded and how many threads were +used. Better still, just copy the on-screen text for each test. + +With respect to system information, state the type of system (name +and/or model number), CPU details (name/model, type/speed/cache, +no. of CPUs/cores), OS name/version (eg. for Linux, what name, +kernel version/build), what compiler was used (name/version) and +what extra options if any were employed. The online results page +also shows the host name where available, but this is optional. + +Thus, for example, a system description might look like this: + + SUN Fire X2100, Solaris 10, host name 'kobe' + Sun Studio 10 Compiler + AMD Opteron 175 2.2 GHz 1MB L2 + +while for an SGI it might be: + + SGI Octane2, IRIX 6.5.26m + MIPS Pro 7.4.3m (7.3 EOE) + Dual-R12000 400MHz (2MB L2) + +or a Windows system (in this case my own setup): + + WinXP-32bit PC (SP2), Asrock AM2NF3 motherboard, 4GB DDR2/800 RAM + Athlon64 X2 6000+ 3.15GHz (overclocked) + Supplied x86 binary used (1 core only) + +You can also mention the system's RAM, disk, or anything else, but +they're not essential. + +Note for SGI users: you can find out what eoe/dev compiler versions +your system has installed by entering: + + versions -b | grep compiler_ + +eg. on my Octane2 this gives: + + I compiler_dev 05/14/2004 Base Compiler Development Environment, 7.3 + I compiler_eoe 07/13/2005 IRIX Standard Execution Environment (Base Compiler Headers and Libraries, 7.4.3m) + +********************************************************************** + +5. Background + +When I asked John about why he created C-Ray, he said: + + This is just an extremely small program I did one day to figure + out how would the simplest raytracer program look like in the + least amount of code lines :) It's not useful for anything apart + from benchmarking. + + As part of my BSc dissertation project I did a really big and + feature-full ray tracer, which could be useful, supporting: + programmable shading, network rendering, monte carlo rendering + algorithms, etc. But it's big and buggy, slow, and incomplete + because I was rushing to finish it the last minute before the + deadline (as always) :) + + So I scrapped the damn thing after that, and I'm starting from + scratch with a new design if I finish it and it proves to be + sucessful I'll let you know :)" + + +I also asked John why the best c-ray-mt results seem to be obtained +with a number of threads that is much larger than the number of +CPUs/cores in a system, to which he replied: + + Ian wrote: + > I also suspect more threads means the balanced load between + > the two CPUs is less affected by the possible differences in + > complexity between threads. + + Bingo, each thread takes a bunch of scanlines, if the relative + complexity of the rendering calculations between the bunches(sic) + is not equal, then one thread may spend much more time calculating + than another thread. Of course that doesn't necessarily mean that + one "CPU" ends up calculating much more than the other since the + threads are not "bound" to any CPU, each CPU takes one of the + available ready-to-run threads each timeslice. Anyway having more + threads evens it out. I would guess about 4 times as many threads + as the CPUs [multiplied by the no. of cores per CPU] would be enough. + + +I also asked John if there was any element of overhead processing +to handle the results of the multiple threads. He said: + + There's no such overhead. Each thread gets a pointer to the + appropriate location of the framebuffer, and stores every pixel + as it is calculated directly. Also any processing afterwards + (output of the PPM image) is done *after* timing stops. + + +See the Nekochan thread for more discussion about C-Ray, including +further comments by John. + +********************************************************************** + +6. Appendix A: Invalid Tests + +Results for tests done with pre-run profiling/virtualisation compiler +optimisations will NOT be accepted! What does this mean? Read on... + +Someone emailed me to say they had been able to halve the test run +times by using the following compilation/execution sequence: + + XC="gcc -O3 -ffast-math -fomit-frame-pointer c-ray-f.c + -finline-limit=10000 -ftree-vectorize -fwhole-program + -fbranch-probabilities -ffunction-sections -o c-ray-f -lm" && $XC + -fprofile-generate && ./run > /dev/null 2>&1 && $XC -fprofile-use + && ./run && ./run && ./run && ./run + +with ./run containing: + + #!/bin/sh + cat scene | ./c-ray-f > foo2.ppm + +The explanation was as follows: + + What this does is to create an executable with profiling and + virtualization instructions, execute it in order to create "real life" + information and then recompile it using that information to better + optimize it without the need of "guessing" (which is what usually a + plain -O3 does). Doing this speeds up the execution a lot. Another + important thing was to increase the inline limit from 600 (or whatever + the default value is) to something big (like 10000) so more functions + will be inlined instead of called. The usage of "-fwhole-program" tells + to gcc that the .c file is the one and only source code file for the + program, so it will use all functions as static and will make all + "inline-able" functions, inline. This is another great speedup :-). + +My problem with this is that, by definition, the test has to be run +multiple times in order to provide execution profiling data used to +optimise the test for the final run. Thus, the real total run time spent +to obtain the final result was not that much less or perhaps longer than +just running the test a single time without this sort of execution +profiling. + +I asked John about these optimisations; he said: + + Hahaha :) + Yes I bet the biggest advantage was the profiling run and use of that + profiling information, and maybe also the whole program optimizations. + Both of which can't be done in real-life programs :) + + The profiling information helps the compiler issue branch prediction + hints to the processor, and also do prefetches. The first one makes a + lot of difference in modern x86 CPUs with their huge execution + pipelines. If the branch prediction fails, you end up flushing the + pipeline and backtracking tens of instructions. Explicit prefetching, + would also make a big difference if the data set was bigger. I don't + think it helps here. + +This method of optimisation is certainly interesting, but I don't think +it's appropriate for the C-Ray tests. + Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/c-ray.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/c-ray.c (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/c-ray.c 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,671 @@ +/* c-ray-mt - a simple multithreaded raytracing filter. + * Copyright (C) 2006 John Tsiombikas + * + * You are free to use, modify and redistribute this program under the + * terms of the GNU General Public License v2 or (at your option) later. + * see "http://www.gnu.org/licenses/gpl.txt" for details. + * --------------------------------------------------------------------- + * Usage: + * compile: just type make + * (add any arch-specific optimizations for your compiler in CFLAGS first) + * run: cat scene | ./c-ray-mt [-t num-threads] >foo.ppm + * (on broken systems such as windows try: c-ray-mt -i scene -o foo.ppm) + * enjoy: display foo.ppm + * (with imagemagick, or use your favorite image viewer) + * --------------------------------------------------------------------- + * Scene file format: + * # sphere (many) + * s x y z rad r g b shininess reflectivity + * # light (many) + * l x y z + * # camera (one) + * c x y z fov tx ty tz + * --------------------------------------------------------------------- + */ +#include +#include +#include +#include +#include +#include +#include + +#define VER_MAJOR 1 +#define VER_MINOR 1 +#define VER_STR "c-ray-mt v%d.%d\n" + +#if !defined(unix) && !defined(__unix__) +#ifdef __MACH__ +#define unix 1 +#define __unix__ 1 +#endif /* __MACH__ */ +#endif /* unix */ + +/* find the appropriate way to define explicitly sized types */ +/* for C99 or GNU libc (also mach's libc) we can use stdint.h */ +#if (__STDC_VERSION__ >= 199900) || defined(__GLIBC__) || defined(__MACH__) +#include +#elif defined(unix) || defined(__unix__) /* some UNIX systems have them in sys/types.h */ +#include +#elif defined(__WIN32__) || defined(WIN32) /* the nameless one */ +typedef unsigned __int8 uint8_t; +typedef unsigned __int32 uint32_t; +#endif /* sized type detection */ + +struct vec3 { + double x, y, z; +}; + +struct ray { + struct vec3 orig, dir; +}; + +struct material { + struct vec3 col; /* color */ + double spow; /* specular power */ + double refl; /* reflection intensity */ +}; + +struct sphere { + struct vec3 pos; + double rad; + struct material mat; + struct sphere *next; +}; + +struct spoint { + struct vec3 pos, normal, vref; /* position, normal and view reflection */ + double dist; /* parametric distance of intersection along the ray */ +}; + +struct camera { + struct vec3 pos, targ; + double fov; +}; + +struct thread_data { + pthread_t tid; + int sl_start, sl_count; + + uint32_t *pixels; +}; + +void render_scanline(int xsz, int ysz, int sl, uint32_t *fb, int samples); +struct vec3 trace(struct ray ray, int depth); +struct vec3 shade(struct sphere *obj, struct spoint *sp, int depth); +struct vec3 reflect(struct vec3 v, struct vec3 n); +struct vec3 cross_product(struct vec3 v1, struct vec3 v2); +struct ray get_primary_ray(int x, int y, int sample); +struct vec3 get_sample_pos(int x, int y, int sample); +struct vec3 jitter(int x, int y, int s); +int ray_sphere(const struct sphere *sph, struct ray ray, struct spoint *sp); +void load_scene(FILE *fp); +unsigned long get_msec(void); + +void *thread_func(void *tdata); + +#define MAX_LIGHTS 16 /* maximum number of lights */ +#define RAY_MAG 1000.0 /* trace rays of this magnitude */ +#define MAX_RAY_DEPTH 5 /* raytrace recursion limit */ +#define FOV 0.78539816 /* field of view in rads (pi/4) */ +#define HALF_FOV (FOV * 0.5) +#define ERR_MARGIN 1e-6 /* an arbitrary error margin to avoid surface acne */ + +/* bit-shift ammount for packing each color into a 32bit uint */ +#ifdef LITTLE_ENDIAN +#define RSHIFT 16 +#define BSHIFT 0 +#else /* big endian */ +#define RSHIFT 0 +#define BSHIFT 16 +#endif /* endianess */ +#define GSHIFT 8 /* this is the same in both byte orders */ + +/* some helpful macros... */ +#define SQ(x) ((x) * (x)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define DOT(a, b) ((a).x * (b).x + (a).y * (b).y + (a).z * (b).z) +#define NORMALIZE(a) do {\ + double len = sqrt(DOT(a, a));\ + (a).x /= len; (a).y /= len; (a).z /= len;\ +} while(0); + +/* global state */ +int xres = 800; +int yres = 600; +int rays_per_pixel = 1; +double aspect = 1.333333; +struct sphere *obj_list; +struct vec3 lights[MAX_LIGHTS]; +int lnum = 0; +struct camera cam; + +int thread_num = 1; +struct thread_data *threads; + +int start = 0; +pthread_mutex_t start_mutex = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t start_cond = PTHREAD_COND_INITIALIZER; + +#define NRAN 1024 +#define MASK (NRAN - 1) +struct vec3 urand[NRAN]; +int irand[NRAN]; + +const char *usage = { + "Usage: c-ray-mt [options]\n" + " Reads a scene file from stdin, writes the image to stdout, and stats to stderr.\n\n" + "Options:\n" + " -t how many threads to use (default: 1)\n" + " -s WxH where W is the width and H the height of the image\n" + " -r shoot rays per pixel (antialiasing)\n" + " -i read from instead of stdin\n" + " -o write to instead of stdout\n" + " -h this help screen\n\n" +}; + + + +int main(int argc, char **argv) { + int i; + unsigned long rend_time, start_time; + uint32_t *pixels; + double sl, sl_per_thread; + FILE *infile = stdin, *outfile = stdout; + + for(i=1; i yres) { + fprintf(stderr, "more threads than scanlines specified, reducing number of threads to %d\n", yres); + thread_num = yres; + } + + if(!(threads = malloc(thread_num * sizeof *threads))) { + perror("failed to allocate thread table"); + return EXIT_FAILURE; + } + + sl = 0.0; + sl_per_thread = (double)yres / (double)thread_num; + for(i=0; i> RSHIFT) & 0xff, outfile); + fputc((pixels[i] >> GSHIFT) & 0xff, outfile); + fputc((pixels[i] >> BSHIFT) & 0xff, outfile); + } + fflush(outfile); + + if(infile != stdin) fclose(infile); + if(outfile != stdout) fclose(outfile); + return 0; +} + +/* render a frame of xsz/ysz dimensions into the provided framebuffer */ +void render_scanline(int xsz, int ysz, int sl, uint32_t *fb, int samples) { + int i, s; + double rcp_samples = 1.0 / (double)samples; + + for(i=0; inext; + + /* if we reached the recursion limit, bail out */ + if(depth >= MAX_RAY_DEPTH) { + col.x = col.y = col.z = 0.0; + return col; + } + + /* find the nearest intersection ... */ + while(iter) { + if(ray_sphere(iter, ray, &sp)) { + if(!nearest_obj || sp.dist < nearest_sp.dist) { + nearest_obj = iter; + nearest_sp = sp; + } + } + iter = iter->next; + } + + /* and perform shading calculations as needed by calling shade() */ + if(nearest_obj) { + col = shade(nearest_obj, &nearest_sp, depth); + } else { + col.x = col.y = col.z = 0.0; + } + + return col; +} + +/* Calculates direct illumination with the phong reflectance model. + * Also handles reflections by calling trace again, if necessary. + */ +struct vec3 shade(struct sphere *obj, struct spoint *sp, int depth) { + int i; + struct vec3 col = {0, 0, 0}; + + /* for all lights ... */ + for(i=0; inext; + int in_shadow = 0; + + ldir.x = lights[i].x - sp->pos.x; + ldir.y = lights[i].y - sp->pos.y; + ldir.z = lights[i].z - sp->pos.z; + + shadow_ray.orig = sp->pos; + shadow_ray.dir = ldir; + + /* shoot shadow rays to determine if we have a line of sight with the light */ + while(iter) { + if(ray_sphere(iter, shadow_ray, 0)) { + in_shadow = 1; + break; + } + iter = iter->next; + } + + /* and if we're not in shadow, calculate direct illumination with the phong model. */ + if(!in_shadow) { + NORMALIZE(ldir); + + idiff = MAX(DOT(sp->normal, ldir), 0.0); + ispec = obj->mat.spow > 0.0 ? pow(MAX(DOT(sp->vref, ldir), 0.0), obj->mat.spow) : 0.0; + + col.x += idiff * obj->mat.col.x + ispec; + col.y += idiff * obj->mat.col.y + ispec; + col.z += idiff * obj->mat.col.z + ispec; + } + } + + /* Also, if the object is reflective, spawn a reflection ray, and call trace() + * to calculate the light arriving from the mirror direction. + */ + if(obj->mat.refl > 0.0) { + struct ray ray; + struct vec3 rcol; + + ray.orig = sp->pos; + ray.dir = sp->vref; + ray.dir.x *= RAY_MAG; + ray.dir.y *= RAY_MAG; + ray.dir.z *= RAY_MAG; + + rcol = trace(ray, depth + 1); + col.x += rcol.x * obj->mat.refl; + col.y += rcol.y * obj->mat.refl; + col.z += rcol.z * obj->mat.refl; + } + + return col; +} + +/* calculate reflection vector */ +struct vec3 reflect(struct vec3 v, struct vec3 n) { + struct vec3 res; + double dot = v.x * n.x + v.y * n.y + v.z * n.z; + res.x = -(2.0 * dot * n.x - v.x); + res.y = -(2.0 * dot * n.y - v.y); + res.z = -(2.0 * dot * n.z - v.z); + return res; +} + +struct vec3 cross_product(struct vec3 v1, struct vec3 v2) { + struct vec3 res; + res.x = v1.y * v2.z - v1.z * v2.y; + res.y = v1.z * v2.x - v1.x * v2.z; + res.z = v1.x * v2.y - v1.y * v2.x; + return res; +} + +/* determine the primary ray corresponding to the specified pixel (x, y) */ +struct ray get_primary_ray(int x, int y, int sample) { + struct ray ray; + float m[3][3]; + struct vec3 i, j = {0, 1, 0}, k, dir, orig, foo; + + k.x = cam.targ.x - cam.pos.x; + k.y = cam.targ.y - cam.pos.y; + k.z = cam.targ.z - cam.pos.z; + NORMALIZE(k); + + i = cross_product(j, k); + j = cross_product(k, i); + m[0][0] = i.x; m[0][1] = j.x; m[0][2] = k.x; + m[1][0] = i.y; m[1][1] = j.y; m[1][2] = k.y; + m[2][0] = i.z; m[2][1] = j.z; m[2][2] = k.z; + + ray.orig.x = ray.orig.y = ray.orig.z = 0.0; + ray.dir = get_sample_pos(x, y, sample); + ray.dir.z = 1.0 / HALF_FOV; + ray.dir.x *= RAY_MAG; + ray.dir.y *= RAY_MAG; + ray.dir.z *= RAY_MAG; + + dir.x = ray.dir.x + ray.orig.x; + dir.y = ray.dir.y + ray.orig.y; + dir.z = ray.dir.z + ray.orig.z; + foo.x = dir.x * m[0][0] + dir.y * m[0][1] + dir.z * m[0][2]; + foo.y = dir.x * m[1][0] + dir.y * m[1][1] + dir.z * m[1][2]; + foo.z = dir.x * m[2][0] + dir.y * m[2][1] + dir.z * m[2][2]; + + orig.x = ray.orig.x * m[0][0] + ray.orig.y * m[0][1] + ray.orig.z * m[0][2] + cam.pos.x; + orig.y = ray.orig.x * m[1][0] + ray.orig.y * m[1][1] + ray.orig.z * m[1][2] + cam.pos.y; + orig.z = ray.orig.x * m[2][0] + ray.orig.y * m[2][1] + ray.orig.z * m[2][2] + cam.pos.z; + + ray.orig = orig; + ray.dir.x = foo.x + orig.x; + ray.dir.y = foo.y + orig.y; + ray.dir.z = foo.z + orig.z; + + return ray; +} + + +struct vec3 get_sample_pos(int x, int y, int sample) { + struct vec3 pt; + static double sf = 0.0; + + if(sf == 0.0) { + sf = 1.5 / (double)xres; + } + + pt.x = ((double)x / (double)xres) - 0.5; + pt.y = -(((double)y / (double)yres) - 0.65) / aspect; + + if(sample) { + struct vec3 jt = jitter(x, y, sample); + pt.x += jt.x * sf; + pt.y += jt.y * sf / aspect; + } + return pt; +} + +/* jitter function taken from Graphics Gems I. */ +struct vec3 jitter(int x, int y, int s) { + struct vec3 pt; + pt.x = urand[(x + (y << 2) + irand[(x + s) & MASK]) & MASK].x; + pt.y = urand[(y + (x << 2) + irand[(y + s) & MASK]) & MASK].y; + return pt; +} + +/* Calculate ray-sphere intersection, and return {1, 0} to signify hit or no hit. + * Also the surface point parameters like position, normal, etc are returned through + * the sp pointer if it is not NULL. + */ +int ray_sphere(const struct sphere *sph, struct ray ray, struct spoint *sp) { + double a, b, c, d, sqrt_d, t1, t2; + + a = SQ(ray.dir.x) + SQ(ray.dir.y) + SQ(ray.dir.z); + b = 2.0 * ray.dir.x * (ray.orig.x - sph->pos.x) + + 2.0 * ray.dir.y * (ray.orig.y - sph->pos.y) + + 2.0 * ray.dir.z * (ray.orig.z - sph->pos.z); + c = SQ(sph->pos.x) + SQ(sph->pos.y) + SQ(sph->pos.z) + + SQ(ray.orig.x) + SQ(ray.orig.y) + SQ(ray.orig.z) + + 2.0 * (-sph->pos.x * ray.orig.x - sph->pos.y * ray.orig.y - sph->pos.z * ray.orig.z) - SQ(sph->rad); + + if((d = SQ(b) - 4.0 * a * c) < 0.0) return 0; + + sqrt_d = sqrt(d); + t1 = (-b + sqrt_d) / (2.0 * a); + t2 = (-b - sqrt_d) / (2.0 * a); + + if((t1 < ERR_MARGIN && t2 < ERR_MARGIN) || (t1 > 1.0 && t2 > 1.0)) return 0; + + if(sp) { + if(t1 < ERR_MARGIN) t1 = t2; + if(t2 < ERR_MARGIN) t2 = t1; + sp->dist = t1 < t2 ? t1 : t2; + + sp->pos.x = ray.orig.x + ray.dir.x * sp->dist; + sp->pos.y = ray.orig.y + ray.dir.y * sp->dist; + sp->pos.z = ray.orig.z + ray.dir.z * sp->dist; + + sp->normal.x = (sp->pos.x - sph->pos.x) / sph->rad; + sp->normal.y = (sp->pos.y - sph->pos.y) / sph->rad; + sp->normal.z = (sp->pos.z - sph->pos.z) / sph->rad; + + sp->vref = reflect(ray.dir, sp->normal); + NORMALIZE(sp->vref); + } + return 1; +} + +/* Load the scene from an extremely simple scene description file */ +#define DELIM " \t\n" +void load_scene(FILE *fp) { + char line[256], *ptr, type; + + obj_list = malloc(sizeof(struct sphere)); + obj_list->next = 0; + + while((ptr = fgets(line, 256, fp))) { + int i; + struct vec3 pos, col; + double rad, spow, refl; + + while(*ptr == ' ' || *ptr == '\t') ptr++; + if(*ptr == '#' || *ptr == '\n') continue; + + if(!(ptr = strtok(line, DELIM))) continue; + type = *ptr; + + for(i=0; i<3; i++) { + if(!(ptr = strtok(0, DELIM))) break; + *((double*)&pos.x + i) = atof(ptr); + } + + if(type == 'l') { + lights[lnum++] = pos; + continue; + } + + if(!(ptr = strtok(0, DELIM))) continue; + rad = atof(ptr); + + for(i=0; i<3; i++) { + if(!(ptr = strtok(0, DELIM))) break; + *((double*)&col.x + i) = atof(ptr); + } + + if(type == 'c') { + cam.pos = pos; + cam.targ = col; + cam.fov = rad; + continue; + } + + if(!(ptr = strtok(0, DELIM))) continue; + spow = atof(ptr); + + if(!(ptr = strtok(0, DELIM))) continue; + refl = atof(ptr); + + if(type == 's') { + struct sphere *sph = malloc(sizeof *sph); + sph->next = obj_list->next; + obj_list->next = sph; + + sph->pos = pos; + sph->rad = rad; + sph->mat.col = col; + sph->mat.spow = spow; + sph->mat.refl = refl; + } else { + fprintf(stderr, "unknown type: %c\n", type); + } + } +} + + +/* provide a millisecond-resolution timer for each system */ +#if defined(unix) || defined(__unix__) +#include +#include +unsigned long get_msec(void) { + static struct timeval timeval, first_timeval; + + gettimeofday(&timeval, 0); + if(first_timeval.tv_sec == 0) { + first_timeval = timeval; + return 0; + } + return (timeval.tv_sec - first_timeval.tv_sec) * 1000 + (timeval.tv_usec - first_timeval.tv_usec) / 1000; +} +#elif defined(__WIN32__) || defined(WIN32) +#include +unsigned long get_msec(void) { + return GetTickCount(); +} +#else +#error "I don't know how to measure time on your platform" +#endif + +void *thread_func(void *tdata) { + int i; + struct thread_data *td = (struct thread_data*)tdata; + + pthread_mutex_lock(&start_mutex); + while(!start) { + pthread_cond_wait(&start_cond, &start_mutex); + } + pthread_mutex_unlock(&start_mutex); + + for(i=0; isl_count; i++) { + render_scanline(xres, yres, i + td->sl_start, td->pixels, rays_per_pixel); + } + + return 0; +} Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/scene.cr =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/scene.cr (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/scene.cr 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,18 @@ +# spheres +# position radius color shininess reflectivity +s -1.5 -0.3 -1 0.7 1.0 0.2 0.05 50.0 0.3 +s 1.5 -0.4 0 0.6 0.1 0.85 1.0 50.0 0.4 + +# walls +s 0 -1000 2 999 0.1 0.2 0.6 80.0 0.8 + +# bouncing ball +s 0 0 2 1 1.0 0.5 0.1 60.0 0.7 + +# lights... +l -50 100 -50 +l 40 40 150 + +# camera (there can be only one!) +# position FOV target +c 0 6 -17 45 0 -1 0 Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/sphfract.cr =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/sphfract.cr (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/sphfract.cr 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,192 @@ +s 0 0 0 1.0 0.25 0.25 0.25 50.0 0.65 +s 1.4 0 0 0.4 0.25 0.25 0.25 50.0 0.65 +s 1.96 0 0 0.16 0.25 0.25 0.25 50.0 0.65 +s 2.184 0 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.96 0.224 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.96 -0.224 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.96 0 0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.96 0 -0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 0.56 0 0.16 0.25 0.25 0.25 50.0 0.65 +s 1.624 0.56 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.176 0.56 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 0.784 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 0.56 0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 0.56 -0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 -0.56 0 0.16 0.25 0.25 0.25 50.0 0.65 +s 1.624 -0.56 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.176 -0.56 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 -0.784 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 -0.56 0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 -0.56 -0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 0 0.56 0.16 0.25 0.25 0.25 50.0 0.65 +s 1.624 0 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.176 0 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 0.224 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 -0.224 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 0 0.784 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 0 -0.56 0.16 0.25 0.25 0.25 50.0 0.65 +s 1.624 0 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.176 0 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 0.224 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 -0.224 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 1.4 0 -0.784 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 0 0 0.4 0.25 0.25 0.25 50.0 0.65 +s -1.96 0 0 0.16 0.25 0.25 0.25 50.0 0.65 +s -2.184 0 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.96 0.224 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.96 -0.224 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.96 0 0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.96 0 -0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 0.56 0 0.16 0.25 0.25 0.25 50.0 0.65 +s -1.176 0.56 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.624 0.56 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 0.784 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 0.56 0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 0.56 -0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 -0.56 0 0.16 0.25 0.25 0.25 50.0 0.65 +s -1.176 -0.56 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.624 -0.56 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 -0.784 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 -0.56 0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 -0.56 -0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 0 0.56 0.16 0.25 0.25 0.25 50.0 0.65 +s -1.176 0 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.624 0 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 0.224 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 -0.224 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 0 0.784 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 0 -0.56 0.16 0.25 0.25 0.25 50.0 0.65 +s -1.176 0 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.624 0 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 0.224 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 -0.224 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s -1.4 0 -0.784 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 1.4 0 0.4 0.25 0.25 0.25 50.0 0.65 +s 0.56 1.4 0 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.784 1.4 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 1.624 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 1.176 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 1.4 0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 1.4 -0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 1.4 0 0.16 0.25 0.25 0.25 50.0 0.65 +s -0.784 1.4 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 1.624 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 1.176 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 1.4 0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 1.4 -0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 1.96 0 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.224 1.96 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.224 1.96 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 2.184 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 1.96 0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 1.96 -0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 1.4 0.56 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.224 1.4 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.224 1.4 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 1.624 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 1.176 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 1.4 0.784 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 1.4 -0.56 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.224 1.4 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.224 1.4 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 1.624 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 1.176 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 1.4 -0.784 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -1.4 0 0.4 0.25 0.25 0.25 50.0 0.65 +s 0.56 -1.4 0 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.784 -1.4 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 -1.176 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 -1.624 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 -1.4 0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 -1.4 -0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 -1.4 0 0.16 0.25 0.25 0.25 50.0 0.65 +s -0.784 -1.4 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 -1.176 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 -1.624 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 -1.4 0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 -1.4 -0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -1.96 0 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.224 -1.96 0 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.224 -1.96 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -2.184 0 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -1.96 0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -1.96 -0.224 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -1.4 0.56 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.224 -1.4 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.224 -1.4 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -1.176 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -1.624 0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -1.4 0.784 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -1.4 -0.56 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.224 -1.4 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.224 -1.4 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -1.176 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -1.624 -0.56 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -1.4 -0.784 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0 1.4 0.4 0.25 0.25 0.25 50.0 0.65 +s 0.56 0 1.4 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.784 0 1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 0.224 1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 -0.224 1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 0 1.624 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 0 1.176 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 0 1.4 0.16 0.25 0.25 0.25 50.0 0.65 +s -0.784 0 1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 0.224 1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 -0.224 1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 0 1.624 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 0 1.176 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0.56 1.4 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.224 0.56 1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.224 0.56 1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0.784 1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0.56 1.624 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0.56 1.176 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -0.56 1.4 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.224 -0.56 1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.224 -0.56 1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -0.784 1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -0.56 1.624 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -0.56 1.176 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0 1.96 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.224 0 1.96 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.224 0 1.96 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0.224 1.96 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -0.224 1.96 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0 2.184 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0 -1.4 0.4 0.25 0.25 0.25 50.0 0.65 +s 0.56 0 -1.4 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.784 0 -1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 0.224 -1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 -0.224 -1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 0 -1.176 0.064 0.25 0.25 0.25 50.0 0.65 +s 0.56 0 -1.624 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 0 -1.4 0.16 0.25 0.25 0.25 50.0 0.65 +s -0.784 0 -1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 0.224 -1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 -0.224 -1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 0 -1.176 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.56 0 -1.624 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0.56 -1.4 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.224 0.56 -1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.224 0.56 -1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0.784 -1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0.56 -1.176 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0.56 -1.624 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -0.56 -1.4 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.224 -0.56 -1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.224 -0.56 -1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -0.784 -1.4 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -0.56 -1.176 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -0.56 -1.624 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0 -1.96 0.16 0.25 0.25 0.25 50.0 0.65 +s 0.224 0 -1.96 0.064 0.25 0.25 0.25 50.0 0.65 +s -0.224 0 -1.96 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0.224 -1.96 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -0.224 -1.96 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 0 -2.184 0.064 0.25 0.25 0.25 50.0 0.65 +s 0 -10002.25 0 10000 0.2 0.35 0.5 80.0 0.4 +s 0 10100.00 0 10000 0.5 0.2 0.1 40.0 0.0 +l -50 68 -50 +l 40 40 150 +c -7 6 -12 45 0 -0.65 0 Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/test.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/test.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/test.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,2 @@ +#!/bin/sh +cat scene.cr | ./c-ray > scene.ppm Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/c-ray/test.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/Makefile =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/Makefile (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/Makefile 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,59 @@ +bin = md + +CC = gcc +INCLUDES := +OPTZ = -O0 +OPTS = -O3 -ffast-math +CFLAGS = $(OPTZ) -g -fPIC -std=gnu99 $(INCLUDES) + +SRC = main.c md.c +OBJ = $(patsubst %.c,%.o,$(SRC)) + + + +all: $(bin) + +# Link stand-alone executable: +$(bin): $(OBJ) + $(CC) -o $(@) $(OBJ) -lm + +# Swift/T integration: + +USE_SWIFT = 1 +ifeq ($(USE_SWIFT),1) + +TCL_HOME = $(HOME)/sfw/tcl-8.6.0 +INCLUDES += -I $(TCL_HOME)/include +TCLSH = $(TCL_HOME)/bin/tclsh8.6 + +swift-pkg: pkgIndex.tcl + +md_wrap.c: md.i md.h + swig $(<) + sed -i s/Md_Init/Tclmd_Init/ $(@) + +libtclmd.so: md_wrap.o $(OBJ) + gcc -shared -o $(@) $(^) -L $(TCL_HOME)/lib -l tcl8.6 + +pkgIndex.tcl: libtclmd.so + LEAF_PKG=md LEAF_VERSION=0.0 \ + LEAF_SO=$(<) LEAF_TCL=md.tcl \ + $(TCLSH) ./make-package.tcl > $(@) + +clean:: + rm -fv pkgIndex.tcl libtclmd.so md_wrap.c + +endif # Swift/T + +.PHONY: clean +clean:: + rm -fv $(OBJ) $(bin) + +.PHONY: install +install: + cp $(bin) ../../bin/$(bin) + +.PHONY: uninstall +uninstall: + rm -f ../../bin/$(bin) + Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/clean.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/clean.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/clean.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,2 @@ +#! /bin/sh +rm -f md??.trj md.dat Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/clean.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/main.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/main.c (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/main.c 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,219 @@ + +/* + * main.c + * + * Created on: Aug 13, 2014 + * Author: wozniak + */ + +#include +#include +#include "md.h" + + +char *outfile = "md.dat"; +char *trjfile = "md.trj"; + + +/******************************************************************************/ + +int main ( int argc, char *argv[] ) + +/******************************************************************************/ +/* + Purpose: + + MAIN is the main program for MD. + + Discussion: + + MD implements a simple molecular dynamics simulation. + + The velocity Verlet time integration scheme is used. + + The particles interact with a central pair potential. + + Usage: + + md nd np step_num print_step_num dt mass printinfo scale_factor scale_offset seed outFile trajectoryFile + where + * nd is the spatial dimension (2 or 3); + * np is the number of particles (500, for instance); + * step_num is the number of time steps (500, for instance); + * print_step_num is the number of snapshot prints (10 for instance); + * dt is size of timestep; + * mass is particle mass; + * printinfo is a string to append to each particle coord + * scale_offset and scale_factor are used to scale particle positions for logging/rendering (FIXME) + * seed sets the initial configuration + + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 05 November 2010 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + None +*/ +{ + + double ctime; + double ctime1; + double ctime2; + double dt = 0.0001; + int i; + int id; + double mass = 1.0 * .0001; + int nd; + int np; + + int seed = 123456789; + int step; + int step_num; + int step_print; + int step_print_index = 0; + int step_print_num = 10; + double *vel; + + timestamp ( ); + printf ( "\n" ); + printf ( "MD\n" ); + printf ( " C version\n" ); + printf ( " A molecular dynamics program.\n" ); +/* + Get the spatial dimension. +*/ + if ( 1 < argc ) + { + nd = atoi ( argv[1] ); + } + else + { + printf ( "\n" ); + printf ( " Enter ND, the spatial dimension (2 or 3).\n" ); + scanf ( "%d", &nd ); + } +// +// Get the number of points. +// + if ( 2 < argc ) + { + np = atoi ( argv[2] ); + } + else + { + printf ( "\n" ); + printf ( " Enter NP, the number of points (500, for instance).\n" ); + scanf ( "%d", &np ); + } +// +// Get the number of time steps. +// + if ( 3 < argc ) + { + step_num = atoi ( argv[3] ); + } + else + { + printf ( "\n" ); + printf ( " Enter ND, the number of time steps (500 or 1000, for instance).\n" ); + scanf ( "%d", &step_num ); + } + /* + Get any additional args (command-line only) + md nd np step_num [ step__print_num dt mass printinfo scale_factor scale_offset randomseed outfile trjfile ] + */ + if ( 4 < argc ) + { + step_print_num = atoi ( argv[4] ); + } + if ( 5 < argc ) + { + dt = atof ( argv[5] ); + } + if ( 6 < argc ) + { + mass = atof ( argv[6] ); + } + if ( 7 < argc ) + { + printinfo = ( argv[7] ); + } + if ( 8 < argc ) + { + scale_factor = atof ( argv[8] ); + } + if ( 9 < argc ) + { + scale_offset = atof ( argv[9] ); + } + if ( 10 < argc ) + { + seed = atof ( argv[10] ); + } + if ( 11 < argc ) + { + outfile = argv[11]; + } + if ( 12 < argc ) + { + trjfile = argv[12]; + } + +/* + Report. +*/ + printf ( "\n" ); + printf ( " MD: Argument count: %d\n", argc ); + printf ( " ND, the spatial dimension, is %d\n", nd ); + printf ( " NP, the number of particles in the simulation, is %d\n", np ); + printf ( " STEP_NUM, the number of time steps, is %d\n", step_num ); + printf ( " STEP_PRINT_NUM, the number of snapshots to print, is %d\n", step_print_num ); + printf ( " DT, the size of each time step, is %f\n", dt ); + printf ( " MASS, the particle mass, is %f\n", mass ); + printf ( " PRINTINFO, the pass-through info to c-ray, is %s\n", printinfo ); + printf ( " SCALE_FACTOR, the particle position scaling factor, is %f\n", scale_factor ); + printf ( " SCALE_OFFSET, the particle position scaling offset, is %f\n", scale_offset ); + printf ( " SEED, the simulation randomization seed, is %d\n", seed ); + + ctime1 = cpu_time ( ); + + simulate (step_num, step_print_num, step_print, step_print_index, + np, nd, mass, + dt, seed, outfile, trjfile); + + ctime2 = cpu_time ( ); + ctime = ctime2 - ctime1; + + printf ( "\n" ); + printf ( " Elapsed cpu time for main computation:\n" ); + printf ( " %f seconds.\n", ctime ); + +#ifdef NOTDEF + char tarcmd[2000]; + sprintf(tarcmd,"tar zcf %s md??.trj",trjfile); + system(tarcmd); +#endif + +/* + Terminate. +*/ + printf ( "\n" ); + printf ( "MD\n" ); + printf ( " Normal end of execution.\n" ); + + printf ( "\n" ); + timestamp ( ); + + return 0; +} Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/make-package.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/make-package.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/make-package.tcl 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,9 @@ + +set name $env(LEAF_PKG) +set version $env(LEAF_VERSION) +set leaf_so $env(LEAF_SO) +set leaf_tcl $env(LEAF_TCL) + +puts [ ::pkg::create -name $name -version $version \ + -load $leaf_so -source $leaf_tcl ] + Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/make-package.tcl ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.c =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.c (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.c 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,613 @@ +# include +# include +# include +# include +# include + +#include "md.h" + +double scale_factor = 2.5, scale_offset = -2.0; +char *printinfo = "0.05 1.0 0.2 0.05 50.0 0.1"; + + +double dist ( int nd, double r1[], double r2[], double dr[] ); + +double r8_uniform_01 ( int *seed ); +void update ( int np, int nd, double pos[], double vel[], double f[], + double acc[], double mass, double dt ); +void snap ( int np, int nd, int t, double pos[], double vel[], double f[], + double acc[], double mass, double dt ); + +static void trj_file_open(char *trjfile); +static void trj_file_close(void); + +void simulate (int step_num, int step_print_num, + int step_print, int step_print_index, + int np, int nd, + double mass, + double dt, + int seed, + char* outfile, + char* trjfile) +{ + /* + Allocate memory. + */ + double* acc = ( double * ) malloc ( nd * np * sizeof ( double ) ); + double* box = ( double * ) malloc ( nd * sizeof ( double ) ); + double* force = ( double * ) malloc ( nd * np * sizeof ( double ) ); + double* pos = ( double * ) malloc ( nd * np * sizeof ( double ) ); + double* vel = ( double * ) malloc ( nd * np * sizeof ( double ) ); + /* + Set the dimensions of the box. + */ + for (int i = 0; i < nd; i++ ) + { + box[i] = 10.0; + } + + printf ( "\n" ); + printf ( " Initializing positions, velocities, and accelerations.\n" ); + + trj_file_open(trjfile); + + /* + Set initial positions, velocities, and accelerations. + */ + initialize ( np, nd, box, &seed, pos, vel, acc ); + /* + Compute the forces and energies. + */ + printf ( "\n" ); + printf ( " Computing initial forces and energies.\n" ); + + double potential, kinetic; + compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); + double e0 = potential + kinetic; + /* + This is the main time stepping loop: + Compute forces and energies, + Update positions, velocities, accelerations. + */ + printf ( "\n" ); + printf ( " At each step, we report the potential and kinetic energies.\n" ); + printf ( " The sum of these energies should be a constant.\n" ); + printf ( " As an accuracy check, we also print the relative error\n" ); + printf ( " in the total energy.\n" ); + printf ( "\n" ); + printf ( " Step Potential Kinetic (P+K-E0)/E0\n" ); + printf ( " Energy P Energy K Relative Energy Error\n" ); + printf ( "\n" ); + + FILE *ofile = fopen(outfile,"w"); + fprintf (ofile, " Step Potential Kinetic RelativeErr\n" ); + + int step = 0; + printf ( " %8d %14f %14f %14e\n", + step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); + fprintf ( ofile, " %8d %14f %14f %14e\n", + step, potential, kinetic, ( potential + kinetic - e0 ) / e0 ); + step_print_index = step_print_index + 1; + step_print = ( step_print_index * step_num ) / step_print_num; + + + for (step = 1; step <= step_num; step++ ) + { + compute ( np, nd, pos, vel, mass, force, &potential, &kinetic ); + + if ( step == step_print ) + { + printf ( " %8d %14f %14f %14e\n", step, potential, kinetic, + ( potential + kinetic - e0 ) / e0 ); + fprintf ( ofile, " %8d %14f %14f %14e\n", step, potential, kinetic, + ( potential + kinetic - e0 ) / e0 ); + step_print_index = step_print_index + 1; + step_print = ( step_print_index * step_num ) / step_print_num; + snap (np, nd, step, pos, vel, force, acc, mass, dt ); + } + update ( np, nd, pos, vel, force, acc, mass, dt ); + } + + free ( acc ); + free ( box ); + free ( force ); + free ( pos ); + free ( vel ); + + fclose(ofile); + trj_file_close(); +} + +/******************************************************************************/ + +void compute ( int np, int nd, double pos[], double vel[], + double mass, double f[], double *pot, double *kin ) + +/******************************************************************************/ +/* + Purpose: + + COMPUTE computes the forces and energies. + + Discussion: + + The computation of forces and energies is fully parallel. + + The potential function V(X) is a harmonic well which smoothly + saturates to a maximum value at PI/2: + + v(x) = ( sin ( min ( x, PI2 ) ) )^2 + + The derivative of the potential is: + + dv(x) = 2.0 * sin ( min ( x, PI2 ) ) * cos ( min ( x, PI2 ) ) + = sin ( 2.0 * min ( x, PI2 ) ) + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 21 November 2007 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + Input, int NP, the number of particles. + + Input, int ND, the number of spatial dimensions. + + Input, double POS[ND*NP], the position of each particle. + + Input, double VEL[ND*NP], the velocity of each particle. + + Input, double MASS, the mass of each particle. + + Output, double F[ND*NP], the forces. + + Output, double *POT, the total potential energy. + + Output, double *KIN, the total kinetic energy. +*/ +{ + double d; + double d2; + int i; + int j; + int k; + double ke; + double pe; + double PI2 = 3.141592653589793 / 2.0; + double rij[3]; + + pe = 0.0; + ke = 0.0; + + for ( k = 0; k < np; k++ ) + { +/* + Compute the potential energy and forces. +*/ + for ( i = 0; i < nd; i++ ) + { + f[i+k*nd] = 0.0; + } + + for ( j = 0; j < np; j++ ) + { + if ( k != j ) + { + d = dist ( nd, pos+k*nd, pos+j*nd, rij ); +/* + Attribute half of the potential energy to particle J. +*/ + if ( d < PI2 ) + { + d2 = d; + } + else + { + d2 = PI2; + } + + pe = pe + 0.5 * pow ( sin ( d2 ), 2 ); + + for ( i = 0; i < nd; i++ ) + { + f[i+k*nd] = f[i+k*nd] - rij[i] * sin ( 2.0 * d2 ) / d; + } + } + } +/* + Compute the kinetic energy. +*/ + for ( i = 0; i < nd; i++ ) + { + ke = ke + vel[i+k*nd] * vel[i+k*nd]; + } + } + + ke = ke * 0.5 * mass; + + *pot = pe; + *kin = ke; + + return; +} +/*******************************************************************************/ + +double cpu_time ( void ) + +/*******************************************************************************/ +/* + Purpose: + + CPU_TIME reports the total CPU time for a program. + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 27 September 2005 + + Author: + + John Burkardt + + Parameters: + + Output, double CPU_TIME, the current total elapsed CPU time in second. +*/ +{ + double value; + + value = ( double ) clock ( ) / ( double ) CLOCKS_PER_SEC; + + return value; +} +/******************************************************************************/ + +double dist ( int nd, double r1[], double r2[], double dr[] ) + +/******************************************************************************/ +/* + Purpose: + + DIST computes the displacement (and its norm) between two particles. + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 21 November 2007 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + Input, int ND, the number of spatial dimensions. + + Input, double R1[ND], R2[ND], the positions of the particles. + + Output, double DR[ND], the displacement vector. + + Output, double D, the Euclidean norm of the displacement. +*/ +{ + double d; + int i; + + d = 0.0; + for ( i = 0; i < nd; i++ ) + { + dr[i] = r1[i] - r2[i]; + d = d + dr[i] * dr[i]; + } + d = sqrt ( d ); + + return d; +} +/******************************************************************************/ + +void initialize ( int np, int nd, double box[], int *seed, double pos[], + double vel[], double acc[] ) + +/******************************************************************************/ +/* + Purpose: + + INITIALIZE initializes the positions, velocities, and accelerations. + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 20 July 2008 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + Input, int NP, the number of particles. + + Input, int ND, the number of spatial dimensions. + + Input, double BOX[ND], specifies the maximum position + of particles in each dimension. + + Input, int *SEED, a seed for the random number generator. + + Output, double POS[ND*NP], the position of each particle. + + Output, double VEL[ND*NP], the velocity of each particle. + + Output, double ACC[ND*NP], the acceleration of each particle. +*/ +{ + int i; + int j; +/* + Give the particles random positions within the box. +*/ + for ( j = 0; j < np; j++ ) + { + for ( i = 0; i < nd; i++ ) + { + pos[i+j*nd] = box[i] * r8_uniform_01 ( seed ); + vel[i+j*nd] = 0.0; + acc[i+j*nd] = 0.0; + } + } + return; +} +/******************************************************************************/ + +double r8_uniform_01 ( int *seed ) + +/******************************************************************************/ +/* + Purpose: + + R8_UNIFORM_01 is a unit pseudorandom R8. + + Discussion: + + This routine implements the recursion + + seed = 16807 * seed mod ( 2^31 - 1 ) + unif = seed / ( 2^31 - 1 ) + + The integer arithmetic never requires more than 32 bits, + including a sign bit. + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 11 August 2004 + + Author: + + John Burkardt + + Reference: + + Paul Bratley, Bennett Fox, Linus Schrage, + A Guide to Simulation, + Springer Verlag, pages 201-202, 1983. + + Bennett Fox, + Algorithm 647: + Implementation and Relative Efficiency of Quasirandom + Sequence Generators, + ACM Transactions on Mathematical Software, + Volume 12, Number 4, pages 362-376, 1986. + + Parameters: + + Input/output, int *SEED, a seed for the random number generator. + + Output, double R8_UNIFORM_01, a new pseudorandom variate, strictly between + 0 and 1. +*/ +{ + int k; + double r; + + k = *seed / 127773; + + *seed = 16807 * ( *seed - k * 127773 ) - k * 2836; + + if ( *seed < 0 ) + { + *seed = *seed + 2147483647; + } + + r = ( double ) ( *seed ) * 4.656612875E-10; + + return r; +} +/******************************************************************************/ + +void timestamp ( void ) + +/******************************************************************************/ +/* + Purpose: + + TIMESTAMP prints the current YMDHMS date as a time stamp. + + Example: + + 31 May 2001 09:45:54 AM + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 24 September 2003 + + Author: + + John Burkardt + + Parameters: + + None +*/ +{ +# define TIME_SIZE 40 + + static char time_buffer[TIME_SIZE]; + const struct tm *tm; + size_t len; + time_t now; + + now = time ( NULL ); + tm = localtime ( &now ); + + len = strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); + + printf ( "%s\n", time_buffer ); + + return; +# undef TIME_SIZE +} +/******************************************************************************/ + +void update ( int np, int nd, double pos[], double vel[], double f[], + double acc[], double mass, double dt ) + +/******************************************************************************/ +/* + Purpose: + + UPDATE updates positions, velocities and accelerations. + + Discussion: + + The time integration is fully parallel. + + A velocity Verlet algorithm is used for the updating. + + x(t+dt) = x(t) + v(t) * dt + 0.5 * a(t) * dt * dt + v(t+dt) = v(t) + 0.5 * ( a(t) + a(t+dt) ) * dt + a(t+dt) = f(t) / m + + Licensing: + + This code is distributed under the GNU LGPL license. + + Modified: + + 21 November 2007 + + Author: + + Original FORTRAN90 version by Bill Magro. + C version by John Burkardt. + + Parameters: + + Input, int NP, the number of particles. + + Input, int ND, the number of spatial dimensions. + + Input/output, double POS[ND*NP], the position of each particle. + + Input/output, double VEL[ND*NP], the velocity of each particle. + + Input, double F[ND*NP], the force on each particle. + + Input/output, double ACC[ND*NP], the acceleration of each particle. + + Input, double MASS, the mass of each particle. + + Input, double DT, the time step. +*/ +{ + int i; + int j; + double rmass; + + rmass = 1.0 / mass; + + for ( j = 0; j < np; j++ ) + { + for ( i = 0; i < nd; i++ ) + { + pos[i+j*nd] = pos[i+j*nd] + vel[i+j*nd] * dt + 0.5 * acc[i+j*nd] * dt * dt; + vel[i+j*nd] = vel[i+j*nd] + 0.5 * dt * ( f[i+j*nd] * rmass + acc[i+j*nd] ); + acc[i+j*nd] = f[i+j*nd] * rmass; + } + /* +s -0.5 -0.3 -1 0.05 1.0 0.2 0.05 50.0 0.1 +s 0.5 -0.4 0 0.05 0.1 0.85 1.0 50.0 0.1 + */ + char *s = "0.05 1.0 0.2 0.05 50.0 0.1"; + /* printf("s %f %f %f %s\n", pos[0+j*nd]/20.0, pos[1+j*nd]/20.0, pos[2+j*nd]/20.0, s); */ + } + + return; +} + + +double scale (double x) +{ + return( (x / scale_factor) - scale_offset); + /* return( (x / 2.5) - 2.0); */ +} + +static int snapid = 0; +static FILE *trj_file = NULL; + +static void trj_file_open(char *trjfile) +{ +#ifdef NOTDEF + char snapfile[100]; + sprintf(snapfile, "md%02d.trj", snapid); +#endif + trj_file = fopen(trjfile, "w"); + assert(trj_file != NULL); +} + +static void trj_file_close() +{ + fclose(trj_file); + trj_file = NULL; +} + +void snap ( int np, int nd, int t, double pos[], double vel[], double f[], + double acc[], double mass, double dt ) +{ + int j; + + for ( j = 0; j < np; j++ ) + { + fprintf(trj_file, "%d s %f %f %f %s\n", + snapid, scale(pos[0+j*nd]), scale(pos[1+j*nd]), scale(pos[2+j*nd]), printinfo); + } + + snapid++; +} Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.h =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.h (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.h 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,33 @@ +/* + * md.h + * + * Created on: Aug 13, 2014 + * Author: wozniak + */ + +#ifndef MD_H +#define MD_H + +extern double scale_factor, scale_offset; +extern char *printinfo; + +double cpu_time ( void ); + +void timestamp ( void ); + +void initialize ( int np, int nd, double box[], int *seed, double pos[], + double vel[], double acc[] ); + +void compute ( int np, int nd, double pos[], double vel[], + double mass, double f[], double *pot, double *kin ); + +void simulate (int step_num, int step_print_num, + int step_print, int step_print_index, + int np, int nd, + double mass, + double dt, + int seed, + char* outfile, + char* trjfile); + +#endif Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.i =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.i (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.i 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,6 @@ + +%module md +%include "md.h" +%{ + #include "md.h" +%} Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/md.tcl 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,4 @@ + +namespace eval md { + # Nothing +} Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,10 @@ +#!/bin/sh -eu + +NPART=4 +STEPS=10 +MASS=1 +SEED=42 +OUT=output.txt +TRJ=output.trj + +./md 3 ${NPART} ${STEPS} 10 ".0001" ${MASS} "0.1 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 ${SEED} ${OUT} ${TRJ} Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.tcl =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.tcl (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.tcl 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,7 @@ +#!/usr/bin/env tclsh8.6 + +lappend auto_path $env(PWD) +package require md 0.0 + +simulate 4 2 0 0 10 2 1 0.1 9 out.txt + Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test-md.tcl ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,3 @@ +#! /bin/sh + +./md 3 50 1000 Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/md/test.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d01.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d01.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d01.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,9 @@ +#! /bin/sh + +cr=../c-ray-1.1 +md=../mdlite + +for ((i=0;i<50;i++)); do + $md/md 3 50 30000 | tee md$i.trj | grep ^s:$i | cat - $cr/ts2 | $cr/cr >fr$i.ppm ; convert fr$i.ppm fr$i.png +done +convert fr*png t.gif; open -a Safari t.gif Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d01.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d02.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d02.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d02.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,13 @@ +#! /bin/sh + +cr=../c-ray-1.1 +md=../mdlite + +$md/md 3 50 30000 + +for t in md??.trj; do + cat $t $cr/ts2 | $cr/cr >t.ppm + convert t.ppm $t.png +done + +convert -delay 20 md??.trj.png t.gif; open -a Safari t.gif Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d02.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d03.sh =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d03.sh (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d03.sh 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,14 @@ +#! /bin/sh + +cr=../c-ray-1.1 +md=../mdlite + +# $md/md 3 50 30000 + $md/md 3 50 30000 50 .0001 .005 "0.03 1.0 0.2 0.05 50.0 0.1" 2.5 2.0 + +for t in md??.trj; do + cat $t $cr/ts2 | $cr/cr >t.ppm + convert t.ppm $t.png +done + +convert -delay 20 md??.trj.png t.gif; open -a Safari t.gif Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/src/shdemo/d03.sh ___________________________________________________________________ Added: svn:executable + * Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/tukey.properties =================================================================== --- SwiftTutorials/ATPESC_2014-08-14/swift-k/tukey.properties (rev 0) +++ SwiftTutorials/ATPESC_2014-08-14/swift-k/tukey.properties 2014-08-13 23:14:19 UTC (rev 8164) @@ -0,0 +1,18 @@ +site=tukey + +site.tukey { + jobmanager=localhost:cobalt + taskWalltime=00:15:00 + workdir=/home/$USER/swiftwork + filesystem=local + maxJobs=10 + tasksPerWorker=10 + taskThrottle=300 + initialscore=10000 +} + +app.tukey.md=$PWD/../app/md +app.tukey.mdstats=$PWD/../app/mdstats +app.tukey.mdmaxk=$PWD/../app/mdmaxk +app.tukey.renderframe=$PWD/../app/renderframe +app.tukey.convert=/usr/bin/convert Added: SwiftTutorials/ATPESC_2014-08-14/swift-k/tutorial.pptx =================================================================== (Binary files differ) Property changes on: SwiftTutorials/ATPESC_2014-08-14/swift-k/tutorial.pptx ___________________________________________________________________ Added: svn:mime-type + application/octet-stream From wozniak at ci.uchicago.edu Fri Aug 22 15:04:29 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Fri, 22 Aug 2014 20:04:29 -0000 Subject: [Swift-commit] r8227 - www/Swift-T Message-ID: <20140822201508.C17E69D850@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-22 15:15:08 -0500 (Fri, 22 Aug 2014) New Revision: 8227 Modified: www/Swift-T/guide.html Log: Fix @prio Modified: www/Swift-T/guide.html =================================================================== --- www/Swift-T/guide.html 2014-08-16 00:19:16 UTC (rev 8226) +++ www/Swift-T/guide.html 2014-08-22 20:15:08 UTC (rev 8227) @@ -1,1478 +1,415 @@ - - - - - -Swift/T Guide - - - - - -
-
-
-

The Swift/Turbine Compiler (STC) allows you to write Swift programs -and run them using Turbine.

-
-
-
-

1. Support

-
-

An overview of Swift/T may be found at the ExM project site:

- -

The Swift/T user discussion mailing list is found here:

- -
-
-
-

2. Installation

-
-

Writing and running Swift/Turbine programs requires multiple packages. -This section provides generic instructions for installing Swift/T -on a range of systems. We first cover locating and/or installing -prerequisite software packages, then we cover building Swift/T -from a source package.

-

The Turbine Sites Guide -is a accompanying resource for configuration settings and preinstalled software -for specific systems.

-
-

2.1. Installation of Prerequisites

-
    -
  1. -

    -Install or locate MPI implementation (MPICH, OpenMPI, etc.) -

    -
      -
    • -

      -On compute clusters, an MPI will almost certainly be pre-installed -

      -
    • -
    • -

      -Many operating systems provide packages with MPI implementations - that are usable, but often outdated. - E.g. the mpich2 package on Debian/Ubuntu. -

      -
    • -
    • -

      -See MPICH Guides for information on installing the - latest version of MPICH. -

      -
    • -
    • -

      -Other MPI implementations are supported as well. -

      -

      Swift/T attempts to use MPI 3.0 functionality by default. If you -are using an MPI implementation that does not support the MPI 3.0 standard, -you must set MPI_VERSION=2 (if using the exm-setup.zsh build process), -or provide the --enable-mpi-2 configure option (if using -the manual build process).

      -
    • -
    -
  2. -
  3. -

    -Install or locate Tcl 8.6. -

    -
      -
    • -

      -Tcl is available through the package manager on many systems. - You may need to install an additional Tcl development package - in addition to the standard tcl package, - e.g. tcl8.6 plus tcl8.6-dev on Debian/Ubuntu systems. -

      -
    • -
    • -

      -Source distributions are available at the Tcl web site -

      -
    • -
    -
  4. -
  5. -

    -Install or locate SWIG -

    -
      -
    • -

      -You can check if SWIG is installed by running swig -version -

      -
    • -
    • -

      -SWIG is available through the package manager on many systems. -

      -
    • -
    • -

      -Source distributions are available at - the SWIG web site -

      -
    • -
    -
  6. -
-
-
-

2.2. Installation of Swift/T from Source

-

Once you have found all prerequisites, we can continue with building -Swift/T from source.

-
    -
  1. -

    -Obtain the Swift/T source package -

    -
    -
    -
    wget http://www.mcs.anl.gov/exm/local/downloads/exm-0.5.0.tar.gz
    -
    -

    Cf. Swift/T Downloads -for other packages

    -
  2. -
  3. -

    -Unpack and enter package directory -

    -
    -
    -
    tar xfz exm-trunk.tar.gz
    -cd exm-trunk
    -
    -
  4. -
  5. -

    -Edit the settings file: exm-settings.sh -

    -

    At a minimum, you must set the install directory with EXM_PREFIX. -On a standard system, no further configuration may be needed. -In many cases, however, you will need to modify additional -configuration settings so that all prerequisites can -be correctly located and configured (see Section -Build configuration).

    -

    A range of other settings are also available here: -enabling/disabling features, debug or optimized builds, etc.

    -
    - - - -
    -
    Tip
    -
    Save your exm-settings.sh when you download a new package
    -
    -
  6. -
  7. -

    -Run the setup script -

    -
    -
    -
    ./exm-setup.zsh
    -
    -

    If exm-setup.zsh does not succeed on your system, see Section -Build configuration below.

    -
    - - - -
    -
    Tip
    -
    if you want more control than exm-setup.zsh provides, you can - build Swift/T with the - manual configure/make workflow.
    -
    -
  8. -
  9. -

    -Add Turbine and STC to your paths -

    -
    -
    -
    PATH=${PATH}:/path/to/exm-install/turbine/bin
    -PATH=${PATH}:/path/to/exm-install/stc/bin
    -
    -
  10. -
-
-
-
-
-

3. Usage

-
-

Swift code is conventionally written in *.swift files. Turbine -code is stored in Tcl files *.tcl. After writing the Swift program -program.swift, run:

-
-
-
stc program.swift
-
-

This will compile the program to program.tcl. A second, optional -argument may be given as an alternate output file name.

-

Then, to run the program, use Turbine:

-
-
-
turbine -n 4 program.tcl
-
-

See the Turbine section for more information about -running the program.

-

STC accepts the following arguments:

-
-
--A name=value -
-
-

-Set a command-line argument at -compile-time. This may be found at runtime using the Swift -argument processing library. This option enables these -arguments to be treated as compile-time constants for optimization. -

-
-
--D macro=value -
-
-

-Define a C preprocessor macro. -

-
-
--E -
-
-

-Just run the C preprocessor: do not compile the program. The -output goes into the STC output file (the second file name argument). -

-
-
--I -
-
-

-Add a directory to the import and include search path. -

-
-
--O -
-
-

-Set optimization level: 0, 1, 2, or 3. See [Optimizations]. -

-
-
--j -
-
-

-Set the location of the java executable. -

-
-
--p -
-
-

-Disable the C preprocessor. -

-
-
--u -
-
-

-Only compile if output file is not up-to-date. -

-
-
--v -
-
-

-Output version number and exit. -

-
-
--V -
-
-

-Verbose output. -

-
-
-

STC runs as a Java program. You may use -j to set the Java VM -executable. This Java VM must be compatible with the javac used to -compile STC.

-

By default, STC runs the user script through the C preprocessor -(cpp), enabling arbitrary macro processing, etc. The -D, -E, --I, and -p options are relevant to this feature.

-

Additional arguments for advanced users/developers:

-
-
--C -
-
-

-Specify an output file for STC internal representation -

-
-
--l -
-
-

-Specify log file for STC debug log -

-
-
--L -
-
-

-Specify log file for more verbose STC debug log -

-
-
--T -
-
-

-Enable a specific optimization. See [Optimizations] -

-
-
--t -
-
-

-Disable a specific compiler optimization. See [Optimizations] -

-
-
-
-
-
-

4. Program structure

-
-

Swift programs are composed of composite functions. These -share syntax with C-like languages. The program starts in main(). -The following is a complete Swift program:

-
-
-
main
-{}
-
-

STC input is preprocessed by cpp, the C preprocessor.

-

Hello world is written as:

-
-
-
import io;
-main
-{
-  printf("Hello world");
-}
-
-

The newline is supplied by printf().

-

Swift programs eventually call leaf functions, which are the primary -way to do work. From the perspective of the Swift script, they are -atomic operations that wait for input variables and set output -variables. They may be implemented as native code functions or -external application programs.

-
-
-
-

5. Comments

-
-

Swift supports C/C++-style comments:

-
-
-
// This is a comment
-/* This is a
-comment */
-/** Also a
-comment */
-
-

Additionally, if the preprocessor is disabled, single-line comments -starting with # are supported:

-
-
-
# This will work if source file is not preprocessed
-
-
-
-
-

6. Modules

-
-

Swift has a module system that allows you to import function and variable -definitions into your source file. Importing a module will import all -function and variable definitions from that module into your program.

-
-
-
import io;
-import mypackage.mymodule;
-
-

The mechanisms for locating source files is as follows:

-
    -
  • -

    -STC searches a list of directories in order to find a Swift source - file in the correct directory with the correct name. -

    -
  • -
  • -

    -The standard library is always first on the search path, - and the current working directory is last. -

    -
  • -
  • -

    -Additional directories can be added with the -I option to STC. -

    -
  • -
  • -

    -Swift source files must have a .swift suffix. E.g. import io; - looks for a file called io.swift. -

    -
  • -
  • -

    -In the case of a multi-part import name, E.g. import mypackage.mymodule, - then, it looks for mymodule.swift in subdirectory mypackage. -

    -
  • -
-

The alternative #include statement textually includes an entire -file using the C preprocessor at the point of the statement. -Note that #include will only work if the preprocessor is enabled -on the current file. In contrast to import, #include will run the -C preprocessor on any included modules. import is recommended over -#include unless the imported module requires preprocessing.

-
-
-
#include <mypackage/mymodule.swift>
-
-
-
-
-

7. Dataflow evaluation

-
-

Swift expressions are evaluated in dataflow order:

-
-
-
int z1,z2;
+----
+int z1,z2;
 int y;
 int x = f(y);
 y = g(2);
 z1 = h(x,y,1);
 z2 = h(x,y,2);
-int output = r(z1,z2);
-
-

This allows code to execute as concurrently as possible, limited -only by data availability. In this example, g() runs first, because it -is dependent only on a literal. When y is set, f() runs, setting -x. Then, two invocations of h() execute. Finally, z1 and z2 -are set, allowing r() to run.

-

Variables may be assigned only once. Multiple assignment is often +int output = r(z1,z2); +---- + +This allows code to execute as concurrently as possible, limited +only by data availability. In this example, +g()+ runs first, because it +is dependent only on a literal. When +y+ is set, +f()+ runs, setting ++x+. Then, two invocations of +h()+ execute. Finally, +z1+ and +z2+ +are set, allowing +r()+ to run. + +Variables may be assigned only once. Multiple assignment is often detected at compile time, and will always be detected at run time, resulting in a run time error. If variable is not assigned, expressions that depend on the variable cannot execute. If the variable is never assigned during the course of program execution, these expressions will never execute. Upon program completion, Swift/T will report the error and print debug information about any unexecuted -expressions and identifiers of corresponding unassigned variables.

-
-
-
-

8. Composite functions

-
-

Swift code is written in composite functions. The composite function -main is required.

-

Composite functions have the form:

-
-
-
[(<output list>)] function_name [(<input list>)]
+expressions and identifiers of corresponding unassigned variables.
+
+== Composite functions
+
+Swift code is written in composite functions.  The composite function
++main+ is required.
+
+Composite functions have the form:
+
+----
+[()] function_name [()]
 {
   statement;
   statement;
   ...
-}
-
-

An empty input or output list may be omitted or written as ().

-

The output list may have more than one entry. Thus, assignments -may be written as:

-
-
-
x1, x2 = f(i1, i2);
+}
+----
+
+An empty input or output list may be omitted or written as +()+.
+
+The output list may have more than one entry.  Thus, assignments
+may be written as:
+----
+x1, x2 = f(i1, i2);
 // or equivalently:
-(x1, x2) = f(i1, i2);
-
-
-
-
-

9. Types

-
-

Swift provides a similar range of primitive types to many other +(x1, x2) = f(i1, i2); +---- + +== Types + +Swift provides a similar range of primitive types to many other programming languages. Files are a primitive type in Swift, unlike in many other languages, and have a number of special characteristics that merit special mention. -Two basic kinds of data structure are provided: arrays and structs.

-
-

9.1. Primitive types

-

Swift has the conventional types:

-
-
-string -
-
-

-A complete string (not an array of characters). -

-
-
-int -
-
-

-A 64-bit integer. -

-
-
-float -
-
-

-A 64-bit (double-precision) floating point number. -

-
-
-boolean -
-
-

-A boolean (true/false). -

-
-
-file -
-
-

-A file (see Section Files). -

-
-
-blob -
-
-

-External byte data (see Section Blobs). -

-
-
-

Literals for these types use conventional syntax:

-
    -
  • -

    -int literals are written as decimal numbers, e.g. -1234 -

    -
  • -
  • -

    -float literals are written as decimal numbers with a decimal point, - e.g 5493.352 or 1.0. +Two basic kinds of data structure are provided: arrays and structs. + +=== Primitive types + +Swift has the conventional types: + ++string+:: A complete string (not an array of characters). ++int+:: A 64-bit integer. ++float+:: A 64-bit (double-precision) floating point number. ++boolean+:: A boolean (true/false). ++file+:: A file (see Section Files). ++blob+:: External byte data (see Section Blobs). + +Literals for these types use conventional syntax: + +* +int+ literals are written as decimal numbers, e.g. +-1234+ +* +float+ literals are written as decimal numbers with a decimal point, + e.g +5493.352+ or +1.0+. Scientific notation may be used, - as in 2.3e-2 which is equivalent to 0.023. - The literals NaN and inf may be used. In some contexts int - literals are promoted automatically to float. -

    -
  • -
  • -

    -boolean literals true and false may be used. -

    -
  • -
  • -

    -string literals are enclosed in double quotes, with a range of escape + as in +2.3e-2+ which is equivalent to +0.023+. + The literals +NaN+ and +inf+ may be used. In some contexts +int+ + literals are promoted automatically to +float+. +* +boolean+ literals +true+ and +false+ may be used. +* +string+ literals are enclosed in double quotes, with a range of escape sequences supported: -

    -
      -
    • -

      -\\ for a single backslash -

      -
    • -
    • -

      -\" for a quote -

      -
    • -
    • -

      -\n for newline -

      -
    • -
    • -

      -\t for tab -

      -
    • -
    • -

      -\a (alarm) -

      -
    • -
    • -

      -\b (backspace) -

      -
    • -
    • -

      -\f (form feed) -

      -
    • -
    • -

      -\r (carriage return) -

      -
    • -
    • -

      -\v (vertical tab) -

      -
    • -
    • -

      -octal escape codes, e.g. \001 -

      -
    • -
    • -

      -hexadecimal escape codes, e.g. \xf2 -

      -
    • -
    • -

      -For more information: ASCII control codes. -

      -
    • -
    -
  • -
  • -

    -Multi-line strings may be used in two syntaxes: -

    -
      -
    • -

      -Python-style: -

      -
      -
      -
      string s =
      +** +\\+ for a single backslash
      +** +\"+ for a quote
      +** +\n+ for newline
      +** +\t+ for tab
      +** +\a+ (alarm)
      +** +\b+ (backspace)
      +** +\f+ (form feed)
      +** +\r+ (carriage return)
      +** +\v+ (vertical tab)
      +** octal escape codes, e.g. +\001+
      +** hexadecimal escape codes, e.g. +\xf2+
      +** For more information: http://en.wikipedia.org/wiki/US-ASCII#ASCII_control_code_chart[ASCII control codes].
      +* Multi-line strings may be used in two syntaxes:
      +** Python-style:
      ++
      +----
      +string s =
       """
       line data 1
       line data 2
      -""";
      -
      -
    • -
    • -

      -Asciidoc-style: like Python-style but use 4 dashes instead of 3 quotes. -

      -
    • -
    • -

      -Note: Multi-line strings are somewhat incompatible with the C preprocessor: +"""; +---- ++ +** Asciidoc-style: like Python-style but use 4 dashes instead of 3 quotes. +** *Note:* Multi-line strings are somewhat incompatible with the C preprocessor: if you try to compile a Swift program using multi-line strings with the preprocessor enabled, you will likely see warnings or strange - behavior. To disable the C preprocessor, use the -p option + behavior. To disable the C preprocessor, use the +-p+ option to STC. -

      -
    • -
    -
  • -
-
-
-

9.2. Files

-

A file is a first-class entity in Swift that in many ways can be treated + +=== Files + +A file is a first-class entity in Swift that in many ways can be treated as any other variable. The main difference is that a file can be -mapped to path in a filesystem. Assigning to a mapped file variable +*mapped* to path in a filesystem. Assigning to a mapped file variable results in a file being created in the file system at the specified path. -File paths can be arbitrary Swift expressions of type string. Absolute +File paths can be arbitrary Swift expressions of type +string+. Absolute paths or relative paths are specified, with relative paths interpreted relative to the path in which turbine was run. File variables can also be initialized with data from a pre-existing -file using the input_file function. File paths are relative to the -working directory for Turbine.

-

For example, if /home/user/in.txt is a file with some data in it, -the following Swift program will copy the file to /home/user/out.txt.

-
-
-
main
+file using the +input_file+ function.  File paths are relative to the
+working directory for Turbine.
+
+For example, if +/home/user/in.txt+ is a file with some data in it,
+the following Swift program will copy the file to +/home/user/out.txt+.
+----
+main
 {
   file x = input_file("/home/user/in.txt");
-  file y <"/home/user/out.txt">; // Declare a mapped file
+  file y <"/home/user/out.txt">; // Declare a mapped file
   y = x; // Do the copy
-}
-
-

A range of functions to work with files are provided in the -files library module.

-
-
-
// Initialize an array of files from a range of files on disk with glob
+}
+----
+
+
+A range of functions to work with files are provided in the
++files+ library module.
+
+----
+// Initialize an array of files from a range of files on disk with glob
 file f[] = glob("directory/*.txt");
 
 // Read the contents of a file with read
@@ -1484,79 +421,79 @@
 file tmp = write("first line\nsecond line");
 
 // Find the name of a file with filename
-trace("Temporary filename is: " + filename(tmp));
-
-

Temporary files are created as necessary if unmapped files are -written to. For example, the file tmp in the above code snippet. -This feature is implemented by calling GNU mktemp with suffix -.turbine; thus, the directory is set with environment variable -TMPDIR which defaults to /tmp.

-

Currently Swift/T assumes that the file system is shared among -all nodes.

-
- - - -
-
Note
-
-

The syntax

-
-
-
file f<"f.txt"> = g();
-
-

is allowed but

-
-
-
file f<"f.txt">=g();
-
-

results in a parse error: the >= sequence is tokenized as -greater-than-or-equal-to.

-
-
-
-
-

9.3. Blobs

-

Blobs represent raw byte data. They are primarily used to pass +trace("Temporary filename is: " + filename(tmp)); +---- + +Temporary files are created as necessary if unmapped files are +written to. For example, the file +tmp+ in the above code snippet. +This feature is implemented by calling GNU +mktemp+ with suffix ++.turbine+; thus, the directory is set with environment variable ++TMPDIR+ which defaults to +/tmp+. + +Currently Swift/T assumes that the file system is shared among +all nodes. + +[NOTE] +====== +The syntax +---- +file f<"f.txt"> = g(); +---- +is allowed but +---- +file f<"f.txt">=g(); +---- +results in a parse error: the +>=+ sequence is tokenized as +_greater-than-or-equal-to_. +====== + +=== Blobs + +Blobs represent raw byte data. They are primarily used to pass data to and from native code libraries callable from Swift. They are -like Swift strings but may contain arbitrary data.

-

Swift provides multiple builtin functions to create blobs, convert -blobs to and from Swift types, and pass blobs to leaf functions.

-
-
-

9.4. Arrays

-

Arrays can be declared with empty square brackets:

-
-
-
int A[];
-
-

Arrays with empty square brackets have integer indices. It is +like Swift strings but may contain arbitrary data. + +Swift provides multiple builtin functions to create blobs, convert +blobs to and from Swift types, and pass blobs to leaf functions. + +=== Arrays + +Arrays can be declared with empty square brackets: + +---- +int A[]; +---- + +Arrays with empty square brackets have integer indices. It is also possible to declare integers with other index types, such as -strings:

-
-
-
string dict[string];
-
-

They are dynamically sized, expanding each time an item is inserted at -a new index. Arrays are indexed using square brackets.

-
-
-
int A[string];
+strings:
+
+----
+string dict[string];
+----
+
+They are dynamically sized, expanding each time an item is inserted at
+a new index.  Arrays are indexed using square brackets.
+----
+int A[string];
 int B[];
 B = function_returning_array();
 A["zero"] = B[0];
-A["one"] = B[1];
-
-

Each array index can only be assigned to once.

-

A given array variable must be assigned either in toto (as a whole) -or in partes (piece by piece). In this example, B is assigned in toto -and A is assigned in partes. Code that attempts to do both is in error.

-

Arrays may be used as inputs or outputs of functions.

-

Arrays are part of Swift dataflow semantics. An array is closed -when all possible insertions to it are complete.

-
-
-
(int B[]) f(int j)
+A["one"] = B[1];
+----
+
+Each array index can only be assigned to once.
+
+A given array variable must be assigned either _in toto_ (as a whole)
+or _in partes_ (piece by piece).  In this example, +B+ is assigned in toto
+and +A+ is assigned in partes.  Code that attempts to do both is in error.
+
+Arrays may be used as inputs or outputs of functions.
+
+Arrays are part of Swift dataflow semantics. An array is closed
+when all possible insertions to it are complete.
+----
+(int B[]) f(int j)
 {
   int A[];
   A = subroutine_function(1);
@@ -1566,69 +503,72 @@
 
   // OK: assigning to output variable
   B = subroutine_function(2);
-}
-
-

Array literals may be expressed using the range operator:

-
-
-
int start = 0;
+}
+
+----
+
+Array literals may be expressed using the range operator:
+----
+int start = 0;
 int stop = 10;
 int step = 2;
 // Array of length 10:
 int A[] = [start:stop];
 // Array of length 5, containing only even numbers:
-int B[] = [start:stop:step];
-
-

Array literals may also be expressed with list syntax:

-
-
-
int C[] = [4,5,6];
-
-
-
-

9.5. Nested arrays

-

Swift allows arrays of arrays: nested arrays. They can be declared and -assigned as follows:

-
-
-
// An array of arrays of files with string keys
+int B[] = [start:stop:step];
+----
+
+Array literals may also be expressed with list syntax:
+----
+int C[] = [4,5,6];
+----
+
+=== Nested arrays
+Swift allows arrays of arrays: nested arrays.  They can be declared and
+assigned as follows:
+
+----
+// An array of arrays of files with string keys
 file A[string][string];
 A["foo"]["bar"] = input_file("test.txt");
-A["foo"]["qux"] = input_file("test2.txt");
-
-

Note: there is currently a limitation in assignment of nested arrays +A["foo"]["qux"] = input_file("test2.txt"); +---- + +*Note:* there is currently a limitation in assignment of nested arrays that a given array can only be assigned at a single "index level". If -A is a 2D array, for example, then you cannot mix assignments specifying -one index (e.g. A[i] = …) with assignments specifying three indices -(e.g. A[i][j] = …).

-
-
-

9.6. Structs

-

In Swift, structs are defined with the type keyword. They define -a new type.

-
-
-
type person
++A+ is a 2D array, for example, then you cannot mix assignments specifying
+one index (e.g. +A[i] = ...+) with assignments specifying three indices
+(e.g. +A[i][j] = ...+).
+
+=== Structs
+
+In Swift, structs are defined with the +type+ keyword.  They define
+a new type.
+
+----
+type person
 {
   string name;
   int age;
   int events[];
-}
-
-

Structs are accessed with the . syntax:

-
-
-
person p;
+}
+----
+
+Structs are accessed with the +.+ syntax:
+
+----
+person p;
 p.name = "Abe";
-p.age = 90;
-
-

It is possible to have arrays of structs, with some restriction on +p.age = 90; +---- + +It is possible to have arrays of structs, with some restriction on how they can be assigned. Each struct in the array must be assigned -in toto (as a whole). For example, the following code is valid:

-
-
-
person people[], p1, p2;
+_in toto_ (as a whole).  For example, the following code is valid:
 
+----
+person people[], p1, p2;
+
 p1.name = "Thelma";
 p1.age = 31;
 
@@ -1636,46 +576,50 @@
 p2.age = 29;
 
 people[0] = p1;
-people[1] = p2;
-
-

However, attempting to assign the structs in the following way is -currently unsupported:

-
-
-
people[2].name = "Abe";  // Not supported!
-people[2].age = 90;      // Not supported!
-
-
-
-

9.7. Defining new types

-

Swift has two ways to define new types based on existing types.

-

The first is typedef, which creates a new name for the type. +people[1] = p2; +---- + +However, attempting to assign the structs in the following way is +currently unsupported: +---- +people[2].name = "Abe"; // Not supported! +people[2].age = 90; // Not supported! +---- + +=== Defining new types + +Swift has two ways to define new types based on existing types. + +The first is +typedef+, which creates a new name for the type. The new type and the existing type will be completely interchangeable, since they are simply different names for the same underlying type. -The new type name simply serves to improve readability or documentation.

-
-
-
typedef newint int;
+The new type name simply serves to improve readability or documentation.
 
+----
+typedef newint int;
+
 main {
   // We can freely convert between int and newint
   newint x = 1;
   int y = x;
   newint z = y;
-}
-
-

The second is with type, which creates a new type that is a +} +---- + +The second is with +type+, which creates a new type that is a specialization of an existing type. That is, it is a distinct type that is not interchangeable. A specialized type can be converted into the original type, but the reverse transformation is not possible. This means that you can write functions that are more strictly typechecked, for example, only accepted particular types of -file.

-

Note: This feature is immature, so you will have a higher probability -of encountering compiler bugs or limitations.

-
-
-
typedef sorted_file file;
+file.
+
+*Note:* This feature is immature, so you will have a higher probability
+of encountering compiler bugs or limitations.
+
+----
+
+typedef sorted_file file;
 app (sorted_file out) sort (file i) {
   "/usr/bin/sort" "-o" out i
 }
@@ -1687,54 +631,54 @@
 
 main {
   file unsorted = input_file("input.txt");
-  sorted_file sorted <"sorted.txt"> = sort(unsorted);
-  file u <"unique.txt"> = unique(sorted);
+  sorted_file sorted <"sorted.txt"> = sort(unsorted);
+  file u <"unique.txt"> = unique(sorted);
 
   // Can convert from sorted_file to file
   file result2 = sort(unsorted);
 
   // This would cause a type error
   // sorted_file not_sorted = unsorted;
-}
-
-
-
-

9.8. Global Constants

-

Swift supports a basic feature for defining globally visible constants. You -can use the global const statement at the top level of the program. The +} +---- + +=== Global Constants + +Swift supports a basic feature for defining globally visible constants. You +can use the +global const+ statement at the top level of the program. The syntax only supports literals of scalar types: e.g. integer literals, floating -point literals and string literals.

-
-
-
global const string hello = "Hello World";
+point literals and string literals.
+
+----
+global const string hello = "Hello World";
 global const float pi_approx = 3.142;
 global const int ONE = 1;
 
 main () {
   trace(hello, pi_approx, ONE);
-}
-
-

Note: global constants provide no performance benefit compared with -variables initialized to constant values at optimization levels O1 -or greater.

-

Note: better support is planned in future for more flexible support for -global variables and code.

-
-
-
-
-

10. Control structures

-
-

Swift provides control structures that may be placed as statements -inside a composite function.

-
-

10.1. Conditionals

-
-

10.1.1. If statement

-

If statements have the form:

-
-
-
if (<condition>)
+}
+----
+
+*Note:* global constants provide no performance benefit compared with
+variables initialized to constant values at optimization levels +O1+
+or greater.
+
+*Note:* better support is planned in future for more flexible support for
+global variables and code.
+
+== Control structures
+
+Swift provides control structures that may be placed as statements
+inside a composite function.
+
+=== Conditionals
+
+==== If statement
+
+If statements have the form:
+
+----
+if ()
 {
   statement;
   ...
@@ -1743,16 +687,16 @@
 {
   statement;
   ...
-}
-
-

As required by dataflow processing, neither branch of the conditional can -execute until the value of the condition expression is available.

-
-
-

10.1.2. Switch statement

-
-
-
int a = 20;
+}
+----
+
+As required by dataflow processing, neither branch of the conditional can
+execute until the value of the condition expression is available.
+
+==== Switch statement
+
+----
+int a = 20;
 switch (a)
 {
   case 1:
@@ -1766,48 +710,51 @@
   default:
     b = 2102 + 2420;
 }
-printf("b: %i\n", b);
-
-

Note: there is no fall-through between cases in switch statements.

-
-
-
-

10.2. Iteration

-

Iteration is performed with the foreach and for statements.

-
-

10.2.1. Foreach loop

-

The foreach loop allows for parallel iteration over an array:

-
-
-
string A[];
+printf("b: %i\n", b);
+----
+
+*Note:* there is no fall-through between cases in switch statements.
+
+=== Iteration
+
+Iteration is performed with the +foreach+ and +for+ statements.
+
+==== Foreach loop
+
+The +foreach+ loop allows for parallel iteration over an array:
+
+----
+string A[];
 foreach value, index in A
 {
   printf("A[%i] = %s\n", index, value);
-}
-
-

The index and value variables are automatically declared. The -index variable may be omitted from the syntax.

-

A special case of the foreach loop occurs when combined with the +} +---- + +The +index+ and +value+ variables are automatically declared. The ++index+ variable may be omitted from the syntax. + +A special case of the foreach loop occurs when combined with the array range operator. This is the idiomatic way to iterate over a range of integer values in Swift. The STC compiler has special -handling for this case that avoids constructing an array.

-
-
-
foreach i in [start:stop:step] {
+handling for this case that avoids constructing an array.
+
+----
+foreach i in [start:stop:step] {
     ...
-}
-
-
-
-

10.2.2. For loop

-

The for loop allows for sequential iteration. This example +} +---- + +==== For loop + +The +for+ loop allows for sequential iteration. This example implements a counter based on the return values of a function that -accepts integers:

-
-
-
int N = 100;
+accepts integers:
+
+----
+int N = 100;
 int count = 0;
-for (int i = 0; i < N; i = i+1, count = count+c)
+for (int i = 0; i < N; i = i+1, count = count+c)
 {
   int c;
   if (condition_function(i))
@@ -1818,1131 +765,612 @@
   {
     c = 0;
   }
-}
-
-

The general form is:

-
-
-
for ( <initializer> ; <condition> ; <updates> )
+}
+----
+
+The general form is:
+----
+for (  ;  ;  )
 {
   statement;
   ...
-}
-
-

The initializer is executed first, once. The initializer is a +} +---- + +The initializer is executed first, once. The initializer is a comma-separated list of statements. The body statements are then executed. Then, the assignments are performed, formatted as a comma-separated list. Each is a special assignment in which the -left-hand-side is the variable in the next iteration of the loop, -while the right-hand-side is the variable in the previous loop +left-hand-side is the variable in the _next_ iteration of the loop, +while the right-hand-side is the variable in the _previous_ loop iteration. Then, the condition is checked for loop exit. If the loop -continues, the body is executed again, etc.

-

Performance Tip: use the foreach loop instead of for if your -loop iterations are independent and can be executed in parallel.

-
-
-
-

10.3. Explicit data-dependent execution

-

In general, execution ordering in Swift/T is implicit and driven by +continues, the body is executed again, etc. + +*Performance Tip:* use the +foreach+ loop instead of +for+ if your +loop iterations are independent and can be executed in parallel. + +=== Explicit data-dependent execution + +In general, execution ordering in Swift/T is implicit and driven by data dependencies. In some cases it is useful to add explicit data dependencies, for example if you want to print a message to indicate that variable was assigned. It is possible for the programmer to -express additional execution ordering using two constructs: the wait -statement and the => chaining operator.

-

In a wait statement, a block of code is executed after -one or more variables are closed.

-
-
-
x = f();
+express additional execution ordering using two constructs: the +wait+
+statement and the +\=>+ chaining operator.
+
+In a wait statement, a block of code is executed after
+one or more variables are closed.
+----
+x = f();
 y = g();
 wait (x) {
   trace("x is closed!");
 }
 wait(x, y) {
   trace("x and y are closed!");
-}
-
-

The chaining operator chains statements together so that a -statement only executes after the previous statement’s output +} +---- + +The chaining operator chains statements together so that a +statement only executes after the previous statement's output value is closed. This is -a more concise way to express dependencies than the wait statement.

-
-
-
sleep(1) =>
-  x = f() =>
-  int y = g() =>
-  trace("DONE!");
-
-

Chaining is based on the output values -of a statement. In the simple case of a function call f() => …, +a more concise way to express dependencies than the +wait+ statement. +---- +sleep(1) => + x = f() => + int y = g() => + trace("DONE!"); +---- + +Chaining is based on the *output values* +of a statement. In the simple case of a function call +f() \=> ...+, the output values are the output values of the function. In the -case of and assignment x = f() => … or a declaration, -int y = g() => …, then the next statement is dependent on +case of and assignment +x = f() \=> ...+ or a declaration, ++int y = g() \=> ...+, then the next statement is dependent on the assigned values, or the declared values. Some functions such -as sleep have void output values so that they can be used -in this fashion.

-
-
-

10.4. Scoping blocks

-

Arbitrary scoping blocks may be used. In this example, two different -variables, both represented by b, are assigned different values.

-
-
-
{
+as +sleep+ have +void+ output values so that they can be used
+in this fashion.
+
+=== Scoping blocks
+
+Arbitrary scoping blocks may be used.  In this example, two different
+variables, both represented by +b+, are assigned different values.
+
+----
+{
   int b;
   b = 1;
 }
 {
   int b;
   b = 2;
-}
-
-
-
-
-
-

11. Operators

-
-

The following binary arithmetic operators on numbers are defined:

-

+ (plus), - (minus), * (times), / (divide), -%/ (integer divide), %% (modulus), ** (power)

-

&& (boolean and), || (boolean or), -== (equals), != (not equals), > (greater than), < (less than), ->= (greater than or equal to), <= (less than or equal to)

-

xor() is a builtin function.

-

Swift boolean operators are not short-circuited (to allow maximal -concurrency). For conditional execution, use an if statement.

-

The following unary operators are defined:

-

- (negate), ! (boolean not)

-

String concatenation is also performed with + (plus). == and -!= may also be used on strings. Operator s1/s2 is equivalent to -s1+"/"+s2.

-
-
-
-

12. Standard library

-
-

Each category of function is shown with the required import -statement, if necessary.

-

Functions that accept an input of any type are denoted anything. +} +---- + +== Operators + +The following binary arithmetic operators on numbers are defined: + ++++ (plus), +-+ (minus), +\*+ (times), +/+ (divide), ++%/+ (integer divide), +%%+ (modulus), +**+ (power) + ++&&+ (boolean and), +||+ (boolean or), ++==+ (equals), +!=+ (not equals), +>+ (greater than), +<+ (less than), ++>=+ (greater than or equal to), +<=+ (less than or equal to) + ++xor()+ is a builtin function. + +Swift boolean operators are not short-circuited (to allow maximal +concurrency). For conditional execution, use an +if+ statement. + +The following unary operators are defined: + ++-+ (negate), +!+ (boolean not) + +String concatenation is also performed with +++ (plus). +==+ and ++!=+ may also be used on strings. Operator +s1/s2+ is equivalent to ++s1+"/"+s2+. + +== Standard library + +Each category of function is shown with the required import +statement, if necessary. + +Functions that accept an input of any type are denoted +anything+. Functions that accept variable numbers of arguments are denoted with -ellipsis .

-

A function that accepts more than one type is denoted as f(int|string).

-

If a function is described below an Import: label, be sure to -import that package.

-
-

12.1. General

-
-
-xor(boolean,boolean) → boolean -
-
-

-Exclusive logical or -

-
-
-make_void() → void -
-
-

-Create a void value -

-
-
-size(A[]) → int -
-
-

-Obtain the size of array A -

-
-
-contains(A[], key) → boolean -
-
-

-Test that future A[key] exists. -This function blocks until A is closed. Consumers of A[key] may -block again until A[key] is stored. -

-
-
-
-
-

12.2. Type conversion

-
-
-fromint(int) → string -
-
-

-Convert integer to string -

-
-
-toint(string) → int -
-
-

-Convert string to integer -

-
-
-fromfloat(float) → string -
-
-

-Convert float to string -

-
-
-tofloat(string) → float -
-
-

-Convert string to float -

-
-
-itof(int) → float -
-
-

-Convert integer to float -

-
-
-
-
-

12.3. Output

-
-
-trace(anything, anything, …) -
-
-

-Report the value of any variable -

-
-
-

Import: io

-
-
-printf(string format, int|float|string|boolean…) -
-
-

-As printf() in C -

-
-
-
-
-

12.4. String functions

-

strcat(string,string): Concatenation

-

Import: string

-
-
-substring(string s, int start, int length) → string -
-
-

-Obtain substring of given string s starting at character start and of -length length -

-
-
-find(string s, string substring, int start_index, int end_index) → int -
-
-

-Find the index of the first occurence of the string substring within -the string s between the indices start_index and end_index. Here -an index of -1 passed to end_index results in end_index being -treated as the length of the string s. find returns -1 in case -there is no occurence of substring in s in the specified range. -

-
-
-string_count(string s, string substring, int start_index, int end_index) → int -
-
-

-Counts the occurences of the string substring within the string s -between the indices start_index and end_index. Here an index of --1 passed to end_index results in end_index being treated as the -length of the string s -

-
-
-is_int(string s) → boolean -
-
-

-Returns true if string s is a number, else false. -

-
-
-replace(string s, string substring, string rep_string, int start_index) → string -
-
-

+ellipsis +...+. + +A function that accepts more than one type is denoted as +f(int|string)+. + +If a function is described below an *Import:* label, be sure to ++import+ that package. + +=== General + ++xor(boolean,boolean) -> boolean+:: Exclusive logical or ++make_void() -> void+:: Create a void value ++size(A[]) -> int+:: Obtain the size of array +A+ ++contains(A[], key) -> boolean+:: Test that future +A[key]+ exists. +This function blocks until +A+ is closed. Consumers of +A[key]+ may +block again until +A[key]+ is stored. + +=== Type conversion + ++fromint(int) -> string+:: Convert integer to string ++toint(string) -> int+:: Convert string to integer ++fromfloat(float) -> string+:: Convert float to string ++tofloat(string) -> float+:: Convert string to float ++itof(int) -> float+:: Convert integer to float ++repr(*) -> string+:: Convert any type to internal + string representation (exact format not guaranteed + to be consistent, even from call to call) ++array_repr(*[]) -> string[]+:: Convert array of any type to internal + string representation (exact format not guaranteed + to be consistent, even from call to call) + +=== Output + ++trace(anything, anything, ...)+:: Report the value of any variable + +*Import:* +io+ + ++printf(string format, int|float|string|boolean...)+:: +As +printf()+ in C + +=== String functions + ++strcat(string,string)+: Concatenation + +*Import:* +string+ + ++substring(string s, int start, int length) -> string+:: +Obtain substring of given string +s+ starting at character +start+ and of +length +length+ + ++find(string s, string substring, int start_index, int end_index) -> int+:: +Find the index of the first occurence of the string +substring+ within +the string +s+ between the indices +start_index+ and +end_index+. Here +an index of +-1+ passed to +end_index+ results in +end_index+ being +treated as the length of the string +s+. +find+ returns +-1+ in case +there is no occurence of +substring+ in +s+ in the specified range. + ++string_count(string s, string substring, int start_index, int end_index) -> int+:: +Counts the occurences of the string +substring+ within the string +s+ +between the indices +start_index+ and +end_index+. Here an index of ++-1+ passed to +end_index+ results in +end_index+ being treated as the +length of the string +s+ + ++is_int(string s) -> boolean+:: +Returns true if string +s+ is a number, else false. + ++replace(string s, string substring, string rep_string, int start_index) -> string+:: Obtain the string created by replacing the first occurence of the -string substring within string s, after the index start_index, -with the string rep_string. In case there is no such occurence of -the string substring in string s, the original string s is +string +substring+ within string +s+, after the index +start_index+, +with the string +rep_string+. In case there is no such occurence of +the string +substring+ in string +s+, the original string +s+ is returned unmodified. -

-
-
-replace_all(string s, string substring, string rep_string, int start_index) → string -
-
-

+ ++replace_all(string s, string substring, string rep_string, int start_index) -> string+:: Obtain the string created by replacing all the occurences of the -string substring within string s, after the index start_index, -with the string rep_string. In case no such occurence of substring -exists in s, the original string s is returned unmodified. -

-
-
-split(string s, string delimiter) → string[] -
-
-

-Tokenize string s with given delimiter -

-
-
-trim(string s) → string -
-
-

-Remove leading and trailing whitespace from s -

-
-
-strlen(string) → int -
-
-

+string +substring+ within string +s+, after the index +start_index+, +with the string +rep_string+. In case no such occurence of +substring+ +exists in +s+, the original string +s+ is returned unmodified. + ++split(string s, string delimiter) -> string[]+:: +Tokenize string +s+ with given delimiter + ++trim(string s) -> string+:: +Remove leading and trailing whitespace from +s+ + ++strlen(string) -> int+:: Obtain the length of the given string -

-
-
-hash(string) → int -
-
-

+ ++hash(string) -> int+:: Hash the string to a 32-bit integer -

-
-
-sprintf(string format, int|float|string|boolean…) -
-
-

-As sprintf() in C -

-
-
-string_join(string A[], string separator) → string -
-
-

-Join strings in A with given separator. The separator may be the + ++sprintf(string format, int|float|string|boolean...)+:: +As +sprintf()+ in C + ++string_join(string A[], string separator) -> string+:: +Join strings in +A+ with given separator. The separator may be the empty string -

-
-
-
-
-

12.5. Math

-
-
-max|min_integer(int,int) → int -
-
-

-Obtain maximum or minimum integer, + +=== Math + ++max|min_integer(int,int) -> int+:: Obtain maximum or minimum integer, respectively -

-
-
-max|min_float(float,float) → float -
-
-

-Obtain maximum or minimum float, ++max|min_float(float,float) -> float+:: Obtain maximum or minimum float, respectively -

-
-
-pow_integer(int b,int x) -
-
-

-Obtain bx -

-
-
-pow_float(float b,float x) -
-
-

-Obtain bx -

-
-
-

Import: math

-
-
-floor(float) → int -
-
-

-Round down -

-
-
-ceil(float) → int -
-
-

-Round up -

-
-
-round(float) → int -
-
-

-Round nearest -

-
-
-log(float) → float -
-
-

-Natural logarithm -

-
-
-exp(float) → float -
-
-

-Natural exponentiation: ei -

-
-
-sqrt(float) → float -
-
-

-Square root -

-
-
-is_nan(float) → boolean -
-
-

-Check for NaN -

-
-
-abs_integer(int) → int -
-
-

-Absolute value -

-
-
-abs_float(float) → float -
-
-

-Absolute value -

-
-
-

Import: random

-
-
-random() → float -
-
-

-Obtain random number -

-
-
-randint(int start, int end) -
-
-

-Obtain random integer from start, inclusive, to end, exclusive -

-
-
-

Import: stats

-
-
-sum_integer(int[]) → int -
-
-

-Sum -

-
-
-avg(int|float[]) → float -
-
-

-Average -

-
-
-
-
-

12.6. System

-

Import: sys

-
-
-getenv(string) → string -
-
-

-Obtain an environment variable -

-
-
-
-

12.6.1. Command line

-

Consider this command line:

-
-
-
turbine -l -n 3 program.tcl -v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt
-
-

The arguments to program.tcl are just the tokens after program.tcl

-
-
-args() → string -
-
-

++pow_integer(int b,int x)+:: Obtain b^x^ ++pow_float(float b,float x)+:: Obtain b^x^ + +*Import:* +math+ + ++floor(float) -> int+:: Round down ++ceil(float) -> int+:: Round up ++round(float) -> int+:: Round nearest ++log(float) -> float+:: Natural logarithm ++exp(float) -> float+:: Natural exponentiation: e^i^ ++sqrt(float) -> float+:: Square root ++is_nan(float) -> boolean+:: Check for NaN ++abs_integer(int) -> int+:: Absolute value ++abs_float(float) -> float+:: Absolute value + +*Import:* +random+ + ++random() -> float+:: Obtain random number + ++randint(int start, int end)+:: +Obtain random integer from +start+, inclusive, to +end+, exclusive + +*Import:* stats + ++sum_integer(int[]) -> int+:: Sum ++avg(int|float[]) -> float+:: Average + +=== System + +*Import:* +sys+ + ++getenv(string) -> string+:: Obtain an environment variable + +[[argv]] +==== Command line + +Consider this command line: + + turbine -l -n 3 program.tcl -v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt + +The arguments to +program.tcl+ are just the tokens after +program.tcl+ + ++args() -> string+:: + Obtain all arguments as single string -

-

E.g., "-v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt"

-
-
-

The remaining functions are convenience functions oriented around ++ +E.g., +"-v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt"+ + +The remaining functions are convenience functions oriented around Swift conventions. Under these conventions, the example command above -has flagged arguments v, a=file.txt, exec="prog thing1 -thing2", and help. The command has unflagged arguments -file2.txt and file4.txt

-
-
-argc() -
-
-

+has _flagged_ arguments +v+, +a=file.txt+, +exec="prog thing1 +thing2"+, and +help+. The command has _unflagged_ arguments ++file2.txt+ and +file4.txt+ + ++argc()+:: Get count of unflagged arguments -

-
-
-argv(string) -
-
-

-(argument-value) + ++argv(string)+:: +_(argument-value)_ Given a string, returns the flagged argument with that key: -

-

argv("a") → file1.txt

-

In addition to regular run-time arguments, the STC compile-time -arguments feature allows argv() arguments to be provided at compile ++ ++argv("a") -> file1.txt+ ++ +In addition to regular run-time arguments, the STC _compile-time +arguments_ feature allows +argv()+ arguments to be provided at compile time. This allows a specialized, optimized version of code to be -compiled for a particular set of arguments. See the -A -name=value argument to stc. Note that if the -argument is re-specified at run-time, an error will occur.

-
-
-argp(int) -
-
-

-(argument-positional) +compiled for a particular set of arguments. See the +-A +_name_=_value_+ <> to +stc+. Note that if the +argument is re-specified at run-time, an error will occur. + ++argp(int)+:: +_(argument-positional)_ Given an integer, returns the unflagged argument at that index: -

-

argp(2) → file4.txt

-

Given 0, returns the program name,

-

argp(0) → /path/to/program.tcl

-
-
-argv_accept(string…) -
-
-

++ ++argp(2) -> file4.txt+ ++ +Given 0, returns the program name, ++ ++argp(0) -> /path/to/program.tcl+ + ++argv_accept(string...)+:: + If program is given flagged command line arguments not contained in given list, abort. -E.g., argv_accept("x") would cause program failure at run time -

-
-
-argv_contains(string) → boolean -
-
-

+E.g., +argv_accept("x")+ would cause program failure at run time + ++argv_contains(string) -> boolean+:: + Test if the command line contains the given flagged argument: -

-

argv_contains("v") → true

-
-
-
-
-

12.6.2. Debugging

-

Import: assert

-
-
-assert(boolean condition, string message) -
-
-

-If condition is false, report message and exit immediately. -

-
-
-
-
-

12.6.3. Turbine information

-
-
-adlb_servers() → int -
-
-

-Number of ADLB servers -

-
-
-turbine_workers() → int -
-
-

-Number of Turbine workers -

-
-
-
-
-
-

12.7. Files

-
-
-filename(file) → string -
-
-

-Obtain the name of a file -

-
-
-input(string) → file -
-
-

-Obtain a file. At run time, the ++ ++argv_contains("v") -> true+ + +==== Debugging + +*Import:* +assert+ + ++assert(boolean condition, string message)+:: +If condition is false, report +message+ and exit immediately. + +[[Turbine_information]] +==== Turbine information + ++adlb_servers() -> int+:: Number of ADLB servers ++turbine_workers() -> int+:: Number of Turbine workers + +=== Files + ++filename(file) -> string+:: Obtain the name of a file ++input(string) -> file+:: Obtain a +file+. At run time, the filesystem is checked for the given file name -

-
-
-input_file(string) → file -
-
-

-Alias for input() -

-
-
-input_url(string) → file -
-
-

-Obtain a file. Some ++input_file(string) -> file+:: Alias for +input()+ ++input_url(string) -> file+:: Obtain a +file+. Some automatic operations and optimizations are disabled -

-
-
-urlname(file) → string -
-
-

-Obtain the name of a file created with -input_url() -

-
-
-

Import: files

-
-
-read(file) → string -
-
-

-Read file as a string -

-
-
-write(string) → file -
-
-

-Write string to file -

-
-
-file_lines(file) → string[] -
-
-

++urlname(file) -> string+:: Obtain the name of a file created with ++input_url()+ + +*Import:* +files+ + ++read(file) -> string+:: Read file as a string ++write(string) -> file+:: Write string to file + ++file_lines(file) -> string[]+:: Reads the whole file, returning each line as a separate entry in the -output array. Comments with # are excised, leading and trailing +output array. Comments with +#+ are excised, leading and trailing whitespace is trimmed, and blank lines are omitted. -

-
-
-glob(string) → file[] -
-
-

-Perform glob operation, returning files + ++glob(string) -> file[]+:: Perform glob operation, returning files that match. Available glob symbols include: -

-
    -
  • -

    -*: any character sequence (including the zero-length sequence) -

    -
  • -
  • -

    -?: any character -

    -
  • -
  • -

    -[chars]: any of the given characters -

    -
  • -
  • -

    -\x: character x -

    -
  • -
  • -

    -{a,b,c,…} any of a, b, c, etc. -

    -
  • -
-
-
-
-
-

12.8. Blobs

-

Import: blob

-
-
-blob_size(blob) → int -
-
-

-Obtain the size of a blob in bytes. -

-
-
-blob_null() → blob -
-
-

-Obtain an empty blob of size 0. -

-
-
-blob_from_string(string) → blob -
-
-

-Convert a string into a blob. -

-
-
-string_from_blob(blob) → string -
-
-

-Convert a blob into a string. If ++ +* +*+: any character sequence (including the zero-length sequence) +* +?+: any character +* +[chars]+: any of the given characters +* +\x+: character +x+ +* +{a,b,c,...}+ any of +a+, +b+, +c+, etc. + +=== Blobs + +*Import:* +blob+ + ++blob_size(blob) -> int+:: Obtain the size of a blob in bytes. + ++blob_null() -> blob+:: Obtain an empty blob of size 0. + ++blob_from_string(string) -> blob+:: Convert a string into a blob. + ++string_from_blob(blob) -> string+:: Convert a blob into a string. If the blob is not NULL-terminated, this function appends the NULL-terminator. -

-
-
-blob_from_floats(float[]) → blob -
-
-

-Convert an array of Swift floats + ++blob_from_floats(float[]) -> blob+:: Convert an array of Swift floats (implemented as doubles) to blob containing the C-formatted array of doubles . -

-
-
-blob_from_floats(blob) → float[] -
-
-

-Convert blob containing the + ++blob_from_floats(blob) -> float[]+:: Convert blob containing the C-formatted array of doubles to an array of Swift floats (implemented as doubles). -

-
-
-blob_from_ints(int i[]) → blob -
-
-

-Convert blob containing the + ++blob_from_ints(int i[]) -> blob+:: Convert blob containing the C-formatted array of ints to an array of Swift ints (implemented as 64-bit integers). -

-
-
-blob_from_file(file) → blob -
-
-

-Reads whole file, returning it as a + ++blob_from_file(file) -> blob+:: Reads whole file, returning it as a blob. -

-
-
-
-
-

12.9. Location

-

See the section about location.

-
-
-location_from_rank(int) → location -
-
-

-Convert the rank integer to a -location variable compatible with @location. -

-
-
-random_worker() → location -
-
-

-Obtain a worker at random. -

-
-
-hostmap_list() → string[] -
-
-

-Obtain the whole hostmap. -

-
-
-hostmap_one(string) → location -
-
-

-Lookup the string as a host in the + +[[library_location]] +=== Location + +See the section about <>. + ++location_from_rank(int) -> location+:: Convert the rank integer to a ++location+ variable compatible with + at location+. + ++random_worker() -> location+:: Obtain a worker at random. + ++hostmap_list() -> string[]+:: Obtain the whole hostmap. + ++hostmap_one(string) -> location+:: Lookup the string as a host in the hostmap and return one rank running on that host. -

-
-
-hostmap_one_worker(string) → location -
-
-

-Lookup the string as a host + ++hostmap_one_worker(string) -> location+:: Lookup the string as a host in the hostmap and return one worker rank running on that host. -

-
-
-
-
-
-
-

13. Defining leaf functions

-
-

In typical Swift applications, the computationally intensive parts of + +== Defining leaf functions + +In typical Swift applications, the computationally intensive parts of the application are not written in the Swift language. Rather, the -work is done by leaf functions that are composed together with -Swift code. Leaf functions may be extension or app functions.

-

The Swift runtime, Turbine, is built on Tcl, a language which intends -to makes it easy to call C/C++/Fortran functions. The builtin +work is done by _leaf functions_ that are _composed_ together with +Swift code. Leaf functions may be extension or app functions. + +The Swift runtime, Turbine, is built on Tcl, a language which intends +to makes it easy to call C/C\+\+/Fortran functions. The builtin functions mentioned above are implemented as extension functions in -Tcl, which may wrap C/C++/Fortran functions.

-
-

13.1. Swift extension functions

-

Currently we support Tcl extension functions, where a function is +Tcl, which may wrap C/C++/Fortran functions. + +=== Swift extension functions + +Currently we support Tcl extension functions, where a function is implemented as a Tcl function. Tcl has good support for wrapping -native C/C++ functions, so this provides an indirect way to call -C/C++ functions from Swift.

-

Several components are required to implement a Swift native code function:

-
    -
  • -

    -Tcl bindings to your function. -

    -
  • -
  • -

    -The requisite files required to build a Tcl package - (e.g pkgIndex.tcl) -

    -
  • -
  • -

    -Swift declarations for the function that specify the type of the +native C/C\++ functions, so this provides an indirect way to call +C/C++ functions from Swift. + +Several components are required to implement a Swift native code function: + +- Tcl bindings to your function. +- The requisite files required to build a Tcl package + (e.g +pkgIndex.tcl+) +- Swift declarations for the function that specify the type of the function and the Tcl implementation. -

    -
  • -
-
-

13.1.1. Simple Tcl fragment example

-

In this example, the Swift program will simply use Tcl to output a -string:

-
-
-
() my_output (string s) "turbine" "0.0" [
-  "puts <<s>>"
+
+==== Simple Tcl fragment example
+
+In this example, the Swift program will simply use Tcl to output a
+string:
+
+----
+() my_output (string s) "turbine" "0.0" [
+  "puts <>"
 ];
 
 main {
   my_output("HELLO");
-}
-
-

puts is the Tcl builtin for screen output, like puts() in C.

-

The above definition has, from left to right, the output arguments +} +---- + ++puts+ is the Tcl builtin for screen output, like +puts()+ in C. + +The above definition has, from left to right, the output arguments (none), the name of the new Swift function, input arguments, the name of the Tcl package containing the file (here, none, so we use -turbine), and the minimum version of that package (here, 0.0).

-

We tell the compiler how to call our Tcl function using inline -Tcl code as a template with variable names surrounded by << >> -indicating where variables should be substituted.

-
-
-

13.1.2. Simple Tcl package example

-

In this first example we will implement a trivial Tcl extension function ++turbine+), and the minimum version of that package (here, 0.0). + +We tell the compiler how to call our Tcl function using inline +Tcl code as a template with variable names surrounded by +<< >>+ +indicating where variables should be substituted. + +==== Simple Tcl package example + +In this first example we will implement a trivial Tcl extension function that doubles an integer. Here is the Tcl code that will go in -myextension.tcl:

-
-
-
namespace eval myextension {
++myextension.tcl+:
+
+----
+namespace eval myextension {
   proc double { x } {
     return [ expr $x * 2 ]
   }
-}
-
-

Here is the Swift function definition that will go in myextension.swift:

-
-
-
@pure
+}
+----
+
+Here is the Swift function definition that will go in +myextension.swift+:
+----
+ at pure
 (int o) double (int i) "myextension" "0.0.1" [
-  "set <<o>> [ myextension::double <<i>> ]"
-];
-
-

We can also tell the Swift compiler a little about the function so -that it can better optimize your programs. For example, double has + "set <> [ myextension::double <> ]" +]; +---- + +We can also tell the Swift compiler a little about the function so +that it can better optimize your programs. For example, +double+ has no side-effects and produces the same result each time for the same -arguments (i.e. is deterministic), so we can annotate it as a @pure -function.

-

If your function has a long running time and should be dispatched to a +arguments (i.e. is deterministic), so we can annotate it as a + at pure+ +function. + +If your function has a long running time and should be dispatched to a worker process for execution, then you need to label the function as a -worker function, for example:

-
-
-
@dispatch=WORKER
+worker function, for example:
+
+----
+ at dispatch=WORKER
 (int o) process (int i) "pkg" "0.0.1" [
-  "set <<o>> [ pkg::process <<i>> ]"
-];
-
-

Tcl code is conventionally placed into packages. In this example, -myextension.tcl would be part of the package.

-

More information about building Tcl packages may be found -here. Ultimately, -you produce a pkgIndex.tcl file that contains necessary information -about the package.

-

To ensure that Swift can find your package, use

-
-
-
stc -r <package directory> ...
-
-

or set TURBINE_USER_LIB at run time.

-
    -
  • -

    -Tip: advanced users can also create standalone executables + "set <> [ pkg::process <> ]" +]; +---- + +Tcl code is conventionally placed into _packages_. In this example, ++myextension.tcl+ would be part of the package. + +More information about building Tcl packages may be found +http://www.tcl.tk/man/tcl8.5/TclCmd/pkgMkIndex.htm[here]. Ultimately, +you produce a +pkgIndex.tcl+ file that contains necessary information +about the package. + +To ensure that Swift can find your package, use +---- +stc -r ... +---- +or set +TURBINE_USER_LIB+ at run time. + +* *Tip:* advanced users can also create <> with compiled code and Tcl code for the extension directly linked in. -

    -
  • -
-
-
-

13.1.3. Swift/Tcl data type mapping

-

If you are defining Tcl functions in the way above with inline -Tcl code, Swift types are mapped to Tcl types in the following way:

-
    -
  • -

    -int/float/string/bool are converted to the standard + +==== Swift/Tcl data type mapping + +If you are defining Tcl functions in the way above with inline +Tcl code, Swift types are mapped to Tcl types in the following way: + +* +int+/+float+/+string+/+bool+ are converted to the standard Tcl representations. -

    -
  • -
  • -

    -blobs are represented as a Tcl list with first element a pointer +* blobs are represented as a Tcl list with first element a pointer to the data, the second element the length of the data, and if the blob was loaded from the ADLB data store, a third element which is the ADLB ID of the blob. -

    -
  • -
  • -

    -files are represented as a list, with the first element the +* files are represented as a list, with the first element the file path, and the second element a reference count -

    -
  • -
  • -

    -arrays are represented by Tcl dictionaries with keys and values +* arrays are represented by Tcl dictionaries with keys and values represented according to their type. -

    -
  • -
  • -

    -bags are represented by Tcl lists with elements in an arbitrary +* bags are represented by Tcl lists with elements in an arbitrary order. -

    -
  • -
  • -

    -output voids are set automatically. -

    -
  • -
-
-
-

13.1.4. Calling native libraries from Swift

-

The first step is to test that you can successfully call your +* output voids are set automatically. + +==== Calling native libraries from Swift + +The first step is to test that you can successfully call your C/C++/Fortran function from a test Tcl script. If so, you will then -be able to use the Swift→Tcl techniques to call it from Swift.

-

A popular tool to automate Tcl→C bindings is -SWIG, which will wrap your C/C++ functions and -help you produce a Tcl package suitable for use by Swift.

-

To call Fortran functions, first wrap your code with -FortWrap. Then, use SWIG to produce -Tcl bindings.

-
-
-

13.1.5. Writing custom Tcl interfaces

-

It is possible to write a Tcl wrapper function that is -directly passed references to data in Swift’s global data store. In +be able to use the Swift->Tcl techniques to call it from Swift. + +A popular tool to automate Tcl->C bindings is +http://www.swig.org[SWIG], which will wrap your C/C++ functions and +help you produce a Tcl package suitable for use by Swift. + +To call Fortran functions, first wrap your code with +http://fortwrap.sourceforge.net[FortWrap]. Then, use SWIG to produce +Tcl bindings. + +==== Writing custom Tcl interfaces + +It is possible to write a Tcl wrapper function that is +directly passed references to data in Swift's global data store. In this case your function must manually retrieve/store data from/to the global distributed data store. In this case, you do not use the STC -Tcl argument substitution syntax (<<i>>).

-

Consider this custom Swift→Tcl binding:

-
-
-
(int o) complex_function (int arr[]) "pkg" "0.0.1" "complex";
-
-

This function jumps into Tcl function complex, which must -perform its own data dependency management.

-

See the Swift/T Leaf Function Guide for more -information about this process.

-
-
-
-

13.2. App functions

-

App functions are functions that are implemented as command-line +Tcl argument substitution syntax (+<<++i++>>+). + +Consider this custom Swift->Tcl binding: +---- +(int o) complex_function (int arr[]) "pkg" "0.0.1" "complex"; +---- + +This function jumps into Tcl function +complex+, which must +perform its own data dependency management. + +See the link:leaf.html[Swift/T Leaf Function Guide] for more +information about this process. + +[[app_functions]] +=== App functions + +App functions are functions that are implemented as command-line programs. These command-line programs can be brought into a Swift program as functions with typed inputs and outputs. -An app function definition comprises:

-
    -
  • -

    -The standard components of a Swift function declaration: input and +An app function definition comprises: + +* The standard components of a Swift function declaration: input and output arguments and the function name. Note that the output - variable types are restricted to individual files. -

    -
  • -
  • -

    -The command line, which comprises an initial string which is the + variable types are restricted to individual +file+#s#. +* The command line, which comprises an initial string which is the executable to run, and then a series of arguments which are the command-line arguments to pass to the program. -

    -
  • -
-

App arguments can be:

-
    -
  • -

    -Literals such as numbers or strings. -

    -
  • -
  • -

    -File variables (passed as file paths). -

    -
  • -
  • -

    -Other variables, which are converted to string arguments. + +App arguments can be: + +* Literals such as numbers or strings. +* File variables (passed as file paths). +* Other variables, which are converted to string arguments. Arrays (including multi-dimensional arrays) are expanded to multiple arguments. -

    -
  • -
  • -

    -Arbitrary expressions surrounded by parentheses. -

    -
  • -
-

Standard input, output and error can be redirected to files via -@stdin=, @stdout=, and @stderr= expressions. If used, these should point -to a file.

-

Here is an example of an app function that joins multiple files -with the cat utility:

-
-
-
import files;
+* Arbitrary expressions surrounded by parentheses.
 
+Standard input, output and error can be redirected to files via
++ at stdin=+, + at stdout=+, and + at stderr=+ expressions.  If used, these should point
+to a +file+.
+
+Here is an example of an app function that joins multiple files
+with the +cat+ utility:
+----
+import files;
+
 app (file out) cat (file inputs[]) {
   "/bin/cat" inputs @stdout=out
 }
 
 main {
-  file joined <"joined.txt"> = cat(glob("*.txt"));
-}
-
-

Here is an example of an app function that sleeps for an arbitrary -amount of time:

-
-
-
app (void signal) sleep (int secs) {
+  file joined <"joined.txt"> = cat(glob("*.txt"));
+}
+----
+
+Here is an example of an app function that sleeps for an arbitrary
+amount of time:
+----
+
+app (void signal) sleep (int secs) {
   "/bin/sleep" secs
 }
 
@@ -2954,44 +1382,48 @@
       trace("Slept " + fromint(time));
     }
   }
-}
-
-
-
-

13.3. External scripting support

-
-

13.3.1. Calling Python

-

You can evaluate arbitrary Python code from within Swift/T. For +} +---- + +=== External scripting support + +==== Calling Python + +You can evaluate arbitrary Python code from within Swift/T. For example, you can perform processing with a Python library. Once you have that working, you can use Swift/T to coordinate -concurrent calls to that library.

-

Consider the following Swift script:

-
-
-
import io;
+concurrent calls to that library.
+
+Consider the following Swift script:
+
+----
+import io;
 import python;
 
 main {
   i = python("print(\"python works\")\nrepr(2+2)");
   printf("i: %s", i);
-}
-
-

This simply evaluates the Python code line by line. The last line must +} +---- + +This simply evaluates the Python code line by line. The last line must return a Python string to Swift, in this case, the Python string -'4'. The expected output is shown below:

-
-
-
python works
-i: 4
-
-

Swift multi-line strings may be used to enter more complex Python code -without the explicit use of \n.

-

Additionally, you can call Python libraries such as -Numpy if available on your system. The -following code adds matrices I3 + I3 using Numpy arrays.

-
-
-
import io;
++'4'+.  The expected output is shown below:
+
+----
+python works
+i: 4
+----
+
+Swift multi-line strings may be used to enter more complex Python code
+without the explicit use of +\n+.
+
+Additionally, you can call Python libraries such as
+http://www.numpy.org[Numpy] if available on your system.  The
+following code adds matrices _I_~3~ + _I_~3~ using Numpy arrays.
+
+----
+import io;
 import python;
 import string;
 
@@ -3021,48 +1453,42 @@
   matrix A2 = eye(3);
   matrix sum = add(A1, A2);
   printf("2*eye(3)=%s", sum);
-}
-
-

An Python script template is created that imports Numpy and performs +} +---- + +An Python script template is created that imports Numpy and performs some simple calculations. This code is represented in a Swift string. -The template is filled in by the Swift call to sprintf(). Then, the -code is passed to Python for evaluation. The output is:

-
-
-
2*eye(3)=array([[ 2.,  0.,  0.],
+The template is filled in by the Swift call to +sprintf()+.  Then, the
+code is passed to Python for evaluation.  The output is:
+
+----
+2*eye(3)=array([[ 2.,  0.,  0.],
                 [ 0.,  2.,  0.],
-                [ 0.,  0.,  2.]])
-
-
- - - -
-
Note
-
To use this, Turbine must be configured with Python enabled - before compiling, by setting ENABLE_PYTHON=1 - in exm-settings.sh, or by providing the --enable-python argument - to configure. This feature is implemented by linking to Python + [ 0., 0., 2.]]) +---- + +NOTE: To use this, Turbine must be configured with Python enabled + before compiling, by setting +ENABLE_PYTHON=1+ + in +exm-settings.sh+, or by providing the +--enable-python+ argument + to +configure+. This feature is implemented by linking to Python as a shared library, enabling better performance than calling the - python program (which may be done by using a normal Swift - app function). Error messages for minor coding + +python+ program (which may be done by using a normal Swift + <>). Error messages for minor coding mistakes may be badly mangled and refer to missing Python symbols- - refer to the first error in the Python stack trace.
-
-
-
-

13.3.2. Calling R

-

Consider the following Swift script:

-
-
-
import io;
+ refer to the first error in the Python stack trace.
+
+==== Calling R
+
+Consider the following Swift script:
+----
+import io;
 import string;
 import R;
 
 global const string template =
 """
-  x <- %i
-  a <- x+100
+  x <- %i
+  a <- x+100
   cat("the answer is: ", a, "\\n")
   a
 """;
@@ -3072,42 +1498,38 @@
   code = sprintf(template, 4);
   s = R(code);
   printf("the answer was: %i", s);
-}
-
-

An R language script template is placed in a +} +---- + +An http://www.r-project.org[R language] script template is placed in a Swift string. The template is filled in with the value 4 by the Swift -call to sprintf() (note the %i conversion specifier). Then, the -code is passed to R for evaluation. The output is:

-
-
-
the answer is:  104
-the answer was: 104
-
-

As coded here, both R and Swift report the value of a.

-
- - - -
-
Note
-
To use this, Turbine must be configured with R enabled - before compiling, by setting ENABLE_R=1 - in exm-settings.sh, or by providing the --enable-r argument - to configure. This feature is implemented by linking to R as a shared - library, enabling better performance than calling the R program - (which may be done by using a normal Swift app function). When installing R, be sure to include the devel +call to +sprintf()+ (note the +%i+ conversion specifier). Then, the +code is passed to R for evaluation. The output is: + +---- +the answer is: 104 +the answer was: 104 +---- + +As coded here, both R and Swift report the value of +a+. + +NOTE: To use this, Turbine must be configured with R enabled + before compiling, by setting +ENABLE_R=1+ + in +exm-settings.sh+, or by providing the +--enable-r+ argument + to +configure+. This feature is implemented by linking to R as a shared + library, enabling better performance than calling the +R+ program + (which may be done by using a normal Swift <>). When installing R, be sure to include the +devel+ package. When installing R from source, configure with - --enable-R-shlib. You may need to set the environment variable - R_HOME to the directory containing the R installation. For the APT - package, this is /usr/lib/R.
-
-
-
-

13.3.3. Calling Julia

-

Consider the following Swift script:

-
-
-
import io;
+ +--enable-R-shlib+. You may need to set the environment variable
+ +R_HOME+ to the directory containing the R installation.  For the APT
+ package, this is +/usr/lib/R+.
+
+==== Calling Julia
+
+Consider the following Swift script:
+----
+import io;
 import julia;
 import string;
 import sys;
@@ -3131,102 +1553,108 @@
   wait (s1, s2, s3) {
     printf("duration: %0.2f", clock()-start);
   }
-}
-
-

In this example, a Julia script is placed in -string f. It is parameterized three times by sprintf(). Each +} +---- + +In this example, a http://julialang.org[Julia] script is placed in +string +f+. It is parameterized three times by +sprintf()+. Each Julia invocation runs concurrently (if enough processes are provided -to Swift/T).

-
- - - -
-
Note
-
To use this, Turbine must be configured with Julia enabled - before compiling, by providing the --enable-julia argument - to configure. This feature is implemented by linking to Julia +to Swift/T). + +NOTE: To use this, Turbine must be configured with Julia enabled + before compiling, by providing the +--enable-julia+ argument + to +configure+. This feature is implemented by linking to Julia as a shared library, enabling better performance than calling the - julia program (which may be done by using a normal Swift - app function).
-
-
-
-
-
-
-

14. Annotations

-
-

Swift/T supports many annotations to influence the behavior of the -run.

-
-

14.1. Priority

-

Leaf tasks resulting from Swift dataflow may be prioritized by using -the @priority annotation:

-
-
-
foreach i in [0:n-1] {
-  @priority=i f(i);
-}
-
-

In this case, f() will operate on higher values of i first. -Priority is best-effort; it is local to the ADLB server.

-

This annotation is applied to the leaf task call.

-
-
-

14.2. Location

-

Leaf tasks resulting from Swift dataflow may be assigned to a given -processor by using the @location annotation:

-
-
-
foreach i in [0:n-1] {
+ +julia+ program (which may be done by using a normal Swift
+ <>).
+
+[[annotations]]
+== Annotations
+
+Swift/T supports many annotations to influence the behavior of the
+run.
+
+=== Priority
+
+Leaf tasks resulting from Swift dataflow may be prioritized by using
+the + at prio+ annotation:
+
+----
+foreach i in [0:n-1] {
+  @prio=i f(i);
+}
+----
+
+In this case, +f()+ will operate on higher values of +i+ first.
+Priority is best-effort; it is local to the ADLB server.  The values
+of +i+ may be any Swift integer. 
+
+This annotation is applied to the leaf task call.
+
+[[location]]
+=== Location
+
+Leaf tasks resulting from Swift dataflow may be assigned to a given
+processor by using the + at location+ annotation:
+
+----
+foreach i in [0:n-1] {
   location L = location_from_rank(i);
   @location=L f(i);
-}
-
-

In this case, each f(i) will execute on a different worker.

-

This annotation is applied to the leaf task call.

-
-

14.2.1. Hostmap

-

At startup, by default, Turbine obtains all hostnames used in the run +} +---- + +In this case, each +f(i)+ will execute on a different worker. + +This annotation is applied to the leaf task call. + +==== Hostmap + +At startup, by default, Turbine obtains all hostnames used in the run and builds up a data structure called the hostmap to map hostnames to ranks. You may combine the location features with the hostmap features to send work to assigned hostnames. See the -Location library for usage. The hostmap may be -debugged or disabled.

-
-
-
-

14.3. Dispatch

-

This simply dispatches tasks to the given process type: WORKER or -SERVER. By default, work executes on a SERVER.

-
-
-
@dispatch=WORKER
+<> for usage.  The hostmap may be
+<> or <>.
+
+=== Dispatch
+
+This simply dispatches tasks to the given process type: +WORKER+ or
++SERVER+. By default, work executes on a +SERVER+.
+
+----
+ at dispatch=WORKER
 (int o) process (int i) "pkg" "0.0.1" [
-  "set <<o>> [ pkg::process <<i>> ]"
-];
-
-

Swift/T builtin functions (strcat(), arithmetic, etc.) are typically + "set <> [ pkg::process <> ]" +]; +---- + +Swift/T builtin functions (+strcat()+, arithmetic, etc.) are typically implemented in this way as tasks that execute on the server. User work should be performed on workers to keep servers free to process -dataflow.

-

This annotation is applied to the leaf task definition.

-
-
-
-
-

15. Optimizations

-
-

STC performs a range of compiler optimizations that can significantly +dataflow. + +This annotation is applied to the leaf task definition. + +//// + +=== Work types + +Tim? + +//// + +[[Optimizations]] +== Optimizations +STC performs a range of compiler optimizations that can significantly speed up most Swift programs. The optimization level can be controlled -by the -O command line option. The default optimization -level -O2, or the increased optimization level -O3 are usually -the best choices. Some applications benefit markedly from -O3, -while others do not, and compile times can increase slightly.

-
-
-
# No optimizations at all (not recommended)
+by the +-O+ command line option.  The default optimization
+level +-O2+, or the increased optimization level +-O3+ are usually
+the best choices.  Some applications benefit markedly from +-O3+,
+while others do not, and compile times can increase slightly.
+
+----
+# No optimizations at all (not recommended)
 stc -O0 example.swift example.tcl
 
 # Basic optimizations (not recommended)
@@ -3238,366 +1666,200 @@
 stc -O2 example.swift example.tcl
 
 # All optimizations (also recommended)
-stc -O3 example.swift example.tcl
-
-

Individual optimizations can be toggled on using -T <opt name> -or off with -t <opt name>, but this typically is only useful for +stc -O3 example.swift example.tcl +---- + +Individual optimizations can be toggled on using +-T + +or off with +-t +, but this typically is only useful for debugging. You can find an up-to-date list of optimizations in -the stc command-line help:

-
-
-
stc -h
-
-
-
-
-

16. Running in Turbine

-
-

The following describes how to run Turbine programs.

-
-

16.1. Architecture

-

Turbine runs as an MPI program consisting of many processes. Turbine +the stc command-line help: + +---- +stc -h +---- + +[[Turbine]] +== Running in Turbine + +The following describes how to run Turbine programs. + +=== Architecture + +Turbine runs as an MPI program consisting of many processes. Turbine programs are ADLB programs. Thus, they produce and execute discrete -tasks that are distributed and load balanced at run time.

-

Each process runs in a mode: worker, or server.

-
-
-Workers -
-
-

-Evaluate the Swift logic. Produce tasks. Execute tasks. -

-
-
-Servers -
-
-

-Distributes tasks. Manages data. -

-
-
-

Typical Swift programs perform compute-intensive work in leaf +tasks that are distributed and load balanced at run time. + +Each process runs in a _mode_: _worker_, or _server_. + +Workers:: Evaluate the Swift logic. Produce tasks. Execute tasks. +Servers:: Distributes tasks. Manages data. + +Typical Swift programs perform compute-intensive work in leaf functions that execute on workers. -Execution of the Swift logic is split and distributed among workers.

-

Servers distribute tasks in a scalable, load balanced manner. They -also store Swift data (integers, strings, etc.).

-
-
-

16.2. Concurrency

-

The available concurrency and efficiency in your Swift script is -limited by the following factors:

-
    -
  • -

    -The available concurrency in the Swift logic. Sequential - dependencies will be evaluated sequentially. foreach loops and +Execution of the Swift logic is split and distributed among workers. + +Servers distribute tasks in a scalable, load balanced manner. They +also store Swift data (integers, strings, etc.). + +=== Concurrency + +The available concurrency and efficiency in your Swift script is +limited by the following factors: + +* The available concurrency in the Swift logic. Sequential + dependencies will be evaluated sequentially. +foreach+ loops and branching function calls may be evaluated concurrently -

    -
  • -
  • -

    -The number of workers available to process leaf functions +* The number of workers available to process leaf functions concurrently -

    -
  • -
  • -

    -The number of servers available to control the Turbine run. +* The number of servers available to control the Turbine run. Adding more servers can improve performance for applications with small tasks or complex data dependencies but ties up processes -

    -
  • -
-
-
-

16.3. Invocation

-

The form of a Turbine invocation for STC-generated -program.tcl is:

-
-
-
turbine <turbine arguments> <program.tcl> <program arguments>
-
-

The program arguments are available to Swift ([argv]).

-

Turbine accepts the following arguments:

-
-
--f <file> -
-
-

-Provide a machine file to mpiexec -

-
-
--h -
-
-

-Print a help message -

-
-
--l -
-
-

-Enable mpiexec -l ranked output formatting -

-
-
--n <procs> -
-
-

-The total number of Turbine MPI processes -

-
-
--v -
-
-

-Report the Turbine version number -

-
-
--V -
-
-

-Make the Turbine launch script verbose -

-
-
--x -
-
-

-Use turbine_sh launcher with compiled-in libraries instead of tclsh + +=== Invocation + +The form of a Turbine invocation for STC-generated ++program.tcl+ is: + +---- +turbine +---- + +The program arguments are available to Swift (<>). + +Turbine accepts the following arguments: + ++-f +:: Provide a machine file to +mpiexec+ ++-h+:: Print a help message ++-l+:: Enable +mpiexec -l+ ranked output formatting ++-n +:: The total number of Turbine MPI processes ++-v+:: Report the Turbine version number ++-V+:: Make the Turbine launch script verbose ++-x+:: Use turbine_sh launcher with compiled-in libraries instead of tclsh (reduces number of files that must be read from file system) -

-
-
--X -
-
-

-In place of of program.tcl, run standalone Turbine executable - (e.g. created by mkstatic.tcl) -

-
-
-

The user controls the Turbine run time configuration through -environment variables:

-
-
-ADLB_SERVERS -
-
-

-Number of ADLB servers -

-
-
-

The remaining processes are workers. These values are available to -Swift (Turbine information).

-
-
-TURBINE_LOG=0 -
-
-

-Disable logging. TURBINE_LOG=1 or unset enables ++-X+:: In place of of program.tcl, run standalone Turbine executable + (e.g. created by <>) + +The user controls the Turbine run time configuration through +environment variables: + ++ADLB_SERVERS+:: Number of ADLB servers + +The remaining processes are workers. These values are available to +Swift (<>). + ++TURBINE_LOG=0+:: Disable logging. +TURBINE_LOG=1+ or unset enables logging, assuming logging was not disabled at configure time. Logging goes to tandard output by default. -

-
-
-TURBINE_LOG_FILE=<file> -
-
-

-Set log file location. Defaults to + ++TURBINE_LOG_FILE=+:: Set log file location. Defaults to standard output. -

-
-
-TURBINE_LOG_RANKS=1 -
-
-

-Using turbine -l or equivalent prepend the + ++TURBINE_LOG_RANKS=1+:: Using +turbine -l+ or equivalent prepend the MPI rank number to each output line. This works with typical MPICH or OpenMPI systems, however, this is not available on some systems, so set this to emulate the rank output on such systems. -

-
-
-ADLB_PRINT_TIME=1 -
-
-

-Enable a short report of total elapsed time (via -MPI_Wtime()) -

-
-
-ADLB_PERF_COUNTERS=1 -
-
-

+ ++ADLB_PRINT_TIME=1+:: Enable a short report of total elapsed time (via ++MPI_Wtime()+) + ++ADLB_PERF_COUNTERS=1+:: Enable performance counters (printed at end of execution). The -Swift/T internals guide has information +link:internals.html[Swift/T internals guide] has information about interpreting the output. -

-
-
-ADLB_EXHAUST_TIME -
-
-

+ ++ADLB_EXHAUST_TIME+:: Time in seconds taken by ADLB task servers to shut down. May include a decimal point. Default 0.1 . Setting this lower will reduce delay in detection exhaustion. Setting this higher will reduce overhead due to failed exhaust checks. The default setting is almost always adequate. -

-
-
-ADLB_REPORT_LEAKS=1 -
-
-

+ ++ADLB_REPORT_LEAKS=1+:: Enable reporting of any unfreed data in ADLB data store at end of execution. -

-
-
-ADLB_TRACE=true -
-
-ADLB_DEBUG=true -
-
-

+ ++ADLB_TRACE=true+:: ++ADLB_DEBUG=true+:: To print DEBUG/TRACE level information for ADLB (if ADLB was compiled with it enabled) -

-
-
-TURBINE_LAUNCH_OPTIONS -
-
-

-Provide other arguments to mpiexec, such as a machine file, etc. -

-
-
-TURBINE_SRAND -
-
-

+ ++TURBINE_LAUNCH_OPTIONS+:: +Provide other arguments to +mpiexec+, such as a machine file, etc. + ++TURBINE_SRAND+:: If unset or empty, the random number generator seed will be set to the process rank for each process, giving reproducible results. If set to -an integer seed, the random number generator seed for each process -will be set to seed + rank. -

-

For non-reproducible random results, use the following shell commands:

-
-
-
export TURBINE_SRAND=$( date +%s )
-turbine ...
-
-

The seed is recorded in the log.

-
-
-ADLB_DEBUG_RANKS=1 -
-
-

-Enable a report showing the rank and hostname +an integer +seed+, the random number generator seed for each process +will be set to +seed+ + +rank+. ++ +For non-reproducible random results, use the following shell commands: ++ +---- +export TURBINE_SRAND=$( date +%s ) +turbine ... +---- ++ +The seed is recorded in the log. + ++ADLB_DEBUG_RANKS=1+:: Enable a report showing the rank and hostname of each process. This allows you to determine whether your process layout on a given machine is as intended. -

-
-
-

-ADLB_DEBUG_HOSTMAP=1:: Enable a report showing the hostmap, which -maps hostnames to ranks for use with the location functionality.

-

-ADLB_DISABLE_HOSTMAP=1:: Prevent the hostmap from being constructed -(avoiding some communication overhead).

-
-
-VALGRIND -
-
-

-Enable valgrind debugging. Cf. valgrind. -

-
-
-GDB_RANK -
-
-

-Enable GDB debugging. Cf. GDB. -

-
-
-
-
-

16.4. Build configuration

-

The following describes how to turn Swift/T programs in Turbine -on more complex systems.

-
-

16.4.1. Build troubleshooting

-

If exm-setup.zsh does not succeed, you may need to change how it -tries to configure and compile Swift/T.

-

Troubleshooting a build problem can require a few steps. The first -step is to determine why the build failed. exm-setup.zsh will usually + +anchor:env_hostmap_debug[] + ++ADLB_DEBUG_HOSTMAP=1+:: Enable a report showing the hostmap, which +maps hostnames to ranks for use with the location functionality. + +anchor:env_hostmap_disable[] + ++ADLB_DISABLE_HOSTMAP=1+:: Prevent the hostmap from being constructed +(avoiding some communication overhead). + ++VALGRIND+:: Enable valgrind debugging. Cf. <>. + ++GDB_RANK+:: Enable GDB debugging. Cf. <>. + +[[Build_configuration]] +=== Build configuration + +The following describes how to run Swift/T programs in Turbine +on more complex systems. + +==== Build troubleshooting + +If +exm-setup.zsh+ does not succeed, you may need to change how it +tries to configure and compile Swift/T. + +Troubleshooting a build problem can require a few steps. The first +step is to determine why the build failed. +exm-setup.zsh+ will usually report the step at which configuration failed. For example, if it was unable to locate a valid Tcl install, it will report this. Then you can try -these steps to resolve the problem:

-
    -
  1. -

    -If your system is covered by the Sites Guide, +these steps to resolve the problem: + +1. If your system is covered by the link:turbine-sites.html[Sites Guide], check to see if the problem and solution are described there. -

    -
  2. -
  3. -

    -Inspect exm-settings.sh settings related to the reported problem. +2. Inspect +exm-settings.sh+ settings related to the reported problem. For example, if locating a Tcl install failed, setting - the TCL_INSTALL and TCL_VERSION variables to the correct location + the +TCL_INSTALL+ and +TCL_VERSION+ variables to the correct location and version may help. -

    -
  4. -
  5. -

    -If the options in exm-settings.sh do not give sufficient control to +3. If the options in +exm-settings.sh+ do not give sufficient control to fix the problem, you may need to manually configure some components of Swift/T, as described in the next section. -

    -
  6. -
-
-
-

16.4.2. Manual configuration

-

exm-setup.zsh and exm-settings.sh provide a convenient way to install + +[[Manual_build_configuration]] +==== Manual configuration ++exm-setup.zsh+ and +exm-settings.sh+ provide a convenient way to install Swift/T. However, this method does not allow full control over the configuration. Swift/T is built with standard Ant (Java) and Autotools/Makefile (C,Tcl) techniques. You can more directly control -the configuration when building through the arguments to ant or -configure.

-

To perform the installation using configure/make, simply untar the -distribution package and do:

-
-
-
cd c-utils
+the configuration when building through the arguments to +ant+ or
++configure+.
+
+To perform the installation using +configure+/+make+, simply untar the
+distribution package and do:
+
+----
+cd c-utils
 ./configure ...
 make install
 
@@ -3610,339 +1872,215 @@
 make install
 
 cd ../stc
-ant install -Ddist.dir=... -Dturbine.home=...
-
-
    -
  • -

    -You may use ./configure --help and the - Sites Guide for further options. -

    -
  • -
-
-
-

16.4.3. Non-standard MPI locations

-

Sometimes simply specifying the MPI directory is not enough to -configure Swift/T.

-

You can modify these settings in exm-settings.sh to more precisely -define locations of MPI resources:

-
-
-
EXM_CUSTOM_MPI=1
+ant install -Ddist.dir=... -Dturbine.home=...
+----
+
+* You may use +./configure --help+ and the
+  link:turbine-sites.html[Sites Guide] for further options.
+
+==== Non-standard MPI locations
+Sometimes simply specifying the MPI directory is not enough to
+configure Swift/T.
+
+You can modify these settings in +exm-settings.sh+ to more precisely
+define locations of MPI resources:
+
+----
+EXM_CUSTOM_MPI=1
 MPI_INCLUDE=/path/to/mpi.h/include
 MPI_LIB_DIR=/path/to/mpi_lib/lib
-MPI_LIB_NAME=funny.mpi.a
-
-

If you are following the manual build process, configure Turbine with:

-
-
-
 --enable-custom --with-mpi-include=/path/to/mpi.h/include
+MPI_LIB_NAME=funny.mpi.a
+----
+
+If you are following the manual build process, configure Turbine with:
+----
+ --enable-custom --with-mpi-include=/path/to/mpi.h/include
                  --with-mpi-lib-dir=/path/to/mpi_lib/lib
-                 --with-mpi-lib-name=funny.mpi.a
-
-
-
-
-

16.5. Performance enhancements

-
    -
  1. -

    -Disable logging/debugging via environment -

    -
  2. -
  3. -

    -Disable logging/debugging at configure/compile time -

    -
      -
    • -

      -Configure c-utils with --disable-log -

      -
    • -
    -
  4. -
  5. -

    -Specify EXM_OPT_BUILD=1 in exm-settings.sh or configure everything - with --enable-fast. This disables assertions and other checks -

    -
  6. -
  7. -

    -When making performance measurements, always subtract 0.1 seconds - (or the value of ADLB_EXHAUST_TIME) from the Turbine run time + --with-mpi-lib-name=funny.mpi.a +---- + + +=== Performance enhancements + +1. Disable logging/debugging via environment +2. Disable logging/debugging at configure/compile time ++ +** Configure c-utils with +--disable-log+ ++ +3. Specify +EXM_OPT_BUILD=1+ in +exm-settings.sh+ or configure everything + with +--enable-fast+. This disables assertions and other checks +4. When making performance measurements, always subtract 0.1 seconds + (or the value of +ADLB_EXHAUST_TIME+) from the Turbine run time due to the ADLB shutdown protocol, which does not start until the system is idle for that amount of time. -

    -
  8. -
  9. -

    -Reduce the number of program files that must be read off the +5. Reduce the number of program files that must be read off the filesystem. This is particularly useful for parallel file systems and large scale applications. In increasing order of effectiveness, you can: -

    -
      -
    • -

      -use the turbine_sh launcher in place of tclsh in submit script, - or by specifying the -x argument to turbine -

      -
    • -
    • -

      -Use mkstatic.tcl to create a standalone executable with +** use the turbine_sh launcher in place of tclsh in submit script, + or by specifying the +-x+ argument to +turbine+ +** Use <> to create a standalone executable with the Tcl main script and Tcl library code compiled in, and compiled code statically linked. -

      -
    • -
    -
  10. -
-
-
-

16.6. Building standalone executables with mkstatic.tcl

-

It is possible to build a fully self-contained executable, including + +[[mkstatic]] +=== Building standalone executables with mkstatic.tcl +It is possible to build a fully self-contained executable, including all Tcl scripts and compiled code, provided that all dependencies support static linking. If not, it is also possible to build an executable with a subset of Tcl scripts and code linked in, providing some performance -benefits.

-

The provided mkstatic.tcl utility can produce a C source +benefits. + +The provided +mkstatic.tcl+ utility can produce a C source file with Tcl scripts bundled in, which can then be compiled and linked with a C compiler. This is a multi-step process that can be automated -as part of your build process.

-
- - - -
-
Note
-
Ensure that static versions of the c-utils, lb, and turbine libraries - were built, typically with a .a suffix, e.g. libadlb.a. These - are created by default, unless you specified DISABLE_STATIC=0 or - --disable-static. To build a fully standalone +as part of your build process. + +NOTE: Ensure that static versions of the +c-utils+, +lb+, and +turbine+ libraries + were built, typically with a +.a+ suffix, e.g. +libadlb.a+. These + are created by default, unless you specified +DISABLE_STATIC=0+ or + +--disable-static+. To build a fully standalone executable, you will also need to build a static version of Tcl - (with the --disable-shared configure option), and static versions + (with the +--disable-shared+ configure option), and static versions of any other libraries your own code needs to link with, such - as your MPI distribution or application code.
-
-
    -
  1. -

    -Compile your Swift script -

    -
    -
    -
    stc my.swift
    -
    -

    producing the Turbine Tcl script my.tcl.

    -
  2. -
  3. -

    -Create a manifest file, e.g. my.manifest. This file describes the + as your MPI distribution or application code. + +1. Compile your Swift script ++ +---- +stc my.swift +---- ++ +producing the Turbine Tcl script +my.tcl+. + +2. Create a manifest file, e.g. +my.manifest+. This file describes the resources to be bundled, including the STC-generated code and any user libraries. -

    -

    To do this, make a copy of scripts/mkstatic/example.manifest from ++ +To do this, make a copy of +scripts/mkstatic/example.manifest+ from the Turbine installation directory. This file contains examples and descriptions of all the the possible settings. Note that an empty -manifest file corresponds to the turbine_sh utility, which is a -replacement for tclsh with required Turbine libraries statically +manifest file corresponds to the +turbine_sh+ utility, which is a +replacement for +tclsh+ with required Turbine libraries statically linked in. For a simple Swift program with no user Tcl libraries, -you only need to set main_script = my.tcl.

    -
  4. -
  5. -

    -Invoke mkstatic.tcl (found under scripts/mkstatic/mkstatic.tcl in +you only need to set +main_script = my.tcl+. + +3. Invoke +mkstatic.tcl+ (found under +scripts/mkstatic/mkstatic.tcl+ in the Turbine installation) to translate your Tcl script to a C main - program (e.g., my_main.c) with Tcl source code included. + program (e.g., +my_main.c+) with Tcl source code included. The minimal invocation is -

    -
    -
    -
    mkstatic.tcl my.manifest -c my_main.c
    -
    -

    You will likely wish to include Tcl system libraries with ---include-sys-lib /home/example/tcl-install/lib --tcl-version 8.6. ++ +---- +mkstatic.tcl my.manifest -c my_main.c +---- ++ +You will likely wish to include Tcl system libraries with ++--include-sys-lib /home/example/tcl-install/lib --tcl-version 8.6+. The Tcl system library directory can be identified by the fact that -it contains the file init.tcl. This directory must be specified -with a special flag so that mkstatic.tcl can correctly replace -the regular Tcl initialization process.

    -

    You can include additional libraries and packages with ---include-lib /home/example/tcl-lib/. Any .tcl or .tm source files +it contains the file +init.tcl+. This directory must be specified +with a special flag so that +mkstatic.tcl+ can correctly replace +the regular Tcl initialization process. ++ +You can include additional libraries and packages with ++--include-lib /home/example/tcl-lib/+. Any +.tcl+ or +.tm+ source files in the directory will be included. Source-only packages can generally be completely linked into the executable, but if a package -loads shared libraries, only the pkgIndex.tcl file will be linked +loads shared libraries, only the +pkgIndex.tcl+ file will be linked into the executable. A package with compiled code can be converted to support static linking by specifying a package init function, plus -static library or object files in the manifest file.

    -
  6. -
  7. -

    -Link together the compiled C main program with user libraries and +static library or object files in the manifest file. ++ +4. Link together the compiled C main program with user libraries and Swift/T libraries to produce a final executable. The details of the process vary depending on the compiler and system: we assume GCC. You will need to provide the correct flags to link in all libraries required by Swift/T or your own user code. -

    -
      -
    • -

      -User code: you must identify the libraries used by your application +** *User code:* you must identify the libraries used by your application and ensure link flags are provided. If linking static libraries, ensure that any indirect dependencies of these libraries are also linked. -

      -
    • -
    • -

      -Swift/T system: The Turbine distribution includes a helper script, - turbine-build-config.sh, that can be sourced to obtain linker flags +** *Swift/T system:* The Turbine distribution includes a helper script, + +turbine-build-config.sh+, that can be sourced to obtain linker flags for Swift/T dependencies. -

      -
    • -
    • -

      -Link order: In the case of static linking, if libA depends on libB, - then the -lA flag must precede -lB on the command line. To +** *Link order:* In the case of static linking, if *libA* depends on *libB*, + then the +-lA+ flag must precede +-lB+ on the command line. To actually do the linking, there are two further cases to consider: -

      -
        -
      • -

        -If building a fully static executable, you can - provide the -static flag, plus all object files, plus -L - and -l flags for all required library directories and libraries. -

        -
        -
        -
        gcc -static script_main.c file1.o file2.o -L/path/to/lib/dir -lsomething ...
        -
        -
      • -
      • -

        -If you are building an executable that depends on one or more shared - libraries, you will need to provide the -dynamic flag, and then +*** If building a fully static executable, you can + provide the +-static+ flag, plus all object files, plus +-L+ + and +-l+ flags for all required library directories and libraries. ++ +---- +gcc -static script_main.c file1.o file2.o -L/path/to/lib/dir -lsomething ... +---- ++ +*** If you are building an executable that depends on one or more shared + libraries, you will need to provide the +-dynamic+ flag, and then ensure that static libraries are linked statically. If a shared - version of a library is available, gcc will use that in preference + version of a library is available, +gcc+ will use that in preference to a static version. You can override this behaviour by specifying - -Wl,-Bstatic on the command line before the flags for the libraries - you wish to statically link, then -Wl,-Bdynamic to reset to + +-Wl,-Bstatic+ on the command line before the flags for the libraries + you wish to statically link, then +-Wl,-Bdynamic+ to reset to dynamic linking for any libraries after those. -

        -
      • -
      -
    • -
    -
  8. -
-

We have described the most commonly-used options. A full list of options -and descriptions can be obtained by invoking mkstatic.tcl -h. -Additional options include:

-
-
---main-script -
-
-

-Specify Tcl main script (overrides manifest file) -

-
-
--r -
-
-

-Specify non-standard variable prefix for C code -

-
-
--v -
-
-

-Print verbose messages -

-
-
---deps -
-
-

-Generate Makefile include for generating C file -

-
-
---ignore-no-manifest -
-
-

-Pretend empty manifest present -

-
-
-
-
-

16.7. Debugging Swift/T runs

-

Applying the debugger allows you to debug native code linked to Swift/T + +We have described the most commonly-used options. A full list of options +and descriptions can be obtained by invoking +mkstatic.tcl -h+. +Additional options include: + ++--main-script+:: Specify Tcl main script (overrides manifest file) ++-r+:: Specify non-standard variable prefix for C code ++-v+:: Print verbose messages ++--deps+:: Generate Makefile include for generating C file ++--ignore-no-manifest+:: Pretend empty manifest present + +[[debugging]] +=== Debugging Swift/T runs + +Applying the debugger allows you to debug native code linked to Swift/T from a normal debugger. This will allow you to step through your code -(and the Swift/T run time libraries).

-
    -
  • -

    -When using Swift/T dynamically with Tcl packages (the default), you - need to attach to the tclsh process. This process loads your +(and the Swift/T run time libraries). + +* When using Swift/T dynamically with Tcl packages (the default), you + need to attach to the +tclsh+ process. This process loads your native code and calls into it. -

    -
  • -
  • -

    -When using mkstatic, you generate a complete executable. You can +* When using +mkstatic+, you generate a complete executable. You can debug this in the normal method for debugging MPI programs. -

    -
  • -
-
-

16.7.1. Valgrind

-

The Swift/T launcher scripts support valgrind. -Simply set the environment variable VALGRIND to the valgrind command + +[[valgrind]] +==== Valgrind + +The Swift/T launcher scripts support http://valgrind.org[valgrind]. +Simply set the environment variable +VALGRIND+ to the valgrind command you wish to use. A suppressions file is distributed with Turbine to ignore known issues. (Swift/T is valgrind-clean but there are some -issues in Tcl.)

-
-
-
export VALGRIND="valgrind --suppressions=$HOME/turbine/turbine.supp"
-turbine program.tcl
-
-
-
-

16.7.2. GDB

-

The Turbine library provides a convenient attachment mechanism +issues in Tcl.) + +---- +export VALGRIND="valgrind --suppressions=$HOME/turbine/turbine.supp" +turbine program.tcl +---- + +[[gdb]] +==== GDB + +The Turbine library provides a convenient attachment mechanism compatible with debuggers like GDB, Eclipse, etc. You attach to a -Turbine execution by using the GDB_RANK variable:

-
-
-
$ export GDB_RANK=0
+Turbine execution by using the +GDB_RANK+ variable:
+
+----
+$ export GDB_RANK=0
 $ turbine program.tcl
 Waiting for gdb: rank: 0 pid: 23274
-...
-
-

Rank 0, running in process 23274, has blocked (in a loop) and is +... +---- + +Rank 0, running in process +23274+, has blocked (in a loop) and is waiting for the debugger to attach. When you attach, set the variable -t=1 to break out of the loop. Then you can debug normally.

-
-
-
-
-
-

- - - ++t=1+ to break out of the loop. Then you can debug normally. + +//// +Local Variables: +mode: doc +eval: (auto-fill-mode 1) +End: +//// From wozniak at ci.uchicago.edu Fri Aug 22 15:04:29 2014 From: wozniak at ci.uchicago.edu (wozniak at ci.uchicago.edu) Date: Fri, 22 Aug 2014 20:04:29 -0000 Subject: [Swift-commit] r8228 - www/Swift-T Message-ID: <20140822201700.A94879D850@svn.ci.uchicago.edu> Author: wozniak Date: 2014-08-22 15:17:00 -0500 (Fri, 22 Aug 2014) New Revision: 8228 Modified: www/Swift-T/guide.html Log: Fix @prio 2 Modified: www/Swift-T/guide.html =================================================================== --- www/Swift-T/guide.html 2014-08-22 20:15:08 UTC (rev 8227) +++ www/Swift-T/guide.html 2014-08-22 20:17:00 UTC (rev 8228) @@ -1,415 +1,1276 @@ + + + + + +Swift/T Guide + + + + + +
+
+
+

The Swift/Turbine Compiler (STC) allows you to write Swift programs +and run them using Turbine.

+
+
+
+

1. Support

+
+

An overview of Swift/T may be found at the ExM project site:

+ +

The Swift/T user discussion mailing list is found here:

+ +
+
+
+

2. Installation

+
+

Writing and running Swift/Turbine programs requires multiple packages. +This section provides generic instructions for installing Swift/T +on a range of systems. We first cover locating and/or installing +prerequisite software packages, then we cover building Swift/T +from a source package.

+

The Turbine Sites Guide +is a accompanying resource for configuration settings and preinstalled software +for specific systems.

+
+

2.1. Installation of Prerequisites

+
    +
  1. +

    +Install or locate MPI implementation (MPICH, OpenMPI, etc.) +

    +
      +
    • +

      +On compute clusters, an MPI will almost certainly be pre-installed +

      +
    • +
    • +

      +Many operating systems provide packages with MPI implementations + that are usable, but often outdated. + E.g. the mpich2 package on Debian/Ubuntu. +

      +
    • +
    • +

      +See MPICH Guides for information on installing the + latest version of MPICH. +

      +
    • +
    • +

      +Other MPI implementations are supported as well. +

      +

      Swift/T attempts to use MPI 3.0 functionality by default. If you +are using an MPI implementation that does not support the MPI 3.0 standard, +you must set MPI_VERSION=2 (if using the exm-setup.zsh build process), +or provide the --enable-mpi-2 configure option (if using +the manual build process).

      +
    • +
    +
  2. +
  3. +

    +Install or locate Tcl 8.6. +

    +
      +
    • +

      +Tcl is available through the package manager on many systems. + You may need to install an additional Tcl development package + in addition to the standard tcl package, + e.g. tcl8.6 plus tcl8.6-dev on Debian/Ubuntu systems. +

      +
    • +
    • +

      +Source distributions are available at the Tcl web site +

      +
    • +
    +
  4. +
  5. +

    +Install or locate SWIG +

    +
      +
    • +

      +You can check if SWIG is installed by running swig -version +

      +
    • +
    • +

      +SWIG is available through the package manager on many systems. +

      +
    • +
    • +

      +Source distributions are available at + the SWIG web site +

      +
    • +
    +
  6. +
+
+
+

2.2. Installation of Swift/T from Source

+

Once you have found all prerequisites, we can continue with building +Swift/T from source.

+
    +
  1. +

    +Obtain the Swift/T source package +

    +
    +
    +
    wget http://www.mcs.anl.gov/exm/local/downloads/exm-0.5.0.tar.gz
    +
    +

    Cf. Swift/T Downloads +for other packages

    +
  2. +
  3. +

    +Unpack and enter package directory +

    +
    +
    +
    tar xfz exm-trunk.tar.gz
    +cd exm-trunk
    +
    +
  4. +
  5. +

    +Edit the settings file: exm-settings.sh +

    +

    At a minimum, you must set the install directory with EXM_PREFIX. +On a standard system, no further configuration may be needed. +In many cases, however, you will need to modify additional +configuration settings so that all prerequisites can +be correctly located and configured (see Section +Build configuration).

    +

    A range of other settings are also available here: +enabling/disabling features, debug or optimized builds, etc.

    +
    + + + +
    +
    Tip
    +
    Save your exm-settings.sh when you download a new package
    +
    +
  6. +
  7. +

    +Run the setup script +

    +
    +
    +
    ./exm-setup.zsh
    +
    +

    If exm-setup.zsh does not succeed on your system, see Section +Build configuration below.

    +
    + + + +
    +
    Tip
    +
    if you want more control than exm-setup.zsh provides, you can + build Swift/T with the + manual configure/make workflow.
    +
    +
  8. +
  9. +

    +Add Turbine and STC to your paths +

    +
    +
    +
    PATH=${PATH}:/path/to/exm-install/turbine/bin
    +PATH=${PATH}:/path/to/exm-install/stc/bin
    +
    +
  10. +
+
+
+
+
+

3. Usage

+
+

Swift code is conventionally written in *.swift files. Turbine +code is stored in Tcl files *.tcl. After writing the Swift program +program.swift, run:

+
+
+
stc program.swift
+
+

This will compile the program to program.tcl. A second, optional +argument may be given as an alternate output file name.

+

Then, to run the program, use Turbine:

+
+
+
turbine -n 4 program.tcl
+
+

See the Turbine section for more information about +running the program.

+

STC accepts the following arguments:

+
+
+-A name=value +
+
+

+Set a command-line argument at +compile-time. This may be found at runtime using the Swift +argument processing library. This option enables these +arguments to be treated as compile-time constants for optimization. +

+
+
+-D macro=value +
+
+

+Define a C preprocessor macro. +

+
+
+-E +
+
+

+Just run the C preprocessor: do not compile the program. The +output goes into the STC output file (the second file name argument). +

+
+
+-I +
+
+

+Add a directory to the import and include search path. +

+
+
+-O +
+
+

+Set optimization level: 0, 1, 2, or 3. See [Optimizations]. +

+
+
+-j +
+
+

+Set the location of the java executable. +

+
+
+-p +
+
+

+Disable the C preprocessor. +

+
+
+-u +
+
+

+Only compile if output file is not up-to-date. +

+
+
+-v +
+
+

+Output version number and exit. +

+
+
+-V +
+
+

+Verbose output. +

+
+
+

STC runs as a Java program. You may use -j to set the Java VM +executable. This Java VM must be compatible with the javac used to +compile STC.

+

By default, STC runs the user script through the C preprocessor +(cpp), enabling arbitrary macro processing, etc. The -D, -E, +-I, and -p options are relevant to this feature.

+

Additional arguments for advanced users/developers:

+
+
+-C +
+
+

+Specify an output file for STC internal representation +

+
+
+-l +
+
+

+Specify log file for STC debug log +

+
+
+-L +
+
+

+Specify log file for more verbose STC debug log +

+
+
+-T +
+
+

+Enable a specific optimization. See [Optimizations] +

+
+
+-t +
+
+

+Disable a specific compiler optimization. See [Optimizations] +

+
+
+
+
+
+

4. Program structure

+
+

Swift programs are composed of composite functions. These +share syntax with C-like languages. The program starts in main(). +The following is a complete Swift program:

+
+
+
main
+{}
+
+

STC input is preprocessed by cpp, the C preprocessor.

+

Hello world is written as:

+
+
+
import io;
+main
+{
+  printf("Hello world");
+}
+
+

The newline is supplied by printf().

+

Swift programs eventually call leaf functions, which are the primary +way to do work. From the perspective of the Swift script, they are +atomic operations that wait for input variables and set output +variables. They may be implemented as native code functions or +external application programs.

+
+
+
+

5. Comments

+
+

Swift supports C/C++-style comments:

+
+
+
// This is a comment
+/* This is a
+comment */
+/** Also a
+comment */
+
+

Additionally, if the preprocessor is disabled, single-line comments +starting with # are supported:

+
+
+
# This will work if source file is not preprocessed
+
+
+
+
+

6. Modules

+
+

Swift has a module system that allows you to import function and variable +definitions into your source file. Importing a module will import all +function and variable definitions from that module into your program.

+
+
+
import io;
+import mypackage.mymodule;
+
+

The mechanisms for locating source files is as follows:

+
    +
  • +

    +STC searches a list of directories in order to find a Swift source + file in the correct directory with the correct name. +

    +
  • +
  • +

    +The standard library is always first on the search path, + and the current working directory is last. +

    +
  • +
  • +

    +Additional directories can be added with the -I option to STC. +

    +
  • +
  • +

    +Swift source files must have a .swift suffix. E.g. import io; + looks for a file called io.swift. +

    +
  • +
  • +

    +In the case of a multi-part import name, E.g. import mypackage.mymodule, + then, it looks for mymodule.swift in subdirectory mypackage. +

    +
  • +
+

The alternative #include statement textually includes an entire +file using the C preprocessor at the point of the statement. +Note that #include will only work if the preprocessor is enabled +on the current file. In contrast to import, #include will run the +C preprocessor on any included modules. import is recommended over +#include unless the imported module requires preprocessing.

+
+
+
#include <mypackage/mymodule.swift>
+
+
+
+
+

7. Dataflow evaluation

+
+

Swift expressions are evaluated in dataflow order:

+
+
+
int z1,z2;
 int y;
 int x = f(y);
 y = g(2);
 z1 = h(x,y,1);
 z2 = h(x,y,2);
-int output = r(z1,z2);
-----
-
-This allows code to execute as concurrently as possible, limited
-only by data availability.  In this example, +g()+ runs first, because it
-is dependent only on a literal.  When +y+ is set, +f()+ runs, setting
-+x+.  Then, two invocations of +h()+ execute.  Finally, +z1+ and +z2+
-are set, allowing +r()+ to run.
-
-Variables may be assigned only once.  Multiple assignment is often
+int output = r(z1,z2);
+
+

This allows code to execute as concurrently as possible, limited +only by data availability. In this example, g() runs first, because it +is dependent only on a literal. When y is set, f() runs, setting +x. Then, two invocations of h() execute. Finally, z1 and z2 +are set, allowing r() to run.

+

Variables may be assigned only once. Multiple assignment is often detected at compile time, and will always be detected at run time, resulting in a run time error. If variable is not assigned, expressions that depend on the variable cannot execute. If the variable is never assigned during the course of program execution, these expressions will never execute. Upon program completion, Swift/T will report the error and print debug information about any unexecuted -expressions and identifiers of corresponding unassigned variables. - -== Composite functions - -Swift code is written in composite functions. The composite function -+main+ is required. - -Composite functions have the form: - ----- -[()] function_name [()] +expressions and identifiers of corresponding unassigned variables.

+
+
+
+

8. Composite functions

+
+

Swift code is written in composite functions. The composite function +main is required.

+

Composite functions have the form:

+
+
+
[(<output list>)] function_name [(<input list>)]
 {
   statement;
   statement;
   ...
-}
-----
-
-An empty input or output list may be omitted or written as +()+.
-
-The output list may have more than one entry.  Thus, assignments
-may be written as:
-----
-x1, x2 = f(i1, i2);
+}
+
+

An empty input or output list may be omitted or written as ().

+

The output list may have more than one entry. Thus, assignments +may be written as:

+
+
+
x1, x2 = f(i1, i2);
 // or equivalently:
-(x1, x2) = f(i1, i2);
-----
-
-== Types
-
-Swift provides a similar range of primitive types to many other
+(x1, x2) = f(i1, i2);
+
+
+
+
+

9. Types

+
+

Swift provides a similar range of primitive types to many other programming languages. Files are a primitive type in Swift, unlike in many other languages, and have a number of special characteristics that merit special mention. -Two basic kinds of data structure are provided: arrays and structs. - -=== Primitive types - -Swift has the conventional types: - -+string+:: A complete string (not an array of characters). -+int+:: A 64-bit integer. -+float+:: A 64-bit (double-precision) floating point number. -+boolean+:: A boolean (true/false). -+file+:: A file (see Section Files). -+blob+:: External byte data (see Section Blobs). - -Literals for these types use conventional syntax: - -* +int+ literals are written as decimal numbers, e.g. +-1234+ -* +float+ literals are written as decimal numbers with a decimal point, - e.g +5493.352+ or +1.0+. +Two basic kinds of data structure are provided: arrays and structs.

+
+

9.1. Primitive types

+

Swift has the conventional types:

+
+
+string +
+
+

+A complete string (not an array of characters). +

+
+
+int +
+
+

+A 64-bit integer. +

+
+
+float +
+
+

+A 64-bit (double-precision) floating point number. +

+
+
+boolean +
+
+

+A boolean (true/false). +

+
+
+file +
+
+

+A file (see Section Files). +

+
+
+blob +
+
+

+External byte data (see Section Blobs). +

+
+
+

Literals for these types use conventional syntax:

+
    +
  • +

    +int literals are written as decimal numbers, e.g. -1234 +

    +
  • +
  • +

    +float literals are written as decimal numbers with a decimal point, + e.g 5493.352 or 1.0. Scientific notation may be used, - as in +2.3e-2+ which is equivalent to +0.023+. - The literals +NaN+ and +inf+ may be used. In some contexts +int+ - literals are promoted automatically to +float+. -* +boolean+ literals +true+ and +false+ may be used. -* +string+ literals are enclosed in double quotes, with a range of escape + as in 2.3e-2 which is equivalent to 0.023. + The literals NaN and inf may be used. In some contexts int + literals are promoted automatically to float. +

    +
  • +
  • +

    +boolean literals true and false may be used. +

    +
  • +
  • +

    +string literals are enclosed in double quotes, with a range of escape sequences supported: -** +\\+ for a single backslash -** +\"+ for a quote -** +\n+ for newline -** +\t+ for tab -** +\a+ (alarm) -** +\b+ (backspace) -** +\f+ (form feed) -** +\r+ (carriage return) -** +\v+ (vertical tab) -** octal escape codes, e.g. +\001+ -** hexadecimal escape codes, e.g. +\xf2+ -** For more information: http://en.wikipedia.org/wiki/US-ASCII#ASCII_control_code_chart[ASCII control codes]. -* Multi-line strings may be used in two syntaxes: -** Python-style: -+ ----- -string s = +

    +
      +
    • +

      +\\ for a single backslash +

      +
    • +
    • +

      +\" for a quote +

      +
    • +
    • +

      +\n for newline +

      +
    • +
    • +

      +\t for tab +

      +
    • +
    • +

      +\a (alarm) +

      +
    • +
    • +

      +\b (backspace) +

      +
    • +
    • +

      +\f (form feed) +

      +
    • +
    • +

      +\r (carriage return) +

      +
    • +
    • +

      +\v (vertical tab) +

      +
    • +
    • +

      +octal escape codes, e.g. \001 +

      +
    • +
    • +

      +hexadecimal escape codes, e.g. \xf2 +

      +
    • +
    • +

      +For more information: ASCII control codes. +

      +
    • +
    +
  • +
  • +

    +Multi-line strings may be used in two syntaxes: +

    +
      +
    • +

      +Python-style: +

      +
      +
      +
      string s =
       """
       line data 1
       line data 2
      -""";
      -----
      -+
      -** Asciidoc-style: like Python-style but use 4 dashes instead of 3 quotes.
      -** *Note:* Multi-line strings are somewhat incompatible with the C preprocessor:
      +""";
      +
      +
    • +
    • +

      +Asciidoc-style: like Python-style but use 4 dashes instead of 3 quotes. +

      +
    • +
    • +

      +Note: Multi-line strings are somewhat incompatible with the C preprocessor: if you try to compile a Swift program using multi-line strings with the preprocessor enabled, you will likely see warnings or strange - behavior. To disable the C preprocessor, use the +-p+ option + behavior. To disable the C preprocessor, use the -p option to STC. - -=== Files - -A file is a first-class entity in Swift that in many ways can be treated +

      +
    • +
    +
  • +
+
+
+

9.2. Files

+

A file is a first-class entity in Swift that in many ways can be treated as any other variable. The main difference is that a file can be -*mapped* to path in a filesystem. Assigning to a mapped file variable +mapped to path in a filesystem. Assigning to a mapped file variable results in a file being created in the file system at the specified path. -File paths can be arbitrary Swift expressions of type +string+. Absolute +File paths can be arbitrary Swift expressions of type string. Absolute paths or relative paths are specified, with relative paths interpreted relative to the path in which turbine was run. File variables can also be initialized with data from a pre-existing -file using the +input_file+ function. File paths are relative to the -working directory for Turbine. - -For example, if +/home/user/in.txt+ is a file with some data in it, -the following Swift program will copy the file to +/home/user/out.txt+. ----- -main +file using the input_file function. File paths are relative to the +working directory for Turbine.

+

For example, if /home/user/in.txt is a file with some data in it, +the following Swift program will copy the file to /home/user/out.txt.

+
+
+
main
 {
   file x = input_file("/home/user/in.txt");
-  file y <"/home/user/out.txt">; // Declare a mapped file
+  file y <"/home/user/out.txt">; // Declare a mapped file
   y = x; // Do the copy
-}
-----
-
-
-A range of functions to work with files are provided in the
-+files+ library module.
-
-----
-// Initialize an array of files from a range of files on disk with glob
+}
+
+

A range of functions to work with files are provided in the +files library module.

+
+
+
// Initialize an array of files from a range of files on disk with glob
 file f[] = glob("directory/*.txt");
 
 // Read the contents of a file with read
@@ -421,79 +1282,79 @@
 file tmp = write("first line\nsecond line");
 
 // Find the name of a file with filename
-trace("Temporary filename is: " + filename(tmp));
-----
-
-Temporary files are created as necessary if unmapped files are
-written to.  For example, the file +tmp+ in the above code snippet.
-This feature is implemented by calling GNU +mktemp+ with suffix
-+.turbine+; thus, the directory is set with environment variable
-+TMPDIR+ which defaults to +/tmp+.
-
-Currently Swift/T assumes that the file system is shared among
-all nodes.
-
-[NOTE]
-======
-The syntax
-----
-file f<"f.txt"> = g();
-----
-is allowed but
-----
-file f<"f.txt">=g();
-----
-results in a parse error: the +>=+ sequence is tokenized as
-_greater-than-or-equal-to_.
-======
-
-=== Blobs
-
-Blobs represent raw byte data.  They are primarily used to pass
+trace("Temporary filename is: " + filename(tmp));
+
+

Temporary files are created as necessary if unmapped files are +written to. For example, the file tmp in the above code snippet. +This feature is implemented by calling GNU mktemp with suffix +.turbine; thus, the directory is set with environment variable +TMPDIR which defaults to /tmp.

+

Currently Swift/T assumes that the file system is shared among +all nodes.

+
+ + + +
+
Note
+
+

The syntax

+
+
+
file f<"f.txt"> = g();
+
+

is allowed but

+
+
+
file f<"f.txt">=g();
+
+

results in a parse error: the >= sequence is tokenized as +greater-than-or-equal-to.

+
+
+
+
+

9.3. Blobs

+

Blobs represent raw byte data. They are primarily used to pass data to and from native code libraries callable from Swift. They are -like Swift strings but may contain arbitrary data. - -Swift provides multiple builtin functions to create blobs, convert -blobs to and from Swift types, and pass blobs to leaf functions. - -=== Arrays - -Arrays can be declared with empty square brackets: - ----- -int A[]; ----- - -Arrays with empty square brackets have integer indices. It is +like Swift strings but may contain arbitrary data.

+

Swift provides multiple builtin functions to create blobs, convert +blobs to and from Swift types, and pass blobs to leaf functions.

+
+
+

9.4. Arrays

+

Arrays can be declared with empty square brackets:

+
+
+
int A[];
+
+

Arrays with empty square brackets have integer indices. It is also possible to declare integers with other index types, such as -strings: - ----- -string dict[string]; ----- - -They are dynamically sized, expanding each time an item is inserted at -a new index. Arrays are indexed using square brackets. ----- -int A[string]; +strings:

+
+
+
string dict[string];
+
+

They are dynamically sized, expanding each time an item is inserted at +a new index. Arrays are indexed using square brackets.

+
+
+
int A[string];
 int B[];
 B = function_returning_array();
 A["zero"] = B[0];
-A["one"] = B[1];
-----
-
-Each array index can only be assigned to once.
-
-A given array variable must be assigned either _in toto_ (as a whole)
-or _in partes_ (piece by piece).  In this example, +B+ is assigned in toto
-and +A+ is assigned in partes.  Code that attempts to do both is in error.
-
-Arrays may be used as inputs or outputs of functions.
-
-Arrays are part of Swift dataflow semantics. An array is closed
-when all possible insertions to it are complete.
-----
-(int B[]) f(int j)
+A["one"] = B[1];
+
+

Each array index can only be assigned to once.

+

A given array variable must be assigned either in toto (as a whole) +or in partes (piece by piece). In this example, B is assigned in toto +and A is assigned in partes. Code that attempts to do both is in error.

+

Arrays may be used as inputs or outputs of functions.

+

Arrays are part of Swift dataflow semantics. An array is closed +when all possible insertions to it are complete.

+
+
+
(int B[]) f(int j)
 {
   int A[];
   A = subroutine_function(1);
@@ -503,72 +1364,69 @@
 
   // OK: assigning to output variable
   B = subroutine_function(2);
-}
-
-----
-
-Array literals may be expressed using the range operator:
-----
-int start = 0;
+}
+
+

Array literals may be expressed using the range operator:

+
+
+
int start = 0;
 int stop = 10;
 int step = 2;
 // Array of length 10:
 int A[] = [start:stop];
 // Array of length 5, containing only even numbers:
-int B[] = [start:stop:step];
-----
-
-Array literals may also be expressed with list syntax:
-----
-int C[] = [4,5,6];
-----
-
-=== Nested arrays
-Swift allows arrays of arrays: nested arrays.  They can be declared and
-assigned as follows:
-
-----
-// An array of arrays of files with string keys
+int B[] = [start:stop:step];
+
+

Array literals may also be expressed with list syntax:

+
+
+
int C[] = [4,5,6];
+
+
+
+

9.5. Nested arrays

+

Swift allows arrays of arrays: nested arrays. They can be declared and +assigned as follows:

+
+
+
// An array of arrays of files with string keys
 file A[string][string];
 A["foo"]["bar"] = input_file("test.txt");
-A["foo"]["qux"] = input_file("test2.txt");
-----
-
-*Note:* there is currently a limitation in assignment of nested arrays
+A["foo"]["qux"] = input_file("test2.txt");
+
+

Note: there is currently a limitation in assignment of nested arrays that a given array can only be assigned at a single "index level". If -+A+ is a 2D array, for example, then you cannot mix assignments specifying -one index (e.g. +A[i] = ...+) with assignments specifying three indices -(e.g. +A[i][j] = ...+). - -=== Structs - -In Swift, structs are defined with the +type+ keyword. They define -a new type. - ----- -type person +A is a 2D array, for example, then you cannot mix assignments specifying +one index (e.g. A[i] = …) with assignments specifying three indices +(e.g. A[i][j] = …).

+
+
+

9.6. Structs

+

In Swift, structs are defined with the type keyword. They define +a new type.

+
+
+
type person
 {
   string name;
   int age;
   int events[];
-}
-----
-
-Structs are accessed with the +.+ syntax:
-
-----
-person p;
+}
+
+

Structs are accessed with the . syntax:

+
+
+
person p;
 p.name = "Abe";
-p.age = 90;
-----
-
-It is possible to have arrays of structs, with some restriction on
+p.age = 90;
+
+

It is possible to have arrays of structs, with some restriction on how they can be assigned. Each struct in the array must be assigned -_in toto_ (as a whole). For example, the following code is valid: +in toto (as a whole). For example, the following code is valid:

+
+
+
person people[], p1, p2;
 
-----
-person people[], p1, p2;
-
 p1.name = "Thelma";
 p1.age = 31;
 
@@ -576,50 +1434,46 @@
 p2.age = 29;
 
 people[0] = p1;
-people[1] = p2;
-----
-
-However, attempting to assign the structs in the following way is
-currently unsupported:
-----
-people[2].name = "Abe";  // Not supported!
-people[2].age = 90;      // Not supported!
-----
-
-=== Defining new types
-
-Swift has two ways to define new types based on existing types.
-
-The first is +typedef+, which creates a new name for the type.
+people[1] = p2;
+
+

However, attempting to assign the structs in the following way is +currently unsupported:

+
+
+
people[2].name = "Abe";  // Not supported!
+people[2].age = 90;      // Not supported!
+
+
+
+

9.7. Defining new types

+

Swift has two ways to define new types based on existing types.

+

The first is typedef, which creates a new name for the type. The new type and the existing type will be completely interchangeable, since they are simply different names for the same underlying type. -The new type name simply serves to improve readability or documentation. +The new type name simply serves to improve readability or documentation.

+
+
+
typedef newint int;
 
-----
-typedef newint int;
-
 main {
   // We can freely convert between int and newint
   newint x = 1;
   int y = x;
   newint z = y;
-}
-----
-
-The second is with +type+, which creates a new type that is a
+}
+
+

The second is with type, which creates a new type that is a specialization of an existing type. That is, it is a distinct type that is not interchangeable. A specialized type can be converted into the original type, but the reverse transformation is not possible. This means that you can write functions that are more strictly typechecked, for example, only accepted particular types of -file. - -*Note:* This feature is immature, so you will have a higher probability -of encountering compiler bugs or limitations. - ----- - -typedef sorted_file file; +file.

+

Note: This feature is immature, so you will have a higher probability +of encountering compiler bugs or limitations.

+
+
+
typedef sorted_file file;
 app (sorted_file out) sort (file i) {
   "/usr/bin/sort" "-o" out i
 }
@@ -631,54 +1485,54 @@
 
 main {
   file unsorted = input_file("input.txt");
-  sorted_file sorted <"sorted.txt"> = sort(unsorted);
-  file u <"unique.txt"> = unique(sorted);
+  sorted_file sorted <"sorted.txt"> = sort(unsorted);
+  file u <"unique.txt"> = unique(sorted);
 
   // Can convert from sorted_file to file
   file result2 = sort(unsorted);
 
   // This would cause a type error
   // sorted_file not_sorted = unsorted;
-}
-----
-
-=== Global Constants
-
-Swift supports a basic feature for defining globally visible constants.  You
-can use the +global const+ statement at the top level of the program.  The
+}
+
+
+
+

9.8. Global Constants

+

Swift supports a basic feature for defining globally visible constants. You +can use the global const statement at the top level of the program. The syntax only supports literals of scalar types: e.g. integer literals, floating -point literals and string literals. - ----- -global const string hello = "Hello World"; +point literals and string literals.

+
+
+
global const string hello = "Hello World";
 global const float pi_approx = 3.142;
 global const int ONE = 1;
 
 main () {
   trace(hello, pi_approx, ONE);
-}
-----
-
-*Note:* global constants provide no performance benefit compared with
-variables initialized to constant values at optimization levels +O1+
-or greater.
-
-*Note:* better support is planned in future for more flexible support for
-global variables and code.
-
-== Control structures
-
-Swift provides control structures that may be placed as statements
-inside a composite function.
-
-=== Conditionals
-
-==== If statement
-
-If statements have the form:
-
-----
-if ()
+}
+
+

Note: global constants provide no performance benefit compared with +variables initialized to constant values at optimization levels O1 +or greater.

+

Note: better support is planned in future for more flexible support for +global variables and code.

+
+
+
+
+

10. Control structures

+
+

Swift provides control structures that may be placed as statements +inside a composite function.

+
+

10.1. Conditionals

+
+

10.1.1. If statement

+

If statements have the form:

+
+
+
if (<condition>)
 {
   statement;
   ...
@@ -687,16 +1541,16 @@
 {
   statement;
   ...
-}
-----
-
-As required by dataflow processing, neither branch of the conditional can
-execute until the value of the condition expression is available.
-
-==== Switch statement
-
-----
-int a = 20;
+}
+
+

As required by dataflow processing, neither branch of the conditional can +execute until the value of the condition expression is available.

+
+
+

10.1.2. Switch statement

+
+
+
int a = 20;
 switch (a)
 {
   case 1:
@@ -710,51 +1564,48 @@
   default:
     b = 2102 + 2420;
 }
-printf("b: %i\n", b);
-----
-
-*Note:* there is no fall-through between cases in switch statements.
-
-=== Iteration
-
-Iteration is performed with the +foreach+ and +for+ statements.
-
-==== Foreach loop
-
-The +foreach+ loop allows for parallel iteration over an array:
-
-----
-string A[];
+printf("b: %i\n", b);
+
+

Note: there is no fall-through between cases in switch statements.

+
+
+
+

10.2. Iteration

+

Iteration is performed with the foreach and for statements.

+
+

10.2.1. Foreach loop

+

The foreach loop allows for parallel iteration over an array:

+
+
+
string A[];
 foreach value, index in A
 {
   printf("A[%i] = %s\n", index, value);
-}
-----
-
-The +index+ and +value+ variables are automatically declared.  The
-+index+ variable may be omitted from the syntax.
-
-A special case of the foreach loop occurs when combined with the
+}
+
+

The index and value variables are automatically declared. The +index variable may be omitted from the syntax.

+

A special case of the foreach loop occurs when combined with the array range operator. This is the idiomatic way to iterate over a range of integer values in Swift. The STC compiler has special -handling for this case that avoids constructing an array. - ----- -foreach i in [start:stop:step] { +handling for this case that avoids constructing an array.

+
+
+
foreach i in [start:stop:step] {
     ...
-}
-----
-
-==== For loop
-
-The +for+ loop allows for sequential iteration.  This example
+}
+
+
+
+

10.2.2. For loop

+

The for loop allows for sequential iteration. This example implements a counter based on the return values of a function that -accepts integers: - ----- -int N = 100; +accepts integers:

+
+
+
int N = 100;
 int count = 0;
-for (int i = 0; i < N; i = i+1, count = count+c)
+for (int i = 0; i < N; i = i+1, count = count+c)
 {
   int c;
   if (condition_function(i))
@@ -765,612 +1616,1151 @@
   {
     c = 0;
   }
-}
-----
-
-The general form is:
-----
-for (  ;  ;  )
+}
+
+

The general form is:

+
+
+
for ( <initializer> ; <condition> ; <updates> )
 {
   statement;
   ...
-}
-----
-
-The initializer is executed first, once.  The initializer is a
+}
+
+

The initializer is executed first, once. The initializer is a comma-separated list of statements. The body statements are then executed. Then, the assignments are performed, formatted as a comma-separated list. Each is a special assignment in which the -left-hand-side is the variable in the _next_ iteration of the loop, -while the right-hand-side is the variable in the _previous_ loop +left-hand-side is the variable in the next iteration of the loop, +while the right-hand-side is the variable in the previous loop iteration. Then, the condition is checked for loop exit. If the loop -continues, the body is executed again, etc. - -*Performance Tip:* use the +foreach+ loop instead of +for+ if your -loop iterations are independent and can be executed in parallel. - -=== Explicit data-dependent execution - -In general, execution ordering in Swift/T is implicit and driven by +continues, the body is executed again, etc.

+

Performance Tip: use the foreach loop instead of for if your +loop iterations are independent and can be executed in parallel.

+
+
+
+

10.3. Explicit data-dependent execution

+

In general, execution ordering in Swift/T is implicit and driven by data dependencies. In some cases it is useful to add explicit data dependencies, for example if you want to print a message to indicate that variable was assigned. It is possible for the programmer to -express additional execution ordering using two constructs: the +wait+ -statement and the +\=>+ chaining operator. - -In a wait statement, a block of code is executed after -one or more variables are closed. ----- -x = f(); +express additional execution ordering using two constructs: the wait +statement and the => chaining operator.

+

In a wait statement, a block of code is executed after +one or more variables are closed.

+
+
+
x = f();
 y = g();
 wait (x) {
   trace("x is closed!");
 }
 wait(x, y) {
   trace("x and y are closed!");
-}
-----
-
-The chaining operator chains statements together so that a
-statement only executes after the previous statement's output
+}
+
+

The chaining operator chains statements together so that a +statement only executes after the previous statement’s output value is closed. This is -a more concise way to express dependencies than the +wait+ statement. ----- -sleep(1) => - x = f() => - int y = g() => - trace("DONE!"); ----- - -Chaining is based on the *output values* -of a statement. In the simple case of a function call +f() \=> ...+, +a more concise way to express dependencies than the wait statement.

+
+
+
sleep(1) =>
+  x = f() =>
+  int y = g() =>
+  trace("DONE!");
+
+

Chaining is based on the output values +of a statement. In the simple case of a function call f() => …, the output values are the output values of the function. In the -case of and assignment +x = f() \=> ...+ or a declaration, -+int y = g() \=> ...+, then the next statement is dependent on +case of and assignment x = f() => … or a declaration, +int y = g() => …, then the next statement is dependent on the assigned values, or the declared values. Some functions such -as +sleep+ have +void+ output values so that they can be used -in this fashion. - -=== Scoping blocks - -Arbitrary scoping blocks may be used. In this example, two different -variables, both represented by +b+, are assigned different values. - ----- -{ +as sleep have void output values so that they can be used +in this fashion.

+
+
+

10.4. Scoping blocks

+

Arbitrary scoping blocks may be used. In this example, two different +variables, both represented by b, are assigned different values.

+
+
+
{
   int b;
   b = 1;
 }
 {
   int b;
   b = 2;
-}
-----
-
-== Operators
-
-The following binary arithmetic operators on numbers are defined:
-
-+++ (plus), +-+ (minus), +\*+ (times), +/+ (divide),
-+%/+ (integer divide), +%%+ (modulus), +**+ (power)
-
-+&&+ (boolean and), +||+ (boolean or),
-+==+ (equals), +!=+ (not equals), +>+ (greater than), +<+ (less than),
-+>=+ (greater than or equal to), +<=+ (less than or equal to)
-
-+xor()+ is a builtin function.
-
-Swift boolean operators are not short-circuited (to allow maximal
-concurrency).  For conditional execution, use an +if+ statement.
-
-The following unary operators are defined:
-
-+-+ (negate), +!+ (boolean not)
-
-String concatenation is also performed with +++ (plus).  +==+ and
-+!=+ may also be used on strings.  Operator +s1/s2+ is equivalent to
-+s1+"/"+s2+.
-
-== Standard library
-
-Each category of function is shown with the required import
-statement, if necessary.
-
-Functions that accept an input of any type are denoted +anything+.
+}
+
+
+
+
+
+

11. Operators

+
+

The following binary arithmetic operators on numbers are defined:

+

+ (plus), - (minus), * (times), / (divide), +%/ (integer divide), %% (modulus), ** (power)

+

&& (boolean and), || (boolean or), +== (equals), != (not equals), > (greater than), < (less than), +>= (greater than or equal to), <= (less than or equal to)

+

xor() is a builtin function.

+

Swift boolean operators are not short-circuited (to allow maximal +concurrency). For conditional execution, use an if statement.

+

The following unary operators are defined:

+

- (negate), ! (boolean not)

+

String concatenation is also performed with + (plus). == and +!= may also be used on strings. Operator s1/s2 is equivalent to +s1+"/"+s2.

+
+
+
+

12. Standard library

+
+

Each category of function is shown with the required import +statement, if necessary.

+

Functions that accept an input of any type are denoted anything. Functions that accept variable numbers of arguments are denoted with -ellipsis +...+. - -A function that accepts more than one type is denoted as +f(int|string)+. - -If a function is described below an *Import:* label, be sure to -+import+ that package. - -=== General - -+xor(boolean,boolean) -> boolean+:: Exclusive logical or -+make_void() -> void+:: Create a void value -+size(A[]) -> int+:: Obtain the size of array +A+ -+contains(A[], key) -> boolean+:: Test that future +A[key]+ exists. -This function blocks until +A+ is closed. Consumers of +A[key]+ may -block again until +A[key]+ is stored. - -=== Type conversion - -+fromint(int) -> string+:: Convert integer to string -+toint(string) -> int+:: Convert string to integer -+fromfloat(float) -> string+:: Convert float to string -+tofloat(string) -> float+:: Convert string to float -+itof(int) -> float+:: Convert integer to float -+repr(*) -> string+:: Convert any type to internal +ellipsis .

+

A function that accepts more than one type is denoted as f(int|string).

+

If a function is described below an Import: label, be sure to +import that package.

+
+

12.1. General

+
+
+xor(boolean,boolean) → boolean +
+
+

+Exclusive logical or +

+
+
+make_void() → void +
+
+

+Create a void value +

+
+
+size(A[]) → int +
+
+

+Obtain the size of array A +

+
+
+contains(A[], key) → boolean +
+
+

+Test that future A[key] exists. +This function blocks until A is closed. Consumers of A[key] may +block again until A[key] is stored. +

+
+
+
+
+

12.2. Type conversion

+
+
+fromint(int) → string +
+
+

+Convert integer to string +

+
+
+toint(string) → int +
+
+

+Convert string to integer +

+
+
+fromfloat(float) → string +
+
+

+Convert float to string +

+
+
+tofloat(string) → float +
+
+

+Convert string to float +

+
+
+itof(int) → float +
+
+

+Convert integer to float +

+
+
+repr(*) → string +
+
+

+Convert any type to internal string representation (exact format not guaranteed to be consistent, even from call to call) -+array_repr(*[]) -> string[]+:: Convert array of any type to internal +

+
+
+array_repr(*[]) → string[] +
+
+

+Convert array of any type to internal string representation (exact format not guaranteed to be consistent, even from call to call) - -=== Output - -+trace(anything, anything, ...)+:: Report the value of any variable - -*Import:* +io+ - -+printf(string format, int|float|string|boolean...)+:: -As +printf()+ in C - -=== String functions - -+strcat(string,string)+: Concatenation - -*Import:* +string+ - -+substring(string s, int start, int length) -> string+:: -Obtain substring of given string +s+ starting at character +start+ and of -length +length+ - -+find(string s, string substring, int start_index, int end_index) -> int+:: -Find the index of the first occurence of the string +substring+ within -the string +s+ between the indices +start_index+ and +end_index+. Here -an index of +-1+ passed to +end_index+ results in +end_index+ being -treated as the length of the string +s+. +find+ returns +-1+ in case -there is no occurence of +substring+ in +s+ in the specified range. - -+string_count(string s, string substring, int start_index, int end_index) -> int+:: -Counts the occurences of the string +substring+ within the string +s+ -between the indices +start_index+ and +end_index+. Here an index of -+-1+ passed to +end_index+ results in +end_index+ being treated as the -length of the string +s+ - -+is_int(string s) -> boolean+:: -Returns true if string +s+ is a number, else false. - -+replace(string s, string substring, string rep_string, int start_index) -> string+:: +

+
+
+
+
+

12.3. Output

+
+
+trace(anything, anything, …) +
+
+

+Report the value of any variable +

+
+
+

Import: io

+
+
+printf(string format, int|float|string|boolean…) +
+
+

+As printf() in C +

+
+
+
+
+

12.4. String functions

+

strcat(string,string): Concatenation

+

Import: string

+
+
+substring(string s, int start, int length) → string +
+
+

+Obtain substring of given string s starting at character start and of +length length +

+
+
+find(string s, string substring, int start_index, int end_index) → int +
+
+

+Find the index of the first occurence of the string substring within +the string s between the indices start_index and end_index. Here +an index of -1 passed to end_index results in end_index being +treated as the length of the string s. find returns -1 in case +there is no occurence of substring in s in the specified range. +

+
+
+string_count(string s, string substring, int start_index, int end_index) → int +
+
+

+Counts the occurences of the string substring within the string s +between the indices start_index and end_index. Here an index of +-1 passed to end_index results in end_index being treated as the +length of the string s +

+
+
+is_int(string s) → boolean +
+
+

+Returns true if string s is a number, else false. +

+
+
+replace(string s, string substring, string rep_string, int start_index) → string +
+
+

Obtain the string created by replacing the first occurence of the -string +substring+ within string +s+, after the index +start_index+, -with the string +rep_string+. In case there is no such occurence of -the string +substring+ in string +s+, the original string +s+ is +string substring within string s, after the index start_index, +with the string rep_string. In case there is no such occurence of +the string substring in string s, the original string s is returned unmodified. - -+replace_all(string s, string substring, string rep_string, int start_index) -> string+:: +

+
+
+replace_all(string s, string substring, string rep_string, int start_index) → string +
+
+

Obtain the string created by replacing all the occurences of the -string +substring+ within string +s+, after the index +start_index+, -with the string +rep_string+. In case no such occurence of +substring+ -exists in +s+, the original string +s+ is returned unmodified. - -+split(string s, string delimiter) -> string[]+:: -Tokenize string +s+ with given delimiter - -+trim(string s) -> string+:: -Remove leading and trailing whitespace from +s+ - -+strlen(string) -> int+:: +string substring within string s, after the index start_index, +with the string rep_string. In case no such occurence of substring +exists in s, the original string s is returned unmodified. +

+
+
+split(string s, string delimiter) → string[] +
+
+

+Tokenize string s with given delimiter +

+
+
+trim(string s) → string +
+
+

+Remove leading and trailing whitespace from s +

+
+
+strlen(string) → int +
+
+

Obtain the length of the given string - -+hash(string) -> int+:: +

+
+
+hash(string) → int +
+
+

Hash the string to a 32-bit integer - -+sprintf(string format, int|float|string|boolean...)+:: -As +sprintf()+ in C - -+string_join(string A[], string separator) -> string+:: -Join strings in +A+ with given separator. The separator may be the +

+
+
+sprintf(string format, int|float|string|boolean…) +
+
+

+As sprintf() in C +

+
+
+string_join(string A[], string separator) → string +
+
+

+Join strings in A with given separator. The separator may be the empty string - -=== Math - -+max|min_integer(int,int) -> int+:: Obtain maximum or minimum integer, +

+
+
+
+
+

12.5. Math

+
+
+max|min_integer(int,int) → int +
+
+

+Obtain maximum or minimum integer, respectively -+max|min_float(float,float) -> float+:: Obtain maximum or minimum float, +

+
+
+max|min_float(float,float) → float +
+
+

+Obtain maximum or minimum float, respectively -+pow_integer(int b,int x)+:: Obtain b^x^ -+pow_float(float b,float x)+:: Obtain b^x^ - -*Import:* +math+ - -+floor(float) -> int+:: Round down -+ceil(float) -> int+:: Round up -+round(float) -> int+:: Round nearest -+log(float) -> float+:: Natural logarithm -+exp(float) -> float+:: Natural exponentiation: e^i^ -+sqrt(float) -> float+:: Square root -+is_nan(float) -> boolean+:: Check for NaN -+abs_integer(int) -> int+:: Absolute value -+abs_float(float) -> float+:: Absolute value - -*Import:* +random+ - -+random() -> float+:: Obtain random number - -+randint(int start, int end)+:: -Obtain random integer from +start+, inclusive, to +end+, exclusive - -*Import:* stats - -+sum_integer(int[]) -> int+:: Sum -+avg(int|float[]) -> float+:: Average - -=== System - -*Import:* +sys+ - -+getenv(string) -> string+:: Obtain an environment variable - -[[argv]] -==== Command line - -Consider this command line: - - turbine -l -n 3 program.tcl -v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt - -The arguments to +program.tcl+ are just the tokens after +program.tcl+ - -+args() -> string+:: - +

+
+
+pow_integer(int b,int x) +
+
+

+Obtain bx +

+
+
+pow_float(float b,float x) +
+
+

+Obtain bx +

+
+
+

Import: math

+
+
+floor(float) → int +
+
+

+Round down +

+
+
+ceil(float) → int +
+
+

+Round up +

+
+
+round(float) → int +
+
+

+Round nearest +

+
+
+log(float) → float +
+
+

+Natural logarithm +

+
+
+exp(float) → float +
+
+

+Natural exponentiation: ei +

+
+
+sqrt(float) → float +
+
+

+Square root +

+
+
+is_nan(float) → boolean +
+
+

+Check for NaN +

+
+
+abs_integer(int) → int +
+
+

+Absolute value +

+
+
+abs_float(float) → float +
+
+

+Absolute value +

+
+
+

Import: random

+
+
+random() → float +
+
+

+Obtain random number +

+
+
+randint(int start, int end) +
+
+

+Obtain random integer from start, inclusive, to end, exclusive +

+
+
+

Import: stats

+
+
+sum_integer(int[]) → int +
+
+

+Sum +

+
+
+avg(int|float[]) → float +
+
+

+Average +

+
+
+
+
+

12.6. System

+

Import: sys

+
+
+getenv(string) → string +
+
+

+Obtain an environment variable +

+
+
+
+

12.6.1. Command line

+

Consider this command line:

+
+
+
turbine -l -n 3 program.tcl -v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt
+
+

The arguments to program.tcl are just the tokens after program.tcl

+
+
+args() → string +
+
+

Obtain all arguments as single string -+ -E.g., +"-v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt"+ - -The remaining functions are convenience functions oriented around +

+

E.g., "-v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt"

+
+
+

The remaining functions are convenience functions oriented around Swift conventions. Under these conventions, the example command above -has _flagged_ arguments +v+, +a=file.txt+, +exec="prog thing1 -thing2"+, and +help+. The command has _unflagged_ arguments -+file2.txt+ and +file4.txt+ - -+argc()+:: +has flagged arguments v, a=file.txt, exec="prog thing1 +thing2", and help. The command has unflagged arguments +file2.txt and file4.txt

+
+
+argc() +
+
+

Get count of unflagged arguments - -+argv(string)+:: -_(argument-value)_ +

+
+
+argv(string) +
+
+

+(argument-value) Given a string, returns the flagged argument with that key: -+ -+argv("a") -> file1.txt+ -+ -In addition to regular run-time arguments, the STC _compile-time -arguments_ feature allows +argv()+ arguments to be provided at compile +

+

argv("a") → file1.txt

+

In addition to regular run-time arguments, the STC compile-time +arguments feature allows argv() arguments to be provided at compile time. This allows a specialized, optimized version of code to be -compiled for a particular set of arguments. See the +-A -_name_=_value_+ <> to +stc+. Note that if the -argument is re-specified at run-time, an error will occur. - -+argp(int)+:: -_(argument-positional)_ +compiled for a particular set of arguments. See the -A +name=value argument to stc. Note that if the +argument is re-specified at run-time, an error will occur.

+
+
+argp(int) +
+
+

+(argument-positional) Given an integer, returns the unflagged argument at that index: -+ -+argp(2) -> file4.txt+ -+ -Given 0, returns the program name, -+ -+argp(0) -> /path/to/program.tcl+ - -+argv_accept(string...)+:: - +

+

argp(2) → file4.txt

+

Given 0, returns the program name,

+

argp(0) → /path/to/program.tcl

+
+
+argv_accept(string…) +
+
+

If program is given flagged command line arguments not contained in given list, abort. -E.g., +argv_accept("x")+ would cause program failure at run time - -+argv_contains(string) -> boolean+:: - +E.g., argv_accept("x") would cause program failure at run time +

+
+
+argv_contains(string) → boolean +
+
+

Test if the command line contains the given flagged argument: -+ -+argv_contains("v") -> true+ - -==== Debugging - -*Import:* +assert+ - -+assert(boolean condition, string message)+:: -If condition is false, report +message+ and exit immediately. - -[[Turbine_information]] -==== Turbine information - -+adlb_servers() -> int+:: Number of ADLB servers -+turbine_workers() -> int+:: Number of Turbine workers - -=== Files - -+filename(file) -> string+:: Obtain the name of a file -+input(string) -> file+:: Obtain a +file+. At run time, the +

+

argv_contains("v") → true

+
+
+
+
+

12.6.2. Debugging

+

Import: assert

+
+
+assert(boolean condition, string message) +
+
+

+If condition is false, report message and exit immediately. +

+
+
+
+
+

12.6.3. Turbine information

+
+
+adlb_servers() → int +
+
+

+Number of ADLB servers +

+
+
+turbine_workers() → int +
+
+

+Number of Turbine workers +

+
+
+
+
+
+

12.7. Files

+
+
+filename(file) → string +
+
+

+Obtain the name of a file +

+
+
+input(string) → file +
+
+

+Obtain a file. At run time, the filesystem is checked for the given file name -+input_file(string) -> file+:: Alias for +input()+ -+input_url(string) -> file+:: Obtain a +file+. Some +

+
+
+input_file(string) → file +
+
+

+Alias for input() +

+
+
+input_url(string) → file +
+
+

+Obtain a file. Some automatic operations and optimizations are disabled -+urlname(file) -> string+:: Obtain the name of a file created with -+input_url()+ - -*Import:* +files+ - -+read(file) -> string+:: Read file as a string -+write(string) -> file+:: Write string to file - -+file_lines(file) -> string[]+:: +

+
+
+urlname(file) → string +
+
+

+Obtain the name of a file created with +input_url() +

+
+
+

Import: files

+
+
+read(file) → string +
+
+

+Read file as a string +

+
+
+write(string) → file +
+
+

+Write string to file +

+
+
+file_lines(file) → string[] +
+
+

Reads the whole file, returning each line as a separate entry in the -output array. Comments with +#+ are excised, leading and trailing +output array. Comments with # are excised, leading and trailing whitespace is trimmed, and blank lines are omitted. - -+glob(string) -> file[]+:: Perform glob operation, returning files +

+
+
+glob(string) → file[] +
+
+

+Perform glob operation, returning files that match. Available glob symbols include: -+ -* +*+: any character sequence (including the zero-length sequence) -* +?+: any character -* +[chars]+: any of the given characters -* +\x+: character +x+ -* +{a,b,c,...}+ any of +a+, +b+, +c+, etc. - -=== Blobs - -*Import:* +blob+ - -+blob_size(blob) -> int+:: Obtain the size of a blob in bytes. - -+blob_null() -> blob+:: Obtain an empty blob of size 0. - -+blob_from_string(string) -> blob+:: Convert a string into a blob. - -+string_from_blob(blob) -> string+:: Convert a blob into a string. If +

+
    +
  • +

    +*: any character sequence (including the zero-length sequence) +

    +
  • +
  • +

    +?: any character +

    +
  • +
  • +

    +[chars]: any of the given characters +

    +
  • +
  • +

    +\x: character x +

    +
  • +
  • +

    +{a,b,c,…} any of a, b, c, etc. +

    +
  • +
+
+
+
+
+

12.8. Blobs

+

Import: blob

+
+
+blob_size(blob) → int +
+
+

+Obtain the size of a blob in bytes. +

+
+
+blob_null() → blob +
+
+

+Obtain an empty blob of size 0. +

+
+
+blob_from_string(string) → blob +
+
+

+Convert a string into a blob. +

+
+
+string_from_blob(blob) → string +
+
+

+Convert a blob into a string. If the blob is not NULL-terminated, this function appends the NULL-terminator. - -+blob_from_floats(float[]) -> blob+:: Convert an array of Swift floats +

+
+
+blob_from_floats(float[]) → blob +
+
+

+Convert an array of Swift floats (implemented as doubles) to blob containing the C-formatted array of doubles . - -+blob_from_floats(blob) -> float[]+:: Convert blob containing the +

+
+
+blob_from_floats(blob) → float[] +
+
+

+Convert blob containing the C-formatted array of doubles to an array of Swift floats (implemented as doubles). - -+blob_from_ints(int i[]) -> blob+:: Convert blob containing the +

+
+
+blob_from_ints(int i[]) → blob +
+
+

+Convert blob containing the C-formatted array of ints to an array of Swift ints (implemented as 64-bit integers). - -+blob_from_file(file) -> blob+:: Reads whole file, returning it as a +

+
+
+blob_from_file(file) → blob +
+
+

+Reads whole file, returning it as a blob. - -[[library_location]] -=== Location - -See the section about <>. - -+location_from_rank(int) -> location+:: Convert the rank integer to a -+location+ variable compatible with + at location+. - -+random_worker() -> location+:: Obtain a worker at random. - -+hostmap_list() -> string[]+:: Obtain the whole hostmap. - -+hostmap_one(string) -> location+:: Lookup the string as a host in the +

+
+
+
+
+

12.9. Location

+

See the section about location.

+
+
+location_from_rank(int) → location +
+
+

+Convert the rank integer to a +location variable compatible with @location. +

+
+
+random_worker() → location +
+
+

+Obtain a worker at random. +

+
+
+hostmap_list() → string[] +
+
+

+Obtain the whole hostmap. +

+
+
+hostmap_one(string) → location +
+
+

+Lookup the string as a host in the hostmap and return one rank running on that host. - -+hostmap_one_worker(string) -> location+:: Lookup the string as a host +

+
+
+hostmap_one_worker(string) → location +
+
+

+Lookup the string as a host in the hostmap and return one worker rank running on that host. - -== Defining leaf functions - -In typical Swift applications, the computationally intensive parts of +

+
+
+
+
+
+
+

13. Defining leaf functions

+
+

In typical Swift applications, the computationally intensive parts of the application are not written in the Swift language. Rather, the -work is done by _leaf functions_ that are _composed_ together with -Swift code. Leaf functions may be extension or app functions. - -The Swift runtime, Turbine, is built on Tcl, a language which intends -to makes it easy to call C/C\+\+/Fortran functions. The builtin +work is done by leaf functions that are composed together with +Swift code. Leaf functions may be extension or app functions.

+

The Swift runtime, Turbine, is built on Tcl, a language which intends +to makes it easy to call C/C++/Fortran functions. The builtin functions mentioned above are implemented as extension functions in -Tcl, which may wrap C/C++/Fortran functions. - -=== Swift extension functions - -Currently we support Tcl extension functions, where a function is +Tcl, which may wrap C/C++/Fortran functions.

+
+

13.1. Swift extension functions

+

Currently we support Tcl extension functions, where a function is implemented as a Tcl function. Tcl has good support for wrapping -native C/C\++ functions, so this provides an indirect way to call -C/C++ functions from Swift. - -Several components are required to implement a Swift native code function: - -- Tcl bindings to your function. -- The requisite files required to build a Tcl package - (e.g +pkgIndex.tcl+) -- Swift declarations for the function that specify the type of the +native C/C++ functions, so this provides an indirect way to call +C/C++ functions from Swift.

+

Several components are required to implement a Swift native code function:

+
    +
  • +

    +Tcl bindings to your function. +

    +
  • +
  • +

    +The requisite files required to build a Tcl package + (e.g pkgIndex.tcl) +

    +
  • +
  • +

    +Swift declarations for the function that specify the type of the function and the Tcl implementation. - -==== Simple Tcl fragment example - -In this example, the Swift program will simply use Tcl to output a -string: - ----- -() my_output (string s) "turbine" "0.0" [ - "puts <>" +

    +
  • +
+
+

13.1.1. Simple Tcl fragment example

+

In this example, the Swift program will simply use Tcl to output a +string:

+
+
+
() my_output (string s) "turbine" "0.0" [
+  "puts <<s>>"
 ];
 
 main {
   my_output("HELLO");
-}
-----
-
-+puts+ is the Tcl builtin for screen output, like +puts()+ in C.
-
-The above definition has, from left to right, the output arguments
+}
+
+

puts is the Tcl builtin for screen output, like puts() in C.

+

The above definition has, from left to right, the output arguments (none), the name of the new Swift function, input arguments, the name of the Tcl package containing the file (here, none, so we use -+turbine+), and the minimum version of that package (here, 0.0). - -We tell the compiler how to call our Tcl function using inline -Tcl code as a template with variable names surrounded by +<< >>+ -indicating where variables should be substituted. - -==== Simple Tcl package example - -In this first example we will implement a trivial Tcl extension function +turbine), and the minimum version of that package (here, 0.0).

+

We tell the compiler how to call our Tcl function using inline +Tcl code as a template with variable names surrounded by << >> +indicating where variables should be substituted.

+
+
+

13.1.2. Simple Tcl package example

+

In this first example we will implement a trivial Tcl extension function that doubles an integer. Here is the Tcl code that will go in -+myextension.tcl+: - ----- -namespace eval myextension { +myextension.tcl:

+
+
+
namespace eval myextension {
   proc double { x } {
     return [ expr $x * 2 ]
   }
-}
-----
-
-Here is the Swift function definition that will go in +myextension.swift+:
-----
- at pure
+}
+
+

Here is the Swift function definition that will go in myextension.swift:

+
+
+
@pure
 (int o) double (int i) "myextension" "0.0.1" [
-  "set <> [ myextension::double <> ]"
-];
-----
-
-We can also tell the Swift compiler a little about the function so
-that it can better optimize your programs.  For example, +double+ has
+  "set <<o>> [ myextension::double <<i>> ]"
+];
+
+

We can also tell the Swift compiler a little about the function so +that it can better optimize your programs. For example, double has no side-effects and produces the same result each time for the same -arguments (i.e. is deterministic), so we can annotate it as a + at pure+ -function. - -If your function has a long running time and should be dispatched to a +arguments (i.e. is deterministic), so we can annotate it as a @pure +function.

+

If your function has a long running time and should be dispatched to a worker process for execution, then you need to label the function as a -worker function, for example: - ----- - at dispatch=WORKER +worker function, for example:

+
+
+
@dispatch=WORKER
 (int o) process (int i) "pkg" "0.0.1" [
-  "set <> [ pkg::process <> ]"
-];
-----
-
-Tcl code is conventionally placed into _packages_.  In this example,
-+myextension.tcl+ would be part of the package.
-
-More information about building Tcl packages may be found
-http://www.tcl.tk/man/tcl8.5/TclCmd/pkgMkIndex.htm[here].  Ultimately,
-you produce a +pkgIndex.tcl+ file that contains necessary information
-about the package.
-
-To ensure that Swift can find your package, use
-----
-stc -r  ...
-----
-or set +TURBINE_USER_LIB+ at run time.
-
-* *Tip:* advanced users can also create <>
+  "set <<o>> [ pkg::process <<i>> ]"
+];
+
+

Tcl code is conventionally placed into packages. In this example, +myextension.tcl would be part of the package.

+

More information about building Tcl packages may be found +here. Ultimately, +you produce a pkgIndex.tcl file that contains necessary information +about the package.

+

To ensure that Swift can find your package, use

+
+
+
stc -r <package directory> ...
+
+

or set TURBINE_USER_LIB at run time.

+
    +
  • +

    +Tip: advanced users can also create standalone executables with compiled code and Tcl code for the extension directly linked in. - -==== Swift/Tcl data type mapping - -If you are defining Tcl functions in the way above with inline -Tcl code, Swift types are mapped to Tcl types in the following way: - -* +int+/+float+/+string+/+bool+ are converted to the standard +

    +
  • +
+
+
+

13.1.3. Swift/Tcl data type mapping

+

If you are defining Tcl functions in the way above with inline +Tcl code, Swift types are mapped to Tcl types in the following way:

+
    +
  • +

    +int/float/string/bool are converted to the standard Tcl representations. -* blobs are represented as a Tcl list with first element a pointer +

    +
  • +
  • +

    +blobs are represented as a Tcl list with first element a pointer to the data, the second element the length of the data, and if the blob was loaded from the ADLB data store, a third element which is the ADLB ID of the blob. -* files are represented as a list, with the first element the +

    +
  • +
  • +

    +files are represented as a list, with the first element the file path, and the second element a reference count -* arrays are represented by Tcl dictionaries with keys and values +

    +
  • +
  • +

    +arrays are represented by Tcl dictionaries with keys and values represented according to their type. -* bags are represented by Tcl lists with elements in an arbitrary +

    +
  • +
  • +

    +bags are represented by Tcl lists with elements in an arbitrary order. -* output voids are set automatically. - -==== Calling native libraries from Swift - -The first step is to test that you can successfully call your +

    +
  • +
  • +

    +output voids are set automatically. +

    +
  • +
+
+
+

13.1.4. Calling native libraries from Swift

+

The first step is to test that you can successfully call your C/C++/Fortran function from a test Tcl script. If so, you will then -be able to use the Swift->Tcl techniques to call it from Swift. - -A popular tool to automate Tcl->C bindings is -http://www.swig.org[SWIG], which will wrap your C/C++ functions and -help you produce a Tcl package suitable for use by Swift. - -To call Fortran functions, first wrap your code with -http://fortwrap.sourceforge.net[FortWrap]. Then, use SWIG to produce -Tcl bindings. - -==== Writing custom Tcl interfaces - -It is possible to write a Tcl wrapper function that is -directly passed references to data in Swift's global data store. In +be able to use the Swift→Tcl techniques to call it from Swift.

+

A popular tool to automate Tcl→C bindings is +SWIG, which will wrap your C/C++ functions and +help you produce a Tcl package suitable for use by Swift.

+

To call Fortran functions, first wrap your code with +FortWrap. Then, use SWIG to produce +Tcl bindings.

+
+
+

13.1.5. Writing custom Tcl interfaces

+

It is possible to write a Tcl wrapper function that is +directly passed references to data in Swift’s global data store. In this case your function must manually retrieve/store data from/to the global distributed data store. In this case, you do not use the STC -Tcl argument substitution syntax (+<<++i++>>+). - -Consider this custom Swift->Tcl binding: ----- -(int o) complex_function (int arr[]) "pkg" "0.0.1" "complex"; ----- - -This function jumps into Tcl function +complex+, which must -perform its own data dependency management. - -See the link:leaf.html[Swift/T Leaf Function Guide] for more -information about this process. - -[[app_functions]] -=== App functions - -App functions are functions that are implemented as command-line +Tcl argument substitution syntax (<<i>>).

+

Consider this custom Swift→Tcl binding:

+
+
+
(int o) complex_function (int arr[]) "pkg" "0.0.1" "complex";
+
+

This function jumps into Tcl function complex, which must +perform its own data dependency management.

+

See the Swift/T Leaf Function Guide for more +information about this process.

+
+
+
+

13.2. App functions

+

App functions are functions that are implemented as command-line programs. These command-line programs can be brought into a Swift program as functions with typed inputs and outputs. -An app function definition comprises: - -* The standard components of a Swift function declaration: input and +An app function definition comprises:

+
    +
  • +

    +The standard components of a Swift function declaration: input and output arguments and the function name. Note that the output - variable types are restricted to individual +file+#s#. -* The command line, which comprises an initial string which is the + variable types are restricted to individual files. +

    +
  • +
  • +

    +The command line, which comprises an initial string which is the executable to run, and then a series of arguments which are the command-line arguments to pass to the program. - -App arguments can be: - -* Literals such as numbers or strings. -* File variables (passed as file paths). -* Other variables, which are converted to string arguments. +

    +
  • +
+

App arguments can be:

+
    +
  • +

    +Literals such as numbers or strings. +

    +
  • +
  • +

    +File variables (passed as file paths). +

    +
  • +
  • +

    +Other variables, which are converted to string arguments. Arrays (including multi-dimensional arrays) are expanded to multiple arguments. -* Arbitrary expressions surrounded by parentheses. +

    +
  • +
  • +

    +Arbitrary expressions surrounded by parentheses. +

    +
  • +
+

Standard input, output and error can be redirected to files via +@stdin=, @stdout=, and @stderr= expressions. If used, these should point +to a file.

+

Here is an example of an app function that joins multiple files +with the cat utility:

+
+
+
import files;
 
-Standard input, output and error can be redirected to files via
-+ at stdin=+, + at stdout=+, and + at stderr=+ expressions.  If used, these should point
-to a +file+.
-
-Here is an example of an app function that joins multiple files
-with the +cat+ utility:
-----
-import files;
-
 app (file out) cat (file inputs[]) {
   "/bin/cat" inputs @stdout=out
 }
 
 main {
-  file joined <"joined.txt"> = cat(glob("*.txt"));
-}
-----
-
-Here is an example of an app function that sleeps for an arbitrary
-amount of time:
-----
-
-app (void signal) sleep (int secs) {
+  file joined <"joined.txt"> = cat(glob("*.txt"));
+}
+
+

Here is an example of an app function that sleeps for an arbitrary +amount of time:

+
+
+
app (void signal) sleep (int secs) {
   "/bin/sleep" secs
 }
 
@@ -1382,48 +2772,44 @@
       trace("Slept " + fromint(time));
     }
   }
-}
-----
-
-=== External scripting support
-
-==== Calling Python
-
-You can evaluate arbitrary Python code from within Swift/T.  For
+}
+
+
+
+

13.3. External scripting support

+
+

13.3.1. Calling Python

+

You can evaluate arbitrary Python code from within Swift/T. For example, you can perform processing with a Python library. Once you have that working, you can use Swift/T to coordinate -concurrent calls to that library. - -Consider the following Swift script: - ----- -import io; +concurrent calls to that library.

+

Consider the following Swift script:

+
+
+
import io;
 import python;
 
 main {
   i = python("print(\"python works\")\nrepr(2+2)");
   printf("i: %s", i);
-}
-----
-
-This simply evaluates the Python code line by line. The last line must
+}
+
+

This simply evaluates the Python code line by line. The last line must return a Python string to Swift, in this case, the Python string -+'4'+. The expected output is shown below: - ----- -python works -i: 4 ----- - -Swift multi-line strings may be used to enter more complex Python code -without the explicit use of +\n+. - -Additionally, you can call Python libraries such as -http://www.numpy.org[Numpy] if available on your system. The -following code adds matrices _I_~3~ + _I_~3~ using Numpy arrays. - ----- -import io; +'4'. The expected output is shown below:

+
+
+
python works
+i: 4
+
+

Swift multi-line strings may be used to enter more complex Python code +without the explicit use of \n.

+

Additionally, you can call Python libraries such as +Numpy if available on your system. The +following code adds matrices I3 + I3 using Numpy arrays.

+
+
+
import io;
 import python;
 import string;
 
@@ -1453,42 +2839,48 @@
   matrix A2 = eye(3);
   matrix sum = add(A1, A2);
   printf("2*eye(3)=%s", sum);
-}
-----
-
-An Python script template is created that imports Numpy and performs
+}
+
+

An Python script template is created that imports Numpy and performs some simple calculations. This code is represented in a Swift string. -The template is filled in by the Swift call to +sprintf()+. Then, the -code is passed to Python for evaluation. The output is: - ----- -2*eye(3)=array([[ 2., 0., 0.], +The template is filled in by the Swift call to sprintf(). Then, the +code is passed to Python for evaluation. The output is:

+
+
+
2*eye(3)=array([[ 2.,  0.,  0.],
                 [ 0.,  2.,  0.],
-                [ 0.,  0.,  2.]])
-----
-
-NOTE: To use this, Turbine must be configured with Python enabled
- before compiling, by setting +ENABLE_PYTHON=1+
- in +exm-settings.sh+, or by providing the +--enable-python+ argument
- to +configure+.  This feature is implemented by linking to Python
+                [ 0.,  0.,  2.]])
+
+
+ + + +
+
Note
+
To use this, Turbine must be configured with Python enabled + before compiling, by setting ENABLE_PYTHON=1 + in exm-settings.sh, or by providing the --enable-python argument + to configure. This feature is implemented by linking to Python as a shared library, enabling better performance than calling the - +python+ program (which may be done by using a normal Swift - <>). Error messages for minor coding + python program (which may be done by using a normal Swift + app function). Error messages for minor coding mistakes may be badly mangled and refer to missing Python symbols- - refer to the first error in the Python stack trace. - -==== Calling R - -Consider the following Swift script: ----- -import io; + refer to the first error in the Python stack trace.
+
+
+
+

13.3.2. Calling R

+

Consider the following Swift script:

+
+
+
import io;
 import string;
 import R;
 
 global const string template =
 """
-  x <- %i
-  a <- x+100
+  x <- %i
+  a <- x+100
   cat("the answer is: ", a, "\\n")
   a
 """;
@@ -1498,38 +2890,42 @@
   code = sprintf(template, 4);
   s = R(code);
   printf("the answer was: %i", s);
-}
-----
-
-An http://www.r-project.org[R language] script template is placed in a
+}
+
+

An R language script template is placed in a Swift string. The template is filled in with the value 4 by the Swift -call to +sprintf()+ (note the +%i+ conversion specifier). Then, the -code is passed to R for evaluation. The output is: - ----- -the answer is: 104 -the answer was: 104 ----- - -As coded here, both R and Swift report the value of +a+. - -NOTE: To use this, Turbine must be configured with R enabled - before compiling, by setting +ENABLE_R=1+ - in +exm-settings.sh+, or by providing the +--enable-r+ argument - to +configure+. This feature is implemented by linking to R as a shared - library, enabling better performance than calling the +R+ program - (which may be done by using a normal Swift <>). When installing R, be sure to include the +devel+ +call to sprintf() (note the %i conversion specifier). Then, the +code is passed to R for evaluation. The output is:

+
+
+
the answer is:  104
+the answer was: 104
+
+

As coded here, both R and Swift report the value of a.

+
+ + + +
+
Note
+
To use this, Turbine must be configured with R enabled + before compiling, by setting ENABLE_R=1 + in exm-settings.sh, or by providing the --enable-r argument + to configure. This feature is implemented by linking to R as a shared + library, enabling better performance than calling the R program + (which may be done by using a normal Swift app function). When installing R, be sure to include the devel package. When installing R from source, configure with - +--enable-R-shlib+. You may need to set the environment variable - +R_HOME+ to the directory containing the R installation. For the APT - package, this is +/usr/lib/R+. - -==== Calling Julia - -Consider the following Swift script: ----- -import io; + --enable-R-shlib. You may need to set the environment variable + R_HOME to the directory containing the R installation. For the APT + package, this is /usr/lib/R.
+
+
+
+

13.3.3. Calling Julia

+

Consider the following Swift script:

+
+
+
import io;
 import julia;
 import string;
 import sys;
@@ -1553,108 +2949,103 @@
   wait (s1, s2, s3) {
     printf("duration: %0.2f", clock()-start);
   }
-}
-----
-
-In this example, a http://julialang.org[Julia] script is placed in
-string +f+.  It is parameterized three times by +sprintf()+.  Each
+}
+
+

In this example, a Julia script is placed in +string f. It is parameterized three times by sprintf(). Each Julia invocation runs concurrently (if enough processes are provided -to Swift/T). - -NOTE: To use this, Turbine must be configured with Julia enabled - before compiling, by providing the +--enable-julia+ argument - to +configure+. This feature is implemented by linking to Julia +to Swift/T).

+
+ + + +
+
Note
+
To use this, Turbine must be configured with Julia enabled + before compiling, by providing the --enable-julia argument + to configure. This feature is implemented by linking to Julia as a shared library, enabling better performance than calling the - +julia+ program (which may be done by using a normal Swift - <>). - -[[annotations]] -== Annotations - -Swift/T supports many annotations to influence the behavior of the -run. - -=== Priority - -Leaf tasks resulting from Swift dataflow may be prioritized by using -the + at prio+ annotation: - ----- -foreach i in [0:n-1] { + julia program (which may be done by using a normal Swift + app function).
+
+
+
+
+
+
+

14. Annotations

+
+

Swift/T supports many annotations to influence the behavior of the +run.

+
+

14.1. Priority

+

Leaf tasks resulting from Swift dataflow may be prioritized by using +the @prio annotation:

+
+
+
foreach i in [0:n-1] {
   @prio=i f(i);
-}
-----
-
-In this case, +f()+ will operate on higher values of +i+ first.
+}
+
+

In this case, f() will operate on higher values of i first. Priority is best-effort; it is local to the ADLB server. The values -of +i+ may be any Swift integer. - -This annotation is applied to the leaf task call. - -[[location]] -=== Location - -Leaf tasks resulting from Swift dataflow may be assigned to a given -processor by using the + at location+ annotation: - ----- -foreach i in [0:n-1] { +of i may be any Swift integer.

+

This annotation is applied to the leaf task call.

+
+
+

14.2. Location

+

Leaf tasks resulting from Swift dataflow may be assigned to a given +processor by using the @location annotation:

+
+
+
foreach i in [0:n-1] {
   location L = location_from_rank(i);
   @location=L f(i);
-}
-----
-
-In this case, each +f(i)+ will execute on a different worker.
-
-This annotation is applied to the leaf task call.
-
-==== Hostmap
-
-At startup, by default, Turbine obtains all hostnames used in the run
+}
+
+

In this case, each f(i) will execute on a different worker.

+

This annotation is applied to the leaf task call.

+
+

14.2.1. Hostmap

+

At startup, by default, Turbine obtains all hostnames used in the run and builds up a data structure called the hostmap to map hostnames to ranks. You may combine the location features with the hostmap features to send work to assigned hostnames. See the -<> for usage. The hostmap may be -<> or <>. - -=== Dispatch - -This simply dispatches tasks to the given process type: +WORKER+ or -+SERVER+. By default, work executes on a +SERVER+. - ----- - at dispatch=WORKER +Location library for usage. The hostmap may be +debugged or disabled.

+
+
+
+

14.3. Dispatch

+

This simply dispatches tasks to the given process type: WORKER or +SERVER. By default, work executes on a SERVER.

+
+
+
@dispatch=WORKER
 (int o) process (int i) "pkg" "0.0.1" [
-  "set <> [ pkg::process <> ]"
-];
-----
-
-Swift/T builtin functions (+strcat()+, arithmetic, etc.) are typically
+  "set <<o>> [ pkg::process <<i>> ]"
+];
+
+

Swift/T builtin functions (strcat(), arithmetic, etc.) are typically implemented in this way as tasks that execute on the server. User work should be performed on workers to keep servers free to process -dataflow. - -This annotation is applied to the leaf task definition. - -//// - -=== Work types - -Tim? - -//// - -[[Optimizations]] -== Optimizations -STC performs a range of compiler optimizations that can significantly +dataflow.

+

This annotation is applied to the leaf task definition.

+
+
+
+
+

15. Optimizations

+
+

STC performs a range of compiler optimizations that can significantly speed up most Swift programs. The optimization level can be controlled -by the +-O+ command line option. The default optimization -level +-O2+, or the increased optimization level +-O3+ are usually -the best choices. Some applications benefit markedly from +-O3+, -while others do not, and compile times can increase slightly. - ----- -# No optimizations at all (not recommended) +by the -O command line option. The default optimization +level -O2, or the increased optimization level -O3 are usually +the best choices. Some applications benefit markedly from -O3, +while others do not, and compile times can increase slightly.

+
+
+
# No optimizations at all (not recommended)
 stc -O0 example.swift example.tcl
 
 # Basic optimizations (not recommended)
@@ -1666,200 +3057,382 @@
 stc -O2 example.swift example.tcl
 
 # All optimizations (also recommended)
-stc -O3 example.swift example.tcl
-----
-
-Individual optimizations can be toggled on using +-T +
-or off with +-t +, but this typically is only useful for
+stc -O3 example.swift example.tcl
+
+

Individual optimizations can be toggled on using -T <opt name> +or off with -t <opt name>, but this typically is only useful for debugging. You can find an up-to-date list of optimizations in -the stc command-line help: - ----- -stc -h ----- - -[[Turbine]] -== Running in Turbine - -The following describes how to run Turbine programs. - -=== Architecture - -Turbine runs as an MPI program consisting of many processes. Turbine +the stc command-line help:

+
+
+
stc -h
+
+
+
+
+

16. Running in Turbine

+
+

The following describes how to run Turbine programs.

+
+

16.1. Architecture

+

Turbine runs as an MPI program consisting of many processes. Turbine programs are ADLB programs. Thus, they produce and execute discrete -tasks that are distributed and load balanced at run time. - -Each process runs in a _mode_: _worker_, or _server_. - -Workers:: Evaluate the Swift logic. Produce tasks. Execute tasks. -Servers:: Distributes tasks. Manages data. - -Typical Swift programs perform compute-intensive work in leaf +tasks that are distributed and load balanced at run time.

+

Each process runs in a mode: worker, or server.

+
+
+Workers +
+
+

+Evaluate the Swift logic. Produce tasks. Execute tasks. +

+
+
+Servers +
+
+

+Distributes tasks. Manages data. +

+
+
+

Typical Swift programs perform compute-intensive work in leaf functions that execute on workers. -Execution of the Swift logic is split and distributed among workers. - -Servers distribute tasks in a scalable, load balanced manner. They -also store Swift data (integers, strings, etc.). - -=== Concurrency - -The available concurrency and efficiency in your Swift script is -limited by the following factors: - -* The available concurrency in the Swift logic. Sequential - dependencies will be evaluated sequentially. +foreach+ loops and +Execution of the Swift logic is split and distributed among workers.

+

Servers distribute tasks in a scalable, load balanced manner. They +also store Swift data (integers, strings, etc.).

+
+
+

16.2. Concurrency

+

The available concurrency and efficiency in your Swift script is +limited by the following factors:

+
    +
  • +

    +The available concurrency in the Swift logic. Sequential + dependencies will be evaluated sequentially. foreach loops and branching function calls may be evaluated concurrently -* The number of workers available to process leaf functions +

    +
  • +
  • +

    +The number of workers available to process leaf functions concurrently -* The number of servers available to control the Turbine run. +

    +
  • +
  • +

    +The number of servers available to control the Turbine run. Adding more servers can improve performance for applications with small tasks or complex data dependencies but ties up processes - -=== Invocation - -The form of a Turbine invocation for STC-generated -+program.tcl+ is: - ----- -turbine ----- - -The program arguments are available to Swift (<>). - -Turbine accepts the following arguments: - -+-f +:: Provide a machine file to +mpiexec+ -+-h+:: Print a help message -+-l+:: Enable +mpiexec -l+ ranked output formatting -+-n +:: The total number of Turbine MPI processes -+-v+:: Report the Turbine version number -+-V+:: Make the Turbine launch script verbose -+-x+:: Use turbine_sh launcher with compiled-in libraries instead of tclsh +

    +
  • +
+
+
+

16.3. Invocation

+

The form of a Turbine invocation for STC-generated +program.tcl is:

+
+
+
turbine <turbine arguments> <program.tcl> <program arguments>
+
+

The program arguments are available to Swift ([argv]).

+

Turbine accepts the following arguments:

+
+
+-f <file> +
+
+

+Provide a machine file to mpiexec +

+
+
+-h +
+
+

+Print a help message +

+
+
+-l +
+
+

+Enable mpiexec -l ranked output formatting +

+
+
+-n <procs> +
+
+

+The total number of Turbine MPI processes +

+
+
+-v +
+
+

+Report the Turbine version number +

+
+
+-V +
+
+

+Make the Turbine launch script verbose +

+
+
+-x +
+
+

+Use turbine_sh launcher with compiled-in libraries instead of tclsh (reduces number of files that must be read from file system) -+-X+:: In place of of program.tcl, run standalone Turbine executable - (e.g. created by <>) - -The user controls the Turbine run time configuration through -environment variables: - -+ADLB_SERVERS+:: Number of ADLB servers - -The remaining processes are workers. These values are available to -Swift (<>). - -+TURBINE_LOG=0+:: Disable logging. +TURBINE_LOG=1+ or unset enables +

+
+
+-X +
+
+

+In place of of program.tcl, run standalone Turbine executable + (e.g. created by mkstatic.tcl) +

+
+
+

The user controls the Turbine run time configuration through +environment variables:

+
+
+ADLB_SERVERS +
+
+

+Number of ADLB servers +

+
+
+

The remaining processes are workers. These values are available to +Swift (Turbine information).

+
+
+TURBINE_LOG=0 +
+
+

+Disable logging. TURBINE_LOG=1 or unset enables logging, assuming logging was not disabled at configure time. Logging goes to tandard output by default. - -+TURBINE_LOG_FILE=+:: Set log file location. Defaults to +

+
+
+TURBINE_LOG_FILE=<file> +
+
+

+Set log file location. Defaults to standard output. - -+TURBINE_LOG_RANKS=1+:: Using +turbine -l+ or equivalent prepend the +

+
+
+TURBINE_LOG_RANKS=1 +
+
+

+Using turbine -l or equivalent prepend the MPI rank number to each output line. This works with typical MPICH or OpenMPI systems, however, this is not available on some systems, so set this to emulate the rank output on such systems. - -+ADLB_PRINT_TIME=1+:: Enable a short report of total elapsed time (via -+MPI_Wtime()+) - -+ADLB_PERF_COUNTERS=1+:: +

+
+
+ADLB_PRINT_TIME=1 +
+
+

+Enable a short report of total elapsed time (via +MPI_Wtime()) +

+
+
+ADLB_PERF_COUNTERS=1 +
+
+

Enable performance counters (printed at end of execution). The -link:internals.html[Swift/T internals guide] has information +Swift/T internals guide has information about interpreting the output. - -+ADLB_EXHAUST_TIME+:: +

+
+
+ADLB_EXHAUST_TIME +
+
+

Time in seconds taken by ADLB task servers to shut down. May include a decimal point. Default 0.1 . Setting this lower will reduce delay in detection exhaustion. Setting this higher will reduce overhead due to failed exhaust checks. The default setting is almost always adequate. - -+ADLB_REPORT_LEAKS=1+:: +

+
+
+ADLB_REPORT_LEAKS=1 +
+
+

Enable reporting of any unfreed data in ADLB data store at end of execution. - -+ADLB_TRACE=true+:: -+ADLB_DEBUG=true+:: +

+
+
+ADLB_TRACE=true +
+
+ADLB_DEBUG=true +
+
+

To print DEBUG/TRACE level information for ADLB (if ADLB was compiled with it enabled) - -+TURBINE_LAUNCH_OPTIONS+:: -Provide other arguments to +mpiexec+, such as a machine file, etc. - -+TURBINE_SRAND+:: +

+
+
+TURBINE_LAUNCH_OPTIONS +
+
+

+Provide other arguments to mpiexec, such as a machine file, etc. +

+
+
+TURBINE_SRAND +
+
+

If unset or empty, the random number generator seed will be set to the process rank for each process, giving reproducible results. If set to -an integer +seed+, the random number generator seed for each process -will be set to +seed+ + +rank+. -+ -For non-reproducible random results, use the following shell commands: -+ ----- -export TURBINE_SRAND=$( date +%s ) -turbine ... ----- -+ -The seed is recorded in the log. - -+ADLB_DEBUG_RANKS=1+:: Enable a report showing the rank and hostname +an integer seed, the random number generator seed for each process +will be set to seed + rank. +

+

For non-reproducible random results, use the following shell commands:

+
+
+
export TURBINE_SRAND=$( date +%s )
+turbine ...
+
+

The seed is recorded in the log.

+
+
+ADLB_DEBUG_RANKS=1 +
+
+

+Enable a report showing the rank and hostname of each process. This allows you to determine whether your process layout on a given machine is as intended. - -anchor:env_hostmap_debug[] - -+ADLB_DEBUG_HOSTMAP=1+:: Enable a report showing the hostmap, which +

+
+
+

+
+
+ADLB_DEBUG_HOSTMAP=1 +
+
+

+Enable a report showing the hostmap, which maps hostnames to ranks for use with the location functionality. - -anchor:env_hostmap_disable[] - -+ADLB_DISABLE_HOSTMAP=1+:: Prevent the hostmap from being constructed +

+
+
+

+
+
+ADLB_DISABLE_HOSTMAP=1 +
+
+

+Prevent the hostmap from being constructed (avoiding some communication overhead). - -+VALGRIND+:: Enable valgrind debugging. Cf. <>. - -+GDB_RANK+:: Enable GDB debugging. Cf. <>. - -[[Build_configuration]] -=== Build configuration - -The following describes how to run Swift/T programs in Turbine -on more complex systems. - -==== Build troubleshooting - -If +exm-setup.zsh+ does not succeed, you may need to change how it -tries to configure and compile Swift/T. - -Troubleshooting a build problem can require a few steps. The first -step is to determine why the build failed. +exm-setup.zsh+ will usually +

+
+
+VALGRIND +
+
+

+Enable valgrind debugging. Cf. valgrind. +

+
+
+GDB_RANK +
+
+

+Enable GDB debugging. Cf. GDB. +

+
+
+
+
+

16.4. Build configuration

+

The following describes how to run Swift/T programs in Turbine +on more complex systems.

+
+

16.4.1. Build troubleshooting

+

If exm-setup.zsh does not succeed, you may need to change how it +tries to configure and compile Swift/T.

+

Troubleshooting a build problem can require a few steps. The first +step is to determine why the build failed. exm-setup.zsh will usually report the step at which configuration failed. For example, if it was unable to locate a valid Tcl install, it will report this. Then you can try -these steps to resolve the problem: - -1. If your system is covered by the link:turbine-sites.html[Sites Guide], +these steps to resolve the problem:

+
    +
  1. +

    +If your system is covered by the Sites Guide, check to see if the problem and solution are described there. -2. Inspect +exm-settings.sh+ settings related to the reported problem. +

    +
  2. +
  3. +

    +Inspect exm-settings.sh settings related to the reported problem. For example, if locating a Tcl install failed, setting - the +TCL_INSTALL+ and +TCL_VERSION+ variables to the correct location + the TCL_INSTALL and TCL_VERSION variables to the correct location and version may help. -3. If the options in +exm-settings.sh+ do not give sufficient control to +

    +
  4. +
  5. +

    +If the options in exm-settings.sh do not give sufficient control to fix the problem, you may need to manually configure some components of Swift/T, as described in the next section. - -[[Manual_build_configuration]] -==== Manual configuration -+exm-setup.zsh+ and +exm-settings.sh+ provide a convenient way to install +

    +
  6. +
+
+
+

16.4.2. Manual configuration

+

exm-setup.zsh and exm-settings.sh provide a convenient way to install Swift/T. However, this method does not allow full control over the configuration. Swift/T is built with standard Ant (Java) and Autotools/Makefile (C,Tcl) techniques. You can more directly control -the configuration when building through the arguments to +ant+ or -+configure+. - -To perform the installation using +configure+/+make+, simply untar the -distribution package and do: - ----- -cd c-utils +the configuration when building through the arguments to ant or +configure.

+

To perform the installation using configure/make, simply untar the +distribution package and do:

+
+
+
cd c-utils
 ./configure ...
 make install
 
@@ -1872,215 +3445,339 @@
 make install
 
 cd ../stc
-ant install -Ddist.dir=... -Dturbine.home=...
-----
-
-* You may use +./configure --help+ and the
-  link:turbine-sites.html[Sites Guide] for further options.
-
-==== Non-standard MPI locations
-Sometimes simply specifying the MPI directory is not enough to
-configure Swift/T.
-
-You can modify these settings in +exm-settings.sh+ to more precisely
-define locations of MPI resources:
-
-----
-EXM_CUSTOM_MPI=1
+ant install -Ddist.dir=... -Dturbine.home=...
+
+
    +
  • +

    +You may use ./configure --help and the + Sites Guide for further options. +

    +
  • +
+
+
+

16.4.3. Non-standard MPI locations

+

Sometimes simply specifying the MPI directory is not enough to +configure Swift/T.

+

You can modify these settings in exm-settings.sh to more precisely +define locations of MPI resources:

+
+
+
EXM_CUSTOM_MPI=1
 MPI_INCLUDE=/path/to/mpi.h/include
 MPI_LIB_DIR=/path/to/mpi_lib/lib
-MPI_LIB_NAME=funny.mpi.a
-----
-
-If you are following the manual build process, configure Turbine with:
-----
- --enable-custom --with-mpi-include=/path/to/mpi.h/include
+MPI_LIB_NAME=funny.mpi.a
+
+

If you are following the manual build process, configure Turbine with:

+
+
+
 --enable-custom --with-mpi-include=/path/to/mpi.h/include
                  --with-mpi-lib-dir=/path/to/mpi_lib/lib
-                 --with-mpi-lib-name=funny.mpi.a
-----
-
-
-=== Performance enhancements
-
-1. Disable logging/debugging via environment
-2. Disable logging/debugging at configure/compile time
-+
-** Configure c-utils with +--disable-log+
-+
-3. Specify +EXM_OPT_BUILD=1+ in +exm-settings.sh+ or configure everything
-    with +--enable-fast+.  This disables assertions and other checks
-4. When making performance measurements, always subtract 0.1 seconds
-   (or the value of +ADLB_EXHAUST_TIME+) from the Turbine run time
+                 --with-mpi-lib-name=funny.mpi.a
+
+
+
+
+

16.5. Performance enhancements

+
    +
  1. +

    +Disable logging/debugging via environment +

    +
  2. +
  3. +

    +Disable logging/debugging at configure/compile time +

    +
      +
    • +

      +Configure c-utils with --disable-log +

      +
    • +
    +
  4. +
  5. +

    +Specify EXM_OPT_BUILD=1 in exm-settings.sh or configure everything + with --enable-fast. This disables assertions and other checks +

    +
  6. +
  7. +

    +When making performance measurements, always subtract 0.1 seconds + (or the value of ADLB_EXHAUST_TIME) from the Turbine run time due to the ADLB shutdown protocol, which does not start until the system is idle for that amount of time. -5. Reduce the number of program files that must be read off the +

    +
  8. +
  9. +

    +Reduce the number of program files that must be read off the filesystem. This is particularly useful for parallel file systems and large scale applications. In increasing order of effectiveness, you can: -** use the turbine_sh launcher in place of tclsh in submit script, - or by specifying the +-x+ argument to +turbine+ -** Use <> to create a standalone executable with +

    +
      +
    • +

      +use the turbine_sh launcher in place of tclsh in submit script, + or by specifying the -x argument to turbine +

      +
    • +
    • +

      +Use mkstatic.tcl to create a standalone executable with the Tcl main script and Tcl library code compiled in, and compiled code statically linked. - -[[mkstatic]] -=== Building standalone executables with mkstatic.tcl -It is possible to build a fully self-contained executable, including +

      +
    • +
    +
  10. +
+
+
+

16.6. Building standalone executables with mkstatic.tcl

+

It is possible to build a fully self-contained executable, including all Tcl scripts and compiled code, provided that all dependencies support static linking. If not, it is also possible to build an executable with a subset of Tcl scripts and code linked in, providing some performance -benefits. - -The provided +mkstatic.tcl+ utility can produce a C source +benefits.

+

The provided mkstatic.tcl utility can produce a C source file with Tcl scripts bundled in, which can then be compiled and linked with a C compiler. This is a multi-step process that can be automated -as part of your build process. - -NOTE: Ensure that static versions of the +c-utils+, +lb+, and +turbine+ libraries - were built, typically with a +.a+ suffix, e.g. +libadlb.a+. These - are created by default, unless you specified +DISABLE_STATIC=0+ or - +--disable-static+. To build a fully standalone +as part of your build process.

+
+ + + +
+
Note
+
Ensure that static versions of the c-utils, lb, and turbine libraries + were built, typically with a .a suffix, e.g. libadlb.a. These + are created by default, unless you specified DISABLE_STATIC=0 or + --disable-static. To build a fully standalone executable, you will also need to build a static version of Tcl - (with the +--disable-shared+ configure option), and static versions + (with the --disable-shared configure option), and static versions of any other libraries your own code needs to link with, such - as your MPI distribution or application code. - -1. Compile your Swift script -+ ----- -stc my.swift ----- -+ -producing the Turbine Tcl script +my.tcl+. - -2. Create a manifest file, e.g. +my.manifest+. This file describes the + as your MPI distribution or application code.
+
+
    +
  1. +

    +Compile your Swift script +

    +
    +
    +
    stc my.swift
    +
    +

    producing the Turbine Tcl script my.tcl.

    +
  2. +
  3. +

    +Create a manifest file, e.g. my.manifest. This file describes the resources to be bundled, including the STC-generated code and any user libraries. -+ -To do this, make a copy of +scripts/mkstatic/example.manifest+ from +

    +

    To do this, make a copy of scripts/mkstatic/example.manifest from the Turbine installation directory. This file contains examples and descriptions of all the the possible settings. Note that an empty -manifest file corresponds to the +turbine_sh+ utility, which is a -replacement for +tclsh+ with required Turbine libraries statically +manifest file corresponds to the turbine_sh utility, which is a +replacement for tclsh with required Turbine libraries statically linked in. For a simple Swift program with no user Tcl libraries, -you only need to set +main_script = my.tcl+. - -3. Invoke +mkstatic.tcl+ (found under +scripts/mkstatic/mkstatic.tcl+ in +you only need to set main_script = my.tcl.

    +
  4. +
  5. +

    +Invoke mkstatic.tcl (found under scripts/mkstatic/mkstatic.tcl in the Turbine installation) to translate your Tcl script to a C main - program (e.g., +my_main.c+) with Tcl source code included. + program (e.g., my_main.c) with Tcl source code included. The minimal invocation is -+ ----- -mkstatic.tcl my.manifest -c my_main.c ----- -+ -You will likely wish to include Tcl system libraries with -+--include-sys-lib /home/example/tcl-install/lib --tcl-version 8.6+. +

    +
    +
    +
    mkstatic.tcl my.manifest -c my_main.c
    +
    +

    You will likely wish to include Tcl system libraries with +--include-sys-lib /home/example/tcl-install/lib --tcl-version 8.6. The Tcl system library directory can be identified by the fact that -it contains the file +init.tcl+. This directory must be specified -with a special flag so that +mkstatic.tcl+ can correctly replace -the regular Tcl initialization process. -+ -You can include additional libraries and packages with -+--include-lib /home/example/tcl-lib/+. Any +.tcl+ or +.tm+ source files +it contains the file init.tcl. This directory must be specified +with a special flag so that mkstatic.tcl can correctly replace +the regular Tcl initialization process.

    +

    You can include additional libraries and packages with +--include-lib /home/example/tcl-lib/. Any .tcl or .tm source files in the directory will be included. Source-only packages can generally be completely linked into the executable, but if a package -loads shared libraries, only the +pkgIndex.tcl+ file will be linked +loads shared libraries, only the pkgIndex.tcl file will be linked into the executable. A package with compiled code can be converted to support static linking by specifying a package init function, plus -static library or object files in the manifest file. -+ -4. Link together the compiled C main program with user libraries and +static library or object files in the manifest file.

    +
  6. +
  7. +

    +Link together the compiled C main program with user libraries and Swift/T libraries to produce a final executable. The details of the process vary depending on the compiler and system: we assume GCC. You will need to provide the correct flags to link in all libraries required by Swift/T or your own user code. -** *User code:* you must identify the libraries used by your application +

    +
      +
    • +

      +User code: you must identify the libraries used by your application and ensure link flags are provided. If linking static libraries, ensure that any indirect dependencies of these libraries are also linked. -** *Swift/T system:* The Turbine distribution includes a helper script, - +turbine-build-config.sh+, that can be sourced to obtain linker flags +

      +
    • +
    • +

      +Swift/T system: The Turbine distribution includes a helper script, + turbine-build-config.sh, that can be sourced to obtain linker flags for Swift/T dependencies. -** *Link order:* In the case of static linking, if *libA* depends on *libB*, - then the +-lA+ flag must precede +-lB+ on the command line. To +

      +
    • +
    • +

      +Link order: In the case of static linking, if libA depends on libB, + then the -lA flag must precede -lB on the command line. To actually do the linking, there are two further cases to consider: -*** If building a fully static executable, you can - provide the +-static+ flag, plus all object files, plus +-L+ - and +-l+ flags for all required library directories and libraries. -+ ----- -gcc -static script_main.c file1.o file2.o -L/path/to/lib/dir -lsomething ... ----- -+ -*** If you are building an executable that depends on one or more shared - libraries, you will need to provide the +-dynamic+ flag, and then +

      +
        +
      • +

        +If building a fully static executable, you can + provide the -static flag, plus all object files, plus -L + and -l flags for all required library directories and libraries. +

        +
        +
        +
        gcc -static script_main.c file1.o file2.o -L/path/to/lib/dir -lsomething ...
        +
        +
      • +
      • +

        +If you are building an executable that depends on one or more shared + libraries, you will need to provide the -dynamic flag, and then ensure that static libraries are linked statically. If a shared - version of a library is available, +gcc+ will use that in preference + version of a library is available, gcc will use that in preference to a static version. You can override this behaviour by specifying - +-Wl,-Bstatic+ on the command line before the flags for the libraries - you wish to statically link, then +-Wl,-Bdynamic+ to reset to + -Wl,-Bstatic on the command line before the flags for the libraries + you wish to statically link, then -Wl,-Bdynamic to reset to dynamic linking for any libraries after those. - -We have described the most commonly-used options. A full list of options -and descriptions can be obtained by invoking +mkstatic.tcl -h+. -Additional options include: - -+--main-script+:: Specify Tcl main script (overrides manifest file) -+-r+:: Specify non-standard variable prefix for C code -+-v+:: Print verbose messages -+--deps+:: Generate Makefile include for generating C file -+--ignore-no-manifest+:: Pretend empty manifest present - -[[debugging]] -=== Debugging Swift/T runs - -Applying the debugger allows you to debug native code linked to Swift/T +

        +
      • +
      +
    • +
    +
  8. +
+

We have described the most commonly-used options. A full list of options +and descriptions can be obtained by invoking mkstatic.tcl -h. +Additional options include:

+
+
+--main-script +
+
+

+Specify Tcl main script (overrides manifest file) +

+
+
+-r +
+
+

+Specify non-standard variable prefix for C code +

+
+
+-v +
+
+

+Print verbose messages +

+
+
+--deps +
+
+

+Generate Makefile include for generating C file +

+
+
+--ignore-no-manifest +
+
+

+Pretend empty manifest present +

+
+
+
+
+

16.7. Debugging Swift/T runs

+

Applying the debugger allows you to debug native code linked to Swift/T from a normal debugger. This will allow you to step through your code -(and the Swift/T run time libraries). - -* When using Swift/T dynamically with Tcl packages (the default), you - need to attach to the +tclsh+ process. This process loads your +(and the Swift/T run time libraries).

+
    +
  • +

    +When using Swift/T dynamically with Tcl packages (the default), you + need to attach to the tclsh process. This process loads your native code and calls into it. -* When using +mkstatic+, you generate a complete executable. You can +

    +
  • +
  • +

    +When using mkstatic, you generate a complete executable. You can debug this in the normal method for debugging MPI programs. - -[[valgrind]] -==== Valgrind - -The Swift/T launcher scripts support http://valgrind.org[valgrind]. -Simply set the environment variable +VALGRIND+ to the valgrind command +

    +
  • +
+
+

16.7.1. Valgrind

+

The Swift/T launcher scripts support valgrind. +Simply set the environment variable VALGRIND to the valgrind command you wish to use. A suppressions file is distributed with Turbine to ignore known issues. (Swift/T is valgrind-clean but there are some -issues in Tcl.) - ----- -export VALGRIND="valgrind --suppressions=$HOME/turbine/turbine.supp" -turbine program.tcl ----- - -[[gdb]] -==== GDB - -The Turbine library provides a convenient attachment mechanism +issues in Tcl.)

+
+
+
export VALGRIND="valgrind --suppressions=$HOME/turbine/turbine.supp"
+turbine program.tcl
+
+
+
+

16.7.2. GDB

+

The Turbine library provides a convenient attachment mechanism compatible with debuggers like GDB, Eclipse, etc. You attach to a -Turbine execution by using the +GDB_RANK+ variable: - ----- -$ export GDB_RANK=0 +Turbine execution by using the GDB_RANK variable:

+
+
+
$ export GDB_RANK=0
 $ turbine program.tcl
 Waiting for gdb: rank: 0 pid: 23274
-...
-----
-
-Rank 0, running in process +23274+, has blocked (in a loop) and is
+...
+
+

Rank 0, running in process 23274, has blocked (in a loop) and is waiting for the debugger to attach. When you attach, set the variable -+t=1+ to break out of the loop. Then you can debug normally. - -//// -Local Variables: -mode: doc -eval: (auto-fill-mode 1) -End: -//// +t=1 to break out of the loop. Then you can debug normally.

+
+
+
+
+
+

+ + +