summaryrefslogtreecommitdiff
blob: 2cfbef761baf0a92c308b5a6ddecd347f52065b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
--- src/cern/colt/matrix/linalg/SmpBlas.java.orig	2015-10-07 22:23:44.969486000 +0000
+++ src/cern/colt/matrix/linalg/SmpBlas.java	2015-10-07 22:29:15.475486000 +0000
@@ -10,7 +10,8 @@
 
 import cern.colt.matrix.DoubleMatrix1D;
 import cern.colt.matrix.DoubleMatrix2D;
-import EDU.oswego.cs.dl.util.concurrent.FJTask;
+
+import java.util.concurrent.ForkJoinTask;
 /**
 Parallel implementation of the Basic Linear Algebra System for symmetric multi processing boxes.
 Currently only a few algorithms are parallelised; the others are fully functional, but run in sequential mode.
@@ -198,7 +199,7 @@
 	
 	// set up concurrent tasks
 	int span = width/noOfTasks;
-	final FJTask[] subTasks = new FJTask[noOfTasks];
+	final ForkJoinTask[] subTasks = new ForkJoinTask[noOfTasks];
 	for (int i=0; i<noOfTasks; i++) {
 		final int offset = i*span;
 		if (i==noOfTasks-1) span = width - span*i; // last span may be a bit larger
@@ -217,24 +218,30 @@
 			CC = C.viewPart(offset,0,span,p);
 		}
 				
-		subTasks[i] = new FJTask() { 
+		subTasks[i] = new ForkJoinTask() { 
 			public void run() { 
 				seqBlas.dgemm(transposeA,transposeB,alpha,AA,BB,beta,CC); 
 				//System.out.println("Hello "+offset); 
 			}
+
+      public boolean exec() { return true; }
+      public void setRawResult(Object o) {}
+      public Object getRawResult() {return null;}
 		};
 	}
 	
 	// run tasks and wait for completion
-	try { 
-		this.smp.taskGroup.invoke(
-			new FJTask() {
-				public void run() {	
-					coInvoke(subTasks);	
-				}
-			}
-		);
-	} catch (InterruptedException exc) {}
+  this.smp.taskGroup.invoke(
+          new ForkJoinTask() {
+              public void run() {	
+                  invokeAll(subTasks);	
+              }
+
+              public boolean exec() { return true; }
+              public void setRawResult(Object o) {}
+              public Object getRawResult() {return null;}
+          }
+          );
 }
 public void dgemv(final boolean transposeA, final double alpha, DoubleMatrix2D A, final DoubleMatrix1D x, final double beta, DoubleMatrix1D y) {
 	/*
@@ -271,7 +278,7 @@
 	
 	// set up concurrent tasks
 	int span = width/noOfTasks;
-	final FJTask[] subTasks = new FJTask[noOfTasks];
+	final ForkJoinTask[] subTasks = new ForkJoinTask[noOfTasks];
 	for (int i=0; i<noOfTasks; i++) {
 		final int offset = i*span;
 		if (i==noOfTasks-1) span = width - span*i; // last span may be a bit larger
@@ -280,24 +287,30 @@
 		final DoubleMatrix2D AA = A.viewPart(offset,0,span,n);
 		final DoubleMatrix1D yy = y.viewPart(offset,span);
 				
-		subTasks[i] = new FJTask() { 
+		subTasks[i] = new ForkJoinTask() { 
 			public void run() { 
 				seqBlas.dgemv(transposeA,alpha,AA,x,beta,yy); 
 				//System.out.println("Hello "+offset); 
 			}
+
+      public boolean exec() { return true; }
+      public void setRawResult(Object o) {}
+      public Object getRawResult() {return null;}
 		};
 	}
 	
 	// run tasks and wait for completion
-	try { 
-		this.smp.taskGroup.invoke(
-			new FJTask() {
-				public void run() {	
-					coInvoke(subTasks);	
-				}
-			}
-		);
-	} catch (InterruptedException exc) {}
+  this.smp.taskGroup.invoke(
+          new ForkJoinTask() {
+              public void run() {	
+                  invokeAll(subTasks);	
+              }
+
+              public boolean exec() { return true; }
+              public void setRawResult(Object o) {}
+              public Object getRawResult() {return null;}
+          }
+          );
 }
 public void dger(double alpha, DoubleMatrix1D x, DoubleMatrix1D y, DoubleMatrix2D A) {
 	seqBlas.dger(alpha,x,y,A);
@@ -369,9 +382,6 @@
 /**
  * Prints various snapshot statistics to System.out; Simply delegates to {@link EDU.oswego.cs.dl.util.concurrent.FJTaskRunnerGroup#stats}.
  */
