Skip to content

Commit

Permalink
Fix some threading arrangement bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
bdezonia committed Feb 6, 2023
1 parent 8fe57c8 commit 1e40c4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/main/java/nom/bdezonia/zorbage/misc/ThreadingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ public static Tuple2<Integer,Long> arrange(int numThreads, long numElems, boolea
numThreads--;
}

numThreads++;
if (numThreads * minElemSlice != numElems)
numThreads++;

return new Tuple2<>(numThreads, elemsPerThread+1);
return new Tuple2<>(numThreads, minElemSlice);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ public void test() {
numThreads = tuple.a();
numElems = tuple.b();
assertTrue(numThreads * numElems >= 51);
assertEquals(400, numThreads);
assertEquals(51, numThreads);
assertEquals(1, numElems);

tuple = ThreadingUtils.arrange(400, 451, false);
numThreads = tuple.a();
numElems = tuple.b();
assertTrue(numThreads * numElems >= 451);
assertEquals(400, numThreads);
assertEquals(226, numThreads);
assertEquals(2, numElems);

tuple = ThreadingUtils.arrange(10, 501, false);
Expand Down

0 comments on commit 1e40c4b

Please sign in to comment.