summaryrefslogtreecommitdiff
path: root/elki
diff options
context:
space:
mode:
authorErich Schubert <schube@dbs.ifi.lmu.de>2016-06-30 14:38:55 +0200
committerAndrej Shadura <andrewsh@debian.org>2019-03-09 22:48:46 +0000
commite7bb14abebeb0bf5a3a80165856e85f4a56e7cf6 (patch)
treea81c24c47bf28aef6dcc160f18861b49172c5caa /elki
parentc5ba1e872e92d7bd28d9757a1652f0abce321164 (diff)
[PATCH] Bug fix for single-core CPUs.
Gbp-Pq: Name single-core-bugfix.patch
Diffstat (limited to 'elki')
-rw-r--r--elki/src/main/java/de/lmu/ifi/dbs/elki/parallel/ParallelExecutor.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/elki/src/main/java/de/lmu/ifi/dbs/elki/parallel/ParallelExecutor.java b/elki/src/main/java/de/lmu/ifi/dbs/elki/parallel/ParallelExecutor.java
index dc7c8b1c..47d477e5 100644
--- a/elki/src/main/java/de/lmu/ifi/dbs/elki/parallel/ParallelExecutor.java
+++ b/elki/src/main/java/de/lmu/ifi/dbs/elki/parallel/ParallelExecutor.java
@@ -40,19 +40,19 @@ import de.lmu.ifi.dbs.elki.parallel.variables.SharedVariable.Instance;
/**
* Class to run processors in parallel, on all available cores.
- *
+ *
* TODO: add progress
- *
+ *
* @author Erich Schubert
* @since 0.7.0
- *
+ *
* @apiviz.has BlockArrayRunner
* @apiviz.uses ParallelCore
*/
public class ParallelExecutor {
/**
* Run a task on all available CPUs.
- *
+ *
* @param ids IDs to process
* @param procs Processors to run
*/
@@ -65,7 +65,7 @@ public class ParallelExecutor {
core.connect();
int numparts = core.getParallelism();
// TODO: are there better heuristics for choosing this?
- numparts = (size > numparts * numparts * 16) ? numparts * numparts - 1 : numparts;
+ numparts = (size > numparts * numparts * 16) ? numparts * Math.max(1, numparts - 1) : numparts;
final int blocksize = (size + (numparts - 1)) / numparts;
List<Future<ArrayDBIDs>> parts = new ArrayList<>(numparts);
@@ -93,9 +93,9 @@ public class ParallelExecutor {
/**
* Run for an array part, without step size.
- *
+ *
* @author Erich Schubert
- *
+ *
* @apiviz.uses Processor
*/
protected static class BlockArrayRunner implements Callable<ArrayDBIDs>, Executor {
@@ -126,7 +126,7 @@ public class ParallelExecutor {
/**
* Constructor.
- *
+ *
* @param ids IDs to process
* @param start Starting position
* @param end End position