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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_BASE_WORK_THREAD_LIMITS_H
25 #define PXR_BASE_WORK_THREAD_LIMITS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/base/work/api.h"
29 
31 
32 /// \file work/threadLimits.h
33 
34 /// Return the current concurrency limit, always >= 1.
35 ///
36 /// This value is determined by the underlying concurrency subsystem. It may
37 /// have been set by a third party, by a call to Work API below, or by Work
38 /// itself if the PXR_WORK_THREAD_LIMIT env setting was set. If the
39 /// PXR_WORK_THREAD_LIMIT env setting has been explicitly set to a non-zero
40 /// value, Work will attempt to configure the underlying concurrency subsystem
41 /// to use the specified limit and will ignore concurrency limits set via the
42 /// API calls below.
43 ///
44 /// Note that this can return a value larger than
45 /// WorkGetPhysicalConcurrencyLimit() if WorkSetConcurrencyLimit() was called
46 /// with such a value, or if PXR_WORK_THREAD_LIMIT was set with such a value.
47 ///
49 
50 /// Return true if WorkGetPhysicalConcurrencyLimit() returns a number greater
51 /// than 1 and PXR_WORK_THREAD_LIMIT was not set in an attempt to limit the
52 /// process to a single thread, false otherwise.
53 ///
55 
56 /// Return the number of physical execution cores available to the program.
57 /// This is either the number of physical cores on the machine or the number of
58 /// cores specified by the process's affinity mask, whichever is smaller.
59 ///
61 
62 /// Set the concurrency limit to \p n, if \p n is a non-zero value.
63 ///
64 /// If \p n is zero, then do not change the current concurrency limit.
65 ///
66 /// Note, calling this function with n > WorkGetPhysicalConcurrencyLimit() may
67 /// overtax the machine.
68 ///
69 /// In general, very few places should call this function. Call it in places
70 /// where the number of allowed threads is dictated, for example, by a hosting
71 /// environment. Lower-level library code should never call this function.
72 ///
73 WORK_API void WorkSetConcurrencyLimit(unsigned n);
74 
75 /// Sanitize \p n as described below and set the concurrency limit accordingly.
76 /// This function is useful for interpreting command line arguments.
77 ///
78 /// If \p n is zero, then do not change the current concurrency limit.
79 ///
80 /// If \p n is a positive, non-zero value then call WorkSetConcurrencyLimit(n).
81 /// Note that calling this method with \p n greater than the value returned by
82 /// WorkGetPhysicalConcurrencyLimit() may overtax the machine.
83 ///
84 /// If \p n is negative, then set the concurrency limit to all but abs(\p n)
85 /// cores. The number of cores is determined by the value returned by
86 /// WorkGetPhysicalConcurrencyLimit().
87 /// For example, if \p n is -2, then use all but two cores. If abs(\p n) is
88 /// greater than the number of physical cores, then call
89 /// WorkSetConcurrencyLimit(1), effectively disabling concurrency.
90 ///
92 
93 /// Set the concurrency limit to be the maximum recommended for the hardware
94 /// on which it's running. Equivalent to:
95 /// \code
96 /// WorkSetConcurrencyLimit(WorkGetPhysicalConcurrencyLimit()).
97 /// \endcode
98 ///
100 
102 
103 #endif
WORK_API unsigned WorkGetPhysicalConcurrencyLimit()
WORK_API void WorkSetMaximumConcurrencyLimit()
#define WORK_API
Definition: api.h:40
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:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
WORK_API void WorkSetConcurrencyLimit(unsigned n)