[Swift-commit] r6644 - in trunk: resources src/org/griphyn/vdl/karajan/lib

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Fri Jul 12 20:36:13 CDT 2013


Author: hategan
Date: 2013-07-12 20:36:13 -0500 (Fri, 12 Jul 2013)
New Revision: 6644

Modified:
   trunk/resources/Karajan.stg
   trunk/src/org/griphyn/vdl/karajan/lib/ThrottledParallelFor.java
Log:
fixed foreach tracing

Modified: trunk/resources/Karajan.stg
===================================================================
--- trunk/resources/Karajan.stg	2013-07-13 01:34:36 UTC (rev 6643)
+++ trunk/resources/Karajan.stg	2013-07-13 01:36:13 UTC (rev 6644)
@@ -205,8 +205,8 @@
 }
 >>
 
-foreach(var, in, indexVar, indexVarType, declarations, statements, line, refs, selfClose, cleanups, trace) ::= <<
-swift:tParallelFor(\$$if(trace)$, _traceline="$line$"$endif$$if(indexVar)$, _kvar="$indexVar$"$endif$, _vvar="$var$"$if(selfClose)$, selfClose=true$endif$$if(refs)$, refs="$refs;separator=" "$"$endif$,
+foreach(var, in, indexVar, indexVarType, declarations, statements, line, refs, selfClose, cleanups) ::= <<
+swift:tParallelFor(\$, _traceline="$line$"$if(indexVar)$, _kvar="$indexVar$"$endif$, _vvar="$var$"$if(selfClose)$, selfClose=true$endif$$if(refs)$, refs="$refs;separator=" "$"$endif$,
 $! The iterator !$
 	getArrayIterator($in$)) {
 	(\$\$, $var$) := each(\$)

Modified: trunk/src/org/griphyn/vdl/karajan/lib/ThrottledParallelFor.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/ThrottledParallelFor.java	2013-07-13 01:34:36 UTC (rev 6643)
+++ trunk/src/org/griphyn/vdl/karajan/lib/ThrottledParallelFor.java	2013-07-13 01:36:13 UTC (rev 6644)
@@ -181,16 +181,22 @@
         LWThread ct = thr.fork(new KRunnable() {
             @Override
             public void run(LWThread thr2) {
+                int i = thr2.checkSliceAndPopState();
                 try {
-                    if (iterationTracer.isEnabled()) {
-                        iterationTracer.trace(thr2, unwrap(value));
-                    }
+                    switch (i) {
+                        case 0:
+                            if (iterationTracer.isEnabled()) {
+                                iterationTracer.trace(thr2, unwrap(value));
+                            }
 
-                    if (CompilerSettings.PERFORMANCE_COUNTERS) {
-                        startCount++;
+                            if (CompilerSettings.PERFORMANCE_COUNTERS) {
+                                startCount++;
+                            }
+                            i++;
+                        case 1:
+                            body.run(thr2);
+                            ts.threadDone(thr2, null);
                     }
-                    body.run(thr2);
-                    ts.threadDone(thr2, null);
                 }
                 catch (ExecutionException e) {
                     thr2.getStack().dropToFrame(fcf);
@@ -204,6 +210,10 @@
                     ts.abortAll();
                     thr.awake();
                 }
+                catch (Yield y) {
+                    y.getState().push(i);
+                    throw y;
+                }
             }
         });
         if(ts.add(ct)) {
@@ -232,8 +242,8 @@
 	}
 	
 	protected Object unwrap(Object value) {
-        if (value instanceof Pair) {
-            Pair<?> p = (Pair<?>) value;
+        if (value instanceof List) {
+            List<?> p = (List<?>) value;
             if (_kvar.getValue() != null) {
                 return _kvar.getValue() + "=" + p.get(0) + ", " + _vvar.getValue() + "=" + Tracer.unwrapHandle(p.get(1));
             }




More information about the Swift-commit mailing list