MAGMA  1.2.0
MatrixAlgebraonGPUandMulticoreArchitectures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
descriptor.c File Reference
#include <stdlib.h>
#include "common.h"
Include dependency graph for descriptor.c:

Go to the source code of this file.

Functions

magma_desc_t magma_desc_init (MAGMA_enum dtyp, int mb, int nb, int bsiz, int lm, int ln, int i, int j, int m, int n)
magma_desc_t magma_desc_submatrix (magma_desc_t descA, int i, int j, int m, int n)
int magma_desc_check (magma_desc_t *desc)
int magma_desc_mat_alloc (magma_desc_t *desc)
int magma_desc_mat_free (magma_desc_t *desc)
int MAGMA_Desc_Create (magma_desc_t **desc, void *mat, MAGMA_enum dtyp, int mb, int nb, int bsiz, int lm, int ln, int i, int j, int m, int n)
int MAGMA_Desc_Destroy (magma_desc_t **desc)

Function Documentation

int magma_desc_check ( magma_desc_t desc)

Check for descriptor correctness

Definition at line 88 of file descriptor.c.

References magma_desc_s::desc, MAGMA_ERR_ILLEGAL_VALUE, MAGMA_ERR_UNALLOCATED, magma_error, and MAGMA_SUCCESS.

{
if (desc->desc.mat == NULL) {
magma_error("magma_desc_check", "NULL matrix pointer");
}
if (desc->desc.dtyp != PlasmaRealFloat &&
desc->desc.dtyp != PlasmaRealDouble &&
desc->desc.dtyp != PlasmaComplexFloat &&
desc->desc.dtyp != PlasmaComplexDouble ) {
magma_error("magma_desc_check", "invalid matrix type");
}
if (desc->desc.mb <= 0 || desc->desc.nb <= 0) {
magma_error("magma_desc_check", "negative tile dimension");
}
if (desc->desc.bsiz < desc->desc.mb*desc->desc.nb) {
magma_error("magma_desc_check", "tile memory size smaller than the product of dimensions");
}
if (desc->desc.lm <= 0 || desc->desc.ln <= 0) {
magma_error("magma_desc_check", "negative matrix dimension");
}
if (desc->desc.i >= desc->desc.lm || desc->desc.j >= desc->desc.ln) {
magma_error("magma_desc_check", "beginning of the matrix out of scope");
}
if (desc->desc.i+desc->desc.m > desc->desc.lm || desc->desc.j+desc->desc.n > desc->desc.ln) {
magma_error("magma_desc_check", "submatrix out of scope");
}
return MAGMA_SUCCESS;
}

Here is the caller graph for this function:

int MAGMA_Desc_Create ( magma_desc_t **  desc,
void *  mat,
MAGMA_enum  dtyp,
int  mb,
int  nb,
int  bsiz,
int  lm,
int  ln,
int  i,
int  j,
int  m,
int  n 
)

MAGMA_Desc_Create - Create matrix descriptor.

Parameters:
[out]descOn exit, descriptor of the matrix.
[in]matMemory location of the matrix.
[in]dtypData type of the matrix:
  • MagmaRealFloat: single precision real (S),
  • MagmaRealDouble: double precision real (D),
  • MagmaComplexFloat: single precision complex (C),
  • MagmaComplexDouble: double precision complex (Z).
[in]mbNumber of rows in a tile.
[in]nbNumber of columns in a tile.
[in]bsizSize in bytes including padding.
[in]lmNumber of rows of the entire matrix.
[in]lnNumber of columns of the entire matrix.
[in]iRow index to the beginning of the submatrix.
[in]jColumn indes to the beginning of the submatrix.
[in]mNumber of rows of the submatrix.
[in]nNumber of columns of the submatrix.
Returns:
Return values:
MAGMA_SUCCESSsuccessful exit

Definition at line 211 of file descriptor.c.

References magma_context_self(), magma_desc_check(), magma_desc_init(), MAGMA_ERR_NOT_INITIALIZED, MAGMA_ERR_OUT_OF_RESOURCES, magma_error, MAGMA_SUCCESS, and morse_desc_create().

