libflame
revision_anchor
|
00001 /* 00002 00003 Copyright (C) 2014, The University of Texas at Austin 00004 00005 This file is part of libflame and is available under the 3-Clause 00006 BSD license, which can be found in the LICENSE file at the top-level 00007 directory, or at http://opensource.org/licenses/BSD-3-Clause 00008 00009 */ 00010 00011 #ifndef FLA_TYPE_DEFS_H 00012 #define FLA_TYPE_DEFS_H 00013 00014 #if FLA_MULTITHREADING_MODEL == FLA_OPENMP 00015 #ifdef FLA_ENABLE_TIDSP 00016 #include <ti/omp/omp.h> 00017 #else 00018 #include <omp.h> 00019 #endif 00020 #elif FLA_MULTITHREADING_MODEL == FLA_PTHREADS 00021 #include <pthread.h> 00022 #endif 00023 00024 00025 // --- Complex type definitions ----------------------------------------------- 00026 00027 #ifndef _DEFINED_SCOMPLEX 00028 #define _DEFINED_SCOMPLEX 00029 typedef struct scomplex 00030 { 00031 float real, imag; 00032 } scomplex; 00033 #endif 00034 00035 #ifndef _DEFINED_DCOMPLEX 00036 #define _DEFINED_DCOMPLEX 00037 typedef struct dcomplex 00038 { 00039 double real, imag; 00040 } dcomplex; 00041 #endif 00042 00043 00044 // --- Parameter and return type definitions ---------------------------------- 00045 00046 typedef int FLA_Bool; 00047 typedef int FLA_Error; 00048 typedef int FLA_Quadrant; 00049 typedef int FLA_Datatype; 00050 typedef int FLA_Elemtype; 00051 typedef int FLA_Side; 00052 typedef int FLA_Uplo; 00053 typedef int FLA_Trans; 00054 typedef int FLA_Conj; 00055 typedef int FLA_Diag; 00056 typedef int FLA_Dimension; 00057 typedef int FLA_Pivot_type; 00058 typedef int FLA_Direct; 00059 typedef int FLA_Store; 00060 typedef int FLA_Matrix_type; 00061 typedef int FLA_Precision; 00062 typedef int FLA_Domain; 00063 typedef int FLA_Inv; 00064 typedef int FLA_Evd_type; 00065 typedef int FLA_Svd_type; 00066 typedef int FLA_Machval; 00067 typedef int FLA_Diag_off; 00068 00069 #ifndef _DEFINED_DIM_T 00070 #define _DEFINED_DIM_T 00071 typedef unsigned long dim_t; 00072 #endif 00073 00074 // --- Intrinsic/assembly definitions ---------------------------------------- 00075 00076 #if FLA_VECTOR_INTRINSIC_TYPE == FLA_SSE_INTRINSICS 00077 00078 #include "pmmintrin.h" 00079 00080 //typedef double v2df __attribute__ ((vector_size (16))); 00081 00082 typedef union 00083 { 00084 __m128 v; 00085 float f[4]; 00086 } v4sf_t; 00087 00088 typedef union 00089 { 00090 __m128d v; 00091 double d[2]; 00092 } v2df_t; 00093 00094 #endif 00095 00096 // --- FLAME object definitions ----------------------------------------------- 00097 00098 typedef struct FLA_Lock_s FLA_Lock; 00099 00100 //#ifdef FLA_ENABLE_MULTITHREADING 00101 struct FLA_Lock_s 00102 { 00103 // Implementation-specific lock object 00104 #if FLA_MULTITHREADING_MODEL == FLA_OPENMP 00105 omp_lock_t lock; 00106 #elif FLA_MULTITHREADING_MODEL == FLA_PTHREADS 00107 pthread_mutex_t lock; 00108 #endif 00109 }; 00110 //#endif 00111 00112 #ifdef FLA_ENABLE_SUPERMATRIX 00113 typedef int FLASH_Verbose; 00114 typedef int FLASH_Data_aff; 00115 00116 typedef struct FLASH_Queue_s FLASH_Queue; 00117 typedef struct FLASH_Task_s FLASH_Task; 00118 typedef struct FLASH_Dep_s FLASH_Dep; 00119 #endif 00120 typedef struct FLASH_Thread_s FLASH_Thread; 00121 00122 typedef struct FLA_Obj_struct 00123 { 00124 // Basic object description fields 00125 FLA_Datatype datatype; 00126 FLA_Elemtype elemtype; 00127 dim_t m; 00128 dim_t n; 00129 dim_t rs; 00130 dim_t cs; 00131 dim_t m_inner; 00132 dim_t n_inner; 00133 unsigned long id; 00134 dim_t m_index; 00135 dim_t n_index; 00136 00137 dim_t n_elem_alloc; 00138 void* buffer; 00139 int buffer_info; 00140 00141 FLA_Uplo uplo; 00142 00143 #ifdef FLA_ENABLE_SUPERMATRIX 00144 // Fields for supermatrix 00145 int n_read_blocks; 00146 int n_write_blocks; 00147 00148 // All the tasks that previously read this block, anti-dependency 00149 int n_read_tasks; 00150 FLASH_Dep* read_task_head; 00151 FLASH_Dep* read_task_tail; 00152 00153 // Task that last overwrote this block, flow dependency 00154 FLASH_Task* write_task; 00155 #endif 00156 } FLA_Base_obj; 00157 00158 typedef struct FLA_Obj_view 00159 { 00160 // Basic object view description fields 00161 dim_t offm; 00162 dim_t offn; 00163 dim_t m; 00164 dim_t n; 00165 dim_t m_inner; 00166 dim_t n_inner; 00167 00168 FLA_Base_obj* base; 00169 00170 } FLA_Obj; 00171 00172 #ifdef FLA_ENABLE_SUPERMATRIX 00173 struct FLASH_Queue_s 00174 { 00175 // Number of tasks currently in queue 00176 unsigned int n_tasks; 00177 00178 // Pointers to head (front) and tail (back) of queue 00179 FLASH_Task* head; 00180 FLASH_Task* tail; 00181 }; 00182 00183 struct FLASH_Task_s 00184 { 00185 // Execution information 00186 int n_ready; 00187 00188 // Labels 00189 int order; 00190 int queue; 00191 int height; 00192 int thread; 00193 int cache; 00194 FLA_Bool hit; 00195 00196 // Function pointer 00197 void* func; 00198 00199 // Control tree pointer 00200 void* cntl; 00201 00202 // Name of task 00203 char* name; 00204 00205 // GPU enabled task 00206 FLA_Bool enabled_gpu; 00207 00208 // Integer arguments 00209 int n_int_args; 00210 int* int_arg; 00211 00212 // Constant FLA_Obj arguments 00213 int n_fla_args; 00214 FLA_Obj* fla_arg; 00215 00216 // Input FLA_Obj arguments 00217 int n_input_args; 00218 FLA_Obj* input_arg; 00219 00220 // Output FLA_Obj argument 00221 int n_output_args; 00222 FLA_Obj* output_arg; 00223 00224 // Number of blocks within all macroblocks 00225 int n_macro_args; 00226 00227 // Number of write after read dependencies 00228 int n_war_args; 00229 00230 // Dependence information 00231 int n_dep_args; 00232 FLASH_Dep* dep_arg_head; 00233 FLASH_Dep* dep_arg_tail; 00234 00235 // Support for a doubly linked list of tasks 00236 FLASH_Task* prev_task; 00237 FLASH_Task* next_task; 00238 00239 // Support for a doubly linked list for wait queue 00240 FLASH_Task* prev_wait; 00241 FLASH_Task* next_wait; 00242 }; 00243 00244 struct FLASH_Dep_s 00245 { 00246 // Task yielding dependency 00247 FLASH_Task* task; 00248 00249 // Support for linked list of FLASH_Deps 00250 FLASH_Dep* next_dep; 00251 }; 00252 #endif // FLA_ENABLE_SUPERMATRIX 00253 00254 struct FLASH_Thread_s 00255 { 00256 // The thread's unique identifier 00257 int id; 00258 00259 // Pointer to variables needed to execute SuperMatrix mechanism 00260 void* args; 00261 00262 #if FLA_MULTITHREADING_MODEL == FLA_PTHREADS 00263 // The thread object. Only needed for the POSIX threads implementation. 00264 pthread_t pthread_obj; 00265 #endif 00266 }; 00267 00268 #endif // FLA_TYPE_DEFS_H