Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
work-force.cpp
Go to the documentation of this file.
1/*
2 WorkForce.hpp - actively coordinated pool of workers for rendering
3
4 Copyright (C)
5 2023, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
23#include "lib/util.hpp"
24
25
26namespace vault{
27namespace gear {
28
29 namespace { // internal details
30
32
33 } // internal details
34
35
36
45 size_t work::Config::COMPUTATION_CAPACITY = Config::getDefaultComputationCapacity();
46
50 size_t
52 {
53 return util::max (std::thread::hardware_concurrency()
54 , MINIMAL_CONCURRENCY);
55 }
56
57
65 void
66 work::performRandomisedSpin (size_t stepping, size_t randFact)
67 {
68 size_t degree = CONTEND_SOFT_FACTOR * (1+randFact) * stepping;
69 for (volatile size_t i=0; i<degree; ) { i=i+1; /*SPIN*/}
70 }
71
81 microseconds
82 work::steppedRandDelay (size_t stepping, size_t randFact)
83 {
84 REQUIRE (stepping > 0);
85 uint factor = 1u << (stepping-1);
86 return (CONTEND_WAIT + 10us*randFact) * factor;
87 }
88
89
90}} // namespace vault::gear
unsigned int uint
Definition integral.hpp:29
auto max(IT &&elms)
void performRandomisedSpin(size_t, size_t)
This is part of the weak level of anti-contention measures.
microseconds steppedRandDelay(size_t, size_t)
Calculate the delay time for a stronger anti-contention wait.
Vault-Layer implementation namespace root.
static size_t getDefaultComputationCapacity()
default value for full computing capacity is to use all (virtual) cores.
static size_t COMPUTATION_CAPACITY
Nominal »full size« of a pool of concurrent workers.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
A pool of workers for multithreaded rendering.