Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 35aa252

Browse filesBrowse files
Ji ChuJi Chu
authored andcommitted
Merge branch 'dist-snc' of https://github.com/yuemingl/SymJava into dist-snc
2 parents 6b17686 + 761d8c8 commit 35aa252
Copy full SHA for 35aa252

File tree

Expand file treeCollapse file tree

11 files changed

+38
-27
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

11 files changed

+38
-27
lines changed
Open diff view settings
Collapse file

‎src/lambdacloud/core/CloudFunc.java‎

Copy file name to clipboardExpand all lines: src/lambdacloud/core/CloudFunc.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public CloudFunc compile(Expr[] args, Expr expr) {
270270
public CloudFunc compile(Expr[] args, Expr[] exprs) {
271271
if(currentCloudConfig().isLocal()) {
272272
funcType = FUNC_TYPE.VECTOR;
273-
batchFunc = JIT.compile(args, exprs);
273+
batchFunc = JIT.compileBatchFunc(args, exprs);
274274
} else {
275275
//send the exprssion to the server
276276
}
Collapse file

‎src/lambdacloud/examples/ExampleDotProduct.java‎

Copy file name to clipboardExpand all lines: src/lambdacloud/examples/ExampleDotProduct.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static void main(String[] args) {
2525

2626
lcs.append(output[2].assign(sum));
2727

28-
BytecodeVecFunc f = CompileUtils.compileVec(lcs, output, x, y);
28+
BytecodeVecFunc f = CompileUtils.compileVecFunc(lcs, output, x, y);
2929

3030
double[] out = new double[6];
3131
double[] xx = new double[] {1,2,3,4,5,6};
Collapse file

‎src/lambdacloud/test/CompileUtils.java‎

Copy file name to clipboardExpand all lines: src/lambdacloud/test/CompileUtils.java
+18-8Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@
3535
import com.sun.org.apache.bcel.internal.generic.PUSH;
3636
import com.sun.org.apache.bcel.internal.generic.Type;
3737

38+
/**
39+
* This class use recursive way to generate bytecode for expressions
40+
*
41+
*
42+
*/
3843
public class CompileUtils {
44+
45+
/**
46+
* Recursively reset the compile flags for an expression.
47+
* @param expr
48+
*/
3949
public static void bytecodeGenResetAll(Expr expr) {
4050
Expr[] tmp = expr.args();
4151
for(int i=0; i<tmp.length; i++)
@@ -52,7 +62,7 @@ public static IR getIR(String name, Expr expr, Expr ...args) {
5262

5363
if(expr.getType() == TYPE.MATRIX || expr.getType() == TYPE.VECTOR) {
5464
LCArray output = LCArray.getDoubleArray("output");
55-
cg = _compileVec(name, expr, output, args);
65+
cg = _compileVecFunc(name, expr, output, args);
5666
ir.type = FUNC_TYPE.VECTOR; //BytecodeVecFunc
5767
if(expr.getType() == TYPE.VECTOR)
5868
ir.outAryLen = expr.getTypeInfo().dim[0];
@@ -288,15 +298,15 @@ public static ClassGen _compileBatchFunc(String name, Expr[] exprs, Expr ...args
288298
* @param args
289299
* @return
290300
*/
291-
public static BytecodeVecFunc compileVec(Expr expr, LCArray output, Expr ...args) {
292-
ClassGen cg = _compileVec(null, expr, output, args);
301+
public static BytecodeVecFunc compileVecFunc(Expr expr, LCArray output, Expr ...args) {
302+
ClassGen cg = _compileVecFunc(null, expr, output, args);
293303
FuncClassLoader<BytecodeVecFunc> fcl = new FuncClassLoader<BytecodeVecFunc>();
294304
BytecodeVecFunc fun = fcl.newInstance(cg);
295305
return fun;
296306
}
297307

298-
public static BytecodeVecFunc compileVec(String name, Expr expr, LCArray output, Expr ...args) {
299-
ClassGen cg = _compileVec(name, expr, output, args);
308+
public static BytecodeVecFunc compileVecFunc(String name, Expr expr, LCArray output, Expr ...args) {
309+
ClassGen cg = _compileVecFunc(name, expr, output, args);
300310
FuncClassLoader<BytecodeVecFunc> fcl = new FuncClassLoader<BytecodeVecFunc>();
301311
BytecodeVecFunc fun = fcl.newInstance(cg);
302312
return fun;
@@ -308,15 +318,15 @@ public static BytecodeVecFunc compileVec(String name, Expr expr, LCArray output,
308318
* @param args
309319
* @return
310320
*/
311-
public static BytecodeVecFunc compileVec(Expr expr, Expr ...args) {
321+
public static BytecodeVecFunc compileVecFunc(Expr expr, Expr ...args) {
312322
LCArray output = LCArray.getDoubleArray("output");
313-
ClassGen cg = _compileVec(null, expr, output, args);
323+
ClassGen cg = _compileVecFunc(null, expr, output, args);
314324
FuncClassLoader<BytecodeVecFunc> fcl = new FuncClassLoader<BytecodeVecFunc>();
315325
BytecodeVecFunc fun = fcl.newInstance(cg);
316326
return fun;
317327
}
318328

319-
public static ClassGen _compileVec(String name, Expr expr, LCArray output, Expr ...args) {
329+
public static ClassGen _compileVecFunc(String name, Expr expr, LCArray output, Expr ...args) {
320330
String packageName = "symjava.bytecode";
321331
String clsName = name;
322332
if(clsName == null)
Collapse file

‎src/lambdacloud/test/TestLCIndex.java‎

Copy file name to clipboardExpand all lines: src/lambdacloud/test/TestLCIndex.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static void test1() {
1515
LCArray output = LCArray.getDoubleArray("output");
1616

1717
lcs.append(new LCAssign(output[0], x[2]));
18-
BytecodeVecFunc f = CompileUtils.compileVec(lcs, output, x);
18+
BytecodeVecFunc f = CompileUtils.compileVecFunc(lcs, output, x);
1919
double[] out = new double[10];
2020
double[] xx = new double[] {1,2,3};
2121
f.apply(out, 0, xx);
@@ -30,7 +30,7 @@ public static void test2() {
3030
LCArray output = LCArray.getDoubleArray("output");
3131

3232
lcs.append(new LCAssign(output[0], x[2]*y[2]));
33-
BytecodeVecFunc f = CompileUtils.compileVec(lcs, output, x, y);
33+
BytecodeVecFunc f = CompileUtils.compileVecFunc(lcs, output, x, y);
3434
double[] out = new double[10];
3535
double[] xx = new double[] {1,2,3};
3636
double[] yy = new double[] {2,1,2};
Collapse file

‎src/lambdacloud/test/TestLCLength.java‎

Copy file name to clipboardExpand all lines: src/lambdacloud/test/TestLCLength.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static void test1() {
2424
lcs.append(output[1].assign(x.size()));
2525
lcs.append(output[2].assign(new LCLength(x)));
2626

27-
BytecodeVecFunc f = CompileUtils.compileVec(lcs, x);
27+
BytecodeVecFunc f = CompileUtils.compileVecFunc(lcs, x);
2828

2929
double[] out = new double[10];
3030
double[] xx = new double[] {1,2,3};
Collapse file

‎src/lambdacloud/test/TestMatrix.java‎

Copy file name to clipboardExpand all lines: src/lambdacloud/test/TestMatrix.java
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static void main(String[] args) {
3333

3434
public static void testBasic1() {
3535
Matrix A = new Matrix("A",3,3);
36-
BytecodeVecFunc fun = CompileUtils.compileVec(new LCReturn(A));
36+
BytecodeVecFunc fun = CompileUtils.compileVecFunc(new LCReturn(A));
3737
/**
3838
* 1 2 3
3939
* 4 5 6
@@ -47,7 +47,7 @@ public static void testBasic1() {
4747

4848
public static void testBasic2() {
4949
Vector x = new Vector("x",3);
50-
BytecodeVecFunc fun = CompileUtils.compileVec(new LCReturn(x));
50+
BytecodeVecFunc fun = CompileUtils.compileVecFunc(new LCReturn(x));
5151
double[] data_x = new double[] {1,2,3};
5252
double[] outAry = new double[3];
5353
fun.apply(outAry, 0, data_x);
@@ -57,7 +57,7 @@ public static void testBasic2() {
5757
public static void testBasic3() {
5858
Matrix A = new Matrix("A",3,3);
5959
Vector x = new Vector("x",3);
60-
BytecodeVecFunc fun = CompileUtils.compileVec(new LCReturn(A*x));
60+
BytecodeVecFunc fun = CompileUtils.compileVecFunc(new LCReturn(A*x));
6161
/**
6262
* 1 2 3
6363
* 4 5 6
@@ -74,7 +74,7 @@ public static void testBasic4() {
7474
Vector x = new Vector("x",3);
7575
Vector y = new Vector("y",3);
7676

77-
BytecodeVecFunc fun = CompileUtils.compileVec(new LCReturn(x+y), x, y);
77+
BytecodeVecFunc fun = CompileUtils.compileVecFunc(new LCReturn(x+y), x, y);
7878
double[] outAry = new double[4];
7979
double[] data_x = new double[] {1,2,3};
8080
double[] data_y = new double[] {1,2,3};
@@ -87,7 +87,7 @@ public static void testConcat1() {
8787
Vector y = new Vector("y",2);
8888
Vector z = new Vector("z",4);
8989

90-
BytecodeVecFunc fun = CompileUtils.compileVec(new LCReturn(new Concat(x,y,z)), x, y, z);
90+
BytecodeVecFunc fun = CompileUtils.compileVecFunc(new LCReturn(new Concat(x,y,z)), x, y, z);
9191
double[] outAry = new double[9];
9292
double[] data_x = new double[] {1,2,3};
9393
double[] data_y = new double[] {4,5};
@@ -101,7 +101,7 @@ public static void testConcat2() {
101101
Vector y = new Vector("y",2);
102102
Vector z = new Vector("z",5);
103103

104-
BytecodeVecFunc fun = CompileUtils.compileVec(new LCReturn(new Concat(x,y)+z), x, y, z);
104+
BytecodeVecFunc fun = CompileUtils.compileVecFunc(new LCReturn(new Concat(x,y)+z), x, y, z);
105105
double[] outAry = new double[5];
106106
double[] data_x = new double[] {1,2,3};
107107
double[] data_y = new double[] {4,5};
@@ -128,7 +128,7 @@ public static void testMatrixSplit1() {
128128
System.out.println(res);
129129
//Doesn't work because the symbol AA[0][0] has no name?
130130
//BytecodeVecFunc fun = CompileUtils.compileVec(new LCReturn(res), A,x,y0,AA[0][0],AA[1][0],xx[0],xx[1]);
131-
BytecodeVecFunc fun = CompileUtils.compileVec(new LCReturn(res));
131+
BytecodeVecFunc fun = CompileUtils.compileVecFunc(new LCReturn(res));
132132
/*
133133
1 2 3 4 0 1 13
134134
1 2 1 3 * 1 + 2 = 9
Collapse file

‎src/symjava/examples/BenchmarkGriewank.java‎

Copy file name to clipboardExpand all lines: src/symjava/examples/BenchmarkGriewank.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static void test() {
4343

4444
Expr[] args = xi.get(0, N);
4545
start = System.currentTimeMillis();
46-
BytecodeBatchFunc f = JIT.compile(args, grad);
46+
BytecodeBatchFunc f = JIT.compileBatchFunc(args, grad);
4747
long compileTime = System.currentTimeMillis() - start;
4848

4949
double[] outAry = new double[N];
Collapse file

‎src/symjava/numeric/NumMatrix.java‎

Copy file name to clipboardExpand all lines: src/symjava/numeric/NumMatrix.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public NumMatrix(SymMatrix sm, Expr[] args) {
3434
exprs[idx++] = sm.get(i, j);
3535
}
3636
}
37-
this.func = JIT.compile(args, exprs);
37+
this.func = JIT.compileBatchFunc(args, exprs);
3838
}
3939

4040
public int rowDim() {
Collapse file

‎src/symjava/numeric/NumVector.java‎

Copy file name to clipboardExpand all lines: src/symjava/numeric/NumVector.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public NumVector(int size) {
2020

2121
public NumVector(SymVector sv, Expr[] args) {
2222
this.size = sv.dim();
23-
this.func = JIT.compile(args, sv.getData());
23+
this.func = JIT.compileBatchFunc(args, sv.getData());
2424
}
2525

2626
public int dim() {
Collapse file

‎src/symjava/symbolic/Expr.java‎

Copy file name to clipboardExpand all lines: src/symjava/symbolic/Expr.java
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,10 @@ public InstructionHandle bytecodeGen(String clsName, MethodGen mg,
495495

496496
/**
497497
* Reset the compile flags for an expression.
498-
* For example, a matrix is defined and stored to a local variable at the first reference of it
499-
* The following reference of it just load the local variable.
500-
* By calling this function, the state is reset.
498+
*
499+
* For example, a matrix is defined and stored to new a local variable when it is referenced
500+
* at the first time. The following references of the matrix just load the local variable.
501+
* By calling this function, the state is reset to define a new local variable.
501502
*/
502503
public void bytecodeGenReset() {
503504

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.