Changeset 3263 in Sophya for trunk/SophyaProg
- Timestamp:
- Jun 11, 2007, 6:56:30 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaProg/Tests/zthr.cc
r3253 r3263 8 8 #include "tmatrix.h" 9 9 #include "tvector.h" 10 #include "matharr.h" 10 11 #include "tarrinit.h" 11 12 … … 17 18 SOPHYA::ZThread SOPHYA::ZMutex ... 18 19 Exemples d'execution 19 csh> time zthr mtx 2 500 20 csh> time zthr mtx 2 500 20 21 csh> time zthr arr 2 500 22 csh> time zthr arrdl 2 500 23 csh> time zthr arrmf 2 500 21 24 csh> time zthr sync 4 1000 25 csh> time zthr syncp 4 1000 22 26 */ 23 27 … … 74 78 return; 75 79 } 76 // --- fonction de test simple avec calcul sur tableaux 80 // --- fonction de test simple avec calcul sur tableaux entier I4 77 81 void arr_funzt(void *arg) 78 82 { … … 90 94 ares = (4*a1)+(12*a2); 91 95 sprintf(buff, "arr-funzt(ThId=%d) EndOfOper", za->thid); 96 PrtTim(buff); 97 return; 98 } 99 // --- fonction de test simple avec calcul de type DL sur tableaux double 1D 100 void arrdl_funzt(void *arg) 101 { 102 ztarg * za = (ztarg *)arg; 103 sa_size_t vsz = za->M*za->M; 104 105 cout << ">>>> arrdl-funzt(ThId=" << za->thid << " VecSz=M*M " << vsz 106 << " V2=DLO4(V1) , NOp ~= 10*vsz=" << 10*vsz << endl; 107 108 TVector<r_8> v1(vsz), v2(vsz); 109 v1 = RegularSequence(1.,0.001); 110 char buff[128]; 111 sprintf(buff, "arrdl-funzt(ThId=%d) EndOfInit", za->thid); 112 PrtTim(buff); 113 for(sa_size_t i=0; i<vsz; i++) { 114 double x = v1(i); 115 v2(i) = x*(1+x*(x/2.+x*(x/6.+x*x/24.))); 116 } 117 sprintf(buff, "arrdl-funzt(ThId=%d) EndOfOper", za->thid); 118 PrtTim(buff); 119 return; 120 } 121 // --- fonction de test simple avec calcul de type fonction mathematique sur tableaux double 1D 122 void arrmf_funzt(void *arg) 123 { 124 ztarg * za = (ztarg *)arg; 125 sa_size_t vsz = za->M*za->M; 126 127 cout << ">>>> arrmf-funzt(ThId=" << za->thid << " VecSz=M*M " << vsz 128 << " V2=Sin(V1) , NOp ~= 10*vsz=" << 10*vsz << endl; 129 130 TVector<r_8> v1(vsz), v2(vsz); 131 v1 = RegularSequence(1.,0.001); 132 char buff[128]; 133 sprintf(buff, "arrmf-funzt(ThId=%d) EndOfInit", za->thid); 134 PrtTim(buff); 135 v2 = Sin(v1); 136 137 sprintf(buff, "arrmf-funzt(ThId=%d) EndOfOper", za->thid); 92 138 PrtTim(buff); 93 139 return; … … 329 375 cout << " Usage: zthr select N LM [Sz] " << endl; 330 376 cout << " select= sl -> simple loop with sleep " << endl; 331 cout << " select= mtx -> matrix init and multiply mx1*mx2" << endl; 332 cout << " select= arr -> array/matrix init and operation c1*a1+c2*a2 " << endl; 377 cout << " select= mtx -> matrix<r_8> init and multiply mx1*mx2" << endl; 378 cout << " select= arr -> array/matrix<int_4> init and operation c1*a1+c2*a2 " << endl; 379 cout << " select= arrdl -> vectorOpe V2 ~= DLO4(V1), VSz=LM*LM " << endl; 380 cout << " select= arrmf -> vectorOpe V2 = Sin(V1), VSz=LM*LM " << endl; 333 381 cout << " select= clk -> Mutex lock count " << endl; 334 382 cout << " select= sync -> Thread synchronisation using ZMutex" << endl; … … 342 390 string sel = arg[1]; 343 391 if ((sel != "sl") && (sel != "mtx") && (sel != "arr") && 392 (sel != "arrdl") && (sel != "arrmf") && 344 393 (sel != "sync") && (sel != "syncp") && (sel != "clk")) { 345 394 cout << "zthr/erreur argument sel (!= sl / mtx / arr / clk) " << endl; … … 361 410 try { 362 411 ResourceUsage res(ResourceUsage::RU_All); 363 if ((sel == "mtx") || (sel == "arr") || (sel == "sl") || (sel == "sync") || (sel == "syncp")) { 412 if ((sel == "mtx") || (sel == "arr") || (sel == "sl") || 413 (sel == "arrdl") || (sel == "arrmf") || 414 (sel == "sync") || (sel == "syncp")) { 364 415 if ( (sel == "sync") || (sel == "syncp")) mtvp = new MTVecPool(N,VSZ,M); 365 416 vector<ztarg *> vza; … … 376 427 if (sel == "mtx") pzt->setAction(mtx_funzt, vza[i]); 377 428 else if (sel == "arr") pzt->setAction(arr_funzt, vza[i]); 429 else if (sel == "arrdl") pzt->setAction(arrdl_funzt, vza[i]); 430 else if (sel == "arrmf") pzt->setAction(arrmf_funzt, vza[i]); 378 431 else if (sel == "sync") pzt->setAction(sync_funzt, vza[i]); 379 432 else if (sel == "syncp") pzt->setAction(syncp_funzt, vza[i]);
Note:
See TracChangeset
for help on using the changeset viewer.