Lumiera  0.pre.03
»edit your freedom«
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 
26 namespace vault{
27 namespace gear {
28 
29  namespace { // internal details
30 
31  size_t MINIMAL_CONCURRENCY = 2;
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) {/*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
const microseconds CONTEND_WAIT
base time unit for the exponentially stepped-up sleep delay in case of contention ...
Definition: work-force.hpp:81
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
const size_t CONTEND_SOFT_FACTOR
base counter for a spinning wait loop
Definition: work-force.hpp:79
A pool of workers for multithreaded rendering.
static size_t COMPUTATION_CAPACITY
Nominal »full size« of a pool of concurrent workers.
Definition: work-force.hpp:106
Vault-Layer implementation namespace root.
static size_t getDefaultComputationCapacity()
default value for full computing capacity is to use all (virtual) cores.
Definition: work-force.cpp:51