MAGMA  2.0.0
Matrix Algebra for GPU and Multicore Architectures
Utilities


More...

Functions

magma_int_t magma_is_devptr (const void *A)
 For debugging purposes, determines whether a pointer points to CPU or GPU memory. More...
 
magmaFloatComplex magma_cmake_lwork (magma_int_t lwork)
 This deals with a subtle bug with returning lwork as a Float. More...
 
double magma_dmake_lwork (magma_int_t lwork)
 This deals with a subtle bug with returning lwork as a Float. More...
 
float magma_smake_lwork (magma_int_t lwork)
 This deals with a subtle bug with returning lwork as a Float. More...
 
magma_int_t magma_get_parallel_numthreads ()
 Returns the number of threads to use for parallel sections of MAGMA. More...
 
magma_int_t magma_get_lapack_numthreads ()
 Returns the number of threads currently used for LAPACK and BLAS. More...
 
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 ()
 Returns the number of threads currently used for OMP sections. More...
 
void magma_set_omp_numthreads (magma_int_t threads)
 Sets the number of threads to use for parallel section. More...
 
magmaDoubleComplex magma_zmake_lwork (magma_int_t lwork)
 This deals with a subtle bug with returning lwork as a Float. More...
 
void magma_xerbla (const char *srname, magma_int_t minfo)
 magma_xerbla is an error handler for the MAGMA routines. More...
 
magma_int_t cusparse2magma_error (cusparseStatus_t status)
 Maps a cuSPARSE error to a MAGMA error. More...
 

Detailed Description


Function Documentation

magma_int_t cusparse2magma_error ( cusparseStatus_t  status)

Maps a cuSPARSE error to a MAGMA error.

Parameters
[in]statuscuSPARSE error
Returns
MAGMA error
magmaFloatComplex magma_cmake_lwork ( magma_int_t  lwork)

This deals with a subtle bug with returning lwork as a Float.

If lwork > 2**24, then it will get rounded as a Float; we need to ensure it is rounded up instead of down, by multiplying by 1.+eps in Double precision: float( 16777217 ) == 16777216 float( 16777217 * (1.+eps) ) == 16777218 (Could use 1+2*eps in Single precision, but that can add more than necesary.) If lwork > 2**53, rounding would happen in Double, too, but that's 94M x 94M!

double magma_dmake_lwork ( magma_int_t  lwork)

This deals with a subtle bug with returning lwork as a Float.

If lwork > 2**24, then it will get rounded as a Float; we need to ensure it is rounded up instead of down, by multiplying by 1.+eps in Double precision: float( 16777217 ) == 16777216 float( 16777217 * (1.+eps) ) == 16777218 (Could use 1+2*eps in Single precision, but that can add more than necesary.) If lwork > 2**53, rounding would happen in Double, too, but that's 94M x 94M!

magma_int_t magma_get_lapack_numthreads ( )

Returns the 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
magma_int_t magma_get_omp_numthreads ( )

Returns the number of threads currently used for OMP sections.

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

See also
magma_get_parallel_numthreads
magma_set_lapack_numthreads
magma_int_t magma_get_parallel_numthreads ( )

Returns the 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_is_devptr ( const void *  A)

For debugging purposes, determines whether a pointer points to CPU or GPU memory.

On CUDA architecture 2.0 cards with unified addressing, CUDA can tell if it is a device pointer or pinned host pointer. For malloc'd host pointers, cudaPointerGetAttributes returns error, implying it is a (non-pinned) host pointer.

On older cards, this cannot determine if it is CPU or GPU memory.

Parameters
Apointer to test
Returns
  • 1: if A is a device pointer (definitely),
  • 0: if A is a host pointer (definitely or inferred from error),
  • -1: if unknown.
Author
Mark Gates
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
void magma_set_omp_numthreads ( magma_int_t  threads)

Sets the number of threads to use for parallel section.

Internal routines.

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
float magma_smake_lwork ( magma_int_t  lwork)

This deals with a subtle bug with returning lwork as a Float.

If lwork > 2**24, then it will get rounded as a Float; we need to ensure it is rounded up instead of down, by multiplying by 1.+eps in Double precision: float( 16777217 ) == 16777216 float( 16777217 * (1.+eps) ) == 16777218 (Could use 1+2*eps in Single precision, but that can add more than necesary.) If lwork > 2**53, rounding would happen in Double, too, but that's 94M x 94M!

void magma_xerbla ( const char *  srname,
magma_int_t  minfo 
)

magma_xerbla is an error handler for the MAGMA routines.

It is called by a MAGMA routine if an input parameter has an invalid value. It prints an error message.

Installers may consider modifying it to call system-specific exception-handling facilities.

Parameters
[in]srnameCHAR* The name of the subroutine that called XERBLA. In C/C++ it is convenient to use "__func__".
[in]minfoINTEGER Note minfo's sign is opposite info's normal sign.

Normally:

  • minfo > 0: The position of the invalid parameter in the parameter list of the calling routine.

These conditions are also reported, but normally code should not call xerbla for these runtime errors:

  • minfo < 0: Function-specific error.
  • minfo >= -MAGMA_ERR: Pre-defined MAGMA error, such as malloc failure.
  • minfo == 0: No error.
magmaDoubleComplex magma_zmake_lwork ( magma_int_t  lwork)

This deals with a subtle bug with returning lwork as a Float.

If lwork > 2**24, then it will get rounded as a Float; we need to ensure it is rounded up instead of down, by multiplying by 1.+eps in Double precision: float( 16777217 ) == 16777216 float( 16777217 * (1.+eps) ) == 16777218 (Could use 1+2*eps in Single precision, but that can add more than necesary.) If lwork > 2**53, rounding would happen in Double, too, but that's 94M x 94M!