diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-11-10 16:21:31 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-11-10 16:21:31 +0000 |
commit | bd86b89077131370e422eccd4939ddef6c32c98c (patch) | |
tree | 5cbbae315aca3be662976994997b0255f7f37c1b | |
parent | a1b86a7e513f16f93aa2bc4294664f46bcac95d9 (diff) | |
download | scala-bd86b89077131370e422eccd4939ddef6c32c98c.tar.gz scala-bd86b89077131370e422eccd4939ddef6c32c98c.tar.bz2 scala-bd86b89077131370e422eccd4939ddef6c32c98c.zip |
Benchmarking parallel sets.
No review.
5 files changed, 45 insertions, 16 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 = { diff --git a/test/benchmarks/src/scala/collection/parallel/Benchmarking.scala b/test/benchmarks/src/scala/collection/parallel/Benchmarking.scala index 0eb6c6ef13..32c3ca154f 100644 --- a/test/benchmarks/src/scala/collection/parallel/Benchmarking.scala +++ b/test/benchmarks/src/scala/collection/parallel/Benchmarking.scala @@ -109,7 +109,7 @@ trait BenchmarkRegister { register(hashtries.RefParHashTrieBenches.Map) register(hashtries.RefParHashTrieBenches.Map2) - // parallel hash table benchmarks + // parallel hash table map benchmarks register(hashtables.RefParHashTableBenches.Reduce) register(hashtables.RefParHashTableBenches.Reduce2) register(hashtables.RefParHashTableBenches.Foreach) @@ -117,6 +117,15 @@ trait BenchmarkRegister { register(hashtables.RefParHashTableBenches.Map) register(hashtables.RefParHashTableBenches.Map2) register(hashtables.RefParHashTableBenches.HeavyMap) + + // parallel hash table set benchmarks + register(hashtables.RefParHashTableSetBenches.Reduce) + register(hashtables.RefParHashTableSetBenches.Reduce2) + register(hashtables.RefParHashTableSetBenches.Foreach) + register(hashtables.RefParHashTableSetBenches.ForeachSet) + register(hashtables.RefParHashTableSetBenches.Map) + register(hashtables.RefParHashTableSetBenches.Map2) + register(hashtables.RefParHashTableSetBenches.HeavyMap) } diff --git a/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTableSets.scala b/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTableSets.scala index 2ac1e1c110..d0b7bae834 100644 --- a/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTableSets.scala +++ b/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTableSets.scala @@ -19,7 +19,7 @@ trait ParHashTableSetBenches[T] extends StandardParIterableBenches[T, ParHashSet val forkJoinPool = new scala.concurrent.forkjoin.ForkJoinPool object Map2 extends IterableBenchCompanion { - override def defaultSize = 5000 + override def defaultSize = 50000 override def comparisons = List() def benchName = "map2"; def apply(sz: Int, p: Int, w: String) = new Map2(sz, p, w) diff --git a/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTables.scala b/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTables.scala index ad2a8750c1..291f7ec62d 100644 --- a/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTables.scala +++ b/test/benchmarks/src/scala/collection/parallel/benchmarks/hashtables/ParallelHashTables.scala @@ -19,7 +19,7 @@ trait ParHashTableBenches[K, V] extends StandardParIterableBenches[(K, V), ParHa val forkJoinPool = new scala.concurrent.forkjoin.ForkJoinPool object Map2 extends IterableBenchCompanion { - override def defaultSize = 5000 + override def defaultSize = 40000 override def comparisons = List("jhashtable") def benchName = "map2"; def apply(sz: Int, p: Int, w: String) = new Map2(sz, p, w) |