All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
threadLimits.h File Reference
+ Include dependency graph for threadLimits.h:

Go to the source code of this file.

Functions

WORK_API unsigned WorkGetConcurrencyLimit ()
 Return the current concurrency limit, always >= 1. More...
 
WORK_API unsigned WorkGetPhysicalConcurrencyLimit ()
 Return the number of physical execution cores available to the program. More...
 
WORK_API void WorkSetConcurrencyLimit (unsigned n)
 Set the concurrency limit to n, if n is a non-zero value. More...
 
WORK_API void WorkSetConcurrencyLimitArgument (int n)
 Sanitize n as described below and set the concurrency limit accordingly. More...
 
WORK_API void WorkSetMaximumConcurrencyLimit ()
 Set the concurrency limit to be the maximum recommended for the hardware on which it's running. More...
 

Function Documentation

WORK_API unsigned WorkGetConcurrencyLimit ( )

Return the current concurrency limit, always >= 1.

The initial value is determined by the PXR_WORK_THREAD_LIMIT env setting, which defaults to WorkGetPhysicalConcurrencyLimit(). If the env setting has been explicitly set to a non-zero value, it will always override any concurrency limit set via the API calls below.

Note that this can return a value larger than WorkGetPhysicalConcurrencyLimit() if WorkSetConcurrencyLimit() was called with such a value, or if PXR_WORK_THREAD_LIMIT was set with such a value.

WORK_API unsigned WorkGetPhysicalConcurrencyLimit ( )

Return the number of physical execution cores available to the program.

This is either the number of physical cores on the machine or the number of cores specified by the process's affinity mask, whichever is smaller.

WORK_API void WorkSetConcurrencyLimit ( unsigned  n)

Set the concurrency limit to n, if n is a non-zero value.

If n is zero, then do not change the current concurrency limit.

Note, calling this function with n > WorkGetPhysicalConcurrencyLimit() may overtax the machine.

In general, very few places should call this function. Call it in places where the number of allowed threads is dictated, for example, by a hosting environment. Lower-level library code should never call this function.

WORK_API void WorkSetConcurrencyLimitArgument ( int  n)

Sanitize n as described below and set the concurrency limit accordingly.

This function is useful for interpreting command line arguments.

If n is zero, then do not change the current concurrency limit.

If n is a positive, non-zero value then call WorkSetConcurrencyLimit(n). Note that calling this method with n greater than the value returned by WorkGetPhysicalConcurrencyLimit() may overtax the machine.

If n is negative, then set the concurrency limit to all but abs(n) cores. The number of cores is determined by the value returned by WorkGetPhysicalConcurrencyLimit(). For example, if n is -2, then use all but two cores. If abs(n) is greater than the number of physical cores, then call WorkSetConcurrencyLimit(1), effectively disabling concurrency.

WORK_API void WorkSetMaximumConcurrencyLimit ( )

Set the concurrency limit to be the maximum recommended for the hardware on which it's running.

Equivalent to: