[Swift-commit] r8179 - SwiftTutorials/ATPESC_2014-08-14/swift-t

wozniak at ci.uchicago.edu wozniak at ci.uchicago.edu
Thu Aug 14 10:50:58 CDT 2014


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!




More information about the Swift-commit mailing list