[Swift-commit] r2966 - in trunk: libexec resources src/org/griphyn/vdl/engine

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Mon Jun 22 04:02:34 CDT 2009


Author: benc
Date: 2009-06-22 04:02:33 -0500 (Mon, 22 Jun 2009)
New Revision: 2966

Modified:
   trunk/libexec/vdl.k
   trunk/resources/Karajan.stg
   trunk/src/org/griphyn/vdl/engine/Karajan.java
   trunk/src/org/griphyn/vdl/engine/ProcedureSignature.java
Log:
Log parameters and return values from inbuild procedures for provenance
purposes.

This patch maybe also gives the base support removing @function/procedure
distinction in SwiftScript whilst allowing the underlying implementation
to have multiple forms of calling semantics, by introducing a calling
convention field for all procedure definitions.

Modified: trunk/libexec/vdl.k
===================================================================
--- trunk/libexec/vdl.k	2009-06-22 08:08:25 UTC (rev 2965)
+++ trunk/libexec/vdl.k	2009-06-22 09:02:33 UTC (rev 2966)
@@ -23,11 +23,11 @@
 
 	export(
 
-		element(parameterlog, [direction, variable, id],
+		element(parameterlog, [direction, variable, id, thread],
 
 			if(
 				vdl:configProperty("provenance.log") == "true"
-				log("info","PARAM thread={#thread} direction={direction} variable={variable} provenanceid={id}")
+				log("info","PARAM thread={thread} direction={direction} variable={variable} provenanceid={id}")
 			)
 		)
 

Modified: trunk/resources/Karajan.stg
===================================================================
--- trunk/resources/Karajan.stg	2009-06-22 08:08:25 UTC (rev 2965)
+++ trunk/resources/Karajan.stg	2009-06-22 09:02:33 UTC (rev 2966)
@@ -117,6 +117,7 @@
 <string>input</string>
 <string>$it.name$</string>
 <vdl:getdatasetprovenanceid var="{$it.name$}" />
+<string>{#thread}</string>
 </parameterlog>
 >>
 
@@ -125,6 +126,7 @@
 <string>output</string>
 <string>$it.name$</string>
 <vdl:getdatasetprovenanceid var="{$it.name$}" />
+<string>{#thread}</string>
 </parameterlog>
 >>
 
@@ -220,9 +222,53 @@
 </vdl:tparallelFor>
 >>
 
-call(func, outputs, inputs) ::= <<
+// need to log inputs and outputs at the calling stage here because
+// they are not 
+// $outputs:vdl_log_output();separator="\n"$
+
+callInternal(func, outputs, inputs) ::= <<
+<sequential>
+<log level="info" message="INTERNALPROC_START thread={#thread} name=$func$"/>
+<set name="swift#cs"><variable>#thread</variable></set>
 <$func$>
   <parallel>
+    $outputs:callInternal_log_output();separator="\n"$
+    $inputs:callInternal_log_input();separator="\n"$
+  </parallel>
+</$func$>
+<log level="info" message="INTERNALPROC_END thread={#thread}"/>
+</sequential>
+>>
+
+callInternal_log_input() ::= <<
+<sequential>
+  <set name="swift#callInternalValue">$it$</set>
+  <parameterlog>
+    <string>input</string>
+    <string>TODO_name_or_pos</string>
+    <vdl:getdatasetprovenanceid var="{swift#callInternalValue}" />
+    <string>{swift#cs}</string>
+  </parameterlog>
+  <variable>swift#callInternalValue</variable>
+</sequential>
+>>
+
+callInternal_log_output() ::= <<
+<sequential>
+  <set name="swift#callInternalValue">$it$</set>
+  <parameterlog>
+    <string>output</string>
+    <string>TODO_name_or_pos</string>
+    <vdl:getdatasetprovenanceid var="{swift#callInternalValue}" />
+    <string>{swift#cs}</string>
+  </parameterlog>
+  <variable>swift#callInternalValue</variable>
+</sequential>
+>>
+
+callUserDefined(func, outputs, inputs) ::= <<
+<$func$>
+  <parallel>
     $outputs;separator="\n"$
     $inputs;separator="\n"$
   </parallel>

Modified: trunk/src/org/griphyn/vdl/engine/Karajan.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/Karajan.java	2009-06-22 08:08:25 UTC (rev 2965)
+++ trunk/src/org/griphyn/vdl/engine/Karajan.java	2009-06-22 09:02:33 UTC (rev 2966)
@@ -406,8 +406,6 @@
 
 	public StringTemplate call(Call call, VariableScope scope, boolean inhibitOutput) throws CompilationException {
 		try {
-			StringTemplate callST = template("call");
-			callST.setAttribute("func", call.getProc().getLocalPart());
 			// Check is called procedure declared previously 
 			String procName = call.getProc().getLocalPart();
 			if (proceduresMap.get(procName) == null)
@@ -419,6 +417,15 @@
 			Map outArgs = new HashMap();
 			
 			ProcedureSignature proc = (ProcedureSignature)proceduresMap.get(procName);
+			StringTemplate callST;
+			if(proc.getInvocationMode() == ProcedureSignature.INVOCATION_USERDEFINED) {
+				callST = template("callUserDefined");
+			} else if(proc.getInvocationMode() == ProcedureSignature.INVOCATION_INTERNAL) {
+				callST = template("callInternal");
+			} else {
+				throw new CompilationException("Unknown procedure invocation mode "+proc.getInvocationMode());
+			}
+			callST.setAttribute("func", call.getProc().getLocalPart());
 			/* Does number of input arguments match */				
 			for (int i = 0; i < proc.sizeOfInputArray(); i++) {
 				if (proc.getInputArray(i).isOptional())

Modified: trunk/src/org/griphyn/vdl/engine/ProcedureSignature.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/ProcedureSignature.java	2009-06-22 08:08:25 UTC (rev 2965)
+++ trunk/src/org/griphyn/vdl/engine/ProcedureSignature.java	2009-06-22 09:02:33 UTC (rev 2966)
@@ -13,14 +13,21 @@
 	private ArrayList outputArgs;
 	private boolean anyNumOfInputArgs;
 	private boolean anyNumOfOutputArgs; /* this is maybe unnecessary*/
+	private int invocationMode;
+
+	/* Procedure is built in to Swift. */
+	static public final int INVOCATION_INTERNAL = 600;
+
+	/* Procedure is user defined. */
+	static public final int INVOCATION_USERDEFINED = 601;
 	
-	
 	public ProcedureSignature(String name) {
 		this.name = name;
 		inputArgs = new ArrayList();
 		outputArgs = new ArrayList();
 		anyNumOfInputArgs = false;
 		anyNumOfOutputArgs = false;
+		invocationMode = INVOCATION_USERDEFINED;
 	}
 	
 	public String getName() {
@@ -98,6 +105,14 @@
 			this.addOutputArg(fas);
 		}
 	}
+
+	public void setInvocationMode(int i) {
+		this.invocationMode = i;
+	}
+
+	public int getInvocationMode() {
+		return this.invocationMode;
+	}
 	
 	public static HashMap makeProcedureSignatures() {
 		HashMap proceduresMap = new HashMap();
@@ -107,6 +122,7 @@
 		readData.addInputArg(rdInputArg);
 		FormalArgumentSignature rdOutputArg = new FormalArgumentSignature(true);
 		readData.addOutputArg(rdOutputArg);		
+		readData.setInvocationMode(INVOCATION_INTERNAL);
 		proceduresMap.put("readData", readData);
 		
 		ProcedureSignature readData2 = new ProcedureSignature("readData2");
@@ -114,10 +130,12 @@
 		readData2.addInputArg(rd2InputArg);
 		FormalArgumentSignature rd2OutputArg = new FormalArgumentSignature(true);
 		readData2.addOutputArg(rd2OutputArg);     
+		readData2.setInvocationMode(INVOCATION_INTERNAL);
 		proceduresMap.put("readData2", readData2);
 		
 		ProcedureSignature trace = new ProcedureSignature("trace");
 		trace.setAnyNumOfInputArgs();
+		trace.setInvocationMode(INVOCATION_INTERNAL);
 		proceduresMap.put("trace", trace);
 		
 		return proceduresMap;




More information about the Swift-commit mailing list