PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
context.c File Reference
#include <stdlib.h>
#include <pthread.h>
#include "common.h"
#include "auxiliary.h"
#include "context.h"
Include dependency graph for context.c:

Go to the source code of this file.

Functions

plasma_context_tplasma_context_create ()
int plasma_context_insert (plasma_context_t *context, pthread_t thread_id)
int plasma_context_remove (plasma_context_t *context, pthread_t thread_id)
plasma_context_tplasma_context_self ()
int PLASMA_Enable (PLASMA_enum lever)
int PLASMA_Disable (PLASMA_enum lever)
int PLASMA_Set (PLASMA_enum param, int value)
int PLASMA_Get (PLASMA_enum param, int *value)

Variables

plasma_context_map_t context_map [CONTEXTS_MAX]
pthread_mutex_t context_map_lock = PTHREAD_MUTEX_INITIALIZER

Detailed Description

PLASMA auxiliary routines PLASMA is a software package provided by Univ. of Tennessee, Univ. of California Berkeley and Univ. of Colorado Denver

Version:
2.4.5
Author:
Jakub Kurzak
Date:
2010-11-15

Definition in file context.c.


Function Documentation

plasma_context_t* plasma_context_create ( )

Create new context

Definition at line 36 of file context.c.

References plasma_context_struct::action, plasma_context_struct::action_condt, plasma_context_struct::action_mutex, plasma_context_struct::autotuning_enabled, context_map_lock, plasma_context_struct::dynamic_section, plasma_context_struct::errors_enabled, plasma_context_struct::householder, plasma_context_struct::ib, plasma_context_struct::ibnbsize, plasma_context_struct::nb, plasma_context_struct::nbnbsize, plasma_context_struct::parallel_func_ptr, PLASMA_ACT_STAND_BY, PLASMA_FALSE, plasma_fatal_error(), PLASMA_FLAT_HOUSEHOLDER, PLASMA_OUTOFPLACE, PLASMA_STATIC_SCHEDULING, PLASMA_TRUE, pthread_cond_init(), pthread_mutex_init(), plasma_context_struct::rhblock, plasma_context_struct::scheduling, plasma_context_struct::translation, and plasma_context_struct::warnings_enabled.

