[Swift-commit] r8097 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas
wozniak at ci.uchicago.edu
wozniak at ci.uchicago.edu
Tue Aug 12 11:09:05 CDT 2014
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 <builtins.swift>
+#include <io.swift>
+#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);
+}
More information about the Swift-commit
mailing list