-public void stats() {
-	if (this.smp!=null) this.smp.stats();
-}
 private double xsum(DoubleMatrix2D A) {
 	double[] sums = run(A,true,
 		new Matrix2DMatrix2DFunction() {
--- src/cern/colt/matrix/linalg/Smp.java.orig	2015-10-07 21:08:19.443486000 +0000
+++ src/cern/colt/matrix/linalg/Smp.java	2015-10-07 22:28:24.722486000 +0000
@@ -9,12 +9,13 @@
 package cern.colt.matrix.linalg;
 
 import cern.colt.matrix.DoubleMatrix2D;
-import EDU.oswego.cs.dl.util.concurrent.FJTask;
-import EDU.oswego.cs.dl.util.concurrent.FJTaskRunnerGroup;
+import java.util.concurrent.ForkJoinTask;
+import java.util.concurrent.ForkJoinPool;
+
 /*
 */
 class Smp {
-	protected FJTaskRunnerGroup taskGroup; // a very efficient and light weight thread pool
+	protected ForkJoinPool taskGroup; // a very efficient and light weight thread pool
 
 	protected int maxThreads;	
 /**
@@ -24,41 +25,39 @@
 	maxThreads = Math.max(1,maxThreads);
 	this.maxThreads = maxThreads;
 	if (maxThreads>1) {
-		this.taskGroup = new FJTaskRunnerGroup(maxThreads);
+		this.taskGroup = new ForkJoinPool(maxThreads);
 	}
 	else { // avoid parallel overhead
 		this.taskGroup = null;
 	}
 }
-/**
- * Clean up deamon threads, if necessary.
- */
-public void finalize() {
-	if (this.taskGroup!=null) this.taskGroup.interruptAll();
-}
 protected void run(final DoubleMatrix2D[] blocksA, final DoubleMatrix2D[] blocksB, final double[] results, final Matrix2DMatrix2DFunction function) {
-	final FJTask[] subTasks = new FJTask[blocksA.length];
+	final ForkJoinTask[] subTasks = new ForkJoinTask[blocksA.length];
 	for (int i=0; i<blocksA.length; i++) {
 		final int k = i;
-		subTasks[i] = new FJTask() { 
+		subTasks[i] = new ForkJoinTask() { 
 			public void run() {
 				double result = function.apply(blocksA[k],blocksB != null ? blocksB[k] : null);
 				if (results!=null) results[k] = result; 
 				//System.out.print("."); 
 			}
+      public boolean exec() { return true; }
+      public void setRawResult(Object o) {}
+      public Object getRawResult() {return null;}
 		};
 	}
 
 	// run tasks and wait for completion
-	try { 
-		this.taskGroup.invoke(
-			new FJTask() {
-				public void run() {	
-					coInvoke(subTasks);	
-				}
-			}
-		);
-	} catch (InterruptedException exc) {}
+  this.taskGroup.invoke(
+          new ForkJoinTask() {
+              public void run() {	
+                  invokeAll(subTasks);	
+              }
+              public boolean exec() { return true; }
+              public void setRawResult(Object o) {}
+              public Object getRawResult() {return null;}
+          }
+          );
 }
 protected DoubleMatrix2D[] splitBlockedNN(DoubleMatrix2D A, int threshold, long flops) {
 	/*
@@ -186,10 +185,4 @@
 	}
 	return blocks;
 }
-/**
- * Prints various snapshot statistics to System.out; Simply delegates to {@link EDU.oswego.cs.dl.util.concurrent.FJTaskRunnerGroup#stats}.
- */
-public void stats() {
-	if (this.taskGroup!=null) this.taskGroup.stats();
-}
 }