# What are the internally multi - threaded functions in Gauss?

User ForumWhat are the internally multi - threaded functions in Gauss?
Giuseppe Alesii asked 3 years ago

Where can I get a list of the internally multi - threaded functions in Gauss ?

What is the default number of threads of these internally multi - threaded functions ?

Is it possible to change it ? For instance, if I have a 256 cores machine,  may I change the default number of cores of the internally multi - threaded functions ?

aptech Staff answered 3 years ago

The number of threads created internally by a GAUSS function is dependent upon the computer's resources and the size of the data. GAUSS will use the lesser of: 1) the number of cores available 2) The number of cores that can be profitably used for the calculation in question.

For example, a matrix multiply or linear solve involving matrices that are 5x5 will use only one thread regardless of how many cores your system has, because it will slow down the algorithm to use more than one thread.

However, the same linear algebra operation on a matrix of 1000x1000 can profitably use at least 8 threads (maybe up to 16, depending upon the algorithm). So in this case if more cores are available, GAUSS will use them.

As stated above, the maximum number of threads that GAUSS will create for any function is equal to the number of cores on your system. You cannot increase this. However, you can set a maximum number. This can be controlled with the environment variable OMP_NUM_THREADS.

If your GAUSS code executes many independent iterations and only a small part of it is internally parallelized, then it may be more efficient to split the code up into many threads and use just one or two internal threads per GAUSS thread.

Here is a partial list of internally threaded GAUSS functions:
Matrix multiply
Matrix inversion
Linear solve
Cholesky decomposition
LU decomposition
cdfn, cdfni
All random number generators that have a state as an optional argument i.e. rndn, rndu, rndBeta, rndBinomal,...rndWishart, etc.
and also any function that uses the functions above, for example the function 'ols' uses threaded matrix multiply and inversion internally.

Giuseppe Alesii answered 3 years ago

Sorry for the silly question, but,

how do I set up a environment variable such as OMP_NUM_THREADS ?

would it be possible to turn off internal threading lest it interferes with user made threading ?

aptech Staff answered 3 years ago

On Linux the simplest method is to set the environment variable from a shell command prompt like this:

```export OMP_NUM_THREADS=1
```

Setting an environment variable at the shell prompt will set it only for this terminal, so you will need to start GAUSS from the same command prompt.

On Windows 7, you can find instructions at this link.

• ### Aptech Systems, Inc. Worldwide Headquarters

Aptech Systems, Inc.
2350 East Germann Road, Suite #21
Chandler, AZ 85286

Phone: 360.886.7100
FAX: 360.886.8922

• ### Training & Events

Want more guidance while learning about the full functionality of GAUSS and its capabilities? Get in touch for in-person training or browse additional references below.

• ### Tutorials

Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.

• ### Have a Specific Question?

Get a real answer from a real person

• Need Support?
• ### Support Plans

Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.

• ### User Forums

Join our community to see why our users are considered some of the most active and helpful in the industry!