[Swift-commit] r8102 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/03-blas
wozniak at ci.uchicago.edu
wozniak at ci.uchicago.edu
Tue Aug 12 11:35:09 CDT 2014
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 <<z>> [ blas::ddot_impl <<n>> <<x>> <<y>> ]
+----
+];
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 <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