{
plasma = (plasma_context_t*)malloc(sizeof(plasma_context_t));
if (plasma == NULL) {
plasma_fatal_error("plasma_context_create", "malloc() failed");
return NULL;
}
plasma->parallel_func_ptr = NULL;
/* These initializations are just in case the user
disables autotuning and does not set nb and ib */
plasma->nb = 128;
plasma->ib = 32;
plasma->nbnbsize = 16384;
plasma->ibnbsize = 4096;
plasma->rhblock = 4;
return plasma;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int plasma_context_insert ( plasma_context_t context,
pthread_t  thread_id 
)

Insert a (context, thread_id) tuple in the context map

Definition at line 75 of file context.c.

References plasma_context_map_struct::context, context_map_lock, CONTEXTS_MAX, PLASMA_ERR_INTERNAL_LIMIT, plasma_fatal_error(), PLASMA_SUCCESS, pthread_mutex_lock(), pthread_mutex_unlock(), and plasma_context_map_struct::thread_id.

{
int i;
// acquire the access lock
// For each entry
for (i = 0; i < CONTEXTS_MAX; i++) {
// If not occupied
if (context_map[i].context == NULL) {
// Insert new context, release lock, return success
context_map[i].context = context;
context_map[i].thread_id = thread_id;
}
}
// No empty entry found - release lock, return error
plasma_fatal_error("plasma_context_insert", "too many threads");
}

Here is the call graph for this function:

Here is the caller graph for this function:

int plasma_context_remove ( plasma_context_t context,
pthread_t  thread_id 
)

Remove a (context, thread_id) tuple from the context map

Definition at line 101 of file context.c.

References plasma_context_map_struct::context, context_map_lock, CONTEXTS_MAX, PLASMA_ERR_NOT_FOUND, PLASMA_ERR_UNEXPECTED, plasma_fatal_error(), PLASMA_SUCCESS, pthread_equal(), pthread_mutex_lock(), and pthread_mutex_unlock().

{
int i;
// acquire the access lock
// For each entry
for (i = 0; i < CONTEXTS_MAX; i++) {
// If id matches
if (pthread_equal(context_map[i].thread_id, thread_id)) {
if (context_map[i].context == context) {
// Free the context, mark entry as empty, release lock, return success
free(context_map[i].context);
context_map[i].context = NULL;
}
else {
plasma_fatal_error("plasma_context_remove", "context does not match thread");
}
}
}
// No matching id found - release lock, return error
plasma_fatal_error("plasma_context_remove", "thread not found");
}

Here is the call graph for this function:

Here is the caller graph for this function:

plasma_context_t* plasma_context_self ( void  )

Return context for a thread

Definition at line 134 of file context.c.

References plasma_context_map_struct::context, CONTEXTS_MAX, pthread_equal(), and pthread_self().

{
int i;
// For each entry
for (i = 0; i < CONTEXTS_MAX; i++) {
// If id matches
if (pthread_equal(context_map[i].thread_id, pthread_self())) {
return context_map[i].context;
}
}
return NULL;
}

Here is the call graph for this function:

int PLASMA_Disable ( PLASMA_enum  lever)

PLASMA_Disable - Disable PLASMA feature.

Parameters:
[in]leverFeature to be disabled:
  • PLASMA_WARNINGS printing of warning messages,
  • PLASMA_ERRORS printing of error messages,
  • PLASMA_AUTOTUNING autotuning for tile size and inner block size,
  • PLASMA_DAG Quark automatic DAG generation.
Returns:
Return values:
PLASMA_SUCCESSsuccessful exit

Definition at line 222 of file context.c.

References plasma_context_struct::autotuning_enabled, plasma_context_struct::errors_enabled, PLASMA_AUTOTUNING, plasma_context_self(), PLASMA_DAG, PLASMA_ERR_ILLEGAL_VALUE, PLASMA_ERR_NOT_INITIALIZED, plasma_error(), PLASMA_ERRORS, PLASMA_FALSE, plasma_fatal_error(), PLASMA_SUCCESS, PLASMA_WARNINGS, plasma_context_struct::quark, QUARK_Barrier(), QUARK_DOT_DAG_Enable(), and plasma_context_struct::warnings_enabled.

{
plasma = plasma_context_self();
if (plasma == NULL) {
plasma_fatal_error("PLASMA_Disable", "PLASMA not initialized");
}
switch (lever)
{
break;
break;
break;
case PLASMA_DAG:
QUARK_Barrier(plasma->quark);
break;
default:
plasma_error("PLASMA_Disable", "illegal parameter value");
}
}

Here is the call graph for this function:

Here is the caller graph for this function:

int PLASMA_Enable ( PLASMA_enum  lever)

PLASMA_Enable - Enable PLASMA feature.

Parameters:
[in]leverFeature to be enabled:
  • PLASMA_WARNINGS printing of warning messages,
  • PLASMA_ERRORS printing of error messages,
  • PLASMA_AUTOTUNING autotuning for tile size and inner block size,
  • PLASMA_DAG Quark automatic DAG generation.
Returns:
Return values:
PLASMA_SUCCESSsuccessful exit

Definition at line 169 of file context.c.

References plasma_context_struct::autotuning_enabled, plasma_context_struct::errors_enabled, PLASMA_AUTOTUNING, plasma_context_self(), PLASMA_DAG, PLASMA_ERR_ILLEGAL_VALUE, PLASMA_ERR_NOT_INITIALIZED, plasma_error(), PLASMA_ERRORS, plasma_fatal_error(), PLASMA_SUCCESS, PLASMA_TRUE, PLASMA_WARNINGS, plasma_context_struct::quark, QUARK_Barrier(), QUARK_DOT_DAG_Enable(), and plasma_context_struct::warnings_enabled.

{
plasma = plasma_context_self();
if (plasma == NULL) {
plasma_fatal_error("PLASMA_Enable", "PLASMA not initialized");
}
switch (lever)
{
break;
break;
break;
case PLASMA_DAG:
QUARK_Barrier(plasma->quark);
break;
default:
plasma_error("PLASMA_Enable", "illegal parameter value");
}
}

Here is the call graph for this function:

Here is the caller graph for this function:

int PLASMA_Get ( PLASMA_enum  param,
int *  value 
)

PLASMA_Get - Get value of PLASMA parameter.

Parameters:
[in]paramFeature to be enabled:
  • PLASMA_TILE_SIZE: size matrix tile,
  • PLASMA_INNER_BLOCK_SIZE: size of tile inner block,
  • PLASMA_SCHEDULING: type of scheduling (PLASMA_STATIC_SCHEDULING or PLASMA_DYNAMIC_SCHEDULING).
[out]valueValue of the parameter.
Returns:
Return values:
PLASMA_SUCCESSsuccessful exit

Definition at line 391 of file context.c.

References plasma_context_struct::householder, plasma_context_struct::ib, plasma_context_struct::nb, plasma_context_self(), PLASMA_ERR_ILLEGAL_VALUE, PLASMA_ERR_NOT_INITIALIZED, plasma_error(), plasma_fatal_error(), PLASMA_HOUSEHOLDER_MODE, PLASMA_HOUSEHOLDER_SIZE, PLASMA_INNER_BLOCK_SIZE, PLASMA_SCHEDULING_MODE, PLASMA_SUCCESS, PLASMA_TILE_SIZE, PLASMA_TRANSLATION_MODE, plasma_context_struct::rhblock, plasma_context_struct::scheduling, and plasma_context_struct::translation.

{
plasma = plasma_context_self();
if (plasma == NULL) {
plasma_fatal_error("PLASMA_Get", "PLASMA not initialized");
}
switch (param) {
*value = plasma->nb;
*value = plasma->ib;
*value = plasma->scheduling;
*value = plasma->householder;
*value = plasma->rhblock;
*value = plasma->translation;
default:
plasma_error("PLASMA_Get", "unknown parameter");
}
}

Here is the call graph for this function:

Here is the caller graph for this function:

int PLASMA_Set ( PLASMA_enum  param,
int  value 
)

PLASMA_Set - Set PLASMA parameter.

Parameters:
[in]paramFeature to be enabled:
  • PLASMA_TILE_SIZE: size matrix tile,
  • PLASMA_INNER_BLOCK_SIZE: size of tile inner block,
  • PLASMA_SCHEDULING_MODE: type of scheduling (PLASMA_STATIC_SCHEDULING or PLASMA_DYNAMIC_SCHEDULING).
  • PLASMA_INNER_BANDWIDTH: matrix bandwidth size
[in]valueValue of the parameter.
Returns:
Return values:
PLASMA_SUCCESSsuccessful exit

Definition at line 278 of file context.c.

References plasma_context_struct::autotuning_enabled, plasma_context_struct::householder, plasma_context_struct::ib, plasma_context_struct::ibnbsize, min, plasma_context_struct::nb, plasma_context_struct::nbnbsize, plasma_context_self(), PLASMA_DYNAMIC_SCHEDULING, PLASMA_ERR_ILLEGAL_VALUE, PLASMA_ERR_NOT_INITIALIZED, plasma_error(), PLASMA_FALSE, PLASMA_FLAT_HOUSEHOLDER, PLASMA_HOUSEHOLDER_MODE, PLASMA_HOUSEHOLDER_SIZE, PLASMA_INNER_BLOCK_SIZE, PLASMA_INPLACE, PLASMA_OUTOFPLACE, PLASMA_SCHEDULING_MODE, PLASMA_STATIC_SCHEDULING, PLASMA_SUCCESS, PLASMA_TILE_SIZE, PLASMA_TRANSLATION_MODE, PLASMA_TREE_HOUSEHOLDER, plasma_warning(), plasma_context_struct::rhblock, plasma_context_struct::scheduling, and plasma_context_struct::translation.

{
plasma = plasma_context_self();
if (plasma == NULL) {
plasma_error("PLASMA_Set", "PLASMA not initialized");
}
switch (param) {
if (value <= 0) {
plasma_error("PLASMA_Set", "negative tile size");
}
plasma->nb = value;
/* Calculate A, B tile size and round up to cache line size */
/* round up for the smallest type (float) - will hold for all */
plasma->nbnbsize = plasma->nb * plasma->nb; // * sizeof(float);
plasma->ibnbsize = plasma->ib * plasma->nb; // * sizeof(float);
// plasma->nbnbsize = roundup(plasma->nbnbsize, CACHE_LINE_SIZE);
// plasma->nbnbsize /= sizeof(float);
if ( plasma->autotuning_enabled ) {
plasma_warning("PLASMA_Set", "autotuning has been automatically disabled\n");
}
/* Limit ib to nb */
plasma->ib = min( plasma->nb, plasma->ib );
break;
if (value <= 0) {
plasma_error("PLASMA_Set", "negative inner block size");
}
if (value > plasma->nb) {
plasma_error("PLASMA_Set", "inner block larger than tile");
}
/* if (plasma->nb % value != 0) { */
/* plasma_error("PLASMA_Set", "inner block does not divide tile"); */
/* return PLASMA_ERR_ILLEGAL_VALUE; */
/* } */
plasma->ib = value;
/* Calculate T, L tile size and round up to cache line size */
/* round up for the smallest type (float) - will hold for all */
plasma->ibnbsize = plasma->ib * plasma->nb; // * sizeof(float);
// plasma->ibnbsize = roundup(plasma->ibnbsize, CACHE_LINE_SIZE);
// plasma->ibnbsize /= sizeof(float);
if ( plasma->autotuning_enabled ) {
plasma_warning("PLASMA_Set", "autotuning has been automatically disabled\n");
}
break;
plasma_error("PLASMA_Set", "illegal value of PLASMA_SCHEDULING_MODE");
}
plasma->scheduling = value;
break;
plasma_error("PLASMA_Set", "illegal value of PLASMA_HOUSEHOLDER_MODE");
}
plasma->householder = value;
break;
if (value <= 0) {
plasma_error("PLASMA_Set", "negative householder size");
}
plasma->rhblock = value;
break;
if (value != PLASMA_INPLACE && value != PLASMA_OUTOFPLACE) {
plasma_error("PLASMA_Set", "illegal value of PLASMA_TRANSLATION_MODE");
}
plasma->translation = value;
break;
default:
plasma_error("PLASMA_Set", "unknown parameter");
}
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Global data

Definition at line 29 of file context.c.

Definition at line 31 of file context.c.