From 54fb8962f0c68c7a44afb649706dea5c0bcfa11e Mon Sep 17 00:00:00 2001 From: jihoonl Date: Wed, 25 Feb 2009 09:10:33 +0000 Subject: [PATCH] *** empty log message *** --- .../MatrixMultiply/dstm2/AtomicArray.java | 179 +++++ .../dstm2/ContentionManager.java | 77 +++ .../DSTM2/MatrixMultiply/dstm2/Defaults.java | 65 ++ .../DSTM2/MatrixMultiply/dstm2/MMulMain.java | 202 ++++++ .../DSTM2/MatrixMultiply/dstm2/Main.java | 170 +++++ .../DSTM2/MatrixMultiply/dstm2/Thread.java | 557 +++++++++++++++ .../MatrixMultiply/dstm2/Transaction.java | 256 +++++++ .../DSTM2/MatrixMultiply/dstm2/atomic.java | 47 ++ .../dstm2/benchmark/Benchmark.java | 64 ++ .../dstm2/benchmark/IntSetBenchmark.java | 264 +++++++ .../MatrixMultiply/dstm2/benchmark/List.java | 161 +++++ .../dstm2/benchmark/ListRelease.java | 167 +++++ .../dstm2/benchmark/ListSnap.java | 200 ++++++ .../dstm2/benchmark/MMulBenchMark.java | 138 ++++ .../dstm2/benchmark/Matrix.java | 196 ++++++ .../dstm2/benchmark/RBTree.java | 645 ++++++++++++++++++ .../dstm2/benchmark/SkipList.java | 252 +++++++ .../dstm2/exceptions/AbortedException.class | Bin 0 -> 383 bytes .../dstm2/exceptions/AbortedException.java | 56 ++ .../dstm2/exceptions/GracefulException.class | Bin 0 -> 303 bytes .../dstm2/exceptions/GracefulException.java | 48 ++ .../dstm2/exceptions/PanicException.class | Bin 0 -> 596 bytes .../dstm2/exceptions/PanicException.java | 69 ++ .../dstm2/exceptions/SnapshotException.class | Bin 0 -> 321 bytes .../dstm2/exceptions/SnapshotException.java | 58 ++ .../dstm2/factory/Adapter$Getter.class | Bin 0 -> 300 bytes .../dstm2/factory/Adapter$Setter.class | Bin 0 -> 302 bytes .../dstm2/factory/Adapter.class | Bin 0 -> 699 bytes .../MatrixMultiply/dstm2/factory/Adapter.java | 77 +++ .../dstm2/factory/AtomicFactory.class | Bin 0 -> 12882 bytes .../dstm2/factory/AtomicFactory.java | 411 +++++++++++ .../dstm2/factory/BaseFactory.class | Bin 0 -> 7178 bytes .../dstm2/factory/BaseFactory.java | 309 +++++++++ .../dstm2/factory/ClassLoader.class | Bin 0 -> 522 bytes .../dstm2/factory/ClassLoader.java | 56 ++ .../dstm2/factory/Copyable.class | Bin 0 -> 238 bytes .../dstm2/factory/Copyable.java | 41 ++ .../dstm2/factory/CopyableDef.class | Bin 0 -> 240 bytes .../dstm2/factory/CopyableDef.java | 40 ++ .../dstm2/factory/Factory.class | Bin 0 -> 228 bytes .../MatrixMultiply/dstm2/factory/Factory.java | 48 ++ .../dstm2/factory/Property.class | Bin 0 -> 752 bytes .../dstm2/factory/Property.java | 95 +++ .../dstm2/factory/Releasable.class | Bin 0 -> 139 bytes .../dstm2/factory/Releasable.java | 45 ++ .../dstm2/factory/SequentialFactory.class | Bin 0 -> 5225 bytes .../dstm2/factory/SequentialFactory.java | 140 ++++ .../dstm2/factory/Snapable.class | Bin 0 -> 391 bytes .../dstm2/factory/Snapable.java | 58 ++ .../dstm2/factory/ofree/Adapter$1.class | Bin 0 -> 2736 bytes .../dstm2/factory/ofree/Adapter$2.class | Bin 0 -> 2522 bytes .../dstm2/factory/ofree/Adapter.class | Bin 0 -> 4801 bytes .../dstm2/factory/ofree/Adapter.java | 220 ++++++ .../dstm2/factory/ofree/CopyableFactory.class | Bin 0 -> 5784 bytes .../dstm2/factory/ofree/CopyableFactory.java | 155 +++++ .../dstm2/factory/ofree/Locator.class | Bin 0 -> 3548 bytes .../dstm2/factory/ofree/Locator.java | 191 ++++++ .../dstm2/factory/ofree/Node.class | Bin 0 -> 822 bytes .../dstm2/factory/ofree/Node.java | 63 ++ .../dstm2/factory/ofree/ReadSet$1.class | Bin 0 -> 212 bytes .../factory/ofree/ReadSet$Iterator.class | Bin 0 -> 1181 bytes .../dstm2/factory/ofree/ReadSet.class | Bin 0 -> 1984 bytes .../dstm2/factory/ofree/ReadSet.java | 203 ++++++ .../dstm2/factory/shadow/Adapter$1.class | Bin 0 -> 2197 bytes .../dstm2/factory/shadow/Adapter$2.class | Bin 0 -> 1942 bytes .../dstm2/factory/shadow/Adapter.class | Bin 0 -> 5343 bytes .../dstm2/factory/shadow/Adapter.java | 251 +++++++ .../factory/shadow/ReadSet$Iterator.class | Bin 0 -> 1302 bytes .../dstm2/factory/shadow/ReadSet.class | Bin 0 -> 2281 bytes .../dstm2/factory/shadow/ReadSet.java | 199 ++++++ .../dstm2/factory/shadow/Recoverable.class | Bin 0 -> 165 bytes .../dstm2/factory/shadow/Recoverable.java | 49 ++ .../factory/shadow/RecoverableFactory.class | Bin 0 -> 6191 bytes .../factory/shadow/RecoverableFactory.java | 168 +++++ .../dstm2/factory/twophase/Adapter$1$1.class | Bin 0 -> 898 bytes .../dstm2/factory/twophase/Adapter$1$2.class | Bin 0 -> 1019 bytes .../dstm2/factory/twophase/Adapter$1.class | Bin 0 -> 2151 bytes .../dstm2/factory/twophase/Adapter$2$1.class | Bin 0 -> 899 bytes .../dstm2/factory/twophase/Adapter$2$2.class | Bin 0 -> 1020 bytes .../dstm2/factory/twophase/Adapter$2.class | Bin 0 -> 2232 bytes .../dstm2/factory/twophase/Adapter.class | Bin 0 -> 2948 bytes .../dstm2/factory/twophase/Adapter.java | 151 ++++ .../dstm2/manager/AggressiveManager.class | Bin 0 -> 788 bytes .../dstm2/manager/AggressiveManager.java | 58 ++ .../dstm2/manager/BackoffManager.class | Bin 0 -> 1919 bytes .../dstm2/manager/BackoffManager.java | 101 +++ .../dstm2/manager/BaseManager.class | Bin 0 -> 1406 bytes .../dstm2/manager/BaseManager.java | 83 +++ .../dstm2/manager/EruptionManager.class | Bin 0 -> 1192 bytes .../dstm2/manager/EruptionManager.java | 101 +++ .../dstm2/manager/GreedyManager.class | Bin 0 -> 897 bytes .../dstm2/manager/GreedyManager.java | 68 ++ .../dstm2/manager/KarmaManager.class | Bin 0 -> 1075 bytes .../dstm2/manager/KarmaManager.java | 84 +++ .../dstm2/manager/KindergartenManager.class | Bin 0 -> 1388 bytes .../dstm2/manager/KindergartenManager.java | 82 +++ .../dstm2/manager/PriorityManager.class | Bin 0 -> 859 bytes .../dstm2/manager/PriorityManager.java | 61 ++ .../MatrixMultiply/dstm2/util/Random.class | Bin 0 -> 3167 bytes .../MatrixMultiply/dstm2/util/Random.java | 255 +++++++ 100 files changed, 7734 insertions(+) create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/AtomicArray.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/ContentionManager.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Defaults.java create mode 100755 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/MMulMain.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Main.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Thread.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Transaction.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/atomic.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/Benchmark.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/IntSetBenchmark.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/List.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/ListRelease.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/ListSnap.java create mode 100755 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/MMulBenchMark.java create mode 100755 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/Matrix.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/RBTree.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/SkipList.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/AbortedException.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/AbortedException.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/GracefulException.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/GracefulException.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/PanicException.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/PanicException.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/SnapshotException.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/SnapshotException.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Adapter$Getter.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Adapter$Setter.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Adapter.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Adapter.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/AtomicFactory.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/AtomicFactory.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/BaseFactory.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/BaseFactory.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ClassLoader.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ClassLoader.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Copyable.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Copyable.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/CopyableDef.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/CopyableDef.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Factory.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Factory.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Property.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Property.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Releasable.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Releasable.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/SequentialFactory.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/SequentialFactory.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Snapable.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Snapable.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Adapter$1.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Adapter$2.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Adapter.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Adapter.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/CopyableFactory.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/CopyableFactory.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Locator.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Locator.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Node.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Node.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/ReadSet$1.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/ReadSet$Iterator.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/ReadSet.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/ReadSet.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Adapter$1.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Adapter$2.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Adapter.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Adapter.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/ReadSet$Iterator.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/ReadSet.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/ReadSet.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Recoverable.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Recoverable.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/RecoverableFactory.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/RecoverableFactory.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$1$1.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$1$2.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$1.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$2$1.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$2$2.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$2.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/AggressiveManager.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/AggressiveManager.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BackoffManager.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BackoffManager.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BaseManager.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BaseManager.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/EruptionManager.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/EruptionManager.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/GreedyManager.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/GreedyManager.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/KarmaManager.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/KarmaManager.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/KindergartenManager.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/KindergartenManager.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/PriorityManager.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/PriorityManager.java create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/util/Random.class create mode 100644 Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/util/Random.java diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/AtomicArray.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/AtomicArray.java new file mode 100644 index 00000000..872de674 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/AtomicArray.java @@ -0,0 +1,179 @@ +/* + * AtomicArray.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; + +import dstm2.exceptions.AbortedException; +import dstm2.exceptions.PanicException; +import dstm2.factory.ofree.ReadSet; +import java.lang.reflect.Array; + +/** + * @author mph + */ +@atomic public class AtomicArray { + + private final T[] array; + private final T[] shadow; + private Transaction writer; + private ReadSet readers; + long version; + private final String FORMAT = "Unexpected transaction state: %s"; + + /** Creates a new instance of AtomicArray */ + public AtomicArray(Class _class, int capacity) { + array = (T[]) Array.newInstance(_class, capacity); + shadow = (T[]) Array.newInstance(_class, capacity); + writer = Transaction.COMMITTED; + readers = new ReadSet(); + version = 0; + } + + public T get(int i) { + Transaction me = Thread.getTransaction(); + Transaction other = null; + ContentionManager manager = Thread.getContentionManager(); + while (true) { + synchronized (this) { + other = openRead(me); + if (other == null) { + return array[i]; + } + } + manager.resolveConflict(me, other); + } + } + + public void set(int i, T value) { + Transaction me = Thread.getTransaction(); + Transaction other = null; + ContentionManager manager = Thread.getContentionManager(); + while (true) { + synchronized (this) { + other = openWrite(me); + if (other == null) { + array[i] = value; + return; + } + } + manager.resolveConflict(me, other); + } + } + /** + * Tries to open object for reading. Returns reference to conflictin transaction, if one exists + **/ + private Transaction openRead(Transaction me) { + // not in a transaction + if (me == null) { // restore object if latest writer aborted + if (writer.isAborted()) { + restore(); + version++; + writer = Transaction.COMMITTED; + } + return null; + } + // Am I still active? + if (!me.isActive()) { + throw new AbortedException(); + } + // Have I already opened this object? + if (writer == me) { + return null; + } + switch (writer.getStatus()) { + case ACTIVE: + return writer; + case COMMITTED: + break; + case ABORTED: + restore(); + version++; + break; + default: + throw new PanicException(FORMAT, writer.getStatus()); + } + writer = Transaction.COMMITTED; + readers.add(me); + return null; + } + + /** + * Tries to open object for reading. Returns reference to conflicting transaction, if one exists + **/ + public Transaction openWrite(Transaction me) { + // not in a transaction + if (me == null) { // restore object if latest writer aborted + if (writer.isAborted()) { + restore(); + version++; + writer = Transaction.COMMITTED; + } + return null; + } + if (!me.validate()) { + throw new AbortedException(); + } + if (me == writer) { + return null; + } + for (Transaction reader : readers) { + if (reader.isActive() && reader != me) { + return reader; + } + } + readers.clear(); + switch (writer.getStatus()) { + case ACTIVE: + return writer; + case COMMITTED: + backup(); + version++; + break; + case ABORTED: + restore(); + version++; + break; + default: + throw new PanicException(FORMAT, writer.getStatus()); + } + writer = me; + return null; + } + + private void restore() { + System.arraycopy(shadow, 0, array, 0, array.length); + } + private void backup() { + System.arraycopy(array, 0, shadow, 0, array.length); + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/ContentionManager.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/ContentionManager.java new file mode 100644 index 00000000..ed342192 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/ContentionManager.java @@ -0,0 +1,77 @@ +/* + * ContentionManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; + +import dstm2.*; +import java.util.Collection; +/** + * Interface satisfied by all contention managers + */ +public interface ContentionManager { + /** + * Either give the writer a chance to finish it, abort it, or both. + * @param me Calling transaction. + * @param other Transaction that's in my way. + */ + void resolveConflict(Transaction me, Transaction other); + + /** + * Either give the writer a chance to finish it, abort it, or both. + * @param me Calling transaction. + * @param other set of transactions in my way + */ + void resolveConflict(Transaction me, Collection other); + + /** + * Assign a priority to caller. Not all managers assign meaningful priorities. + * @return Priority of conflicting transaction. + */ + long getPriority(); + + /** + * Change this manager's priority. + * @param value new priority value + */ + void setPriority(long value); + + /** + * Notify manager that object was opened. + */ + void openSucceeded(); + + /** + * Notify manager that transaction committed. + */ + void committed(); + +}; diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Defaults.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Defaults.java new file mode 100644 index 00000000..4ace327f --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Defaults.java @@ -0,0 +1,65 @@ +/* + * Defaults.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; + +/** + * + * @author Maurice Herlihy + */ +public class Defaults { + /** + * how many threads + **/ + public static final int THREADS = 1; + /** + * benchmark duration in milliseconds + **/ + public static final int TIME = 10000; + /** + * uninterpreted arg passed to benchmark + **/ + public static final int EXPERIMENT = 100; + /** + * fully-qualified contention manager name + **/ + public static final String MANAGER = "dstm2.manager.BackoffManager"; + /** + * fully-qualified factory name + **/ + public static final String FACTORY = "dstm2.factory.shadow.Factory"; + /** + * fully-qualified adapter name + **/ + public static final String ADAPTER = "dstm2.factory.shadow.Adapter";; + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/MMulMain.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/MMulMain.java new file mode 100755 index 00000000..d34b33ba --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/MMulMain.java @@ -0,0 +1,202 @@ +/* + * Main.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; +import static dstm2.Defaults.*; +import dstm2.benchmark.MMulBenchMark; +import dstm2.AtomicArray; + +public class MMulMain { + + /** + * @param args the command line arguments + * usage: dstm.benchmark.Main -b [-m ] [-t <#threads>] [-n <#time-in-ms>] [-e ] [-f " + */ + public static void main(String args[]) { + int numThreads = THREADS; + int numMillis = TIME; + int experiment = EXPERIMENT; + String managerClassName = MANAGER; + Class managerClass = null; + String benchmarkClassName = null; + Class benchmarkClass = null; + + String adapterClassName = Defaults.ADAPTER; + + + // setting for matrix + int SIZE = 600; + + // discard statistics from previous runs + Thread.clear(); + // Parse and check the args + int argc = 0; + try { + while (argc < args.length) { + String option = args[argc++]; + + if (option.equals("-b")) + benchmarkClassName = args[argc]; + else if (option.equals("-t")) + numThreads = Integer.parseInt(args[argc]); + else if (option.equals("-n")) + numMillis = Integer.parseInt(args[argc]); + else if (option.equals("-s")) // parse size + SIZE = Integer.parseInt(args[argc]); + else + reportUsageErrorAndDie(); + argc++; + } + } catch (NumberFormatException e) { + System.out.println("Expected a number: " + args[argc]); + System.exit(0); + } catch (Exception e) { + reportUsageErrorAndDie(); + } + +////////////////////////Don't know what they are ///////////// + // Initialize contention manager. + try { + managerClass = Class.forName(MANAGER); + Thread.setContentionManagerClass(managerClass); + } catch (ClassNotFoundException ex) { + reportUsageErrorAndDie(); + } + + // Initialize adapter class + Thread.setAdapterClass(adapterClassName); + +///////////////////////////////////////////////////////////// + + // initialize benchmark + MMulBenchMark benchmark = null; + try { + benchmarkClass = Class.forName(benchmarkClassName); + benchmark = (MMulBenchMark) benchmarkClass.newInstance(); + } catch (InstantiationException e) { + System.out.format("%s does not implement dstm.benchmark.Benchmark: %s\n", benchmarkClass, e); + System.exit(0); + } catch (ClassCastException e) { + System.out.format("Exception when creating class %s: %s\n", benchmarkClass, e); + System.exit(0); + } catch (Exception e) { + e.printStackTrace(System.out); + System.exit(0); + } + + + + // Set up the benchmark + long startTime = 0; + System.out.println("Testing start"); + +////////////// Setting for matrix multiplication + int dataSet[] = {600,800,1200}; // size of mat + int threadSet[] = {1,2,4,6,8}; // number of thread; + + for(int dSet:dataSet) { + for(int tSet : threadSet) { + numThreads = tSet; // 1,2,4,6,8 + SIZE = dSet; // 600,800,1200 + + System.out.println("Threads: " + numThreads); + System.out.println("Size : " + SIZE); + Thread[] thread = new Thread[numThreads]; + + benchmark.init(SIZE,numThreads); + + System.out.println("init completed"); + + try { + for (int i = 0; i < numThreads - 1; i++) { + // each thread will call different rows to compute Matrix multiplication + thread[i] = benchmark.createThread(i); + } + // rests of matrix rows will be computed in the last thread + // all thread will share the same matrix but compute different rows + thread[numThreads-1] = benchmark.createThread(numThreads-1); + + startTime = System.currentTimeMillis(); + + for (int i = 0; i < numThreads; i++) + thread[i].start(); + Thread.sleep(numMillis); + Thread.stop = true; // notify threads to stop + for (int i = 0; i < numThreads; i++) { + thread[i].join(); + } + } catch (Exception e) { + e.printStackTrace(System.out); + System.exit(0); + } + long stopTime = System.currentTimeMillis(); + + double elapsed = (double)(stopTime - startTime) / 1000.0; + + System.out.println("Elapsed time: " + elapsed + " seconds."); + System.out.println("----------------------------------------"); + benchmark.sanityCheck(); + } // tSet + } // dSet + } + /* + //Run the sanity check for this benchmark + try { + benchmark.sanityCheck(); + } catch (Exception e) { + e.printStackTrace(System.out); + } + + long committed = Thread.totalCommitted; + long total = Thread.totalTotal; + if (total > 0) { + System.out.printf("Committed: %d\nTotal: %d\nPercent committed: (%d%%)\n", + committed, + total, + (100 * committed) / total); + } else { + System.out.println("No transactions executed!"); + } + benchmark.report(); + System.out.println("Elapsed time: " + elapsed + " seconds."); + System.out.println("----------------------------------------"); + + } + */ + + private static void reportUsageErrorAndDie() { + System.out.println("usage: dstm2.Main -b [-m ] [-t <#threads>] [-n <#time-in-ms>] [-e ] [-a ]"); + System.exit(0); + } + +} + diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Main.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Main.java new file mode 100644 index 00000000..5a8a1ceb --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Main.java @@ -0,0 +1,170 @@ +/* + * Main.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; +import static dstm2.Defaults.*; +import dstm2.benchmark.Benchmark; +import dstm2.exceptions.PanicException; +import dstm2.factory.Factory; + +public class Main { + + /** + * @param args the command line arguments + * usage: dstm.benchmark.Main -b [-m ] [-t <#threads>] [-n <#time-in-ms>] [-e ] [-f " + */ + public static void main(String args[]) { + int numThreads = THREADS; + int numMillis = TIME; + int experiment = EXPERIMENT; + String managerClassName = MANAGER; + Class managerClass = null; + String benchmarkClassName = null; + Class benchmarkClass = null; + + String adapterClassName = Defaults.ADAPTER; + + // discard statistics from previous runs + Thread.clear(); + // Parse and check the args + int argc = 0; + try { + while (argc < args.length) { + String option = args[argc++]; + if (option.equals("-m")) + managerClassName = args[argc]; + else if (option.equals("-b")) + benchmarkClassName = args[argc]; + else if (option.equals("-t")) + numThreads = Integer.parseInt(args[argc]); + else if (option.equals("-n")) + numMillis = Integer.parseInt(args[argc]); + else if (option.equals("-e")) + experiment = Integer.parseInt(args[argc]); + else if (option.equals("-a")) + adapterClassName = args[argc]; + else + reportUsageErrorAndDie(); + argc++; + } + } catch (NumberFormatException e) { + System.out.println("Expected a number: " + args[argc]); + System.exit(0); + } catch (Exception e) { + reportUsageErrorAndDie(); + } + + // Initialize contention manager. + try { + managerClass = Class.forName(MANAGER); + Thread.setContentionManagerClass(managerClass); + } catch (ClassNotFoundException ex) { + reportUsageErrorAndDie(); + } + + // Initialize adapter class + Thread.setAdapterClass(adapterClassName); + + // initialize benchmark + Benchmark benchmark = null; + try { + benchmarkClass = Class.forName(benchmarkClassName); + benchmark = (Benchmark) benchmarkClass.newInstance(); + } catch (InstantiationException e) { + System.out.format("%s does not implement dstm.benchmark.Benchmark: %s\n", benchmarkClass, e); + System.exit(0); + } catch (ClassCastException e) { + System.out.format("Exception when creating class %s: %s\n", benchmarkClass, e); + System.exit(0); + } catch (Exception e) { + e.printStackTrace(System.out); + System.exit(0); + } + + // Set up the benchmark + long startTime = 0; + + Thread[] thread = new Thread[numThreads]; + System.out.println("Benchmark: " + benchmarkClass); + System.out.println("Adapter: " + adapterClassName); + System.out.println("Contention manager: " + managerClassName); + System.out.println("Threads: " + numThreads); + System.out.println("Mix: " + experiment + "% updates"); + + try { + for (int i = 0; i < numThreads; i++) + thread[i] = benchmark.createThread(experiment); + startTime = System.currentTimeMillis(); + for (int i = 0; i < numThreads; i++) + thread[i].start(); + Thread.sleep(numMillis); + Thread.stop = true; // notify threads to stop + for (int i = 0; i < numThreads; i++) { + thread[i].join(); + } + } catch (Exception e) { + e.printStackTrace(System.out); + System.exit(0); + } + long stopTime = System.currentTimeMillis(); + + double elapsed = (double)(stopTime - startTime) / 1000.0; + + // Run the sanity check for this benchmark + try { + benchmark.sanityCheck(); + } catch (Exception e) { + e.printStackTrace(System.out); + } + + long committed = Thread.totalCommitted; + long total = Thread.totalTotal; + if (total > 0) { + System.out.printf("Committed: %d\nTotal: %d\nPercent committed: (%d%%)\n", + committed, + total, + (100 * committed) / total); + } else { + System.out.println("No transactions executed!"); + } + benchmark.report(); + System.out.println("Elapsed time: " + elapsed + " seconds."); + System.out.println("----------------------------------------"); + } + + private static void reportUsageErrorAndDie() { + System.out.println("usage: dstm2.Main -b [-m ] [-t <#threads>] [-n <#time-in-ms>] [-e ] [-a ]"); + System.exit(0); + } + +} + diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Thread.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Thread.java new file mode 100644 index 00000000..b2940fd9 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Thread.java @@ -0,0 +1,557 @@ +/* + * Thread.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; + +import dstm2.exceptions.AbortedException; +import dstm2.exceptions.GracefulException; +import dstm2.exceptions.PanicException; +import dstm2.exceptions.SnapshotException; +import dstm2.factory.AtomicFactory; +import dstm2.factory.Factory; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Callable; +import static dstm2.Defaults.*; +/** + * The basic unit of computation for the transactional memory. This + * class extends java.lang.Thread by providing methods to + * begin, commit and abort transactions. + * + * Every Thread has a contention manager, created when + * the thread is created. Before creating any Threads, + * you must call Thread.setContentionManager to set the + * class of the contention manager that will be created. The + * contention manager of a thread is notified (by invoking its + * notification methods) of the results of any methods involving the + * thread. It is also consulted on whether a transaction should be + * begun. + * + * @see dstm2.ContentionManager + */ +public class Thread extends java.lang.Thread { + /** + * Contention manager class. + */ + protected static Class contentionManagerClass; + + /** + * Adapter class. + */ + protected static Class adapterClass; + + /** + * Set to true when benchmark runs out of time. + **/ + public static volatile boolean stop = false; + /** + * number of committed transactions for all threads + */ + public static long totalCommitted = 0; + /** + * total number of transactions for all threads + */ + public static long totalTotal = 0; + /** + * number of committed memory references for all threads + */ + public static long totalCommittedMemRefs = 0; + /** + * total number of memory references for all threads + */ + public static long totalTotalMemRefs = 0; + + static ThreadLocal _threadState = new ThreadLocal() { + protected synchronized ThreadState initialValue() { + return new ThreadState(); + } + }; + static ThreadLocal _thread = new ThreadLocal() { + protected synchronized Thread initialValue() { + return null; + } + }; + + private static int MAX_NESTING_DEPTH = 1; + + private static Object lock = new Object(); + + // Memo-ize factories so we don't have to recreate them. + private static Map factoryTable + = Collections.synchronizedMap(new HashMap()); + + /** + * Create thread to run a method. + * @param target execute this object's run() method + */ + public Thread(final Runnable target) { + super(new Runnable() { + public void run() { + ThreadState threadState = _threadState.get(); + threadState.reset(); + target.run(); + // collect statistics + synchronized (lock){ + totalCommitted += threadState.committed; + totalTotal += threadState.total; + totalCommittedMemRefs += threadState.committedMemRefs; + totalTotalMemRefs += threadState.totalMemRefs; + } + } + }); + } + /** + * no-arg constructor + */ + public Thread() { + super(); + } + + /** + * Establishes a contention manager. You must call this method + * before creating any Thread. + * + * @see dstm2.ContentionManager + * @param theClass class of desired contention manager. + */ + public static void setContentionManagerClass(Class theClass) { + Class cm; + try { + cm = Class.forName("dstm2.ContentionManager"); + } catch (ClassNotFoundException e) { + throw new PanicException(e); + } + try { + contentionManagerClass = theClass; + } catch (Exception e) { + throw new PanicException("The class " + theClass + + " does not implement dstm2.ContentionManager"); + } + } + + /** + * set Adapter class for this thread + * @param adapterClassName adapter class as string + */ + public static void setAdapterClass(String adapterClassName) { + try { + adapterClass = (Class)Class.forName(adapterClassName); + } catch (ClassNotFoundException ex) { + throw new PanicException("Adapter class not found: %s\n", adapterClassName); + } + } + + /** + * Tests whether the current transaction can still commit. Does not + * actually end the transaction (either commitTransaction or + * abortTransaction must still be called). The contention + * manager of the invoking thread is notified if the onValidate fails + * because a TMObject opened for reading was invalidated. + * + * @return whether the current transaction may commit successfully. + */ + static public boolean validate() { + ThreadState threadState = _threadState.get(); + return threadState.validate(); + } + + /** + * Gets the current transaction, if any, of the invoking Thread. + * + * @return the current thread's current transaction; null if + * there is no current transaction. + */ + static public Transaction getTransaction() { + return _threadState.get().transaction; + } + + /** + * Gets the contention manager of the invoking Thread. + * + * @return the invoking thread's contention manager + */ + static public ContentionManager getContentionManager() { + return _threadState.get().manager; + } + + /** + * Create a new factory instance. + * @param _class class to implement + * @return new factory + */ + static public Factory makeFactory(Class _class) { + try { + Factory factory = (Factory) factoryTable.get(_class); + if (factory == null) { + factory = new AtomicFactory(_class, adapterClass); + factoryTable.put(_class, factory); + } + return factory; + } catch (Exception e) { + throw new PanicException(e); + } + } + + /** + * Execute a transaction + * @param xaction execute this object's call() method. + * @return result of call() method + */ + public static T doIt(Callable xaction) { + ThreadState threadState = _threadState.get(); + ContentionManager manager = threadState.manager; + T result = null; + try { + while (!Thread.stop) { + threadState.beginTransaction(); + try { + result = xaction.call(); + } catch (AbortedException d) { + } catch (SnapshotException s) { + threadState.abortTransaction(); + } catch (Exception e) { + e.printStackTrace(); + throw new PanicException("Unhandled exception " + e); + } + threadState.totalMemRefs += threadState.transaction.memRefs; + if (threadState.commitTransaction()) { + threadState.committedMemRefs += threadState.transaction.memRefs; + return result; + } + threadState.transaction.attempts++; + // transaction aborted + } + if (threadState.transaction != null) { + threadState.abortTransaction(); + } + } finally { + threadState.transaction = null; + } + // collect statistics + synchronized (lock){ + totalTotalMemRefs = threadState.totalMemRefs; + totalCommittedMemRefs = threadState.committedMemRefs; + totalCommitted += threadState.committed; + totalTotal += threadState.total; + threadState.reset(); // set up for next iteration + } + throw new GracefulException(); + } + /** + * Execute transaction + * @param xaction call this object's run() method + */ + public static void doIt(final Runnable xaction) { + doIt(new Callable() { + public Boolean call() { + xaction.run(); + return false; + }; + }); + } + + /** + * number of transactions committed by this thread + * @return number of transactions committed by this thread + */ + public static long getCommitted() { + return totalCommitted; + } + + /** + * umber of transactions aborted by this thread + * @return number of aborted transactions + */ + public static long getAborted() { + return totalTotal - totalCommitted; + } + + /** + * number of transactions executed by this thread + * @return number of transactions + */ + public static long getTotal() { + return totalTotal; + } + + /** + * Register a method to be called every time this thread validates any transaction. + * @param c abort if this object's call() method returns false + */ + public static void onValidate(Callable c) { + _threadState.get().onValidate.add(c); + } + /** + * Register a method to be called every time the current transaction is validated. + * @param c abort if this object's call() method returns false + */ + public static void onValidateOnce(Callable c) { + _threadState.get().onValidateOnce.add(c); + } + /** + * Register a method to be called every time this thread commits a transaction. + * @param r call this object's run() method + */ + public static void onCommit(Runnable r) { + _threadState.get().onCommit.add(r); + } + /** + * Register a method to be called once if the current transaction commits. + * @param r call this object's run() method + */ + public static void onCommitOnce(Runnable r) { + _threadState.get().onCommitOnce.add(r); + } + /** + * Register a method to be called every time this thread aborts a transaction. + * @param r call this objec't run() method + */ + public static void onAbort(Runnable r) { + _threadState.get().onAbort.add(r); + } + /** + * Register a method to be called once if the current transaction aborts. + * @param r call this object's run() method + */ + public static void onAbortOnce(Runnable r) { + _threadState.get().onAbortOnce.add(r); + } + /** + * get thread ID for debugging + * @return unique id + */ + public static int getID() { + return _threadState.get().hashCode(); + } + + /** + * reset thread statistics + */ + public static void clear() { + totalTotal = 0; + totalCommitted = 0; + totalCommittedMemRefs = 0; + totalTotalMemRefs = 0; + stop = false; + } + + /** + * Class that holds thread's actual state + */ + public static class ThreadState { + + int depth = 0; + ContentionManager manager; + + private long committed = 0; // number of committed transactions + private long total = 0; // total number of transactions + private long committedMemRefs = 0; // number of committed reads and writes + private long totalMemRefs = 0; // total number of reads and writes + + Set> onValidate = new HashSet>(); + Set onCommit = new HashSet(); + Set onAbort = new HashSet(); + Set> onValidateOnce = new HashSet>(); + Set onCommitOnce = new HashSet(); + Set onAbortOnce = new HashSet(); + + Transaction transaction = null; + + /** + * Creates new ThreadState + */ + public ThreadState() { + try { + manager = (ContentionManager)Thread.contentionManagerClass.newInstance(); + } catch (NullPointerException e) { + throw new PanicException("No default contention manager class set."); + } catch (Exception e) { // Some problem with instantiation + throw new PanicException(e); + } + } + + /** + * Resets any metering information (commits/aborts, etc). + */ + public void reset() { + committed = 0; // number of committed transactions + total = 0; // total number of transactions + committedMemRefs = 0; // number of committed reads and writes + totalMemRefs = 0; // total number of reads and writes + } + + /** + * used for debugging + * @return string representation of thread state + */ + public String toString() { + return + "Thread" + hashCode() + "["+ + "committed: " + committed + "," + + "aborted: " + ( total - committed) + + "]"; + } + + /** + * Can this transaction still commit? + * This method may be called at any time, not just at transaction end, + * so we do not clear the onValidateOnce table. + * @return true iff transaction might still commit + */ + public boolean validate() { + try { + // permanent + for (Callable v : onValidate) { + if (!v.call()) { + return false; + } + } + // temporary + for (Callable v : onValidateOnce) { + if (!v.call()) { + return false; + } + } + return transaction.validate(); + } catch (Exception ex) { + return false; + } + } + + /** + * Call methods registered to be called on commit. + */ + public void runCommitHandlers() { + try { + // permanent + for (Runnable r: onCommit) { + r.run(); + } + // temporary + for (Runnable r: onCommitOnce) { + r.run(); + } + onCommitOnce.clear(); + onValidateOnce.clear(); + } catch (Exception ex) { + throw new PanicException(ex); + } + } + + /** + * Starts a new transaction. Cannot nest transactions deeper than + * Thread.MAX_NESTING_DEPTH. The contention manager of the + * invoking thread is notified when a transaction is begun. + */ + public void beginTransaction() { + transaction = new Transaction(); + if (depth == 0) { + total++; + } + // first thing to fix if we allow nested transactions + if (depth >= 1) { + throw new PanicException("beginTransaction: attempting to nest transactions too deeply."); + } + depth++; + } + + /** + * Attempts to commit the current transaction of the invoking + * Thread. Always succeeds for nested + * transactions. The contention manager of the invoking thread is + * notified of the result. If the transaction does not commit + * because a TMObject opened for reading was + * invalidated, the contention manager is also notified of the + * inonValidate. + * + * + * @return whether commit succeeded. + */ + public boolean commitTransaction() { + depth--; + if (depth < 0) { + throw new PanicException("commitTransaction invoked when no transaction active."); + } + if (depth > 0) { + throw new PanicException("commitTransaction invoked on nested transaction."); + } + if (depth == 0) { + if (validate() && transaction.commit()) { + committed++; + runCommitHandlers(); + return true; + } + abortTransaction(); + return false; + } else { + return true; + } + } + + /** + * Aborts the current transaction of the invoking Thread. + * Does not end transaction, but ensures it will never commit. + */ + public void abortTransaction() { + runAbortHandlers(); + transaction.abort(); + } + + /** + * Call methods registered to be called on commit. + */ + public void runAbortHandlers() { + try { + // permanent + for (Runnable r: onAbort) { + r.run(); + } + // temporary + for (Runnable r: onAbortOnce) { + r.run(); + } + onAbortOnce.clear(); + onValidateOnce.clear(); + } catch (Exception ex) { + throw new PanicException(ex); + } + } + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Transaction.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Transaction.java new file mode 100644 index 00000000..aceba6b4 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/Transaction.java @@ -0,0 +1,256 @@ +/* + * Transaction.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; + +import dstm2.exceptions.PanicException; +import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; + +/** + * Transaction.java + * Keeps a transaction's status and contention manager. + */ + +public class Transaction { + + /** + * Possible transaction status + **/ + public enum Status {ABORTED, ACTIVE, COMMITTED}; + + /** + * Predefined committed transaction + */ + public static Transaction COMMITTED = new Transaction(Status.COMMITTED); + /** + * Predefined orted transaction + */ + public static Transaction ABORTED = new Transaction(Status.ABORTED); + + /** + * Is transaction waiting for another? + */ + public boolean waiting = false; + + /** + * Number of times this transaction tried + */ + public int attempts = 0; + + /** + * Number of unique memory references so far. + */ + public int memRefs = 0; + + /** + * Time in nanos when transaction started + */ + public long startTime = 0; + /** + * Time in nanos when transaction committed or aborted + */ + public long stopTime = 0; + + // generate unique ids + private static AtomicInteger unique = new AtomicInteger(100); + + /** Updater for status */ + private static final + AtomicReferenceFieldUpdater + statusUpdater = AtomicReferenceFieldUpdater.newUpdater + (Transaction.class, Status.class, "status"); + + private volatile Status status; + + private long id; + + private ContentionManager manager; + + /** + * Creates a new, active transaction. + */ + public Transaction() { + this.status = Status.ACTIVE; + this.id = this.startTime = System.nanoTime(); + this.manager = Thread.getContentionManager(); + } + + /** + * Creates a new transaction with given status. + * @param myStatus active, committed, or aborted + */ + private Transaction(Transaction.Status myStatus) { + this.status = myStatus; + this.startTime = 0; + } + + /** + * Access the transaction's current status. + * @return current transaction status + */ + public Status getStatus() { + return status; + } + + /** + * Tests whether transaction is active. + * @return whether transaction is active + */ + public boolean isActive() { + return this.getStatus() == Status.ACTIVE; + } + + /** + * Tests whether transaction is aborted. + * @return whether transaction is aborted + */ + public boolean isAborted() { + return this.getStatus() == Status.ABORTED; + } + + /** + * Tests whether transaction is committed. + * @return whether transaction is committed + */ + public boolean isCommitted() { + return (this.getStatus() == Status.COMMITTED); + } + + /** + * Tests whether transaction is committed or active. + * @return whether transaction is committed or active + */ + public boolean validate() { + Status status = this.getStatus(); + switch (status) { + case COMMITTED: + throw new PanicException("committed transaction still running"); + case ACTIVE: + return true; + case ABORTED: + return false; + default: + throw new PanicException("unexpected transaction state: " + status); + } + } + + /** + * Tries to commit transaction + * @return whether transaction was committed + */ + public boolean commit() { + try { + while (this.getStatus() == Status.ACTIVE) { + if (statusUpdater.compareAndSet(this, + Status.ACTIVE, + Status.COMMITTED)) { + return true; + } + } + return false; + } finally { + wakeUp(); + } + } + + /** + * Tries to abort transaction + * @return whether transaction was aborted (not necessarily by this call) + */ + public boolean abort() { + try { + while (this.getStatus() == Status.ACTIVE) { + if (statusUpdater.compareAndSet(this, Status.ACTIVE, Status.ABORTED)) { + return true; + } + } + return this.getStatus() == Status.ABORTED; + } finally { + wakeUp(); + } + } + + /** + * Returns a string representation of this transaction + * @return the string representcodes[ation + */ + public String toString() { + switch (this.status) { + case COMMITTED: + return "Transaction" + this.startTime + "[committed]"; + case ABORTED: + return "Transaction" + this.startTime + "[aborted]"; + case ACTIVE: + return "Transaction" + this.startTime + "[active]"; + default: + return "Transaction" + this.startTime + "[???]"; + } + } + + /** + * Block caller while transaction is active. + */ + public synchronized void waitWhileActive() { + while (this.getStatus() == Status.ACTIVE) { + try { + wait(); + } catch (InterruptedException ex) {} + } + } + /** + * Block caller while transaction is active. + */ + public synchronized void waitWhileActiveNotWaiting() { + while (getStatus() == Status.ACTIVE && !waiting) { + try { + wait(); + } catch (InterruptedException ex) {} + } + } + + /** + * Wake up any transactions waiting for this one to finish. + */ + public synchronized void wakeUp() { + notifyAll(); + } + + /** + * This transaction's contention manager + * @return the manager + */ + public ContentionManager getContentionManager() { + return manager; + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/atomic.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/atomic.java new file mode 100644 index 00000000..bfa3b57e --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/atomic.java @@ -0,0 +1,47 @@ +/* + * atomic.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation indicating that class is atomic (can be shared among transactions). + * @author Maurice Herlihy + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface atomic { + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/Benchmark.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/Benchmark.java new file mode 100644 index 00000000..d3254401 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/Benchmark.java @@ -0,0 +1,64 @@ +/* + * Benchmark.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.benchmark; +import dstm2.Thread; + + +/** + * A simple interface to set up uniform benchmarks for the DSTM system + **/ +public interface Benchmark +{ + /** + * Creates a thread to run the benchmark. + * + * @param which int which test to run + * @return Thread the thread to run the benchmark + */ + public Thread createThread(int which); + + /** + * Checks that after running the benchmark, the resulting data + * structure meets a specified "sanity check". Prints messages to + * System.out if problems are found, or confirmation + * that no problems were found. + * @param stats how big should the object be? + */ + public void sanityCheck(); + + /** + * Reports statistics. + */ + public void report(); +} + diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/IntSetBenchmark.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/IntSetBenchmark.java new file mode 100644 index 00000000..38033904 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/IntSetBenchmark.java @@ -0,0 +1,264 @@ +/* + * IntSetBenchmark.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.benchmark; + +import dstm2.exceptions.AbortedException; +import dstm2.exceptions.GracefulException; +import dstm2.exceptions.PanicException; +import dstm2.Thread; +import dstm2.atomic; +import dstm2.benchmark.Benchmark; +import dstm2.benchmark.Benchmark; +import dstm2.util.Random; +import java.util.Iterator; +import java.util.concurrent.Callable; + +/** + * This abstract class is the superclass for the integer set benchmarks. + * @author Maurice Herlihy + * @date April 2004 + */ +public abstract class IntSetBenchmark implements Benchmark, Iterable { + + /** + * How large to initialize the integer set. + */ + protected final int INITIAL_SIZE = 8; + + /** + * After the run is over, synchronize merging statistics with other threads. + */ + static final Object lock = new Object(); + /** + * local variable + */ + int element; + /** + * local variable + */ + int value; + + /** + * Number of calls to insert() + */ + int insertCalls = 0; + /** + * number of calls to contains() + */ + int containsCalls = 0; + /** + * number of calls to remove() + */ + int removeCalls = 0; + /** + * amount by which the set size has changed + */ + int delta = 0; + + /** + * Give subclass a chance to intialize private fields. + */ + protected abstract void init(); + + /** + * Iterate through set. Not necessarily thread-safe. + */ + public abstract Iterator iterator(); + + /** + * Add an element to the integer set, if it is not already there. + * @param v the integer value to add from the set + * @return true iff value was added. + */ + public abstract boolean insert(int v); + + /** + * Tests wheter a value is in an the integer set. + * @param v the integer value to insert into the set + * @return true iff presence was confirmed. + */ + public abstract boolean contains(int v); + + /** + * Removes an element from the integer set, if it is there. + * @param v the integer value to delete from the set + * @return true iff v was removed + */ + public abstract boolean remove(int v); + + /** + * Creates a new test thread. + * @param percent Mix of mutators and observers. + * @return Thread to run. + */ + public Thread createThread(int percent) { + try { + TestThread testThread = new TestThread(this, percent); + return testThread; + } catch (Exception e) { + e.printStackTrace(System.out); + return null; + } + } + + /** + * Prints an error message to System.out, including a + * standard header to identify the message as an error message. + * @param s String describing error + */ + protected static void reportError(String s) { + System.out.println(" ERROR: " + s); + System.out.flush(); + } + + public void report() { + System.out.println("Insert/Remove calls:\t" + (insertCalls + removeCalls)); + System.out.println("Contains calls:\t" + containsCalls); + } + + private class TestThread extends Thread { + IntSetBenchmark intSet; + /** + * Thread-local statistic. + */ + int myInsertCalls = 0; + /** + * Thread-local statistic. + */ + int myRemoveCalls = 0; + /** + * Thread-local statistic. + */ + int myContainsCalls = 0; + /** + * Thread-local statistic. + */ + int myDelta = 0; // net change + public int percent = 0; // percent inserts + + TestThread(IntSetBenchmark intSet, int percent) { + this.intSet = intSet; + this.percent = percent; + } + + public void run() { + Random random = new Random(this.hashCode()); + random.setSeed(System.currentTimeMillis()); // comment out for determinstic + + boolean toggle = true; + try { + while (true) { + boolean result = true; + element = random.nextInt(); + if (Math.abs(element) % 100 < percent) { + if (toggle) { // insert on even turns + value = element / 100; + result = Thread.doIt(new Callable() { + public Boolean call() { + return intSet.insert(value); + } + }); + if (result) + myDelta++; + } else { // remove on odd turns + result = Thread.doIt(new Callable() { + public Boolean call() { + return intSet.remove(value); + } + }); + myRemoveCalls++; + if (result) + this.myDelta--; + } + toggle = !toggle; + } else { + Thread.doIt(new Callable() { + public Void call() { + intSet.contains(element / 100); + return null; + } + }); + myContainsCalls++; + } + } + } catch (GracefulException g) { + // update statistics + synchronized (lock) { + insertCalls += myInsertCalls; + removeCalls += myRemoveCalls; + containsCalls += myContainsCalls; + delta += myDelta; + } + return; + } + } + } + + public void sanityCheck() { + long expected = INITIAL_SIZE + delta; + int length = 1; + + int prevValue = Integer.MIN_VALUE; + for (int value : this) { + length++; + if (value < prevValue) { + System.out.println("ERROR: set not sorted"); + System.exit(0); + } + if (value == prevValue) { + System.out.println("ERROR: set has duplicates!"); + System.exit(0); + } + if (length == expected) { + System.out.println("ERROR: set has bad length!"); + System.exit(0); + } + } + System.out.println("Integer Set OK"); + } + + /** + * Creates a new IntSetBenchmark + */ + public IntSetBenchmark() { + int size = 2; + init(); + Random random = new Random(this.hashCode()); + while (size < INITIAL_SIZE) { + if (insert(random.nextInt())) { + size++; + } + } + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/List.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/List.java new file mode 100644 index 00000000..9ce4076e --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/List.java @@ -0,0 +1,161 @@ +/* + * List.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.benchmark; + +import dstm2.atomic; +import dstm2.factory.Factory; +import dstm2.Thread; +import java.util.Iterator; + +/** + * @author Maurice Herlihy + */ +public class List extends IntSetBenchmark { + + static Factory factory = Thread.makeFactory(INode.class); + + protected INode first; + + protected void init() { + INode firstList = factory.create(); + firstList.setValue(Integer.MIN_VALUE); + this.first = firstList; + INode firstNext = factory.create(); + firstNext.setValue(Integer.MAX_VALUE); + firstList.setNext(firstNext); + } + + /** + * This method does all the work. It returns a + * dstm.benchmark.IntSetBenchmark.Neighborhood object containing + * the transactional node with maximal value strictly less than v, and the + * non-transactional TestFactory element containing v (or null, if none exists). + * @param v value sought + * @return neighborhood of value + */ + protected Neighborhood find(int v) { + INode prevNode = this.first; + INode currNode = prevNode.getNext(); + while (currNode.getValue() < v) { + prevNode = currNode; + currNode = prevNode.getNext(); + } + if (currNode.getValue() == v) + return new Neighborhood(prevNode, currNode); + else + return new Neighborhood(prevNode); + } + + /** + * Add an element to the integer set, if it is not already there. + * @param v the integer value to add from the set + * @return true iff value was added. + */ + public boolean insert(int v) { + INode newNode = factory.create(); + newNode.setValue(v); + Neighborhood hood = find(v); + if (hood.currNode != null) { + return false; + } else { + INode prevNode = hood.prevNode; + newNode.setNext(prevNode.getNext()); + prevNode.setNext(newNode); + return true; + } + } + + /** + * Tests wheter a value is in an the integer set. + * @param v the integer value to insert into the set + * @return true iff presence was confirmed. + */ + public boolean contains(int v) { + Neighborhood hood = find(v); + return hood.currNode != null; + } + + /** + * Removes an element from the integer set, if it is there. + * @param v the integer value to delete from the set + * @return true iff v was removed + */ + public boolean remove(int v) { + INode newNode = factory.create(); + newNode.setValue(v); + Neighborhood hood = find(v); + if (hood.currNode == null) { + return false; + } else { + INode prevNode = hood.prevNode; + prevNode.setNext(hood.currNode.getNext()); + return true; + } + } + + @atomic public interface INode { + int getValue(); + void setValue(int value); + INode getNext(); + void setNext(INode value); + } + + public Iterator iterator() { + return new Iterator() { + INode cursor = List.this.first.getNext(); + public boolean hasNext() { + return cursor.getNext().getValue() != Integer.MAX_VALUE; + } + public Integer next() { + INode node = cursor; + cursor = cursor.getNext(); + return node.getValue(); + } + public void remove() { + throw new UnsupportedOperationException(); + } + + }; + } + protected class Neighborhood { + public INode prevNode; + public INode currNode; + public Neighborhood(INode prevNode, INode currNode) { + this.prevNode = prevNode; + this.currNode = currNode; + } + public Neighborhood(INode prevNode) { + this.prevNode = prevNode; + } + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/ListRelease.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/ListRelease.java new file mode 100644 index 00000000..87417993 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/ListRelease.java @@ -0,0 +1,167 @@ +/* + * ListRelease.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.benchmark; + +import dstm2.atomic; +import dstm2.factory.Factory; +import dstm2.Thread; +import dstm2.factory.Releasable; +import java.lang.reflect.Method; +import java.util.Iterator; + +/** + * @author Maurice Herlihy + */ +public class ListRelease extends IntSetBenchmark { + + static Factory factory = Thread.makeFactory(INode.class); + + protected INode first; + + protected void init() { + INode firstList = factory.create(); + firstList.setValue(Integer.MIN_VALUE); + this.first = firstList; + INode firstNext = factory.create(); + firstNext.setValue(Integer.MAX_VALUE); + firstList.setNext(firstNext); + } + + /** + * This method does all the work. It returns a + * dstm.benchmark.IntSetBenchmark.Neighborhood object containing + * the transactional node with maximal value strictly less than v, and the + * non-transactional TestFactory element containing v (or null, if none exists). + * @param v value sought + * @return neighborhood of value + */ + protected Neighborhood find(int v) { + INode last = null; + INode prev = this.first; + INode curr = prev.getNext(); + while (curr.getValue() < v) { + if (last != null) { + ((Releasable)last).release(); + } + prev = curr; + curr = prev.getNext(); + } + if (curr.getValue() == v) + return new Neighborhood(prev, curr); + else + return new Neighborhood(prev); + } + + /** + * Add an element to the integer set, if it is not already there. + * @param v the integer value to add from the set + * @return true iff value was added. + */ + public boolean insert(int v) { + INode newNode = factory.create(); + newNode.setValue(v); + Neighborhood hood = find(v); + if (hood.curr != null) { + return false; + } else { + INode prev = hood.prev; + newNode.setNext(prev.getNext()); + prev.setNext(newNode); + return true; + } + } + + /** + * Tests wheter a value is in an the integer set. + * @param v the integer value to insert into the set + * @return true iff presence was confirmed. + */ + public boolean contains(int v) { + Neighborhood hood = find(v); + return hood.curr != null; + } + + /** + * Removes an element from the integer set, if it is there. + * @param v the integer value to delete from the set + * @return true iff v was removed + */ + public boolean remove(int v) { + INode newNode = factory.create(); + newNode.setValue(v); + Neighborhood hood = find(v); + if (hood.curr == null) { + return false; + } else { + INode prev = hood.prev; + prev.setNext(hood.curr.getNext()); + return true; + } + } + + @atomic public interface INode { + int getValue(); + void setValue(int value); + INode getNext(); + void setNext(INode value); + } + + public Iterator iterator() { + return new Iterator() { + INode cursor = ListRelease.this.first.getNext(); + public boolean hasNext() { + return cursor.getNext().getValue() != Integer.MAX_VALUE; + } + public Integer next() { + INode node = cursor; + cursor = cursor.getNext(); + return node.getValue(); + } + public void remove() { + throw new UnsupportedOperationException(); + } + + }; + } + protected class Neighborhood { + public INode prev; + public INode curr; + public Neighborhood(INode prev, INode curr) { + this.prev = prev; + this.curr = curr; + } + public Neighborhood(INode prev) { + this.prev = prev; + } + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/ListSnap.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/ListSnap.java new file mode 100644 index 00000000..f06c4824 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/ListSnap.java @@ -0,0 +1,200 @@ +/* + * ListSnap.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.benchmark; +import dstm2.exceptions.AbortedException; +import dstm2.exceptions.GracefulException; +import dstm2.atomic; +import dstm2.benchmark.IntSetBenchmark; +import dstm2.Thread; +import dstm2.factory.Factory; +import dstm2.factory.Snapable; +import java.lang.reflect.Method; +import java.util.Iterator; +import java.util.concurrent.Callable; + +/** + * @author Maurice Herlihy + */ +public class ListSnap extends IntSetBenchmark { + + static Factory factory = Thread.makeFactory(INode.class); + + protected INode first; + + protected void init() { + INode firstList = factory.create(); + firstList.setValue(Integer.MIN_VALUE); + this.first = firstList; + INode firstNext = factory.create(); + firstNext.setValue(Integer.MAX_VALUE); + firstList.setNext(firstNext); + } + + /** + * Tests wheter a value is in an the integer set. + * @param v the integer value to insert into the set + * @return true iff presence was confirmed. + */ + public boolean contains(int v) { + INode last = null; + INode lastSnap = null; + INode prev = this.first; + INode prevSnap = ((Snapable)prev).snapshot(); + INode curr = prevSnap.getNext(); + INode currSnap = ((Snapable)curr).snapshot(); + while (currSnap.getValue()< v) { + if (last != null) { + ((Snapable)last).validate(lastSnap); + } + last = prev; + lastSnap = prevSnap; + prev = curr; + prevSnap = currSnap; + curr = prevSnap.getNext(); + currSnap = ((Snapable)curr).snapshot(); + } + if (lastSnap != null) { + ((Snapable)last).upgrade(lastSnap); + } + ((Snapable)prev).upgrade(prevSnap); + ((Snapable)curr).upgrade(currSnap); + return (curr.getValue()== v); + } + + /** + * Removes an element from the integer set, if it is there. + * @param v the integer value to delete from the set + * @return true iff v was removed + */ + public boolean remove(int v) { + INode last = null; + INode lastSnap = null; + INode prev = this.first; + INode prevSnap = ((Snapable)prev).snapshot(); + INode curr = prevSnap.getNext(); + INode currSnap = ((Snapable)curr).snapshot(); + while (currSnap.getValue()< v) { + if (last != null) { + ((Snapable)last).validate(lastSnap); + } + last = prev; + lastSnap = prevSnap; + prev = curr; + prevSnap = currSnap; + curr = prevSnap.getNext(); + currSnap = ((Snapable)curr).snapshot(); + } + if (lastSnap != null) { + ((Snapable)last).upgrade(lastSnap); + } + ((Snapable)prev).upgrade(prevSnap); + ((Snapable)curr).upgrade(currSnap); + if (curr.getValue()!= v) { + return false; + } else { + prev.setNext(curr.getNext()); + return true; + } + } + + public boolean insert(int v) { + INode last = null; + INode lastSnap = null; + INode prev = this.first; + Snapable prevS = (Snapable)prev; + INode prevSnap = prevS.snapshot(); + INode curr = prevSnap.getNext(); + INode currSnap = ((Snapable)curr).snapshot(); + INode newNode = factory.create(); + while (currSnap.getValue()< v) { + if (last != null) { + ((Snapable)last).validate(lastSnap); + } + last = prev; + lastSnap = prevSnap; + prev = curr; + prevSnap = currSnap; + curr = prevSnap.getNext(); + currSnap = ((Snapable)curr).snapshot(); + } + if (lastSnap != null) { + ((Snapable)last).upgrade(lastSnap); + } + ((Snapable)prev).upgrade(prevSnap); + ((Snapable)curr).upgrade(currSnap); + if (currSnap.getValue()== v) { + return false; + } else { + newNode.setNext(curr); + prev.setNext(newNode); + return true; + } + } + + public Iterator iterator() { + return new Iterator() { + INode cursor = ListSnap.this.first.getNext(); + public boolean hasNext() { + return cursor.getNext().getValue() == Integer.MAX_VALUE; + } + public Integer next() { + INode node = cursor; + cursor = cursor.getNext(); + return node.getValue(); + } + public void remove() { + throw new UnsupportedOperationException(); + } + + }; + } + protected class Neighborhood { + public INode prev; + public INode curr; + public Neighborhood(INode prev, INode curr) { + this.prev = prev; + this.curr = curr; + } + public Neighborhood(INode prev) { + this.prev = prev; + } + } + + @atomic public interface INode { + int getValue(); + void setValue(int value); + INode getNext(); + void setNext(INode value); + } +} + diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/MMulBenchMark.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/MMulBenchMark.java new file mode 100755 index 00000000..65c4f409 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/MMulBenchMark.java @@ -0,0 +1,138 @@ + +package dstm2.benchmark; + +import dstm2.AtomicArray; +import dstm2.Thread; +import dstm2.benchmark.Benchmark; +import dstm2.benchmark.Matrix.ArrayHolder; + + +public class MMulBenchMark implements Benchmark { + + Matrix matrix; + int SIZE; + int numThreads; + + int base; + int increments; + + int setV; + int getV; + + public void init(int SIZE,int numThreads) { + matrix = new Matrix(SIZE,SIZE,SIZE); + + this.SIZE = SIZE; + this.numThreads = numThreads; + increments = SIZE / numThreads; + base =0; + + matrix.setValues(); + matrix.transpose(); + + setV =0; + getV =0; + } + + public Thread createThread(int order) + { + MMul mmul; + try { + if(order < numThreads-1) { + mmul = new MMul(matrix,base, base+increments, 0, SIZE); + base += increments; + } + else + mmul = new MMul(matrix,base,SIZE,0,SIZE); + return mmul; + }catch(Exception e) + { + e.printStackTrace(System.out); + return null; + } + } + + private class MMul extends Thread { + + Matrix mmul; + + public int x0; // # of start row + public int x1; // # of end row + public int y0; // # of start col + public int y1; // # of end col + + MMul(Matrix mul,int x0,int x1,int y0,int y1) + { + this.mmul = mul; + this.x0 = x0; + this.x1 = x1; + this.y0 = y0; + this.y1 = y1; + + } + + public void run() { + + AtomicArray la=mmul.a; + AtomicArray lc=mmul.c; + AtomicArray lb=mmul.btranspose; + + int M=mmul.M; + + ArrayHolder rowHolder; // temporary variable to get column array + + //Use btranspose for cache performance + for(int i = x0; i< x1; i++){ + + rowHolder = la.get(i); + AtomicArray ai = rowHolder.getAtomicArray(); // a[i][] + + rowHolder = lc.get(i); + AtomicArray ci = rowHolder.getAtomicArray(); // c[i][] + + for (int j = y0; j < y1; j++) { + + double innerProduct=0; + + rowHolder = lb.get(j); // b[j][] + AtomicArray bj = rowHolder.getAtomicArray(); // b[j][] + + for(int k = 0; k < M; k++) { + innerProduct += ai.get(k) * bj.get(k); // innerProduct = a[i][j] * b[j][k]; + getV += 2; + } + + ci.set(j, Double.valueOf(innerProduct)); // c[i][j] = innerProduct; + setV++; + } + } + } + + } + + + // print out the matrices to be multiplied + public void sanityCheck() + { + int chk=0; + + for(int i=0;i ci = rowHolder.getAtomicArray(); + System.out.println("C[0][0] = " + ci.get(0)); + System.out.println("Chk = " + chk); + + } + + public void report() + { + + +// System.out.println("SetValue Calls : " + setV); +// System.out.println("GetValue Calls : " + getV); + } + +} + diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/Matrix.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/Matrix.java new file mode 100755 index 00000000..7c0ae44f --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/Matrix.java @@ -0,0 +1,196 @@ + +package dstm2.benchmark; + +import dstm2.AtomicArray; +import dstm2.atomic; +import dstm2.factory.Factory; +import dstm2.Thread; + +/* atomic interface + * the factory will create this interface's instance + */ +/* this class will use atomic double array */ +public class Matrix +{ + static Factory ArrayHolderfactory = Thread.makeFactory(ArrayHolder.class); +// static Factory INodeFactory = Thread.makeFactory(double.class); + + public int L, M, N; + public AtomicArray a; // double[][] a; + public AtomicArray b; // '' b; + public AtomicArray c; // '' c; + public AtomicArray btranspose; // '' btranspose; + + // create all matrices using factory.create() + public Matrix(int L, int M, int N) { + this.L = L; + this.M = M; + this.N = N; +// a = new INode[L][M]; +// b = new INode[M][N]; +// c = new INode[L][N]; +// btranspose = new INode[N][M]; + + ArrayHolder arrayHolder; // temporary variable to initiate 2dim array + AtomicArray doubleArray; + + System.out.println("L = " + L); + System.out.println("M = " + M); + System.out.println("N = " + N); + + + // set up matrix a[L][M] + a = new AtomicArray(ArrayHolder.class,L); // create row of atomic array + + for(int i=0;i(Double.class,M); // create column + + arrayHolder.setAtomicArray(doubleArray); // set the pointer to double array + + a.set(i,arrayHolder); + + } + + + // set up matrix b[M][N] + b = new AtomicArray(ArrayHolder.class,M); // create row of atomic array + + for(int i=0;i(Double.class,N); // create column + + arrayHolder.setAtomicArray(doubleArray); // set the pointer to double array + + b.set(i,arrayHolder); + + } + + // set up matrix c[L][N] + c = new AtomicArray(ArrayHolder.class,L); // create row of atomic array + + for(int i=0;i(Double.class,N); // create column + + arrayHolder.setAtomicArray(doubleArray); // set the pointer to double array + + c.set(i,arrayHolder); + + } + + // set up matrix btranspose[N][M] + btranspose = new AtomicArray(ArrayHolder.class,N); // create row of atomic array + + for(int i=0;i(Double.class,M); // create column + + if(null == doubleArray) + { + System.out.println("no heap space???"); + + } + + if(null == arrayHolder) + { + System.out.println("no heap space???"); + } + + arrayHolder.setAtomicArray(doubleArray); // set the pointer to double array + + btranspose.set(i,arrayHolder); + + } + + } + + // initialize matrices + public void setValues() { + + ArrayHolder arrayHolder; // temporary variable to initiate 2dim array + + + // initiate matrix A[L][M] + for(int i = 0; i < L; i++) { // row + arrayHolder = a.get(i); + AtomicArray ai = arrayHolder.getAtomicArray(); // get the column of array + + for(int j = 0; j < M; j++) { + ai.set(j,Double.valueOf(j+1)); // a[i][j] = j+1 + } + } + + // initiate matrix B[M][N] + for(int i = 0; i < M; i++) { // row + + arrayHolder = b.get(i); + AtomicArray bi = arrayHolder.getAtomicArray(); // get the column of array + for(int j = 0; j < N; j++) { + bi.set(j,Double.valueOf(j+1)); // b[i][j] = j+1 + } + } + + // initiate matrix C[L][N] + for(int i = 0; i < L; i++) { + + arrayHolder = c.get(i); + AtomicArray ci = arrayHolder.getAtomicArray(); // get the column of array + + for(int j = 0; j < N; j++) { + ci.set(j,Double.valueOf(0)); // c[i][j] = 0 + } +// System.out.print(ci.get(0) + " "); + } + + // initiate matrix btranspose[N][M] + for(int i = 0; i < N; i++) { + + arrayHolder = btranspose.get(i); + AtomicArray btransposei = arrayHolder.getAtomicArray(); // get the column of array + + for(int j = 0; j < M; j++) { + + btransposei.set(j,Double.valueOf(0)); // btranspose[i][j] = 0 + } +// System.out.println("Value of i = " + i); + } + } + + // initialize btranspose + // it doesn't have parameter because there is only one transpose + public void transpose() { + + ArrayHolder b_arrayHolder; + ArrayHolder btrans_arrayHolder; + + for(int row = 0; row < M; row++) { + + b_arrayHolder = b.get(row); // b[row][] + AtomicArray brow= b_arrayHolder.getAtomicArray(); + + for(int col = 0; col < N; col++) { + btrans_arrayHolder = btranspose.get(col); // btranspose[col][] + AtomicArray btranspose_col = btrans_arrayHolder.getAtomicArray(); + + btranspose_col.set(row, brow.get(col)); // btranspose[col][row] = b[row][col] + + } + } + } + + + @atomic public interface ArrayHolder { + AtomicArray getAtomicArray(); + void setAtomicArray(AtomicArray d); + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/RBTree.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/RBTree.java new file mode 100644 index 00000000..193dda9b --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/RBTree.java @@ -0,0 +1,645 @@ +/* + * RBTree.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.benchmark; + +import dstm2.atomic; +import dstm2.benchmark.Benchmark; +import dstm2.factory.Factory; +import dstm2.Thread; +import java.util.EmptyStackException; +import java.util.Iterator; +import java.util.Stack; + +/** + * Red-Black tree benchmark. + * Adapted from {@link http://www.codeproject.com/csharp/RedBlackCS.asp + * } + * @author Maurice Herlihy + */ +public class RBTree extends IntSetBenchmark { + /** + * Transactional RBNode factory. + */ + static Factory factory = Thread.makeFactory(RBNode.class); + /** + * Each node has one of two colors. + */ + public enum Color {BLACK, RED}; + + /** + * Left hand of darkness: the actual root of the tree is the left-hand + * child of this node. Indirection needed to make changes to the root + * transactional. + */ + private RBNode root; + /** + * Used in place of null pointer. + */ + public static RBNode sentinelNode; + /** + * Initializes the tree shared by all the threads. + **/ + public void init() { + sentinelNode = factory.create(); + sentinelNode.setLeft(null); + sentinelNode.setRight(null); + sentinelNode.setParent(null); + sentinelNode.setColor(Color.BLACK); + root = factory.create(); + root.setLeft(sentinelNode); + this.root.setValue(Integer.MIN_VALUE); + this.root.setColor(Color.BLACK); + int size = 0; + } + + protected RBNode getRoot() { + return root.getLeft(); + } + + protected void setRoot(RBNode value) { + root.setLeft(value); + } + + /** + * Inserts an element into the tree, if it is not already present. + * @param key element to insert + * @return true iff item was not there already + */ + public boolean insert(int key) { + // traverse tree - find where node belongs + RBNode node = factory.create(); + RBNode temp = getRoot(); + + while(temp != sentinelNode) { // find Parent + node.setParent(temp); + if ( key == temp.getValue()) { + return false; + } else if (key > temp.getValue()) { + temp = temp.getRight(); + } else { + temp = temp.getLeft(); + } + } + + // setup node + node.setValue(key); + node.setLeft(sentinelNode); + node.setRight(sentinelNode); + + // insert node into tree starting at parent's location + if(node.getParent() != null) { + if (node.getValue() > node.getParent().getValue()) { + node.getParent().setRight(node); + } else + node.getParent().setLeft(node); + } else + setRoot(node); // first node added + + restoreAfterInsert(node); // restore red-black properities + return true; + } + + /** + * Tests whether item is present. + * @return whether the item was present + * @param key item to search for + */ + public boolean contains(int key) { + + RBNode node = getRoot(); // begin at root + + // traverse tree until node is found + while(node != sentinelNode) { + if (key == node.getValue()) { + return true; + } else if (key < node.getValue()) { + node = node.getLeft(); + } else { + node = node.getRight(); + } + } + return false; + } + + /** + * Remove item if present. + * @return whether the item was removed + * @param key item to remove + */ + public boolean remove(int key) { + + // find node + RBNode node; + + node = getRoot(); + while(node != sentinelNode) { + if (key == node.getValue()) { + break; + } else if (key < node.getValue()) { + node = node.getLeft(); + } else { + node = node.getRight(); + } + } + + if(node == sentinelNode) + return false; // key not found + + delete(node); + return true; + } + + /** + * Delete a node. + * A node to be deleted will be: + * 1. a leaf with no children + * 2. have one child + * 3. have two children + * If the deleted node is red, the red black properties still hold. + * If the deleted node is black, the tree needs rebalancing + * @param z start at this node + */ + private void delete(RBNode z) { + + RBNode x = factory.create(); // work node to contain the replacement node + RBNode y; // work node + + // find the replacement node (the successor to x) - the node one with + // at *most* one child. + if(z.getLeft() == sentinelNode || z.getRight() == sentinelNode) + y = z; // node has sentinel as a child + else { + // z has two children, find replacement node which will + // be the leftmost node greater than z + y = z.getRight(); // traverse right subtree + while(y.getLeft() != sentinelNode) // to find next node in sequence + y = y.getLeft(); + } + + // at this point, y contains the replacement node. it's content will be copied + // to the valules in the node to be deleted + + // x (y's only child) is the node that will be linked to y's old parent. + if(y.getLeft() != sentinelNode) + x = y.getLeft(); + else + x = y.getRight(); + + // replace x's parent with y's parent and + // link x to proper subtree in parent + // this removes y from the chain + x.setParent(y.getParent()); + if(y.getParent() != null) + if(y == y.getParent().getLeft()) + y.getParent().setLeft(x); + else + y.getParent().setRight(x); + else + setRoot(x); // make x the root node + + // copy the values from y (the replacement node) to the node being deleted. + // note: this effectively deletes the node. + if(y != z) { + z.setValue(y.getValue()); + } + + if(y.getColor() == Color.BLACK) + restoreAfterDelete(x); + } + + /** + * restoreAfterDelete + * Deletions from red-black trees may destroy the red-black + * properties. Examine the tree and restore. Rotations are normally + * required to restore it + * @param x start here + */ + private void restoreAfterDelete(RBNode x) { + // maintain Red-Black tree balance after deleting node + + RBNode y; + + while(x != getRoot() && x.getColor() == Color.BLACK) { + if(x == x.getParent().getLeft()) // determine sub tree from parent + { + y = x.getParent().getRight(); // y is x's sibling + if(y.getColor() == Color.RED) { // x is black, y is red - make both black and rotate + y.setColor(Color.BLACK); + x.getParent().setColor(Color.RED); + rotateLeft(x.getParent()); + y = x.getParent().getRight(); + } + if(y.getLeft().getColor() == Color.BLACK && + y.getRight().getColor() == Color.BLACK) { // children are both black + y.setColor(Color.RED); // change parent to red + x = x.getParent(); // move up the tree + } else { + if(y.getRight().getColor() == Color.BLACK) { + y.getLeft().setColor(Color.BLACK); + y.setColor(Color.RED); + rotateRight(y); + y = x.getParent().getRight(); + } + y.setColor(x.getParent().getColor()); + x.getParent().setColor(Color.BLACK); + y.getRight().setColor(Color.BLACK); + rotateLeft(x.getParent()); + setRoot(x); + } + } else { // right subtree - same as code above with right and left swapped + y = x.getParent().getLeft(); + if(y.getColor() == Color.RED) { + y.setColor(Color.BLACK); + x.getParent().setColor(Color.RED); + rotateRight(x.getParent()); + y = x.getParent().getLeft(); + } + if(y.getRight().getColor() == Color.BLACK && + y.getLeft().getColor() == Color.BLACK) { + y.setColor(Color.RED); + x = x.getParent(); + } else { + if(y.getLeft().getColor() == Color.BLACK) { + y.getRight().setColor(Color.BLACK); + y.setColor(Color.RED); + rotateLeft(y); + y = x.getParent().getLeft(); + } + y.setColor(x.getParent().getColor()); + x.getParent().setColor(Color.BLACK); + y.getLeft().setColor(Color.BLACK); + rotateRight(x.getParent()); + setRoot(x); + } + } + } + x.setColor(Color.BLACK); + } + + /** + * Insertions may destroy the red-black properties. Examine the tree + * and rotate as needed to restore the property. + * @param x start here + */ + private void restoreAfterInsert(RBNode x) { + RBNode y; + + // maintain red-black tree properties after adding x + while(x != getRoot() && x.getParent().getColor() == Color.RED) { + // Parent node is .Colored red; + if(x.getParent() == x.getParent().getParent().getLeft()) // determine traversal path + { // is it on the Left or Right subtree? + y = x.getParent().getParent().getRight(); // get uncle + if(y!= null && y.getColor() == Color.RED) { // uncle is red; change x's Parent and uncle to black + x.getParent().setColor(Color.BLACK); + y.setColor(Color.BLACK); + // grandparent must be red. Why? Every red node that is not + // a leaf has only black children + x.getParent().getParent().setColor(Color.RED); + x = x.getParent().getParent(); // continue loop with grandparent + } else { + // uncle is black; determine if x is greater than Parent + if(x == x.getParent().getRight()) { // yes, x is greater than Parent; rotate Left + // make x a Left child + x = x.getParent(); + rotateLeft(x); + } + // no, x is less than Parent + x.getParent().setColor(Color.BLACK); // make Parent black + x.getParent().getParent().setColor(Color.RED); // make grandparent black + rotateRight(x.getParent().getParent()); // rotate right + } + } else { // x's Parent is on the Right subtree + // this code is the same as above with "Left" and "Right" swapped + y = x.getParent().getParent().getLeft(); + if(y!= null && y.getColor() == Color.RED) { + x.getParent().setColor(Color.BLACK); + y.setColor(Color.BLACK); + x.getParent().getParent().setColor(Color.RED); + x = x.getParent().getParent(); + } else { + if(x == x.getParent().getLeft()) { + x = x.getParent(); + rotateRight(x); + } + x.getParent().setColor(Color.BLACK); + x.getParent().getParent().setColor(Color.RED); + rotateLeft(x.getParent().getParent()); + } + } + } + getRoot().setColor(Color.BLACK); // root should always be black + } + + /** + * rotateLeft + * Rebalance the tree by rotating the nodes to the left + * @param x start here + */ + public void rotateLeft(RBNode x) { + // pushing node x down and to the Left to balance the tree. x's Right child (y) + // replaces x (since y > x), and y's Left child becomes x's Right child + // (since it's < y but > x). + + RBNode y = x.getRight(); // get x's Right node, this becomes y + + // set x's Right link + x.setRight(y.getLeft()); // y's Left child's becomes x's Right child + + // modify parents + if(y.getLeft() != sentinelNode) + y.getLeft().setParent(x); // sets y's Left Parent to x + + if(y != sentinelNode) + y.setParent(x.getParent()); // set y's Parent to x's Parent + + if(x.getParent() != null) { // determine which side of it's Parent x was on + if(x == x.getParent().getLeft()) + x.getParent().setLeft(y); // set Left Parent to y + else + x.getParent().setRight(y); // set Right Parent to y + } else + setRoot(y); // at root, set it to y + + // link x and y + y.setLeft(x); // put x on y's Left + if(x != sentinelNode) // set y as x's Parent + x.setParent(y); + } + + /** + * rotateRight + * Rebalance the tree by rotating the nodes to the right + * @param x start here + */ + public void rotateRight(RBNode x) { + // pushing node x down and to the Right to balance the tree. x's Left child (y) + // replaces x (since x < y), and y's Right child becomes x's Left child + // (since it's < x but > y). + + RBNode y = x.getLeft(); // get x's Left node, this becomes y + + // set x's Right link + x.setLeft(y.getRight()); // y's Right child becomes x's Left child + + // modify parents + if(y.getRight() != sentinelNode) + y.getRight().setParent(x); // sets y's Right Parent to x + + if(y != sentinelNode) + y.setParent(x.getParent()); // set y's Parent to x's Parent + + if(x.getParent() != null) // null=root, could also have used root + { // determine which side of its Parent x was on + if(x == x.getParent().getRight()) + x.getParent().setRight(y); // set Right Parent to y + else + x.getParent().setLeft(y); // set Left Parent to y + } else + setRoot(y); // at root, set it to y + + // link x and y + y.setRight(x); // put x on y's Right + if(x != sentinelNode) // set y as x's Parent + x.setParent(y); + } + + /** + * returns number of black nodes akibg root to leaf path + * @param root tree root + * @return number of black nodes in left-most path + */ + private int countBlackNodes(RBNode root) { + if (sentinelNode == root) + return 0; + int me = (root.getColor() == Color.BLACK) ? 1 : 0; + RBNode left = (sentinelNode == root.getLeft()) + ? sentinelNode + : root.getLeft(); + return me + countBlackNodes(left); + } + + /** + * counts nodes in tree + * @param root tree root + * @return number of nodes in tree + */ + private int count(RBNode root) { + if (root == sentinelNode) + return 0; + return 1 + count(root.getLeft()) + count(root.getRight()); + } + + /** + * Checks internal consistency. + * @param root tree root + * @param blackNodes number of black nodes expected in leaf-to-root path + * @param soFar number of black nodes seen in path so far + */ + private void recursiveValidate(RBNode root, int blackNodes, int soFar) { + // Empty sub-tree is vacuously OK + if (sentinelNode == root) + return; + + Color rootcolor = root.getColor(); + soFar += ((Color.BLACK == rootcolor) ? 1 : 0); + root.setMarked(true); + + // Check left side + RBNode left = root.getLeft(); + if (sentinelNode != left) { + if (left.getColor() != Color.RED || rootcolor != Color.RED) { + System.out.println("Error: Two consecutive red nodes!"); + } + if (left.getValue() < root.getValue()) { + System.out.println(" Error; Tree values out of order!"); + } + if (!left.isMarked()) { + System.out.println("Error; Cycle in tree structure!"); + } + recursiveValidate(left, blackNodes, soFar); + } + + // Check right side + RBNode right = root.getRight(); + if (sentinelNode != right) { + if (right.getColor() != Color.RED || rootcolor != Color.RED) { + System.out.println("Error: Two consecutive red nodes!"); + } + if (right.getValue() > root.getValue()) { + System.out.println("Error: Tree values out of order!"); + } + if (!right.isMarked()) { + System.out.println("Error: Cycle in tree structure!"); + } + recursiveValidate(right, blackNodes, soFar); + } + + // Check black node count + if (sentinelNode == root.getLeft() || sentinelNode == root.getRight()) { + if (soFar != blackNodes) { + System.out.println("Error: Variable number of black nodes to leaves!"); + return; + } + } + // Everything checks out if we get this far. + return; + } + + public Iterator iterator() { + return new MyIterator(); + } + + /** + * Tree node definition. Implemented by transactional factory. + */ + @atomic public interface RBNode { + + /** + * Reads node value. + * @return node value + */ + public int getValue(); + + /** + * sets node value + * @param newValue new value for node + */ + public void setValue(int newValue); + + /** + * is node marked? + * @return whether node is marked + */ + public boolean isMarked(); + + /** + * mark or unmark node + * @param newMarked new value for marked flag + */ + public void setMarked(boolean newMarked); + + /** + * examine node color + * @return node color + */ + public Color getColor(); + + /** + * change node's color + * @param newColor new color + */ + public void setColor(Color newColor); + + /** + * examine node's parent + * @return node's parent + */ + public RBNode getParent(); + + /** + * change node's parent + * @param newParent new parent + */ + public void setParent(RBNode newParent); + + /** + * examine node's left child + * @return node's left child + */ + public RBNode getLeft(); + + /** + * change node's right child + * @param newLeft new left child + */ + public void setLeft(RBNode newLeft); + + /** + * examine node's right child + * @return node's right child + */ + public RBNode getRight(); + + /** + * change node's left child + * @param newRight new right child + */ + public void setRight(RBNode newRight); + + } + + private class MyIterator implements Iterator { + RBNode node = getRoot(); + RBNode prev = node; + RBNode next = node; + Stack stack = new Stack(); + MyIterator() { + while (node != sentinelNode) { + stack.push(node); + node = node.getLeft(); + } + next = prev = stack.peek(); + } + public boolean hasNext() { + return !stack.empty(); + } + public void remove() { + throw new UnsupportedOperationException(); + } + public Integer next() { + prev = next; + node = stack.peek(); + // If I have a right child, move there and descend left + if (node.getRight() != sentinelNode) { + node = node.getRight(); + while (node != sentinelNode) { + stack.push(node); + node = node.getLeft(); + } + } else { + RBNode seen = sentinelNode; + while (node.getRight() == seen) { + seen = stack.pop(); + if (stack.empty()) { + next = null; + break; + } else { + next = node = stack.peek(); + } + } + } + return prev.getValue(); + } + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/SkipList.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/SkipList.java new file mode 100644 index 00000000..8092c278 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/benchmark/SkipList.java @@ -0,0 +1,252 @@ +/* + * SkipList.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.benchmark; + +import dstm2.AtomicArray; +import dstm2.atomic; +import dstm2.factory.Factory; +import dstm2.Thread; +import dstm2.util.Random; +import java.util.Iterator; + +/** + * @author Maurice Herlihy + */ +public class SkipList extends IntSetBenchmark { + /** + * Transactional Node factory. + */ + static Factory factory = Thread.makeFactory(Node.class); + + // Maximum level any node in a skip list can have + private final int MaxLevel = 32; + + // Probability factor used to determine the node level + private final double Probability = 0.5; + + // The skip list header. It also serves as the NIL node. + private Node header; + + // Random number generator for generating random node levels. + private Random random; + + // Current maximum list level. + private int listLevel; + + protected void init() { + int size = 0; + header = factory.create(); + random = new Random(); + initNode(header, MaxLevel); + listLevel = 1; + AtomicArray forward = header.getForward(); + for (int i = 0; i < MaxLevel; i++) { + forward.set(i, header); + } + } + + public java.util.Iterator iterator() { + return new MyIterator(); + } + + public boolean insert(int key) { + Node[] update = new Node[MaxLevel]; + Node curr = search(key, update); + // If key does not already exist in the skip list. + if(curr.getKey() != key) { + insert(key, update); + return true; + } else { + return false; + } + } + + public boolean contains(int key) { + Node[] dummy = new Node[MaxLevel]; + Node curr = search(key, dummy); + return curr.getKey() == key; + } + + public boolean remove(int key) { + Node[] update = new Node[MaxLevel]; + Node curr = search(key, update); + if(curr.getKey() == key) { + // Redirect references to victim node to successors. + for (int i = 0; i < listLevel && update[i].getForward().get(i) == curr; i++) { + update[i].getForward().set(i, curr.getForward().get(i)); + } + return true; + } + return false; + } + + private class MyIterator implements Iterator { + Node node = header.getForward().get(0); + public boolean hasNext() { + return node != header; + } + public void remove() { + throw new UnsupportedOperationException(); + } + public Integer next() { + node = node.getForward().get(0); + return node.getKey(); + } + } + /** + * Initializes an instant of a Node with its node level. + **/ + public void initNode(Node node, int level) { + node.setForward(new AtomicArray(Node.class, level)); + } + + /** + * Initializes an instant of a Node with its node level and + * key/value pair. + **/ + public void initNode(Node node, int level, int key) { + node.setForward(new AtomicArray(Node.class, level)); + node.setKey(key); + } + + /// + /// Returns a level value for a new SkipList node. + /// + /// The level value for a new SkipList node. + /// + /// + private int getNewLevel() { + int level = 1; + while(random.nextDouble() < Probability && level < MaxLevel && level <= listLevel) { + level++; + } + return level; + } + + /// + /// Inserts a keykey into the SkipList. + /// + /// The key to insert into the SkipList. + /// + /// + /// An array of nodes holding references to places in the SkipList in + /// which the search for the place to insert the new key/value pair + /// dropped down one level. + /// + /// + private void insert(int key, Node[] update) { + // Get the level for the new node. + int newLevel = getNewLevel(); + // If new node level greater than skip list level. + if (newLevel > listLevel) { + // Make sure our update references above the current skip list + // level point to the header. + for (int i = listLevel; i < newLevel; i++) { + update[i] = header; + } + // The current skip list level is now the new node level. + listLevel++; + } + // Create the new node. + Node newNode = factory.create(); + initNode(newNode, newLevel, key); + // Insert the new node into the skip list. + for (int i = 0; i < newLevel; i++) { + // Initialize new node forward references to update forward references + newNode.getForward().set(i, update[i].getForward().get(i)); + // Set update forward references to new node. + update[i].getForward().set(i, newNode); + } + } + + /// + /// Search for the specified key. + /// + /// The key to search for. + /// + /// + /// A SkipList node to hold the results of the search. + /// + /// + /// An array of nodes holding references to the places in the SkipList + /// search in which the search dropped down one level. + /// + /// + /// Returns node with least key greater than or equal to search key. + /// + /// + private Node search(int key, Node[] update) { + int comp; + // Begin at the start of the skip list. + Node curr = header; + // Work our way down from the top of the skip list to the bottom. + for(int i = listLevel - 1; i >= 0; i--) { + comp = curr.getForward().get(i).getKey(); + // While we haven't reached the end of the skip list and the + // current key is less than the search key. + while(curr.getForward().get(i) != header && comp < key) { + // Move forward in the skip list. + curr = curr.getForward().get(i); + // Get the current key. + comp = curr.getForward().get(i).getKey(); + } + // Keep track of each node where we move down a level. Used later to rearrange + // node references when inserting a new element. + update[i] = curr; + } + // Move ahead in the skip list. If the key isn't there, we end up at a node with a + // key greater key, and otherwise at a node with the same key. + curr = curr.getForward().get(0); + return curr; + } + + @atomic public interface Node { + /** + * Get array of nodes further along in the skip list. + **/ + public AtomicArray getForward(); + /** + * Set array of nodes further along in the skip list. + **/ + public void setForward(AtomicArray value); + + /** + * Get node value. + **/ + public int getKey(); + /** + * Set node value. + **/ + public void setKey(int value); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/AbortedException.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/AbortedException.class new file mode 100644 index 0000000000000000000000000000000000000000..be310b7a0c2584aed2a047bc815068420132ee79 GIT binary patch literal 383 zcmZ9HOH0E*6ot=Cn^w}NkAk|3t6FJ;F6u%Nq$()Ih1DRqnzTb1Nhgv_#DC*&a8+>O z!lnPnjd&A$Ko@f^_s)0jnfds7eFLzImV+XeGg&EPwTv}FGm)_pp)cb^Mf&Fagg_UB z+91-25!(17Or?F-@7{iHJiil4he|7RL@2bkeL`^%O(dZ)R9ar9vp~kzA_#fXY7g(l zqwqqZr{2iKN>2|mgENZKcr4FU4jl(kY~N?h&E9Q2YKYOD@pK$lna ca=iY7Z}B|4DRp+{uon3~N9{A&V8TN48!lf?q5uE@ literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/AbortedException.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/AbortedException.java new file mode 100644 index 00000000..ac3c0889 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/AbortedException.java @@ -0,0 +1,56 @@ +/* + * AbortedException.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.exceptions; +/** + * Thrown by an attempt to open a TMObject to indicate + * that the current transaction cannot commit. + **/ +public class AbortedException extends java.lang.RuntimeException { + static final long serialVersionUID = 6572490566353395650L; + + /** + * Creates a new DeniedException instance with no detail message. + */ + public AbortedException() { + super(); + } + + + /** + * Creates a new Denied instance with the specified detail message. + * @param msg the detail message. + */ + public AbortedException(String msg) { + super(msg); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/GracefulException.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/GracefulException.class new file mode 100644 index 0000000000000000000000000000000000000000..dc7de2e88de6f2c6947ec34991393319ac1beec2 GIT binary patch literal 303 zcmZWkyH3ME5S(@5SeS$a3Iuea0;I$u1r?$R4}lN`4-1Lv;w8A5VjT$@n%$k*nH}xt_uD&wZ7juTpc|nVVUf@)*=c1`cBL-t)$u-oP6(ZGVN0*9 zPnD@SyxAFCf2}@$5L&z1YQINlY;2~4=D3(Lp?j(=pH=yU-KClsVd9ITav2}$8Y~|< zmGNz54xTc8@DenekiRuig^TPCJ7znpsK`%2yTWTy)U?A3^2s$zcSoi^YJVhA* literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/GracefulException.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/GracefulException.java new file mode 100644 index 00000000..cb2e0082 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/GracefulException.java @@ -0,0 +1,48 @@ +/* + * GracefulException.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.exceptions; + +/** + * Thrown by the BaseContentionManager when the benchmark time has elapsed. + **/ +public class GracefulException extends java.lang.RuntimeException { + static final long serialVersionUID = 6572490566353395650L; + + /** + * Creates a new GracefulException instance with no detail message. + */ + public GracefulException() { + super(); + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/PanicException.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/PanicException.class new file mode 100644 index 0000000000000000000000000000000000000000..757e83bb57da3149913751a72f17c15a49446ef4 GIT binary patch literal 596 zcmaKo%}xR_6opUu8y!JVM3Ifbg+V|^+#$w=L{~(O5I3%dp<)TsF+)+eK9Vbp3m?FT zGTtJ}Xozic+TMQm^!C1gyuJabAZH?ml!+xQ>s?yQih+!QRfgE1kU||XgbUkO43WCm z;S9-!ko;`uwz=Q3+kJ`@3XPt9Z(Ds^cCDuJh3wX@1EKSFk2|WSJu)*;9nS{ity|xF z(AMJ=v*`_eho1`lRQke}!Z~?#_?;4-+|}>KVPMX{S{zxd>qA^if?=aGQ0~6Pzv+SX zJDVXlt^0B)m2mlwHA8B8`SmI4$c^W_wqmFT>;31;fi6rak$FdrIXInDNie- zHCh~jJ=2E4BsCEtEfc(hC&Cvd_!h!6>AqMhzaTV1_;1c0*;a_AhD>rc$xFM%ilrHR Yl?po;^NCq}$uWfFCj|z0*8l(j literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/PanicException.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/PanicException.java new file mode 100644 index 00000000..0325beab --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/PanicException.java @@ -0,0 +1,69 @@ +/* + * PanicException.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.exceptions; + +/** + * Thrown to indicate an error in the use of the transactional memory; + * that is, a violation of the assumptions of use. + */ +public class PanicException extends java.lang.RuntimeException { + + /** + * Creates new PanicException with no detail message. + */ + public PanicException() { + } + + public PanicException(String format, Object ... args) { + super(String.format(format, args)); + } + + /** + * Creates a new PanicException with the specified detail message. + * + * @param msg the detail message. + */ + public PanicException(String msg) { + super(msg); + } + + /** + * Creates an PanicException with the specified cause. + * + * @param cause Throwable that caused PanicException to be thrown + */ + public PanicException(Throwable cause) { + super(cause); + } +} + diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/SnapshotException.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/exceptions/SnapshotException.class new file mode 100644 index 0000000000000000000000000000000000000000..e7c2fb400ce2488cb8734a9dd4faf21ac2e3c6c2 GIT binary patch literal 321 zcmZXOF;4SnapshotException instance with no detail message. + */ + public SnapshotException() { + super(); + } + + + /** + * Creates a new SnapshotException instance with the specified detail message. + * @param msg the detail message. + */ + public SnapshotException(String msg) { + super(msg); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Adapter$Getter.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Adapter$Getter.class new file mode 100644 index 0000000000000000000000000000000000000000..388a7b2a776484e62c155e47dc9843dd34ebd2fe GIT binary patch literal 300 zcmZusyH3ME5S$HuVB-WAp`)a*8>~qOG#kb0Z5oCj{%dYK85!B)CcX zl(UxH#o;@yss6{M~hNytkjo3cYK@@&P!uoud)|W*iOG^yZ*&eTDB3q ze-J&it<-l)7$XfK-VaJRJGjXs5JvnjKn~#u4s(~;2p+RPCK~ucyX!6Rs<;&1i?c}?(1d^DceLg8^K@ep&#H!iLbF< zjHmZz-Z1m#^J}*UFhdgJEW|m%SJD{5G=190cPWglOY!`&(aJ5Zb3&9=Wi4H2H6cjX zc~7Qy`Ftq9A5w&I)^t|sRb|*9ekkOd)Ar^N72<+$S+s6@D_*5?jr|bE`&FhL%Q*3O zi684)+oh3ht6M_y_g60PuTwxEc-$BupKt=7@raR!fYHwu;|LIdVc2JiAXQhlXo!@4?Lx7n)n1KOyX4NrILgw z7@x0oxVfFmNc;U?%n3$gzyHH9qaoxbO0$15VVbas|61G(C>QSqqpEnmCdMAa#ZpD` zGMRC#ZV~#)>Rg0Q+B&NmmII5cZ8`7ByUUOO literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Adapter.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Adapter.java new file mode 100644 index 00000000..52135902 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Adapter.java @@ -0,0 +1,77 @@ +/* + * Adapter.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; + +/** + * User-defined factories use this adapter interface. + * @author Maurice Herlihy + */ +public interface Adapter { + /** + * A Setter object represents void setMumble(V value) method. + **/ + public interface Setter { + /** + * Call setter. + */ + public void call(V x); + } + + /** + * A Getter object represents V getMumble() method. + **/ + public interface Getter { + /** + * Call getter. + */ + public V call(); + } + + /** + * creates a Setter + * @param methodName Name of setter, e.g., "setValue" + * @param _class field class, e.g., int.TYPE + * @return Setter object to call. + */ + public Setter makeSetter(String methodName, Class _class); + + /** + * creates a Getter + * @param methodName Name of getter, e.g., "getValue" + * @param _class field class, e.g., int.TYPE + * @return Getter object to call. + */ + public Getter makeGetter(String methodName, Class _class); + + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/AtomicFactory.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/AtomicFactory.class new file mode 100644 index 0000000000000000000000000000000000000000..d18cb3a039aa9732ff66f787dd0106727ca79307 GIT binary patch literal 12882 zcmeHOd3;pW*?!*1awn4uBm+Ul4OFZl35il0aX=)5Ef4~d0LBFzCYNMnm@S>eH9>>B|Pb62LL|sy4nB;N|Oj`Gz*XS&47q z+m-kZzN?q-8F)$Gy{wn-2k-;@(7=xj{Me75=;Hqsz^Qm8fS=-LO7U~O{6a6k)X9FO zT)k@Gzm@9O27Xh4DR?b_-{OEDzthI=4gA5tAN}}K0B7M9KmHs*GybBNzbe0f^W*P+ z{6lB_ryqxT7Z@TOD!u?(r6hn$q_hI6IYTMMy7{845%Q$_k zQp#$-1hp}~LMBL!ANMNxM86!P?MZqG1>{&c&M(IYuwG8k#2GobrJV+lWq#?P0cE*1R`}&SLslBnDKH~Fk^Z!mYK=z*1_agZmqxZkn&Oc}ZYDmr7miAZ`d#pn4W zCY#;WHEYhS;WN&zZ|@mMZ<^7xAreg|Q`?$a9EM4%Yn4Y+RwT{&Ce%*z3|+qdQY)G! z^JTTuI4$MuwbBb?R=lSpvWe6UwZmpzkxKSksr0s4-dQ@+saT>{M-LQ?Hl0Q7`KYv# zTIHllwY1Xe9gIg(_8UQO(N)@$sothYe|E+25%Y^B<04X3flN;@M3#}(yH#c}C7 z^YpINo#{wA78L~h2M79cOShA10_7)g=vCZ%R~p z1XGH^+qNq~>(1J!fu_-MRvLe}D3&Q3q}P-_iJ5Y#Y!uWLo7jUccNWz}+>}j{F!4Uh zhYzZdN$EFavneSVFeGitplmVaGCU-hSSV9AAei_N9yjq}JZ{KVQ?|+F6fdt4TcD0) zdSP-f(X(J{)aqB)6-;(!v$8z{O)DaaSkyyNZ4aH2NT#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MQvNp&nb zT6N5TNoZY6b*v?{E+Mocgw}dOD~daKe)5P|cuY2MXV8n?(uch~Px0yZL@ulhR~3f} zRFN~*|0S$+hwa%v{TngjC?!s%Y$8UI#7I9evY8l3;oUO8?NORrqCq?;S>P(AgYJAAj|O;kPajJUHkX$)8#P8v`J*_Qhl|Wl_PJ&7b_R_a zZYbZ$le*6B{08mtOLoBH;5&4u$Gh#9)9IWV>cWOTc?-d?-|kW8bq)f8ciKf<)-CO~ z>U*q?^kl|`PHvi-^3qG(GlyY)wzi#9QnEeSc^fL_S!qp$jD8-{}I%uky~n z+wyMf4Ap)YsJe%a>BWwM`k-Nu(a;kH*Yf{dfICvZT#2zfWt=2e^91!8W|nI)m-mJI zkkgX45xY0xZn>E|*tg?ZxdmU7Tj|ob;rG1%Ro*EfeqUI}&kLL6Uj9FU`(!S^F`O?C R(1gyp;1ExJc*KK!{{lXTOOF5m literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/AtomicFactory.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/AtomicFactory.java new file mode 100644 index 00000000..b28845bc --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/AtomicFactory.java @@ -0,0 +1,411 @@ +/* + * AtomicFactory.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; +/* + * AtomicFactory.java + * + * Created on November 16, 2005, 1:25 PM + * + * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. In particular, and without limitation, these intellectual property rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent applications in the U.S. and in other countries. + * U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Use is subject to license terms. + * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. + */ +import dstm2.ContentionManager; +import dstm2.exceptions.AbortedException; +import dstm2.exceptions.PanicException; +import dstm2.Transaction; +import dstm2.Transaction.Status; +import dstm2.factory.BaseFactory; +import dstm2.factory.ClassLoader; +import dstm2.factory.Copyable; +import dstm2.factory.Property; +import dstm2.factory.Releasable; +import dstm2.factory.Snapable; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.*; +import org.apache.bcel.Repository; + +import static org.apache.bcel.Constants.*; +/** + * Factory for constructing atomic objects. + * User provides an Adapter class. + * @author Maurice Herlihy + */ +public class AtomicFactory extends dstm2.factory.BaseFactory { + + Class adapterClass; + + public AtomicFactory(Class _class, Class adapterClass) { + super(_class); + synchronized (lock) { // BCEL is not thread-safe! + interfaceName = _class.getName(); + this.adapterClass = adapterClass; + className = _class.getName() + "$"; + Class[] interfaces = adapterClass.getInterfaces(); + String[] myInterfaces = new String[interfaces.length]; + myInterfaces[0] = _class.getName(); + int i = 1; + for (Class c : interfaces) { + if (!c.equals(dstm2.factory.Adapter.class)) { + myInterfaces[i++] = c.getName(); + } + } + _cg = new ClassGen(className, + "java.lang.Object", + "Factory.java", + ACC_PUBLIC | ACC_SUPER, + myInterfaces); + _cp = _cg.getConstantPool(); + _factory = new InstructionFactory(_cg, _cp); + createFields(); + createCtor(); + for (Property p : properties) { + createGetMethod(p); + createSetMethod(p); + } + for (Class c : interfaces) { + if (!c.equals(dstm2.factory.Adapter.class)) { + JavaClass jc = null; + try { + jc = Repository.lookupClass(c); + } catch (java.lang.ClassNotFoundException ex) { + throw new PanicException("Class not found: " + _class); + } + for (Method m : jc.getMethods()) { + passThrough(c, m); + } + } + } + createStatic(); + seal(); + } + } + + public T create() { + try { + synchronized(lock) { // not sure this is needed ... + return theClass.newInstance(); + } + } catch (InstantiationException ex) { + throw new PanicException(ex); + } catch (IllegalAccessException ex) { + throw new PanicException(ex); + } + } + + private String getFieldName(Property p) { + return p.getMethod.getName() + "$$"; + } + private String setFieldName(Property p) { + return p.setMethod.getName() + "$$"; + } + + private void createFields() { + FieldGen field; + // static Class _class; + field = new FieldGen(ACC_STATIC, new ObjectType("java.lang.Class"), "_class", _cp); + _cg.addField(field.getField()); + // Adapter adapter; + field = new FieldGen(0, new ObjectType(adapterClass.getName()), "adapter", _cp); + _cg.addField(field.getField()); + // getter and setter fields for each property + for (Property p : properties) { + field = new FieldGen(0, new ObjectType("dstm2.factory.Adapter$Getter"), getFieldName(p), _cp); + _cg.addField(field.getField()); + + field = new FieldGen(0, new ObjectType("dstm2.factory.Adapter$Setter"), setFieldName(p), _cp); + _cg.addField(field.getField()); + } + } + + private void initRegularField(Property p, InstructionList il, MethodGen method) { + + InstructionHandle ih_0 = il.append(new PUSH(_cp, p._class.getName())); + il.append(_factory.createStore(Type.OBJECT, 1)); + il.append(_factory.createLoad(Type.OBJECT, 1)); + il.append(_factory.createInvoke("java.lang.Class", "forName", new ObjectType("java.lang.Class"), new Type[] { Type.STRING }, Constants.INVOKESTATIC)); + il.append(_factory.createStore(Type.OBJECT, 2)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, "adapter", new ObjectType(adapterClass.getName()), Constants.GETFIELD)); + il.append(new PUSH(_cp, p.getMethod.getName())); + il.append(_factory.createLoad(Type.OBJECT, 2)); + il.append(_factory.createInvoke(adapterClass.getName(), "makeGetter", new ObjectType("dstm2.factory.Adapter$Getter"), new Type[] { Type.STRING, new ObjectType("java.lang.Class") }, Constants.INVOKEVIRTUAL)); + il.append(_factory.createFieldAccess(className, getFieldName(p), new ObjectType("dstm2.factory.Adapter$Getter"), Constants.PUTFIELD)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, "adapter", new ObjectType(adapterClass.getName()), Constants.GETFIELD)); + il.append(new PUSH(_cp, p.setMethod.getName())); + il.append(_factory.createLoad(Type.OBJECT, 2)); + il.append(_factory.createInvoke(adapterClass.getName(), "makeSetter", new ObjectType("dstm2.factory.Adapter$Setter"), new Type[] { Type.STRING, new ObjectType("java.lang.Class") }, Constants.INVOKEVIRTUAL)); + InstructionHandle ih_33 = il.append(_factory.createFieldAccess(className, setFieldName(p), new ObjectType("dstm2.factory.Adapter$Setter"), Constants.PUTFIELD)); + InstructionHandle ih_36; + BranchInstruction goto_36 = _factory.createBranchInstruction(Constants.GOTO, null); + ih_36 = il.append(goto_36); + InstructionHandle ih_39 = il.append(_factory.createStore(Type.OBJECT, 1)); + il.append(_factory.createNew("dstm2.exceptions.PanicException")); + il.append(InstructionConstants.DUP); + il.append(_factory.createLoad(Type.OBJECT, 1)); + il.append(_factory.createInvoke("dstm2.exceptions.PanicException", "", Type.VOID, new Type[] { new ObjectType("java.lang.Throwable") }, Constants.INVOKESPECIAL)); + il.append(InstructionConstants.ATHROW); + InstructionHandle ih_49 = il.append(InstructionConstants.NOP); + goto_36.setTarget(ih_49); + method.addExceptionHandler(ih_0, ih_33, ih_39, new ObjectType("java.lang.ClassNotFoundException")); + } + + private void initPrimitiveField(Property p, InstructionList il, MethodGen method) { + InstructionHandle ih_0 = il.append(new PUSH(_cp, p._class.getName())); + il.append(_factory.createStore(Type.OBJECT, 1)); + il.append(_factory.createLoad(Type.OBJECT, 1)); + pushPrimitiveClass(il, p._class); + il.append(_factory.createStore(Type.OBJECT, 2)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, "adapter", new ObjectType(adapterClass.getName()), Constants.GETFIELD)); + il.append(new PUSH(_cp, p.getMethod.getName())); + il.append(_factory.createLoad(Type.OBJECT, 2)); + il.append(_factory.createInvoke(adapterClass.getName(), "makeGetter", new ObjectType("dstm2.factory.Adapter$Getter"), new Type[] { Type.STRING, new ObjectType("java.lang.Class") }, Constants.INVOKEVIRTUAL)); + il.append(_factory.createFieldAccess(className, getFieldName(p), new ObjectType("dstm2.factory.Adapter$Getter"), Constants.PUTFIELD)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, "adapter", new ObjectType(adapterClass.getName()), Constants.GETFIELD)); + il.append(new PUSH(_cp, p.setMethod.getName())); + il.append(_factory.createLoad(Type.OBJECT, 2)); + il.append(_factory.createInvoke(adapterClass.getName(), "makeSetter", new ObjectType("dstm2.factory.Adapter$Setter"), new Type[] { Type.STRING, new ObjectType("java.lang.Class") }, Constants.INVOKEVIRTUAL)); + InstructionHandle ih_33 = il.append(_factory.createFieldAccess(className, setFieldName(p), new ObjectType("dstm2.factory.Adapter$Setter"), Constants.PUTFIELD)); + InstructionHandle ih_36; + BranchInstruction goto_36 = _factory.createBranchInstruction(Constants.GOTO, null); + ih_36 = il.append(goto_36); + InstructionHandle ih_39 = il.append(_factory.createStore(Type.OBJECT, 1)); + il.append(_factory.createNew("dstm2.exceptions.PanicException")); + il.append(InstructionConstants.DUP); + il.append(_factory.createLoad(Type.OBJECT, 1)); + il.append(_factory.createInvoke("dstm2.exceptions.PanicException", "", Type.VOID, new Type[] { new ObjectType("java.lang.Throwable") }, Constants.INVOKESPECIAL)); + il.append(InstructionConstants.ATHROW); + InstructionHandle ih_49 = il.append(InstructionConstants.NOP); + goto_36.setTarget(ih_49); + method.addExceptionHandler(ih_0, ih_33, ih_39, new ObjectType("java.lang.ClassNotFoundException")); + } + // Create constructor + private void createCtor() { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createNew(adapterClass.getName())); + il.append(InstructionConstants.DUP); + il.append(_factory.createFieldAccess(className, "_class", new ObjectType("java.lang.Class"), Constants.GETSTATIC)); + il.append(_factory.createInvoke(adapterClass.getName(), "", Type.VOID, new Type[] { new ObjectType("java.lang.Class") }, Constants.INVOKESPECIAL)); + il.append(_factory.createFieldAccess(className, "adapter", new ObjectType(adapterClass.getName()), Constants.PUTFIELD)); + + for (Property p : properties) { + if (p._class.isPrimitive()) { + initPrimitiveField(p, il, method); + } else { + initRegularField(p, il, method); + } + } + il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void createGetMethod(Property p) { + if (p._class.isPrimitive()) { + createPrimitiveGetMethod(p); + } else { + createRegularGetMethod(p); + } + } + private void createSetMethod(Property p) { + if (p._class.isPrimitive()) { + createPrimitiveSetMethod(p); + } else { + createRegularSetMethod(p); + } + } + + private void createStatic() { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_STATIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", className, il, _cp); + + InstructionHandle ih_0 = il.append(new PUSH(_cp, interfaceName)); + il.append(_factory.createInvoke("java.lang.Class", "forName", new ObjectType("java.lang.Class"), new Type[] { Type.STRING }, Constants.INVOKESTATIC)); + InstructionHandle ih_5 = il.append(_factory.createFieldAccess(className, "_class", new ObjectType("java.lang.Class"), Constants.PUTSTATIC)); + InstructionHandle ih_8; + BranchInstruction goto_8 = _factory.createBranchInstruction(Constants.GOTO, null); + ih_8 = il.append(goto_8); + InstructionHandle ih_11 = il.append(_factory.createStore(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createInvoke("java.lang.ClassNotFoundException", "printStackTrace", Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); + InstructionHandle ih_16 = il.append(_factory.createReturn(Type.VOID)); + goto_8.setTarget(ih_16); + method.addExceptionHandler(ih_0, ih_5, ih_11, new ObjectType("java.lang.ClassNotFoundException")); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void pushPrimitiveClass(InstructionList il, Class _class) { + il.append(_factory.createFieldAccess(unboxedClass(_class), "TYPE", new ObjectType("java.lang.Class"), Constants.GETSTATIC)); + } + + private String unboxedClass(Class _class) { + if (_class.equals(Boolean.TYPE)) { + return "java.lang.Boolean"; + } else if (_class.equals(Character.TYPE)) { + return "java.lang.Character"; + } else if (_class.equals(Byte.TYPE)) { + return "java.lang.Byte"; + } else if (_class.equals(Short.TYPE)) { + return "java.lang.Short"; + } else if (_class.equals(Integer.TYPE)) { + return "java.lang.Integer"; + } else if (_class.equals(Long.TYPE)) { + return "java.lang.Long"; + } else if (_class.equals(Float.TYPE)) { + return "java.lang.Float"; + } else if (_class.equals(Double.TYPE)) { + return "java.lang.Double"; + } else { + throw new PanicException("Unrecognized primitive type: " + _class); + } + } + + private void createPrimitiveGetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_PUBLIC, p.type, Type.NO_ARGS, new String[] { }, p.getMethod.getName(), className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, getFieldName(p), new ObjectType("dstm2.factory.Adapter$Getter"), Constants.GETFIELD)); + il.append(_factory.createInvoke("dstm2.factory.Adapter$Getter", "call", Type.OBJECT, Type.NO_ARGS, Constants.INVOKEINTERFACE)); + il.append(_factory.createCheckCast(new ObjectType(unboxedClass(p._class)))); + il.append(_factory.createInvoke(unboxedClass(p._class), p._class.getName() + "Value", p.type, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); + il.append(_factory.createReturn(Type.INT)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void createPrimitiveSetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[] { p.type }, new String[] { "arg0" }, p.setMethod.getName(), className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, setFieldName(p), new ObjectType("dstm2.factory.Adapter$Setter"), Constants.GETFIELD)); + il.append(_factory.createLoad(Type.INT, 1)); + il.append(_factory.createInvoke(unboxedClass(p._class), "valueOf", new ObjectType(unboxedClass(p._class)), new Type[] { p.type }, Constants.INVOKESTATIC)); + il.append(_factory.createInvoke("dstm2.factory.Adapter$Setter", "call", Type.VOID, new Type[] { Type.OBJECT }, Constants.INVOKEINTERFACE)); + il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void createRegularGetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_PUBLIC, p.type, Type.NO_ARGS, new String[] { }, p.getMethod.getName(), className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, getFieldName(p), new ObjectType("dstm2.factory.Adapter$Getter"), Constants.GETFIELD)); + il.append(_factory.createInvoke("dstm2.factory.Adapter$Getter", "call", Type.OBJECT, Type.NO_ARGS, Constants.INVOKEINTERFACE)); + il.append(_factory.createCheckCast(new ObjectType(p._class.getName()))); + il.append(_factory.createReturn(Type.OBJECT)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + + } + private void createRegularSetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, new Type[] { p.type }, new String[] { "arg0" }, p.setMethod.getName(), className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, setFieldName(p), new ObjectType("dstm2.factory.Adapter$Setter"), Constants.GETFIELD)); + il.append(_factory.createLoad(Type.OBJECT, 1)); + il.append(_factory.createInvoke("dstm2.factory.Adapter$Setter", "call", Type.VOID, new Type[] { Type.OBJECT }, Constants.INVOKEINTERFACE)); + il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void passThrough(Class c, Method m) { + InstructionList il = new InstructionList(); + Type[] argTypes = m.getArgumentTypes(); + String[] argNames = new String[m.getArgumentTypes().length]; + int argCount = argTypes.length; + for (int i = 0; i < argCount; i++) { + argNames[i] = "arg" + i; + } + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, + m.getReturnType(), + argTypes, argNames, + m.getName(), className, il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, "adapter", new ObjectType("dstm2.factory.Adapter"), Constants.GETFIELD)); + il.append(_factory.createCheckCast(new ObjectType(c.getName()))); + il.append(_factory.createStore(Type.OBJECT, argCount + 1)); + + il.append(_factory.createLoad(Type.OBJECT, argCount + 1)); + for (int i = 0; i < argCount; i++) { + il.append(_factory.createLoad(argTypes[i], i + 1)); + } + il.append(_factory.createInvoke(c.getName(), + m.getName(), + m.getReturnType(), + m.getArgumentTypes(), + Constants.INVOKEINTERFACE)); + il.append(_factory.createReturn(m.getReturnType())); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/BaseFactory.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/BaseFactory.class new file mode 100644 index 0000000000000000000000000000000000000000..c3be8409a8da0516283255e7c3ef96a30bff455d GIT binary patch literal 7178 zcmbtZd3+q@d4ArVm1eaXNw#dsEMUC8K$k5a*nnhgB-sLiBpb^Zgds3qjikk^U9pF; z$(^Q0T9T%vZDQ3ei3x~ONWj4>j6f!kKp{Zd94$FWLRy-HmJo-KhL++y-#4?`)kV#( ze`w~NZ{GW!)wAzBG67(%TpvUbhfVxV5I!6(!7%<-UG7kq&joQlK5ybk0C$@BLJ$Gm z73BHdCPsrObJ6b!;_q;85Py&ROx&+0jtB7w#)BBdqX9go?i1?dgp&4n0AEo!eEkHTH1SmvUkjoZhXZ&@-Je#Me^8fa zl=Np!d_9OYIIL89E{JO|ZsK{x-~|)kP|yFU`2Uk){moK*3*R>JodEt>q5q3|{bCT! z_--k_hwqmV`hmiENkKmh;zyVW;Ku>H9KcUX`1G#<{96F81n}<);im!oEP$UYf>#y& zf0W`s@tV5)!o=&P=)tc7cthQP9l)C=eiOidDK5WN+P$SN|83%b)ctJ}|EmHsVd5PV zr%Zt5+)ihbj-Yz_`%SxcHE&i(5yha}9wJhq?LFyaG(JFtvS>W*Bx%3nA_a$&iD4(1 zjye=u;j+!7qp`*wN4ctY>dB_gzEpZ>U8Co}#vLy4K`q-Ha?*o|KJr;Vooc$1wU+(S znA6y$X*7LsQZ=$zHl0O2j;=$LwZ)sF@o0LpU}24muH)>!uiecgXiN0b5fz=$xYL~( z+Uq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git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/BaseFactory.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/BaseFactory.java new file mode 100644 index 00000000..01a5f1df --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/BaseFactory.java @@ -0,0 +1,309 @@ +/* + * BaseFactory.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; + +import dstm2.atomic; +import java.util.Map; +import java.util.Map.Entry; +import java.util.HashMap; +import java.util.Set; +import java.util.HashSet; +import java.io.IOException; +import java.io.ByteArrayOutputStream; + +import dstm2.Transaction; +import dstm2.exceptions.PanicException; + +import org.apache.bcel.classfile.*; +import org.apache.bcel.generic.*; +import org.apache.bcel.util.*; +import org.apache.bcel.Constants; +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.Method; + +/** + * Provides utility methods for factories. + * @author Maurice Herlihy + */ +public abstract class BaseFactory implements Factory { + /** + * BCEL is not thread-safe + **/ + protected static Object lock = new Object(); + /** + * BCEL instruction factory. + */ + protected InstructionFactory _factory; + /** + * Constant pool for created class. + */ + protected ConstantPoolGen _cp; + /** + * Used to generate the class. + */ + protected ClassGen _cg; + /** + * The actual class we are building. + */ + protected Class theClass; + /** + * The name of the class we are building. + */ + protected String className; + /** + * Interface exported by created class. + */ + protected String interfaceName; + + /** + * Set of properties. + **/ + protected Set properties = new HashSet(); + /** + * Set of other methods. + **/ + protected Set methods = new HashSet(); + + /** + * set of interfaces satisfied by this class + */ + protected Set interfaces = new HashSet(); + + /** + * This constructor separates methods into properties and miscellaneous + * methods. For properties, it deduces type and name of properties, and + * stores them in the properties set. Other methods go into + * the methods field. + * @param interfaces additional interfaces satisfied by this class and understood by this factory. + * @param _class interface class + */ + public BaseFactory(Class _class) { + if (!_class.isInterface()) { + throw new PanicException("%s is not an interface", _class); + } + parseProperties(_class); + } + + /** + * Once methods and fields have been defined, this method turns the + * byte code into a Java class. + */ + protected void seal() { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + try { + _cg.getJavaClass().dump(out); + } catch (IOException ex) { + throw new PanicException(ex); + } + byte[] bytes = out.toByteArray(); + ClassLoader classLoader = new ClassLoader(bytes); + theClass = classLoader.make(); + } + + /** + * Create a new field. + * @param type BCEL type of field. + * @param name field name + */ + protected void createField(Type type, String name) { + FieldGen field = new FieldGen(0, type, name, _cp); + _cg.addField(field.getField()); + } + + /** + * Extracts properties from interface definition. Does rudimentary type + * and sanity checking + * @param _class class to inspect. + */ + private void parseProperties(Class _class) { + // Make sure implied field types are scalar or atomic. + // Enough to check return type of getField() methods. + for (java.lang.reflect.Method method : _class.getMethods()) { + if (method.getName().substring(0,3).equals("get")) { + if (!isAtomicOrScalar(method.getReturnType())) { + throw new PanicException("Method %s return type %s not scalar or atomic.", + method.getName(), method.getReturnType().getName()); + } + } + } + JavaClass jc = null; + try { + jc = Repository.lookupClass(_class); + } catch (java.lang.ClassNotFoundException ex) { + throw new PanicException("Class not found: " + _class); + } + properties = new HashSet(); + methods = new HashSet(); + Map fieldMap = new HashMap(); + for (Method m : jc.getMethods()) { + String methodName = m.getName(); + Class returnClass = null; // need both class & type + try { + returnClass = _class.getMethod(methodName).getReturnType(); + } catch (NoSuchMethodException e) {}; + Type[] parameterTypes = m.getArgumentTypes(); + // for get and set methods + String fieldName = unCapitalize(methodName.substring(3)); + // for boolean is method + String fieldNameBool = unCapitalize(methodName.substring(2)); + // get method? + if (methodName.substring(0,3).equals("get")) { + Property record = fieldMap.get(fieldName); + if (parameterTypes.length != 0) { + throw new PanicException("Class %s: method %s\n has bad signature\n", + jc.getClassName(), methodName); + } + Type returnType = m.getReturnType(); + // first time? + if (record == null) { + Property newRecord = new Property(returnClass, returnType, fieldName); + properties.add(newRecord); + newRecord.getMethod = m; + fieldMap.put(fieldName, newRecord); + } else { // not first time + if (!record.type.equals(returnType)) { + throw new PanicException("Class %s: inconsistent definitions for field type %s: %s vs %s\n", + jc.getClassName(), fieldName, record.type, returnType); + } else if (record.getMethod != null) { + throw new PanicException("Class %s: multiple definitions for %s\n", + jc.getClassName(), methodName); + } + record.getMethod = m; + } + // is method + } else if (methodName.substring(0,2).equals("is")) { + Property record = fieldMap.get(fieldNameBool); + if (parameterTypes.length != 0) { + throw new PanicException("Class %s: method %s\n has bad signature\n", + jc.getClassName(), methodName); + } + Type returnType = m.getReturnType(); + if (!returnType.equals(Type.BOOLEAN)) { + throw new PanicException("Class %s: method %s\n must have Boolean argument\n", + jc.getClassName(), methodName); + } + // first time? + if (record == null) { + Property newRecord = new Property(returnClass, returnType, fieldNameBool); + properties.add(newRecord); + newRecord.getMethod = m; + fieldMap.put(fieldNameBool, newRecord); + } else { // not first time + if (!record.type.equals(returnType)) { + throw new PanicException("Class %s: inconsistent definitions for field type %s: %s vs %s\n", + jc.getClassName(), fieldNameBool, record.type, returnType); + } else if (record.getMethod != null) { + throw new PanicException("Class %s: multiple definitions for %s\n", + jc.getClassName(), methodName); + } + record.getMethod = m; + } + } else if (methodName.substring(0,3).equals("set")) { + Property record = fieldMap.get(fieldName); + if (parameterTypes.length != 1) { + throw new PanicException("Class %s: method %s has bad signature\n", + jc.getClassName(), methodName); + } + Type argType = parameterTypes[0]; + // first time? + if (record == null) { + Property newRecord = new Property(returnClass, argType, fieldName); + properties.add(newRecord); + newRecord.setMethod = m; + fieldMap.put(fieldName, newRecord); + } else { // not first time + if (!record.type.equals(argType)) { + throw new PanicException("Class %s: inconsistent definitions for field arg type %s: %s vs %s\n", + jc.getClassName(), fieldName, record.type, argType); + } else if (record.setMethod != null) { + throw new PanicException("Class %s: multiple definitions for %s\n", + jc.getClassName(), methodName); + } + record.setMethod = m; + } + } else { + throw new PanicException("%s: not a get/set method\n", m.getName()); + } + } + for (Entry entry : fieldMap.entrySet()) { + if (entry.getValue().getMethod == null) { + throw new PanicException("Class %s: method get%s not defined\n", + jc.getClassName(), entry.getKey()); + } else if (entry.getValue().setMethod == null) { + throw new PanicException("Class %s: method set%s not defined\n", + jc.getClassName(), entry.getKey()); + } + } + } + + /** + * Did caller declare a void release() method? + * @return whether to provide a release() implementation. + */ + protected boolean releaseDefined() { + for (Method m : methods) { + if (m.getName().equals("release") && + m.getReturnType() == Type.NULL && + m.getArgumentTypes().length == 0) { + return true; + } + } + return false; + } + + /** + * Checks whether a field type is scalar or declared atomic. + * @param _class class to check + * @return whether field is legit type for an atomic object + */ + public boolean isAtomicOrScalar(Class _class) { + return _class.isPrimitive() || + _class.isEnum() || + _class.isAnnotationPresent(atomic.class) || + _class.equals(Boolean.class) || + _class.equals(Character.class) || + _class.equals(Byte.class) || + _class.equals(Short.class) || + _class.equals(Integer.class) || + _class.equals(Long.class) || + _class.equals(Float.class) || + _class.equals(Double.class) || + _class.equals(String.class); + } + + String unCapitalize(String s) { + StringBuffer sb = new StringBuffer(s); + sb.setCharAt(0, Character.toLowerCase(sb.charAt(0))); + return sb.toString(); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ClassLoader.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ClassLoader.class new file mode 100644 index 0000000000000000000000000000000000000000..d75e2007faa626cc897e2a1d3157c3167ab4188d GIT binary patch literal 522 zcmZWlO;5r=6r64OtW{7%K~LUFjaEE(u!I97CL}};G+sC@bRh-WCT%hCUuoh;;(;IF zk21ctF=^zmv-@V}&70ltpRWyoHcl1fQ7a>dLxrGT#8DB)423WX1a}#vagVBw<2g~6 zA+L>ltw)Aj-?s%rW$1X~e(g>~VDZU{n4HU(wAHlMaKWFrvEts`=&yJfnhfQUGxvD3 z4oK11R&*@O?2_!FW8G%DA0`Vijm&O_N(_fSw?#mDW#q4eskn3E0M*RhWgJ082@Mqm z6jd~F!qBwC$h|gZd>Z+|a~dx7VyOQM{m08%{OTQB%;>?%1csKDNi>QA$D5nu-e9o( za-7lE=IOr~Eeb*?(Yb^&p+c2TwM4t3e}d`f?~q=pqJe~akO>WPxFUUF2{zYv#p7n1uMa*1bFXr-qr_7mpd7j9*5DF6Tf literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ClassLoader.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ClassLoader.java new file mode 100644 index 00000000..238f7664 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ClassLoader.java @@ -0,0 +1,56 @@ +/* + * ClassLoader.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; +/** + * Simple classloader used to turn BCEL-generated classes into Java classes. + * @author Maurice Herlihy + */ + public class ClassLoader extends java.lang.ClassLoader { + /** + * Holds actual bytes. + */ + byte[] stream; + /** + * Create instance of class loader. + * @param bytes + */ + public ClassLoader(byte[] bytes) { + stream = bytes; + } + /** + * Transform byte code into a Java class. + */ + public Class make() { + return (Class)defineClass(null, stream, 0, stream.length); + } + } diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Copyable.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Copyable.class new file mode 100644 index 0000000000000000000000000000000000000000..ec6d5ac7722cf9ee7f46aab44bc080c2332764df GIT binary patch literal 238 zcmX^0Z`VEs1_nb0ZgvI^b_Py%1};Vh&fv`Syu^~yqEto(cb}}pvPAuy#JqHU|D>$c z{ + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/CopyableDef.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/CopyableDef.class new file mode 100644 index 0000000000000000000000000000000000000000..e2b5dfb0376de40ce61f1bf6d407935cd8812e45 GIT binary patch literal 240 zcmX^0Z`VEs1_nb09(D#Ub_Q-n29D(Xf=aid{9Hx`Q4OE0#Ii*FoW#6zegCAa)Z`Lt z%`ip=&fv`Syu^~yqEto(HjR)Fu%L!bh!v)CJ4_))2Cm@z(xT*4x6B-%0RqlI`x29K zQe9Hh^gz}zGDxNrm*g7hrzIwr { + void copyFrom(T other); +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Factory.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Factory.class new file mode 100644 index 0000000000000000000000000000000000000000..3cf5c37eca7cd1f55898c4b2b47d7b364134cd09 GIT binary patch literal 228 zcmX^0Z`VEs1_nb09(D#Ub_Q-n2Dap))WnihMg|cLO`oj9vPAuy#JqHU|D>$c { + /** + * Creates a new object via no-arg constructor. Return type may satisfy + * other, factory-specific interfaces. + * @return new object. + */ + T create(); + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Property.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Property.class new file mode 100644 index 0000000000000000000000000000000000000000..1fcb2eb3a01e9a77ccbaffa17766e69424a76d20 GIT binary patch literal 752 zcmZuv+iuf95IvhXPGVfzh7iiF^g-!DrJY@Uj*f`=mV`F~339uahdQ1US*El92lj7ao|q>|xxwF)AiaOPeR1^N}k>qaI$9&d){pP@4F zNw39rds5Ulciy168K2x52Lpm7d4piKiN)Mi; zOS4hIx{Wd{8#iFvSimBYOfg6GWTl>bVOY4{@cZ_u^mGxAZPf9Eq1H)s?+FOz@igN1&sV0ZjSu? z#FHkv=jf~87U8ON+M~NczUuq{b2f*_Ia@>Io$VovZxm;^O}0k;fdfK*AeN8R&!rA6 t%GPja(&_nV24JaDDEx$Zn0LM-?;aZD4EF-X^S|9pssKKdT_T^u-9N*vuRH(% literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Property.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Property.java new file mode 100644 index 00000000..2e9542df --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Property.java @@ -0,0 +1,95 @@ +/* + * Property.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; +import dstm2.exceptions.PanicException; +import dstm2.atomic; +import java.lang.annotation.Annotation; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.Map; +import java.util.Set; +import org.apache.bcel.Repository; +import org.apache.bcel.classfile.Attribute; +import org.apache.bcel.classfile.JavaClass; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.BasicType; +import org.apache.bcel.generic.Type; + +/** + * A property is a private or protected field prop of type + * T with T getProp() and void setProp(T) methods. + * If T is Boolean, getter can be boolean isProp(). + */ +public class Property { + /** + * Java class of property + */ + public Class _class; + /** + * BCEL type of property + */ + public Type type; + /** + * Method that reads property value. + */ + public Method getMethod; + /** + * Method that sets property value. + */ + public Method setMethod; + /** + * Name of field associated with property. + */ + public String name; + /** + * Create a property + * @param _type property type + * @param _name property name + */ + Property(Class _class, Type _type, String _name) { + this._class = _class; + this.type = _type; + this.name = _name; + } + + + /** + * for debugging + * @return property description + */ + public String toString() { + return String.format("Property[%s %s]", type, name); + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Releasable.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Releasable.class new file mode 100644 index 0000000000000000000000000000000000000000..71dd16f8dc09a651e2410a79d882cb315ad9d8cf GIT binary patch literal 139 zcmX^0Z`VEs1_nb0PId-%b_Nbc2KJ)VoYchPR7M774b3n{2Cm@z(xT*4x6B-%5PuL@ zGBGJ9RWB>CERm5xBBi(_*GNAtF}Wnas8Syx&&VJEQlX!dn3t~apOlrFT*Ai4z{tP^ Ww2py+kp*Zz0}F`7zzQUp7}x+MBOq`9 literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Releasable.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Releasable.java new file mode 100644 index 00000000..69ec6360 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Releasable.java @@ -0,0 +1,45 @@ +/* + * Releasable.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; + +/** + * The void release() method forgets that the + * transaction ever read or modified this object. Use with care. + * @author Maurice Herlihy + */ +public interface Releasable { + /** + * Forget that the calling transaction ever saw this object. + */ + void release(); +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/SequentialFactory.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/SequentialFactory.class new file mode 100644 index 0000000000000000000000000000000000000000..3db914ecc59f0b0c954282d1da747b8c89853d25 GIT binary patch literal 5225 zcmb_g>t7Vt8Ga5dEG*NCXow^+iHT8I5R8%5uu2sagD#*f!4ezEI6K1VGK0Ib3T>0# zlbEDUY|@LiHuh?hwy9cKG&V8SUhTc<{eHjx0sYqYIWq$c?2abCUq37}bIy6+^SsY{ zJBQ2vdHzKJx8q-76bamv%-AEVn)axgZKcPX68iqEZrX;L>TpNG2np28Ueu;$bZ=Uq zbgf|;cB{a`+W21efZCK&&7r3Dl$y!J>iPxB6ULCK+S#;DJ$Xyk_VvYDopqshE2&3N zj0y!MC@qJ;YZSZ|^8`XEOWP+<<K@F}C<2r%L8F_b3!3|hU1qakrR`1y( zu*`3n2d<#XO57yvyIJ5GzlgVGU4I#F5fDowsKinQw_zC>R!2v5Gbym5kVGDC&w9eI zM6H54X=#~lxjRT&>lHL$1wErlC%FXpx%IGw(IjxQl^$wRM^$ZDZ`!Ttsiq;_)YFFM zI(V~gmf?1fpGN8UM%VTT8gYlTbG1NM0n~Y*WBDVUJM+it`lSJ{Q}BAM5hxzih6HYj zUkxLvXhe&G7}hct==65W%-E`FZ?miv`JnRyRrprY+L+wFRlysu-r0Us;FZgU(IyZL z+NqO}(pk+mEYr)a2sU7&Byp2KcWp34=|zbxc*PteToyMgxC@<(jX^K@1sVcXrPke`N5M91=j3SG8r9Rbp=U_H>(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YobzcHHpq)8oaH2s|@itrDw5dZUk DH!;yv literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/SequentialFactory.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/SequentialFactory.java new file mode 100644 index 00000000..3eb364aa --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/SequentialFactory.java @@ -0,0 +1,140 @@ +/* + * SequentialFactory.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; +import dstm2.exceptions.PanicException; +import dstm2.Transaction; +import dstm2.factory.BaseFactory; +import dstm2.factory.ClassLoader; +import dstm2.factory.Property; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.*; + +/** + * Simple factory that implements properties declared in an interface. + * Ignores all non-property methods. + * @author Maurice Herlihy + */ +public class SequentialFactory extends BaseFactory { + + /** + * Creates a new instance of SequentialFactory + * @param _class Run-time class of interface being implemented. + */ + public SequentialFactory(Class _class) { + super(_class); + synchronized(lock) { + className = _class.getName() + "$"; + int constants = Constants.ACC_PUBLIC | Constants.ACC_SUPER; + String[] interfaces = new String[] {_class.getName()}; + _cg = new ClassGen(className, "java.lang.Object", null, constants, interfaces); + _cp = _cg.getConstantPool(); + _factory = new InstructionFactory(_cg, _cp); + createCtor(); + for (Property p : properties) { + createField(p.type, p.name); + createGetMethod(p); + createSetMethod(p); + } + seal(); + } + } + + /** + * Create an object. + * @return the object. + */ + public T create() { + try { + synchronized (lock) { + return theClass.newInstance(); + } + } catch (Exception ex) { + throw new PanicException(ex); + } + } + + /** + * Create constructor for new class. + */ + private void createCtor() { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", className, il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); + InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + /** + * Create getter for property. + * @param p Property to implement. + */ + private void createGetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, p.type, Type.NO_ARGS, new String[] { }, p.getMethod.getName(), className, il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, p.name, p.type, Constants.GETFIELD)); + InstructionHandle ih_4 = il.append(_factory.createReturn(p.type)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + /** + * create setter for new class + * @param p Property to implement + */ + private void createSetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[] { p.type }, new String[] { "value" }, p.setMethod.getName(), className, il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(p.type, 1)); + il.append(_factory.createFieldAccess(className, p.name, p.type, Constants.PUTFIELD)); + InstructionHandle ih_5 = il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Snapable.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Snapable.class new file mode 100644 index 0000000000000000000000000000000000000000..ff1c9acdf03ef840a49fc04d11e857abeb272ea8 GIT binary patch literal 391 zcmZvYy-veG5QJy*<8uOm@cRH%=LQQ(g6NV8iNY5B#y*TAV_Wt)f>)#90eC3HI)N0J z?q+7c)!cr5y?+3>!imCE;fUbYIhXZwVF{<&yI=8|{fzU(e^{DUQB)av-KgpgX`~N30y`?8O*laoc2G09hr2qf` literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Snapable.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Snapable.java new file mode 100644 index 00000000..75508c67 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/Snapable.java @@ -0,0 +1,58 @@ +/* + * Snapable.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory; +import dstm2.exceptions.SnapshotException; + +/** + * Interface for objects that support snapshots. {@link http://www.cs.brown.edu/people/mph/ColeH05/herlihy-snapshot-final.pdf } + * @author Maurice Herlihy + */ +public interface Snapable { + /** + * Return version that would have been returned by a read open. + * @return current version + */ + T snapshot(); + /** + * Check that version is still current. + * @param snap Earlier snapshot. + * @throws SnapshotException if snapshot not current. + */ + void validate(T snap) throws SnapshotException; + /** + * If snapshot is current, convert to write access. + * @param snap prior snapshot + * @throws SnapshotException if snapshot not current. + */ + void upgrade(T snap) throws SnapshotException; +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Adapter$1.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Adapter$1.class new file mode 100644 index 0000000000000000000000000000000000000000..5726ba43a0c67d76de477bc9676addd8d246ceab GIT binary patch literal 2736 zcma)8TXz#x6#h;#&Cqn9wLl?U=R-~R+Kh;MW> z3GB_6g5uHCjA;d)znJo7d?{0zyg3(0ziUv3CeVJ}oHtXB=@wFFr>{#Z&=D8dQ!iK* z$;yC|0`XwhE_EHDfzkSdbr#YBiFwoMD#~Ei%M0upUA5)Q8HdJFW8of8#!uL;9lRkh z)V-n3r|amM5YUFbyljC$n*kl0)a*F}El4B~!&U>W*d`F`R!7@LZC9Qt7pJA4Gp8LX z&@t*+rZZvswt9~iHFZ^ieH%H|HOLESlywB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literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Adapter.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Adapter.java new file mode 100644 index 00000000..504babf1 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Adapter.java @@ -0,0 +1,220 @@ +/* + * Adapter.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory.ofree; +import dstm2.ContentionManager; +import dstm2.Transaction; +import dstm2.exceptions.AbortedException; +import dstm2.exceptions.PanicException; +import dstm2.exceptions.SnapshotException; +import dstm2.factory.Copyable; +import dstm2.factory.Factory; +import dstm2.Thread; +import dstm2.factory.Releasable; +import dstm2.factory.Snapable; +import dstm2.factory.ofree.CopyableFactory; +import dstm2.factory.ofree.Locator; +import dstm2.factory.shadow.RecoverableFactory; +import java.lang.Class; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.concurrent.atomic.AtomicReference; + +/** + * Obstruction-free atomic object implementation. Visible reads. + * Support snapshots and early release. + * @author Maurice Herlihy + */ +public class Adapter implements dstm2.factory.Adapter, Releasable, Snapable { + protected Class iface; + protected Factory factory; + protected AtomicReference start; + + /** + * Creates a new instance of Adapter + */ + public Adapter(Class _class) { + iface = _class; + factory = new CopyableFactory(iface); + + Locator locator = new Locator(Transaction.COMMITTED, (Copyable)factory.create()); + start = new AtomicReference(locator); + } + + public Adapter.Setter makeSetter(String methodName, Class _class) { + try { + T version = (T) start.get().newVersion; + final Method method = version.getClass().getMethod(methodName, _class); + return new Adapter.Setter() { + public void call(V value) { + try { + Transaction me = Thread.getTransaction(); + Locator oldLocator = start.get(); + T version = (T) oldLocator.fastPath(me); + if (version != null) { + method.invoke(version, value); + return; + } + ContentionManager manager = Thread.getContentionManager(); + Locator newLocator = new Locator(me, (Copyable)factory.create()); + version = (T) newLocator.newVersion; + while (true) { + oldLocator.writePath(me, manager, newLocator); + if (!me.isActive()) { + throw new AbortedException(); + } + method.invoke(version, value); + if (Adapter.this.start.compareAndSet(oldLocator, newLocator)) { + return; + } + oldLocator = Adapter.this.start.get(); + } + } catch (IllegalAccessException e) { + throw new PanicException(e); + } catch (InvocationTargetException e) { + throw new PanicException(e); + } + }}; + } catch (NoSuchMethodException e) { + throw new PanicException(e); + } + } + + public Adapter.Getter makeGetter(String methodName, Class _class) { + try { + T version = (T) start.get().newVersion; + final Method method = version.getClass().getMethod(methodName); + return new Adapter.Getter() { + public V call() { + try { + Transaction me = Thread.getTransaction(); + Locator oldLocator = Adapter.this.start.get(); + T version = (T) oldLocator.fastPath(me); + if (version == null) { + ContentionManager manager = Thread.getContentionManager(); + Locator newLocator = new Locator(); + while (true) { + oldLocator.readPath(me, manager, newLocator); + if (Adapter.this.start.compareAndSet(oldLocator, newLocator)) { + version = (T) newLocator.newVersion; + break; + } + oldLocator = start.get(); + } + if (!me.isActive()) { + throw new AbortedException(); + } + } + return (V)method.invoke(version); + } catch (SecurityException e) { + throw new PanicException(e); + } catch (IllegalAccessException e) { + throw new PanicException(e); + } catch (InvocationTargetException e) { + throw new PanicException(e); + } + }}; + } catch (NoSuchMethodException e) { + throw new PanicException(e); + } + } + + public void release() { + Transaction me = Thread.getTransaction(); + Locator oldLocator = this.start.get(); + T version = (T) oldLocator.fastPath(me); + if (version == null) { + ContentionManager manager = Thread.getContentionManager(); + Locator newLocator = new Locator(); + version = (T) newLocator.newVersion; + while (true) { + oldLocator.releasePath(me, manager, newLocator); + if (this.start.compareAndSet(oldLocator, newLocator)) { + break; + } + oldLocator = this.start.get(); + } + if (!me.isActive()) { + throw new AbortedException(); + } + } + return; + } + + public T snapshot() { + Transaction me = Thread.getTransaction(); + Locator oldLocator = this.start.get(); + T version = (T) oldLocator.fastPath(me); + if (version == null) { + ContentionManager manager = Thread.getContentionManager(); + return (T)oldLocator.snapshot(me, manager); + } else { + return version; + } + } + + public void validate(T snap) { + if (snap != snapshot()) { + throw new SnapshotException(); + } + } + + public void upgrade(T snap) { + Transaction me = Thread.getTransaction(); + Locator oldLocator = this.start.get(); + T version = (T) oldLocator.fastPath(me); + if (version != null) { + if (version != snap) { + throw new SnapshotException(); + } else { + return; + } + } + ContentionManager manager = Thread.getContentionManager(); + Locator newLocator = new Locator(me, (Copyable)factory.create()); + while (true) { + oldLocator.writePath(me, manager, newLocator); + if (!me.isActive()) { + throw new AbortedException(); + } + if (snap != newLocator.oldVersion) { + throw new SnapshotException(); + } + if (this.start.compareAndSet(oldLocator, newLocator)) { + return; + } + oldLocator = this.start.get(); + } + } + +} + diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/CopyableFactory.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/CopyableFactory.class new file mode 100644 index 0000000000000000000000000000000000000000..5109b8f804467ac76b96d5a9a47af5d38556b080 GIT binary patch literal 5784 zcmb_gdwdkt75*mKWRuM($%1H91mt0|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NscRJ1k6^Kn1B(-=8No8n2gLkhewK}53(^3wbx*eKx?wp8c&O7jk(Lwt255a!z`dd=_KgcK?I_~>%x5m%$+y+;@_QM5zljpdS!T zySd^Ctl>$Z4hPVPXL-FC<=T^2i@T`ldTJtGco**GQ~cVAdx&irhHx+5O|+|dB7G0; zgNynu$9wTUu6REsr_)Aj<^5uzx$*;CDdB@?PsQZ{5f?l}Jwkeh2uZ_ff;E)Du8K3y zRGc~4a1;->FE$fTTHDJ4N`4@TN9hSe+5cd;-KR3}|*KzD?%cXlk{$gr)e;oAwG|hLH)Ayrz z*-V&G{5*kIY|n@D4&ycPn``aFaP7zDQdcrDn#N(s4Y^OF&a0dEE}lA|5lWklaqfiTufR1V_kQWaJgpCgV8< zN9Y=`gVSh|v4T+8Y~;^BB=9GJL?ypih7L4UIw&ayO`Is$CDx5WSSem@RxThb`7v3^ zr(h+?na0Yy3C~Xc^Xp#R$bt|gDD5l extends BaseFactory { + +/* + * CopyableFactory.java + * + * Created on November 21, 2005, 8:54 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + + /** + * Creates a new instance of CopyableFactory + */ + public CopyableFactory(Class _class) { + super(_class); + synchronized(lock) { + className = _class.getName() + "$"; + int constants = Constants.ACC_PUBLIC | Constants.ACC_SUPER; + String[] interfaces = new String[] {_class.getName(), "dstm2.factory.Copyable"}; + _cg = new ClassGen(className, "java.lang.Object", null, constants, interfaces); + _cp = _cg.getConstantPool(); + _factory = new InstructionFactory(_cg, _cp); + createCtor(); + for (Property p : properties) { + createField(p.type, p.name); + createGetMethod(p); + createSetMethod(p); + } + createCopyFrom(); + seal(); + } + } + + /** + * Create an object. + * @return the object. + */ + public T create() { + try { + synchronized (lock) { + return theClass.newInstance(); + } + } catch (Exception ex) { + throw new PanicException(ex); + } + } + + private void createCtor() { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); + il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + private void createCopyFrom() { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[] { Type.OBJECT }, new String[] { "arg0" }, "copyFrom", className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 1)); + il.append(_factory.createCheckCast(new ObjectType(className))); + il.append(_factory.createStore(Type.OBJECT, 2)); + for (Property p : properties) { + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 2)); + il.append(_factory.createFieldAccess(className, p.name, p.type, Constants.GETFIELD)); + il.append(_factory.createFieldAccess(className, p.name, p.type, Constants.PUTFIELD)); + } + il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void createGetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, p.type, Type.NO_ARGS, new String[] { }, p.getMethod.getName(), className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, p.name, p.type, Constants.GETFIELD)); + il.append(_factory.createReturn(p.type)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void createSetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[] { p.type }, new String[] { "value" }, p.setMethod.getName(), className, il, _cp); + + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(p.type, 1)); + il.append(_factory.createFieldAccess(className, p.name, p.type, Constants.PUTFIELD)); + il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Locator.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/Locator.class new file mode 100644 index 0000000000000000000000000000000000000000..0e2e8879ab068b30ff61fb4bb5318b20614b1289 GIT binary patch literal 3548 zcmaJ@TUQ(B72N|8BgCWuY_P$0EE4Jp39QCRofO$5fFV&Vz%?=ilg1sS0ptpeIvQcS zbuZ~9q|T*ndX1B&Y1eA#>O+f(4R+loeM;8qTc7(Y`UmRnGcy{%fLTj3^UZwUIs5Fh z&pG_-e}DTJz~lJ6iW&t6a%FqrSYlSs+NO0SVa{5Hkw}|aol6w~1&tT=MLki_i*t#w znTtl&R#11z%G-veU{BgTow4*{nHKV9F{wbc3_WL9Wd(=4?^~^(<>zt3=FYHL$W3r3 z&neh{-{wKHbVZ*j7_zTuT=MrF=^UR-Wd@(Wkm(;t4|O^SIyWKc9Jh75Lhm)xDPld5 zFXrt&1+~$x2?c>cGiQWRi)IaqG2EE6x0unjf|u+nW0nlP|&6! zh&mMqc45woEsSN280znoX!`G(aOS%VPzyx1S8q?p;^6bpV94k1wA|2 z?%K_Gm@$4)qr#3cb9096XKr{WGoF<}vuGPdQP7B9)aMK<`2hQS@uY??;W)EH`_+6O zj8>0qS3|NMPor1Gm#MRDnf4T;A&C=YpnqWOEYq!^eLJJx)}#tbs>8KpT+SLLL0(Su z&zP2NV?FpS?rNFZV~E*h^1$#^XHJ39FHhyiKaISdEB=0#kpkHL<7d~6%}U` z>~o!NOM`~97^hY(qihxy4St_3HC({g z6ohQk{it9sb#wm_7L>Z+3Xw&>t43)@nw?uE=?5^fjo0LT)w8AXk~FE$Sq*bw`GvA< zg~OJ)z%Ektv2#mx&t25;b%>($964&O9@&zW^KMu5`iFuB%P1In*^p2gPy(C(H+a@n zMb%lgB?~ULq%E4Nvh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TrkWUIW z{#m?;rL1_1YB9>U>Sw6V+rOgW>x58CRhhler6)GIam| literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/ReadSet$Iterator.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/ReadSet$Iterator.class new file mode 100644 index 0000000000000000000000000000000000000000..637657d536c14e281cc51089326c99453a9e380d GIT binary patch literal 1181 zcmah}O-~b16g{skopuEj&;;B#v=10kW}2BP!N221 z7A!Oo@gvc=GyW*!d1aunl5x@ZaqqeJ+d=u(bGf6V7vt(Qp(Bri zT1*W^9U8_JYEr{p4J8fJ0`aEn3y1}QWUy`fIhsZn>wd6XDQ#M{!1Z32+)Yo)(lcq* zS7cBnaMpJ0U``;Lk3<$;2qfm+x)kVJv>mzB+TD=es%ze8cj6 z$=)7CR~gkpu3S}Y=@om+v4WOI{_4NHCze)VH%beE^el=tdrlK`Y(rmhTV72*wUq=$ zDCv~y#6Uj=4D=zRPQwN+;G%|#ff?L0a32o@COREIcl=hf>3V^zFEReG{tlTCFn za0OQdauKhXJ1tZo)j4K51SgUT475#u^~M2-%FH(yiSSbct5%b~pDRyu*8Vp_oXb;u zMd4?nAG7fC9O04W%=fCnK#ZRXg#|JhB{gqJ+NeCemv}4krZ9bG@dz>V7;!Uxgv5KA zICNa~w)+5S9MUp`%VFRo?HoP~njethFZKyNZ=faKA`w44i%zyNpSkjd&LVrxA{mu5 z*O*~F@rtyScU_S`h`fg3Ffto*roKX3J4Whz7y4)BF?mKp^eA^#VUPI{>F&e_l%gLu uLg*M1#|cfE#bbz0^C#sW(3hn*hMTz6-fv@!`v5K1`B#HXiZbOfh1eees|Kk6 literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/ReadSet.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/ReadSet.class new file mode 100644 index 0000000000000000000000000000000000000000..8147ef87a06a27d0cc78e5041150482635d2517d GIT binary patch literal 1984 zcma)7Npl-T7=5kLIvElhYz5+l*a(nD#sXpNV`M4Jj11-m zgr(pHx16XHMJ_q8Ii{eXD2|*sQ2ZRi`!tem9L1oj>F(+NmiN8y_2~D%fBXf&C@v&$ zAM!GskYP;c@T88zcuHPR#&Al~8WpwM%G1L@vv-=4Y@`VR0)jVg3B{2EOvZhF2=!6hu$wKhe73TB%w7Vd6r zArP(O%~0>6G%Ad}o<6u;2kAOBN@Zh!xAZXYco+#`nX8b{+n7mxV`d*X8@#||pJNZ- zQncfpM%?@s+BU-9aIMhGQRfM8o}YpX4UfL2$29ll1OLSWfzfQ0c zmYD;3&otV#N}8__uY*3Uk(D=)K?PZ?@?(7!6L=GIaIpxFRrx4kgX3F_Ft}4soec^z z>S=9Kn`%}xEQx#b1mE9S?ZHtdj(jmZb@R?&jjI0W+l6Ej4Dc=+@*YFJPo-QVv=16372~e-@;y1t@(N)6C{)*Ub82i)Y zI^r-%^#4F4rbBq5jj7rXCWkngYTd1Vy2vluarQfCyB8w>K1LY^&~q4}Rfzm{a=xFd NBfQOETKVtg`#)k`jfDUJ literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/ReadSet.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/ReadSet.java new file mode 100644 index 00000000..8c609858 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/ofree/ReadSet.java @@ -0,0 +1,203 @@ +/* + * ReadSet.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory.ofree; + +import dstm2.Transaction; +import dstm2.factory.ofree.ReadSet; +import java.util.AbstractSet; +import java.util.Iterator; +import java.util.Set; + +/** + * ReadSet.java + * Keep track of transactions that opened this object for READ. + * + * @author Maurice Herlihy + */ +public class ReadSet extends AbstractSet { + + /** + * This value is public to facilitate unit testing. + */ + public static int INITIAL_SIZE = 64; + /** + * Number of allocated slots. Must reallocate if actual number of + * transactions exceeds this size. + */ + private int size; + /** + * Next free slot in array. + */ + private int next; + /** + * Iterates over elements. + */ + private Transaction elements[]; + + /** + * Create ReadSet of default size. + */ + public ReadSet() { + this(INITIAL_SIZE); + } + /** + * Create ReadSet of indicated size. + * @param size Size of readSet to create. + */ + public ReadSet(int size) { + this.size = size; + elements = new Transaction[size]; + next = 0; + } + + /** + * Initialize one object from another. + * @param aSet Initialize from this other object. + */ + public void copyFrom(ReadSet aSet) { + if (aSet.size > this.size) { + elements = new Transaction[aSet.size]; + this.size = aSet.size; + } + System.arraycopy(aSet.elements, 0, this.elements, 0, aSet.next); + this.next = aSet.next; + } + + /** + * Add a new transaction to the set. + * @param t Transaction to add. + * @return Whether this transaction was already present. + */ + public boolean add(Transaction t) { + // try to reuse slot + for (int i = 0; i < next; i++) { + if (!elements[i].isActive()) { + elements[i] = t; + return true; + } else if (elements[i] == t) { + return true; + } + } + // check for overflow + if (next == size) { + Transaction[] newElements = new Transaction[2 * size]; + System.arraycopy(elements, 0, newElements, 0, size); + elements = newElements; + size = 2 * size; + } + elements[next++] = t; + return true; + } + + /** + * remove transaction from the set. + * @param t Transaction to remove. + * @return Whether this transaction was already present. + */ + public boolean remove(Transaction t) { + // try to reuse slot + int i = 0; + boolean present = false; + while(i < next) { + if (elements[i] == t) { + elements[i] = elements[next--]; + present = true; + } else { + i++; + } + } + return present; + } + + /** + * Discard all elements of this set. + */ + public void clear() { + next = 0; + } + + /** + * How many transactions in the set? + * @return Number of transactions in the set. + */ + public int size() { + return next; + } + + /** + * Iterate over transaction in the set. + * @return Iterator over transactions in the set. + */ + public java.util.Iterator iterator() { + return new Iterator(); + } + + /** + * Inner class that implements iterator. + */ + private class Iterator implements java.util.Iterator { + /** + * Iterator position. + */ + int pos = 0; + /** + * Is there another transaction in the set? + * @return whether there are more active transactions + */ + public boolean hasNext() { +// if (pos == next) { +// return false; +// } +// while (pos < next && !elements[pos].isActive()) { +// elements[pos] = elements[next-1]; // discard inactive transactions +// next--; +// } + return pos < next; + } + + /** + * Get next item in the set. + * @return next transaction in the set. + */ + public Transaction next() { + return elements[pos++]; + } + + /** + * Do not call this method. + */ + public void remove() { + throw new java.lang.UnsupportedOperationException(); + } + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Adapter$1.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Adapter$1.class new file mode 100644 index 0000000000000000000000000000000000000000..523d11f09a9ba096f1ecb44860b7fb55fed036ae GIT binary patch literal 2197 zcmah~TXPd-7=FHFo3-iM#zG54D2Nf0G$j;8r736)#a4Pi8&k`9yV)jNHoKk8riH;< zy>-0c4|pNh%y1ALWkzRU#vdg<-zK4(X~694ey8{FywCf7Z~poBw?6?)KvxkF7%kWR z+R5CyZuqWuJ6EsjWp_I_UDh{!(@RdMPy`Yi`j(!vb*GYBTH7!UUqwvdV5eqVW!dzp zDG>9kRy}!w9_Bj*J6+@j;#<0%teJk*Eejl&-*M)d>o&dR7J@TM#-=RC^3Mw7Q?EDr zY9r~AfKqVFW-kN=G^lt(&fe0{i+CJS?9tGNy#mpc6djni9CNWzTQj|)zGj;OgY&MT z+a=wzBymi|d%M!snGFr^BSki(gB8#6 z&4TN!+m_)AB-@mS&8C}CGG4X+$jD|5}8H&4UI)M>^RCnc8JUj67y~KH3Lk=t) zb<6bXK}>_Y$%^A7K2-66!2VYijD}PAh%{QxmV1+Yp6Yosp2?AKI+Fc`=25;6Q#h;QjKIETh`U5Ie2ULlUY=QZ?X3{a*=|gQST4A> zyc2ZB(vW^Wm!=8=>8^^q8BUi}%m^HAo|v}`b5mNY=Pv4wWz4kKah$^!@+!=d;V^Nm zK6hJ|KK-lsl10D6{~WPZbbHz`%zFK$DHZbqV>?pqYdy!j7`k*`)IFB*O9g=*wuA;# z7OC;Gr%OFk#PzE|p9w}@zJU-+vK9pdm5+uJ+#MbT$3sH@i;nWcoju_8X1fnWd1HB1 zI+09u!GD%w@nyH+8RmIQwiT__KaWeExSVqw(<|6|y>2qLQz3w@ZqYK@Zrq*icZxWq zi-8%(u-&@lRGK|h!*$%C=bC=gY&YscIJ?WfN8xNG|IOJkwii^ zRUk1aTPpu*B7FOx@$^m3&Tt*&IFK28i2h9WArhI#7`z_{4)Gfg6bKR}40A0NDUN;E z&ym*-2PpA2=Mfx~CdFOE_y9ltibD%xQA{eC)ybZ}G7r$7eS~)>l@aAR##+nt;`non za*>c54=}F$f#_;(^b literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Adapter$2.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Adapter$2.class new file mode 100644 index 0000000000000000000000000000000000000000..f65033e1eb5ff3bcf72a4d45e57c6388b5451424 GIT binary patch literal 1942 zcmah}Yi}Dx6g^|R-o{xHle9Fnr7b0ZA4#32El`{XA*3bXq@gxJDW4|miL>o`H`?8# zR7gM(NC+tWjD7{F4<3R_1PO^B1)N#iu_L?1()!*zbD!tlxqtuj%kKcr;sXOQffLmr ztWOp;q!oJptwOLVtKQARTvcv`${(FHkPt{;mpiiHNVitFvVL7zp@F2p@%@%9lglck zr9d*=w1d$JMkwu9+#jMSklK;XXkCSyURB^|sU6H$8xErtmZCdqCZ}xI4rc_4nI}7a zyp!yzKw{pjsy+w|nlNxsb5EP-Ln?(hhE4S2kU%`6RR>G9tCqLx>&malbw>#dl{`y2 ztJ1f%+&oO^Vg*h;F{{x@mXM&aBXB5_?Z~l#DsTJBcFmRHw$DHZGTF*%F@+O2W#FWM z*?_UK=_^?^@jOlo4AfLu@ueHEeYWQc9H!rSEx24>x z3?h(e;oK3V*egOGBjilvF(zQ_C_jj@8S1Vvg)^8iP!Je-T%%16=OmkLyF1tAv z*;S;^LEAGBh}GGb;U492Y`t((qb#WLTt}C>lH<6a?zr!r8Rq0>Zi)ywr{CR zwtlTxB;2%{SPrskIOHZ?!2t$QgzhTyQPN3v9R6SWPD0 z2bV>vE^nyT{+sXYS~>KoTa(wqu}R|h$K8MbEd7e*YJG= z(F`qFeiNbu=I}Na2~`rac!yk!mVI~^C7!KB+!DEK5w}b(L9ZIl6}(59;)#Y_{~9n~ LMVWkpORDl8jY$4v literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Adapter.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Adapter.class new file mode 100644 index 0000000000000000000000000000000000000000..a2c38e4e6a6bdfbd08454bdbd15bb2b03735b9b9 GIT binary patch literal 5343 zcmcIoX?RrS6@G6fWRl56VptRsNze$%Odx<%mV}fL5(#91WJnrl!JC;&GB8UzGhxx9 zrKS6>T?8q%wGc|xjz}`Z2)GqnTdPv*)>cbx)!O>Q_IcWWZQpb6oypC@13y}xX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zzc-yRqnG0Gh@DnuM;!DRoFnQmTwBa!5bSMDI1w_f_c*O42tN@ zxJb1giRm)xOhH=C=K_9;hDwhww{kO){6=b{pU?n{3RQy%veIiAA implements dstm2.factory.Adapter, Releasable { + Class iface; + T version; + Recoverable rVersion; + ContentionManager manager; + Transaction writer; + ReadSet readers; + private final String FORMAT = "Unexpected transaction state: %s"; + /** + * A transaction switches to exclusive mode after being aborted this many times. + */ + public static final int CONFLICT_THRESHOLD = 0; + + /** + * Creates a new instance of Adapter + */ + public Adapter(Class _class) { + iface = _class; + Factory factory = new RecoverableFactory(iface); + version = factory.create(); + rVersion = (Recoverable)version; + manager = Thread.getContentionManager(); + writer = Transaction.COMMITTED; + readers = new ReadSet(); + } + + public Adapter.Setter makeSetter(String methodName, Class _class) { + try { + final Method method = version.getClass().getMethod(methodName, _class); + return new Adapter.Setter() { + public void call(V value) { + try { + Transaction me = Thread.getTransaction(); + Transaction other = null; + Set others = null; + while (true) { + synchronized (this) { + others = readWriteConflict(me); + if (others == null) { + other = openWrite(me); + if (other == null) { + method.invoke(version, value); + return; + } + } + } + if (others != null) { + manager.resolveConflict(me, others); + } else if (other != null) { + manager.resolveConflict(me, other); + } + } + } catch (IllegalAccessException e) { + throw new PanicException(e); + } catch (InvocationTargetException e) { + throw new PanicException(e); + } + }}; + } catch (NoSuchMethodException e) { + throw new PanicException(e); + } + } + + public Adapter.Getter makeGetter(String methodName, Class _class) { + try { + final Method method = version.getClass().getMethod(methodName); + return new Adapter.Getter() { + public V call() { + try { + Transaction me = Thread.getTransaction(); + Transaction other = null; + while (true) { + synchronized (this) { + other = openRead(me); + //other = openWrite(me); + if (other == null) { + return (V)method.invoke(version); + } + } + manager.resolveConflict(me, other); + } + } catch (SecurityException e) { + throw new PanicException(e); + } catch (IllegalAccessException e) { + throw new PanicException(e); + } catch (InvocationTargetException e) { + throw new PanicException(e); + } + }}; + } catch (NoSuchMethodException e) { + throw new PanicException(e); + } + } + + public void release() { + Transaction me = Thread.getTransaction(); + if (me != null) { + boolean ok = readers.remove(me); + if (!ok) { + throw new PanicException("illegal release attempt"); + } + } + } + /** + * Tries to open object for reading. Returns reference to conflictin transaction, if one exists + **/ + public Transaction openRead(Transaction me) { + // don't try read sharing if contention seems high + if (me == null) { // restore object if latest writer aborted + if (writer.isAborted()) { + rVersion.recover(); + writer = Transaction.COMMITTED; + } + return null; + } + if (me.attempts > CONFLICT_THRESHOLD) { + return openWrite(me); + } + // Am I still active? + if (!me.isActive()) { + throw new AbortedException(); + } + // Have I already opened this object? + if (writer == me) { + return null; + } + switch (writer.getStatus()) { + case ACTIVE: + return writer; + case COMMITTED: + break; + case ABORTED: + rVersion.recover(); + break; + default: + throw new PanicException(FORMAT, writer.getStatus()); + } + writer = Transaction.COMMITTED; + readers.add(me); + manager.openSucceeded(); + return null; + } + + /** + * Tries to open object for reading. + * Returns reference to conflicting transaction, if one exists + **/ + Transaction openWrite(Transaction me) { + boolean cacheHit = false; // already open for read? + // not in a transaction + if (me == null) { // restore object if latest writer aborted + if (writer.isAborted()) { + rVersion.recover(); + writer = Transaction.COMMITTED; + } + return null; + } + if (!me.isActive()) { + throw new AbortedException(); + } + if (me == writer) { + return null; + } + switch (writer.getStatus()) { + case ACTIVE: + return writer; + case COMMITTED: + rVersion.backup(); + break; + case ABORTED: + rVersion.recover(); + break; + default: + throw new PanicException(FORMAT, writer.getStatus()); + } + writer = me; + if (!cacheHit) { + me.memRefs++; + manager.openSucceeded(); + } + return null; + } + + public Set readWriteConflict(Transaction me) { + for (Transaction reader : readers) { + if (reader.isActive() && reader != me) { + return readers; + } + } + readers.clear(); + return null; + } + +} + diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/ReadSet$Iterator.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/ReadSet$Iterator.class new file mode 100644 index 0000000000000000000000000000000000000000..4afec3260ebf11dc2f3f7ddbf05a9b289256f255 GIT binary patch literal 1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Ub;lP$ed#Qc1Y`MHaKkLN`v{tqU7Zbsf>F5V`Cs~E&8(s&0Ku-3$8s=;Oo3F-+O zc9O^D53-TW@A_vS;+*&!$UMQ==ZL!dR3Y%FcA5Gb!N8+Wd}@H__=CTG7s1v01(HFL zTjYO*o0xx0c=rnBF-hM#55X--C?Dk%-w51bAc9TLK1iWnVJ(5{WOIWV)z}A{=tGfT zwh~5oKaMTTz+ld|8RdIeN13lC98}#{ldK1$XvDgU7ipu2o<@dw^3gJem)HQ(DHDzO zAF$KJa@s%ZpL>Xua2&`m*g<#KM7c!DnL>a{p@S^^7CQ)GgvAE-=->_^?-KX}hVmi5 zz#m}@_ekU}OY?CP-RTD1=?2{k9^C+&dJ-?QIEq&FMxSu$1EE7rS?lvpnZD0l{92!f zJbZo;G36CJO(~-yHH#mRmze|ZHyH;T#?!2h4_UtZSOb~22?i+oksmR;o>cp|_>KE2 zm8>Cs)r1tOA$2aW?_Q;yAS8$-Q_!AF{eu1{SUgOH|K~0wI@>sG%bwXVv)4wzPPho`9|PZ{s#R-wdnu= literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/ReadSet.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/ReadSet.java new file mode 100644 index 00000000..9fa1832d --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/ReadSet.java @@ -0,0 +1,199 @@ +/* + * ReadSet.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory.shadow; + +import dstm2.Transaction; +import dstm2.exceptions.PanicException; +import java.util.AbstractSet; + +class ReadSet extends AbstractSet { + + /** + * This value is public to facilitate unit testing. + */ + final static int INITIAL_SIZE = 64; + /** + * Number of allocated slots. Must reallocate if actual number of + * transactions exceeds this size. + */ + private int size; + /** + * Next free slot in array. + */ + private int next; + /** + * Iterates over elements. + */ + private Transaction elements[]; + + /** + * Create ReadSet of default size. + */ + public ReadSet() { + this(INITIAL_SIZE); + } + /** + * Create ReadSet of indicated size. + * @param size Size of readSet to create. + */ + public ReadSet(int size) { + this.size = size; + elements = new Transaction[size]; + next = 0; + } + + /** + * Initialize one object from another. + * @param aSet Initialize from this other object. + */ + public void copyFrom(ReadSet aSet) { + if (aSet.size > this.size) { + elements = new Transaction[aSet.size]; + this.size = aSet.size; + } + System.arraycopy(aSet.elements, 0, this.elements, 0, aSet.next); + this.next = aSet.next; + } + + /** + * Add a new transaction to the set. + * @param t Transaction to add. + * @return Whether this transaction was already present. + */ + public boolean add(Transaction t) { + // try to reuse slot + for (int i = 0; i < next; i++) { + if (!elements[i].isActive()) { + elements[i] = t; + return true; + } else if (elements[i] == t) { + return true; + } + } + // check for overflow + if (next == size) { + Transaction[] newElements = new Transaction[2 * size]; + System.arraycopy(elements, 0, newElements, 0, size); + elements = newElements; + size = 2 * size; + } + elements[next++] = t; + return true; + } + + /** + * remove transaction from the set. + * @param t Transaction to remove. + * @return Whether this transaction was already present. + */ + public boolean remove(Transaction t) { + // try to reuse slot + int i = 0; + boolean present = false; + while(i < next) { + if (elements[i] == t) { + elements[i] = elements[next--]; + present = true; + } else { + i++; + } + } + return present; + } + + /** + * Discard all elements of this set. + */ + public void clear() { + next = 0; + } + + /** + * discard inactive transactions + * must be called only while object is locked! + **/ +// public void clean() { +// int i = 0; +// while (i < next && (!elements[i].isActive())) { +// elements[i] = elements[next-1]; +// next--; +// } +// } + /** + * How many transactions in the set? + * @return Number of transactions in the set. + */ + public int size() { + return next; + } + + /** + * Iterate over transaction in the set. + * @return Iterator over transactions in the set. + */ + public java.util.Iterator iterator() { + return new Iterator(); + } + + /** + * Inner class that implements iterator. + */ + private class Iterator implements java.util.Iterator { + /** + * Iterator position. + */ + int pos = 0; + /** + * Is there another item in the set? + * @return whether there are more active transactions + */ + public boolean hasNext() { + return pos < next; + } + + /** + * Get next item in the set. + * @return Next item in the set. + */ + public Transaction next() { + return ReadSet.this.elements[pos++]; + } + + /** + * Do not call this method. + */ + public void remove() { + throw new java.lang.UnsupportedOperationException(); + } + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Recoverable.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/Recoverable.class new file mode 100644 index 0000000000000000000000000000000000000000..ea8ade111711c3330576add41df91349f512ab7c GIT binary patch literal 165 zcmX^0Z`VEs1_nb0E_MbcMh1nH;*wk={j|j7lKi4d{o;(ol>Bo2pw#62vecr)q?}ZC z1{OvJfvm)`ME#t^ymWp4q^#8B5=I8Lq{QUx(gH>XW)00SMh5mGh!#c$uHgLAqU2P! q%$!u9MkJH;K!&g}G61yz9l*fA1T>hHfsFxV0Xv8W%5Z?h88`t?nLcmC>s3=0R30aINm|%d!0FgXsHYEnyhRJ4<3~YA7?gWzB zs`$o75%FDZi;AJPwGzk%q=<#mS}L`zZEdTzRPFoyw12fdcV@CXNp?W{vwzIapbQ=eu`L{QJ4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K4To{p`2YsPf`E+#%# zvPTv5cnONI6cs!qHK7`7siVEP3Y$=iJFy%OV+9UkC61sD$NBALtimg($E#?-Yqaqe zN8Lz^3uuwp;wIe8yLh?q zRs13xd{t}BH!wn_F7)d{XgK->g6dzaS zm*?-bdQZh@951k;m7RtT;A?!W@RY{!BCl_;??T?c9mn@b&>!yQ)K*A-IsmT2EGU?R z5XyNRS_PHCbuqARBHDuu&=BEoGH<#aW)^$=7(Zb!bC~bf@H&GlXO`c zLs1^sVq}Sqr+GXZ!4@u^0UX94UL-s(;aU^&Dhr$hcty8>SZcD; zLu-~KSW<53qOf7|v2*WI;Z%-sb-)$hW_o9wgDur$R?Pv^E2O=aUmOVZ#FLAM_#(|Frim@B9}iHR^c) literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/RecoverableFactory.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/RecoverableFactory.java new file mode 100644 index 00000000..e19a9130 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/shadow/RecoverableFactory.java @@ -0,0 +1,168 @@ +/* + * RecoverableFactory.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.factory.shadow; + +import dstm2.ContentionManager; +import dstm2.exceptions.AbortedException; +import dstm2.exceptions.PanicException; +import dstm2.Transaction; +import dstm2.Transaction.Status; +import dstm2.factory.BaseFactory; +import dstm2.factory.ClassLoader; +import dstm2.factory.Copyable; +import dstm2.factory.Property; +import dstm2.factory.Snapable; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.*; + +import static org.apache.bcel.Constants.*; + +/** + * Implements simple object with getters and setters. Also provides a + * copyTo method that copies one such object to another. + * @author Maurice Herlihy + */ +public class RecoverableFactory extends BaseFactory { + public RecoverableFactory(Class _class) { + super(_class); + synchronized (lock) { + className = _class.getName() + "$"; + int constants = Constants.ACC_PUBLIC | Constants.ACC_SUPER; + String[] interfaces = new String[] {_class.getName(), "dstm2.factory.shadow.Recoverable"}; + _cg = new ClassGen(className, "java.lang.Object", null, constants, interfaces); + _cp = _cg.getConstantPool(); + _factory = new InstructionFactory(_cg, _cp); + createCtor(); + for (Property p : properties) { + createField(p.type, p.name); // actual field + createField(p.type, p.name + "$"); // shadow field + createGetMethod(p); + createSetMethod(p); + } + createBackup(); + createRecover(); + seal(); + } + } + + /** + * Create an object. + * @return the object. + */ + public T create() { + try { + synchronized (lock) { + return theClass.newInstance(); + } + } catch (Exception ex) { + throw new PanicException(ex); + } + } + + private void createCtor() { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", className, il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); + InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + public void createBackup() { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "backup", className, il, _cp); + + for (Property p : properties) { + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, p.name, p.type, Constants.GETFIELD)); + il.append(_factory.createFieldAccess(className, p.name + "$", p.type, Constants.PUTFIELD)); + } + + InstructionHandle ih_24 = il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + public void createRecover() { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "recover", className, il, _cp); + + for (Property p : properties) { + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, p.name + "$", p.type, Constants.GETFIELD)); + il.append(_factory.createFieldAccess(className, p.name, p.type, Constants.PUTFIELD)); + } + InstructionHandle ih_24 = il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void createGetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, p.type, Type.NO_ARGS, new String[] { }, p.getMethod.getName(), className, il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createFieldAccess(className, p.name, p.type, Constants.GETFIELD)); + InstructionHandle ih_4 = il.append(_factory.createReturn(p.type)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void createSetMethod(Property p) { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.VOID, new Type[] { p.type }, new String[] { "value" }, p.setMethod.getName(), className, il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createLoad(p.type, 1)); + il.append(_factory.createFieldAccess(className, p.name, p.type, Constants.PUTFIELD)); + InstructionHandle ih_5 = il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$1$1.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$1$1.class new file mode 100644 index 0000000000000000000000000000000000000000..38fe989ec163ae75c1d28118c61f4021566f2a0c GIT binary patch literal 898 zcma)4+invv5IxR@Y_m0F359a)jV&Z8bh|tu1yw=?B&1LzKz%^);5eq)c57F=UJ##! zRK(?h58$H^<0KLl4=k2O<2f@vKA!Qyt~Ix-!UWA1jAVlA9Ddbv^bgw8N7}wXbn=WcFUuo%3nE)#ku!t)@E;FoDJ&fZjt})CBDOFKKTMUo>=Xn)c`c2%xvX3Q( zrGG2nSivgwDl_tsVRbN>Q)$yImPX4m&y}{ZOBONp=CD7Hn^^Y|F)UY zp%<_~p5Y?G8Ot_#mkWC*;9qg+1lPY|jp1*uH)!GQDXwtF<>5A+uAzf2`8Mqq$-CuP L-RhCm3ElV&Z5h>n literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$1$2.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$1$2.class new file mode 100644 index 0000000000000000000000000000000000000000..e94bacc08db769fa1b19dac7192a0938bd0ccdc1 GIT binary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tD;@@MCcH6Mm+3oT$hk`I-$Enq=WCl=}&Rlu;Al FZvcZiH?9Bx literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$2$1.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$2$1.class new file mode 100644 index 0000000000000000000000000000000000000000..3a01626b6eeee54fa9c6f6a289e70aa9e47573a3 GIT binary patch literal 899 zcma)4+invv5IxR@Y_m0F372y1bqh%f-KI}SL6uMe2`Ll_P~IKKZMNOo)vg!B3xZEV zD&q3M2k=pdaT1A&2Np}C@theSAJ6#bukSwqbg}89!mv8Z?eTWJFQhfuyV$-pCu5PT z_|Zt5Sd~TFQP)S6Av_dsM4SqJ5Wg56DrtSx7@B|3mxb11m@0;v9VdCzCGLJ1d5@|e zCOWY@4C}4(^7eqCx@$(N4uCTw_=+dl<(J++>&&QmQGM{|>Iev(r`-dJ9TIdlK7)6@;KHX#%|(YzGVb(yG%4nE z#-W#RnLJ&JaK^Gj-sQs1Dfm}hJ;kkWSY`N|>jN72c!n#Sae25)rz>coO}@gs4zU-Y1i>*>*cq_R`|BsJ}<3 zXnhc${ZZnXB-ld1bznGizB!j~&N=hz_xB$F+IZk#hM_i$;+>B7R>;_d@4R^5?2bgF zyeC7k8>`UmxE%*shVqu!6J8+nruTZVrDW_N$51&!*AuP9AW#gsc;rWJn_~CUf_KUK zk+1#uF~f2_-MrCf$gY{8%7fuFhlAMyGAME6QD(^0twE{hYxOGG8K`h$!l=?SQUrYw z`c|KUSxb|_P0i|dh-M~CbOH0Yu=V+kG;Owa|@{OjknB+S)EnNq zB%xH#eLG!zI+-h$C#f&AR^eJ8qDWCUOV6|nOyuj$mnt5aA;&%3r#evk1BUbUlf)W* ztkN)LXrBTrm+ef^|CphjM}g2HogR{IkwUZe1-$tcbDzgHXDl|pvEJ`dA)S+tMbF|K zNlJ?HG|C1^dsk~7fPce<16(~sjp46)^Cwz|xXo}BeU6v`A5g+aRPpIphT1ekhWJ~) WZFERh=rm8#E}P4)JG8Te-u(l*3ig`- literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$2.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter$2.class new file mode 100644 index 0000000000000000000000000000000000000000..b58d6940aa792387da11c7402cc1355bec26add0 GIT binary patch literal 2232 zcma)7TUQ%Z6#h;UGBAt~u{W`{1%oAlG9^-b3AAEL6$_=3NQEkTGC3quCNp$q0!6!g z@yYx0(O=-JU8~qumX~LLl*@f)LX$u#&05LXbI!he-?z`~{QKV@e*qXpSwV#1RLS$J z8GVHtzT| zq!t)rIj1B#z|gHhLA$hG*3bb}MHH`S=)@t0=%94%o-u84qgE{nx4?^*VCb1~3~nuO z*Obro&6p(2(0>4~WQJ(ODBNN=JlF&>lr}3XcI3^n&Hb87wc>+?1={Su37k@JlHtVj z<w|d zBctIh*@t+M8>_W71?NcL*1+AjDVa%*su;t0*}@A90|(s`>PKop#U+d@pw4Jv`a;DO zyrf|Qbk{V;&NCf2)Q9at+wfUNDOSqIo!83Q%>$+hWmNM{%{9a|Q%)wWK88o6c=R}J+rrIR-17v@ zrgKeP>KA2K{?;izPLMBCiS8-eupG~{%i$o_Ah1G}t9(`L%==vP)yVrUIcJ;71sJla z=a$RjEREqPecKR8B;;HM5^h0z##OqJ+2196{{sq0E zHS`bkCm0P6qFXqk_)?ca!*hLA<`i0PfSw{R$WGHFEfdBEQ8l zzN5(RQNa(miyz_QC-VF`&|!?k1;vCqNNWKjq|GwPdP_%&`j$9 literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/factory/twophase/Adapter.class new file mode 100644 index 0000000000000000000000000000000000000000..9c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$0JR3O5=PSR>)vH?7I|vn2y7qm zMZc&cZNwv}`URvPAA5qk6ihs!og>WqQ`ESUQ5+yXDK*RZ implements dstm2.factory.Adapter { + T version; + Lock lock; + boolean firstTime; + private final String FORMAT = "Unexpected transaction state: %s"; + private static Map map = new HashMap(); + + /** + * Creates a new instance of Adapter + */ + public Adapter(Class _class) { + lock = new ReentrantLock(); + Factory factory = map.get(_class); + if (factory == null) { + factory = new RecoverableFactory(_class); + map.put(_class, factory); + } + version = factory.create(); + firstTime = true; + } + + public Adapter.Getter makeGetter(String methodName, Class _class) { + try { + final Method method = version.getClass().getMethod(methodName); + return new Adapter.Getter() { + public V call() { + try{ + lock.lock(); + if (firstTime) { + ((Recoverable)version).backup(); + firstTime = false; + } + Thread.onCommitOnce( new Runnable() { + public void run() { + lock.unlock(); + } + }); + Thread.onAbortOnce( new Runnable() { + public void run() { + lock.unlock(); + ((Recoverable)version).recover(); + } + }); + return (V)method.invoke(version); + } catch (IllegalArgumentException ex) { + throw new PanicException(ex); + } catch (IllegalAccessException ex) { + throw new PanicException(ex); + } catch (InvocationTargetException ex) { + throw new PanicException(ex); + } + }}; + } catch (NoSuchMethodException e) { + throw new PanicException(e); + } + } + + public Adapter.Setter makeSetter(String methodName, Class _class) { + try { + final Method method = version.getClass().getMethod(methodName, _class); + return new Adapter.Setter() { + public void call(V value) { + try{ + lock.lock(); + if (firstTime) { + ((Recoverable)version).backup(); + firstTime = false; + } + Thread.onCommitOnce( new Runnable() { + public void run() { + lock.unlock(); + } + }); + Thread.onAbortOnce( new Runnable() { + public void run() { + lock.unlock(); + ((Recoverable)version).recover(); + } + }); + method.invoke(version, value); + } catch (IllegalArgumentException ex) { + throw new PanicException(ex); + } catch (IllegalAccessException ex) { + throw new PanicException(ex); + } catch (InvocationTargetException ex) { + throw new PanicException(ex); + } + }}; + } catch (NoSuchMethodException e) { + throw new PanicException(e); + } + } +} + diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/AggressiveManager.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/AggressiveManager.class new file mode 100644 index 0000000000000000000000000000000000000000..6b0d10aa859bf3e328f96036a2cb3387ff5dad5f GIT binary patch literal 788 zcmZ{h(N7aW5XQeL*IqfQ2xt*e0Wq;9NCkN?ftV=Kn5F`WSR-%S>vAl)-Zp#JM*l2d zB#{K){iBStcPA-=FFP}P-~8sg*gr(NyQCIwIF_9hWa42_lbQCH-A=GPm+kp{LEc`_2XzQA*dfUSk zW?W1Yrm{gJ9TnWh9YRrbv|%X!&mp1EW5+Ysuvn;*V`&HzflT&|(ncj;)3&CI`-CSa zVkjD+h=Rt)C?53tOqJcezBI!6d-KJYeVcfg$2e2sQHoP*+HDqxA{?**Y7)E;dSHC{ zR@og^uPkQGj>8hz0Y5L`aK;b7r_0rIj>NIJa*FadP73h&^f&@fS-ge`&MKLR;|;C| zH!;bl1-#>E!KKyjxb^8@!ZRMVo)Q)_RZd_%s+diwCEVq#!1)~R<-oMRi>*{~~FVg-ht5|d4sf@*RQG`e7yyZWS5u0KF literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/AggressiveManager.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/AggressiveManager.java new file mode 100644 index 00000000..c199b5e3 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/AggressiveManager.java @@ -0,0 +1,58 @@ +/* + * AggressiveManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; + +import dstm2.util.Random; +import dstm2.ContentionManager; +import dstm2.Transaction; + +/** + * The Chuck Norris contention manager: always abort other transaction. + * @author Maurice Herlihy + */ +public class AggressiveManager extends BaseManager { + + public AggressiveManager() { + } + public void resolveConflict(Transaction me, Transaction other) { + other.abort(); + } + + public long getPriority() { + throw new UnsupportedOperationException(); + } + + public void setPriority(long value) { + throw new UnsupportedOperationException(); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BackoffManager.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BackoffManager.class new file mode 100644 index 0000000000000000000000000000000000000000..4ec9085431e3e713c7ace3714f5a3d3bb9f869ff GIT binary patch literal 1919 zcmbtUT~k_D6kP`{pm>enCX$$srj6i7X!BvBSRzt2C~Bh=qn*@T;i#l=FLSv#_MyJ@ zM>MZ($LGv6Nz=}B`rQA}xBiZ{>s$dz!$W5}42N^}*?aB1*4~HT|N8k?03Ts90FS_> ze8nlhW_nQk+o}qu9ej4PI_%|XD*RkURziY5GjGq zq-9nd!*sGnu`0dHMwqUZ#N%dHWey2+DD(P!W<52(p-h7Ue%mnfR!N{QeVV%J6pGPx z*BBExm#f;gG@XRw$Wqy%|4hLwIB@}QIFc36l2%>@;YGiWZuGQ6U{FUF`~h4L=y?Y+ zi1X-IUKe$A;v6eY7fiWYE$vD>W9$~CKyTX08O5w&7u30C)SQDtMc{I+$kqz7-cGA5 z&5ddR!(f5S_u(+ckCxUW+Aj9tri0+^;AXTeM$ZM#}_WPbiA zC(DYBfTzTQ>aA_6no{{J=Rn#5!J@Tan?!-}mYTR(+`&j%#iBe_O0~azqp)upPSs|X z#D5N*X(4hv7Rh!XiTMCN5$JD~QO5!nmC__?I2KDE3`f#uo~fEW)`1k316blLy?d)8 zjTN>+HHC@l2yO$`cAt@)8^5OGQzdrbz^JUcu6|c94&h)^&L%z7#aom6Rk=RBV=W_E z%fNy+r5*FFd%!wU=SQU9Pv8ZW8^thhbXu z(_mc26`q88cQxP{Mk?SSfv>s1XK3eKDpN$8CR(fsDcC@|j`wRwf6`ACzCHRQ2D%5o zLu&jLK6no8g);c^fv54|?$Gz}cZcG%gtXzKR~Vbr2DIL2@f)?4f5L|+@J;(hw-}*4 zCCd|Z5@m9;R+&H)A7d6%HNKM+4Yaf)PO%=4RRST*kzW$mF;DMBdOxIP32Pj$3|6qk zozmnE8^mgBOw=xh8CQ#KA}U=%R5DIZUgBJ(zn=^RaUbw*ma!gYV{=5f#{9U>Jn_F6 zPmRC9oWQhpf-6JX8$1;F4L4RNsOGomoEZB7ZQM_8s=HNz=YRjvP-lb{-={iWcN(VM zfqF!B)>-EUM=pbl$YKPK>9xhKeolR!@bd)<*n!F25q9x4@~%RPJ8;}k=(wTKF&+`q eL)5xLBMpU~unS5*FEiFBPx)u)FYuYGTlOECy_T;4 literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BackoffManager.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BackoffManager.java new file mode 100644 index 00000000..30f175ba --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BackoffManager.java @@ -0,0 +1,101 @@ +/* + * BackoffManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; + +import dstm2.util.Random; +import dstm2.ContentionManager; +import dstm2.Transaction; +import java.util.Collection; + +/** + * Contention manager employing simple exponential backoff. + * @author Maurice Herlihy + */ +public class BackoffManager extends BaseManager { + static final int MIN_LOG_BACKOFF = 4; + static final int MAX_LOG_BACKOFF = 26; + static final int MAX_RETRIES = 22; + + Random random; + + int currentAttempt = 0; + + public BackoffManager() { + random = new Random(); + } + public void openSucceeded() { + super.openSucceeded(); + currentAttempt = 0; + } + public void resolveConflict(Transaction me, Transaction other) { + if (currentAttempt <= MAX_RETRIES) { + if (!other.isActive()) { + return; + } + int logBackoff = currentAttempt - 2 + MIN_LOG_BACKOFF; + if (logBackoff > MAX_LOG_BACKOFF) { + logBackoff = MAX_LOG_BACKOFF; + } + int sleep = random.nextInt(1 << logBackoff); + try { + Thread.sleep(sleep/1000000, sleep % 1000000); + } catch (InterruptedException ex) { + } + currentAttempt++; + } else { + other.abort(); + currentAttempt = 0; + } + } + public void resolveConflict(Transaction me, Collection others) { + if (currentAttempt <= MAX_RETRIES) { + int logBackoff = currentAttempt - 2 + MIN_LOG_BACKOFF; + if (logBackoff > MAX_LOG_BACKOFF) { + logBackoff = MAX_LOG_BACKOFF; + } + int sleep = random.nextInt(1 << logBackoff); + try { + Thread.sleep(sleep/1000000, sleep % 1000000); + } catch (InterruptedException ex) { + } + currentAttempt++; + } else { + for (Transaction other : others) { + if (other.isActive() && other != me) { + other.abort(); + } + } + currentAttempt = 0; + } + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BaseManager.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BaseManager.class new file mode 100644 index 0000000000000000000000000000000000000000..d71ca06e6a15a005db13ddeb8b5dab78060ea4b3 GIT binary patch literal 1406 zcma)6-A)rh6#k~&{w)P7U@M|h{A~+Tg+yY&8YD3mi(*Q+AGTvzvfXWVrzAXpZ{VHJ z;Dw1srG?BTOVQo<|O54h)y_$RJC5%XY=_{dAv&T%{=gBUPyMbmt9vFYsAW(+ zGfeH{K#E=-3nyeJT2&hK$xMooVoB9V2U9-vegt8}hZ>S4?~+Zvq8cC+H4Xf`K|k zJj7+P@*2s+B&Nt>n8uX|=^5GTJv#+R>&GiPupC}Sfhx3!lD=oSN~Z*!r!hnOH3CUs zR?~Ys3YyfcLeR$-0KHByHwYl)tkT@nY35L-WUBhQwt-ab3no74ysGdp#gmbOQ^SJi zaVrXLP(`ZXbZzd8Y$kyMPf7HKMks1KJ*+&9+qwx1cZO|Ppa|8X|HRuEAwmBGt-67` zxEGP|s5@y2EPcoQjohk1+p1AC%3}8YhmU`MpZ20ie1Mnqyh(%bibQEq2evhQjl2Xg oWLUx?9#8^<(k&6!1Vt1`tSosL4Z_LroXdJAhBc%At!nJ@KgCx6;{X5v literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BaseManager.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BaseManager.java new file mode 100644 index 00000000..a2c6650a --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/BaseManager.java @@ -0,0 +1,83 @@ +/* + * BaseManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; +import dstm2.ContentionManager; +import dstm2.Transaction; +import java.util.Collection; + +/** + * + * @author mph + */ +public class BaseManager implements ContentionManager { + long priority; + + /** Creates a new instance of BaseManager */ + public BaseManager() { + priority = 0; + } + + public void resolveConflict(Transaction me, Transaction other) { + } + + public void resolveConflict(Transaction me, Collection other) { + } + + public long getPriority() { + return priority; + } + + public void setPriority(long value) { + priority = value; + } + + public void openSucceeded() { + } + + /** + * Local-spin sleep method -- more accurate than Thread.sleep() + * Difference discovered by V. Marathe. + */ + protected void sleep(int ns) { + long startTime = System.nanoTime(); + long stopTime = 0; + do { + stopTime = System.nanoTime(); + } while((stopTime - startTime) < ns); + } + + public void committed() { + } + + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/EruptionManager.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/EruptionManager.class new file mode 100644 index 0000000000000000000000000000000000000000..c15e7f3914668135c2787f060b65b3b553a27957 GIT binary patch literal 1192 zcmZ`(T~8B16g|^V+Ad(B6e?D%pKV3HRK7|`1gn-5s4Xd?CS=+Uuw=X2>~2YX*MGp9 z#s^<~CQ%GN_yhbU{0j9>+th;iGCTLqJ!kGYciNx7zW)F)i3Kkl4AF{ZSEt6ST<5#O z98a6|nyni8YBTo2#Sl4LvcxUXI%ZG`*>pO$olEC4>yH^&hM{}e&@G$mc9Cm!;RKwg z44ws5SM5axXFO44a4j1Z;fE953ViVUz|gDU5`qj}HB&WA)qX>4E0oTvx>&1MOTygX zB~38&WsNe|iriFX+)BFaJ=J0u$)4@?oSYQ#nZh!(13^vhXlmJJNW@#94U_8@FH8BU z3sQ-q9}x_DahW05yru)8;0mG)p(A@X0DG+A!jqFS?QPTdXEUoq~A z&}=UAHK7;k<+2bJ$?h*0b+as zK$(R`4EU4Zpd@`?(R0+O>!Y=&!SEC=JR?K~{ghJ(N7V>nfW8c23^tiqh;EULnr~_J z7(?@J=d>r{KEYLn8E@E|{DK}a;|u$Ihwsrl;CUCOy?Xc&fkyq!%_CV6qr_0e-7M!Z zae}xL@?fcfIQ&432A!wJ7=7zupMQU%`y7zHE~1y#EJdrNag91zryg^N;yEUe#}o>f z!3JiriAQ)r*)0_D3fp*%9jcew@`R-RTiWDqg8mSsUXAdR#O=U7?juOPbfJO=cu3v` zz%fnQJ%r2C9YJzBN^Z^4PX2=D+Fs95wPXt delta * delta) { + transferred = 0; + other.abort(); + return; + } + // Unsafe increment, but too expensive to synchronize. + if (priority > transferred) { + otherManager.setPriority(otherPriority + priority - transferred); + transferred = priority; + } + if (attempts < delta) { + sleep(SLEEP_PERIOD); + } + } + } + + public void openSucceeded() { + priority++; + } + +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/GreedyManager.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/GreedyManager.class new file mode 100644 index 0000000000000000000000000000000000000000..2e0af145d52c2f5c840f681b7ddf968f1f511015 GIT binary patch literal 897 zcmZuvU2hUW6g|VIEL$nXFN)QwRbjzW>sOkZ8cR|Wf{jTDBz+r}5yr4PW_G|d@n`sC zeD~QzG4a74;EyuiEl45h!_M40bM86k-q}BYfBgpV5L-z^7z*9Mc-vKv`@AP~^_3Q) zd-8gcB@tuDF9P;?Ag0$0iRaRnW{)9SEVUS7HPsasqDa|@Bf*eqNM9Tdy^hdL-Wdpn zm4xEU@Uly6S_En^5;f(&9Z1(Ol#0`mrsjUYT_cshd(Kg* zl|mM|Bvu%*6Op+J8<%jIA^CwzBmEu&I}YJjZCpd1Ar%;|O;dVgpVck8DcHD8 zcsJki5yvgki_*^l#3-UCq%}!dm3BsZ-1&(M-zbQ{qBXn*wveXPo&acHqKx4pGPH)p zABij^bt>Pn{23YAu9WHf^abh47_05C$d+S2uuRE~a+HEIg;ml3wvodl6!3(``xF~^ zh7xv8Ro5rXQ&rNS7H*$9ad3yC2*n$-HXai?bewQfW86Jcu?Pq3QNu6hdP&TBDa{ym d2oo}-9cK*3;^)xp(`agQH0c@5CKX0d{Ra@tt5E;| literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/GreedyManager.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/GreedyManager.java new file mode 100644 index 00000000..7d966abb --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/GreedyManager.java @@ -0,0 +1,68 @@ +/* + * GreedyManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; + +import dstm2.Transaction; + +/** + * Tries to keep a maximal independent set running. + * If prior transaction is + * waiting or lower priority, then abort it. + * otherwise, wait for it to commit, abort, or wait + * Complete description in + * Rachid Guerraoui, Maurice Herlihy, and Sebastian Pochon, Toward a Theory of Transactional Contention Management, + * Proceedings of the Twenty-Fourth Annual Symposium on Principles of Distributed Computing (PODC). + * Las Vegas, NV July 2005. + * @author Maurice Herlihy + */ +public class GreedyManager extends BaseManager { + public void resolveConflict(Transaction me, Transaction other) { + if (other.waiting || other.startTime < me.startTime) { + other.abort(); + } else { + me.waiting = true; // I'm waiting + other.waitWhileActiveNotWaiting(); + me.waiting = false; // I'm no longer waiting + } + } + /** + * Reset priority only on commit. On abort, restart with previous priority. + **/ + public void committed() { + setPriority(0); + } + + public void openSucceeded() { + setPriority(getPriority() + 1); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/KarmaManager.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/KarmaManager.class new file mode 100644 index 0000000000000000000000000000000000000000..faf516e2d57bd7f7f5a6da5f26e555b08a31b824 GIT binary patch literal 1075 zcmZ`%%T5$g5Ir^1J&&FSMBXnIL7g6f5k$~Hi1IK2M<5It6F274bA>k3-K6^tiF^G6 zH*VazHZd4o_yK-~E5Aamo|&{mz(v>Xx^?Q*sjB}~F>6KIprvF3ZB5}vAvT3sfAs1;dM;>>fxbGD0q?DG#@dJetDK7prKEeT zct)|4P*ZQperzOEXqZq~#c?y~lI*rv{{xZIl2kql>NC z1mF_7+2d!09=1{PdnSu$t*KM=ZYLMC>8}_j6h7mcT-5utxBdFN56EzI^4S}WKK}X1 z-~^%q!(0M*$l4yUrd3|V8n1616YNJtR~m7vRg_C0&tD|ULV>>oXHMcarnt)tcRS5^ zjafP|!yGyzi*b+hjEOQ+h3qNr{A delta) { + other.abort(); + } + } + } + + /** + * Reset priority only on commit. On abort, restart with previous priority. + * "Cosmic debt"?. More like cosmic credit. + **/ + public void committed() { + setPriority(0); + } + + public void openSucceeded() { + setPriority(getPriority() + 1); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/KindergartenManager.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/KindergartenManager.class new file mode 100644 index 0000000000000000000000000000000000000000..7f7d30a3620288281ce7af1a53eda30342539fe1 GIT binary patch literal 1388 zcma)5+fox*6kR822*h?2Gz^Y-iFiqZ8g&%VU=%`dGK63e3LGECIwZ%?R;SzQ?ojgq z^Aj^~^EA&?jaa2sme2DgmLH+6a}p`6@ZdxD>9h7;d#`=z|3AHX2jC{E3B&}_%`j@; z%D1H_TPnyeJ6=--Eg3}0Tj^p6SOTZMbz6|3>X`-XdbM1B{Ooagt+Ki(ASwb!OTHII z(u+2v+fi{K{z2f#%KVdOYvuK|O1Vx5P5SxKwhBtyj@t~BCvc+rLhi_XCvx2UdZ1KY zMFoN3y3_Jx)CrWpY`@1`^;>a=)KDlg%wQnBrr*|Cx&)JE&4AiG=Xg$36o_ZC8v<6z zZ>l8XNZA;{XaYY9jP$8XVhpKa2>fK@2yA_wuyF=w8Adi)VJg!V>`JedU)_448c`wp zG=cMs)~6zgbKPi@Hjd%Az_F_1samJKrGj<2<+A?Ks^5_Ah725i?}1jd?Sul8-_Z!h z3{>d5JBlNE?mCS~Ae-qC*V&;^HX_IO3Wq@1jU=XUErF~1;tw!vTt{BuWJ^U1&Hd3~ z_Lt;zCfkeHXDsNh-L!E_cWtOau5`RmgSTzm(coa9+WrowF@+f$v$!iTAh-O0+BvMJ zN%p^BV-EL;hptjDIlfG#EBAqohng_tg!8OyMv50`O;r$7eTUan8n zsd=@ld&s?qsOcov_Hg4bjP^c%-lT1Mb2mP1{fks?B>rI!_XrjLhPC^rB~sS$=0Bf5 zP8la1hrXsCX*|L_E>Mp?XRu_>7{^?^UM1N?0`2*2r2kQ+Pn;6)L*K43Fq otherChildren; + Random random; + + /** Creates new Kindergarten manager */ + public KindergartenManager() { + super(); + otherChildren = new TreeSet(); + otherChildren.add(this); + random = new Random(); + } + + public void resolveConflict(Transaction me, Transaction other) { + try { + KindergartenManager otherManager = + (KindergartenManager) other.getContentionManager(); + // first, check sharing records. + if (otherChildren.contains(otherManager)) { + otherChildren.remove(otherManager); + other.abort(); // My turn! My turn! + return; + } + for (int i = 0; i < MAX_RETRIES; i++) { + this.sleep(SLEEP_PERIOD); + if (!other.isActive()) { + return; + } + } + me.abort(); // give up + return; + } catch (ClassCastException e) { + other.abort(); // Oh, other not a Kindergartener. Kill it. + return; + } + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/PriorityManager.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/PriorityManager.class new file mode 100644 index 0000000000000000000000000000000000000000..ed3cd509b0748eb01e730d46957c2e46defc2908 GIT binary patch literal 859 zcmZ`%%Wl&^6g`tVb>bLG(+317E#=Xq1PlR*MJgnyU=f9fL`Vg@i8CaF96K6M0{jPC z)~t~bl|X_$ABDJMyCp?s;kgf=d(OEY|N8yy2Y_4Hwvl64>&JT3@J2l31EIWUN=8cR z_m9)shQ&}h3VFa|k-cV^-;trz_Za4?wJw9T8})^QITT&wG0(8jmZ5ku8TEwf@LnJo z%I(PKL6<9O>a1z$p^O>U+efATanmF|CE_TUirpxD9Y|j@)T-G~NAWP`zLrtgJf>Ca z7O{vW8)b&YRAy$v#WGeHim~QOcjSnSvX(;wr(K*ug(1&-ks>+T^OfnJb8$Xd@GX~m zZzuzCpQNWWmovjl$2cI8NDqZ#C=G-@*e#)K*|@~8^@dNm7w~Z4y$IvUcub0-|8y)A zH(Nb?=ZmpP9BiUUEb%OhRc)CY$WM7NAp_3yXrg@ah>S5TABbi5cEbqaB1oHl1;C<= zu8U5as@oJ9#r*a@3ZE&-!J*Tk2-FFD9VN=#6h!d^RSYMwK&K(_31f&W*S_FXot_UL zQL2B%>fR^V6wm%8EfW;*h~y^SK!d*ZorHWNCCJE$3TwEK2v)F8S&s6JWCJ7ENNS+) z9h)!rarr0pQqyK9;O>m!!lB_SxSAQ>A+$04zxie|ze*^=9C|8X3oFFHP)+n|e*nFt Bs!jj^ literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/PriorityManager.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/PriorityManager.java new file mode 100644 index 00000000..14e33f6b --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/manager/PriorityManager.java @@ -0,0 +1,61 @@ +/* + * PriorityManager.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.manager; + +import dstm2.ContentionManager; +import dstm2.Transaction; + +/** + * Older transaction always wins. + * @author Maurice Herlihy + */ +public class PriorityManager extends BaseManager { + + public PriorityManager() { + } + public void resolveConflict(Transaction me, Transaction other) { + if (me.startTime <= other.startTime) { + other.abort(); + } else { + other.waitWhileActive(); + } + } + + public long getPriority() { + throw new UnsupportedOperationException(); + } + + public void setPriority(long value) { + throw new UnsupportedOperationException(); + } +} diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/util/Random.class b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/util/Random.class new file mode 100644 index 0000000000000000000000000000000000000000..ad6520c33a18917b43cad46dc9f6f45b910522c6 GIT binary patch literal 3167 zcmaJ@Yj7LY75>(iw9;l{6Gb+TAiH-)2p|9rwuCbWK1)mKucwlt~Hgk%(R!d z-cP^%Dy6_@Bod~b5G&#{hvq3GGs*dk{3xgq?%Qo^Z`RsPUjlW;hX!{IY}mG|b7W`( z!Q<8R^otG7^E>grA+abDu+4pLAOANQ*-XYVY&wu}Xu_B_#qwEOI~COD^BWNPWn9yC zH(F*gkx|feZLh3`<#hCq?lH&QK{st0DY+d};9obEv~0`0QbBb%GR#c6oP_DcqQ9Kn zb?nHu0Vr6eBLts{u!05W4dsUxz{U8Xigso%&60*a-qGvW<2sh3gOP_u2AKK0JRiB+ zl{7M$n1(j2)UgVeu(az6Y?g&9?8w=&$72;MdC$nOAB_QADsV3=_FYEqcCw>M(~qVA z){0%G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7?ZHS0x8!hZXKUc8!hZpblSR0lp%EFL}_u#u9vk4*ZQo|1MLBN=d{@U5SzQV@$=% z-)4{F3DT@ZJDw!rYLa~lKP@ESq0L@N|K@`B!leJSpfALb!(kHTXe5Uh$W!z)hnH#c ztFjy$85Q`RSpOi(Kgsi7Sd4$OjQ^3`TBN4KC2nDIdsT8M8R(up$fnKAH$H= Ar2qf` literal 0 HcmV?d00001 diff --git a/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/util/Random.java b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/util/Random.java new file mode 100644 index 00000000..ad1b038e --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/DSTM2/MatrixMultiply/dstm2/util/Random.java @@ -0,0 +1,255 @@ +/* + * Random.java + * + * Copyright 2006 Sun Microsystems, Inc., 4150 Network Circle, Santa + * Clara, California 95054, U.S.A. All rights reserved. + * + * Sun Microsystems, Inc. has intellectual property rights relating to + * technology embodied in the product that is described in this + * document. In particular, and without limitation, these + * intellectual property rights may include one or more of the + * U.S. patents listed at http://www.sun.com/patents and one or more + * additional patents or pending patent applications in the U.S. and + * in other countries. + * + * U.S. Government Rights - Commercial software. + * Government users are subject to the Sun Microsystems, Inc. standard + * license agreement and applicable provisions of the FAR and its + * supplements. Use is subject to license terms. Sun, Sun + * Microsystems, the Sun logo and Java are trademarks or registered + * trademarks of Sun Microsystems, Inc. in the U.S. and other + * countries. + * + * This product is covered and controlled by U.S. Export Control laws + * and may be subject to the export or import laws in other countries. + * Nuclear, missile, chemical biological weapons or nuclear maritime + * end uses or end users, whether direct or indirect, are strictly + * prohibited. Export or reexport to countries subject to + * U.S. embargo or to entities identified on U.S. export exclusion + * lists, including, but not limited to, the denied persons and + * specially designated nationals lists is strictly prohibited. + */ + +package dstm2.util; + +import java.io.*; +import java.util.concurrent.atomic.AtomicLong; + +/** + * Lightweight random number generator. Not thread-safe. Synchronization in the + * java.util.Randome can distort the performance of multithreaded benchmarks. + */ +public class Random extends java.util.Random { + + /** use serialVersionUID from JDK 1.1 for interoperability */ + static final long serialVersionUID = 3905348978240129619L; + + private long seed; + + private final static long multiplier = 0x5DEECE66DL; + private final static long addend = 0xBL; + private final static long mask = (1L << 48) - 1; + + /** + * Creates a new random number generator. This constructor sets + * the seed of the random number generator to a value very likely + * to be distinct from any other invocation of this constructor. + */ + public Random() { this(++seedUniquifier + System.nanoTime()); } + private static volatile long seedUniquifier = 8682522807148012L; + + /** + * Creates a new random number generator using a single + * long seed: + *
+   * public Random(long seed) { setSeed(seed); }
+ * Used by method next to hold + * the state of the pseudorandom number generator. + * + * @param seed the initial seed. + * @see java.util.Random#setSeed(long) + */ + public Random(long seed) { + this.seed = 0L; + setSeed(seed); + } + + /** + * Sets the seed of this random number generator using a single + * long seed. The general contract of setSeed + * is that it alters the state of this random number generator + * object so as to be in exactly the same state as if it had just + * been created with the argument seed as a seed. The method + * setSeed is implemented by class Random as follows: + *
+   * synchronized public void setSeed(long seed) {
+   *       this.seed = (seed ^ 0x5DEECE66DL) & ((1L << 48) - 1);
+   *       haveNextNextGaussian = false;
+   * }
+ * The implementation of setSeed by class Random + * happens to use only 48 bits of the given seed. In general, however, + * an overriding method may use all 64 bits of the long argument + * as a seed value. + * + * Note: Although the seed value is an AtomicLong, this method + * must still be synchronized to ensure correct semantics + * of haveNextNextGaussian. + * + * @param seed the initial seed. + */ + public void setSeed(long seed) { + seed = (seed ^ multiplier) & mask; + this.seed = seed; + haveNextNextGaussian = false; + } + + /** + * Generates the next pseudorandom number. Subclass should + * override this, as this is used by all other methods.

+ * The general contract of next is that it returns an + * int value and if the argument bits is between 1 + * and 32 (inclusive), then that many low-order bits of the + * returned value will be (approximately) independently chosen bit + * values, each of which is (approximately) equally likely to be + * 0 or 1. The method next is implemented + * by class Random as follows: + *

+   * synchronized protected int next(int bits) {
+   *       seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
+   *       return (int)(seed >>> (48 - bits));
+   * }
+ * This is a linear congruential pseudorandom number generator, as + * defined by D. H. Lehmer and described by Donald E. Knuth in The + * Art of Computer Programming, Volume 2: Seminumerical + * Algorithms, section 3.2.1. + * + * @param bits random bits + * @return the next pseudorandom value from this random number generator's sequence. + * @since JDK1.1 + */ + protected int next(int bits) { + seed = (seed * multiplier + addend) & mask; + return (int)(seed >>> (48 - bits)); + } + + private static final int BITS_PER_BYTE = 8; + private static final int BYTES_PER_INT = 4; + + private double nextNextGaussian; + private boolean haveNextNextGaussian = false; + + /** + * Returns the next pseudorandom, Gaussian ("normally") distributed + * double value with mean 0.0 and standard + * deviation 1.0 from this random number generator's sequence. + *

+ * The general contract of nextGaussian is that one + * double value, chosen from (approximately) the usual + * normal distribution with mean 0.0 and standard deviation + * 1.0, is pseudorandomly generated and returned. The method + * nextGaussian is implemented by class Random as follows: + *

+   * synchronized public double nextGaussian() {
+   *    if (haveNextNextGaussian) {
+   *            haveNextNextGaussian = false;
+   *            return nextNextGaussian;
+   *    } else {
+   *            double v1, v2, s;
+   *            do {
+   *                    v1 = 2 * nextDouble() - 1;   // between -1.0 and 1.0
+   *                    v2 = 2 * nextDouble() - 1;   // between -1.0 and 1.0
+   *                    s = v1 * v1 + v2 * v2;
+   *            } while (s >= 1 || s == 0);
+   *            double multiplier = Math.sqrt(-2 * Math.log(s)/s);
+   *            nextNextGaussian = v2 * multiplier;
+   *            haveNextNextGaussian = true;
+   *            return v1 * multiplier;
+   *    }
+   * }
+ * This uses the polar method of G. E. P. Box, M. E. Muller, and + * G. Marsaglia, as described by Donald E. Knuth in The Art of + * Computer Programming, Volume 2: Seminumerical Algorithms, + * section 3.4.1, subsection C, algorithm P. Note that it generates two + * independent values at the cost of only one call to Math.log + * and one call to Math.sqrt. + * + * @return the next pseudorandom, Gaussian ("normally") distributed + * double value with mean 0.0 and + * standard deviation 1.0 from this random number + * generator's sequence. + */ + public double nextGaussian() { + // See Knuth, ACP, Section 3.4.1 Algorithm C. + if (haveNextNextGaussian) { + haveNextNextGaussian = false; + return nextNextGaussian; + } else { + double v1, v2, s; + do { + v1 = 2 * nextDouble() - 1; // between -1 and 1 + v2 = 2 * nextDouble() - 1; // between -1 and 1 + s = v1 * v1 + v2 * v2; + } while (s >= 1 || s == 0); + double multiplier = Math.sqrt(-2 * Math.log(s)/s); + nextNextGaussian = v2 * multiplier; + haveNextNextGaussian = true; + return v1 * multiplier; + } + } + + /** + * Serializable fields for Random. + * + * @serialField seed long; + * seed for random computations + * @serialField nextNextGaussian double; + * next Gaussian to be returned + * @serialField haveNextNextGaussian boolean + * nextNextGaussian is valid + */ + private static final ObjectStreamField[] serialPersistentFields = { + new ObjectStreamField("seed", Long.TYPE), + new ObjectStreamField("nextNextGaussian", Double.TYPE), + new ObjectStreamField("haveNextNextGaussian", Boolean.TYPE) + }; + + /** + * Reconstitute the Random instance from a stream (that is, + * deserialize it). The seed is read in as long for + * historical reasons, but it is converted to an AtomicLong. + */ + private void readObject(java.io.ObjectInputStream s) + throws java.io.IOException, ClassNotFoundException { + + ObjectInputStream.GetField fields = s.readFields(); + long seedVal; + + seedVal = (long) fields.get("seed", -1L); + if (seedVal < 0) + throw new java.io.StreamCorruptedException( + "Random: invalid seed"); + seed = seedVal; + nextNextGaussian = fields.get("nextNextGaussian", 0.0); + haveNextNextGaussian = fields.get("haveNextNextGaussian", false); + } + + + /** + * Save the Random instance to a stream. + * The seed of a Random is serialized as a long for + * historical reasons. + * + */ + synchronized private void writeObject(ObjectOutputStream s) throws IOException { + // set the values of the Serializable fields + ObjectOutputStream.PutField fields = s.putFields(); + fields.put("seed", seed); + fields.put("nextNextGaussian", nextNextGaussian); + fields.put("haveNextNextGaussian", haveNextNextGaussian); + + // save them + s.writeFields(); + + } + +} -- 2.34.1