summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-01-22 18:36:15 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-01-22 18:36:15 (GMT)
commitf251814cf0fd10a767972530c119f8f109613c48 (patch)
treee9bd67bca2531c083ee0754fe6dabe043c8012d1 /src/core
parentc1bcf3e7bd0a256005bd15832117b78cee5fdfab (diff)
Fixed run sizes of parallel jobs.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nproc.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/core/nproc.h b/src/core/nproc.h
index 4a175b9..87cab23 100644
--- a/src/core/nproc.h
+++ b/src/core/nproc.h
@@ -33,5 +33,22 @@
guint get_max_online_threads(void);
+/**
+ * Calcul de tranches de travaux, avec prise en compte des cas particuliers.
+ */
+#define compute_run_size(qty, cpus) \
+ ({ \
+ if (qty == 0) \
+ *(cpus) = 0; \
+ else \
+ { \
+ *(cpus) = get_max_online_threads(); \
+ if (qty < *(cpus)) \
+ *(cpus) = qty; \
+ } \
+ *(cpus) > 0 ? qty / *(cpus) : 0; \
+ })
+
+
#endif /* _CORE_NPROC_H */