MAGMA  2.3.0
Matrix Algebra for GPU and Multicore Architectures
 All Classes Files Functions Friends Groups Pages
Thread management

Classes

class  magma_task
 Super class for tasks used with magma_thread_queue. More...
 
class  magma_thread_queue
 TODO: replace with OpenMP tasks. More...
 

Functions

magma_int_t magma_get_parallel_numthreads ()
 
magma_int_t magma_get_lapack_numthreads ()
 
void magma_set_lapack_numthreads (magma_int_t threads)
 Sets the number of threads to use for LAPACK and BLAS. More...
 
magma_int_t magma_get_omp_numthreads ()
 
void magma_set_omp_numthreads (magma_int_t threads)
 Sets the number of threads to use for parallel section. More...
 
magma_int_t magma_yield ()
 Yield the CPU to let another thread of lower priority run, for example, for I/O.
 

Detailed Description

Function Documentation

magma_int_t magma_get_parallel_numthreads ( )
Returns
Number of threads to use for parallel sections of MAGMA. Typically, it is initially set by the environment variables OMP_NUM_THREADS or MAGMA_NUM_THREADS.

If MAGMA_NUM_THREADS is set, this returns min( num_cores, MAGMA_NUM_THREADS ); else if MAGMA is compiled with OpenMP, this queries OpenMP and returns min( num_cores, OMP_NUM_THREADS ); else this returns num_cores.

For the number of cores, if MAGMA is compiled with hwloc, this queries hwloc; else it queries sysconf (on Unix) or GetSystemInfo (on Windows).

See Also
magma_get_lapack_numthreads
magma_set_lapack_numthreads
magma_int_t magma_get_lapack_numthreads ( )
Returns
Number of threads currently used for LAPACK and BLAS.

Typically, the number of threads is initially set by the environment variables OMP_NUM_THREADS or MKL_NUM_THREADS.

If MAGMA is compiled with MAGMA_WITH_MKL, this queries MKL; else if MAGMA is compiled with OpenMP, this queries OpenMP; else this returns 1.

See Also
magma_get_parallel_numthreads
magma_set_lapack_numthreads
void magma_set_lapack_numthreads ( magma_int_t  threads)

Sets the number of threads to use for LAPACK and BLAS.

This is often used to set BLAS to be single-threaded during sections where MAGMA uses explicit pthread parallelism. Example use:

nthread_save = magma_get_lapack_numthreads();
magma_set_lapack_numthreads( 1 );

... launch pthreads, do work, terminate pthreads ...

magma_set_lapack_numthreads( nthread_save );

If MAGMA is compiled with MAGMA_WITH_MKL, this sets MKL threads; else if MAGMA is compiled with OpenMP, this sets OpenMP threads; else this does nothing.

Parameters
[in]threadsINTEGER Number of threads to use. threads >= 1. If threads < 1, this silently does nothing.
See Also
magma_get_parallel_numthreads
magma_get_lapack_numthreads
magma_int_t magma_get_omp_numthreads ( )
Returns
Number of threads currently used for OMP sections. Typically, the number of threads is initially set by the environment variable OMP_NUM_THREADS.
See Also
magma_get_parallel_numthreads
magma_set_lapack_numthreads
void magma_set_omp_numthreads ( magma_int_t  threads)

Sets the number of threads to use for parallel section.

This is often used to set BLAS to be single-threaded during sections where MAGMA uses explicit pthread parallelism. Example use:

nthread_save = magma_get_omp_numthreads();
magma_set_omp_numthreads( 1 );

... launch pthreads, do work, terminate pthreads ...

magma_set_omp_numthreads( nthread_save );
Parameters
[in]threadsINTEGER Number of threads to use. threads >= 1. If threads < 1, this silently does nothing.
See Also
magma_get_parallel_numthreads
magma_get_lapack_numthreads