libflame revision_anchor
FLA_type_defs.h
Go to the documentation of this file.
00001 /*
00002    libflame
00003    An object-based infrastructure for developing high-performance
00004    dense linear algebra libraries.
00005 
00006    Copyright (C) 2011, The University of Texas
00007 
00008    libflame is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU Lesser General Public License as
00010    published by the Free Software Foundation; either version 2.1 of
00011    the License, or (at your option) any later version.
00012 
00013    libflame is distributed in the hope that it will be useful, but
00014    WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016    Lesser General Public License for more details.
00017 
00018    You should have received a copy of the GNU Lesser General Public
00019    License along with libflame; if you did not receive a copy, see
00020    http://www.gnu.org/licenses/.
00021 
00022    For more information, please contact us at flame@cs.utexas.edu or
00023    send mail to:
00024 
00025    Field G. Van Zee and/or
00026    Robert A. van de Geijn
00027    The University of Texas at Austin
00028    Department of Computer Sciences
00029    1 University Station C0500
00030    Austin TX 78712
00031 */
00032 
00033 #ifndef FLA_TYPE_DEFS_H
00034 #define FLA_TYPE_DEFS_H
00035 
00036 #if   FLA_MULTITHREADING_MODEL == FLA_OPENMP
00037 #include <omp.h>
00038 #elif FLA_MULTITHREADING_MODEL == FLA_PTHREADS
00039 #include <pthread.h>
00040 #endif
00041 
00042 
00043 // --- Complex type definitions -----------------------------------------------
00044 
00045 typedef struct scomplex
00046 {
00047   float real, imag;
00048 } scomplex;
00049 
00050 typedef struct dcomplex
00051 {
00052   double real, imag;
00053 } dcomplex;
00054 
00055 
00056 // --- Parameter and return type definitions ----------------------------------
00057 
00058 typedef int FLA_Bool;
00059 typedef int FLA_Error;
00060 typedef int FLA_Quadrant;
00061 typedef int FLA_Datatype;
00062 typedef int FLA_Elemtype;
00063 typedef int FLA_Side;
00064 typedef int FLA_Uplo;
00065 typedef int FLA_Trans;
00066 typedef int FLA_Conj;
00067 typedef int FLA_Diag;
00068 typedef int FLA_Dimension;
00069 typedef int FLA_Pivot_type;
00070 typedef int FLA_Direct;
00071 typedef int FLA_Store;
00072 typedef int FLA_Matrix_type;
00073 typedef int FLA_Precision;
00074 typedef int FLA_Domain;
00075 typedef int FLA_Inv;
00076 typedef int FLA_Evd_type;
00077 typedef int FLA_Svd_type;
00078 typedef unsigned int dim_t;
00079 
00080 // --- FLAME object definitions -----------------------------------------------
00081 
00082 typedef struct FLA_Lock_s     FLA_Lock;
00083 
00084 //#ifdef FLA_ENABLE_MULTITHREADING
00085 struct FLA_Lock_s
00086 {
00087   // Implementation-specific lock object
00088 #if   FLA_MULTITHREADING_MODEL == FLA_OPENMP
00089   omp_lock_t       lock;
00090 #elif FLA_MULTITHREADING_MODEL == FLA_PTHREADS
00091   pthread_mutex_t  lock;
00092 #endif
00093 };
00094 //#endif
00095 
00096 #ifdef FLA_ENABLE_SUPERMATRIX
00097 typedef int                   FLASH_Verbose;
00098 typedef int                   FLASH_Data_aff;
00099 
00100 typedef struct FLASH_Queue_s  FLASH_Queue;
00101 typedef struct FLASH_Task_s   FLASH_Task;
00102 typedef struct FLASH_Dep_s    FLASH_Dep;
00103 #endif
00104 typedef struct FLASH_Thread_s FLASH_Thread;
00105 
00106 typedef struct FLA_Obj_struct
00107 {
00108   // Basic object description fields
00109   FLA_Datatype  datatype;
00110   FLA_Elemtype  elemtype;
00111   dim_t         m;
00112   dim_t         n;
00113   dim_t         rs;
00114   dim_t         cs;
00115   dim_t         m_inner;
00116   dim_t         n_inner;
00117   unsigned long id;
00118   dim_t         m_index;
00119   dim_t         n_index;
00120 
00121   dim_t         n_elem_alloc;
00122   void*         buffer;
00123 
00124 #ifdef FLA_ENABLE_SUPERMATRIX
00125   // Fields for supermatrix
00126   int           n_read_blocks;
00127   int           n_write_blocks;
00128 
00129   // All the tasks that previously read this block, anti-dependency
00130   int           n_read_tasks;
00131   FLASH_Dep*    read_task_head;
00132   FLASH_Dep*    read_task_tail;
00133 
00134   // Task that last overwrote this block, flow dependency
00135   FLASH_Task*   write_task;
00136 #endif
00137 } FLA_Base_obj;
00138 
00139 typedef struct FLA_Obj_view
00140 {
00141   // Basic object view description fields
00142   dim_t         offm;
00143   dim_t         offn;
00144   dim_t         m;
00145   dim_t         n;
00146   dim_t         m_inner;
00147   dim_t         n_inner;
00148 
00149   FLA_Base_obj* base;
00150 
00151 } FLA_Obj;
00152 
00153 #ifdef FLA_ENABLE_SUPERMATRIX
00154 struct FLASH_Queue_s
00155 {
00156   // Number of tasks currently in queue
00157   unsigned int  n_tasks;
00158 
00159   // Pointers to head (front) and tail (back) of queue
00160   FLASH_Task*   head;
00161   FLASH_Task*   tail;
00162 };
00163 
00164 struct FLASH_Task_s
00165 {
00166   // Execution information
00167   int           n_ready;
00168 
00169   // Labels
00170   int           order;
00171   int           queue;
00172   int           height;
00173   int           thread;
00174   int           cache;
00175   FLA_Bool      hit;
00176       
00177   // Function pointer
00178   void*         func;
00179 
00180   // Control tree pointer
00181   void*         cntl;
00182 
00183   // Name of task
00184   char*         name;
00185 
00186   // GPU enabled task
00187   FLA_Bool      enabled_gpu;
00188 
00189   // Integer arguments
00190   int           n_int_args;
00191   int*          int_arg;
00192 
00193   // Constant FLA_Obj arguments
00194   int           n_fla_args;
00195   FLA_Obj*      fla_arg;
00196 
00197   // Input FLA_Obj arguments
00198   int           n_input_args;
00199   FLA_Obj*      input_arg;
00200 
00201   // Output FLA_Obj argument
00202   int           n_output_args;
00203   FLA_Obj*      output_arg;
00204 
00205   // Number of blocks within all macroblocks
00206   int           n_macro_args;
00207 
00208   // Number of write after read dependencies
00209   int           n_war_args;
00210 
00211   // Dependence information
00212   int           n_dep_args;
00213   FLASH_Dep*    dep_arg_head;
00214   FLASH_Dep*    dep_arg_tail;
00215   
00216   // Support for a doubly linked list of tasks
00217   FLASH_Task*   prev_task;
00218   FLASH_Task*   next_task;
00219 
00220   // Support for a doubly linked list for wait queue
00221   FLASH_Task*   prev_wait;
00222   FLASH_Task*   next_wait;
00223 };
00224 
00225 struct FLASH_Dep_s
00226 {
00227   // Task yielding dependency
00228   FLASH_Task*   task;
00229 
00230   // Support for linked list of FLASH_Deps
00231   FLASH_Dep*    next_dep;
00232 };
00233 #endif // FLA_ENABLE_SUPERMATRIX
00234 
00235 struct FLASH_Thread_s
00236 {
00237   // The thread's unique identifier
00238   int       id;
00239 
00240   // Pointer to variables needed to execute SuperMatrix mechanism
00241   void*     args;
00242 
00243 #if FLA_MULTITHREADING_MODEL == FLA_PTHREADS
00244   // The thread object. Only needed for the POSIX threads implementation.
00245   pthread_t pthread_obj;
00246 #endif
00247 };
00248 
00249 #endif // FLA_TYPE_DEFS_H