15 |
|
|
16 |
|
public static void main(String[] args) throws Exception { |
17 |
|
int maxThreads = NCPUS * 3 / 2; // 100; |
18 |
< |
if (args.length > 0) |
18 |
> |
if (args.length > 0) |
19 |
|
maxThreads = Integer.parseInt(args[0]); |
20 |
|
|
21 |
|
System.out.print("Warmup:"); |
28 |
|
if (i == k) { |
29 |
|
k = i << 1; |
30 |
|
i = i + (i >>> 1); |
31 |
< |
} |
32 |
< |
else |
31 |
> |
} |
32 |
> |
else |
33 |
|
i = k; |
34 |
|
} |
35 |
|
} |
43 |
|
if (i == k) { |
44 |
|
k = i << 1; |
45 |
|
i = i + (i >>> 1); |
46 |
< |
} |
47 |
< |
else |
46 |
> |
} |
47 |
> |
else |
48 |
|
i = k; |
49 |
|
} |
50 |
|
} |
83 |
|
static final class Task implements Runnable { |
84 |
|
final ThreadPoolExecutor pool; |
85 |
|
final CountDownLatch done; |
86 |
< |
Task(ThreadPoolExecutor p, CountDownLatch d) { |
87 |
< |
pool = p; |
86 |
> |
Task(ThreadPoolExecutor p, CountDownLatch d) { |
87 |
> |
pool = p; |
88 |
|
done = d; |
89 |
|
} |
90 |
|
public void run() { |
92 |
|
remaining.incrementAndGet(); |
93 |
|
int n; |
94 |
|
while (!Thread.interrupted() && |
95 |
< |
(n = remaining.get()) > 0 && |
95 |
> |
(n = remaining.get()) > 0 && |
96 |
|
done.getCount() > 0) { |
97 |
|
if (remaining.compareAndSet(n, n-1)) { |
98 |
|
try { |
107 |
|
} |
108 |
|
} |
109 |
|
} |
110 |
< |
|
110 |
> |
|
111 |
|
static void oneRun(BlockingQueue<Runnable> q, int nThreads, int iters, boolean print) throws Exception { |
112 |
< |
|
113 |
< |
ThreadPoolExecutor pool = |
112 |
> |
|
113 |
> |
ThreadPoolExecutor pool = |
114 |
|
new ThreadPoolExecutor(nThreads+1, Integer.MAX_VALUE, |
115 |
|
1L, TimeUnit.SECONDS, q); |
116 |
|
|
134 |
|
static final class LTQasSQ<T> extends LinkedTransferQueue<T> { |
135 |
|
LTQasSQ() { super(); } |
136 |
|
public void put(T x) { |
137 |
< |
try { super.transfer(x); |
137 |
> |
try { super.transfer(x); |
138 |
|
} catch (InterruptedException ex) { throw new Error(); } |
139 |
|
} |
140 |
|
} |
146 |
|
if ((++calls & 1) == 0) |
147 |
|
super.put(x); |
148 |
|
else { |
149 |
< |
try { super.transfer(x); |
150 |
< |
} catch (InterruptedException ex) { |
151 |
< |
throw new Error(); |
149 |
> |
try { super.transfer(x); |
150 |
> |
} catch (InterruptedException ex) { |
151 |
> |
throw new Error(); |
152 |
|
} |
153 |
|
} |
154 |
|
} |