PLASMA 2.3.1

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

00001 
00016 /***************************************************************************/
00020 #ifndef _PLASMA_GLOBAL_H_
00021 #define _PLASMA_GLOBAL_H_
00022 
00023 #include <plasma.h>
00024 
00025 #include <string.h>
00026 
00027 #if defined( _WIN32 ) || defined( _WIN64 )
00028 #include "plasmawinthread.h"
00029 #else
00030 #include <pthread.h>
00031 #endif
00032 
00033 /***************************************************************************/
00036 // maximum contexts
00037 #define CONTEXTS_MAX         256
00038 // maximum cores per context
00039 #define CONTEXT_THREADS_MAX  256
00040 // size of parallel functions arguments buffer
00041 #define ARGS_BUFF_SIZE       512
00042 // cache line size
00043 #define CACHE_LINE_SIZE      128
00044 // standard page size
00045 #define STANDARD_PAGE_SIZE  4096
00046 
00047 /***************************************************************************/
00050 #define PLASMA_ACT_STAND_BY     0
00051 #define PLASMA_ACT_PARALLEL     1
00052 #define PLASMA_ACT_DYNAMIC      2
00053 #define PLASMA_ACT_FINALIZE     3
00054 
00055 /***************************************************************************/
00058 #define PLASMA_FUNC_SGELS    1
00059 #define PLASMA_FUNC_SPOSV    2
00060 #define PLASMA_FUNC_SGESV    3
00061 #define PLASMA_FUNC_DGELS    4
00062 #define PLASMA_FUNC_DPOSV    5
00063 #define PLASMA_FUNC_DGESV    6
00064 #define PLASMA_FUNC_CGELS    7
00065 #define PLASMA_FUNC_CPOSV    8
00066 #define PLASMA_FUNC_CGESV    9
00067 #define PLASMA_FUNC_ZGELS   10
00068 #define PLASMA_FUNC_ZPOSV   11
00069 #define PLASMA_FUNC_ZGESV   12
00070 #define PLASMA_FUNC_ZCGESV  13
00071 #define PLASMA_FUNC_DSGESV  14
00072 #define PLASMA_FUNC_ZCPOSV  15
00073 #define PLASMA_FUNC_DSPOSV  16
00074 #define PLASMA_FUNC_DSGELS  17
00075 #define PLASMA_FUNC_ZCGELS  18
00076 #define PLASMA_FUNC_SGEMM   19
00077 #define PLASMA_FUNC_DGEMM   20
00078 #define PLASMA_FUNC_CGEMM   21
00079 #define PLASMA_FUNC_ZGEMM   22
00080 #define PLASMA_FUNC_SSYMM   23
00081 #define PLASMA_FUNC_DSYMM   24
00082 #define PLASMA_FUNC_CSYMM   25
00083 #define PLASMA_FUNC_ZSYMM   26
00084 #define PLASMA_FUNC_CHERK   27
00085 #define PLASMA_FUNC_ZHERK   28
00086 #define PLASMA_FUNC_SSYRK   29
00087 #define PLASMA_FUNC_DSYRK   30
00088 #define PLASMA_FUNC_CSYRK   31
00089 #define PLASMA_FUNC_ZSYRK   32
00090 #define PLASMA_FUNC_CHEMM   33
00091 #define PLASMA_FUNC_ZHEMM   34
00092 #define PLASMA_FUNC_ZHEEV   35
00093 #define PLASMA_FUNC_CHEEV   36
00094 #define PLASMA_FUNC_DSYEV   37
00095 #define PLASMA_FUNC_SSYEV   38
00096 #define PLASMA_FUNC_ZHEGST  39
00097 #define PLASMA_FUNC_CHEGST  40
00098 #define PLASMA_FUNC_DSYGST  41
00099 #define PLASMA_FUNC_SSYGST  42
00100 #define PLASMA_FUNC_ZHEGV   43
00101 #define PLASMA_FUNC_CHEGV   44
00102 #define PLASMA_FUNC_DSYGV   45
00103 #define PLASMA_FUNC_SSYGV   46
00104 #define PLASMA_FUNC_ZHETRD  47
00105 #define PLASMA_FUNC_CHETRD  48
00106 #define PLASMA_FUNC_DSYTRD  49
00107 #define PLASMA_FUNC_SSYTRD  50
00108 #define PLASMA_FUNC_ZGESVD  51
00109 #define PLASMA_FUNC_CGESVD  52
00110 #define PLASMA_FUNC_DGESVD  53
00111 #define PLASMA_FUNC_SGESVD  54
00112 #define PLASMA_FUNC_ZGEEV   55
00113 #define PLASMA_FUNC_CGEEV   56
00114 #define PLASMA_FUNC_DGEEV   57
00115 #define PLASMA_FUNC_SGEEV   58
00116 #define PLASMA_FUNC_ZGEHRD  59
00117 #define PLASMA_FUNC_CGEHRD  60
00118 #define PLASMA_FUNC_DGEHRD  61
00119 #define PLASMA_FUNC_SGEHRD  62
00120 #define PLASMA_FUNC_ZGEBRD  63
00121 #define PLASMA_FUNC_CGEBRD  64
00122 #define PLASMA_FUNC_DGEBRD  65
00123 #define PLASMA_FUNC_SGEBRD  66
00124 
00125 /***************************************************************************/
00128 #define plasma_pack_args_1( \
00129     type1, arg1) \
00130 { \
00131     type1 var1 = (arg1); \
00132     unsigned char *plasma_ptr = plasma->args_buff; \
00133     if (sizeof(type1) > ARGS_BUFF_SIZE) \
00134         plasma_fatal_error("plasma_pack_args_1", "arguments buffer too small"); \
00135     memcpy(plasma_ptr, &var1, sizeof(type1)); plasma_ptr += sizeof(type1); \
00136 }
00137 
00138 #define plasma_pack_args_2( \
00139     type1, arg1, \
00140     type2, arg2) \
00141 { \
00142     type1 var1 = (arg1); \
00143     type2 var2 = (arg2); \
00144     unsigned char *plasma_ptr = plasma->args_buff; \
00145     if (sizeof(type1) + \
00146         sizeof(type2) > ARGS_BUFF_SIZE) \
00147         plasma_fatal_error("plasma_pack_args_2", "arguments buffer too small"); \
00148     memcpy(plasma_ptr, &var1, sizeof(type1)); plasma_ptr += sizeof(type1); \
00149     memcpy(plasma_ptr, &var2, sizeof(type2)); plasma_ptr += sizeof(type2); \
00150 }
00151 
00152 #define plasma_pack_args_3( \
00153     type1, arg1, \
00154     type2, arg2, \
00155     type3, arg3) \
00156 { \
00157     type1 var1 = (arg1); \
00158     type2 var2 = (arg2); \
00159     type3 var3 = (arg3); \
00160     unsigned char *plasma_ptr = plasma->args_buff; \
00161     if (sizeof(type1) + \
00162         sizeof(type2) + \
00163         sizeof(type3) > ARGS_BUFF_SIZE) \
00164         plasma_fatal_error("plasma_pack_args_3", "arguments buffer too small"); \
00165     memcpy(plasma_ptr, &var1, sizeof(type1)); plasma_ptr += sizeof(type1); \
00166     memcpy(plasma_ptr, &var2, sizeof(type2)); plasma_ptr += sizeof(type2); \
00167     memcpy(plasma_ptr, &var3, sizeof(type3)); plasma_ptr += sizeof(type3); \
00168 }
00169 
00170 #define plasma_pack_args_4( \
00171     type1, arg1, \
00172     type2, arg2, \
00173     type3, arg3, \
00174     type4, arg4) \
00175 { \
00176     type1 var1 = (arg1); \
00177     type2 var2 = (arg2); \
00178     type3 var3 = (arg3); \
00179     type4 var4 = (arg4); \
00180     unsigned char *plasma_ptr = plasma->args_buff; \
00181     if (sizeof(type1) + \
00182         sizeof(type2) + \
00183         sizeof(type3) + \
00184         sizeof(type4) > ARGS_BUFF_SIZE) \
00185         plasma_fatal_error("plasma_pack_args_4", "arguments buffer too small"); \
00186     memcpy(plasma_ptr, &var1, sizeof(type1)); plasma_ptr += sizeof(type1); \
00187     memcpy(plasma_ptr, &var2, sizeof(type2)); plasma_ptr += sizeof(type2); \
00188     memcpy(plasma_ptr, &var3, sizeof(type3)); plasma_ptr += sizeof(type3); \
00189     memcpy(plasma_ptr, &var4, sizeof(type4)); plasma_ptr += sizeof(type4); \
00190 }
00191 
00192 #define plasma_pack_args_5( \
00193     type1, arg1, \
00194     type2, arg2, \
00195     type3, arg3, \
00196     type4, arg4, \
00197     type5, arg5) \
00198 { \
00199     type1 var1 = (arg1); \
00200     type2 var2 = (arg2); \
00201     type3 var3 = (arg3); \
00202     type4 var4 = (arg4); \
00203     type5 var5 = (arg5); \
00204     unsigned char *plasma_ptr = plasma->args_buff; \
00205     if (sizeof(type1) + \
00206         sizeof(type2) + \
00207         sizeof(type3) + \
00208         sizeof(type4) + \
00209         sizeof(type5) > ARGS_BUFF_SIZE) \
00210         plasma_fatal_error("plasma_pack_args_5", "arguments buffer too small"); \
00211     memcpy(plasma_ptr, &var1, sizeof(type1)); plasma_ptr += sizeof(type1); \
00212     memcpy(plasma_ptr, &var2, sizeof(type2)); plasma_ptr += sizeof(type2); \
00213     memcpy(plasma_ptr, &var3, sizeof(type3)); plasma_ptr += sizeof(type3); \
00214     memcpy(plasma_ptr, &var4, sizeof(type4)); plasma_ptr += sizeof(type4); \
00215     memcpy(plasma_ptr, &var5, sizeof(type5)); plasma_ptr += sizeof(type5); \
00216 }
00217 
00218 #define plasma_pack_args_6( \
00219     type1, arg1, \
00220     type2, arg2, \
00221     type3, arg3, \
00222     type4, arg4, \
00223     type5, arg5, \
00224     type6, arg6) \
00225 { \
00226     type1 var1 = (arg1); \
00227     type2 var2 = (arg2); \
00228     type3 var3 = (arg3); \
00229     type4 var4 = (arg4); \
00230     type5 var5 = (arg5); \
00231     type6 var6 = (arg6); \
00232     unsigned char *plasma_ptr = plasma->args_buff; \
00233     if (sizeof(type1) + \
00234         sizeof(type2) + \
00235         sizeof(type3) + \
00236         sizeof(type4) + \
00237         sizeof(type5) + \
00238         sizeof(type6) > ARGS_BUFF_SIZE) \
00239         plasma_fatal_error("plasma_pack_args_6", "arguments buffer too small"); \
00240     memcpy(plasma_ptr, &var1, sizeof(type1)); plasma_ptr += sizeof(type1); \
00241     memcpy(plasma_ptr, &var2, sizeof(type2)); plasma_ptr += sizeof(type2); \
00242     memcpy(plasma_ptr, &var3, sizeof(type3)); plasma_ptr += sizeof(type3); \
00243     memcpy(plasma_ptr, &var4, sizeof(type4)); plasma_ptr += sizeof(type4); \
00244     memcpy(plasma_ptr, &var5, sizeof(type5)); plasma_ptr += sizeof(type5); \
00245     memcpy(plasma_ptr, &var6, sizeof(type6)); plasma_ptr += sizeof(type6); \
00246 }
00247 
00248 #define plasma_pack_args_7( \
00249     type1, arg1, \
00250     type2, arg2, \
00251     type3, arg3, \
00252     type4, arg4, \
00253     type5, arg5, \
00254     type6, arg6, \
00255     type7, arg7) \
00256 { \
00257     type1 var1 = (arg1); \
00258     type2 var2 = (arg2); \
00259     type3 var3 = (arg3); \
00260     type4 var4 = (arg4); \
00261     type5 var5 = (arg5); \
00262     type6 var6 = (arg6); \
00263     type7 var7 = (arg7); \
00264     unsigned char *plasma_ptr = plasma->args_buff; \
00265     if (sizeof(type1) + \
00266         sizeof(type2) + \
00267         sizeof(type3) + \
00268         sizeof(type4) + \
00269         sizeof(type5) + \
00270         sizeof(type6) + \
00271         sizeof(type7) > ARGS_BUFF_SIZE) \
00272         plasma_fatal_error("plasma_pack_args_7", "arguments buffer too small"); \
00273     memcpy(plasma_ptr, &var1, sizeof(type1)); plasma_ptr += sizeof(type1); \
00274     memcpy(plasma_ptr, &var2, sizeof(type2)); plasma_ptr += sizeof(type2); \
00275     memcpy(plasma_ptr, &var3, sizeof(type3)); plasma_ptr += sizeof(type3); \
00276     memcpy(plasma_ptr, &var4, sizeof(type4)); plasma_ptr += sizeof(type4); \
00277     memcpy(plasma_ptr, &var5, sizeof(type5)); plasma_ptr += sizeof(type5); \
00278     memcpy(plasma_ptr, &var6, sizeof(type6)); plasma_ptr += sizeof(type6); \
00279     memcpy(plasma_ptr, &var7, sizeof(type7)); plasma_ptr += sizeof(type7); \
00280 }
00281 
00282 #define plasma_pack_args_8( \
00283     type1, arg1, \
00284     type2, arg2, \
00285     type3, arg3, \
00286     type4, arg4, \
00287     type5, arg5, \
00288     type6, arg6, \
00289     type7, arg7, \
00290     type8, arg8) \
00291 { \
00292     type1 var1 = (arg1); \
00293     type2 var2 = (arg2); \
00294     type3 var3 = (arg3); \
00295     type4 var4 = (arg4); \
00296     type5 var5 = (arg5); \
00297     type6 var6 = (arg6); \
00298     type7 var7 = (arg7); \
00299     type8 var8 = (arg8); \
00300     unsigned char *plasma_ptr = plasma->args_buff; \
00301     if (sizeof(type1) + \
00302         sizeof(type2) + \
00303         sizeof(type3) + \
00304         sizeof(type4) + \
00305         sizeof(type5) + \
00306         sizeof(type6) + \
00307         sizeof(type7) + \
00308         sizeof(type8) > ARGS_BUFF_SIZE) \
00309         plasma_fatal_error("plasma_pack_args_8", "arguments buffer too small"); \
00310     memcpy(plasma_ptr, &var1, sizeof(type1)); plasma_ptr += sizeof(type1); \
00311     memcpy(plasma_ptr, &var2, sizeof(type2)); plasma_ptr += sizeof(type2); \
00312     memcpy(plasma_ptr, &var3, sizeof(type3)); plasma_ptr += sizeof(type3); \
00313     memcpy(plasma_ptr, &var4, sizeof(type4)); plasma_ptr += sizeof(type4); \
00314     memcpy(plasma_ptr, &var5, sizeof(type5)); plasma_ptr += sizeof(type5); \
00315     memcpy(plasma_ptr, &var6, sizeof(type6)); plasma_ptr += sizeof(type6); \
00316     memcpy(plasma_ptr, &var7, sizeof(type7)); plasma_ptr += sizeof(type7); \
00317     memcpy(plasma_ptr, &var8, sizeof(type8)); plasma_ptr += sizeof(type8); \
00318 }
00319 
00320 #define plasma_pack_args_9( \
00321     type1, arg1, \
00322     type2, arg2, \
00323     type3, arg3, \
00324     type4, arg4, \
00325     type5, arg5, \
00326     type6, arg6, \
00327     type7, arg7, \
00328     type8, arg8, \
00329     type9, arg9) \
00330 { \
00331     type1 var1 = (arg1); \
00332     type2 var2 = (arg2); \
00333     type3 var3 = (arg3); \
00334     type4 var4 = (arg4); \
00335     type5 var5 = (arg5); \
00336     type6 var6 = (arg6); \
00337     type7 var7 = (arg7); \
00338     type8 var8 = (arg8); \
00339     type9 var9 = (arg9); \
00340     unsigned char *plasma_ptr = plasma->args_buff; \
00341     if (sizeof(type1) + \
00342         sizeof(type2) + \
00343         sizeof(type3) + \
00344         sizeof(type4) + \
00345         sizeof(type5) + \
00346         sizeof(type6) + \
00347         sizeof(type7) + \
00348         sizeof(type8) + \
00349         sizeof(type9) > ARGS_BUFF_SIZE) \
00350         plasma_fatal_error("plasma_pack_args_9", "arguments buffer too small"); \
00351     memcpy(plasma_ptr, &var1, sizeof(type1)); plasma_ptr += sizeof(type1); \
00352     memcpy(plasma_ptr, &var2, sizeof(type2)); plasma_ptr += sizeof(type2); \
00353     memcpy(plasma_ptr, &var3, sizeof(type3)); plasma_ptr += sizeof(type3); \
00354     memcpy(plasma_ptr, &var4, sizeof(type4)); plasma_ptr += sizeof(type4); \
00355     memcpy(plasma_ptr, &var5, sizeof(type5)); plasma_ptr += sizeof(type5); \
00356     memcpy(plasma_ptr, &var6, sizeof(type6)); plasma_ptr += sizeof(type6); \
00357     memcpy(plasma_ptr, &var7, sizeof(type7)); plasma_ptr += sizeof(type7); \
00358     memcpy(plasma_ptr, &var8, sizeof(type8)); plasma_ptr += sizeof(type8); \
00359     memcpy(plasma_ptr, &var9, sizeof(type9)); plasma_ptr += sizeof(type9); \
00360 }
00361 
00362 #define plasma_pack_args_10( \
00363     type1, arg1, \
00364     type2, arg2, \
00365     type3, arg3, \
00366     type4, arg4, \
00367     type5, arg5, \
00368     type6, arg6, \
00369     type7, arg7, \
00370     type8, arg8, \
00371     type9, arg9, \
00372     type10, arg10) \
00373 { \
00374     type1 var1 = (arg1); \
00375     type2 var2 = (arg2); \
00376     type3 var3 = (arg3); \
00377     type4 var4 = (arg4); \
00378     type5 var5 = (arg5); \
00379     type6 var6 = (arg6); \
00380     type7 var7 = (arg7); \
00381     type8 var8 = (arg8); \
00382     type9 var9 = (arg9); \
00383     type10 var10 = (arg10); \
00384     unsigned char *plasma_ptr = plasma->args_buff; \
00385     if (sizeof(type1) + \
00386         sizeof(type2) + \
00387         sizeof(type3) + \
00388         sizeof(type4) + \
00389         sizeof(type5) + \
00390         sizeof(type6) + \
00391         sizeof(type7) + \
00392         sizeof(type8) + \
00393         sizeof(type9) + \
00394         sizeof(type10) > ARGS_BUFF_SIZE) \
00395         plasma_fatal_error("plasma_pack_args_9", "arguments buffer too small"); \
00396     memcpy(plasma_ptr, &var1, sizeof(type1)); plasma_ptr += sizeof(type1); \
00397     memcpy(plasma_ptr, &var2, sizeof(type2)); plasma_ptr += sizeof(type2); \
00398     memcpy(plasma_ptr, &var3, sizeof(type3)); plasma_ptr += sizeof(type3); \
00399     memcpy(plasma_ptr, &var4, sizeof(type4)); plasma_ptr += sizeof(type4); \
00400     memcpy(plasma_ptr, &var5, sizeof(type5)); plasma_ptr += sizeof(type5); \
00401     memcpy(plasma_ptr, &var6, sizeof(type6)); plasma_ptr += sizeof(type6); \
00402     memcpy(plasma_ptr, &var7, sizeof(type7)); plasma_ptr += sizeof(type7); \
00403     memcpy(plasma_ptr, &var8, sizeof(type8)); plasma_ptr += sizeof(type8); \
00404     memcpy(plasma_ptr, &var9, sizeof(type9)); plasma_ptr += sizeof(type9); \
00405     memcpy(plasma_ptr, &var10, sizeof(type10)); plasma_ptr += sizeof(type10); \
00406 }
00407 
00408 /***************************************************************************/
00411 #define plasma_dynamic_sync() \
00412 { \
00413     if (plasma->dynamic_section) { \
00414         QUARK_Waitall(plasma->quark); \
00415         plasma_barrier(plasma); \
00416         plasma->dynamic_section = PLASMA_FALSE; \
00417     } \
00418 }
00419 
00420 /***************************************************************************/
00423 #define plasma_static_call(parallel_function) \
00424 { \
00425     if (plasma->dynamic_section) \
00426         plasma_dynamic_sync(); \
00427     pthread_mutex_lock(&plasma->action_mutex); \
00428     plasma->action = PLASMA_ACT_PARALLEL; \
00429     plasma->parallel_func_ptr = &parallel_function; \
00430     pthread_mutex_unlock(&plasma->action_mutex); \
00431     pthread_cond_broadcast(&plasma->action_condt); \
00432     plasma_barrier(plasma); \
00433     plasma->action = PLASMA_ACT_STAND_BY; \
00434     parallel_function(plasma); \
00435     plasma_barrier(plasma); \
00436 }
00437 
00438 /***************************************************************************/
00441 #define plasma_dynamic_spawn() \
00442 { \
00443     if (!plasma->dynamic_section) { \
00444         plasma->dynamic_section = PLASMA_TRUE; \
00445         pthread_mutex_lock(&plasma->action_mutex); \
00446         plasma->action = PLASMA_ACT_DYNAMIC; \
00447         pthread_mutex_unlock(&plasma->action_mutex); \
00448         pthread_cond_broadcast(&plasma->action_condt); \
00449         plasma_barrier(plasma); \
00450         plasma->action = PLASMA_ACT_STAND_BY; \
00451     } \
00452 }
00453 
00454 /***************************************************************************/
00457 #define plasma_static_call_1( \
00458            parallel_function, \
00459     type1, arg1) \
00460     plasma_pack_args_1( \
00461         type1, (arg1)) \
00462     plasma_static_call(parallel_function) \
00463 
00464 #define plasma_static_call_2( \
00465            parallel_function, \
00466     type1, arg1, \
00467     type2, arg2) \
00468     plasma_pack_args_2( \
00469         type1, (arg1), \
00470         type2, (arg2)) \
00471     plasma_static_call(parallel_function) \
00472 
00473 #define plasma_static_call_3( \
00474            parallel_function, \
00475     type1, arg1, \
00476     type2, arg2, \
00477     type3, arg3) \
00478     plasma_pack_args_3( \
00479         type1, (arg1), \
00480         type2, (arg2), \
00481         type3, (arg3)) \
00482     plasma_static_call(parallel_function) \
00483 
00484 #define plasma_static_call_4( \
00485            parallel_function, \
00486     type1, arg1, \
00487     type2, arg2, \
00488     type3, arg3, \
00489     type4, arg4) \
00490     plasma_pack_args_4( \
00491         type1, (arg1), \
00492         type2, (arg2), \
00493         type3, (arg3), \
00494         type4, (arg4)) \
00495     plasma_static_call(parallel_function) \
00496 
00497 #define plasma_static_call_5( \
00498            parallel_function, \
00499     type1, arg1, \
00500     type2, arg2, \
00501     type3, arg3, \
00502     type4, arg4, \
00503     type5, arg5) \
00504     plasma_pack_args_5( \
00505         type1, (arg1), \
00506         type2, (arg2), \
00507         type3, (arg3), \
00508         type4, (arg4), \
00509         type5, (arg5)) \
00510     plasma_static_call(parallel_function) \
00511 
00512 #define plasma_static_call_6( \
00513            parallel_function, \
00514     type1, arg1, \
00515     type2, arg2, \
00516     type3, arg3, \
00517     type4, arg4, \
00518     type5, arg5, \
00519     type6, arg6) \
00520     plasma_pack_args_6( \
00521         type1, (arg1), \
00522         type2, (arg2), \
00523         type3, (arg3), \
00524         type4, (arg4), \
00525         type5, (arg5), \
00526         type6, (arg6)) \
00527     plasma_static_call(parallel_function) \
00528 
00529 #define plasma_static_call_7( \
00530            parallel_function, \
00531     type1, arg1, \
00532     type2, arg2, \
00533     type3, arg3, \
00534     type4, arg4, \
00535     type5, arg5, \
00536     type6, arg6, \
00537     type7, arg7) \
00538     plasma_pack_args_7( \
00539         type1, (arg1), \
00540         type2, (arg2), \
00541         type3, (arg3), \
00542         type4, (arg4), \
00543         type5, (arg5), \
00544         type6, (arg6), \
00545         type7, (arg7)) \
00546     plasma_static_call(parallel_function) \
00547 
00548 #define plasma_static_call_8( \
00549            parallel_function, \
00550     type1, arg1, \
00551     type2, arg2, \
00552     type3, arg3, \
00553     type4, arg4, \
00554     type5, arg5, \
00555     type6, arg6, \
00556     type7, arg7, \
00557     type8, arg8) \
00558     plasma_pack_args_8( \
00559         type1, (arg1), \
00560         type2, (arg2), \
00561         type3, (arg3), \
00562         type4, (arg4), \
00563         type5, (arg5), \
00564         type6, (arg6), \
00565         type7, (arg7), \
00566         type8, (arg8)) \
00567     plasma_static_call(parallel_function) \
00568 
00569 #define plasma_static_call_9( \
00570            parallel_function, \
00571     type1, arg1, \
00572     type2, arg2, \
00573     type3, arg3, \
00574     type4, arg4, \
00575     type5, arg5, \
00576     type6, arg6, \
00577     type7, arg7, \
00578     type8, arg8, \
00579     type9, arg9) \
00580     plasma_pack_args_9( \
00581         type1, (arg1), \
00582         type2, (arg2), \
00583         type3, (arg3), \
00584         type4, (arg4), \
00585         type5, (arg5), \
00586         type6, (arg6), \
00587         type7, (arg7), \
00588         type8, (arg8), \
00589         type9, (arg9)) \
00590     plasma_static_call(parallel_function) \
00591 
00592 #define plasma_static_call_10( \
00593            parallel_function, \
00594     type1, arg1, \
00595     type2, arg2, \
00596     type3, arg3, \
00597     type4, arg4, \
00598     type5, arg5, \
00599     type6, arg6, \
00600     type7, arg7, \
00601     type8, arg8, \
00602     type9, arg9, \
00603     type10, arg10) \
00604     plasma_pack_args_10( \
00605         type1, (arg1), \
00606         type2, (arg2), \
00607         type3, (arg3), \
00608         type4, (arg4), \
00609         type5, (arg5), \
00610         type6, (arg6), \
00611         type7, (arg7), \
00612         type8, (arg8), \
00613         type9, (arg9), \
00614         type10, (arg10)) \
00615     plasma_static_call(parallel_function) \
00616 
00617 /***************************************************************************/
00620 #define plasma_parallel_call_1( \
00621            parallel_function, \
00622     type1, arg1) \
00623     if (PLASMA_SCHEDULING == PLASMA_STATIC_SCHEDULING) { \
00624         plasma_pack_args_1( \
00625             type1, (arg1)) \
00626         plasma_static_call(parallel_function) \
00627     } else { \
00628         plasma_dynamic_spawn(); \
00629         parallel_function##_quark( \
00630             arg1); \
00631     }
00632 
00633 #define plasma_parallel_call_2( \
00634            parallel_function, \
00635     type1, arg1, \
00636     type2, arg2) \
00637     if (PLASMA_SCHEDULING == PLASMA_STATIC_SCHEDULING) { \
00638         plasma_pack_args_2( \
00639             type1, (arg1), \
00640             type2, (arg2)) \
00641         plasma_static_call(parallel_function) \
00642     } else { \
00643         plasma_dynamic_spawn(); \
00644         parallel_function##_quark( \
00645             arg1, \
00646             arg2); \
00647     }
00648 
00649 #define plasma_parallel_call_3( \
00650            parallel_function, \
00651     type1, arg1, \
00652     type2, arg2, \
00653     type3, arg3) \
00654     if (PLASMA_SCHEDULING == PLASMA_STATIC_SCHEDULING) { \
00655         plasma_pack_args_3( \
00656             type1, (arg1), \
00657             type2, (arg2), \
00658             type3, (arg3)) \
00659         plasma_static_call(parallel_function) \
00660     } else { \
00661         plasma_dynamic_spawn(); \
00662         parallel_function##_quark( \
00663             arg1, \
00664             arg2, \
00665             arg3); \
00666     }
00667 
00668 #define plasma_parallel_call_4( \
00669            parallel_function, \
00670     type1, arg1, \
00671     type2, arg2, \
00672     type3, arg3, \
00673     type4, arg4) \
00674     if (PLASMA_SCHEDULING == PLASMA_STATIC_SCHEDULING) { \
00675         plasma_pack_args_4( \
00676             type1, (arg1), \
00677             type2, (arg2), \
00678             type3, (arg3), \
00679             type4, (arg4)) \
00680         plasma_static_call(parallel_function) \
00681     } else { \
00682         plasma_dynamic_spawn(); \
00683         parallel_function##_quark( \
00684             arg1, \
00685             arg2, \
00686             arg3, \
00687             arg4); \
00688     }
00689 
00690 #define plasma_parallel_call_5( \
00691            parallel_function, \
00692     type1, arg1, \
00693     type2, arg2, \
00694     type3, arg3, \
00695     type4, arg4, \
00696     type5, arg5) \
00697     if (PLASMA_SCHEDULING == PLASMA_STATIC_SCHEDULING) { \
00698         plasma_pack_args_5( \
00699             type1, (arg1), \
00700             type2, (arg2), \
00701             type3, (arg3), \
00702             type4, (arg4), \
00703             type5, (arg5)) \
00704         plasma_static_call(parallel_function) \
00705     } else { \
00706         plasma_dynamic_spawn(); \
00707         parallel_function##_quark( \
00708             arg1, \
00709             arg2, \
00710             arg3, \
00711             arg4, \
00712             arg5); \
00713     }
00714 
00715 #define plasma_parallel_call_6( \
00716            parallel_function, \
00717     type1, arg1, \
00718     type2, arg2, \
00719     type3, arg3, \
00720     type4, arg4, \
00721     type5, arg5, \
00722     type6, arg6) \
00723     if (PLASMA_SCHEDULING == PLASMA_STATIC_SCHEDULING) { \
00724         plasma_pack_args_6( \
00725             type1, (arg1), \
00726             type2, (arg2), \
00727             type3, (arg3), \
00728             type4, (arg4), \
00729             type5, (arg5), \
00730             type6, (arg6)) \
00731         plasma_static_call(parallel_function) \
00732     } else { \
00733         plasma_dynamic_spawn(); \
00734         parallel_function##_quark( \
00735             arg1, \
00736             arg2, \
00737             arg3, \
00738             arg4, \
00739             arg5, \
00740             arg6); \
00741     }
00742 
00743 #define plasma_parallel_call_7( \
00744            parallel_function, \
00745     type1, arg1, \
00746     type2, arg2, \
00747     type3, arg3, \
00748     type4, arg4, \
00749     type5, arg5, \
00750     type6, arg6, \
00751     type7, arg7) \
00752     if (PLASMA_SCHEDULING == PLASMA_STATIC_SCHEDULING) { \
00753         plasma_pack_args_7( \
00754             type1, (arg1), \
00755             type2, (arg2), \
00756             type3, (arg3), \
00757             type4, (arg4), \
00758             type5, (arg5), \
00759             type6, (arg6), \
00760             type7, (arg7)) \
00761         plasma_static_call(parallel_function) \
00762     } else { \
00763         plasma_dynamic_spawn(); \
00764         parallel_function##_quark( \
00765             arg1, \
00766             arg2, \
00767             arg3, \
00768             arg4, \
00769             arg5, \
00770             arg6, \
00771             arg7); \
00772     }
00773 
00774 #define plasma_parallel_call_8( \
00775            parallel_function, \
00776     type1, arg1, \
00777     type2, arg2, \
00778     type3, arg3, \
00779     type4, arg4, \
00780     type5, arg5, \
00781     type6, arg6, \
00782     type7, arg7, \
00783     type8, arg8) \
00784     if (PLASMA_SCHEDULING == PLASMA_STATIC_SCHEDULING) { \
00785         plasma_pack_args_8( \
00786             type1, (arg1), \
00787             type2, (arg2), \
00788             type3, (arg3), \
00789             type4, (arg4), \
00790             type5, (arg5), \
00791             type6, (arg6), \
00792             type7, (arg7), \
00793             type8, (arg8)) \
00794         plasma_static_call(parallel_function) \
00795     } else { \
00796         plasma_dynamic_spawn(); \
00797         parallel_function##_quark( \
00798             arg1, \
00799             arg2, \
00800             arg3, \
00801             arg4, \
00802             arg5, \
00803             arg6, \
00804             arg7, \
00805             arg8); \
00806     }
00807 
00808 #define plasma_parallel_call_9( \
00809            parallel_function, \
00810     type1, arg1, \
00811     type2, arg2, \
00812     type3, arg3, \
00813     type4, arg4, \
00814     type5, arg5, \
00815     type6, arg6, \
00816     type7, arg7, \
00817     type8, arg8, \
00818     type9, arg9) \
00819     if (PLASMA_SCHEDULING == PLASMA_STATIC_SCHEDULING) { \
00820         plasma_pack_args_9( \
00821             type1, (arg1), \
00822             type2, (arg2), \
00823             type3, (arg3), \
00824             type4, (arg4), \
00825             type5, (arg5), \
00826             type6, (arg6), \
00827             type7, (arg7), \
00828             type8, (arg8), \
00829             type9, (arg9)) \
00830         plasma_static_call(parallel_function) \
00831     } else { \
00832         plasma_dynamic_spawn(); \
00833         parallel_function##_quark( \
00834             arg1, \
00835             arg2, \
00836             arg3, \
00837             arg4, \
00838             arg5, \
00839             arg6, \
00840             arg7, \
00841             arg8, \
00842             arg9); \
00843     }
00844 
00845 #define plasma_parallel_call_10( \
00846            parallel_function, \
00847     type1, arg1, \
00848     type2, arg2, \
00849     type3, arg3, \
00850     type4, arg4, \
00851     type5, arg5, \
00852     type6, arg6, \
00853     type7, arg7, \
00854     type8, arg8, \
00855     type9, arg9, \
00856     type10, arg10) \
00857     if (PLASMA_SCHEDULING == PLASMA_STATIC_SCHEDULING) { \
00858         plasma_pack_args_10( \
00859             type1, (arg1), \
00860             type2, (arg2), \
00861             type3, (arg3), \
00862             type4, (arg4), \
00863             type5, (arg5), \
00864             type6, (arg6), \
00865             type7, (arg7), \
00866             type8, (arg8), \
00867             type9, (arg9), \
00868             type10, (arg10)) \
00869         plasma_static_call(parallel_function) \
00870     } else { \
00871         plasma_dynamic_spawn(); \
00872         parallel_function##_quark( \
00873             arg1, \
00874             arg2, \
00875             arg3, \
00876             arg4, \
00877             arg5, \
00878             arg6, \
00879             arg7, \
00880             arg8, \
00881             arg9, \
00882             arg10); \
00883     }
00884 
00885 /***************************************************************************/
00888 #define plasma_dynamic_call_1( \
00889            parallel_function, \
00890     type1, arg1) \
00891     plasma_dynamic_spawn(); \
00892     parallel_function##_quark( \
00893         arg1); \
00894 
00895 #define plasma_dynamic_call_2( \
00896            parallel_function, \
00897     type1, arg1, \
00898     type2, arg2) \
00899     plasma_dynamic_spawn(); \
00900     parallel_function##_quark( \
00901         arg1, \
00902         arg2); \
00903 
00904 #define plasma_dynamic_call_3( \
00905            parallel_function, \
00906     type1, arg1, \
00907     type2, arg2, \
00908     type3, arg3) \
00909     plasma_dynamic_spawn(); \
00910     parallel_function##_quark( \
00911         arg1, \
00912         arg2, \
00913         arg3); \
00914 
00915 #define plasma_dynamic_call_4( \
00916            parallel_function, \
00917     type1, arg1, \
00918     type2, arg2, \
00919     type3, arg3, \
00920     type4, arg4) \
00921     plasma_dynamic_spawn(); \
00922     parallel_function##_quark( \
00923         arg1, \
00924         arg2, \
00925         arg3, \
00926         arg4); \
00927 
00928 #define plasma_dynamic_call_5( \
00929            parallel_function, \
00930     type1, arg1, \
00931     type2, arg2, \
00932     type3, arg3, \
00933     type4, arg4, \
00934     type5, arg5) \
00935     plasma_dynamic_spawn(); \
00936     parallel_function##_quark( \
00937         arg1, \
00938         arg2, \
00939         arg3, \
00940         arg4, \
00941         arg5); \
00942 
00943 #define plasma_dynamic_call_6( \
00944            parallel_function, \
00945     type1, arg1, \
00946     type2, arg2, \
00947     type3, arg3, \
00948     type4, arg4, \
00949     type5, arg5, \
00950     type6, arg6) \
00951     plasma_dynamic_spawn(); \
00952     parallel_function##_quark( \
00953         arg1, \
00954         arg2, \
00955         arg3, \
00956         arg4, \
00957         arg5, \
00958         arg6); \
00959 
00960 #define plasma_dynamic_call_7( \
00961            parallel_function, \
00962     type1, arg1, \
00963     type2, arg2, \
00964     type3, arg3, \
00965     type4, arg4, \
00966     type5, arg5, \
00967     type6, arg6, \
00968     type7, arg7) \
00969     plasma_dynamic_spawn(); \
00970     parallel_function##_quark( \
00971         arg1, \
00972         arg2, \
00973         arg3, \
00974         arg4, \
00975         arg5, \
00976         arg6, \
00977         arg7); \
00978 
00979 #define plasma_dynamic_call_8( \
00980            parallel_function, \
00981     type1, arg1, \
00982     type2, arg2, \
00983     type3, arg3, \
00984     type4, arg4, \
00985     type5, arg5, \
00986     type6, arg6, \
00987     type7, arg7, \
00988     type8, arg8) \
00989     plasma_dynamic_spawn(); \
00990     parallel_function##_quark( \
00991         arg1, \
00992         arg2, \
00993         arg3, \
00994         arg4, \
00995         arg5, \
00996         arg6, \
00997         arg7, \
00998         arg8); \
00999 
01000 #define plasma_dynamic_call_9( \
01001            parallel_function, \
01002     type1, arg1, \
01003     type2, arg2, \
01004     type3, arg3, \
01005     type4, arg4, \
01006     type5, arg5, \
01007     type6, arg6, \
01008     type7, arg7, \
01009     type8, arg8, \
01010     type9, arg9) \
01011     plasma_dynamic_spawn(); \
01012     parallel_function##_quark( \
01013         arg1, \
01014         arg2, \
01015         arg3, \
01016         arg4, \
01017         arg5, \
01018         arg6, \
01019         arg7, \
01020         arg8, \
01021         arg9);
01022 
01023 #define plasma_dynamic_call_10( \
01024            parallel_function, \
01025     type1, arg1, \
01026     type2, arg2, \
01027     type3, arg3, \
01028     type4, arg4, \
01029     type5, arg5, \
01030     type6, arg6, \
01031     type7, arg7, \
01032     type8, arg8, \
01033     type9, arg9, \
01034     type10, arg10) \
01035     plasma_dynamic_spawn(); \
01036     parallel_function##_quark( \
01037         arg1, \
01038         arg2, \
01039         arg3, \
01040         arg4, \
01041         arg5, \
01042         arg6, \
01043         arg7, \
01044         arg8, \
01045         arg9, \
01046         arg10);
01047 
01048 /***************************************************************************/
01051 #define plasma_unpack_args_1( \
01052     arg1) \
01053 { \
01054     unsigned char *plasma_ptr = plasma->args_buff; \
01055     memcpy(&arg1, plasma_ptr, sizeof(arg1)); plasma_ptr += sizeof(arg1); \
01056 }
01057 
01058 #define plasma_unpack_args_2( \
01059     arg1, \
01060     arg2) \
01061 { \
01062     unsigned char *plasma_ptr = plasma->args_buff; \
01063     memcpy(&arg1, plasma_ptr, sizeof(arg1)); plasma_ptr += sizeof(arg1); \
01064     memcpy(&arg2, plasma_ptr, sizeof(arg2)); plasma_ptr += sizeof(arg2); \
01065 }
01066 
01067 #define plasma_unpack_args_3( \
01068     arg1, \
01069     arg2, \
01070     arg3) \
01071 { \
01072     unsigned char *plasma_ptr = plasma->args_buff; \
01073     memcpy(&arg1, plasma_ptr, sizeof(arg1)); plasma_ptr += sizeof(arg1); \
01074     memcpy(&arg2, plasma_ptr, sizeof(arg2)); plasma_ptr += sizeof(arg2); \
01075     memcpy(&arg3, plasma_ptr, sizeof(arg3)); plasma_ptr += sizeof(arg3); \
01076 }
01077 
01078 #define plasma_unpack_args_4( \
01079     arg1, \
01080     arg2, \
01081     arg3, \
01082     arg4) \
01083 { \
01084     unsigned char *plasma_ptr = plasma->args_buff; \
01085     memcpy(&arg1, plasma_ptr, sizeof(arg1)); plasma_ptr += sizeof(arg1); \
01086     memcpy(&arg2, plasma_ptr, sizeof(arg2)); plasma_ptr += sizeof(arg2); \
01087     memcpy(&arg3, plasma_ptr, sizeof(arg3)); plasma_ptr += sizeof(arg3); \
01088     memcpy(&arg4, plasma_ptr, sizeof(arg4)); plasma_ptr += sizeof(arg4); \
01089 }
01090 
01091 #define plasma_unpack_args_5( \
01092     arg1, \
01093     arg2, \
01094     arg3, \
01095     arg4, \
01096     arg5) \
01097 { \
01098     unsigned char *plasma_ptr = plasma->args_buff; \
01099     memcpy(&arg1, plasma_ptr, sizeof(arg1)); plasma_ptr += sizeof(arg1); \
01100     memcpy(&arg2, plasma_ptr, sizeof(arg2)); plasma_ptr += sizeof(arg2); \
01101     memcpy(&arg3, plasma_ptr, sizeof(arg3)); plasma_ptr += sizeof(arg3); \
01102     memcpy(&arg4, plasma_ptr, sizeof(arg4)); plasma_ptr += sizeof(arg4); \
01103     memcpy(&arg5, plasma_ptr, sizeof(arg5)); plasma_ptr += sizeof(arg5); \
01104 }
01105 
01106 #define plasma_unpack_args_6( \
01107     arg1, \
01108     arg2, \
01109     arg3, \
01110     arg4, \
01111     arg5, \
01112     arg6) \
01113 { \
01114     unsigned char *plasma_ptr = plasma->args_buff; \
01115     memcpy(&arg1, plasma_ptr, sizeof(arg1)); plasma_ptr += sizeof(arg1); \
01116     memcpy(&arg2, plasma_ptr, sizeof(arg2)); plasma_ptr += sizeof(arg2); \
01117     memcpy(&arg3, plasma_ptr, sizeof(arg3)); plasma_ptr += sizeof(arg3); \
01118     memcpy(&arg4, plasma_ptr, sizeof(arg4)); plasma_ptr += sizeof(arg4); \
01119     memcpy(&arg5, plasma_ptr, sizeof(arg5)); plasma_ptr += sizeof(arg5); \
01120     memcpy(&arg6, plasma_ptr, sizeof(arg6)); plasma_ptr += sizeof(arg6); \
01121 }
01122 
01123 #define plasma_unpack_args_7( \
01124     arg1, \
01125     arg2, \
01126     arg3, \
01127     arg4, \
01128     arg5, \
01129     arg6, \
01130     arg7) \
01131 { \
01132     unsigned char *plasma_ptr = plasma->args_buff; \
01133     memcpy(&arg1, plasma_ptr, sizeof(arg1)); plasma_ptr += sizeof(arg1); \
01134     memcpy(&arg2, plasma_ptr, sizeof(arg2)); plasma_ptr += sizeof(arg2); \
01135     memcpy(&arg3, plasma_ptr, sizeof(arg3)); plasma_ptr += sizeof(arg3); \
01136     memcpy(&arg4, plasma_ptr, sizeof(arg4)); plasma_ptr += sizeof(arg4); \
01137     memcpy(&arg5, plasma_ptr, sizeof(arg5)); plasma_ptr += sizeof(arg5); \
01138     memcpy(&arg6, plasma_ptr, sizeof(arg6)); plasma_ptr += sizeof(arg6); \
01139     memcpy(&arg7, plasma_ptr, sizeof(arg7)); plasma_ptr += sizeof(arg7); \
01140 }
01141 
01142 #define plasma_unpack_args_8( \
01143     arg1, \
01144     arg2, \
01145     arg3, \
01146     arg4, \
01147     arg5, \
01148     arg6, \
01149     arg7, \
01150     arg8) \
01151 { \
01152     unsigned char *plasma_ptr = plasma->args_buff; \
01153     memcpy(&arg1, plasma_ptr, sizeof(arg1)); plasma_ptr += sizeof(arg1); \
01154     memcpy(&arg2, plasma_ptr, sizeof(arg2)); plasma_ptr += sizeof(arg2); \
01155     memcpy(&arg3, plasma_ptr, sizeof(arg3)); plasma_ptr += sizeof(arg3); \
01156     memcpy(&arg4, plasma_ptr, sizeof(arg4)); plasma_ptr += sizeof(arg4); \
01157     memcpy(&arg5, plasma_ptr, sizeof(arg5)); plasma_ptr += sizeof(arg5); \
01158     memcpy(&arg6, plasma_ptr, sizeof(arg6)); plasma_ptr += sizeof(arg6); \
01159     memcpy(&arg7, plasma_ptr, sizeof(arg7)); plasma_ptr += sizeof(arg7); \
01160     memcpy(&arg8, plasma_ptr, sizeof(arg8)); plasma_ptr += sizeof(arg8); \
01161 }
01162 
01163 #define plasma_unpack_args_9( \
01164     arg1, \
01165     arg2, \
01166     arg3, \
01167     arg4, \
01168     arg5, \
01169     arg6, \
01170     arg7, \
01171     arg8, \
01172     arg9) \
01173 { \
01174     unsigned char *plasma_ptr = plasma->args_buff; \
01175     memcpy(&arg1, plasma_ptr, sizeof(arg1)); plasma_ptr += sizeof(arg1); \
01176     memcpy(&arg2, plasma_ptr, sizeof(arg2)); plasma_ptr += sizeof(arg2); \
01177     memcpy(&arg3, plasma_ptr, sizeof(arg3)); plasma_ptr += sizeof(arg3); \
01178     memcpy(&arg4, plasma_ptr, sizeof(arg4)); plasma_ptr += sizeof(arg4); \
01179     memcpy(&arg5, plasma_ptr, sizeof(arg5)); plasma_ptr += sizeof(arg5); \
01180     memcpy(&arg6, plasma_ptr, sizeof(arg6)); plasma_ptr += sizeof(arg6); \
01181     memcpy(&arg7, plasma_ptr, sizeof(arg7)); plasma_ptr += sizeof(arg7); \
01182     memcpy(&arg8, plasma_ptr, sizeof(arg8)); plasma_ptr += sizeof(arg8); \
01183     memcpy(&arg9, plasma_ptr, sizeof(arg9)); plasma_ptr += sizeof(arg9); \
01184 }
01185 
01186 #define plasma_unpack_args_10( \
01187     arg1, \
01188     arg2, \
01189     arg3, \
01190     arg4, \
01191     arg5, \
01192     arg6, \
01193     arg7, \
01194     arg8, \
01195     arg9, \
01196     arg10) \
01197 { \
01198     unsigned char *plasma_ptr = plasma->args_buff; \
01199     memcpy(&arg1, plasma_ptr, sizeof(arg1)); plasma_ptr += sizeof(arg1); \
01200     memcpy(&arg2, plasma_ptr, sizeof(arg2)); plasma_ptr += sizeof(arg2); \
01201     memcpy(&arg3, plasma_ptr, sizeof(arg3)); plasma_ptr += sizeof(arg3); \
01202     memcpy(&arg4, plasma_ptr, sizeof(arg4)); plasma_ptr += sizeof(arg4); \
01203     memcpy(&arg5, plasma_ptr, sizeof(arg5)); plasma_ptr += sizeof(arg5); \
01204     memcpy(&arg6, plasma_ptr, sizeof(arg6)); plasma_ptr += sizeof(arg6); \
01205     memcpy(&arg7, plasma_ptr, sizeof(arg7)); plasma_ptr += sizeof(arg7); \
01206     memcpy(&arg8, plasma_ptr, sizeof(arg8)); plasma_ptr += sizeof(arg8); \
01207     memcpy(&arg9, plasma_ptr, sizeof(arg9)); plasma_ptr += sizeof(arg9); \
01208     memcpy(&arg10, plasma_ptr, sizeof(arg10)); plasma_ptr += sizeof(arg10); \
01209 }
01210 #endif
 All Data Structures