{
int status;
magma = magma_context_self();
if (magma == NULL) {
magma_error("MAGMA_Desc_Create", "MAGMA not initialized");
}
/* Allocate memory and initialize the descriptor */
*desc = (magma_desc_t*)malloc(sizeof(magma_desc_t));
if (*desc == NULL) {
magma_error("MAGMA_Desc_Create", "malloc() failed");
}
**desc = magma_desc_init(dtyp, mb, nb, bsiz, lm, ln, i, j, m, n);
(**desc).desc.mat = mat;
/* Create scheduler structure like registering data */
status = magma_desc_check(*desc);
if (status != MAGMA_SUCCESS) {
magma_error("MAGMA_Desc_Create", "invalid descriptor");
return status;
}
return MAGMA_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int MAGMA_Desc_Destroy ( magma_desc_t **  desc)

MAGMA_Desc_Destroy - Destroys matrix descriptor.

Parameters:
[in]descMatrix descriptor.
Returns:
Return values:
MAGMA_SUCCESSsuccessful exit

Definition at line 260 of file descriptor.c.

References magma_context_self(), MAGMA_ERR_NOT_INITIALIZED, MAGMA_ERR_UNALLOCATED, magma_error, MAGMA_SUCCESS, and morse_desc_destroy().

{
magma = magma_context_self();
if (magma == NULL) {
magma_error("MAGMA_Desc_Destroy", "MAGMA not initialized");
}
if (*desc == NULL) {
magma_error("MAGMA_Desc_Destroy", "attempting to destroy a NULL descriptor");
}
/* Clean at scheduler level like unregistering data */
free(*desc);
*desc = NULL;
return MAGMA_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

magma_desc_t magma_desc_init ( MAGMA_enum  dtyp,
int  mb,
int  nb,
int  bsiz,
int  lm,
int  ln,
int  i,
int  j,
int  m,
int  n 
)

Internal static descriptor initializer

Definition at line 20 of file descriptor.c.

References magma_desc_s::desc, morse_desc_init(), and magma_desc_s::occurences.

{
PLASMA_desc *pdesc = &(desc.desc);
// Matrix address
pdesc->mat = NULL;
pdesc->A21 = (lm - lm%mb)*(ln - ln%nb);
pdesc->A12 = ( lm%mb)*(ln - ln%nb) + pdesc->A21;
pdesc->A22 = (lm - lm%mb)*( ln%nb) + pdesc->A12;
// Matrix properties
pdesc->dtyp = dtyp;
pdesc->mb = mb;
pdesc->nb = nb;
pdesc->bsiz = bsiz;
// Large matrix parameters
pdesc->lm = lm;
pdesc->ln = ln;
// Large matrix derived parameters
pdesc->lm1 = (lm/mb);
pdesc->ln1 = (ln/nb);
pdesc->lmt = (lm%mb==0) ? (lm/mb) : (lm/mb+1);
pdesc->lnt = (ln%nb==0) ? (ln/nb) : (ln/nb+1);
// Submatrix parameters
pdesc->i = i;
pdesc->j = j;
pdesc->m = m;
pdesc->n = n;
// Submatrix derived parameters
pdesc->mt = (i+m-1)/mb - i/mb + 1;
pdesc->nt = (j+n-1)/nb - j/nb + 1;
desc.occurences = 0;
morse_desc_init( &desc );
return desc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int magma_desc_mat_alloc ( magma_desc_t desc)

Definition at line 127 of file descriptor.c.

References magma_desc_s::desc, MAGMA_ERR_OUT_OF_RESOURCES, magma_error, MAGMA_SUCCESS, morse_desc_create(), and plasma_element_size().

{
size_t size;
size = (size_t)desc->desc.lm * (size_t)desc->desc.ln * (size_t)plasma_element_size(desc->desc.dtyp);
if ((desc->desc.mat = malloc(size)) == NULL) {
magma_error("magma_desc_mat_alloc", "malloc() failed");
}
return MAGMA_SUCCESS;
}

Here is the call graph for this function:

int magma_desc_mat_free ( magma_desc_t desc)

Definition at line 145 of file descriptor.c.

References magma_desc_s::desc, MAGMA_SUCCESS, and morse_desc_destroy().

{
if (desc->desc.mat != NULL) {
free(desc->desc.mat);
desc->desc.mat = NULL;
}
return MAGMA_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

magma_desc_t magma_desc_submatrix ( magma_desc_t  descA,
int  i,
int  j,
int  m,
int  n 
)

Internal static descriptor initializer for submatrices

Definition at line 62 of file descriptor.c.

References magma_desc_s::desc, and morse_desc_submatrix().

{
magma_desc_t descB;
PLASMA_desc *pdescB = &(descB.desc);
int mb, nb;
descB = descA;
mb = descA.desc.mb;
nb = descA.desc.nb;
// Submatrix parameters
pdescB->i = i;
pdescB->j = j;
pdescB->m = m;
pdescB->n = n;
// Submatrix derived parameters
pdescB->mt = (i+m-1)/mb - i/mb + 1;
pdescB->nt = (j+n-1)/nb - j/nb + 1;
return descB;
}

Here is the call graph for this function: