Crate caffe2_threadpool
source ·Macros
Structs
- | Deleter object for unique_ptr for an | aligned object |
- | A BlockingCounter lets one thread to | wait for N events to occur. | | This is how the master thread waits for | all the worker threads to have finished | working. |
- | A threadpool with the given number of | threads. | | ———– | @note | | the kCacheLineSize alignment is present | only for cache performance, and is not | strictly enforced (for example, when | the object is created on the heap). Thus, | in order to avoid misaligned intrinsics, | no SSE instructions shall be involved | in the ThreadPool implementation. | ––––– | @note | | alignas is disabled because some compilers | do not deal with TORCH_API and alignas | annotations at the same time. |
- A worker thread.
- | A RAII, thread local (!) guard that enables | or disables grad mode upon construction, | and sets it back to the original value | upon destruction. |
Enums
Constants
- | A work-stealing threadpool loosely | based off of pthreadpool |
- | Default smallest amount of work that | will be partitioned between multiple | threads; the runtime value is configurable |
Traits
- A workload for a worker.
Functions
- | Waits until *var != initial_value. | | Returns the new value of *var. The guarantee | here is that the return value is different | from initial_value, and that that new | value has been taken by *var at some point | during the execution of this function. | There is no guarantee that this is still | the value of *var when this function | returns, since *var is not assumed to | be guarded by any lock. | | First does some busy-waiting for a fixed | number of no-op cycles, then falls back | to passive waiting for the given condvar, | guarded by the given mutex. | | The idea of doing some initial busy-waiting | is to help get better and more consistent | multithreading benefits for small | GEMM sizes. | | Busy-waiting help ensuring that if | we need to wake up soon after having started | waiting, then we can wake up quickly | (as opposed to, say, having to wait to | be scheduled again by the OS). On the | other hand, we must still eventually | revert to passive waiting for longer | waits (e.g. worker threads having finished | a GEMM and waiting until the next GEMM) | so as to avoid permanently spinning. |