HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
threadLimits.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_BASE_WORK_THREAD_LIMITS_H
8 #define PXR_BASE_WORK_THREAD_LIMITS_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/base/work/api.h"
12 
14 
15 /// \file work/threadLimits.h
16 
17 /// Return the current concurrency limit, always >= 1.
18 ///
19 /// This value is determined by the underlying concurrency subsystem. It may
20 /// have been set by a third party, by a call to Work API below, or by Work
21 /// itself if the PXR_WORK_THREAD_LIMIT env setting was set. If the
22 /// PXR_WORK_THREAD_LIMIT env setting has been explicitly set to a non-zero
23 /// value, Work will attempt to configure the underlying concurrency subsystem
24 /// to use the specified limit and will ignore concurrency limits set via the
25 /// API calls below.
26 ///
27 /// Note that this can return a value larger than
28 /// WorkGetPhysicalConcurrencyLimit() if WorkSetConcurrencyLimit() was called
29 /// with such a value, or if PXR_WORK_THREAD_LIMIT was set with such a value.
30 ///
32 
33 /// Return true if WorkGetPhysicalConcurrencyLimit() returns a number greater
34 /// than 1 and PXR_WORK_THREAD_LIMIT was not set in an attempt to limit the
35 /// process to a single thread, false otherwise.
36 ///
38 
39 /// Return the number of physical execution cores available to the program.
40 /// This is either the number of physical cores on the machine or the number of
41 /// cores specified by the process's affinity mask, whichever is smaller.
42 ///
44 
45 /// Set the concurrency limit to \p n, if \p n is a non-zero value.
46 ///
47 /// If \p n is zero, then do not change the current concurrency limit.
48 ///
49 /// Note, calling this function with n > WorkGetPhysicalConcurrencyLimit() may
50 /// overtax the machine.
51 ///
52 /// In general, very few places should call this function. Call it in places
53 /// where the number of allowed threads is dictated, for example, by a hosting
54 /// environment. Lower-level library code should never call this function.
55 ///
56 WORK_API void WorkSetConcurrencyLimit(unsigned n);
57 
58 /// Sanitize \p n as described below and set the concurrency limit accordingly.
59 /// This function is useful for interpreting command line arguments.
60 ///
61 /// If \p n is zero, then do not change the current concurrency limit.
62 ///
63 /// If \p n is a positive, non-zero value then call WorkSetConcurrencyLimit(n).
64 /// Note that calling this method with \p n greater than the value returned by
65 /// WorkGetPhysicalConcurrencyLimit() may overtax the machine.
66 ///
67 /// If \p n is negative, then set the concurrency limit to all but abs(\p n)
68 /// cores. The number of cores is determined by the value returned by
69 /// WorkGetPhysicalConcurrencyLimit().
70 /// For example, if \p n is -2, then use all but two cores. If abs(\p n) is
71 /// greater than the number of physical cores, then call
72 /// WorkSetConcurrencyLimit(1), effectively disabling concurrency.
73 ///
75 
76 /// Set the concurrency limit to be the maximum recommended for the hardware
77 /// on which it's running. Equivalent to:
78 /// \code
79 /// WorkSetConcurrencyLimit(WorkGetPhysicalConcurrencyLimit()).
80 /// \endcode
81 ///
83 
85 
86 #endif
WORK_API unsigned WorkGetPhysicalConcurrencyLimit()
WORK_API void WorkSetMaximumConcurrencyLimit()
#define WORK_API
Definition: api.h:23
GLdouble n
Definition: glcorearb.h:2008
WORK_API unsigned WorkGetConcurrencyLimit()
WORK_API void WorkSetConcurrencyLimitArgument(int n)
WORK_API bool WorkHasConcurrency()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
WORK_API void WorkSetConcurrencyLimit(unsigned n)