Skip to content

Commit 80bbccb

Browse files
committed
Add TypeInfo for expr, add method getTypeInfo()
1 parent de7ff81 commit 80bbccb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+372
-90
lines changed

.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<classpathentry kind="lib" path="lib/libsvm.jar"/>
88
<classpathentry kind="lib" path="lib/jzlib.jar"/>
99
<classpathentry kind="lib" path="lib/netty-all-5.0.0.Alpha2.jar" sourcepath="/home/yueming/Downloads/netty-5.0.0.Alpha2/jar/all-in-one/netty-all-5.0.0.Alpha2-sources.jar"/>
10-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
10+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 7 [1.7.0_75]"/>
1111
<classpathentry combineaccessrules="false" kind="src" path="/Futureye_v2"/>
1212
<classpathentry kind="output" path="bin"/>
1313
</classpath>

src/lambdacloud/core/CloudFunc.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import symjava.bytecode.BytecodeVecFunc;
2424
import symjava.bytecode.IR;
2525
import symjava.symbolic.Expr;
26+
import symjava.symbolic.TypeInfo;
27+
import symjava.symbolic.utils.FuncClassLoader;
2628
import symjava.symbolic.utils.JIT;
2729

2830
public class CloudFunc extends LCBase {
@@ -171,9 +173,10 @@ public CloudFunc(Class<?> clazz) {
171173

172174
public CloudFunc compile(Expr[] args, Expr expr) {
173175
Expr compileExpr = expr;
174-
if(!(expr instanceof LCBase)) {
175-
compileExpr = new LCReturn(expr);
176-
}
176+
//TODO Do we need LCReturn? It depends on how the compile function treat the return value of an expr
177+
//if(!(expr instanceof LCBase)) {
178+
// compileExpr = new LCReturn(expr);
179+
//}
177180
if(currentCloudConfig().isLocal()) {
178181
funcType = 1;
179182
func = CompileUtils.compile(name, compileExpr, args);
@@ -182,6 +185,8 @@ public CloudFunc compile(Expr[] args, Expr expr) {
182185
} else {
183186
//send the exprssion to the server
184187
funcIR = CompileUtils.getIR(name, compileExpr, args);
188+
189+
185190
//funcIR = JIT.getIR(name, args, expr);
186191
CloudFuncHandler handler = currentCloudConfig().currentClient().getCloudFuncHandler();
187192
Channel ch = currentCloudConfig().currentClient().getChannel();
@@ -348,9 +353,16 @@ public BytecodeVecFunc getBytecodeVecFunc() {
348353
public BytecodeBatchFunc getBytecodeBatchFunc() {
349354
return this.batchFunc;
350355
}
356+
351357
@Override
352358
public Expr[] args() {
353359
// TODO Auto-generated method stub
354360
return null;
355361
}
362+
363+
@Override
364+
public TypeInfo getTypeInfo() {
365+
// TODO Auto-generated method stub
366+
return null;
367+
}
356368
}

src/lambdacloud/core/graph/GraphBuilder.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
import lambdacloud.core.CloudFunc;
44
import lambdacloud.test.CompileUtils;
55
import symjava.symbolic.Expr;
6+
import symjava.symbolic.Matrix;
67
import symjava.symbolic.Symbol;
78
import symjava.symbolic.Symbols;
9+
import symjava.symbolic.TypeInfo;
10+
import symjava.symbolic.Expr.TYPE;
11+
import symjava.symbolic.Vector;
812
import symjava.symbolic.utils.JIT;
913
import symjava.symbolic.utils.Utils;
1014

@@ -22,7 +26,7 @@ protected static void compile(Node root) {
2226
//no return
2327
//root.func = CompileUtils.compile(null, root.expr, Utils.extractSymbols(root.expr).toArray(new Expr[0]));
2428
root.args = Utils.extractSymbols(root.expr);
25-
root.func = JIT.compile(root.expr);
29+
//root.func = JIT.compile(root.expr);
2630
root.cfunc = new CloudFunc(root.args.toArray(new Expr[0]), root.expr);
2731
}
2832

@@ -39,10 +43,25 @@ public static Node helper(Expr expr) {
3943
Node n = helper(args[i]);
4044
if(n != null) {
4145
if(n.isDevice()) {
42-
Symbol arg = ss.get(idx++);
43-
ret.expr.setArg(i, arg);
44-
//ret.args.add(arg);
45-
ret.children.put(arg.toString(), n);
46+
TypeInfo ti = args[i].getTypeInfo();
47+
if(ti.type == TYPE.VECTOR) {
48+
Vector arg = new Vector("__vec_"+(idx++), ti.dim[0]);
49+
ret.expr.setArg(i, arg);
50+
//ret.args.add(arg);
51+
ret.children.put(arg.toString(), n);
52+
53+
} else if(ti.type == TYPE.MATRIX) {
54+
Matrix arg = new Matrix("__mat_"+(idx++), ti.dim[0], ti.dim[1]);
55+
ret.expr.setArg(i, arg);
56+
//ret.args.add(arg);
57+
ret.children.put(arg.toString(), n);
58+
} else {
59+
Symbol arg = ss.get(idx++);
60+
ret.expr.setArg(i, arg);
61+
//ret.args.add(arg);
62+
ret.children.put(arg.toString(), n);
63+
64+
}
4665
} else {
4766
ret.expr.setArg(i, n.expr);
4867
//ret.args.addAll(n.args);

src/lambdacloud/core/graph/Node.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ public boolean isDevice() {
2222
public Node() {
2323

2424
}
25+
public String toString() {
26+
return expr.toString();
27+
}
2528
}

src/lambdacloud/core/lang/LCArray.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.Map;
44

55
import symjava.symbolic.Expr;
6+
import symjava.symbolic.TypeInfo;
67

78
import com.sun.org.apache.bcel.internal.generic.ALOAD;
89
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
@@ -118,7 +119,7 @@ public InstructionHandle bytecodeGen(String clsName, MethodGen mg,
118119
}
119120

120121
@Override
121-
public TYPE getType() {
122+
public TypeInfo getType() {
122123
return TYPE.DOUBLE;
123124
}
124125

src/lambdacloud/core/lang/LCBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package lambdacloud.core.lang;
22

33
import symjava.symbolic.Expr;
4+
import symjava.symbolic.TypeInfo;
45

56
public abstract class LCBase extends Expr {
67
protected LCBase parent = null;
@@ -22,7 +23,7 @@ public Expr diff(Expr expr) {
2223
}
2324

2425
@Override
25-
public TYPE getType() {
26+
public TypeInfo getType() {
2627
throw new UnsupportedOperationException();
2728
}
2829

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package lambdacloud.core.lang;
22

3+
import symjava.symbolic.TypeInfo;
4+
35
public class LCBoolean extends LCVar {
46
public LCBoolean(String name) {
57
super(name);
68
}
79

810
@Override
9-
public TYPE getType() {
11+
public TypeInfo getType() {
1012
return TYPE.BOOLEAN;
1113
}
1214
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package lambdacloud.core.lang;
22

3+
import symjava.symbolic.TypeInfo;
4+
35
public class LCByte extends LCVar {
46
public LCByte(String name) {
57
super(name);
68
}
79

810
@Override
9-
public TYPE getType() {
11+
public TypeInfo getType() {
1012
return TYPE.BYTE;
1113
}
1214
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package lambdacloud.core.lang;
22

3+
import symjava.symbolic.TypeInfo;
4+
35

46
public class LCChar extends LCVar {
57
public LCChar(String name) {
68
super(name);
79
}
810

911
@Override
10-
public TYPE getType() {
12+
public TypeInfo getType() {
1113
return TYPE.CHAR;
1214
}
1315
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package lambdacloud.core.lang;
22

3+
import symjava.symbolic.TypeInfo;
4+
35

46
public class LCDouble extends LCVar {
57
public LCDouble(String name) {
68
super(name);
79
}
810

911
@Override
10-
public TYPE getType() {
12+
public TypeInfo getType() {
1113
return TYPE.DOUBLE;
1214
}
1315
}

0 commit comments

Comments
 (0)