00001 /* 00002 libflame 00003 An object-based infrastructure for developing high-performance 00004 dense linear algebra libraries. 00005 00006 Copyright (C) 2009, 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 unsigned int dim_t; 00076 00077 // --- FLAME object definitions ----------------------------------------------- 00078 00079 typedef struct FLA_Lock_s FLA_Lock; 00080 00081 //#ifdef FLA_ENABLE_MULTITHREADING 00082 struct FLA_Lock_s 00083 { 00084 // Implementation-specific lock object 00085 #if FLA_MULTITHREADING_MODEL == FLA_OPENMP 00086 omp_lock_t lock; 00087 #elif FLA_MULTITHREADING_MODEL == FLA_PTHREADS 00088 pthread_mutex_t lock; 00089 #endif 00090 }; 00091 //#endif 00092 00093 #ifdef FLA_ENABLE_SUPERMATRIX 00094 typedef int FLASH_Data_aff; 00095 00096 typedef struct FLASH_Queue_s FLASH_Queue; 00097 typedef struct FLASH_Task_s FLASH_Task; 00098 typedef struct FLASH_Dep_s FLASH_Dep; 00099 typedef struct FLASH_Thread_s FLASH_Thread; 00100 #endif 00101 00102 typedef struct FLA_Obj_struct 00103 { 00104 /* Basic object description fields */ 00105 FLA_Datatype datatype; 00106 FLA_Elemtype elemtype; 00107 dim_t m; 00108 dim_t n; 00109 dim_t ldim; 00110 dim_t m_inner; 00111 dim_t n_inner; 00112 unsigned long id; 00113 dim_t m_index; 00114 dim_t n_index; 00115 void* buffer; 00116 00117 #ifdef FLA_ENABLE_SUPERMATRIX 00118 /* Fields for supermatrix */ 00119 int n_read_blocks; 00120 int n_write_blocks; 00121 FLASH_Task* first_task; 00122 00123 // All the tasks that previously read this block, anti-dependency 00124 int n_read_tasks; 00125 FLASH_Dep* read_task_head; 00126 FLASH_Dep* read_task_tail; 00127 00128 // Task that last overwrote this block, flow dependency 00129 FLASH_Task* write_task; 00130 #endif 00131 } FLA_Base_obj; 00132 00133 typedef struct FLA_Obj_view 00134 { 00135 /* Basic object view description fields */ 00136 dim_t offm; 00137 dim_t offn; 00138 dim_t m; 00139 dim_t n; 00140 00141 FLA_Base_obj* base; 00142 00143 } FLA_Obj; 00144 00145 #ifdef FLA_ENABLE_SUPERMATRIX 00146 struct FLASH_Queue_s 00147 { 00148 // Number of tasks currently in queue 00149 int n_tasks; 00150 00151 // Pointers to head (front) and tail (back) of queue 00152 FLASH_Task* head; 00153 FLASH_Task* tail; 00154 }; 00155 00156 struct FLASH_Task_s 00157 { 00158 // Execution information 00159 int n_ready; 00160 00161 // Labels 00162 int order; 00163 int queue; 00164 int height; 00165 int thread; 00166 int cache; 00167 FLA_Bool hit; 00168 00169 // Function pointer 00170 void* func; 00171 00172 // Control tree pointer 00173 void* cntl; 00174 00175 // Name of task 00176 char* name; 00177 00178 // Integer arguments 00179 int n_int_args; 00180 int* int_arg; 00181 00182 // Constant FLA_Obj arguments 00183 int n_fla_args; 00184 FLA_Obj* fla_arg; 00185 00186 // Input FLA_Obj arguments 00187 int n_input_args; 00188 FLA_Obj* input_arg; 00189 00190 // Output FLA_Obj argument 00191 int n_output_args; 00192 FLA_Obj* output_arg; 00193 00194 // Number of write after read dependencies 00195 int n_war_args; 00196 00197 // Dependence information 00198 int n_dep_args; 00199 FLASH_Dep* dep_arg_head; 00200 FLASH_Dep* dep_arg_tail; 00201 00202 // Support for a doubly linked list of tasks 00203 FLASH_Task* prev_task; 00204 FLASH_Task* next_task; 00205 00206 // Support for a doubly linked list for wait queue 00207 FLASH_Task* prev_wait; 00208 FLASH_Task* next_wait; 00209 00210 #ifdef FLA_ENABLE_SUPERMATRIX_VISUALIZATION 00211 // Information about dynamic execution for visualization 00212 double begin_time; 00213 double end_time; 00214 #endif 00215 }; 00216 00217 struct FLASH_Dep_s 00218 { 00219 // Task yielding dependency 00220 FLASH_Task* task; 00221 00222 // Support for linked list of FLASH_Deps 00223 FLASH_Dep* next_dep; 00224 }; 00225 00226 struct FLASH_Thread_s 00227 { 00228 // The thread's unique identifier 00229 int id; 00230 00231 // Pointer to variables needed to execute SuperMatrix mechanism 00232 void* args; 00233 00234 #if FLA_MULTITHREADING_MODEL == FLA_PTHREADS 00235 // The thread object. Only needed for the POSIX threads implementation. 00236 pthread_t pthread_obj; 00237 #endif 00238 }; 00239 #endif // FLA_ENABLE_SUPERMATRIX 00240 00241 00242 #endif // FLA_TYPE_DEFS_H