PLASMA 2.3.1

/home/mathieu/ICL/Plasma/svn/trunk/tools/plasma_2.4.0/control/context.h

00001 
00014 #ifndef _PLASMA_CONTEXT_H_
00015 #define _PLASMA_CONTEXT_H_
00016 
00017 #include <stdio.h>
00018 #include "quark.h"
00019 
00020 struct plasma_context_struct;
00021 
00022 /***************************************************************************/
00025 typedef struct plasma_context_struct {
00026     /* Initialization flag */
00027     PLASMA_bool initialized;
00028 
00029     /* Thread control */
00030     int world_size, group_size;
00031     int thread_bind[CONTEXT_THREADS_MAX];
00032     int thread_rank[CONTEXT_THREADS_MAX];
00033     pthread_attr_t thread_attr;
00034     pthread_t thread_id[CONTEXT_THREADS_MAX];
00035 
00036     /* Master-worker communication */
00037     pthread_mutex_t action_mutex;
00038     pthread_cond_t action_condt;
00039     volatile PLASMA_enum action;
00040     void (*parallel_func_ptr)(struct plasma_context_struct*);
00041     unsigned char args_buff[ARGS_BUFF_SIZE];
00042 
00043     /* Boolean flags */
00044     PLASMA_bool errors_enabled;
00045     PLASMA_bool warnings_enabled;
00046     PLASMA_bool autotuning_enabled;
00047     PLASMA_bool dynamic_section;
00048 
00049     /* Enum flags */
00050     PLASMA_enum scheduling;     // static or dynamic scheduling
00051     PLASMA_enum householder;    // "domino" (flat) or tree-based (reduction) Householder
00052     PLASMA_enum translation;    // In place or Out of place layout conversion
00053 
00054     /* Matrix tile attributes */
00055     int nb;
00056     int ib;
00057     int nbnbsize;   // tile size in elements (possibly padded)
00058     int ibnbsize;   // T or L tile size in elements (---''---)
00059     int rhblock;    // block size for tree-based (reduction) Householder
00060 
00061     /* Barrier implementation */
00062 #ifdef BUSY_WAITING
00063     volatile int barrier_in[CONTEXT_THREADS_MAX];
00064     volatile int barrier_out[CONTEXT_THREADS_MAX];
00065 #else
00066     int volatile    barrier_id;             /*+ ID of the barrier                     +*/
00067     int volatile    barrier_nblocked_thrds; /*+ Number of threads lock in the barrier +*/
00068     pthread_mutex_t barrier_synclock;       /*+ mutex for the barrier                 +*/
00069     pthread_cond_t  barrier_synccond;       /*+ condition for the barrier             +*/
00070 #endif
00071 
00072     /* Static scheduler implementation */
00073     int ss_ld;                  // static scheduler progress table leading dimension
00074     volatile int ss_abort;      // static scheduler abort flag
00075     volatile int *ss_progress;  // static scheduler progress table
00076 
00077     /* Dynamic scheduler */
00078     Quark *quark;
00079 } plasma_context_t;
00080 
00081 /***************************************************************************/
00084 typedef struct plasma_context_map_struct {
00085     pthread_t thread_id;        // thread id
00086     plasma_context_t *context;  // pointer to associated context
00087 } plasma_context_map_t;
00088 
00089 #ifdef __cplusplus
00090 extern "C" {
00091 #endif
00092 
00093 /***************************************************************************/
00096 plasma_context_t *plasma_context_create();
00097 int plasma_context_insert(plasma_context_t *context, pthread_t thread_id);
00098 int plasma_context_remove(plasma_context_t *context, pthread_t thread_id);
00099 plasma_context_t *plasma_context_self();
00100 
00101 #ifdef __cplusplus
00102 }
00103 #endif
00104 
00105 #endif
 All Data Structures