Geogram
Version 1.9.1
A programming library of geometric algorithms
|
Abstract interface to the basic linear algebra routines used by OpenNL internally. More...
#include "nl_private.h"
Go to the source code of this file.
Classes | |
struct | NLBlas |
Macros | |
#define | NL_NEW_VECTOR(blas, memtype, dim) (double*)blas->Malloc(blas,memtype,(size_t)(dim)*sizeof(double)) |
Allocates a vector of doubles;. More... | |
#define | NL_DELETE_VECTOR(blas, memtype, dim, ptr) blas->Free(blas,memtype,(size_t)(dim)*sizeof(double),ptr) |
Deletes a vector of doubles;. More... | |
Typedefs | |
typedef struct NLBlas * | NLBlas_t |
A handle to a BLAS abstraction layer. | |
typedef void *(* | FUNPTR_malloc) (NLBlas_t blas, NLmemoryType type, size_t size) |
Allocates memory in host or in device. More... | |
typedef void(* | FUNPTR_free) (NLBlas_t blas, NLmemoryType type, size_t size, void *ptr) |
Frees memory from host or from device. More... | |
typedef void(* | FUNPTR_memcpy) (NLBlas_t blas, void *to, NLmemoryType to_type, void *from, NLmemoryType from_type, size_t size) |
Copies a bloc of memory. More... | |
typedef void(* | FUNPTR_memset) (NLBlas_t blas, void *to, NLmemoryType to_type, int c, size_t size) |
Sets a bloc of memory. More... | |
typedef void(* | FUNPTR_dcopy) (NLBlas_t blas, int n, const double *x, int incx, double *y, int incy) |
Copies a vector. More... | |
typedef void(* | FUNPTR_dscal) (NLBlas_t blas, int n, double a, double *x, int incx) |
Scales a vector. More... | |
typedef double(* | FUNPTR_ddot) (NLBlas_t blas, int n, const double *x, int incx, const double *y, int incy) |
Computes the dot product between two vectors. More... | |
typedef double(* | FUNPTR_dnrm2) (NLBlas_t blas, int n, const double *x, int incx) |
Computes the norm of a vector. More... | |
typedef void(* | FUNPTR_daxpy) (NLBlas_t blas, int n, double a, const double *x, int incx, double *y, int incy) |
Computes a linear combination of two vectors. More... | |
typedef void(* | FUNPTR_dmul) (NLBlas_t blas, int n, const double *x, const double *y, double *z) |
Component-wise multiplication. More... | |
typedef void(* | FUNPTR_dgemv) (NLBlas_t blas, MatrixTranspose trans, int m, int n, double alpha, const double *A, int ldA, const double *x, int incx, double beta, double *y, int incy) |
Computes a matrix-vector product. More... | |
typedef void(* | FUNPTR_dtpsv) (NLBlas_t blas, MatrixTriangle uplo, MatrixTranspose trans, MatrixUnitTriangular diag, int n, const double *AP, double *x, int incx) |
Solves a linear system. More... | |
typedef void(* | FUNPTR_show_stats) (NLBlas_t blas) |
Displays the statistics associated with a BLAS context. More... | |
typedef void(* | FUNPTR_reset_stats) (NLBlas_t blas) |
Resets the statistics associated with a BLAS context. More... | |
Enumerations | |
enum | MatrixTranspose { NoTranspose =0 , Transpose =1 , ConjugateTranspose =2 } |
Specifies whether matrix should be transposed. More... | |
enum | MatrixTriangle { UpperTriangle =0 , LowerTriangle =1 } |
Specifies which triangular part of a matrix should be used. More... | |
enum | MatrixUnitTriangular { UnitTriangular =0 , NotUnitTriangular =1 } |
Specifies which triangular part of a matrix should be used. More... | |
enum | NLmemoryType { NL_HOST_MEMORY , NL_DEVICE_MEMORY } |
Specifies on which type of memory a function should be applied. More... | |
Functions | |
NLAPI NLboolean NLAPIENTRY | nlBlasHasUnifiedMemory (NLBlas_t blas) |
Tests whether BLAS device uses the same address space as the CPU. More... | |
NLAPI void NLAPIENTRY | nlBlasResetStats (NLBlas_t blas) |
Resets the statistics associated with a BLAS context. More... | |
NLAPI void NLAPIENTRY | nlBlasShowStats (NLBlas_t blas) |
Displays the statistics associated with a BLAS context. More... | |
NLAPI double NLAPIENTRY | nlBlasGFlops (NLBlas_t blas) |
Gets the number of floating point operations per seconds computed since creation of the BLAS abstaction layer or since the latest call to nlBlasResetStats(). More... | |
NLAPI NLulong NLAPIENTRY | nlBlasUsedRam (NLBlas_t blas, NLmemoryType type) |
Gets the currently used amount of memory computed since creation of the BLAS abstaction layer or since the latest call to nlBlasResetStats(). More... | |
NLAPI NLulong NLAPIENTRY | nlBlasMaxUsedRam (NLBlas_t blas, NLmemoryType type) |
Gets the high mark of used amount of memory computed since creation of the BLAS abstaction layer or since the latest call to nlBlasResetStats(). More... | |
NLAPI NLBlas_t NLAPIENTRY | nlHostBlas (void) |
Gets a pointer to the BLAS abstraction layer for BLAS operation on the host CPU. More... | |
Abstract interface to the basic linear algebra routines used by OpenNL internally.
Definition in file nl_blas.h.
#define NL_DELETE_VECTOR | ( | blas, | |
memtype, | |||
dim, | |||
ptr | |||
) | blas->Free(blas,memtype,(size_t)(dim)*sizeof(double),ptr) |
#define NL_NEW_VECTOR | ( | blas, | |
memtype, | |||
dim | |||
) | (double*)blas->Malloc(blas,memtype,(size_t)(dim)*sizeof(double)) |
typedef void(* FUNPTR_daxpy) (NLBlas_t blas, int n, double a, const double *x, int incx, double *y, int incy) |
Computes a linear combination of two vectors.
In formula: \( y \leftarrow a x + y \)
[in] | blas | a handle to the BLAS abstraction layer |
[in] | n | dimension of the vectors |
[in] | a | scaling coefficient |
[in] | x | source vector to be scaled and added |
[in] | incx | straddle between two consecutive coefficients of the source vector |
[in,out] | y | the vector that a x should be added to |
[in] | incy | straddle between two consecutive coefficients of the destination vector |
typedef void(* FUNPTR_dcopy) (NLBlas_t blas, int n, const double *x, int incx, double *y, int incy) |
Copies a vector.
In formula: \( y \leftarrow x \)
[in] | blas | a handle to the BLAS abstraction layer |
[in] | n | dimension of the vector |
[in] | x | source vector |
[in] | incx | straddle between two consecutive coefficients of the source vector |
[out] | y | destination vector |
[in] | incy | straddle between two consecutive coefficients of the destination vector |
typedef double(* FUNPTR_ddot) (NLBlas_t blas, int n, const double *x, int incx, const double *y, int incy) |
Computes the dot product between two vectors.
[in] | blas | a handle to the BLAS abstraction layer |
[in] | n | dimension of the vectors |
[in] | x | first vector |
[in] | incx | straddle between two consecutive coefficients of the first vector |
[in] | y | second vector |
[in] | incy | straddle between two consecutive coefficients of the second vector |
x
and y
typedef void(* FUNPTR_dgemv) (NLBlas_t blas, MatrixTranspose trans, int m, int n, double alpha, const double *A, int ldA, const double *x, int incx, double beta, double *y, int incy) |
Computes a matrix-vector product.
performs one of the matrix-vector operations \( y = \alpha A x + \beta y \) or \( y = \alpha A^t x + \beta y \), where \( \alpha \) and \( \beta \) are scalars, x and y are vectors and A is an m by n matrix.
[in] | blas | a handle to the BLAS abstraction layer |
[in] | trans | one of (NoTranspose, Transpose, ConjugateTranspose), specifies the operation to be performed as follows:
|
[in] | m | number of rows of the matrix A |
[in] | n | number of columns of the matrix A |
[in] | alpha | the scalar \( \alpha \) |
[in] | A | an array of dimension (ldA,n). On entry, the leading m by n part of the array A must contain the array of coefficients. |
[in] | ldA | specifies the first dimension of A as declared by the caller. ldA must be at least max(1,m). |
[in] | x | array of dimension at least ( 1 + ( n - 1 )*abs( incx ) ) when trans = NoTranspose and at least ( 1 + ( m - 1 )*abs( incx ) ) otherwise. Before entry, the incremented array X must contain the vector x. |
[in] | incx | the increment for the elements of x |
[in] | beta | the scalar \( \beta \) |
[in,out] | y | an array of dimension ( 1 + ( m - 1 )*abs( incy ) ) when trans = NoTranspose and at least ( 1 + ( n - 1 )*abs( incy ) ) otherwise. Before entry with beta non-zero, the incremented array y must contain the vector y. On exit, y is overwritten by the updated vector y. |
[in] | incy | the increment for the elements of y |
typedef void(* FUNPTR_dmul) (NLBlas_t blas, int n, const double *x, const double *y, double *z) |
typedef double(* FUNPTR_dnrm2) (NLBlas_t blas, int n, const double *x, int incx) |
typedef void(* FUNPTR_dscal) (NLBlas_t blas, int n, double a, double *x, int incx) |
typedef void(* FUNPTR_dtpsv) (NLBlas_t blas, MatrixTriangle uplo, MatrixTranspose trans, MatrixUnitTriangular diag, int n, const double *AP, double *x, int incx) |
Solves a linear system.
Solves one of the systems of equations \( A x = b \) or \( A^t x = b \) where b and x are n element vectors and A is an n by n unit, or non-unit, upper or lower triangular matrix, supplied in packed form. No test for singularity or near-singularity is included in this routine. Such tests must be performed before calling this routine.
[in] | blas | a handle to the BLAS abstraction layer |
[in] | uplo | one of (UpperTriangle, LowerTriangle), specifies whether A is an upper or lower triangular matrix as follows:
|
[in] | trans | one of (NoTranspose, Transpose, ConjugateTranspose), specifies the equations to be solved as follows:
|
[in] | diag | one of (UnitTriangular, NotUnitTriangular), specifies whether or not A is unit triangular as follows:
|
[in] | n | the order of the matrix |
[in] | AP | an array of dimension at least ( ( n*( n + 1))/2).
|
[in,out] | x | array of dimension at least (1 + (n-1)*abs( incx )). Before entry, the incremented array x must contain the n element right-hand side vector b. On exit, x is overwritten with the solution vector x. |
[in] | incx | specifies the increment for the elements of x. Must not be zero. |
typedef void(* FUNPTR_free) (NLBlas_t blas, NLmemoryType type, size_t size, void *ptr) |
Frees memory from host or from device.
[in] | blas | a handle to the BLAS abstraction layer |
[in] | type | whether RAM should be allocated on the CPU (NL_HOST_MEMORY) or the GPU (NL_DEVICE_MEMORY) |
[in] | size | the number of bytes of the memory bloc to be allocated. |
[in] | ptr | a pointer to the memory to be freed. |
typedef void*(* FUNPTR_malloc) (NLBlas_t blas, NLmemoryType type, size_t size) |
Allocates memory in host or in device.
[in] | blas | a handle to the BLAS abstraction layer |
[in] | type | whether RAM should be allocated on the CPU (NL_HOST_MEMORY) or the GPU (NL_DEVICE_MEMORY) |
[in] | size | the number of bytes of the memory bloc to be allocated. |
typedef void(* FUNPTR_memcpy) (NLBlas_t blas, void *to, NLmemoryType to_type, void *from, NLmemoryType from_type, size_t size) |
Copies a bloc of memory.
[in] | blas | a handle to the BLAS abstraction layer. |
[in] | to,to_type | a pointer to the destination and indication of whether the destination is on CPU RAM (NL_HOST_MEMORY) or GPU RAM (NL_DEVICE_MEMORY). |
[in] | from,frm_type | a pointer to the source and indication of whether the source is on CPU RAM (NL_HOST_MEMORY) or GPU RAM (NL_DEVICE_MEMORY). |
[in] | size | number of bytes to be copied. |
typedef void(* FUNPTR_memset) (NLBlas_t blas, void *to, NLmemoryType to_type, int c, size_t size) |
Sets a bloc of memory.
[in] | blas | a handle to the BLAS abstraction layer. |
[in] | to,to_type | a pointer to the destination and indication of whether the destination is on CPU RAM (NL_HOST_MEMORY) or GPU RAM (NL_DEVICE_MEMORY). |
[in] | c | value of each byte to be set. |
[in] | size | number of bytes to set. |
typedef void(* FUNPTR_reset_stats) (NLBlas_t blas) |
typedef void(* FUNPTR_show_stats) (NLBlas_t blas) |
enum MatrixTranspose |
enum MatrixTriangle |
enum MatrixUnitTriangular |
enum NLmemoryType |
NLAPI double NLAPIENTRY nlBlasGFlops | ( | NLBlas_t | blas | ) |
Gets the number of floating point operations per seconds computed since creation of the BLAS abstaction layer or since the latest call to nlBlasResetStats().
Tests whether BLAS device uses the same address space as the CPU.
[in] | blas | a pointer to the BLAS abstraction layer. |
NL_FALSE | otherwise. |
NLAPI NLulong NLAPIENTRY nlBlasMaxUsedRam | ( | NLBlas_t | blas, |
NLmemoryType | type | ||
) |
Gets the high mark of used amount of memory computed since creation of the BLAS abstaction layer or since the latest call to nlBlasResetStats().
[in] | blas | a pointer to the BLAS abstraction layer. |
[in] | type | one of NL_HOST_MEMORY, NL_DEVICE_MEMORY. |
NLAPI void NLAPIENTRY nlBlasResetStats | ( | NLBlas_t | blas | ) |
Resets the statistics associated with a BLAS context.
[in] | blas | a pointer to the BLAS abstraction layer. |
NLAPI void NLAPIENTRY nlBlasShowStats | ( | NLBlas_t | blas | ) |
Displays the statistics associated with a BLAS context.
[in] | blas | a pointer to the BLAS abstraction layer. |
NLAPI NLulong NLAPIENTRY nlBlasUsedRam | ( | NLBlas_t | blas, |
NLmemoryType | type | ||
) |
Gets the currently used amount of memory computed since creation of the BLAS abstaction layer or since the latest call to nlBlasResetStats().
[in] | blas | a pointer to the BLAS abstraction layer. |
[in] | type | one of NL_HOST_MEMORY, NL_DEVICE_MEMORY. |
NLAPI NLBlas_t NLAPIENTRY nlHostBlas | ( | void | ) |
Gets a pointer to the BLAS abstraction layer for BLAS operation on the host CPU.