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

Go to the source code of this file.

Functions

magma_context_tmagma_context_create ()
magma_context_tmagma_context_self ()
int magma_context_destroy ()
int MAGMA_Enable (MAGMA_enum option)
int MAGMA_Disable (MAGMA_enum option)
int MAGMA_Set (MAGMA_enum param, int value)
int MAGMA_Get (MAGMA_enum param, int *value)

Variables

static magma_context_tmagma_ctxt = NULL

Function Documentation

magma_context_t* magma_context_create ( )

Create new context

Definition at line 28 of file context.c.

References magma_context_s::autotuning_enabled, magma_context_s::errors_enabled, magma_context_s::householder, magma_context_s::ib, magma_error, MAGMA_FALSE, MAGMA_FLAT_HOUSEHOLDER, MAGMA_OUTOFPLACE, MAGMA_SCHED_QUARK, MAGMA_TRUE, morse_context_create(), magma_context_s::nb, magma_context_s::ncudas, magma_context_s::nthreads_per_worker, magma_context_s::nworkers, magma_context_s::parallel_enabled, magma_context_s::profiling_enabled, magma_context_s::rhblock, magma_context_s::scheduler, magma_context_s::translation, and magma_context_s::warnings_enabled.

{
if ( magma_ctxt != NULL ) {
magma_error("magma_context_create", "a context is already existing\n");
return NULL;
}
magma = (magma_context_t*)malloc(sizeof(magma_context_t));
if (magma == NULL) {
magma_error("magma_context_create", "malloc() failed");
return NULL;
}
magma->nworkers = 1;
magma->ncudas = 0;
/* These initializations are just in case the user
disables autotuning and does not set nb and ib */
magma->nb = 128;
magma->ib = 32;
magma->rhblock = 4;
/* Initialize scheduler */
magma_ctxt = magma;
return magma;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int magma_context_destroy ( )

Clean the context

Definition at line 83 of file context.c.

References MAGMA_SUCCESS, and morse_context_destroy().

Here is the call graph for this function:

Here is the caller graph for this function:

magma_context_t* magma_context_self ( )

Return context for a thread

Definition at line 74 of file context.c.

References magma_ctxt.

{
return magma_ctxt;
}
int MAGMA_Disable ( MAGMA_enum  option)

MAGMA_Disable - Disable MAGMA feature.

Parameters:
[in]leverFeature to be disabled:
  • MAGMA_WARNINGS printing of warning messages,
  • MAGMA_ERRORS printing of error messages,
  • MAGMA_AUTOTUNING autotuning for tile size and inner block size.
  • MAGMA_PROFILING_MODE activate profiling of kernels
Returns:
Return values:
MAGMA_SUCCESSsuccessful exit

Definition at line 172 of file context.c.

References magma_context_s::autotuning_enabled, magma_context_s::errors_enabled, MAGMA_AUTOTUNING, magma_context_self(), MAGMA_ERR_ILLEGAL_VALUE, MAGMA_ERR_NOT_INITIALIZED, magma_error, MAGMA_ERRORS, MAGMA_FALSE, MAGMA_PARALLEL_MODE, MAGMA_PROFILING_MODE, MAGMA_SUCCESS, MAGMA_WARNINGS, morse_disable(), magma_context_s::parallel_enabled, magma_context_s::profiling_enabled, and magma_context_s::warnings_enabled.

{
magma = magma_context_self();
if (magma == NULL) {
magma_error("MAGMA_Disable", "MAGMA not initialized");
}
switch ( option )
{
break;
break;
break;
break;
break;
default:
magma_error("MAGMA_Disable", "illegal parameter value");
}
/* Disable at the lower level if required */
morse_disable( magma, option );
return MAGMA_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int MAGMA_Enable ( MAGMA_enum  option)

MAGMA_Enable - Enable MAGMA feature.

Parameters:
[in]leverFeature to be enabled:
  • MAGMA_WARNINGS printing of warning messages,
  • MAGMA_ERRORS printing of error messages,
  • MAGMA_AUTOTUNING autotuning for tile size and inner block size.
  • MAGMA_PROFILING_MODE activate profiling of kernels
Returns:
Return values:
MAGMA_SUCCESSsuccessful exit

Definition at line 113 of file context.c.

References magma_context_s::autotuning_enabled, magma_context_s::errors_enabled, MAGMA_AUTOTUNING, magma_context_self(), MAGMA_ERR_ILLEGAL_VALUE, MAGMA_ERR_NOT_INITIALIZED, magma_error, MAGMA_ERRORS, MAGMA_PROFILING_MODE, MAGMA_SUCCESS, MAGMA_TRUE, MAGMA_WARNINGS, morse_enable(), magma_context_s::profiling_enabled, and magma_context_s::warnings_enabled.

{
magma = magma_context_self();
if (magma == NULL) {
magma_error("MAGMA_Enable", "MAGMA not initialized");
}
switch (option)
{
break;
break;
break;
break;
/* case MAGMA_PARALLEL: */
/* magma->parallel_enabled = MAGMA_TRUE; */
/* break; */
default:
magma_error("MAGMA_Enable", "illegal parameter value");
}
/* Enable at the lower level if required */
morse_enable( magma, option );
return MAGMA_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int MAGMA_Get ( MAGMA_enum  param,
int *  value 
)

MAGMA_Get - Get value of MAGMA parameter.

Parameters:
[in]paramFeature to be enabled:
  • MAGMA_TILE_SIZE: size matrix tile,
  • MAGMA_INNER_BLOCK_SIZE: size of tile inner block,
[out]valueValue of the parameter.
Returns:
Return values:
MAGMA_SUCCESSsuccessful exit

Definition at line 325 of file context.c.

References magma_context_s::householder, magma_context_s::ib, magma_context_self(), MAGMA_ERR_ILLEGAL_VALUE, MAGMA_ERR_NOT_INITIALIZED, magma_error, MAGMA_HOUSEHOLDER_MODE, MAGMA_HOUSEHOLDER_SIZE, MAGMA_INNER_BLOCK_SIZE, MAGMA_SUCCESS, MAGMA_TILE_SIZE, MAGMA_TRANSLATION_MODE, magma_context_s::nb, magma_context_s::rhblock, and magma_context_s::translation.

{
magma = magma_context_self();
if (magma == NULL) {
magma_error("MAGMA_Get", "MAGMA not initialized");
}
switch (param) {
*value = magma->nb;
return MAGMA_SUCCESS;
*value = magma->ib;
return MAGMA_SUCCESS;
*value = magma->householder;
return MAGMA_SUCCESS;
*value = magma->rhblock;
return MAGMA_SUCCESS;
*value = magma->translation;
return MAGMA_SUCCESS;
default:
magma_error("MAGMA_Get", "unknown parameter");
}
return MAGMA_SUCCESS;
}

Here is the call graph for this function:

int MAGMA_Set ( MAGMA_enum  param,
int  value 
)

MAGMA_Set - Set MAGMA parameter.

Parameters:
[in]paramFeature to be enabled:
  • MAGMA_TILE_SIZE: size matrix tile,
  • MAGMA_INNER_BLOCK_SIZE: size of tile inner block,
[in]valueValue of the parameter.
Returns:
Return values:
MAGMA_SUCCESSsuccessful exit

Definition at line 231 of file context.c.

References magma_context_s::autotuning_enabled, magma_context_s::householder, magma_context_s::ib, magma_context_self(), MAGMA_ERR_ILLEGAL_VALUE, MAGMA_ERR_NOT_INITIALIZED, magma_error, MAGMA_FALSE, MAGMA_FLAT_HOUSEHOLDER, MAGMA_HOUSEHOLDER_MODE, MAGMA_HOUSEHOLDER_SIZE, MAGMA_INNER_BLOCK_SIZE, MAGMA_INPLACE, MAGMA_OUTOFPLACE, MAGMA_SUCCESS, MAGMA_TILE_SIZE, MAGMA_TRANSLATION_MODE, MAGMA_TREE_HOUSEHOLDER, magma_warning, min, magma_context_s::nb, magma_context_s::rhblock, and magma_context_s::translation.

{
magma = magma_context_self();
if (magma == NULL) {
magma_error("MAGMA_Set", "MAGMA not initialized");
}
switch (param) {
if (value <= 0) {
magma_error("MAGMA_Set", "negative tile size");
}
magma->nb = value;
if ( magma->autotuning_enabled ) {
magma_warning("MAGMA_Set", "autotuning has been automatically disable\n");
}
/* Limit ib to nb */
magma->ib = min( magma->nb, magma->ib );
break;
if (value <= 0) {
magma_error("MAGMA_Set", "negative inner block size");
}
if (value > magma->nb) {
magma_error("MAGMA_Set", "inner block larger than tile");
}
/* if (magma->nb % value != 0) { */
/* magma_error("MAGMA_Set", "inner block does not divide tile"); */
/* return MAGMA_ERR_ILLEGAL_VALUE; */
/* } */
magma->ib = value;
if ( magma->autotuning_enabled ) {
magma_warning("MAGMA_Set", "autotuning has been automatically disable\n");
}
break;
if (value != MAGMA_FLAT_HOUSEHOLDER && value != MAGMA_TREE_HOUSEHOLDER) {
magma_error("MAGMA_Set", "illegal value of MAGMA_HOUSEHOLDER_MODE");
}
magma->householder = value;
break;
if (value <= 0) {
magma_error("MAGMA_Set", "negative householder size");
}
magma->rhblock = value;
break;
if (value != MAGMA_INPLACE && value != MAGMA_OUTOFPLACE) {
magma_error("MAGMA_Set", "illegal value of MAGMA_TRANSLATION_MODE");
}
magma->translation = value;
break;
default:
magma_error("MAGMA_Set", "unknown parameter");
}
return MAGMA_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

magma_context_t* magma_ctxt = NULL
static

Global data

Definition at line 23 of file context.c.