summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-11-10 16:21:31 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-11-10 16:21:31 +0000
commitbd86b89077131370e422eccd4939ddef6c32c98c (patch)
tree5cbbae315aca3be662976994997b0255f7f37c1b /src
parenta1b86a7e513f16f93aa2bc4294664f46bcac95d9 (diff)
downloadscala-bd86b89077131370e422eccd4939ddef6c32c98c.tar.gz
scala-bd86b89077131370e422eccd4939ddef6c32c98c.tar.bz2
scala-bd86b89077131370e422eccd4939ddef6c32c98c.zip
Benchmarking parallel sets.
No review.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/collection/mutable/FlatHashTable.scala2
-rw-r--r--src/library/scala/collection/parallel/mutable/ParHashSet.scala44
2 files changed, 33 insertions, 13 deletions
diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala
index d0d9ce2cf5..51872909ec 100644
--- a/src/library/scala/collection/mutable/FlatHashTable.scala
+++ b/src/library/scala/collection/mutable/FlatHashTable.scala
@@ -68,7 +68,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
threshold = newThreshold(_loadFactor, table.size)
val smDefined = in.readBoolean
- if (smDefined) sizeMapInit(table.length)
+ if (smDefined) sizeMapInit(table.length) else sizemap = null
var index = 0
while (index < size) {
diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala
index e14fbd7305..5386ae278d 100644
--- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala
+++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala
@@ -174,17 +174,17 @@ self: EnvironmentPassingCombiner[T, ParHashSet[T]] =>
*/
def insertEntry(insertAt: Int, comesBefore: Int, elem: T): Int = {
var h = insertAt
- if (h == -1) h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry) {
- if (entry == elem) return 0
- h = (h + 1) // we *do not* do `(h + 1) % table.length` here, because we don't overlap!!
- if (h >= comesBefore) return -1
- entry = table(h)
- }
- table(h) = elem.asInstanceOf[AnyRef]
- tableSize = tableSize + 1
- nnSizeMapAdd(h)
+ // if (h == -1) h = index(elemHashCode(elem))
+ // var entry = table(h)
+ // while (null != entry) {
+ // if (entry == elem) return 0
+ // h = (h + 1) // we *do not* do `(h + 1) % table.length` here, because we don't overlap!!
+ // if (h >= comesBefore) return -1
+ // entry = table(h)
+ // }
+ // table(h) = elem.asInstanceOf[AnyRef]
+ // tableSize = tableSize + 1
+ // nnSizeMapAdd(h)
1
}
}
@@ -222,15 +222,35 @@ self: EnvironmentPassingCombiner[T, ParHashSet[T]] =>
(elemsIn + leftoversIn, elemsLeft concat leftoversLeft)
}
private def insertAll(atPos: Int, beforePos: Int, elems: UnrolledBuffer[Any]): (Int, UnrolledBuffer[Any]) = {
- var it = elems.iterator
var leftovers = new UnrolledBuffer[Any]
var inserted = 0
+
+ // var unrolled = elems.headPtr
+ // var i = 0
+ // var t = table
+ // while (unrolled ne null) {
+ // val chunkarr = unrolled.array
+ // val chunksz = unrolled.size
+ // while (i < chunksz) {
+ // val elem = chunkarr(i)
+ // val res = t.insertEntry(atPos, beforePos, elem.asInstanceOf[T])
+ // if (res >= 0) inserted += 1
+ // else leftovers += elem
+ // i += 1
+ // }
+ // i = 0
+ // unrolled = unrolled.next
+ // }
+
+ // slower:
+ var it = elems.iterator
while (it.hasNext) {
val elem = it.next
val res = table.insertEntry(atPos, beforePos, elem.asInstanceOf[T])
if (res >= 0) inserted += res
else leftovers += elem
}
+
(inserted, leftovers)
}
def split = {