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.h File Reference
#include <stdio.h>
#include "quark.h"
Include dependency graph for context.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  plasma_context_struct
struct  plasma_context_map_struct

Typedefs

typedef struct
plasma_context_struct 
plasma_context_t
typedef struct
plasma_context_map_struct 
plasma_context_map_t

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 ()

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.h.


Typedef Documentation

Threads contexts map

PLASMA context


Function Documentation

plasma_context_t* plasma_context_create ( )

Internal routines

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 ( )

Return context for a thread

Definition at line 134 of file context.c.

{
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;
}